@import url('https://fonts.googleapis.com/css2?family=Newsreader:opsz,wght@6..72,500;6..72,600&family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --bg: #faf9f5;
  --surface: #ffffff;
  --surface-subtle: #f3f1ea;
  --surface-hover: #ece9df;
  --border: #e5e2d9;
  --border-strong: #d4d0c5;
  --text: #141413;
  --text-2: #4a4843;
  --muted: #78756c;

  --accent: #c6613f;
  --accent-hover: #b25232;
  --accent-soft: rgba(198, 97, 63, 0.1);

  --green: #1f7a53;
  --green-soft: rgba(31, 122, 83, 0.1);
  --amber: #a8640b;
  --amber-soft: rgba(168, 100, 11, 0.1);
  --red: #b9382c;
  --red-soft: rgba(185, 56, 44, 0.1);
  --blue: #2563a8;
  --blue-soft: rgba(37, 99, 168, 0.1);

  --serif: 'Newsreader', Georgia, 'Times New Roman', serif;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
}

[data-theme="dark"] {
  --bg: #141413;
  --surface: #1b1b19;
  --surface-subtle: #23221f;
  --surface-hover: #2b2a26;
  --border: #2e2d28;
  --border-strong: #3f3d36;
  --text: #f3f1ea;
  --text-2: #c9c6bc;
  --muted: #8f8b80;

  --accent: #d97757;
  --accent-hover: #e38667;
  --accent-soft: rgba(217, 119, 87, 0.14);

  --green: #4ade9a;
  --green-soft: rgba(74, 222, 154, 0.12);
  --amber: #f5b942;
  --amber-soft: rgba(245, 185, 66, 0.13);
  --red: #f2746b;
  --red-soft: rgba(242, 116, 107, 0.13);
  --blue: #6fb1fc;
  --blue-soft: rgba(111, 177, 252, 0.13);
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14.5px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}

.tnum { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); }
.serif { font-family: var(--serif); }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--text);
}

.brand-mark {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--accent);
}

.save-pill {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  padding: 2px 8px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--surface);
}
.save-pill.ok { color: var(--green); }

.segmented {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: var(--radius);
  background: var(--surface-subtle);
  border: 1px solid var(--border);
}

.seg-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 7px;
  cursor: pointer;
  transition: color 0.14s, background 0.14s;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  transition: border-color 0.14s, color 0.14s;
}
.icon-btn:hover { border-color: var(--border-strong); color: var(--text); }

/* Main container */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 20px 24px 40px;
}

/* Hero Readiness Band */
.hero-band {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 24px;
  align-items: center;
  padding: 28px 30px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
}

.eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  font-weight: 600;
}

.hero-title {
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin: 6px 0 8px;
}

.hero-sub {
  color: var(--text-2);
  font-size: 13.5px;
  margin: 0 0 20px;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

/* Score Gauge */
.score-panel {
  padding-left: 24px;
  border-left: 1px solid var(--border);
}

.score-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}

.score-num {
  font-family: var(--serif);
  font-size: 44px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.03em;
}

.score-scale {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

.gauge-track {
  position: relative;
  height: 10px;
  background: var(--surface-subtle);
  border-radius: 99px;
  overflow: visible;
  margin-bottom: 14px;
}

.gauge-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.35s ease;
}

.gauge-pass-mark {
  position: absolute;
  left: 68.89%; /* (720-100)/900 */
  top: -4px;
  bottom: -4px;
  width: 2px;
  background: var(--text);
  opacity: 0.7;
}
.gauge-pass-label {
  position: absolute;
  left: 68.89%;
  top: 14px;
  transform: translateX(-50%);
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
}

.mini-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 24px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.mini-stat-label { font-size: 11px; color: var(--muted); }
.mini-stat-val { font-family: var(--mono); font-size: 15px; font-weight: 600; margin-top: 2px; }

/* Buttons & Inputs */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 15px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.14s, border-color 0.14s, transform 0.08s;
}
.btn:hover:not(:disabled) { background: var(--surface-subtle); border-color: var(--text-2); }
.btn:active:not(:disabled) { transform: translateY(0.5px); }
.btn:disabled { opacity: 0.42; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text-2);
}
.btn-ghost:hover:not(:disabled) { background: var(--surface-subtle); color: var(--text); }

