/* ==========================================================================
   Design tokens + skeleton — Operate surface (dark, precise, dense)
   Vocabulary: Linear (near-black canvas, luminance stepping,
   translucent white borders, Inter cv01/ss03, weight 510)
   ========================================================================== */

:root {
  /* surfaces — elevation via luminance stepping, never solid */
  --bg:            #08090a;
  --panel:         #0f1011;
  --surface:       #191a1b;
  --surface-2:     #28282c;
  --sheen-1:       rgba(255,255,255,0.02);
  --sheen-2:       rgba(255,255,255,0.04);
  --sheen-3:       rgba(255,255,255,0.06);

  /* text */
  --ink:           #f7f8f8;
  --ink-2:         #d0d6e0;
  --ink-3:         #8a8f98;
  --ink-4:         #62666d;

  /* single chromatic accent — CTA/interactive only */
  --accent:        #5e6ad2;
  --accent-hi:     #7170ff;
  --accent-hover:  #828fff;

  /* status */
  --ok:            #10b981;
  --ok-dim:        rgba(16,185,129,0.12);
  --bad:           #e5484d;
  --bad-dim:       rgba(229,72,77,0.12);
  --warn:          #f5a524;
  --flag:          #f5a524;

  /* borders */
  --line:          rgba(255,255,255,0.08);
  --line-soft:     rgba(255,255,255,0.05);
  --line-solid:    #23252a;

  /* radii */
  --r-xs: 2px; --r-sm: 4px; --r: 6px; --r-md: 8px; --r-lg: 12px; --r-pill: 9999px;

  /* metrics */
  --topbar-h: 52px;
  --rail-w: 264px;
  --maxw: 1440px;

  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', 'Noto Sans Thai', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  font-feature-settings: 'cv01', 'ss03';
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.6;
  letter-spacing: -0.165px;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--accent); color: #fff; }

:focus-visible {
  outline: 2px solid var(--accent-hi);
  outline-offset: 2px;
}

/* ---------- top bar: monitor strip, dense, never decorative ---------- */

.topbar {
  position: sticky; top: 0; z-index: 50;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 16px;
  padding: 0 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line-soft);
}

.brand {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 590; letter-spacing: -0.182px;
  color: var(--ink); white-space: nowrap;
}
.brand-mark {
  width: 20px; height: 20px; border-radius: var(--r-sm);
  background: var(--accent);
  display: grid; place-items: center;
  font-size: 11px; font-weight: 590; color: #fff;
}
.brand-sub { color: var(--ink-4); font-weight: 400; font-size: 13px; }

.topbar-spacer { flex: 1; }

/* live readouts — monospace so digits don't jitter */
.readout {
  display: flex; align-items: baseline; gap: 6px;
  padding: 4px 10px;
  background: var(--sheen-1);
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  font-variant-numeric: tabular-nums;
}
/* a class-level `display: flex` beats the UA `[hidden]` rule, so opt out
   explicitly — otherwise stale exam readouts stay visible on the results view */
.readout[hidden] { display: none; }
.readout-label {
  font-size: 10px; font-weight: 510; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--ink-4);
}
.readout-value {
  font-family: var(--mono); font-size: 13px; font-weight: 500; color: var(--ink);
}
.readout.is-urgent { border-color: rgba(229,72,77,0.4); background: var(--bad-dim); }
.readout.is-urgent .readout-value { color: var(--bad); }

/* thin progress line under the bar — glanceable, no chrome */
.progress-line {
  position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
  background: transparent;
}
.progress-line > i {
  display: block; height: 100%; width: 0;
  background: var(--accent-hi);
  transition: width .25s ease;
}

/* ---------- shell: rail + work area (Operate composition) ---------- */

.shell {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  max-width: var(--maxw);
  margin: 0 auto;
  min-height: calc(100vh - var(--topbar-h));
}

.rail {
  border-right: 1px solid var(--line-soft);
  padding: 16px 14px 40px;
  position: sticky; top: var(--topbar-h);
  align-self: start;
  max-height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
}

.work { padding: 24px 28px 72px; min-width: 0; }

.rail-title {
  font-size: 10px; font-weight: 510; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--ink-4);
  margin-bottom: 10px;
}

.hint {
  font-size: 12px; color: var(--ink-4); line-height: 1.5;
}
.hint kbd {
  font-family: var(--mono); font-size: 11px;
  padding: 1px 5px; margin: 0 1px;
  background: var(--sheen-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-xs);
  color: var(--ink-2);
}

.divider { height: 1px; background: var(--line-soft); margin: 16px 0; }

.view { display: none; }
.view.is-active { display: block; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .rail {
    position: static; max-height: none; order: 2;
    border-right: 0; border-top: 1px solid var(--line-soft);
  }
  .work { order: 1; padding: 18px 16px 48px; }
  .brand-sub { display: none; }
}
