:root,
[data-theme="dark"] {
  --bg: #070b12;
  --bg-elevated: #0d1320;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-hover: rgba(255, 255, 255, 0.07);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #f4f6fa;
  --text-muted: #8b95a8;
  --text-dim: #5c6678;
  --accent: #3dd6c6;
  --accent-dim: rgba(61, 214, 198, 0.15);
  --accent-glow: rgba(61, 214, 198, 0.35);
  --warm: #e8a87c;
  --warm-dim: rgba(232, 168, 124, 0.12);
  --violet: #a78bfa;
  --violet-dim: rgba(167, 139, 250, 0.15);
  --blue: #7aa5f8;
  --blue-dim: rgba(122, 165, 248, 0.15);
  --positive: #3dd6c6;
  --negative: #f07178;
  --neutral: #8b95a8;
  --header-bg: rgba(7, 11, 18, 0.82);
  --gradient: radial-gradient(ellipse 80% 50% at 50% -30%, rgba(61, 214, 198, 0.12), transparent 55%);
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f6f8fc;
  --bg-elevated: #ffffff;
  --surface: rgba(7, 11, 18, 0.04);
  --surface-hover: rgba(7, 11, 18, 0.07);
  --border: rgba(7, 11, 18, 0.08);
  --border-strong: rgba(7, 11, 18, 0.12);
  --text: #0d1320;
  --text-muted: #5c6678;
  --text-dim: #8b95a8;
  --accent: #1a9e92;
  --accent-dim: rgba(26, 158, 146, 0.12);
  --accent-glow: rgba(26, 158, 146, 0.25);
  --warm: #c4784a;
  --warm-dim: rgba(196, 120, 74, 0.1);
  --violet: #7c5ce0;
  --violet-dim: rgba(124, 92, 224, 0.12);
  --blue: #3b6fd4;
  --blue-dim: rgba(59, 111, 212, 0.12);
  --positive: #1a9e92;
  --negative: #d64550;
  --neutral: #5c6678;
  --header-bg: rgba(246, 248, 252, 0.9);
  --gradient: radial-gradient(ellipse 80% 50% at 50% -30%, rgba(26, 158, 146, 0.1), transparent 55%);
  --shadow: 0 16px 48px rgba(13, 19, 32, 0.08);
  color-scheme: light;
}

:root {
  --font-sans: "DM Sans", system-ui, sans-serif;
  --font-serif: "Instrument Serif", Georgia, serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  --radius: 12px;
  --radius-lg: 20px;
  --header-h: 56px;
  --tabbar-h: 44px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100dvh;
  overflow: hidden;
}

.bg-gradient { position: fixed; inset: 0; background: var(--gradient); pointer-events: none; z-index: 0; }

/* ───── header ───── */
header {
  position: relative; z-index: 100; height: var(--header-h);
  display: flex; align-items: center;
  border-bottom: 1px solid var(--border);
  background: var(--header-bg); backdrop-filter: blur(16px);
}
.header-inner {
  width: 100%; padding-inline: 1.25rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.logo {
  display: flex; align-items: center; gap: 0.6rem; text-decoration: none;
  color: var(--text); font-weight: 600; font-size: 1rem; letter-spacing: -0.02em;
}
.logo-mark {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--accent) 0%, #2a9d8f 100%);
  border: 1px solid rgba(61, 214, 198, 0.35);
  box-shadow: 0 2px 12px var(--accent-glow);
}
.logo-letter {
  font-family: var(--font-serif); font-size: 1rem; line-height: 1;
  color: var(--bg); letter-spacing: -0.06em; margin-top: 1px; user-select: none;
}
.header-meta {
  display: flex; gap: 1rem; align-items: center;
  font-family: var(--font-mono); font-size: 0.7rem; color: var(--text-dim);
  overflow: hidden; white-space: nowrap;
}
.live-dot { display: inline-flex; align-items: center; gap: 0.35rem; color: var(--accent); }
.live-dot::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent); animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
.header-actions { display: flex; align-items: center; gap: 0.6rem; }
.btn-icon {
  width: 36px; height: 36px; border-radius: var(--radius);
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text-muted); cursor: pointer; display: grid; place-items: center;
  transition: background 0.2s, color 0.2s;
}
.btn-icon:hover { background: var(--surface-hover); color: var(--text); }
.btn {
  display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.45rem 0.9rem;
  border-radius: 999px; font-size: 0.8rem; font-weight: 600; text-decoration: none;
  border: none; cursor: pointer; font-family: inherit; transition: transform 0.2s var(--ease);
}
.btn-primary { background: var(--accent); color: var(--bg); }
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 28px var(--accent-glow);
}
.btn-ghost { background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); }
.btn-ghost:hover {
  background: var(--surface-hover);
  transform: translateY(-1px);
}
.btn:active { transform: translateY(0); }
.hidden { display: none !important; }

