@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=DM+Sans:wght@400;500;600;700&family=Fraunces:opsz,wght@9..144,500;9..144,600&display=swap');

:root {
  --ink: #19312f;
  --muted: #70817e;
  --faint: #aab9b4;
  --line: #dfe8e4;
  --surface: #ffffff;
  --canvas: #f4f7f5;
  --accent: #147c6b;
  --accent-dark: #0d6254;
  --mint: #e4f2ed;
  --coral: #df725e;
  --coral-soft: #fff0ec;
  --green: #13805d;
  --green-soft: #e9f8f0;
  --shadow: 0 18px 50px rgba(34, 65, 57, .08);
  --radius: 20px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: 'DM Sans', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, select:focus-visible { outline: 3px solid rgba(20, 124, 107, .28); outline-offset: 3px; }

.app-shell { max-width: 1060px; margin: 0 auto; padding: 0 28px 50px; }
.topbar { height: 84px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; background: var(--accent); color: white; font: 500 12px 'DM Mono', monospace; letter-spacing: -.08em; }
.brand strong, .brand small { display: block; line-height: 1.05; }
.brand strong { font-size: 14px; letter-spacing: -.02em; }
.brand small { margin-top: 4px; color: var(--muted); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.top-actions { display: flex; align-items: center; gap: 11px; }
.icon-button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); color: var(--muted); font-size: 20px; line-height: 1; transition: .2s ease; }
.icon-button:hover { color: var(--accent); border-color: #b8d7ce; transform: rotate(-15deg); }
.save-state { color: var(--muted); font: 11px 'DM Mono', monospace; }

.intro { display: flex; align-items: end; justify-content: space-between; gap: 30px; padding: 48px 0 45px; }
.data-tools { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 18px; margin-bottom: 24px; padding: 17px 19px; border: 1px solid #b8d7ce; border-radius: 15px; background: var(--mint); }
.data-tools h2 { margin: 0; font-size: 18px; letter-spacing: -.03em; }
.data-tools p:not(.eyebrow):not(.sheets-status) { max-width: 660px; margin: 7px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.data-tools .sheets-status { grid-column: 1 / -1; margin: 0; }
.data-tools-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.eyebrow { margin: 0 0 18px; color: var(--accent); font: 500 11px 'DM Mono', monospace; letter-spacing: .12em; text-transform: uppercase; }
h1 { margin: 0; max-width: 680px; font-size: clamp(38px, 6vw, 70px); line-height: .99; letter-spacing: -.065em; font-weight: 600; }
h1 em { color: var(--accent); font-family: 'Fraunces', Georgia, serif; font-weight: 500; letter-spacing: -.07em; }
.intro-copy { max-width: 470px; margin: 22px 0 0; color: var(--muted); font-size: 15px; line-height: 1.6; }
.streak-card { flex: 0 0 155px; padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.54); }
.streak-label { display: block; color: var(--muted); font: 10px 'DM Mono', monospace; text-transform: uppercase; letter-spacing: .08em; }
.streak-card strong { display: block; margin: 7px 0 2px; font: 600 34px 'Fraunces', Georgia, serif; color: var(--accent); }
.streak-card span:last-child { color: var(--muted); font-size: 11px; }

.controls { padding: 6px 0 23px; border-bottom: 1px solid var(--line); }
.mode-tabs { display: flex; gap: 4px; width: fit-content; margin-bottom: 15px; padding: 3px; border: 1px solid var(--line); border-radius: 11px; background: rgba(255,255,255,.5); }
.mode-tab { min-height: 32px; padding: 0 12px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font: 11px 'DM Mono', monospace; letter-spacing: .02em; }
.mode-tab:hover { color: var(--ink); }
.mode-tab.active { background: var(--ink); color: white; }
.mode-tab span { display: inline-grid; place-items: center; min-width: 18px; height: 18px; margin-left: 4px; padding: 0 4px; border-radius: 9px; background: rgba(255,255,255,.2); font-size: 10px; }
.mode-tab:not(.active) span { background: var(--mint); color: var(--accent); }
.subject-tabs { display: flex; gap: 5px; padding: 4px; width: fit-content; border-radius: 13px; background: #e9efec; }
.subject-tab { display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 15px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-size: 13px; transition: .2s ease; }
.subject-tab:hover { color: var(--ink); }
.subject-tab.active { background: var(--surface); color: var(--ink); box-shadow: 0 2px 8px rgba(35,70,59,.08); font-weight: 600; }
.tab-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.tab-dot.chem { background: #d68c3e; }
.tab-dot.phys { background: #6c72b9; }
.filter-row { display: flex; align-items: center; gap: 10px; margin-top: 21px; }
.practice-filters { display: block; }
.paper-tracker-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.paper-tracker-heading .eyebrow { margin-bottom: 5px; }
.paper-tracker-heading h2 { margin: 0; font-size: 20px; letter-spacing: -.03em; }
.tracker-legend { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 9px 13px; color: var(--muted); font: 10px 'DM Mono', monospace; }
.tracker-legend span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.tracker-dot { display: inline-block; width: 9px; height: 9px; border: 1px solid transparent; border-radius: 3px; }
.tracker-dot.done { border-color: #76bd9e; background: #c9eddb; }
.tracker-dot.not-done { border-color: #efa696; background: #ffd9d1; }
.tracker-dot.not-uploaded { border-color: #cbd6d2; background: #fff; }
.paper-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); gap: 9px; margin-top: 16px; }
.paper-cell { display: flex; min-height: 92px; flex-direction: column; align-items: flex-start; justify-content: space-between; padding: 12px; border: 1px solid #efa696; border-radius: 13px; background: #ffd9d1; color: #913a2d; text-align: left; transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease; }
.paper-cell strong { font: 500 18px 'Fraunces', Georgia, serif; letter-spacing: -.03em; }
.paper-cell span { margin-top: 4px; font-size: 12px; font-weight: 600; }
.paper-cell small { margin-top: 8px; font: 10px 'DM Mono', monospace; opacity: .85; }
.paper-cell.done { border-color: #76bd9e; background: #c9eddb; color: #0b5d43; }
.paper-cell.not-uploaded { border-color: #cbd6d2; background: #fff; color: var(--faint); cursor: not-allowed; }
.paper-cell.selected { box-shadow: 0 0 0 3px rgba(20,124,107,.22); }
.paper-cell:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 5px 14px rgba(34,65,57,.08); }
.tracker-actions { justify-content: flex-end; }
.select-wrap { display: flex; align-items: center; gap: 8px; color: var(--muted); font: 11px 'DM Mono', monospace; text-transform: uppercase; letter-spacing: .04em; }
select { min-height: 40px; padding: 0 30px 0 12px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: var(--surface); font: 12px 'DM Sans', sans-serif; text-transform: none; letter-spacing: normal; }
.shuffle-button { display: inline-flex; align-items: center; gap: 7px; min-height: 40px; margin-left: auto; padding: 0 14px; border: 1px solid var(--line); border-radius: 10px; color: var(--accent); background: transparent; font-size: 12px; transition: .2s ease; }
.shuffle-button:hover { background: var(--mint); border-color: #b8d7ce; }
.sheet-panel { margin: 2px 0 22px; padding: 20px; border: 1px solid #b8d7ce; border-radius: 15px; background: var(--mint); }
.sheet-panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; }
.sheet-panel .eyebrow { margin-bottom: 7px; }
.sheet-panel h2 { margin: 0; font-size: 21px; letter-spacing: -.03em; }
.sheet-panel p:not(.eyebrow) { max-width: 700px; margin: 12px 0 15px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.panel-close { width: 30px; height: 30px; border: 1px solid #b8d7ce; border-radius: 8px; background: rgba(255,255,255,.55); color: var(--muted); font-size: 21px; line-height: 1; }
.endpoint-label { display: block; margin-bottom: 6px; color: var(--ink); font: 10px 'DM Mono', monospace; letter-spacing: .06em; text-transform: uppercase; }
.endpoint-row { display: flex; gap: 8px; }
.endpoint-row input { flex: 1; min-width: 0; min-height: 40px; padding: 0 11px; border: 1px solid #b8d7ce; border-radius: 9px; background: white; color: var(--ink); font: 12px 'DM Sans', sans-serif; }
.sheets-token { display: block; width: 100%; min-height: 40px; margin-bottom: 12px; padding: 0 11px; border: 1px solid #b8d7ce; border-radius: 9px; background: white; color: var(--ink); font: 12px 'DM Sans', sans-serif; }
.save-sheets-button { min-height: 40px; padding: 0 14px; border: 1px solid var(--accent); border-radius: 9px; background: var(--accent); color: white; font-size: 12px; }
.sync-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.sync-button { min-height: 38px; padding: 0 12px; border: 1px solid var(--accent); border-radius: 9px; background: var(--accent); color: white; font-size: 12px; }
.sync-button.secondary { border-color: #b8d7ce; background: transparent; color: var(--muted); }
.sync-button:disabled { cursor: wait; opacity: .55; }
.sync-status { margin-bottom: 0 !important; font: 11px 'DM Mono', monospace; }
.sheets-status { margin-bottom: 0 !important; font: 11px 'DM Mono', monospace; }
.panel-close:hover { color: var(--ink); }

.progress-line { padding: 24px 0 16px; }
.progress-meta { display: flex; justify-content: space-between; margin-bottom: 8px; color: var(--muted); font: 11px 'DM Mono', monospace; }
.progress-track { height: 4px; overflow: hidden; border-radius: 4px; background: #dfe8e4; }
.progress-bar { width: 25%; height: 100%; border-radius: inherit; background: var(--accent); transition: width .25s ease; }

.question-card { position: relative; min-height: 400px; padding: clamp(25px, 5vw, 46px); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.question-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; color: var(--faint); font: 10px 'DM Mono', monospace; letter-spacing: .1em; }
.question-tag { color: var(--accent); font-weight: 500; }
.question-card h2 { max-width: 760px; margin: 0 0 29px; font-size: clamp(20px, 3vw, 29px); line-height: 1.28; letter-spacing: -.035em; font-weight: 600; white-space: pre-line; }
.question-support { margin: -12px 0 25px; padding: 13px 16px; border-radius: 10px; background: #f4f8f6; color: var(--muted); font-size: 13px; line-height: 1.5; }
.question-support span { display: block; margin-bottom: 10px; font: 10px 'DM Mono', monospace; letter-spacing: .05em; text-transform: uppercase; }
.question-support img { display: block; width: min(100%, 720px); max-height: 420px; object-fit: contain; object-position: top left; border: 1px solid var(--line); border-radius: 8px; background: white; }
.options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; max-width: 780px; }
.bookmark-button { display: inline-flex; align-items: center; min-height: 38px; margin-top: 14px; padding: 0 14px; border: 1px solid var(--line); border-radius: 9px; background: transparent; color: var(--muted); font-size: 12px; transition: .18s ease; }
.bookmark-button:hover { border-color: #91c4b7; background: var(--mint); color: var(--accent); }
.bookmark-button.is-bookmarked { border-color: #dfb64d; background: #fff5d6; color: #765500; }
.option { position: relative; display: flex; align-items: center; min-height: 60px; padding: 13px 15px 13px 48px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); text-align: left; font-size: 14px; line-height: 1.35; transition: border-color .18s ease, background .18s ease, transform .18s ease; }
.option:hover:not(:disabled) { border-color: #91c4b7; background: #fbfdfc; transform: translateY(-1px); }
.option:disabled { cursor: default; }
.option-letter { position: absolute; left: 15px; display: grid; place-items: center; width: 22px; height: 22px; border: 1px solid var(--line); border-radius: 7px; color: var(--muted); font: 11px 'DM Mono', monospace; }
.option.correct { border-color: #76bd9e; background: var(--green-soft); color: #0b5d43; }
.option.correct .option-letter { border-color: #76bd9e; background: #c9eddb; color: #0b5d43; }
.option.wrong { border-color: #efa696; background: var(--coral-soft); color: #9a3c2b; }
.option.wrong .option-letter { border-color: #efa696; background: #ffd9d1; color: #9a3c2b; }
.answer-feedback { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 21px; color: var(--muted); font-size: 13px; }
.answer-feedback.is-correct { color: var(--green); }
.answer-feedback.is-wrong { color: var(--coral); }
.feedback-icon { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; color: white; background: var(--green); font-weight: 700; }
.is-wrong .feedback-icon { background: var(--coral); }
.answer-feedback > span:nth-child(2) { flex: 1 1 180px; }
.feedback-button { flex: 0 0 auto; min-height: 34px; margin-left: 30px; padding: 0 12px; border: 1px solid var(--accent); border-radius: 8px; background: var(--accent); color: white; font-size: 12px; }
.feedback-button.secondary { border-color: var(--line); background: transparent; color: var(--muted); }

.question-selector { margin-top: 22px; padding: 18px 20px 20px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.62); }
.question-selector-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.question-selector .eyebrow { margin-bottom: 5px; }
.question-selector h2 { margin: 0; font-size: 17px; letter-spacing: -.03em; }
.question-legend { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px 14px; color: var(--muted); font: 10px 'DM Mono', monospace; }
.question-legend span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.legend-dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; border: 1px solid transparent; }
.legend-dot.complete { background: #c9eddb; border-color: #76bd9e; }
.legend-dot.wrong { background: #ffe5a8; border-color: #dfb64d; }
.legend-dot.unanswered { background: #ffd9d1; border-color: #efa696; }
.question-selector-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 7px; margin-top: 16px; }
.question-index { min-height: 37px; padding: 0 4px; border: 1px solid #efa696; border-radius: 9px; background: #ffd9d1; color: #9a3c2b; font: 11px 'DM Mono', monospace; transition: transform .16s ease, box-shadow .16s ease; }
.question-index.complete { border-color: #76bd9e; background: #c9eddb; color: #0b5d43; }
.question-index.wrong { border-color: #dfb64d; background: #ffe5a8; color: #765500; }
.question-index:hover { transform: translateY(-1px); }
.question-index.current { box-shadow: 0 0 0 3px rgba(20,124,107,.22); }

.question-nav { display: flex; justify-content: space-between; gap: 12px; padding: 20px 0 0; }
.finish-actions { display: flex; gap: 8px; }
.nav-button { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 46px; padding: 0 18px; border: 1px solid var(--line); border-radius: 11px; font-size: 13px; transition: .2s ease; }
.nav-button.secondary { background: transparent; color: var(--muted); }
.nav-button.secondary:hover:not(:disabled) { color: var(--ink); border-color: #adc9c0; background: var(--surface); }
.nav-button.primary { min-width: 110px; border-color: var(--accent); background: var(--accent); color: white; }
.nav-button.primary:hover:not(:disabled) { background: var(--accent-dark); }
.nav-button:disabled { cursor: not-allowed; opacity: .42; }
.session-note { display: flex; gap: 10px; align-items: flex-start; max-width: 560px; margin: 35px auto 0; color: var(--muted); }
.note-icon { flex: 0 0 auto; display: grid; place-items: center; width: 20px; height: 20px; border: 1px solid #b7c9c2; border-radius: 50%; color: var(--accent); font: 12px Georgia, serif; }
.session-note p { margin: 0; font-size: 12px; line-height: 1.5; }
.session-note strong { color: var(--ink); font-weight: 600; }
footer { padding-top: 50px; color: var(--faint); text-align: center; font: 10px 'DM Mono', monospace; letter-spacing: .08em; text-transform: uppercase; }

@media (max-width: 680px) {
  .app-shell { padding: 0 16px 36px; }
  .topbar { height: 70px; }
  .save-state { display: none; }
  .intro { display: block; padding: 40px 0 32px; }
  .data-tools { display: block; padding: 16px; }
  .data-tools-actions { display: grid; margin-top: 14px; }
  .data-tools-actions .sync-button { width: 100%; }
  h1 { font-size: clamp(42px, 13vw, 64px); }
  .intro-copy { margin-top: 18px; font-size: 14px; }
  .streak-card { display: flex; align-items: center; gap: 10px; width: fit-content; margin-top: 24px; padding: 10px 13px; }
  .streak-card strong { margin: 0; font-size: 27px; }
  .streak-card span:last-child { margin-left: 2px; }
  .subject-tabs { width: 100%; }
  .subject-tab { flex: 1; padding: 0 6px; justify-content: center; font-size: 12px; }
  .filter-row { flex-wrap: wrap; gap: 8px; }
  .practice-filters { width: 100%; }
  .paper-tracker-heading { display: block; }
  .tracker-legend { justify-content: flex-start; margin-top: 12px; }
  .paper-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .select-wrap { flex: 1 1 100%; min-width: 0; justify-content: space-between; }
  .select-wrap select { flex: 1; }
  .shuffle-button { width: 100%; margin-left: 0; }
  .endpoint-row { flex-direction: column; }
  .save-sheets-button { width: 100%; }
  .sync-actions { display: grid; }
  .sync-button { width: 100%; }
  .sheet-panel { padding: 16px; }
  .question-card { min-height: 0; padding: 22px 17px 24px; border-radius: 16px; }
  .question-meta { margin-bottom: 22px; }
  .question-card h2 { margin-bottom: 22px; font-size: 21px; }
  .options { grid-template-columns: 1fr; gap: 8px; }
  .option { min-height: 56px; font-size: 13px; }
  .question-selector { padding: 16px 13px; }
  .question-selector-heading { display: block; }
  .question-legend { justify-content: flex-start; margin-top: 12px; }
  .question-nav { display: grid; grid-template-columns: 1fr 1fr; padding-top: 13px; }
  .question-nav #previousButton { order: 1; }
  .question-nav #nextButton { order: 2; }
  .finish-actions { order: 3; grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; }
  .nav-button { width: 100%; padding: 0 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
