/* SAT Practice — DSAT-style B&W layout + reviewer toolkit */

:root {
  --ink: #0F0F0F;
  --char: #3A3A3A;
  --muted: #767676;
  --ghost: #BBBBBB;
  --line: #DDDDDD;
  --hover: #F4F4F4;
  --panel: #FAFAFA;
  --bg: #FFFFFF;
  --correct: #15803D;
  --wrong: #B91C1C;
  --status-ok: #15803D;
  --status-fix: #DC2626;
  --status-discuss: #D97706;
  --status-reject: #6B21A8;
  --tier1-bg: #F4F4F4;
  --tier2-bg: #DCDCDC;
  --tier3-bg: #BFBFBF;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Avenir Next", Avenir, -apple-system, BlinkMacSystemFont,
               system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Topbar ───────────────────────────────────────────── */
.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 12px 24px;
  border-bottom: 1px solid var(--line);
  background: white;
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 600; font-size: 14px; }
.progress { font-size: 14px; color: var(--char); text-align: center; }
.tools { display: flex; gap: 8px; align-items: center; }
.tool-btn {
  font-size: 13px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  background: white;
  cursor: pointer;
  border-radius: 4px;
  display: inline-flex; align-items: center; gap: 6px;
  user-select: none;
  font-family: inherit;
}
.tool-btn:hover { background: var(--hover); }
.tool-btn input[type="checkbox"] { margin: 0; }
.reviewer-input {
  font-size: 13px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  width: 160px;
  font-family: inherit;
}
.badge {
  background: var(--ink); color: white;
  border-radius: 9px;
  padding: 1px 7px;
  font-size: 11px;
  margin-left: 4px;
}
.badge[data-flag="0"] { background: var(--ghost); }

/* ── Body grid: sidebar + main ────────────────────────── */
.body-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 0;
  min-height: 0;
}

/* ── Sidebar ──────────────────────────────────────────── */
.sidebar {
  border-right: 1px solid var(--line);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 49px;
  align-self: start;
  height: calc(100vh - 49px);
}
.sidebar-header {
  padding: 10px 14px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  display: flex; justify-content: space-between; align-items: center;
  border-bottom: 1px solid var(--line);
}
.legend { display: flex; gap: 2px; }
.legend-tier { width: 8px; height: 8px; border-radius: 1px; }
.legend-tier.t1 { background: var(--tier1-bg); border: 1px solid var(--ghost); }
.legend-tier.t2 { background: var(--tier2-bg); }
.legend-tier.t3 { background: var(--tier3-bg); }

.grid-tiles {
  padding: 10px;
  overflow-y: auto;
  flex: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}
.tile {
  position: relative;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  padding: 8px 2px;
  border-radius: 3px;
  cursor: pointer;
  background: var(--tier1-bg);
  border: 1px solid transparent;
  color: var(--char);
  user-select: none;
  transition: border-color 0.1s;
}
.tile.t2 { background: var(--tier2-bg); }
.tile.t3 { background: var(--tier3-bg); color: var(--ink); }
.tile:hover { border-color: var(--ink); }
.tile.active {
  background: var(--ink);
  color: white;
  border-color: var(--ink);
}
.tile-icons {
  position: absolute;
  top: 1px; right: 2px;
  font-size: 8px;
  line-height: 1;
}
.tile-status-dot {
  position: absolute;
  bottom: 2px; right: 2px;
  width: 6px; height: 6px;
  border-radius: 50%;
}
.tile-status-dot.ok { background: var(--status-ok); }
.tile-status-dot.fix { background: var(--status-fix); }
.tile-status-dot.discuss { background: var(--status-discuss); }
.tile-status-dot.reject { background: var(--status-reject); }
.tile-multi {
  position: absolute;
  top: 1px; left: 2px;
  font-size: 8px;
  background: var(--ink);
  color: white;
  border-radius: 6px;
  padding: 0 4px;
  line-height: 12px;
}
.sidebar-footer {
  padding: 8px 14px;
  font-size: 11px;
  color: var(--muted);
  border-top: 1px solid var(--line);
}

