/* Smartypants canvas: a staff-engineer whiteboard on an infinite dotted canvas. */
:root {
  color-scheme: light;
  --font: "Inter", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Liberation Sans", sans-serif;
  --mono: "SF Mono", ui-monospace, "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --canvas: #f4f5f8;
  --grid: rgba(15, 23, 42, 0.11);
  --sheet: #ffffff;
  --sheet-line: #e3e6ec;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --faint: #94a3b8;
  --line: #e2e8f0;
  --accent: #4f46e5;
  --accent-ink: #3730a3;
  --accent-soft: #eef2ff;
  --box: #ffffff;
  --box-line: #c3c8d9;
  --edge: #64748b;
  --control: #7c3aed;
  --drift: #dc2626;
  --drift-soft: #fef2f2;
  --zone: #6b9ae0;
  --zone-ink: #2f5c9c;
  --zone-fill: rgba(59, 130, 246, 0.035);
  --frame: #fdfbf2;
  --frame-line: #e3d59f;
  --frame-ink: #8a6a12;
  --panel: #ffffff;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 1px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12), 0 2px 6px rgba(15, 23, 42, 0.06);
  font-family: var(--font);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--canvas);
  color: var(--ink);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#boot, .serve-help {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 32px;
  text-align: center;
}
.serve-help { max-width: 640px; margin: 0 auto; }
.serve-help h1, #boot { font-weight: 600; font-size: 1.6rem; }
.serve-help p { color: var(--muted); line-height: 1.5; }
code, kbd {
  font-family: var(--mono);
  background: #f1f3f7;
  padding: 0.1em 0.35em;
  border-radius: 4px;
  font-size: 0.9em;
}
kbd { border: 1px solid var(--line); border-bottom-width: 2px; font-size: 11px; color: var(--muted); background: #fff; }

/* ---- canvas ---------------------------------------------------------------- */

#viewport {
  position: fixed;
  inset: 0;
  touch-action: none;
  cursor: default;
  background-color: var(--canvas);
  background-image: radial-gradient(circle, var(--grid) 1px, transparent 1.3px);
}
#viewport.is-panning, #viewport.is-moving { cursor: grabbing; }
#viewport.is-over { cursor: pointer; }

#surface { position: absolute; inset: 0; width: 100%; height: 100%; display: block; overflow: visible; }
#surface text { font-family: var(--font); }

/* the sheet the system sits on */
.system-sheet { fill: var(--sheet); stroke: none; pointer-events: none; filter: drop-shadow(0 1px 3px rgba(15, 23, 42, 0.06)); }
.system-frame { fill: none; stroke: var(--sheet-line); stroke-width: 1; pointer-events: none; }
.system-hit { fill: none; stroke: transparent; stroke-width: 14; pointer-events: stroke; cursor: grab; }
.system-hit:hover { stroke: rgba(148, 163, 184, 0.25); }

