/* SAT Prep — Bluebook-style theme */

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

:root {
  --bb-bg: #ffffff;
  --bb-surface: #f7f9fc;
  --bb-surface-2: #eef2f8;
  --bb-text: #1d2939;
  --bb-text-muted: #4a5568;
  --bb-border: #d0d5dd;
  --bb-blue: #324dc7;
  --bb-blue-hover: #233aa3;
  --bb-blue-light: #eaf0ff;
  --bb-green: #0e7c66;
  --bb-red: #c0392b;
  --bb-yellow: #d4a017;
  --bb-shadow: 0 1px 3px rgba(16,24,40,.08), 0 1px 2px rgba(16,24,40,.06);
  --topbar-h: 56px;
  --bottombar-h: 64px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

html, body {
  background: var(--bb-bg);
  color: var(--bb-text);
  height: 100%;
  font-size: 16px;
  line-height: 1.55;
}

.hidden { display: none !important; }

/* === Topbar / Bottombar === */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; background: var(--bb-surface); border-bottom: 1px solid var(--bb-border);
  z-index: 50;
}
.topbar-left, .topbar-right {
  display: flex; align-items: center; gap: 8px;
  flex: 1;
}
.topbar-right { justify-content: flex-end; }
.topbar-center { display: flex; align-items: center; justify-content: center; flex: 1; }
#topbar-title { font-weight: 600; color: var(--bb-text); font-size: 14px; }
.timer {
  font-family: "SF Mono", Menlo, monospace;
  font-size: 18px; font-weight: 600; padding: 6px 14px;
  background: white; border: 1px solid var(--bb-border); border-radius: 8px;
  min-width: 80px; text-align: center;
}
.timer.warning { color: var(--bb-yellow); border-color: var(--bb-yellow); }
.timer.danger { color: var(--bb-red); border-color: var(--bb-red); }

#bottombar {
  position: fixed; bottom: 0; left: 0; right: 0; height: var(--bottombar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; background: var(--bb-surface); border-top: 1px solid var(--bb-border);
  z-index: 50;
}

/* === Buttons === */
button { font: inherit; cursor: pointer; }
.primary-btn {
  background: var(--bb-blue); color: white; border: none;
  padding: 10px 24px; border-radius: 999px; font-weight: 600;
  font-size: 14px; min-width: 120px;
}
.primary-btn:hover { background: var(--bb-blue-hover); }
.primary-btn:disabled { background: #b0b8d0; cursor: not-allowed; }
.ghost-btn {
  background: transparent; color: var(--bb-text); border: 1px solid var(--bb-border);
  padding: 8px 14px; border-radius: 8px; font-weight: 500; font-size: 13px;
}
.ghost-btn:hover { background: var(--bb-surface-2); }
.danger-btn {
  background: white; color: var(--bb-red); border: 1px solid var(--bb-red);
  padding: 8px 14px; border-radius: 8px; font-weight: 500; font-size: 13px;
}
.danger-btn:hover { background: #ffe6e3; }

/* === Main / pages === */
#main {
  padding-top: 0; padding-bottom: 0;
  min-height: 100vh;
}
body.has-topbar #main { padding-top: var(--topbar-h); }
body.has-bottombar #main { padding-bottom: var(--bottombar-h); }

/* === Home / Dashboard === */
.home {
  max-width: 1100px; margin: 0 auto; padding: 32px 24px 80px;
}
.home h1 { font-size: 28px; margin-bottom: 4px; }
.home .sub { color: var(--bb-text-muted); margin-bottom: 32px; }

.dash-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; margin-bottom: 32px; }
@media (max-width: 800px) { .dash-grid { grid-template-columns: 1fr; } }

.card {
  background: white; border: 1px solid var(--bb-border); border-radius: 12px;
  padding: 20px; box-shadow: var(--bb-shadow);
}
.card h2 { font-size: 16px; margin-bottom: 12px; }
.card .big { font-size: 56px; font-weight: 700; line-height: 1; }
.card .label { color: var(--bb-text-muted); font-size: 13px; }