/* ── Main pane ────────────────────────────────────────── */
.main-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.dsat {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  padding: 24px 32px 16px;
}
.stem { padding-right: 32px; border-right: 1px solid var(--line); }
.choices { padding-left: 32px; }
.stem-meta {
  display: flex; gap: 14px; align-items: center;
  font-size: 12px; color: var(--muted);
  margin-bottom: 14px; padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.tier-pill { font-weight: 600; letter-spacing: 1px; text-transform: uppercase; }
.stars { color: var(--ghost); letter-spacing: 1px; }
.stem-body { font-size: 16px; line-height: 1.65; }
.stem-figure { margin-top: 14px; text-align: center; }
.stem-figure img, .stem-figure svg {
  max-width: 90%; max-height: 320px;
}
.stem-table { margin-top: 14px; display: flex; justify-content: center; }
.stem-table table { border-collapse: collapse; font-size: 14px; }
.stem-table th, .stem-table td {
  border: 1px solid var(--line);
  padding: 6px 14px; text-align: center;
}
.stem-table th { font-weight: 600; background: var(--panel); }

/* ── Choices ──────────────────────────────────────────── */
.choices-tools {
  display: flex; gap: 12px;
  font-size: 12px;
  margin-bottom: 12px;
  color: var(--muted);
}
.mini-tog { display: flex; align-items: center; gap: 4px; cursor: pointer; }
.mini-btn {
  font-family: inherit; font-size: 12px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  background: white; cursor: pointer;
  border-radius: 3px;
}
.mini-btn:hover { background: var(--hover); }
.choice {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 12px;
  padding: 12px 16px;
  margin-bottom: 6px;
  border: 1.5px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  font-size: 15px;
  background: white;
  transition: border-color 0.1s, background 0.1s;
  align-items: start;
}
.choice:hover { background: var(--hover); border-color: var(--char); }
.choice.selected { border-color: var(--ink); background: #F9FAFB; }
.choice.struck { opacity: 0.4; text-decoration: line-through; }
.choice.correct { border-color: var(--correct); background: #F0FDF4; }
.choice.wrong { border-color: var(--wrong); background: #FEF2F2; }
.choice-key {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 1.5px solid var(--char);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 12px; color: var(--char);
  flex-shrink: 0;
}
.choice.selected .choice-key {
  background: var(--ink); color: white; border-color: var(--ink);
}
.choice-body img, .choice-body svg { max-width: 100%; max-height: 200px; }
.choice-body { text-align: left; }
.choice-body .katex-display { display: inline; margin: 0 !important; }
.choice-body .katex-display > .katex { font-size: 1.15em; }
.grid-in { margin-top: 18px; font-size: 15px; }
.grid-in input {
  font-family: inherit; font-size: 16px;
  padding: 10px 14px;
  border: 1.5px solid var(--char);
  border-radius: 4px;
  width: 200px; margin-left: 8px;
}

/* ── Feedback ─────────────────────────────────────────── */
.feedback {
  margin: 0 32px 16px;
  padding: 14px 20px;
  border-top: 2px solid var(--ink);
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.feedback-header {
  display: flex; align-items: center; gap: 14px;
  font-size: 14px; font-weight: 600;
  margin-bottom: 6px;
}
.feedback-header .correct-mark { color: var(--correct); }
.feedback-header .wrong-mark { color: var(--wrong); }
.feedback-body { font-size: 13px; line-height: 1.55; color: var(--char); }
.feedback-body .placeholder { font-style: italic; color: var(--muted); }

/* ── Reviewer notes panel ─────────────────────────────── */
.notes-panel {
  margin: 0 32px 16px;
  padding: 14px 20px;
  background: #FFFEF7;
  border: 1px solid #F0E5C0;
  border-radius: 6px;
}
.notes-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
}
.notes-title {
  font-size: 12px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--char); font-weight: 600;
}
.notes-save {
  font-size: 11px; color: var(--muted); font-style: italic;
}
.notes-save.saved { color: var(--correct); font-style: normal; }
.notes-status {
  display: flex; gap: 18px;
  margin-bottom: 10px;
  font-size: 13px;
}
.notes-status label {
  display: flex; align-items: center; gap: 5px;
  cursor: pointer;
  color: var(--char);
}
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot-ok { background: var(--status-ok); }
.dot-fix { background: var(--status-fix); }
.dot-discuss { background: var(--status-discuss); }
.dot-reject { background: var(--status-reject); }
.notes-panel textarea {
  width: 100%;
  font-family: inherit;
  font-size: 13px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  resize: vertical;
  min-height: 60px;
}

/* ── Other reviewers' notes ──────────────────────────────── */
#other-notes {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px dashed #E5DBB6;
}
.other-notes-head {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin-bottom: 8px;
}
.other-note {
  background: white;
  border: 1px solid #F0E5C0;
  border-radius: 4px;
  padding: 8px 12px;
  margin-bottom: 6px;
  font-size: 13px;
}
.other-note-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 12px;
}
.other-note-head .dot {
  margin-left: 4px;
}
.other-note-time {
  margin-left: auto;
  color: var(--muted);
  font-size: 11px;
}
.other-note-body {
  color: var(--char);
  white-space: pre-wrap;
}

/* ── Claude's resolution card ──────────────────────────── */
.resolution-card {
  background: #F0FDF4;
  border: 1px solid #BBF7D0;
  border-left: 3px solid var(--correct);
  border-radius: 4px;
  padding: 10px 14px;
  margin-top: 8px;
  font-size: 13px;
}
.resolution-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; margin-bottom: 4px;
  color: var(--correct);
}
.resolution-head .check {
  font-size: 14px; font-weight: 700;
}
.resolution-time { margin-left: auto; color: var(--muted); font-size: 11px; }
.resolution-body { color: var(--char); white-space: pre-wrap; }
.resolution-deploy {
  margin-top: 4px; font-size: 11px; color: var(--muted);
}
.resolution-deploy code {
  background: white; padding: 1px 5px; border-radius: 3px;
  border: 1px solid var(--line);
}