.btn .btn-spinner {
  display: none; width: 13px; height: 13px; flex-shrink: 0;
  border-radius: 50%; border: 2px solid rgba(7, 11, 18, 0.25);
  border-top-color: var(--bg);
  animation: spin 0.7s linear infinite;
}
.btn.loading { opacity: 0.85; pointer-events: none; }
.btn.loading .btn-spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ───── tab bar ───── */
.tabbar {
  position: relative; z-index: 90; height: var(--tabbar-h);
  display: flex; align-items: stretch; gap: 0.25rem;
  padding: 0.35rem 1.25rem 0;
  border-bottom: 1px solid var(--border);
  background: var(--header-bg); backdrop-filter: blur(16px);
  overflow-x: auto; overflow-y: hidden; scrollbar-width: thin;
}
.tab {
  display: inline-flex; align-items: center; gap: 0.45rem;
  padding: 0 0.85rem; border-radius: 10px 10px 0 0;
  font-size: 0.8rem; font-weight: 600; color: var(--text-muted);
  background: transparent; border: 1px solid transparent; border-bottom: none;
  cursor: pointer; user-select: none; white-space: nowrap; font-family: inherit;
  max-width: 230px;
}
.tab .tab-label { overflow: hidden; text-overflow: ellipsis; }
.tab:hover { color: var(--text); background: var(--surface); }
.tab.active {
  color: var(--text); background: var(--bg-elevated);
  border-color: var(--border); position: relative;
}
.tab.active::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
  background: var(--accent);
}
.tab.dragging { opacity: 0.4; }
.tab .tab-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.tab .tab-dot.narratives { background: var(--accent); }
.tab .tab-dot.graph { background: var(--violet); }
.tab .tab-dot.assets { background: var(--warm); }
.tab .tab-dot.pulse { background: var(--blue); }
.tab .tab-dot.custom { background: var(--negative); }
.tab .tab-pane-mark { font-size: 0.6rem; color: var(--text-dim); font-family: var(--font-mono); }
.tab-close {
  background: none; border: none; color: var(--text-dim); cursor: pointer;
  font-size: 0.95rem; line-height: 1; padding: 0 0.1rem; border-radius: 4px;
}
.tab-close:hover { color: var(--negative); }
.tab-add {
  align-self: center; width: 30px; height: 30px; flex-shrink: 0;
  border-radius: 8px; border: 1px dashed var(--border-strong);
  background: transparent; color: var(--text-muted); cursor: pointer;
  font-size: 1.05rem; line-height: 1;
}
.tab-add:hover { color: var(--accent); border-color: var(--accent); }
.add-menu {
  position: absolute; z-index: 300; min-width: 220px;
  background: var(--bg-elevated); border: 1px solid var(--border-strong);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 0.4rem;
}
.add-menu button {
  display: block; width: 100%; text-align: left; padding: 0.5rem 0.7rem;
  background: none; border: none; border-radius: 8px; color: var(--text);
  font-family: inherit; font-size: 0.85rem; cursor: pointer;
}
.add-menu button:hover { background: var(--surface-hover); }
.add-menu .menu-note { font-size: 0.7rem; color: var(--text-dim); padding: 0.25rem 0.7rem; }
.add-menu .menu-plus-tag {
  font-size: 0.6rem;
  font-weight: 700;
  padding: 0.1rem 0.35rem;
  border-radius: 999px;
  margin-left: 0.35rem;
  color: #1a1208;
  background: linear-gradient(135deg, #f5d078 0%, #e8a838 55%, #c8862a 100%);
}

/* ───── panes ───── */
.pane-wrap {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: 1fr; gap: 0;
  height: calc(100dvh - var(--header-h) - var(--tabbar-h));
}
.pane-wrap.split { grid-template-columns: 1fr 1fr; }
.pane {
  overflow-y: auto; overflow-x: hidden; position: relative;
  padding: 1.25rem 1.25rem 3rem;
}
.pane-wrap.split .pane[data-pane="0"] { border-right: 1px solid var(--border); }
.view { width: 100%; max-width: 1400px; margin-inline: auto; }
.view.hidden { display: none; }

.drop-overlay {
  position: fixed; z-index: 250; display: none;
  top: calc(var(--header-h) + var(--tabbar-h)); bottom: 0;
  pointer-events: none;
}
body.tab-dragging .drop-overlay { display: flex; pointer-events: auto; }
.drop-overlay .drop-zone {
  flex: 1; display: grid; place-items: center;
  border: 2px dashed transparent; border-radius: var(--radius-lg);
  margin: 1rem; color: var(--text-dim); font-size: 0.85rem; font-weight: 600;
  transition: border-color 0.15s, background 0.15s;
}
.drop-overlay .drop-zone.hover {
  border-color: var(--accent); background: var(--accent-dim); color: var(--accent);
}

/* ───── shared components ───── */
.panel {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.25rem; box-shadow: var(--shadow);
}
.panel-title {
  font-family: var(--font-mono); font-size: 0.7rem; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--text-dim); margin-bottom: 1rem;
}
.toolbar { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-bottom: 1rem; align-items: center; }
.toolbar input[type="search"], .toolbar select, .toolbar input[type="text"] {
  font-family: inherit; font-size: 0.85rem; padding: 0.5rem 0.85rem;
  border-radius: 999px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); min-width: 0;
}
.toolbar input[type="search"] { flex: 1 1 180px; }
.toolbar label.check {
  display: flex; align-items: center; gap: 0.35rem; font-size: 0.8rem;
  color: var(--text-muted); cursor: pointer;
}
.filter-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip {
  font-size: 0.75rem; font-weight: 600; padding: 0.35rem 0.7rem; border-radius: 999px;
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text-muted); cursor: pointer; font-family: inherit;
}
.chip.active { background: var(--accent-dim); border-color: rgba(61, 214, 198, 0.35); color: var(--accent); }
.badge {
  font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
  padding: 0.25rem 0.6rem; border-radius: 999px; white-space: nowrap;
}
.badge.bullish { background: rgba(61, 214, 198, 0.15); color: var(--positive); }
.badge.bearish { background: rgba(240, 113, 120, 0.15); color: var(--negative); }
.badge.mixed { background: var(--warm-dim); color: var(--warm); }
.badge.neutral { background: var(--surface); color: var(--text-muted); border: 1px solid var(--border); }
.status-pill {
  font-size: 0.65rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
  padding: 0.2rem 0.5rem; border-radius: 999px; background: var(--surface);
  border: 1px solid var(--border); color: var(--text-dim);
}
.status-pill.active { color: var(--accent); border-color: rgba(61, 214, 198, 0.3); }
.status-pill.fading { color: var(--warm); }
.status-pill.decayed { color: var(--text-dim); }
.metrics-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.75rem; }
.metric-pill {
  font-family: var(--font-mono); font-size: 0.68rem; padding: 0.2rem 0.5rem;
  border-radius: 6px; background: var(--surface); border: 1px solid var(--border);
  color: var(--text-muted);
}
.metric-pill strong { color: var(--text); }
.metric-pill.up strong:last-child { color: var(--positive); }
.metric-pill.down strong:last-child { color: var(--negative); }
.chg { font-family: var(--font-mono); font-size: 0.75rem; }
.chg.up { color: var(--positive); }
.chg.down { color: var(--negative); }
.chg.flat { color: var(--neutral); }
.star-btn {
  background: none; border: none; cursor: pointer; font-size: 1.1rem; line-height: 1;
  color: var(--text-dim); padding: 0.15rem; transition: color 0.2s, transform 0.2s;
}
.star-btn:hover { transform: scale(1.1); }
.star-btn.on { color: var(--warm); }
.pulse-btn {
  display: inline-flex; align-items: center; gap: 0.3rem;
  font-size: 0.72rem; font-weight: 700; font-family: var(--font-mono);
  text-transform: uppercase; letter-spacing: 0.05em;
  padding: 0.3rem 0.7rem; border-radius: 999px; cursor: pointer;
  background: var(--blue-dim); color: var(--blue); border: 1px solid transparent;
}
.pulse-btn:hover { border-color: var(--blue); }
.pulse-btn::before { content: "◉"; font-size: 0.65rem; }
.empty, .error-banner {
  padding: 2rem; text-align: center; color: var(--text-muted);
  border: 1px dashed var(--border-strong); border-radius: var(--radius-lg);
}
.error-banner {
  background: rgba(240, 113, 120, 0.08); border-color: rgba(240, 113, 120, 0.3);
  color: var(--negative); margin-bottom: 1.5rem; text-align: left; font-size: 0.9rem;
}
.error-banner code { font-family: var(--font-mono); font-size: 0.8rem; display: block; margin-top: 0.5rem; color: var(--text-muted); }

