/* ═══════════════════════════════════════════════════════════
   macpsy — Design System
   Reset → Tokens → Nav → Columns → Detail → Chart → Terminal
   ═══════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Tokens: Light ── */
:root {
  --bg:          #ffffff;
  --bg-sub:      #f9f9fa;
  --surface:     #f3f3f5;
  --surface-2:   #ebebed;
  --border:      #e5e5e8;
  --border-2:    #d5d5d9;

  --text:        #111113;
  --text-2:      #3d3d44;
  --text-3:      #6e6e76;

  --accent:      #2563eb;
  --accent-bg:   rgba(37,99,235,.07);
  --accent-text: #1d4ed8;
  --premium:     #7c3aed;
  --green:       #16a34a;
  --red:         #dc2626;
  --amber:       #d97706;

  --nav-w:   200px;
  --col-w:   240px;
  --radius:  6px;
  --radius-md: 8px;
  --radius-lg: 12px;

  --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI",
          "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", ui-monospace, "Fira Code", "Cascadia Code", monospace;
  --ease: cubic-bezier(.25, 0, .15, 1);
}

/* ── Tokens: Dark ── */
[data-theme="dark"] {
  --bg:          #0d0d0f;
  --bg-sub:      #111114;
  --surface:     #1a1a1d;
  --surface-2:   #232327;
  --border:      #2c2c30;
  --border-2:    #3a3a3f;

  --text:        #ededed;
  --text-2:      #b0b0b8;
  --text-3:      #68686f;

  --accent:      #3b82f6;
  --accent-bg:   rgba(59,130,246,.09);
  --accent-text: #60a5fa;
  --premium:     #a78bfa;
  --green:       #22c55e;
  --red:         #f87171;
  --amber:       #fbbf24;
}

/* ── Base ── */
html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  overflow: hidden;
  height: 100vh;
}

a { color: inherit; }

::-webkit-scrollbar          { width: 4px; height: 4px; }
::-webkit-scrollbar-track    { background: transparent; }
::-webkit-scrollbar-thumb    { background: var(--border-2); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }
* { scrollbar-width: thin; scrollbar-color: var(--border-2) transparent; }


/* ═══════════════════════════════════════════════════════════
   LEFT NAV
   ═══════════════════════════════════════════════════════════ */
.left-nav {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--nav-w);
  background: var(--bg-sub);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
}

/* Brand */
.nav-brand {
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  user-select: none;
}

.nav-brand-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -.03em;
  color: var(--text);
  line-height: 1.15;
}

.nav-brand-sub {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 3px;
  letter-spacing: .01em;
  font-weight: 400;
}

/* Nav section */
.nav-section-label {
  padding: 14px 16px 6px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-3);
  user-select: none;
}

.nav-items {
  flex: 1;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

/* Nav item — shared between <a> and <button> */
.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 7px 10px;
  border-radius: var(--radius);
  border: none;
  background: transparent;
  color: var(--text-2);
  font-family: var(--font);
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.4;
  cursor: pointer;
  text-decoration: none;
  transition: background 90ms, color 90ms;
}
.nav-item:hover {
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}
.nav-item.active {
  background: var(--accent-bg);
  color: var(--accent-text);
  font-weight: 600;
}

.nav-icon {
  font-size: 13px;
  width: 16px;
  flex-shrink: 0;
  text-align: center;
  opacity: .6;
  line-height: 1;
}
.nav-item:hover .nav-icon,
.nav-item.active .nav-icon { opacity: 1; }

.nav-label { font-size: 13.5px; }

/* Footer */
.nav-footer {
  flex-shrink: 0;
  padding: 8px;
  border-top: 1px solid var(--border);
}


/* ═══════════════════════════════════════════════════════════
   COLUMN VIEW (Finder-style)
   ═══════════════════════════════════════════════════════════ */
.columns {
  display: flex;
  height: 100vh;
  margin-left: var(--nav-w);
  overflow: hidden;
}

/* Each column */
.col {
  flex-shrink: 0;
  width: var(--col-w);
  border-right: 1px solid var(--border);
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  animation: colIn .16s var(--ease) both;
}

@keyframes colIn {
  from { opacity: 0; transform: translateX(10px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* Column header */
.col-header {
  padding: 10px 16px 8px;
  border-bottom: 1px solid var(--border);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-3);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 1;
  user-select: none;
}

/* Column row */
.col-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 9px 14px 9px 16px;
  border: none;
  border-left: 2px solid transparent;
  background: transparent;
  color: var(--text);
  font-family: var(--font);
  font-size: 13.5px;
  font-weight: 450;
  text-align: left;
  cursor: pointer;
  transition: background 80ms, color 80ms, border-color 80ms;
}
.col-item:hover {
  background: var(--surface);
}
.col-item.active {
  border-left-color: var(--accent);
  background: var(--accent-bg);
  color: var(--accent-text);
  font-weight: 600;
}

/* Cell sub-elements */
.ci-icon   { font-size: 13px; flex-shrink: 0; opacity: .75; }
.ci-label  { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ci-arrow  {
  font-size: 10px; color: var(--text-3); flex-shrink: 0;
  opacity: 0; transition: opacity 80ms; margin-left: auto;
}
.col-item:hover .ci-arrow,
.col-item.active .ci-arrow { opacity: 1; }

/* Stock item */
.stock-item .ci-ticker {
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--accent-text);
  flex-shrink: 0;
  min-width: 44px;
  letter-spacing: .02em;
}
.stock-item .ci-label {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-2);
}
.stock-item.active .ci-label { color: var(--accent-text); }