/* Sidebar tile resolved checkmark */
.tile-resolved {
  position: absolute;
  bottom: 1px; right: 2px;
  font-size: 9px;
  font-weight: 700;
  color: var(--correct);
  background: white;
  border-radius: 50%;
  width: 11px; height: 11px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--correct);
}

/* ── Navbar ───────────────────────────────────────────── */
.navbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 32px;
  border-top: 1px solid var(--line);
  background: white;
  position: sticky; bottom: 0;
}
.nav-btn {
  font-family: inherit; font-size: 14px;
  padding: 9px 22px;
  border: 1.5px solid var(--char);
  background: white; cursor: pointer;
  border-radius: 4px; font-weight: 500;
}
.nav-btn:hover { background: var(--hover); }
.nav-btn.primary {
  background: var(--ink); color: white; border-color: var(--ink);
}
.nav-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.nav-info { font-size: 13px; color: var(--muted); }

/* ── Modal (calculator) — DSAT-style side panel, problem stays visible ─ */
.modal {
  position: fixed;
  inset: 60px 16px 16px auto;          /* anchor right, not full screen */
  background: transparent;
  pointer-events: none;
  display: flex;
  z-index: 100;
}
.modal-content {
  pointer-events: auto;
  background: white;
  width: 540px;
  max-width: 50vw;
  height: 100%;
  max-height: calc(100vh - 80px);
  border-radius: 8px;
  position: relative;
  overflow: hidden;
  box-shadow: -4px 4px 24px rgba(0, 0, 0, 0.18);
  border: 1px solid var(--line);
}
.modal-close {
  position: absolute; top: 8px; right: 8px;
  background: white;
  border: 1px solid var(--line);
  width: 30px; height: 30px;
  border-radius: 50%; font-size: 16px;
  cursor: pointer; z-index: 1;
}

/* Bump KaTeX size + give fractions room to breathe (\dfrac is taller). */
.stem-body {
  line-height: 1.85;
  /* Preserve `\n\n` paragraph breaks from CB-extracted stems
     (e.g. equation on its own line). */
  white-space: pre-line;
}
.choice-body { line-height: 1.7; text-align: left; }
.stem-body .katex,
.choice-body .katex { font-size: 1.15em; }
.stem-table .katex { font-size: 1.05em; }

/* Display-mode equations (block-level) get more breathing room */
.katex-display { margin: 0.6em 0 !important; }
.katex-display > .katex { font-size: 1.25em; }
/* Stems with leading display equations or system/I-II arrays should
   left-align (review note: 좌측정렬 requested for I/II + system patterns) */
.stem-body .katex-display {
  text-align: left !important;
  padding-left: 0 !important;
  margin-left: 0 !important;
}
.stem-body .katex-display > .katex {
  text-align: left !important;
  margin-left: 0 !important;
  margin-right: auto !important;
}

@media (max-width: 1100px) {
  .body-grid { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}