/* ───── narratives view ───── */
.grid-2 { display: grid; grid-template-columns: 1fr 300px; gap: 1.25rem; align-items: start; }
.grid-2 > * { min-width: 0; }
.pane-wrap.split .grid-2, .pane-wrap .pane[data-pane] .view-narrow .grid-2 { grid-template-columns: 1fr; }
@media (max-width: 1100px) { .grid-2 { grid-template-columns: 1fr; } }
.narratives { display: flex; flex-direction: column; gap: 1rem; }
.narrative-card {
  padding: 1.25rem; background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-lg); transition: border-color 0.2s;
}
.narrative-card:hover { border-color: var(--border-strong); }
.narrative-card.status-decayed { opacity: 0.55; }
.narrative-card.status-fading { opacity: 0.88; }
.narrative-top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 0.6rem 1rem; margin-bottom: 0.75rem; }
.narrative-top .nt-left { display: flex; align-items: flex-start; gap: 0.5rem; flex: 1 1 220px; min-width: 0; }
.narrative-top .nt-right { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; min-width: 0; }
.narrative-card h2 { font-size: 1.1rem; font-weight: 600; letter-spacing: -0.02em; }
.narrative-summary { color: var(--text-muted); font-size: 0.92rem; margin-bottom: 1rem; }
.themes { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 1rem; }
.theme {
  font-family: var(--font-mono); font-size: 0.7rem; padding: 0.2rem 0.5rem;
  border-radius: 6px; background: var(--accent-dim); color: var(--accent);
}
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.impacts-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.impacts-table th {
  text-align: left; font-family: var(--font-mono); font-size: 0.65rem;
  text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-dim);
  padding: 0.5rem 0.5rem 0.5rem 0; border-bottom: 1px solid var(--border);
}
.impacts-table td { padding: 0.6rem 0.5rem 0.6rem 0; border-bottom: 1px solid var(--border); vertical-align: middle; }
.impacts-table tr:last-child td { border-bottom: none; }
.asset-cell { font-family: var(--font-mono); font-weight: 500; }
.asset-link { cursor: pointer; color: var(--text); text-decoration: underline dotted var(--text-dim); }
.asset-link:hover { color: var(--accent); }
.asset-class-tag {
  font-family: var(--font-mono); font-size: 0.6rem; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-dim); flex-shrink: 0;
}
.alignment { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.alignment.confirmed { color: var(--positive); }
.alignment.divergent { color: var(--negative); }
.alignment.flat { color: var(--neutral); }
.sidebar-section { margin-bottom: 1.25rem; }
.index-list { list-style: none; display: flex; flex-direction: column; gap: 0.4rem; }
.index-list li {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 0.85rem; padding: 0.35rem 0; border-bottom: 1px solid var(--border);
}
.index-list li:last-child { border-bottom: none; }
.sources-list { font-size: 0.8rem; color: var(--text-muted); max-height: 180px; overflow-y: auto; }
.sources-list li { padding: 0.3rem 0; border-bottom: 1px solid var(--border); list-style: none; display: flex; justify-content: space-between; gap: 0.5rem; }

/* ───── assets view ───── */
.asset-list { display: flex; flex-direction: column; gap: 0.6rem; }
.asset-item {
  display: grid; grid-template-columns: auto 1fr auto; gap: 0.75rem 1rem;
  align-items: center; padding: 0.85rem 1rem;
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius);
}
.asset-item:hover { border-color: var(--border-strong); }
.asset-item .sym { font-family: var(--font-mono); font-weight: 600; font-size: 0.95rem; }
.asset-item .full-name { font-size: 0.8rem; color: var(--text-muted); }
.asset-item .asset-mid { min-width: 0; }
.asset-item .asset-right { display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap; justify-content: flex-end; }
.asset-item .price { font-family: var(--font-mono); font-size: 0.85rem; }
.narr-chips { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.35rem; }
.narr-chip {
  font-size: 0.68rem; font-weight: 600; padding: 0.18rem 0.5rem; border-radius: 999px;
  background: var(--accent-dim); color: var(--accent); cursor: pointer; border: none; font-family: inherit;
  max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.narr-chip.bearish { background: rgba(240, 113, 120, 0.13); color: var(--negative); }
.narr-chip.mixed { background: var(--warm-dim); color: var(--warm); }
.narr-chip.more { background: var(--surface); color: var(--text-dim); }

/* ───── graph view ───── */
.graph-shell { position: relative; }
.graph-shell.expanded {
  position: fixed; inset: 0; z-index: 400; background: var(--bg);
  padding: 1rem; display: flex; flex-direction: column;
}
.graph-canvas-wrap {
  position: relative; height: calc(100dvh - var(--header-h) - var(--tabbar-h) - 170px);
  min-height: 380px; border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--bg-elevated); overflow: hidden;
}
.graph-shell.expanded .graph-canvas-wrap { flex: 1; height: auto; }
.graph-canvas-wrap canvas { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
.graph-canvas-wrap canvas.grabbing { cursor: grabbing; }
.graph-canvas-wrap canvas.pointer { cursor: pointer; }
.graph-tooltip {
  position: absolute; z-index: 10; pointer-events: none; display: none;
  background: var(--bg-elevated); border: 1px solid var(--border-strong);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 0.6rem 0.8rem; font-size: 0.78rem; max-width: 280px;
}
.graph-tooltip .tt-title { font-weight: 600; margin-bottom: 0.2rem; }
.graph-tooltip .tt-row { display: flex; justify-content: space-between; gap: 1rem; color: var(--text-muted); font-family: var(--font-mono); font-size: 0.7rem; }
.graph-controls {
  position: absolute; top: 0.75rem; right: 0.75rem; z-index: 5;
  display: flex; flex-direction: column; gap: 0.35rem;
}
.graph-controls button {
  width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--bg-elevated); color: var(--text-muted); cursor: pointer; font-size: 0.95rem;
}
.graph-controls button:hover { color: var(--text); }
.graph-legend {
  display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 0.75rem;
  font-size: 0.75rem; color: var(--text-muted); align-items: center;
}
.graph-legend .lg { display: inline-flex; align-items: center; gap: 0.35rem; }
.graph-legend .dot { width: 10px; height: 10px; border-radius: 50%; }
.graph-hint { font-size: 0.72rem; color: var(--text-dim); margin-left: auto; }
.graph-select-toggle.active { border-color: var(--accent); color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.graph-select-box {
  position: absolute; z-index: 6; pointer-events: none;
  border: 1.5px dashed var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border-radius: 4px;
}
.graph-select-bar {
  position: absolute; left: 50%; bottom: 0.85rem; transform: translateX(-50%); z-index: 7;
  display: flex; align-items: center; gap: 0.65rem; flex-wrap: wrap; justify-content: center;
  padding: 0.55rem 0.85rem; border-radius: 999px;
  background: var(--bg-elevated); border: 1px solid var(--border-strong);
  box-shadow: var(--shadow); font-size: 0.78rem;
}
.graph-select-bar span { color: var(--text-muted); white-space: nowrap; }
.graph-select-bar button {
  border: none; border-radius: 999px; padding: 0.35rem 0.85rem; cursor: pointer;
  background: var(--accent); color: var(--bg); font-weight: 600; font-size: 0.75rem; font-family: inherit;
}
.graph-select-bar button:hover { filter: brightness(1.05); }
.graph-select-bar button.ghost {
  background: transparent; color: var(--text-muted); border: 1px solid var(--border);
}
.graph-canvas-wrap canvas.select-mode { cursor: crosshair; }
.graph-canvas-wrap canvas.selecting { cursor: crosshair; }

/* ───── pulse view ───── */
.pulse-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.pulse-head h2 { font-family: var(--font-serif); font-weight: 400; font-size: 1.7rem; letter-spacing: -0.02em; }
.pulse-head .sub { color: var(--text-muted); font-size: 0.9rem; }
.chart-box { position: relative; height: 300px; }
.chart-box canvas { display: block; width: 100%; height: 100%; }
.chart-tooltip {
  position: absolute; z-index: 5; pointer-events: none; display: none;
  background: var(--bg-elevated); border: 1px solid var(--border-strong); border-radius: 8px;
  padding: 0.4rem 0.6rem; font-family: var(--font-mono); font-size: 0.68rem; white-space: nowrap;
  box-shadow: var(--shadow);
}
.chart-legend { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 0.6rem; }
.chart-legend label {
  display: inline-flex; align-items: center; gap: 0.35rem; cursor: pointer;
  font-size: 0.75rem; color: var(--text-muted); font-family: var(--font-mono);
}
.chart-legend .swatch { width: 12px; height: 3px; border-radius: 2px; }
.pulse-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 1.25rem; align-items: start; }
.pulse-side-stack { display: flex; flex-direction: column; gap: 1.25rem; min-width: 0; }
@media (max-width: 1100px) { .pulse-grid { grid-template-columns: 1fr; } }
.pane-wrap.split .pulse-grid { grid-template-columns: 1fr; }
.related-list { display: flex; flex-direction: column; gap: 0.6rem; }
.related-item {
  padding: 0.75rem 0.9rem; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); cursor: pointer; transition: border-color 0.15s;
}
.related-item:hover { border-color: var(--accent); }
.related-item .ri-title { font-size: 0.85rem; font-weight: 600; display: flex; justify-content: space-between; gap: 0.5rem; align-items: center; }
.related-item .ri-sub { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.15rem; }
.source-item .source-title { min-width: 0; }
.source-item .source-title a { color: var(--text); text-decoration: none; }
.source-item .source-title a:hover { color: var(--accent); text-decoration: underline; }
.source-tag {
  flex-shrink: 0; font-size: 0.65rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent);
  padding: 0.15rem 0.45rem; border-radius: 999px;
}
.pulse-side-stack .sources-list { max-height: 420px; overflow-y: auto; }