/* ═══════════════════════════════════════════════════════════
   DETAIL PANEL
   ═══════════════════════════════════════════════════════════ */
.col-detail {
  flex: 1;
  min-width: 0;
  height: 100%;
  overflow-y: auto;
  border-right: none;
  width: auto;
  animation: colIn .2s var(--ease) both;
  background: var(--bg-sub);
  display: flex;
  flex-direction: column;
}

/* Empty state */
.detail-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px 52px;
  max-width: 480px;
}
.de-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.04em;
  color: var(--text);
  margin-bottom: 8px;
  line-height: 1.2;
}
.de-sub {
  font-size: 14px;
  color: var(--text-2);
  line-height: 1.7;
}

/* Stock detail — scroll container */
.detail-stock-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 36px 52px 56px;
}

/* Stock detail */
.sd-breadcrumb {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-3);
  margin-bottom: 20px;
  display: flex;
  gap: 6px;
  align-items: center;
}
.sd-breadcrumb span + span::before { content: "/"; opacity: .5; margin-right: 6px; }

.sd-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 28px;
}

.sd-header-text { flex: 1; }

.sd-ticker {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-text);
  letter-spacing: .08em;
  margin-bottom: 5px;
  text-transform: uppercase;
}

.sd-name {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -.045em;
  line-height: 1.1;
  margin-bottom: 5px;
  color: var(--text);
}

.sd-meta {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-3);
  letter-spacing: .02em;
}

.sd-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0 0 24px;
}

.sd-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 8px;
}

.sd-text {
  font-size: 14px;
  line-height: 1.75;
  color: var(--text-2);
  max-width: 540px;
}

.sd-kost {
  margin-top: 24px;
  padding: 18px 22px;
  background: var(--surface);
  border-radius: var(--radius-md);
  border-left: 3px solid var(--premium);
  max-width: 540px;
}
.sd-kost-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--premium);
  margin-bottom: 8px;
}
.sd-kost-text {
  font-size: 14px;
  line-height: 1.72;
  color: var(--text-2);
}

.sd-links {
  display: flex;
  gap: 8px;
  margin-top: 28px;
}

.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 16px;
  border-radius: 980px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-2);
  font-family: var(--font);
  font-size: 12.5px;
  font-weight: 500;
  text-decoration: none;
  transition: background 90ms, color 90ms, border-color 90ms;
}
.link-btn:hover {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-2);
  text-decoration: none;
}


/* ═══════════════════════════════════════════════════════════
   CHART PAGE
   ═══════════════════════════════════════════════════════════ */
body.chart-page {
  overflow: auto;
  height: auto;
}

.chart-wrap {
  padding: 28px 0 64px;
  margin-left: var(--nav-w);
}

.chart-body {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 28px;
  display: grid;
  grid-template-columns: 1fr 290px;
  gap: 28px;
  align-items: start;
}
@media (max-width: 820px) {
  .chart-body { grid-template-columns: 1fr; }
  .chart-detail-col { order: -1; }
}

.chart-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -.025em;
  color: var(--text);
  margin-bottom: 3px;
}
.chart-hint {
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 14px;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  font-size: 12.5px;
  margin-bottom: 14px;
  min-height: 20px;
}
.breadcrumb-item {
  color: var(--accent-text);
  cursor: pointer;
  padding: 1px 4px;
  border-radius: 4px;
  transition: background 80ms;
}
.breadcrumb-item:hover { background: var(--surface); }
.breadcrumb-item.current { color: var(--text-3); cursor: default; }
.breadcrumb-item.current:hover { background: transparent; }
.breadcrumb-sep { color: var(--border-2); }

#chart-svg-wrap { display: flex; justify-content: center; }
#chart-svg      { display: block; max-width: 100%; height: auto; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 14px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-3);
  cursor: pointer;
  transition: color 80ms;
}
.legend-item:hover { color: var(--text); }
.legend-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }

/* Chart detail card */
.chart-detail-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 18px 20px;
  position: sticky;
  top: 28px;
}
.cdc-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 12px;
}
.cdc-empty   { font-size: 13px; color: var(--text-3); line-height: 1.65; }

