/* Layout: app shell with an input column on the left and stacked result panels on the right;
   one column on phones. Dark-first palette (the tool's original look) with a light variant. */
:root {
  --bg: #0f1115;
  --panel-bg: #171a21;
  --panel-border: #2a2e38;
  --tile-bg: #11141a;
  --text: #e6e8eb;
  --text-dim: #9aa1ac;
  --text-muted: #6f7682;
  --accent: #4f8cff;
  --accent-strong: #3f7ae0;
  --accent-dim: #2c4b8a;
  --accent-ink: #ffffff;
  --track: #1d2940;
  --zone: #1a2336;
  --band: rgba(79, 140, 255, 0.16);
  --area: rgba(79, 140, 255, 0.22);
  --obs: #d7dbe2;
  --good: #3fb950;
  --good-bg: #1b3320;
  --warn: #d29922;
  --warn-bg: #3a2f12;
  --bad: #f85149;
  --bad-bg: #3a1616;
  --info-bg: #22252d;
  --grid: #262a33;
  --row-hover: #1e222b;
  --row-current: #1a2336;
  --tooltip-bg: #0b0d11;
  --shadow: rgba(0, 0, 0, 0.35);
  --disabled-bg: rgba(51, 56, 69, 0.2);
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #eef1f5;
    --panel-bg: #ffffff;
    --panel-border: #d6dce5;
    --tile-bg: #f6f8fb;
    --text: #161b23;
    --text-dim: #525c6b;
    --text-muted: #8791a0;
    --accent: #2563d8;
    --accent-strong: #1d4fb0;
    --accent-dim: #9db8ec;
    --accent-ink: #ffffff;
    --track: #dde6f5;
    --zone: #e7eefb;
    --band: rgba(37, 99, 216, 0.14);
    --area: rgba(37, 99, 216, 0.18);
    --obs: #2a303a;
    --good: #1f7a33;
    --good-bg: #dff3e3;
    --warn: #9a6a00;
    --warn-bg: #fbefd2;
    --bad: #c62828;
    --bad-bg: #fbe1e1;
    --info-bg: #eceff4;
    --grid: #e4e8ee;
    --row-hover: #f1f4f9;
    --row-current: #e7eefb;
    --tooltip-bg: #ffffff;
    --shadow: rgba(20, 30, 50, 0.16);
    --disabled-bg: rgba(120, 130, 150, 0.15);
    color-scheme: light;
  }
}

:root[data-theme="light"] {
  --bg: #eef1f5;
  --panel-bg: #ffffff;
  --panel-border: #d6dce5;
  --tile-bg: #f6f8fb;
  --text: #161b23;
  --text-dim: #525c6b;
  --text-muted: #8791a0;
  --accent: #2563d8;
  --accent-strong: #1d4fb0;
  --accent-dim: #9db8ec;
  --accent-ink: #ffffff;
  --track: #dde6f5;
  --zone: #e7eefb;
  --band: rgba(37, 99, 216, 0.14);
  --area: rgba(37, 99, 216, 0.18);
  --obs: #2a303a;
  --good: #1f7a33;
  --good-bg: #dff3e3;
  --warn: #9a6a00;
  --warn-bg: #fbefd2;
  --bad: #c62828;
  --bad-bg: #fbe1e1;
  --info-bg: #eceff4;
  --grid: #e4e8ee;
  --row-hover: #f1f4f9;
  --row-current: #e7eefb;
  --tooltip-bg: #ffffff;
  --shadow: rgba(20, 30, 50, 0.16);
  --disabled-bg: rgba(120, 130, 150, 0.15);
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
}

code { font-family: var(--mono); font-size: 0.9em; }

/* ---------- header and mode tabs ---------- */

.app-head {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem 2rem;
  padding: 1.25rem 2rem 0;
  border-bottom: 1px solid var(--panel-border);
}

.app-head h1 { margin: 0 0 0.25rem; font-size: 1.5rem; text-wrap: balance; }

.brand { padding-bottom: 1rem; min-width: 0; }

.subtitle { margin: 0; color: var(--text-dim); font-size: 0.9rem; }

.mode-tabs { display: flex; gap: 0.25rem; }