.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn-danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 35%, transparent); }
.btn-danger:hover:not(:disabled) { background: var(--red-soft); border-color: var(--red); }

select, input[type="search"] {
  padding: 7px 11px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
}
select:focus, input:focus, textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: 1px;
}

/* Cards & Grids */
.grid-main {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 20px;
  align-items: start;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
}

.card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.card-title {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 500;
  margin: 0;
}

.card-sub { font-size: 12px; color: var(--muted); }

/* Custom Filter Strip */
.filter-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 12px 16px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
}

.filter-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  margin-right: 4px;
}

/* Domain Heatmap */
.domain-row {
  display: grid;
  grid-template-columns: 1fr 110px 52px 72px;
  align-items: center;
  gap: 14px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.domain-row:last-child { border-bottom: none; padding-bottom: 0; }
.domain-title { font-size: 13.5px; font-weight: 500; color: var(--text); }
.domain-id { font-family: var(--mono); font-size: 11.5px; color: var(--muted); margin-right: 6px; }
.domain-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }

.bar-track {
  height: 6px;
  background: var(--surface-subtle);
  border-radius: 99px;
  overflow: hidden;
}
.bar-fill { height: 100%; border-radius: 99px; transition: width 0.3s; }

/* Calibration 2x2 Matrix */
.matrix-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.matrix-cell {
  padding: 14px 15px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  cursor: pointer;
  transition: border-color 0.14s, transform 0.1s;
  text-align: left;
}
.matrix-cell:hover { transform: translateY(-1px); border-color: var(--text-2); }
.matrix-cell.danger { background: var(--red-soft); border-color: color-mix(in srgb, var(--red) 30%, transparent); }
.matrix-cell.gap { background: var(--amber-soft); border-color: color-mix(in srgb, var(--amber) 30%, transparent); }
.matrix-cell.lucky { background: var(--blue-soft); border-color: color-mix(in srgb, var(--blue) 30%, transparent); }
.matrix-cell.mastered { background: var(--green-soft); border-color: color-mix(in srgb, var(--green) 30%, transparent); }

.matrix-count { font-family: var(--serif); font-size: 28px; font-weight: 600; line-height: 1.1; }
.matrix-label { font-size: 12.5px; font-weight: 600; margin-top: 4px; color: var(--text); }
.matrix-desc { font-size: 11.5px; color: var(--muted); margin-top: 1px; }

.session-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
}
.session-item:last-child { border-bottom: none; }

/* Badges */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 500;
  background: var(--surface-subtle);
  color: var(--text-2);
  border: 1px solid var(--border);
}
.tag.accent { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 28%, transparent); }
.tag.green { background: var(--green-soft); color: var(--green); border-color: color-mix(in srgb, var(--green) 28%, transparent); }
.tag.red { background: var(--red-soft); color: var(--red); border-color: color-mix(in srgb, var(--red) 28%, transparent); }
.tag.amber { background: var(--amber-soft); color: var(--amber); border-color: color-mix(in srgb, var(--amber) 28%, transparent); }
.tag.blue { background: var(--blue-soft); color: var(--blue); border-color: color-mix(in srgb, var(--blue) 28%, transparent); }

/* Study / Practice Focus Layout */
.study-wrap {
  max-width: 1280px;
  margin: 0 auto;
}

.study-split {
  display: grid;
  grid-template-columns: 1.12fr 0.88fr;
  gap: 18px;
  align-items: start;
}

.study-split.pre-submit {
  grid-template-columns: 0.95fr 1.05fr;
}

.study-col-right {
  position: sticky;
  top: 72px;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
}

.progress-hairline {
  height: 3px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 12px;
}
.progress-hairline-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.25s ease;
}

.study-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.study-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
}

.question-stem {
  font-size: 15px;
  line-height: 1.62;
  color: var(--text);
  white-space: pre-wrap;
  margin: 0 0 16px;
}

.question-stem code, .opt-text code, .explanation-body code {
  font-family: var(--mono);
  font-size: 0.87em;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 5px;
}

.question-stem pre, .explanation-body pre {
  margin: 10px 0;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.5;
}
.question-stem pre code, .explanation-body pre code {
  background: transparent;
  border: none;
  padding: 0;
  font-size: inherit;
}