.csd-ticker  { font-family: var(--mono); font-size: 13px; font-weight: 700; color: var(--accent-text); }
.csd-name    { font-size: 14px; font-weight: 600; margin-top: 3px; color: var(--text); }
.csd-ex      { font-size: 11.5px; color: var(--text-3); margin: 3px 0 12px; }
.csd-lbl     { font-size: 10.5px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--text-3); margin: 10px 0 4px; }
.csd-text    { font-size: 13px; line-height: 1.65; color: var(--text-2); }
.csd-kost    { margin-top: 10px; padding: 10px 12px; background: var(--bg); border-radius: var(--radius); border-left: 2px solid var(--premium); }
.csd-kl      { font-size: 10.5px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--premium); margin-bottom: 4px; }
.csd-kt      { font-size: 13px; line-height: 1.6; color: var(--text-2); }
.csd-links   { display: flex; gap: 8px; margin-top: 12px; }

.node-name   { font-size: 15px; font-weight: 600; letter-spacing: -.01em; color: var(--text); }
.node-stats  { display: flex; gap: 20px; margin-top: 12px; }
.stat-val    { font-size: 22px; font-weight: 700; color: var(--accent-text); line-height: 1; font-variant-numeric: tabular-nums; }
.stat-lbl    { font-size: 11px; color: var(--text-3); margin-top: 3px; }

#tooltip {
  position: fixed;
  pointer-events: none;
  background: var(--text);
  color: var(--bg);
  border-radius: var(--radius);
  padding: 6px 10px;
  font-size: 12.5px;
  font-family: var(--font);
  line-height: 1.4;
  z-index: 999;
  display: none;
  max-width: 200px;
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
}
#tt-sub { opacity: .55; font-size: 11.5px; margin-top: 1px; }


/* ═══════════════════════════════════════════════════════════
   TERMINAL PAGE — base (all themes)
   ═══════════════════════════════════════════════════════════ */
body.terminal-page {
  overflow: auto !important;
  height: auto !important;
  background: var(--bg);
  color: var(--text);
}

body.terminal-page main {
  margin-left: var(--nav-w);
  padding-top: 0;
}

/* Timestamp label adapts to theme */
.kt-muted { color: var(--text-3); }

/* ── Terminal: dark mode nav overrides ── */
[data-theme="dark"] body.terminal-page .left-nav       { background: #0f0f12; border-right-color: #222226; }
[data-theme="dark"] body.terminal-page .nav-brand      { border-bottom-color: #222226; }
[data-theme="dark"] body.terminal-page .nav-brand-name { color: #e2e2e6; }
[data-theme="dark"] body.terminal-page .nav-brand-sub  { color: #44444c; }
[data-theme="dark"] body.terminal-page .nav-footer     { border-top-color: #222226; }
[data-theme="dark"] body.terminal-page .nav-item       { color: #50505a; }
[data-theme="dark"] body.terminal-page .nav-item:hover { background: rgba(255,255,255,.04); color: #b0b0ba; }
[data-theme="dark"] body.terminal-page .nav-item.active {
  background: rgba(59,130,246,.1);
  color: #60a5fa;
}

/* ── Terminal: light mode — reset hardcoded Tailwind charcoal/zinc classes ── */
[data-theme="light"] body.terminal-page .bg-charcoal-800 { background: var(--bg) !important; }
[data-theme="light"] body.terminal-page .bg-charcoal-700 { background: var(--surface) !important; }
[data-theme="light"] body.terminal-page .border-charcoal-700 { border-color: var(--border) !important; }
[data-theme="light"] body.terminal-page .border-charcoal-600 { border-color: var(--border-2) !important; }

[data-theme="light"] body.terminal-page .text-zinc-300  { color: var(--text) !important; }
[data-theme="light"] body.terminal-page .text-zinc-400  { color: var(--text-2) !important; }
[data-theme="light"] body.terminal-page .text-zinc-500  { color: var(--text-2) !important; }
[data-theme="light"] body.terminal-page .text-zinc-600  { color: var(--text-3) !important; }
[data-theme="light"] body.terminal-page .text-zinc-700  { color: var(--text-3) !important; }

[data-theme="light"] body.terminal-page .bg-charcoal-700.rounded-full { background: var(--surface-2) !important; }

/* Table rows */
[data-theme="light"] body.terminal-page thead tr    { border-color: var(--border) !important; }
[data-theme="light"] body.terminal-page tbody tr    { border-color: var(--border) !important; }
[data-theme="light"] body.terminal-page .phase-row-active { background: rgba(37,99,235,.06) !important; border-left-color: var(--accent) !important; }

/* Input field */
[data-theme="light"] body.terminal-page .bg-charcoal-700.border { background: var(--surface) !important; border-color: var(--border-2) !important; color: var(--text) !important; }

/* Score output panels use inline border/bg set by JS — no override needed */


/* ═══════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 600px) {
  :root { --col-w: 170px; }
  .col-detail  { padding: 24px 20px; }
  .sd-name     { font-size: 20px; }
}

@media (max-width: 480px) {
  :root { --nav-w: 52px; }
  .nav-brand-name, .nav-brand-sub, .nav-label, .nav-section-label { display: none; }
  .nav-brand  { padding: 13px 0; display: flex; justify-content: center; align-items: center; }
  .nav-items  { padding: 6px; }
  .nav-item   { justify-content: center; padding: 9px 0; }
  .nav-icon   { width: auto; font-size: 15px; opacity: .7; }
  .nav-footer { padding: 6px; }
}