.mode-tabs button {
  background: transparent;
  border: 1px solid transparent;
  border-bottom: none;
  color: var(--text-dim);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  padding: 0.6rem 1rem 0.7rem;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  position: relative;
  top: 1px;
}

.mode-tabs button:hover { color: var(--text); }

.mode-tabs button[aria-selected="true"] {
  background: var(--bg);
  color: var(--text);
  border-color: var(--panel-border);
  box-shadow: inset 0 2px 0 var(--accent);
}

.mode-tabs button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

main {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

#sidebar {
  flex: 0 0 420px;
  width: 420px;
  overflow-y: auto;
  border-right: 1px solid var(--panel-border);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

#results-area {
  flex: 1 1 auto;
  min-width: 0;
  overflow-y: auto;
  padding: 1.5rem 2rem 4rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

#school-results, #promoted-results { display: flex; flex-direction: column; gap: 1.5rem; min-width: 0; }
#school-results[hidden], #promoted-results[hidden] { display: none; }

.panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  min-width: 0;
}

.panel h2 { margin: 0 0 1rem; font-size: 1.05rem; text-wrap: balance; }

.panel h2 .opt, .opt { color: var(--text-muted); font-weight: 400; font-size: 0.78rem; margin-left: 0.35rem; }

.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 0.5rem; }
.panel-head h2 { margin: 0; }

.hint { color: var(--text-dim); font-size: 0.82rem; margin: 0 0 0.75rem; }
.hint.small { font-size: 0.78rem; margin: 0; }

/* ---------- inputs ---------- */

textarea {
  width: 100%;
  resize: vertical;
  background: var(--bg);
  border: 1px solid var(--panel-border);
  color: var(--text);
  border-radius: 6px;
  padding: 0.6rem 0.7rem;
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.45;
}

textarea:focus, input:focus, select:focus { outline: none; border-color: var(--accent); }

label.check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.84rem;
  color: var(--text-dim);
  margin: 0.6rem 0 0.9rem;
  cursor: pointer;
}

label.check input { accent-color: var(--accent); width: 1rem; height: 1rem; margin: 0; }

.param-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem 1rem;
  margin-bottom: 1rem;
}

.param-grid:last-child { margin-bottom: 0; }

.param-grid label {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 0.3rem;
  font-size: 0.82rem;
  color: var(--text-dim);
  min-width: 0;
}

.param-grid label.wide { grid-column: 1 / -1; }

.skills-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.param-grid input, .param-grid select {
  background: var(--bg);
  border: 1px solid var(--panel-border);
  color: var(--text);
  padding: 0.45rem 0.55rem;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 0.92rem;
  width: 100%;
  min-width: 0;
}

.param-grid select { font-family: var(--sans); font-size: 0.85rem; }

.param-grid input.filled { border-color: var(--accent-dim); }

.req { color: var(--warn); font-size: 0.72rem; margin-left: 0.35rem; }

.req.ok { color: var(--text-muted); }

.row-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.9rem; }

.row-actions .hint { margin: 0 0 0 0.25rem; }

button.primary-btn {
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  padding: 0.6rem 1.2rem;
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
  font-weight: 600;
}

button.primary-btn:hover:not(:disabled) { background: var(--accent-strong); }

button.primary-btn:disabled { background: var(--disabled-bg); color: var(--text-dim); cursor: not-allowed; }

button.secondary-btn {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--panel-border);
  padding: 0.4rem 0.85rem;
  border-radius: 6px;
  font-size: 0.82rem;
  cursor: pointer;
}

button.secondary-btn:hover { border-color: var(--accent); color: var(--text); }

button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#add-status { margin-left: 0.75rem; }

/* ---------- hero ---------- */

.rank-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }

.eyebrow { margin: 0; color: var(--text-dim); font-size: 0.85rem; }

.hero {
  margin: 0.1rem 0 0.2rem;
  font-size: 3.25rem;
  font-weight: 650;
  line-height: 1.1;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.hero-word { font-size: 1.1rem; font-weight: 500; color: var(--text-dim); margin-left: 0.6rem; letter-spacing: 0; }

.type-badge {
  flex: 0 0 auto;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  padding: 0.25rem 0.75rem;
  font-size: 0.8rem;
  color: var(--text-dim);
  white-space: nowrap;
}

.type-badge:empty { display: none; }

/* chance of reaching each level */
.prob-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }

.prob {
  display: grid;
  grid-template-columns: auto auto;
  align-items: baseline;
  gap: 0 0.5rem;
  min-width: 5.6rem;
  padding: 0.45rem 0.7rem 0.55rem;
  border-radius: 8px;
  background: var(--tile-bg);
  border: 1px solid var(--panel-border);
  position: relative;
  overflow: hidden;
}

.prob .lvl { font-size: 0.78rem; color: var(--text-dim); }
.prob .pct { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 0.95rem; font-weight: 600; text-align: right; }
.prob .meter { grid-column: 1 / -1; height: 4px; margin-top: 0.35rem; border-radius: 2px; background: var(--track); overflow: hidden; }
.prob .meter span { display: block; height: 100%; background: var(--accent); border-radius: 2px; }

/* ---------- prospect scale ---------- */

.scale { position: relative; margin: 1.25rem 0 0.5rem; height: 72px; }

.scale .zone { position: absolute; top: 18px; height: 24px; background: var(--zone); border-radius: 6px; }

.scale .zone-label { position: absolute; top: 0; right: 0; font-size: 0.72rem; color: var(--text-dim); white-space: nowrap; }

.scale .track { position: absolute; left: 0; right: 0; top: 26px; height: 8px; background: var(--track); border-radius: 4px; }

.scale .fill { position: absolute; left: 0; top: 26px; height: 8px; background: var(--accent); border-radius: 4px; }

.scale .dot {
  position: absolute; top: 20px; width: 20px; height: 20px;
  margin-left: -10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--panel-bg);
}

.scale .tick { position: absolute; top: 44px; width: 1px; height: 6px; background: var(--text-muted); }

.scale .tick-label { position: absolute; top: 52px; transform: translateX(-50%); font-size: 0.72rem; color: var(--text-dim); white-space: nowrap; }

/* ---------- tiles ---------- */

/* five tiles: three across on wide screens, rows always filled (3 + 2), one per row on phones */
.tiles { display: flex; flex-wrap: wrap; gap: 0.75rem; }

.tile {
  flex: 1 1 14rem;
  background: var(--tile-bg);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 0.8rem 1rem;
  min-width: 0;
}

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

.tile .value { font-size: 1.6rem; font-weight: 650; margin-top: 0.15rem; line-height: 1.2; font-variant-numeric: tabular-nums; }

.tile .value .unit { font-size: 0.95rem; font-weight: 500; color: var(--text-dim); margin-left: 0.25rem; }

.tile .sub { color: var(--text-dim); font-size: 0.78rem; margin-top: 0.25rem; }

/* ---------- checks ---------- */

.checks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }

.checks li { display: flex; gap: 0.6rem; align-items: flex-start; font-size: 0.86rem; }

.checks .icon {
  flex: 0 0 auto;
  font-family: var(--mono);
  font-size: 0.72rem;
  border-radius: 4px;
  padding: 0.05rem 0.4rem;
  margin-top: 0.1rem;
}

.checks .ok   .icon { background: var(--good-bg); color: var(--good); }
.checks .warn .icon { background: var(--warn-bg); color: var(--warn); }
.checks .bad  .icon { background: var(--bad-bg); color: var(--bad); }
.checks .info .icon { background: var(--info-bg); color: var(--text-dim); }

/* ---------- tables ---------- */

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }

th, td { padding: 0.45rem 0.7rem; text-align: left; border-bottom: 1px solid var(--panel-border); white-space: nowrap; }

th { color: var(--text-dim); font-weight: 600; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.04em; }

th[data-sort] { cursor: pointer; user-select: none; }
th[data-sort]:hover { color: var(--text); }
th.sorted::after { content: " ▾"; color: var(--accent); }
th.sorted.asc::after { content: " ▴"; }

th.r, td.r { text-align: right; }

td.num, td.r { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.stage { font-size: 0.74rem; border: 1px solid var(--panel-border); border-radius: 999px; padding: 0.05rem 0.5rem; color: var(--text-dim); }
.stage.school { border-color: var(--accent-dim); color: var(--accent); }

.frac { display: inline-flex; align-items: center; gap: 0.5rem; }

.frac .bar { width: 90px; height: 6px; background: var(--track); border-radius: 3px; position: relative; overflow: hidden; }

.frac .bar span { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); border-radius: 3px; }