.options-stack {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.opt-btn {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  width: 100%;
  padding: 13px 15px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14.5px;
  line-height: 1.55;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.opt-btn:hover:not(.locked) { border-color: var(--border-strong); background: var(--surface-subtle); }
.opt-btn.selected { border-color: var(--accent); background: var(--accent-soft); }
.opt-btn.correct { border-color: var(--green); background: var(--green-soft); }
.opt-btn.wrong { border-color: var(--red); background: var(--red-soft); }
.opt-btn.locked { cursor: default; }

.opt-key {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  margin-top: 1px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text-2);
}
.opt-btn.selected .opt-key { background: var(--accent); border-color: var(--accent); color: #fff; }
.opt-btn.correct .opt-key { background: var(--green); border-color: var(--green); color: #fff; }
.opt-btn.wrong .opt-key { background: var(--red); border-color: var(--red); color: #fff; }

.opt-rationale {
  display: block;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--border-strong);
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-2);
}

.study-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.conf-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.conf-pill {
  padding: 6px 11px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: 0.12s;
}
.conf-pill:hover:not(:disabled) { border-color: var(--border-strong); color: var(--text); }
.conf-pill.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.explanation-panel {
  margin-top: 0;
  padding: 18px 20px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
}
.explanation-body {
  font-size: 14px;
  line-height: 1.68;
  color: var(--text-2);
  white-space: pre-wrap;
  margin-top: 12px;
}

.note-area {
  width: 100%;
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  resize: vertical;
  min-height: 64px;
}

.kbd {
  font-family: var(--mono);
  font-size: 10.5px;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--surface-subtle);
  border: 1px solid var(--border-strong);
  color: var(--muted);
}

.shortcut-hint {
  margin-top: 14px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

.mock-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 16px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.mock-dot {
  width: 28px;
  height: 26px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: 0.1s;
}
.mock-dot:hover { border-color: var(--text-2); color: var(--text); }
.mock-dot.answered { background: var(--surface-subtle); color: var(--text); border-color: var(--border-strong); font-weight: 600; }
.mock-dot.flagged { border-color: var(--amber); color: var(--amber); }
.mock-dot.current { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

.submit-conf-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

/* History Table */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
th {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
tr:hover td { background: var(--surface-subtle); }

@media (max-width: 960px) {
  .hero-band, .grid-main, .study-split, .study-split.pre-submit { grid-template-columns: 1fr; }
  .study-col-right { position: static; max-height: none; overflow: visible; }
  .score-panel { padding-left: 0; border-left: none; padding-top: 18px; border-top: 1px solid var(--border); }
  .topbar-inner { flex-wrap: wrap; padding: 10px 16px; gap: 10px; }
  .study-card { padding: 18px 16px; }
  .domain-row { grid-template-columns: 1fr 54px 62px; gap: 10px; }
  .domain-row .bar-track { display: none; }
}

@media (max-width: 640px) {
  .container { padding: 14px 12px 48px; }
  .topbar-inner { padding: 10px 12px; }
  .brand { font-size: 16px; }
  .segmented { width: 100%; justify-content: space-between; }
  .seg-btn { flex: 1; text-align: center; padding: 6px 8px; font-size: 12px; }
  .topbar-right { width: 100%; justify-content: space-between; }
  .hero-band { padding: 18px 16px; gap: 16px; }
  .hero-title { font-size: 22px; }
  .score-num { font-size: 36px; }
  .action-row .btn { flex: 1 1 auto; }
  .filter-strip select, .filter-strip input[type="search"] { flex: 1 1 140px; min-width: 0; }
  .matrix-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .matrix-cell { padding: 12px; }
  .matrix-count { font-size: 22px; }
  .opt-btn { padding: 12px; font-size: 14px; min-height: 48px; }
  .study-footer { flex-direction: column; align-items: stretch; gap: 10px; }
  .submit-conf-group { display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; gap: 6px; }
  .submit-conf-group .btn { padding: 10px 6px; font-size: 12.5px; }
  .conf-row { width: 100%; justify-content: space-between; }
  .conf-pill { flex: 1; text-align: center; padding: 8px 6px; }
  .explanation-panel { padding: 14px; }
  .card { padding: 16px 14px; }
  .kbd, .shortcut-hint { display: none; }
}

@media (hover: none) {
  .kbd, .shortcut-hint { display: none; }
}
