:root {
  --bg: #070b16;
  --bg-2: #0d1426;
  --surface: rgba(15, 22, 40, 0.86);
  --surface-solid: #111a30;
  --surface-2: #18223d;
  --border: rgba(148, 163, 184, 0.16);
  --border-strong: rgba(148, 163, 184, 0.3);
  --text: #e6ebf5;
  --text-dim: #9aa6bf;
  --text-faint: #66728c;
  --accent: #a970ff;
  --s-not-started: #475569;
  --s-exploring: #38bdf8;
  --s-learned: #4ade80;
  --s-deeper: #fbbf24;
  --idea: #f472b6;
  --radius: 14px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  --topbar-h: 60px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

/* ---------- Top bar ---------- */

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: linear-gradient(to bottom, rgba(7, 11, 22, 0.95), rgba(7, 11, 22, 0.7));
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  z-index: 30;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  letter-spacing: 0.02em;
  font-size: 17px;
  color: #c8b3ff;
  white-space: nowrap;
}
.brand svg { width: 26px; height: 26px; }
.brand span {
  background: linear-gradient(90deg, #c8b3ff, #7dd3fc);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.search { position: relative; flex: 1; max-width: 420px; margin-left: 12px; }
.search input {
  width: 100%;
  height: 38px;
  padding: 0 36px 0 14px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.04);
  outline: none;
  transition: border-color .15s, background .15s;
}
.search input:focus { border-color: var(--accent); background: rgba(255, 255, 255, 0.07); }
.search kbd {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-faint);
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  padding: 1px 6px;
  pointer-events: none;
}
.search input:focus + kbd { display: none; }

.search-results {
  position: absolute;
  top: 44px;
  left: 0;
  right: 0;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--surface-solid);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: var(--shadow);
  max-height: 60vh;
  overflow-y: auto;
}
.search-results li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.search-results li.active, .search-results li:hover { background: var(--surface-2); }
.search-results .sr-domain { margin-left: auto; font-size: 12px; color: var(--text-faint); white-space: nowrap; }
.search-results .empty { color: var(--text-faint); cursor: default; }

select#domain-filter {
  height: 38px;
  padding: 0 30px 0 12px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.04) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%239aa6bf' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 11px center / 10px;
  appearance: none;
  outline: none;
  max-width: 220px;
}
select#domain-filter option { background: var(--surface-solid); }

.progress-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  margin-left: auto;
  white-space: nowrap;
  font-size: 13px;
  color: var(--text-dim);
}
.progress-pill .bar { width: 90px; height: 6px; border-radius: 3px; background: rgba(255,255,255,0.08); overflow: hidden; display: flex; }
.progress-pill .bar span { display: block; height: 100%; }
.progress-pill strong { color: var(--text); font-weight: 600; }

.views { display: flex; gap: 6px; }
.views button {
  height: 38px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-dim);
  transition: all .15s;
}
.views button:hover { color: var(--text); border-color: var(--border-strong); }
.views button.active { color: #fff; background: rgba(169, 112, 255, 0.18); border-color: rgba(169, 112, 255, 0.55); }

/* ---------- Map ---------- */

#map-wrap {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(91, 141, 239, 0.10), transparent 55%),
    radial-gradient(ellipse at 75% 80%, rgba(169, 112, 255, 0.10), transparent 55%),
    var(--bg);
}
#map { width: 100%; height: 100%; display: block; cursor: grab; }
#map:active { cursor: grabbing; }

.region-shape { transition: opacity .25s; }
.region-label {
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  paint-order: stroke;
  stroke: var(--bg);
  stroke-width: 6px;
  stroke-linejoin: round;
  pointer-events: none;
  transition: opacity .25s;
}
.region-sub {
  fill: var(--text-dim);
  font-weight: 600;
  paint-order: stroke;
  stroke: var(--bg);
  stroke-width: 5px;
  pointer-events: none;
}