/* nodes */
.node { cursor: pointer; }
.node .box { fill: var(--box); stroke: var(--box-line); stroke-width: 1.25; filter: drop-shadow(0 1px 1.5px rgba(15, 23, 42, 0.07)); transition: stroke 0.12s, stroke-width 0.12s; }
.node .rule { stroke: var(--box-line); stroke-width: 1; }
.node:hover .box, .node.is-lit .box { stroke: #8b93b8; stroke-width: 1.75; }
.node .label { fill: var(--ink); font-size: 16px; font-weight: 600; dominant-baseline: central; pointer-events: none; letter-spacing: -0.005em; }
.node .blurb { fill: var(--muted); font-size: 13px; dominant-baseline: central; pointer-events: none; }
.lod-tiny .node .blurb, .lod-tiny .node .head-blurb { display: none; }

.node.shape-gateway .box { fill: #f2f7ff; stroke: #8fb0e3; }
.node.shape-client .box { fill: #f7f8fa; stroke: #b6bdca; }
.node.shape-queue .box { fill: #effaf4; stroke: #74c29b; }
.node.shape-store .box { fill: #f3f6fd; stroke: #94a8d2; }
.node.tier-storage.shape-store .box { fill: #faf7f0; stroke: #c8b388; }
.node.shape-cache .box { fill: #fffaeb; stroke: #deb455; }
.node.shape-external .box { fill: #f8f9fb; stroke: #a1a9b8; stroke-dasharray: 5 3; }
.node.shape-worker .rule { stroke: #c3c8d9; }

.node.is-drift .box { fill: var(--drift-soft); stroke: var(--drift); stroke-width: 1.75; }
.node.is-selected .box { stroke: var(--accent); stroke-width: 2.5; }
.node.is-fresh .box { animation: pulse 1.4s ease-out 1; }
@keyframes pulse { 0% { stroke: #16a34a; stroke-width: 6px; } 100% { stroke-width: 1.25px; } }

/* system title */
.node.kind-system .box { fill: transparent; stroke: none; filter: none; }
.node.kind-system:hover .box { fill: rgba(79, 70, 229, 0.05); stroke: none; }
.node.kind-system.is-selected .box { fill: var(--accent-soft); stroke: none; }
.node .title { fill: var(--ink); font-size: 20px; font-weight: 700; letter-spacing: -0.01em; pointer-events: none; }
.node .subtitle { fill: var(--muted); font-size: 13px; pointer-events: none; }

/* subgraph title panel */
.node.is-header .box { fill: transparent; stroke: none; filter: none; }
.node.is-header:hover .box, .node.is-header.is-lit .box { fill: rgba(227, 213, 159, 0.18); stroke: none; }
.node.is-header.is-selected .box { fill: rgba(79, 70, 229, 0.06); stroke: none; }
.node.is-header.is-drift .box { fill: rgba(220, 38, 38, 0.05); stroke: none; }
.node .head-name { fill: var(--ink); font-size: 16px; font-weight: 700; dominant-baseline: central; pointer-events: none; }
.node .head-blurb { fill: var(--muted); font-size: 13px; dominant-baseline: central; pointer-events: none; }
.node .head-meta { fill: var(--frame-ink); font-size: 11px; font-weight: 700; letter-spacing: 0.08em; dominant-baseline: central; pointer-events: none; }

/* unmapped drift cards */
.node.kind-unmapped .box { fill: var(--drift-soft); stroke: var(--drift); stroke-dasharray: 6 4; stroke-width: 1.5; }
.node .card-title { fill: var(--drift); font-size: 13px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; pointer-events: none; }
.node .card-line { fill: var(--ink); font-size: 13px; pointer-events: none; }
.node .card-code { fill: #9f1d1d; font-size: 13px; pointer-events: none; }

.badge text { font-size: 11px; font-weight: 700; text-anchor: middle; dominant-baseline: central; fill: #fff; pointer-events: none; }
.drift-badge circle { fill: var(--drift); stroke: #fff; stroke-width: 2; }
.notes-badge circle { fill: #e7e9f3; stroke: #fff; stroke-width: 1.5; }
.notes-badge text { fill: var(--accent-ink); font-size: 10px; font-style: italic; font-family: Georgia, serif; }
.more-badge rect { fill: var(--accent); stroke: #fff; stroke-width: 1.5; }

/* arrows */
.edge { cursor: pointer; transition: opacity 0.15s; }
.edge .hit { fill: none; stroke: transparent; stroke-width: 16px; }
.edge .line { fill: none; stroke: var(--edge); stroke-width: 1.5; stroke-linejoin: round; }
.edge .head { fill: var(--edge); stroke: none; }
.edge.flow-control .line { stroke: var(--control); stroke-dasharray: 5 4; }
.edge.flow-control .head { fill: var(--control); }
.edge.flow-dependency .line { stroke-width: 2.5; }
.edge:hover .line, .edge.is-hot .line { stroke: var(--accent); stroke-width: 2.25; }
.edge:hover .head, .edge.is-hot .head { fill: var(--accent); }
.edge.flow-control:hover .line, .edge.flow-control.is-hot .line { stroke: var(--control); }
.edge.flow-control:hover .head, .edge.flow-control.is-hot .head { fill: var(--control); }
.edge.is-related .line { stroke: var(--accent); stroke-width: 2.25; }
.edge.is-related .head { fill: var(--accent); }
.edge.flow-control.is-related .line { stroke: var(--control); }
.edge.flow-control.is-related .head { fill: var(--control); }
.has-selection .edge:not(.is-related) { opacity: 0.32; }
.has-hot .edge:not(.is-hot) { opacity: 0.16; }
.has-hot .edge.is-hot { opacity: 1; }

/* arrow labels: shown when zoomed in enough, and always for what is in focus */
.edge-label { cursor: pointer; transition: opacity 0.15s; }
.edge-label rect { fill: #ffffff; stroke: #dfe3ea; stroke-width: 1; }
.edge-label text { font-size: 12px; fill: var(--ink-2); text-anchor: middle; dominant-baseline: central; }
.edge-label.flow-control text { fill: #5b21b6; }
.edge-label:hover rect, .edge-label.is-hot rect, .edge-label.is-related rect { stroke: var(--accent); }
.edge-label.is-crowded { display: none; }
.lod-far .edge-label { display: none; }
.edge-label.is-related, .edge-label.is-hot, .lod-far .edge-label.is-related, .lod-far .edge-label.is-hot { display: inline; }
.has-hot .edge-label:not(.is-hot) { opacity: 0; pointer-events: none; }
.has-selection .edge-label:not(.is-related) { opacity: 0.35; }
.has-hot.has-selection .edge-label.is-related:not(.is-hot) { opacity: 0; }
.has-hot .node:not(.is-lit):not(.kind-system):not(.is-header) { opacity: 0.55; }
.node { transition: opacity 0.15s; }

/* subgraphs */
.cluster { cursor: grab; }
.cluster rect { fill: var(--frame); stroke: var(--frame-line); stroke-width: 1.25; }
.cluster:hover rect { stroke: #cdb865; }
.cluster.is-selected rect { stroke: var(--accent); stroke-width: 2; }
.cluster .divider { stroke: var(--frame-line); stroke-width: 1; stroke-dasharray: 3 4; }
.cluster text { font-size: 13px; fill: var(--frame-ink); font-weight: 700; }

/* boundaries */
.zone .zone-fill { fill: var(--zone-fill); stroke: none; fill-rule: evenodd; pointer-events: none; }
.zone .zone-line { fill: none; stroke: var(--zone); stroke-width: 1.25; stroke-dasharray: 7 5; pointer-events: none; }
.zone .zone-hit { fill: none; stroke: transparent; stroke-width: 12; pointer-events: stroke; cursor: grab; }
.zone:hover .zone-line { stroke-width: 2; }
.zone-label { cursor: grab; }
.zone-label rect { fill: #ffffff; stroke: #c9daf3; }
.zone-label text { font-size: 12px; fill: var(--zone-ink); font-weight: 600; dominant-baseline: central; letter-spacing: 0.01em; }
.zone-label:hover rect { stroke: var(--zone); }

/* layer labels */
.lane { cursor: grab; }
.lane .lane-hit { fill: transparent; }
.lane text { font-size: calc(11px * var(--lane-scale, 1)); fill: #8b95a7; font-weight: 700; letter-spacing: 0.1em; text-anchor: end; dominant-baseline: central; }
.lane line { stroke: #c5ccd8; stroke-width: 1.5; }
.lane:hover text { fill: var(--accent); }
.lane:hover .lane-hit { fill: rgba(79, 70, 229, 0.06); }

/* ---- HUD ------------------------------------------------------------------- */

#hud {
  position: fixed;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}
.pill {
  pointer-events: auto;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 12px;
  height: 40px;
  font-size: 13px;
  box-shadow: var(--shadow-sm);
  display: flex;
  gap: 8px;
  align-items: center;
  backdrop-filter: blur(6px);
}
.brand { gap: 8px; }
.brand strong { color: var(--ink); font-weight: 700; letter-spacing: -0.01em; }
.brand .mark { width: 16px; height: 16px; border-radius: 5px; background: linear-gradient(135deg, #6366f1, #8b5cf6); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35); }
#level-label { color: var(--muted); }
#level-label:empty { display: none; }
#level-label::before { content: "·"; margin-right: 8px; color: var(--faint); }
#busy { color: #15803d; font-weight: 600; animation: blink 1s infinite alternate; }
@keyframes blink { from { opacity: 0.4; } to { opacity: 1; } }
.search-wrap { flex: 0 1 280px; min-width: 180px; cursor: text; }
.search-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12); }
.search-wrap .icon { width: 15px; height: 15px; fill: none; stroke: var(--faint); stroke-width: 1.6; flex: none; }
.search { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; font: inherit; font-size: 14px; color: var(--ink); }
.search::placeholder { color: var(--faint); }
.tools { margin-left: auto; padding: 0 6px; gap: 2px; }
.tools .sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }
.tools .zoom { display: inline-flex; align-items: center; }
.tools button, .actions button, #panel-close {
  font: inherit;
  font-size: 13px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 7px;
  padding: 0 10px;
  height: 30px;
  cursor: pointer;
  color: var(--ink-2);
  white-space: nowrap;
}
.tools button:hover { background: #f1f3f8; color: var(--ink); }
.tools button:focus-visible, .actions button:focus-visible, #panel-close:focus-visible, .row-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
#zoom-in, #zoom-out { width: 30px; padding: 0; font-size: 16px; }
#zoom-label { min-width: 44px; text-align: center; color: var(--muted); font-variant-numeric: tabular-nums; }

.legend { position: fixed; left: 12px; bottom: 12px; height: 36px; gap: 14px; color: var(--ink-2); }
.legend > span { display: inline-flex; align-items: center; gap: 6px; }
.legend .hint { color: var(--muted); padding-left: 12px; border-left: 1px solid var(--line); }
.swatch { display: inline-block; width: 18px; height: 0; border-top: 1.5px solid var(--edge); }
.swatch.flow-control { border-top: 1.5px dashed var(--control); }
.swatch.zone { height: 10px; border: 1.25px dashed var(--zone); background: var(--zone-fill); border-radius: 3px; }
.swatch.frame { height: 10px; border: 1.25px solid var(--frame-line); background: var(--frame); border-radius: 3px; }
.swatch.drift { height: 10px; border: 1.5px solid var(--drift); background: var(--drift-soft); border-radius: 3px; }

#minimap {
  position: fixed;
  right: 12px;
  bottom: 12px;
  width: 176px;
  height: 112px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}
.mm-zone { fill: rgba(59, 130, 246, 0.06); stroke: rgba(107, 154, 224, 0.5); stroke-width: 0.75; }
.mm-node { fill: #c7cde0; }
.mm-drift { fill: var(--drift); }
.mm-view { fill: rgba(79, 70, 229, 0.06); stroke: var(--accent); stroke-width: 1.25; }

/* ---- hover card -------------------------------------------------------------- */

#tip {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 20;
  max-width: 300px;
  padding: 10px 12px;
  background: rgba(15, 23, 42, 0.94);
  color: #e2e8f0;
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  font-size: 12.5px;
  line-height: 1.45;
  pointer-events: none;
}
#tip[hidden] { display: none; }
#tip p { margin: 0; }
#tip .tip-name { color: #fff; font-weight: 600; font-size: 13.5px; }
#tip .tip-blurb { color: #cbd5e1; margin-top: 2px; }
#tip .tip-why { margin-top: 8px; color: #f1f5f9; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
#tip .tip-why span { display: block; color: #a5b4fc; font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 1px; }
#tip .tip-hint { margin-top: 8px; color: #94a3b8; font-size: 11px; }

/* ---- read-more panel ------------------------------------------------------------ */

#panel {
  position: fixed;
  top: 64px;
  right: 12px;
  bottom: 12px;
  width: min(400px, calc(100vw - 24px));
  overflow: auto;
  overscroll-behavior: contain;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px 22px 0;
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink-2);
  z-index: 10;
}
#panel[hidden] { display: none; }
#panel .grip { display: none; }
#panel-close { position: absolute; top: 12px; right: 12px; width: 30px; padding: 0; font-size: 18px; line-height: 1; color: var(--muted); }
#panel-close:hover { background: #f1f3f8; color: var(--ink); }
#panel h2 { margin: 2px 0 4px; font-size: 21px; line-height: 1.25; color: var(--ink); letter-spacing: -0.015em; padding-right: 28px; }
#panel h3 { margin: 0 0 6px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); display: flex; align-items: center; gap: 6px; }
#panel h3 .count { font-weight: 600; color: var(--faint); letter-spacing: 0; }
#panel p { margin: 0; }
.p-head { padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.eyebrow { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.07em; font-weight: 600; margin-bottom: 4px !important; }
.eyebrow .link { text-transform: none; letter-spacing: 0; font-weight: 600; }
.lede { font-size: 15px; color: var(--ink-2); margin: 0 0 10px !important; }
.p-sec { padding: 14px 0; border-bottom: 1px solid #f0f2f6; }
.p-sec:last-of-type { border-bottom: 0; }
.p-sec.why { margin: 14px 0 2px; padding: 12px 14px; border: 0; border-radius: 10px; background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.p-sec.why h3 { color: var(--accent-ink); }
.p-sec.why .why-text, .p-sec.why p { font-size: 15px; line-height: 1.5; color: var(--ink); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; padding: 10px 0 16px; }
.notes { margin: 0; padding-left: 18px; }
.notes li { margin: 4px 0; }
.notes li::marker { color: var(--faint); }
.rows { list-style: none; margin: 0 -8px; padding: 0; }
.rows li { display: flex; align-items: flex-start; gap: 6px; }
.row-link { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; text-align: left; border: 0; background: none; padding: 6px 8px; border-radius: 8px; font: inherit; cursor: pointer; color: inherit; }
.row-link:hover { background: #f5f6fa; }
.row-name { font-weight: 600; color: var(--ink); font-size: 14px; }
.row-link:hover .row-name { color: var(--accent); }
.row-sub { color: var(--muted); font-size: 13px; line-height: 1.4; white-space: pre-wrap; }
.tag { margin: 8px 8px 0 0; font-size: 10.5px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; border-radius: 999px; padding: 1px 7px; background: #f3f0ff; color: var(--control); flex: none; }
.flag { padding: 10px 12px; border: 1px solid #f5c2c2; background: var(--drift-soft); border-radius: 10px; margin-top: 8px; }
.flag p + p { margin-top: 6px !important; }
.flag-k { display: block; font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--drift); }
.p-sec.drift h3 { color: var(--drift); }
.link { border: 0; background: none; padding: 0; color: var(--accent); font: inherit; cursor: pointer; }
.link:hover { text-decoration: underline; }
pre.intent {
  margin: 0;
  background: #f7f8fb;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--ink-2);
}
.actions { position: sticky; bottom: 0; display: flex; gap: 8px; margin: 8px -22px 0; padding: 12px 22px 16px; flex-wrap: wrap; background: linear-gradient(rgba(255, 255, 255, 0.85), #fff 30%); border-top: 1px solid var(--line); }
.actions button { border: 1px solid var(--line); background: #fff; color: var(--ink-2); height: 34px; padding: 0 14px; font-weight: 600; }
.actions button:hover { background: #f5f6fa; }
.actions .primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.actions .primary:hover { background: var(--accent-ink); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 !important; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; background: #f1f3f8; color: var(--ink-2); border-radius: 999px; padding: 2px 10px; }
.chip i { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.zone-chip { background: #edf3fc; color: var(--zone-ink); }
.drift-chip { background: var(--drift-soft); color: var(--drift); }
.tier-client i { background: #94a3b8; }
.tier-edge i { background: #5b8fd9; }
.tier-frontend i { background: #0ea5e9; }
.tier-api i { background: #6366f1; }
.tier-service i, .tier-platform i { background: #8b5cf6; }
.tier-external i { background: #a1a9b8; }
.tier-messaging i, .tier-worker i { background: #22a06b; }
.tier-cache i { background: #d4a02a; }
.tier-database i { background: #4f6fb0; }
.tier-storage i { background: #a8895a; }
.route { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.route-end { font: inherit; font-size: 13px; font-weight: 600; border: 1px solid var(--line); background: #f8f9fb; color: var(--ink); border-radius: 8px; padding: 5px 10px; cursor: pointer; }
.route-end:hover { border-color: var(--accent); color: var(--accent); }
.route-arrow { color: var(--edge); font-weight: 700; }
.route-arrow.control { color: var(--control); }

#toast {
  position: fixed;
  left: 50%;
  bottom: 64px;
  transform: translateX(-50%);
  background: #0f172a;
  color: #fff;
  padding: 9px 14px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  z-index: 30;
}
#toast[hidden] { display: none; }

.empty {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 24px;
  pointer-events: none;
}
.empty[hidden] { display: none; }
.empty .primary-button { pointer-events: auto; font: inherit; border: 0; border-radius: 8px; padding: 8px 14px; background: var(--accent); color: #fff; cursor: pointer; }
.empty > div { max-width: 520px; background: rgba(255, 255, 255, 0.96); padding: 24px 28px; border-radius: 14px; border: 1px solid var(--line); box-shadow: var(--shadow-lg); }
.empty h2 { margin: 0 0 8px; }
.empty p { color: var(--muted); }

/* short or narrow views (embeds, laptops): the minimap would cover the picture */
@media (max-height: 820px), (max-width: 1100px) {
  #minimap { display: none; }
}

/* ---- small screens: compact HUD, panel as a bottom sheet ------------------------ */

@media (max-width: 720px) {
  #hud { top: 8px; left: 8px; right: 8px; flex-wrap: wrap; gap: 6px; }
  .pill { height: 38px; }
  .brand { flex: none; }
  #level-label { display: none; }
  .search-wrap { flex: 1 1 120px; min-width: 0; }
  .search-wrap kbd { display: none; }
  .tools { order: 3; flex: 1 1 100%; margin-left: 0; overflow-x: auto; scrollbar-width: none; justify-content: flex-start; }
  .tools::-webkit-scrollbar { display: none; }
  .legend { display: none; }
  #minimap { display: none; }
  #panel {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: 58vh;
    border-radius: 18px 18px 0 0;
    border-bottom: 0;
    padding: 8px 18px 0;
    box-shadow: 0 -8px 30px rgba(15, 23, 42, 0.16);
  }
  #panel .grip { display: block; width: 40px; height: 4px; border-radius: 2px; background: #d6dae3; margin: 2px auto 10px; }
  #panel-close { top: 14px; right: 10px; }
  #panel h2 { font-size: 19px; }
  .actions { margin: 8px -18px 0; padding: 10px 18px calc(12px + env(safe-area-inset-bottom)); }
  #tip { display: none; }
}
