/* AntMind - app styles. Dark: glass. Light: paper & ink. Inter only, weights 400/500/600. */

:root {
  --font: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --canvas: #0f1217;
  --bg: #0b0e13;
  --card: rgba(255, 255, 255, 0.06);
  --card-solid: #171b24;
  --glass: rgba(18, 22, 30, 0.78);
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: rgba(255, 255, 255, 0.18);
  --ink: #e8eaf0;
  --ink-2: #b4bac6;
  --ink-3: #8a90a2;
  --accent: #4f7cf5;
  --accent-soft: rgba(79, 124, 245, 0.18);
  --danger: #f0665e;
  --warn: #f2a53b;
  --root-fill: #e8eaf0;
  --root-text: #0f1217;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --blur: blur(18px);
  --radius: 12px;
  --topbar-h: 48px;
  --maps-w: 0px;
  --side-w: 0px;
  --mobilebar-h: 0px;
  --grid: radial-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1px);
  color-scheme: dark;
}
html[data-theme="light"] {
  --canvas: #f6f6f4;
  --bg: #ffffff;
  --card: #ffffff;
  --card-solid: #ffffff;
  --glass: rgba(255, 255, 255, 0.92);
  --line: #e4e4e0;
  --line-strong: #cfcfca;
  --ink: #1a1d24;
  --ink-2: #4c5160;
  --ink-3: #7a8090;
  --accent: #3b6ef0;
  --accent-soft: rgba(59, 110, 240, 0.12);
  --root-fill: #1f2430;
  --root-text: #ffffff;
  --shadow: 0 8px 24px rgba(20, 24, 40, 0.12);
  --blur: none;
  --grid: radial-gradient(rgba(0, 0, 0, 0.08) 1px, transparent 1px);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.4;
  color: var(--ink);
  background: var(--bg);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
[hidden] { display: none !important; }
.spacer { flex: 1; }
.muted { color: var(--ink-3); }
svg.ic { width: 18px; height: 18px; display: block; flex: none; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- layout ---------- */
.app {
  display: grid;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-columns: var(--maps-w) 1fr var(--side-w);
  height: 100dvh;
  width: 100vw;
  padding-top: env(safe-area-inset-top);
}
.app.maps-open { --maps-w: 280px; }
.app.side-open { --side-w: 330px; }
.topbar { grid-row: 1; grid-column: 1 / -1; }
.maps-panel { grid-row: 2; grid-column: 1; }
.stage { grid-row: 2; grid-column: 2; }
.side-panel { grid-row: 2; grid-column: 3; }
.maps-panel, .side-panel { min-width: 0; overflow: hidden; display: flex; flex-direction: column; background: var(--bg); border-right: 1px solid var(--line); }
.side-panel { border-right: 0; border-left: 1px solid var(--line); }
.app:not(.maps-open) .maps-panel { display: none; }
.app:not(.side-open) .side-panel { display: none; }

/* ---------- topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border-bottom: 1px solid var(--line);
  background: var(--glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  z-index: 20;
}
.tb-group { display: flex; align-items: center; gap: 2px; min-width: 0; }
.tb-left { flex: 1 1 0; }
.tb-center { flex: 0 0 auto; justify-content: center; }
.tb-right { flex: 1 1 0; justify-content: flex-end; }
.brand { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 14px; padding: 0 6px; }
.brand-mark .ic { width: 20px; height: 20px; color: var(--accent); }
.map-title { font-size: 13px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 6px; border-left: 1px solid var(--line); margin-left: 4px; }
.tb-sep { width: 1px; height: 20px; background: var(--line); margin: 0 6px; }
.tb {
  position: relative;
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 8px; background: transparent; color: var(--ink-2);
}
.tb:hover { background: var(--card); color: var(--ink); }
.tb.on, .tb[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.tb:disabled { opacity: 0.35; pointer-events: none; }
.tb.sync[data-state="signed-out"], .tb.sync[data-state="error"] { color: var(--warn); }
.tb.sync[data-state="synced"] { color: #2fb57c; }
.zoom-label { width: auto; min-width: 48px; padding: 0 6px; font-size: 12px; font-weight: 500; }

@media (hover: hover) {
  [data-tip]:hover::after {
    content: attr(data-tip);
    position: absolute; left: 50%; top: calc(100% + 6px); transform: translateX(-50%);
    background: var(--card-solid); color: var(--ink); border: 1px solid var(--line-strong);
    padding: 4px 8px; border-radius: 6px; font-size: 11.5px; font-weight: 500; white-space: nowrap;
    box-shadow: var(--shadow); z-index: 100; pointer-events: none;
  }
  .zoombar [data-tip]:hover::after, .mobilebar [data-tip]:hover::after { top: auto; bottom: calc(100% + 6px); }
}

/* ---------- stage ---------- */
.stage {
  position: relative; overflow: hidden; outline: none;
  background-color: var(--canvas);
  background-image: var(--grid);
  background-size: 24px 24px;
  touch-action: none;
  cursor: default;
  user-select: none; -webkit-user-select: none;
}
.stage.dragging { cursor: grabbing; }
.stage.space-pan { cursor: grab; }
.stage.space-pan:active { cursor: grabbing; }
.stage.marquee-on { cursor: crosshair; }
.marquee { position: absolute; border: 1px solid var(--accent); background: var(--accent-soft); border-radius: 2px; pointer-events: none; z-index: 3; }
.stage.mode-relation { cursor: crosshair; }
.stage.drop-files::after { content: "Drop to import"; position: absolute; inset: 12px; border: 2px dashed var(--accent); border-radius: 16px; display: flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 500; color: var(--accent); background: var(--accent-soft); pointer-events: none; }
.world { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.world.animate { transition: transform 0.45s cubic-bezier(0.2, 0.8, 0.2, 1); }
.edges { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: visible; }
.nodes { position: absolute; left: 0; top: 0; }

.edge { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.edge.dim { opacity: 0.12; }
.axis { fill: none; stroke: var(--ink-3); stroke-width: 2; color: var(--ink-3); }
.bound { fill: color-mix(in srgb, var(--bc) 9%, transparent); stroke: var(--bc); stroke-width: 1.3; stroke-dasharray: 6 4; }
.bound-title { fill: var(--bc); font-family: var(--font); font-size: 12px; font-weight: 500; }
.brace { fill: none; stroke-width: 1.6; stroke-linecap: round; }
.rel { color: var(--ink-3); }
.rel-hit { fill: none; stroke: transparent; stroke-width: 16; pointer-events: stroke; cursor: pointer; }
.rel-line { fill: none; stroke: currentColor; stroke-width: 1.5; stroke-dasharray: 6 5; pointer-events: none; }
.rel.sel { color: var(--accent); }
.rel.sel .rel-line { stroke-width: 2.2; }
.rel-label { fill: currentColor; font-family: var(--font); font-size: 12px; font-weight: 500; pointer-events: none; }
.dim { opacity: 0.12; }

/* ---------- topics ---------- */
.topic {
  position: absolute; left: 0; top: 0;
  display: flex; flex-direction: column; align-items: flex-start;
  padding: 6px 12px;
  border-radius: 10px;
  width: max-content;
  max-width: 280px;
  font-size: 13px; line-height: 1.38; font-weight: 400;
  color: var(--ink);
  --c: var(--root-fill); --ct: var(--root-text);
  cursor: default;
  user-select: none; -webkit-user-select: none;
  transition: box-shadow 0.12s;
}
.topic.lvl-0 { font-size: 17px; font-weight: 600; padding: 10px 18px; max-width: 340px; }
.topic.lvl-1 { font-size: 14px; font-weight: 500; padding: 7px 14px; }
.topic.fs-s { font-size: 12px; }
.topic.fs-l { font-size: 16px; }
.topic.lvl-0.fs-s { font-size: 14px; }
.topic.lvl-0.fs-l { font-size: 22px; }
.topic.bold { font-weight: 600; }
.topic.italic { font-style: italic; }
.fill-filled { background: var(--c); color: var(--ct); }
.fill-soft { background: color-mix(in srgb, var(--c) 18%, transparent); }
.fill-outline { background: var(--card-solid); border: 1.6px solid var(--c); color: var(--c); }
.fill-line { background: transparent; border-bottom: 2.2px solid var(--c); border-radius: 0 !important; padding-left: 6px; padding-right: 6px; }
.fill-none { background: transparent; }
.geo-pill { border-radius: 999px; }
.geo-rect { border-radius: 3px; }
.topic.summary { border: 1.5px dashed var(--c); background: color-mix(in srgb, var(--c) 10%, transparent); font-size: 12.5px; }
.topic.floating.lvl-1 { outline: 1px dashed var(--line-strong); outline-offset: 3px; }
.topic.sel { box-shadow: 0 0 0 2px var(--canvas), 0 0 0 4px var(--accent); }
.topic.hit:not(.sel) { box-shadow: 0 0 0 2px var(--canvas), 0 0 0 4px var(--warn); }
.topic.editing { box-shadow: 0 0 0 2px var(--canvas), 0 0 0 4px var(--accent), var(--shadow); }
.topic.dragging { opacity: 0.35; }
.topic.drop-child { box-shadow: 0 0 0 3px var(--accent); }
.topic.drop-sibling { box-shadow: 0 5px 0 0 var(--accent); }
.topic.ghost { position: fixed; z-index: 1000; pointer-events: none; opacity: 0.85; transform-origin: top left; box-shadow: var(--shadow); }
.t-row { display: flex; align-items: center; gap: 6px; max-width: 100%; }
.t-text { white-space: pre-wrap; overflow-wrap: anywhere; min-width: 1ch; outline: none; }
.t-text.empty { min-width: 60px; }
.t-text.empty::before { content: "New topic"; opacity: 0.45; }
.editing .t-text { cursor: text; user-select: text; -webkit-user-select: text; touch-action: auto; }
.editing .t-text.empty::before { content: none; }
.t-num { font-weight: 600; opacity: 0.8; flex: none; }
.t-marks { display: inline-flex; gap: 3px; flex: none; }
.mk { width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; font-size: 11px; font-weight: 600; flex: none; }
.mk-p { background: var(--mc); color: #fff; }
.mk svg { width: 18px; height: 18px; display: block; }
.mk-pg { color: var(--accent); }
.fill-filled .mk-pg { color: var(--ct); }
.t-ind { display: inline-flex; gap: 4px; flex: none; opacity: 0.75; }
.ind { display: inline-flex; cursor: pointer; }
.ind .ic { width: 14px; height: 14px; }
.t-labels { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.lb { font-size: 11.5px; font-weight: 500; padding: 1px 8px; border-radius: 999px; background: color-mix(in srgb, var(--c) 22%, transparent); color: inherit; }
.fill-filled .lb { background: rgba(255, 255, 255, 0.22); }
.t-img { display: block; border-radius: 6px; margin-bottom: 6px; object-fit: cover; max-width: 100%; }
.t-badge {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 20px; height: 20px; border-radius: 50%;
  border: 1.5px solid var(--c); background: var(--canvas); color: var(--ink);
  font-size: 11px; font-weight: 600; display: flex; align-items: center; justify-content: center; padding: 0;
}
.topic[data-dir="1"] .t-badge { right: -26px; }
.topic[data-dir="-1"] .t-badge { left: -26px; }
.topic[data-kind="v"] .t-badge { top: auto; bottom: -24px; left: 50%; right: auto; transform: translateX(-50%); }
.lvl-0 .t-badge { display: none; }

/* ---------- zoombar / banner ---------- */
.zoombar {
  position: absolute; right: 14px; bottom: calc(14px + var(--mobilebar-h) + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 2px; padding: 4px;
  background: var(--glass); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); z-index: 5;
}
.banner {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px; padding: 8px 14px;
  background: var(--glass); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--line-strong); border-radius: 999px; box-shadow: var(--shadow);
  font-size: 12.5px; color: var(--ink-2); z-index: 6; max-width: calc(100% - 24px);
}

/* ---------- buttons & fields ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: 8px; border: 1px solid var(--line-strong);
  background: var(--card); color: var(--ink); font-weight: 500; font-size: 12.5px;
}
.btn:hover { border-color: var(--ink-3); }
.btn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 50%, transparent); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn .ic { width: 16px; height: 16px; }
input[type="text"], input[type="search"], input[type="url"], input[type="number"], textarea, select {
  width: 100%; padding: 7px 10px; border-radius: 8px; border: 1px solid var(--line-strong);
  background: var(--card); color: var(--ink); font-size: 13px; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; min-height: 72px; line-height: 1.45; }
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--ink-3); margin-bottom: 10px; }
.field.inline { flex: 1; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink); }
.row { display: flex; align-items: center; gap: 6px; }
.row.wrap { flex-wrap: wrap; }
.seg { display: inline-flex; gap: 2px; padding: 2px; border-radius: 8px; background: var(--card); border: 1px solid var(--line); }
.seg.wrap { flex-wrap: wrap; }
.seg-b { padding: 4px 9px; border: 0; border-radius: 6px; background: transparent; color: var(--ink-2); font-size: 12px; font-weight: 500; }
.seg-b.on { background: var(--accent-soft); color: var(--accent); }
.swatches-row { display: flex; flex-wrap: wrap; gap: 6px; }
.sw { position: relative; width: 24px; height: 24px; border-radius: 50%; border: 2px solid transparent; background: var(--sw, var(--card)); padding: 0; display: inline-flex; align-items: center; justify-content: center; color: var(--ink-3); }
.sw.on { border-color: var(--ink); box-shadow: 0 0 0 2px var(--bg) inset; }
.sw.custom { overflow: hidden; }
.sw.custom input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.sw .ic { width: 14px; height: 14px; }
.kv { display: flex; justify-content: space-between; padding: 4px 0; font-size: 12.5px; color: var(--ink-2); }
.kv b { font-weight: 500; color: var(--ink); }

/* ---------- panels ---------- */
.panel-head { display: flex; align-items: center; gap: 4px; height: 48px; padding: 0 8px 0 14px; border-bottom: 1px solid var(--line); flex: none; }
.panel-title { font-weight: 600; font-size: 14px; }
.panel-head.tabs { padding-left: 6px; }
.tab { padding: 6px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--ink-3); font-weight: 500; font-size: 13px; }
.tab.active { color: var(--ink); background: var(--card); }
.panel-body { flex: 1; overflow: auto; padding: 12px 14px 24px; }
.panel-search { position: relative; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.panel-search input { padding-left: 32px; }
.ps-ic { position: absolute; left: 20px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.ps-ic .ic { width: 16px; height: 16px; }
.maps-list { flex: 1; overflow: auto; padding: 8px; }
.map-item { display: flex; align-items: center; gap: 6px; padding: 8px 6px 8px 12px; border-radius: 10px; cursor: pointer; }
.map-item:hover { background: var(--card); }
.map-item.active { background: var(--accent-soft); }
.mi-main { flex: 1; min-width: 0; }
.mi-title { font-weight: 500; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mi-meta { font-size: 11.5px; color: var(--ink-3); }
.mi-more { opacity: 0; }
.map-item:hover .mi-more, .map-item.active .mi-more { opacity: 1; }
@media (hover: none) { .mi-more { opacity: 1; } }
.empty { padding: 24px 12px; color: var(--ink-3); text-align: center; font-size: 12.5px; }
.sec { padding: 10px 0 12px; border-bottom: 1px solid var(--line); }
.sec:last-child { border-bottom: 0; }
.sec-title { font-size: 11.5px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 8px; }
.sec-label { font-size: 12px; color: var(--ink-3); margin: 10px 0 6px; }
.mk-grid { display: flex; flex-wrap: wrap; gap: 4px; }
.mk-btn { width: 30px; height: 30px; border-radius: 8px; border: 1px solid transparent; background: transparent; display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.mk-btn:hover { background: var(--card); }
.mk-btn.on { background: var(--accent-soft); border-color: var(--accent); }
.mk-btn .mk-pg { color: var(--ink-2); }
.theme-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.theme-card { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font-size: 12px; font-weight: 500; }
.theme-card.on { border-color: var(--accent); background: var(--accent-soft); }
.swatches { display: inline-flex; gap: 3px; }
.swatches i { width: 12px; height: 12px; border-radius: 50%; display: block; }
.f-img { max-width: 120px; max-height: 80px; border-radius: 6px; object-fit: cover; }

/* outline */
.outline .ol-list { display: flex; flex-direction: column; gap: 1px; }
.ol-row { display: flex; align-items: center; gap: 4px; padding: 3px 8px 3px calc(6px + var(--d) * 18px); border-radius: 6px; font-size: 13px; }
.ol-row.sel { background: var(--accent-soft); }
.ol-row.float { border-top: 1px dashed var(--line); margin-top: 6px; padding-top: 8px; }
.ol-row[style*="--d:0"] { font-weight: 600; }
.ol-tog { width: 18px; height: 18px; border: 0; background: transparent; color: var(--ink-3); padding: 0; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.ol-tog .ic { width: 14px; height: 14px; transition: transform 0.12s; }
.ol-tog.closed .ic { transform: rotate(-90deg); }
.ol-tog.leaf { visibility: hidden; }
.ol-text { flex: 1; min-width: 0; outline: none; padding: 2px 4px; border-radius: 4px; white-space: pre-wrap; overflow-wrap: anywhere; }
.ol-text:focus { background: var(--card); }
.ol-badge { font-size: 11px; color: var(--ink-3); background: var(--card); border-radius: 999px; padding: 0 6px; }
.ol-ic { color: var(--ink-3); }
.ol-ic .ic { width: 14px; height: 14px; }
.ol-hint { margin-top: 14px; font-size: 11.5px; color: var(--ink-3); }

/* ---------- search bar ---------- */
.search-bar {
  position: fixed; top: calc(var(--topbar-h) + 10px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 4px; padding: 6px 8px;
  background: var(--glass); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: var(--shadow); z-index: 30; width: min(720px, calc(100% - 24px));
}
.search-bar .ps-ic { left: 16px; }
.search-bar input { padding-left: 30px; }
.search-bar #replace-input { padding-left: 10px; }
.search-count { font-size: 12px; color: var(--ink-3); min-width: 40px; text-align: center; }

/* ---------- menus ---------- */
.layer { position: fixed; inset: 0; pointer-events: none; z-index: 40; }
.layer > * { pointer-events: auto; }
.menu {
  position: fixed; min-width: 230px; max-width: 360px; max-height: calc(100vh - 24px); overflow: auto;
  padding: 6px; border-radius: 12px; background: var(--glass); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--line-strong); box-shadow: var(--shadow);
}
.menu.wide { max-width: 420px; }
.menu.sheet { left: 0 !important; right: 0; top: auto !important; bottom: 0; max-width: none; border-radius: 16px 16px 0 0; max-height: 72vh; padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
.menu-title { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-3); padding: 6px 10px 4px; }
.menu-note { font-size: 12px; color: var(--warn); padding: 6px 10px; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--ink); text-align: left; font-size: 13px; }
.menu-item:hover { background: var(--card); }
.menu-item.checked { color: var(--accent); }
.menu-item.danger { color: var(--danger); }
.mi-ic { width: 18px; display: inline-flex; justify-content: center; color: var(--ink-3); flex: none; }
.menu-item.checked .mi-ic { color: var(--accent); }
.mi-l { flex: 1; }
.mi-h { font-size: 11.5px; color: var(--ink-3); }
.mi-c .ic { width: 16px; height: 16px; }
.menu-sep { height: 1px; background: var(--line); margin: 5px 4px; }
.markers { padding: 2px 4px; }
.mk-group { margin-bottom: 8px; }
.mk-title { font-size: 11.5px; color: var(--ink-3); margin-bottom: 3px; }

/* ---------- dialogs / toasts / busy ---------- */
.dialog-back { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.dialog { width: 440px; max-width: 100%; max-height: calc(100vh - 32px); display: flex; flex-direction: column; border-radius: 16px; background: var(--card-solid); border: 1px solid var(--line-strong); box-shadow: var(--shadow); }
.dialog.wide { width: 680px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 10px 12px 18px; font-weight: 600; font-size: 14px; border-bottom: 1px solid var(--line); }
.dialog-body { padding: 16px 18px; overflow: auto; font-size: 13px; }
.dialog-body p { margin: 0 0 8px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px 16px; }
.keys { width: 100%; border-collapse: collapse; }
.keys td { padding: 5px 8px 5px 0; vertical-align: top; border-bottom: 1px solid var(--line); font-size: 12.5px; }
kbd { font-family: var(--font); font-size: 12px; font-weight: 500; padding: 1px 6px; border-radius: 5px; background: var(--card); border: 1px solid var(--line-strong); white-space: nowrap; }
.hist-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.hist-row span:first-child { font-weight: 600; min-width: 40px; }
.hist-row .muted { flex: 1; }
.toasts { position: fixed; left: 50%; bottom: calc(20px + var(--mobilebar-h) + env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; z-index: 60; pointer-events: none; }
.toast { padding: 8px 14px; border-radius: 10px; background: var(--card-solid); border: 1px solid var(--line-strong); box-shadow: var(--shadow); font-size: 12.5px; font-weight: 500; animation: toast-in 0.2s ease; }
.toast.out { opacity: 0; transition: opacity 0.3s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
.busy { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-radius: 12px; background: var(--card-solid); border: 1px solid var(--line-strong); box-shadow: var(--shadow); font-weight: 500; z-index: 55; }

/* ---------- mobile bar ---------- */
.mobilebar { display: none; }
.app.narrow { --mobilebar-h: 58px; }
.app.narrow .mobilebar {
  display: grid; grid-template-columns: repeat(6, 1fr); position: fixed; left: 0; right: 0; bottom: 0;
  height: calc(var(--mobilebar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--glass); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); border-top: 1px solid var(--line); z-index: 25;
}
.mb { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border: 0; background: transparent; color: var(--ink-2); font-size: 10.5px; font-weight: 500; }
.mb:active { color: var(--accent); }
.mb-ic .ic { width: 22px; height: 22px; }

/* ---------- narrow screens ---------- */
@media (max-width: 859px) {
  .app { grid-template-columns: 1fr; }
  .app.maps-open { --maps-w: 0px; }
  .app.side-open { --side-w: 0px; }
  .maps-panel, .side-panel { position: fixed; top: calc(var(--topbar-h) + env(safe-area-inset-top)); bottom: 0; width: min(360px, 92vw); z-index: 30; box-shadow: var(--shadow); }
  .maps-panel { left: 0; }
  .side-panel { right: 0; padding-bottom: calc(var(--mobilebar-h) + env(safe-area-inset-bottom)); }
  .app.maps-open .maps-panel, .app.side-open .side-panel { display: flex; }
  .tb-center { display: none; }
  .map-title { display: none; }
  .brand-name { display: none; }
  .tb-right [data-cmd="pitch"], .tb-right [data-cmd="zen"], .tb-right [data-cmd="help"], .tb-right [data-cmd="uitheme"], .tb-right [data-cmd="menu:export"] { display: none; }
  .stage { padding-bottom: 0; }
  .zoombar [data-cmd="zoom-reset"] { display: none; }
  .search-bar #replace-input, .search-bar [data-cmd="search-replace"] { display: none; }
  .theme-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 859px) and (pointer: coarse) {
  .tb { width: 36px; height: 36px; }
}

/* ---------- modes ---------- */
body.zen .topbar, body.zen .maps-panel, body.zen .side-panel, body.zen .mobilebar, body.zen .search-bar, body.zen .banner { display: none !important; }
body.zen .app { grid-template-rows: 0 1fr; --maps-w: 0px; --side-w: 0px; --mobilebar-h: 0px; }
body.pitch .topbar, body.pitch .maps-panel, body.pitch .side-panel, body.pitch .mobilebar, body.pitch .search-bar, body.pitch .banner, body.pitch .zoombar { display: none !important; }
body.pitch .app { grid-template-rows: 0 1fr; --maps-w: 0px; --side-w: 0px; --mobilebar-h: 0px; }
body.pitch .stage { background-image: none; }
.pitch-overlay { position: absolute; inset: 0; z-index: 4; cursor: pointer; }
.pitch-bar {
  position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: flex; align-items: center; gap: 6px; padding: 6px 8px; min-width: 280px; max-width: calc(100% - 24px);
  background: var(--glass); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); border: 1px solid var(--line-strong); border-radius: 999px; box-shadow: var(--shadow); z-index: 45;
}
.pitch-count { font-size: 12px; font-weight: 500; color: var(--ink-3); min-width: 48px; text-align: center; }
.pitch-label { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; padding: 0 8px; }

@media print {
  .topbar, .maps-panel, .side-panel, .mobilebar, .zoombar, .banner, .search-bar, .layer, .toasts { display: none !important; }
}