/* ───── custom board ───── */
.board-head { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.board-head input[type="text"] {
  font-family: var(--font-serif); font-size: 1.4rem; background: transparent;
  border: none; border-bottom: 1px dashed var(--border-strong); color: var(--text);
  padding: 0.2rem 0; min-width: 220px;
}
.board-head input[type="text"]:focus { outline: none; border-bottom-color: var(--accent); }
.picker { position: relative; flex: 1 1 240px; max-width: 360px; }
.picker input {
  width: 100%; font-family: inherit; font-size: 0.85rem; padding: 0.5rem 0.85rem;
  border-radius: 999px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text);
}
.picker-results {
  position: absolute; z-index: 50; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--bg-elevated); border: 1px solid var(--border-strong);
  border-radius: var(--radius); box-shadow: var(--shadow); max-height: 280px; overflow-y: auto;
}
.picker-results button {
  display: flex; width: 100%; gap: 0.5rem; align-items: center; text-align: left;
  padding: 0.5rem 0.75rem; background: none; border: none; color: var(--text);
  font-family: inherit; font-size: 0.82rem; cursor: pointer;
}
.picker-results button:hover { background: var(--surface-hover); }
.picker-results .kind { font-family: var(--font-mono); font-size: 0.6rem; text-transform: uppercase; color: var(--text-dim); flex-shrink: 0; width: 28px; }
.board-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 1rem; }
.mini-card {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1rem; position: relative;
}
.mini-card .mc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.5rem; margin-bottom: 0.4rem; }
.mini-card .mc-title { font-weight: 600; font-size: 0.9rem; cursor: pointer; }
.mini-card .mc-title:hover { color: var(--accent); }
.mini-card .mc-sub { font-size: 0.72rem; color: var(--text-muted); }
.mini-card canvas { display: block; width: 100%; height: 64px; margin: 0.5rem 0; }
.mini-card .mc-remove {
  background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 1rem; line-height: 1;
}
.mini-card .mc-remove:hover { color: var(--negative); }