.frac .txt { font-family: var(--mono); color: var(--text-dim); font-size: 0.78rem; }

#compare-table tbody tr { cursor: pointer; }

#compare-table tbody tr:hover { background: var(--row-hover); }

#compare-table tbody tr.current { background: var(--row-current); }

.x-btn { background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 1rem; line-height: 1; padding: 0.1rem 0.3rem; }

.x-btn:hover { color: var(--bad); }

/* ---------- charts ---------- */

.chart { position: relative; width: 100%; }

.chart svg { display: block; width: 100%; height: auto; overflow: visible; }

.chart .axis-text { fill: var(--text-dim); font-size: 11px; font-family: var(--sans); }

.chart .axis-title { fill: var(--text-muted); font-size: 11px; font-family: var(--sans); }

.chart .grid { stroke: var(--grid); stroke-width: 1; }

.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; }

.chart .line.future { stroke-dasharray: 5 4; }

.chart .band { fill: var(--band); stroke: none; }

.chart .area { fill: var(--area); stroke: none; }

.chart .obs { fill: var(--obs); stroke: var(--panel-bg); stroke-width: 1.5; }

.chart .obs.missing { fill: none; }

.chart .marker { fill: var(--accent); stroke: var(--panel-bg); stroke-width: 2; }

.chart .ref { stroke: var(--text-muted); stroke-width: 1; stroke-dasharray: 3 3; }

.chart .now { stroke: var(--text-muted); stroke-width: 1; }

.chart .ref-text { fill: var(--text-dim); font-size: 11px; font-family: var(--sans); }

.chart .cross { stroke: var(--text-muted); stroke-width: 1; }

.legend { display: flex; flex-wrap: wrap; gap: 0.4rem 1.2rem; margin-top: 0.6rem; font-size: 0.78rem; color: var(--text-dim); }

.legend span { display: inline-flex; align-items: center; gap: 0.4rem; }

.key { display: inline-block; flex: 0 0 auto; }
.key-dot { width: 4px; height: 12px; border-radius: 2px; background: var(--obs); }
.key-line { width: 18px; height: 2px; background: var(--accent); border-radius: 1px; }
.key-band { width: 18px; height: 10px; background: var(--band); border-radius: 2px; }
.key-area { width: 18px; height: 10px; background: var(--area); border-radius: 2px; }
.key-ref { width: 18px; height: 0; border-top: 1px dashed var(--text-muted); }

.tooltip {
  position: fixed;
  z-index: 10;
  pointer-events: none;
  background: var(--tooltip-bg);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  font-size: 0.8rem;
  color: var(--text);
  box-shadow: 0 4px 14px var(--shadow);
  font-variant-numeric: tabular-nums;
}

.tooltip .muted { color: var(--text-dim); }

/* ---------- method ---------- */

details summary { cursor: pointer; font-weight: 600; font-size: 0.95rem; }

.method { color: var(--text-dim); font-size: 0.84rem; margin-top: 0.75rem; max-width: 72ch; }

.method p { margin: 0 0 0.6rem; }

.method strong { color: var(--text); font-weight: 600; }

.method code { color: var(--text); }

/* ---------- responsive ---------- */

@media (max-width: 960px) {
  html, body { height: auto; }
  body { display: block; }
  main { display: block; overflow: visible; }
  #sidebar { width: auto; border-right: none; border-bottom: 1px solid var(--panel-border); padding: 1rem; }
  #results-area { padding: 1rem 1rem 3rem; overflow: visible; }
  .app-head { padding: 1rem 1rem 0; }
  .hero { font-size: 2.6rem; }
}

@media (max-width: 600px) {
  .scale .tick-label.minor { display: none; }
  .mode-tabs { width: 100%; }
  .mode-tabs button { flex: 1 1 0; padding: 0.55rem 0.5rem 0.65rem; }
  .panel { padding: 1rem 1.1rem; }
}

@media (max-width: 480px) {
  .skills-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rank-head { flex-direction: column; }
  .hero-word { display: block; margin: 0.2rem 0 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