/* score card */
.score-totals { display: flex; gap: 24px; align-items: baseline; margin-bottom: 16px; }
.score-totals .total { font-size: 72px; font-weight: 700; line-height: 1; color: var(--bb-blue); }
.score-totals .delta { font-size: 16px; font-weight: 600; }
.score-totals .delta.up { color: var(--bb-green); }
.score-totals .delta.down { color: var(--bb-red); }
.score-sub { display: flex; gap: 32px; }
.score-sub .seg-label { font-size: 12px; color: var(--bb-text-muted); }
.score-sub .seg-val { font-size: 24px; font-weight: 600; }

.domain-bars { margin-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.domain-row {
  display: grid; grid-template-columns: 1fr 60px 80px; gap: 8px; align-items: center;
  font-size: 13px;
}
.domain-row .name { color: var(--bb-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.domain-row .bar-wrap {
  grid-column: 1 / -1; height: 6px; background: var(--bb-surface-2); border-radius: 3px; overflow: hidden;
}
.domain-row .bar { height: 100%; background: var(--bb-blue); }
.domain-row.weak .bar { background: var(--bb-red); }
.domain-row.strong .bar { background: var(--bb-green); }
.domain-row .acc { text-align: right; font-variant-numeric: tabular-nums; }

/* today card */
.today-task {
  background: var(--bb-blue-light); border-radius: 8px; padding: 16px;
  margin-bottom: 16px;
}
.today-task .task-line { font-size: 15px; line-height: 1.5; }
.today-task .week-info { color: var(--bb-text-muted); font-size: 12px; margin-bottom: 6px; }

.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 24px; }
.action-grid .action-btn {
  padding: 18px; background: white; border: 1px solid var(--bb-border); border-radius: 12px;
  text-align: left; cursor: pointer;
}
.action-grid .action-btn:hover { background: var(--bb-surface-2); border-color: var(--bb-blue); }
.action-grid .action-btn .title { font-weight: 600; margin-bottom: 4px; }
.action-grid .action-btn .desc { font-size: 12px; color: var(--bb-text-muted); }

.day-strip {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 16px;
}
.day-cell {
  border: 1px solid var(--bb-border); border-radius: 8px; padding: 8px 6px; text-align: center;
  font-size: 11px; cursor: pointer; background: white;
}
.day-cell.today { border-color: var(--bb-blue); background: var(--bb-blue-light); font-weight: 600; }
.day-cell.done { background: #ddf3ed; border-color: var(--bb-green); }
.day-cell.future { color: var(--bb-text-muted); }
.day-cell .d { font-size: 14px; font-weight: 600; }

/* === Question / lesson page === */
.qpage {
  display: grid; grid-template-columns: 1.3fr 380px;
  height: calc(100vh - var(--topbar-h) - var(--bottombar-h));
  overflow: hidden;
}
@media (max-width: 900px) { .qpage { grid-template-columns: 1fr; height: auto; } }
.qpane {
  overflow: auto; padding: 28px 32px;
  border-right: 1px solid var(--bb-border);
}
.apane {
  overflow: auto; padding: 24px;
  background: var(--bb-surface);
}
.qimg-wrap { max-width: 1100px; margin: 0 auto; }
.qimg-wrap img {
  width: 100%; height: auto; display: block;
  cursor: zoom-in;
  border-radius: 4px;
}
.qimg-wrap img:hover { box-shadow: 0 0 0 2px var(--bb-blue-light); }
.qimg-wrap .img-hint {
  text-align: center; font-size: 11px; color: var(--bb-text-muted);
  margin-top: 8px; opacity: 0.7;
}

/* answer choices */
.choices { display: flex; flex-direction: column; gap: 10px; }
.choice {
  padding: 16px 18px; background: white; border: 1px solid var(--bb-border); border-radius: 10px;
  display: flex; align-items: center; gap: 12px; cursor: pointer; user-select: none;
  transition: all 0.1s;
  font-size: 15px;
}
.choice:hover { border-color: var(--bb-blue); }
.choice .letter {
  width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--bb-border);
  display: flex; align-items: center; justify-content: center; font-weight: 600;
  background: white;
}
.choice.selected { border-color: var(--bb-blue); background: var(--bb-blue-light); }
.choice.selected .letter { background: var(--bb-blue); color: white; border-color: var(--bb-blue); }
.choice.eliminated { opacity: 0.4; text-decoration: line-through; }
.choice.eliminated .letter { background: #eee; }
.choice.correct { border-color: var(--bb-green); background: #ddf3ed; }
.choice.correct .letter { background: var(--bb-green); color: white; border-color: var(--bb-green); }
.choice.incorrect { border-color: var(--bb-red); background: #ffe6e3; }
.choice.incorrect .letter { background: var(--bb-red); color: white; border-color: var(--bb-red); }
.choice .label-text { font-size: 14px; color: var(--bb-text-muted); }

/* grid-in */
.grid-in {
  display: flex; flex-direction: column; gap: 12px;
}
.grid-in input {
  font: inherit; font-size: 24px; font-weight: 600;
  padding: 14px 16px; border: 2px solid var(--bb-border); border-radius: 10px;
  width: 100%; text-align: center;
}
.grid-in input:focus { outline: none; border-color: var(--bb-blue); }
.grid-in .preview {
  font-size: 13px; color: var(--bb-text-muted); text-align: center; min-height: 18px;
}

/* feedback panel */
.feedback {
  margin-top: 16px; padding: 16px; border-radius: 10px;
  border-left: 4px solid;
}
.feedback.correct { background: #ddf3ed; border-left-color: var(--bb-green); }
.feedback.incorrect { background: #ffe6e3; border-left-color: var(--bb-red); }
.feedback .verdict { font-weight: 600; margin-bottom: 8px; }
.feedback .your-ans { color: var(--bb-text-muted); font-size: 14px; margin-bottom: 8px; }
.rationale-img {
  width: 100%; height: auto; display: block; margin-top: 12px;
  border-radius: 8px; cursor: zoom-in;
}
.rationale-img:hover { box-shadow: 0 0 0 2px var(--bb-blue); }
.feedback .rationale-hint {
  font-size: 11px; color: var(--bb-text-muted); text-align: center;
  margin-top: 6px; font-style: italic;
}

/* Image fullscreen modal */
.img-modal {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0, 0, 0, 0.92);
  display: flex; align-items: center; justify-content: center;
  padding: 32px;
}
.img-modal .close {
  position: absolute; top: 16px; right: 20px;
  background: white; border: none; border-radius: 999px;
  width: 44px; height: 44px; font-size: 20px; cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
.img-modal img {
  max-width: 100%; max-height: 100%;
  background: white; padding: 24px; border-radius: 8px;
  cursor: zoom-out;
  object-fit: contain;
}

/* Report issue button row */
.q-actions {
  display: flex; justify-content: flex-end; margin-bottom: 12px;
}
.q-actions .report-btn {
  background: transparent; border: 1px solid var(--bb-border);
  padding: 4px 10px; border-radius: 6px; font-size: 12px;
  color: var(--bb-text-muted); cursor: pointer;
}
.q-actions .report-btn:hover { background: var(--bb-surface-2); color: var(--bb-red); border-color: var(--bb-red); }

/* Day nav header */
.day-nav { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.day-nav-label { display: flex; align-items: center; gap: 8px; }
.day-nav button { padding: 6px 12px; }
.day-cell.selected:not(.today) { box-shadow: 0 0 0 2px var(--bb-blue); }

/* === Floating panels (Desmos / Reference) === */
.floating-panel {
  position: fixed; top: 80px; right: 20px;
  width: 600px; height: 500px;
  background: white; border: 1px solid var(--bb-border); border-radius: 12px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.2);
  display: flex; flex-direction: column; z-index: 100;
}
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-bottom: 1px solid var(--bb-border); background: var(--bb-surface);
  border-radius: 12px 12px 0 0; cursor: move; user-select: none;
}
.panel-header span { font-weight: 600; font-size: 14px; }
#desmos-body { flex: 1; }
#ref-body { padding: 16px; overflow: auto; }

/* === Test summary / score reveal === */
.summary {
  max-width: 800px; margin: 32px auto; padding: 32px 24px;
}
.summary h1 { font-size: 32px; margin-bottom: 12px; }
.summary .score-display {
  text-align: center; padding: 32px; background: var(--bb-blue-light); border-radius: 16px;
  margin-bottom: 24px;
}
.summary .score-display .total {
  font-size: 96px; font-weight: 700; color: var(--bb-blue); line-height: 1;
}
.summary .score-display .breakdown {
  display: flex; gap: 32px; justify-content: center; margin-top: 16px;
}
.summary .score-display .breakdown .seg .label { font-size: 12px; color: var(--bb-text-muted); }
.summary .score-display .breakdown .seg .val { font-size: 32px; font-weight: 600; }

.q-list { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.q-list-row {
  display: grid; grid-template-columns: 32px 1fr 80px 90px;
  align-items: center; gap: 12px;
  padding: 10px 14px; border: 1px solid var(--bb-border); border-radius: 8px;
  background: white; cursor: pointer; font-size: 14px;
}
.q-list-row .num { font-weight: 600; }
.q-list-row .meta { color: var(--bb-text-muted); font-size: 12px; }
.q-list-row .verdict.correct { color: var(--bb-green); font-weight: 600; }
.q-list-row .verdict.incorrect { color: var(--bb-red); font-weight: 600; }
.q-list-row .verdict.skipped { color: var(--bb-text-muted); }
.q-list-row .time { font-variant-numeric: tabular-nums; color: var(--bb-text-muted); }
.q-list-row:hover { background: var(--bb-surface); }

/* Mistakes view variant — first column is a date, not a number */
.q-list-row.mistake-row {
  grid-template-columns: 90px 1fr 80px 90px;
  min-width: 0;
}
.mistake-date {
  font-size: 12px; color: var(--bb-text-muted);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.mistake-info { min-width: 0; overflow: hidden; }
.mistake-info > div:first-child {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mistake-choice {
  font-variant-numeric: tabular-nums; color: var(--bb-text-muted);
  text-align: center; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* === Custom test builder === */
.custom-form {
  max-width: 700px; margin: 32px auto; padding: 32px 24px;
}
.form-row {
  display: flex; flex-direction: column; gap: 8px;
  margin-bottom: 20px;
}
.form-row label { font-weight: 600; font-size: 14px; }
.checkbox-group { display: flex; flex-wrap: wrap; gap: 8px; }
.checkbox-group label {
  background: white; border: 1px solid var(--bb-border); border-radius: 999px;
  padding: 8px 14px; cursor: pointer; font-size: 13px; font-weight: 500;
  display: flex; align-items: center; gap: 6px;
}
.checkbox-group label.on { background: var(--bb-blue); color: white; border-color: var(--bb-blue); }
.checkbox-group input { display: none; }

input[type=number], select {
  font: inherit; font-size: 15px;
  padding: 10px 14px; border: 1px solid var(--bb-border); border-radius: 8px;
  background: white;
}

/* === Reference sheet === */
.ref-section { margin-bottom: 16px; }
.ref-section h3 { font-size: 14px; margin-bottom: 6px; }
.ref-section img { max-width: 100%; }
.ref-formula { font-family: "Times New Roman", serif; padding: 8px; }

/* === Module break / instructions === */
.module-card {
  max-width: 600px; margin: 80px auto; padding: 40px;
  background: white; border-radius: 16px; box-shadow: var(--bb-shadow);
  text-align: center;
}
.module-card h1 { font-size: 28px; margin-bottom: 16px; }
.module-card p { margin-bottom: 24px; color: var(--bb-text-muted); }
.break-timer { font-size: 64px; font-family: "SF Mono", monospace; color: var(--bb-blue); margin: 24px 0; }

/* utility */
.hstack { display: flex; gap: 12px; align-items: center; }
.vstack { display: flex; flex-direction: column; gap: 12px; }
.muted { color: var(--bb-text-muted); }
.tag {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; background: var(--bb-surface-2);
}
.tag.easy { background: #ddf3ed; color: var(--bb-green); }
.tag.medium { background: #fff5d4; color: #946205; }
.tag.hard { background: #ffe6e3; color: var(--bb-red); }

/* Sync status indicator (top right) */
#sync-indicator {
  font-size: 11px; font-weight: 500;
  padding: 4px 10px; border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
#sync-indicator.sync-ok { color: var(--bb-green); background: #ddf3ed; }
#sync-indicator.sync-pending { color: var(--bb-text-muted); background: var(--bb-surface-2); }
#sync-indicator.sync-warn { color: var(--bb-yellow); background: #fff5d4; }