.edge { fill: none; pointer-events: none; transition: opacity .2s, stroke-opacity .2s; }
.edge.same { stroke-width: 1.6; stroke-opacity: 0.38; }
.edge.cross { stroke: #94a3b8; stroke-width: 1.1; stroke-opacity: 0.13; stroke-dasharray: 4 6; }
.edge.idea-edge { stroke: var(--idea); stroke-width: 1.4; stroke-opacity: 0.5; stroke-dasharray: 2 5; }

.node { cursor: pointer; transition: opacity .2s; }
.node .core { transition: r .2s, stroke-width .2s; }
.node .halo { fill: none; pointer-events: none; }
.node.status-learned .core { filter: url(#glow); }
.node.status-want-to-go-deeper .halo { stroke: var(--s-deeper); stroke-width: 2; animation: pulse 2.4s ease-out infinite; transform-box: fill-box; transform-origin: center; }
.node.status-exploring .halo { stroke: var(--s-exploring); stroke-width: 1.5; stroke-dasharray: 3 4; animation: spin 12s linear infinite; transform-box: fill-box; transform-origin: center; }
.node-label {
  fill: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  text-anchor: middle;
  paint-order: stroke;
  stroke: var(--bg);
  stroke-width: 4px;
  stroke-linejoin: round;
  pointer-events: none;
  transition: opacity .2s;
}
.node.status-not-started .node-label { fill: #b7c0d3; }
.node:hover .core, .node.selected .core { stroke-width: 4; }
.node.selected .sel-ring { opacity: 1; }
.sel-ring { fill: none; stroke: #fff; stroke-width: 1.5; opacity: 0; pointer-events: none; }

.idea-node { cursor: pointer; transition: opacity .2s; }
.idea-node path { fill: var(--idea); stroke: #fff; stroke-width: 1.2; filter: url(#glow); }
.idea-node text { fill: #fbcfe8; font-size: 11px; font-style: italic; text-anchor: middle; paint-order: stroke; stroke: var(--bg); stroke-width: 4px; pointer-events: none; }

/* semantic zoom */
svg.far .node-label, svg.far .idea-node text { opacity: 0; }
svg.far .region-sub { opacity: 0.9; }
svg:not(.far) .region-label { opacity: 0.55; }

/* filtering and hover focus */
.dim { opacity: 0.1 !important; }
svg.hovering .node:not(.hl), svg.hovering .idea-node:not(.hl) { opacity: 0.22; }
svg.hovering .edge:not(.hl) { opacity: 0.08; }
svg.hovering .edge.hl { stroke-opacity: 0.9; stroke-width: 2.2; }

@keyframes pulse {
  0% { transform: scale(1); opacity: 0.9; }
  100% { transform: scale(1.9); opacity: 0; }
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .node .halo { animation: none !important; }
}

/* ---------- Legend / status filter ---------- */

.legend {
  position: fixed;
  left: 16px;
  bottom: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  backdrop-filter: blur(10px);
  z-index: 20;
  max-width: calc(100vw - 32px - 60px);
}
.legend button {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  font-size: 13px;
  color: var(--text);
  transition: opacity .15s, background .15s;
}
.legend button:hover { background: rgba(255, 255, 255, 0.05); }
.legend button.off { opacity: 0.35; }
.legend .count { color: var(--text-faint); font-variant-numeric: tabular-nums; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; display: inline-block; }
.diamond { width: 9px; height: 9px; transform: rotate(45deg); background: var(--idea); flex: none; display: inline-block; }

/* ---------- Zoom controls ---------- */

.zoom-controls {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  backdrop-filter: blur(10px);
  z-index: 20;
  transition: right .3s ease;
}
.zoom-controls button {
  width: 40px;
  height: 40px;
  border: 0;
  background: transparent;
  font-size: 18px;
  display: grid;
  place-items: center;
}
.zoom-controls button + button { border-top: 1px solid var(--border); }
.zoom-controls button:hover { background: rgba(255, 255, 255, 0.06); }
.zoom-controls svg { width: 16px; height: 16px; }
body.panel-open .zoom-controls { right: calc(min(460px, 100vw) + 16px); }

/* ---------- Tooltip ---------- */

.tooltip {
  position: fixed;
  pointer-events: none;
  padding: 8px 11px;
  border-radius: 10px;
  background: var(--surface-solid);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
  font-size: 13px;
  z-index: 40;
  max-width: 260px;
}
.tooltip .tt-title { font-weight: 650; margin-bottom: 3px; }
.tooltip .tt-meta { color: var(--text-dim); font-size: 12px; display: flex; align-items: center; gap: 6px; }

/* ---------- Side panel (note) ---------- */

.panel {
  position: fixed;
  top: var(--topbar-h);
  right: 0;
  bottom: 0;
  width: min(460px, 100vw);
  background: var(--surface-solid);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow);
  transform: translateX(100%);
  transition: transform .3s ease;
  z-index: 25;
  display: flex;
  flex-direction: column;
}
body.panel-open .panel { transform: none; }
.panel-close { position: absolute; top: 14px; right: 14px; z-index: 2; }
.panel-body { overflow-y: auto; padding: 22px 24px 40px; }

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-dim);
  display: grid;
  place-items: center;
}
.icon-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.08); }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid color-mix(in srgb, var(--c) 50%, transparent);
  background: color-mix(in srgb, var(--c) 14%, transparent);
  color: color-mix(in srgb, var(--c) 70%, white);
}
button.tag { cursor: pointer; }
button.tag:hover { background: color-mix(in srgb, var(--c) 26%, transparent); }

.panel h2 { font-size: 24px; line-height: 1.25; margin: 12px 40px 12px 0; }
.meta-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; font-size: 13px; color: var(--text-dim); margin-bottom: 18px; }
.difficulty { display: inline-flex; gap: 3px; align-items: center; }
.difficulty i { width: 7px; height: 7px; border-radius: 50%; background: rgba(255,255,255,0.15); display: inline-block; }
.difficulty i.on { background: #c8b3ff; }

.my-notes {
  border-left: 3px solid var(--accent);
  background: rgba(169, 112, 255, 0.08);
  padding: 10px 14px;
  border-radius: 0 10px 10px 0;
  margin-bottom: 18px;
  font-size: 14px;
  white-space: pre-wrap;
}
.my-notes .label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #c8b3ff; margin-bottom: 4px; }

.connections { margin-bottom: 8px; }
.connections h3, .section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  margin: 18px 0 8px;
  font-weight: 700;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.note { line-height: 1.6; color: #d4dbea; }
.note h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: #c8b3ff;
  margin: 26px 0 8px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.note h2:first-child { border-top: 0; padding-top: 0; margin-top: 8px; }
.note p { margin: 0 0 10px; }
.note ul, .note ol { margin: 0 0 10px; padding-left: 20px; }
.note li { margin-bottom: 5px; }
.note li::marker { color: var(--text-faint); }
.note strong { color: #fff; }
.note code { font-family: var(--mono); font-size: 0.9em; background: rgba(255,255,255,0.07); padding: 1px 5px; border-radius: 4px; }
.note a { color: #7dd3fc; }
.note table { border-collapse: collapse; width: 100%; font-size: 14px; margin-bottom: 12px; }
.note th, .note td { border: 1px solid var(--border); padding: 6px 8px; text-align: left; }
.verify {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: #fcd34d;
  background: rgba(251, 191, 36, 0.12);
  border: 1px solid rgba(251, 191, 36, 0.3);
  border-radius: 5px;
  padding: 0 5px;
  margin-left: 2px;
  white-space: nowrap;
}
.spec {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #f9a8d4;
  background: rgba(244, 114, 182, 0.12);
  border: 1px solid rgba(244, 114, 182, 0.3);
  border-radius: 5px;
  padding: 0 6px;
  margin-right: 2px;
}
.file-path { margin-top: 28px; font-family: var(--mono); font-size: 12px; color: var(--text-faint); word-break: break-all; }

/* ---------- Drawer (progress, explore) ---------- */

.drawer {
  position: fixed;
  top: calc(var(--topbar-h) + 12px);
  left: 16px;
  bottom: 76px;
  width: min(380px, calc(100vw - 32px));
  background: var(--surface);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 22;
  display: flex;
  flex-direction: column;
  transform: translateX(calc(-100% - 24px));
  transition: transform .3s ease;
}
body.drawer-open .drawer { transform: none; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 8px 20px; }
.drawer-head h2 { margin: 0; font-size: 18px; }
.drawer-body { overflow-y: auto; padding: 4px 20px 20px; }

.overall { display: flex; align-items: center; gap: 18px; padding: 10px 0 16px; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.ring { width: 84px; height: 84px; flex: none; }
.ring text { fill: var(--text); font-weight: 700; font-size: 20px; text-anchor: middle; dominant-baseline: central; }
.overall-stats { display: grid; grid-template-columns: auto auto; gap: 4px 14px; font-size: 13px; color: var(--text-dim); }
.overall-stats span { display: flex; align-items: center; gap: 6px; }
.overall-stats b { color: var(--text); font-variant-numeric: tabular-nums; }
.hint { font-size: 12px; color: var(--text-faint); margin: 8px 0 4px; line-height: 1.5; }

.domain-row {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 9px 8px;
  margin: 0 -8px;
  width: calc(100% + 16px);
  border-radius: 10px;
}
.domain-row:hover { background: rgba(255, 255, 255, 0.05); }
.domain-row .top { display: flex; align-items: center; gap: 8px; font-size: 14px; margin-bottom: 6px; }
.domain-row .top .n { margin-left: auto; color: var(--text-dim); font-size: 12px; font-variant-numeric: tabular-nums; }
.stack { display: flex; height: 7px; border-radius: 4px; overflow: hidden; background: rgba(255, 255, 255, 0.07); }
.stack span { height: 100%; }

.list { list-style: none; margin: 0; padding: 0; }
.list li button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 9px 8px;
  border-radius: 9px;
}
.list li button:hover { background: rgba(255, 255, 255, 0.05); }
.list .sub { margin-left: auto; font-size: 12px; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 50%; flex: none; }
.empty-state { font-size: 13px; color: var(--text-faint); padding: 6px 0 4px; line-height: 1.5; }

.message {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 24px;
  color: var(--text-dim);
}
.message code { font-family: var(--mono); color: #c8b3ff; }

/* ---------- Mobile ---------- */


[hidden] { display: none !important; }

/* ---------- Account, login dialog, per-user tracker (hosted mode) ---------- */

.views button.account { display: inline-flex; align-items: center; gap: 7px; }
.views button.account svg { width: 16px; height: 16px; flex: none; }
.views button.account.signed-in { color: #fff; border-color: rgba(74, 222, 128, 0.45); }

.btn {
  height: 36px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid rgba(169, 112, 255, 0.55);
  background: rgba(169, 112, 255, 0.18);
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  transition: background .15s;
}
.btn:hover { background: rgba(169, 112, 255, 0.3); }
.btn:disabled { opacity: .5; cursor: default; }

.login {
  width: min(380px, calc(100vw - 32px));
  padding: 24px;
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}
.login::backdrop { background: rgba(5, 8, 20, 0.6); backdrop-filter: blur(3px); }
.login h2 { margin: 0 32px 8px 0; font-size: 20px; }
.login .who { margin: 0 0 6px; font-weight: 600; word-break: break-all; }
.login .hint { margin: 0 0 14px; font-size: 13px; }
.login-close { position: absolute; top: 12px; right: 12px; }
.login form { display: flex; gap: 8px; }
.login input {
  flex: 1;
  min-width: 0;
  height: 36px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.05);
  outline: none;
}
.login input:focus { border-color: var(--accent); }
.form-msg { min-height: 18px; margin: 12px 0 0; font-size: 13px; color: var(--text-dim); }

.tracker {
  border-left: 3px solid var(--accent);
  background: rgba(169, 112, 255, 0.08);
  padding: 12px 14px;
  border-radius: 0 10px 10px 0;
  margin-bottom: 18px;
  font-size: 14px;
}
.tracker .label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #c8b3ff; margin-bottom: 6px; }
.tracker p { margin: 0 0 10px; color: var(--text-dim); font-size: 13px; line-height: 1.5; }
.status-pick { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.status-pick button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-dim);
}
.status-pick button .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); display: inline-block; }
.status-pick button:hover { border-color: var(--border-strong); color: var(--text); }
.status-pick button.on {
  border-color: color-mix(in srgb, var(--c) 60%, transparent);
  background: color-mix(in srgb, var(--c) 16%, transparent);
  color: color-mix(in srgb, var(--c) 70%, white);
}
.tracker textarea {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  resize: vertical;
  outline: none;
}
.tracker textarea:focus { border-color: var(--accent); }
.tracker-foot { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 8px; }
.tracker-foot .btn { height: 30px; padding: 0 12px; font-size: 12px; }
.save-state { font-size: 12px; color: var(--text-faint); }

.gate { padding: 12px 0; }
.gate p { margin: 0 0 14px; font-size: 14px; line-height: 1.55; color: var(--text-dim); }


/* ---------- Welcome, toast, avatar, copy link ---------- */

.views button.account .avatar {
  display: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(135deg, #a970ff, #38bdf8);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  align-items: center;
  justify-content: center;
  flex: none;
}
.views button.account.signed-in .avatar { display: inline-flex; }
.views button.account.signed-in svg { display: none; }

.btn.ghost { background: transparent; border-color: var(--border-strong); color: var(--text-dim); }
.btn.ghost:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }

.panel-link { position: absolute; top: 14px; right: 54px; z-index: 2; }
.panel-link svg { width: 16px; height: 16px; }

.welcome {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 16px;
  background: radial-gradient(ellipse at center, rgba(11, 16, 32, 0.55), rgba(5, 8, 20, 0.85));
  backdrop-filter: blur(2px);
  animation: fade-in .3s ease;
}
.welcome-card {
  width: min(460px, 100%);
  padding: 28px 28px 24px;
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(169, 112, 255, 0.12);
  animation: rise .35s ease;
}
.welcome-card h1 { margin: 0 0 8px; font-size: 26px; line-height: 1.2; }
.welcome-card p { margin: 0 0 18px; color: var(--text-dim); font-size: 14px; line-height: 1.5; }
.welcome-card ul { list-style: none; margin: 0 0 22px; padding: 0; display: grid; gap: 12px; }
.welcome-card li { display: flex; gap: 12px; align-items: flex-start; font-size: 14px; line-height: 1.5; }
.w-ico { flex: none; width: 28px; height: 28px; border-radius: 8px; margin-top: 1px; position: relative; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--border); }
.w-region::before { content: ''; position: absolute; inset: 7px; border-radius: 40% 60% 55% 45%; border: 1.5px solid #a970ff; background: rgba(169, 112, 255, 0.2); }
.w-zoom::before { content: ''; position: absolute; left: 7px; top: 7px; width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid #38bdf8; }
.w-zoom::after { content: ''; position: absolute; left: 16px; top: 16px; width: 6px; height: 1.5px; background: #38bdf8; transform: rotate(45deg); }
.w-track::before { content: ''; position: absolute; left: 6px; top: 10px; width: 7px; height: 7px; border-radius: 50%; background: #4ade80; box-shadow: 9px 0 0 #fbbf24; }
.welcome-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 70;
  padding: 9px 14px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
  animation: rise .2s ease;
  max-width: calc(100vw - 32px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hint.nudge {
  margin: 4px 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px dashed rgba(169, 112, 255, 0.4);
  background: rgba(169, 112, 255, 0.07);
  color: var(--text-dim);
  font-size: 13px;
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.toast { animation-name: toast-rise; }
@keyframes toast-rise { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- Phone layout (768px and below) ---------- */

.tabbar { display: none; }
.panel-handle { display: none; }
.panel-peek { display: none; }

@media (max-width: 768px) {
  :root { --topbar-h: 56px; --tabbar-h: calc(58px + env(safe-area-inset-bottom)); --peek-h: 300px; }
  html, body { font-size: 16px; }

  /* One-row header: brand mark, search, domain, account. */
  .topbar { height: var(--topbar-h); padding: 0 12px; gap: 8px; }
  .brand span { display: none; }
  .search { margin-left: 0; flex: 1 1 auto; min-width: 0; max-width: none; }
  .search input { height: 40px; font-size: 16px; padding-right: 12px; }
  .search kbd { display: none; }
  .search-results { position: fixed; top: calc(var(--topbar-h) + 4px); left: 12px; right: 12px; max-height: 50vh; }
  .search-results li { font-size: 15px; }
  select#domain-filter { flex: 0 0 118px; min-width: 0; height: 40px; font-size: 14px; padding: 0 8px; }
  .progress-pill { display: none; }
  .views { gap: 0; }
  .views button[data-drawer] { display: none; }
  .views button.account { height: 40px; padding: 0 9px; }
  .views button.account .lbl { display: none; }

  /* Bottom tab bar replaces the Progress and Explore buttons. */
  .tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: var(--tabbar-h);
    padding-bottom: env(safe-area-inset-bottom);
    display: flex;
    z-index: 30;
    background: linear-gradient(to top, rgba(7, 11, 22, 0.98), rgba(7, 11, 22, 0.88));
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border);
  }
  .tabbar button {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border: 0;
    background: transparent;
    color: var(--text-dim);
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: .02em;
  }
  .tabbar button svg { width: 22px; height: 22px; }
  .tabbar button.active { color: #fff; }
  .tabbar button.active svg { color: var(--accent); }
  .tabbar .tab-lbl b { color: #c8b3ff; font-weight: 700; font-variant-numeric: tabular-nums; }
  .tabbar .tab-lbl b:empty { display: none; }

  /* Status filters: one scrolling row above the tab bar, with labels. */
  .legend {
    left: 0;
    right: 0;
    bottom: var(--tabbar-h);
    max-width: none;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 4px;
    padding: 6px 10px;
    border: 0;
    border-radius: 0;
    background: linear-gradient(to top, rgba(7, 11, 22, 0.85), rgba(7, 11, 22, 0.3));
    backdrop-filter: none;
    scrollbar-width: none;
  }
  .legend::-webkit-scrollbar { display: none; }
  .legend button { flex: none; padding: 7px 10px; font-size: 13px; }
  .zoom-controls { display: none; }

  /* Note: a tall bottom sheet with a grab handle and reading-size type. */
  .panel {
    top: auto;
    height: 86vh;
    height: 86dvh;
    width: 100vw;
    border-left: 0;
    border-top: 1px solid var(--border-strong);
    border-radius: 20px 20px 0 0;
    transform: translateY(100%);
    z-index: 36;
  }
  .panel-handle {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 26px;
    border: 0;
    background: transparent;
    z-index: 3;
  }
  .panel-handle::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 50%;
    width: 40px;
    height: 4px;
    margin-left: -20px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.22);
  }

  /* Peek: the sheet shows only its top part, the map and lit links stay visible. */
  body.peeking .panel { transform: translateY(calc(100% - var(--peek-h))); box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.45); }
  body.peeking .panel-body { display: none; }
  body.peeking .panel-peek { display: block; }
  .panel-peek { height: var(--peek-h); padding: 28px 18px 12px; overflow: hidden; }
  .peek-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-right: 88px; }
  .peek-status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-dim); }
  .panel-peek h2 { font-size: 20px; line-height: 1.2; margin: 8px 88px 6px 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .peek-sum {
    margin: 0 0 10px;
    font-size: 14px;
    line-height: 1.45;
    color: var(--text-dim);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .panel-peek .section-label { margin: 0 0 6px; }
  .peek-chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; scrollbar-width: none; }
  .peek-chips::-webkit-scrollbar { display: none; }
  .peek-chips .tag { flex: none; font-size: 13px; padding: 6px 11px; }
  .peek-actions { display: flex; align-items: center; gap: 12px; }
  .peek-actions .btn { flex: 0 0 auto; height: 42px; }
  .hint-tap { font-size: 12.5px; color: var(--text-faint); line-height: 1.3; }

  .panel-close { top: 18px; right: 14px; }
  .panel-link { top: 18px; right: 56px; }
  .icon-btn { width: 36px; height: 36px; }
  .panel-body { padding: 28px 18px calc(36px + env(safe-area-inset-bottom)); }
  .panel h2 { font-size: 24px; line-height: 1.2; margin: 10px 84px 12px 0; }
  .meta-row { font-size: 14px; gap: 8px 12px; margin-bottom: 16px; }
  .tag { font-size: 13px; padding: 5px 11px; }
  .connections h3, .section-label { font-size: 12px; }
  .note { font-size: 16.5px; line-height: 1.65; }
  .note h2 { font-size: 17px; }
  .note table { font-size: 14.5px; }
  .tracker { padding: 14px 14px; }
  .tracker p, .gate p { font-size: 15px; }
  .status-pick { gap: 8px; }
  .status-pick button { padding: 9px 13px; font-size: 14px; }
  .tracker textarea { font-size: 16px; padding: 10px 12px; }
  .tracker-foot .btn { height: 38px; padding: 0 14px; font-size: 14px; }
  .save-state { font-size: 13px; }
  .btn { height: 44px; padding: 0 18px; font-size: 15px; }

  /* Dashboards: a bottom sheet above the tab bar. */
  .drawer {
    top: auto;
    left: 0;
    right: 0;
    bottom: var(--tabbar-h);
    width: 100vw;
    height: 64vh;
    height: 64dvh;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    border-radius: 20px 20px 0 0;
    background: var(--surface-solid);
    transform: translateY(110%);
    z-index: 29;
  }
  .drawer-head { padding: 14px 12px 6px 18px; }
  .drawer-head h2 { font-size: 20px; }
  .drawer-body { padding: 4px 18px 20px; }
  .overall { gap: 16px; }
  .overall-stats { font-size: 14px; }
  .hint { font-size: 13.5px; }
  .empty-state { font-size: 14px; }
  .domain-row { padding: 10px 8px; }
  .domain-row .top { font-size: 15px; }
  .domain-row .top .n { font-size: 13px; }
  .list li button { padding: 11px 8px; font-size: 15px; }
  .list .sub { font-size: 12.5px; max-width: 46%; }

  /* Dialogs and toast. */
  .welcome { padding: 16px 16px calc(var(--tabbar-h) + 16px); }
  .welcome-card { padding: 22px 20px 18px; }
  .welcome-card h1 { font-size: 23px; }
  .welcome-card p, .welcome-card li { font-size: 15px; }
  .login { padding: 22px 18px; }
  .login h2 { font-size: 21px; }
  .login .hint { font-size: 14px; }
  .login input { height: 44px; font-size: 16px; }
  .login form { flex-wrap: wrap; }
  .login form .btn { flex: 1 1 100%; }
  .toast { bottom: calc(var(--tabbar-h) + 56px); }
}