/* ───── misc ───── */
.fav-section { margin-bottom: 1.25rem; padding: 1rem; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.fav-list { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.5rem; }
.fav-pill {
  display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.8rem;
  padding: 0.3rem 0.65rem; border-radius: 999px; background: var(--warm-dim);
  color: var(--warm); border: 1px solid rgba(232, 168, 124, 0.25);
}
.fav-pill button { background: none; border: none; color: inherit; cursor: pointer; padding: 0; line-height: 1; font-size: 1rem; }

@media (max-width: 860px) {
  .pane-wrap.split { grid-template-columns: 1fr; }
  .pane-wrap.split .pane[data-pane="1"] { display: none; }
  .header-meta { display: none; }
}

@media (max-width: 640px) {
  .pane { padding: 0.85rem 0.75rem 3rem; }
  .header-inner { padding-inline: 0.75rem; }
  .tabbar { padding-inline: 0.75rem; }
  .narrative-card { padding: 1rem 0.85rem; }
  .narrative-card h2 { overflow-wrap: anywhere; font-size: 1rem; }
  .impacts-table { min-width: 540px; }
  .impacts-table th, .impacts-table td { padding-right: 0.75rem; }
  /* assets: narrative chips get their own full-width row */
  .asset-item { grid-template-columns: auto 1fr; }
  .asset-item .asset-right {
    grid-column: 1 / -1;
    justify-content: flex-start;
    gap: 0.5rem;
  }
  .narr-chip { max-width: 100%; }
  .graph-canvas-wrap { height: calc(100dvh - var(--header-h) - var(--tabbar-h) - 230px); min-height: 300px; }
  .graph-hint { display: none; }
}

/* ── auth gate ── */
body.auth-locked header,
body.auth-locked .tabbar,
body.auth-locked .pane-wrap {
  filter: blur(5px) saturate(0.85);
  opacity: 0.42;
  pointer-events: none;
  user-select: none;
  transition: filter 0.35s var(--ease), opacity 0.35s var(--ease);
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: rgba(7, 11, 18, 0.35);
  backdrop-filter: blur(2px);
  animation: auth-gate-in 0.4s var(--ease);
}

@keyframes auth-gate-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

[data-theme="light"] .auth-gate {
  background: rgba(246, 248, 252, 0.45);
}

.auth-card {
  width: min(100%, 400px);
  padding: 2rem 1.75rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
}

.auth-title {
  font-family: var(--font-serif);
  font-size: 1.75rem;
  font-weight: 400;
  margin-bottom: 0.35rem;
}

.auth-sub {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 1.25rem;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.auth-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.auth-input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.auth-input:focus {
  outline: 2px solid var(--accent-dim);
  border-color: var(--accent);
}

.auth-form .btn {
  width: 100%;
  justify-content: center;
  margin-top: 0.35rem;
}

.auth-foot {
  margin-top: 1rem;
  font-size: 0.8rem;
  color: var(--text-dim);
  text-align: center;
  line-height: 1.5;
}

.auth-notice {
  margin-bottom: 1rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  line-height: 1.45;
  border: 1px solid transparent;
}

.auth-notice--success {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: rgba(61, 214, 198, 0.25);
}

.auth-notice--error {
  background: rgba(240, 113, 120, 0.12);
  color: var(--negative);
  border-color: rgba(240, 113, 120, 0.25);
}

.auth-notice--info {
  background: var(--blue-dim);
  color: var(--blue);
  border-color: rgba(122, 165, 248, 0.25);
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1rem 0 0.75rem;
  color: var(--text-dim);
  font-size: 0.78rem;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.auth-link-btn {
  width: 100%;
  justify-content: center;
}

.auth-google-btn {
  width: 100%;
  justify-content: center;
  gap: 0.55rem;
}

.auth-google-icon {
  display: inline-flex;
  align-items: center;
  line-height: 0;
}

.auth-optional {
  color: var(--text-dim);
  font-weight: 400;
}

.auth-user-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.auth-user {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-dim);
  max-width: 148px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── site modals (profile, password, settings) ── */
body.modal-open {
  overflow: hidden;
}

.site-modal {
  position: fixed;
  inset: 0;
  z-index: 220;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.site-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(7, 11, 18, 0.55);
  backdrop-filter: blur(4px);
}

[data-theme="light"] .site-modal-backdrop {
  background: rgba(246, 248, 252, 0.65);
}

.site-modal-card {
  position: relative;
  width: min(100%, 420px);
  max-height: min(90dvh, 720px);
  overflow-y: auto;
  padding: 1.75rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
}

.site-modal-card--wide {
  width: min(100%, 480px);
}

.site-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.site-modal-title {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 400;
  line-height: 1.2;
}

.site-modal-sub {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
  line-height: 1.45;
}

.site-modal-close {
  font-size: 1.25rem;
  line-height: 1;
  flex-shrink: 0;
}

.settings-section {
  padding-top: 1.25rem;
  margin-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.settings-section:first-of-type {
  padding-top: 0;
  margin-top: 0;
  border-top: none;
}

.settings-heading {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 0.75rem;
}

.settings-section--signout {
  border-top: 1px solid var(--border);
  padding-top: 1.25rem;
  margin-top: 0.5rem;
}

.settings-signout-btn {
  width: 100%;
  justify-content: center;
  color: var(--negative);
  border-color: rgba(240, 113, 120, 0.35);
}

.settings-signout-btn:hover {
  background: rgba(240, 113, 120, 0.1);
  color: var(--negative);
}

.plus-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #1a1208;
  background: linear-gradient(135deg, #f5d078 0%, #e8a838 55%, #c8862a 100%);
  box-shadow: 0 0 0 1px rgba(232, 168, 56, 0.35);
}

.plus-badge--large {
  min-width: auto;
  height: auto;
  padding: 0.25rem 0.65rem;
  font-size: 0.72rem;
  margin-bottom: 0.5rem;
}

.plus-copy {
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.5;
  margin-bottom: 0.85rem;
}

.plus-copy strong {
  color: var(--text);
}

.plus-foot {
  color: var(--text-dim);
  font-size: 0.75rem;
  margin-top: 0.65rem;
  line-height: 1.4;
}

.plus-upgrade-btn {
  width: 100%;
  justify-content: center;
  text-decoration: none;
}

.plus-active {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.plus-modal-card {
  max-width: 26rem;
}

.plus-feature-list {
  margin: 0 0 1.25rem 1.1rem;
  padding: 0;
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.55;
}

.plus-feature-list li {
  margin-bottom: 0.35rem;
}

.plus-dismiss-btn {
  width: 100%;
  justify-content: center;
  margin-top: 0.65rem;
}

.plus-locked-panel {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 2rem;
  max-width: 28rem;
}
