:root {
  color-scheme: light;
  --ink: #25343d;
  --muted: #56656e;
  --border: #d8dfe9;
  --accent: #003DA5;
  --topic-accent: #C8102E;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: #e9eef6;
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 1rem;
  line-height: 1.65;
}
main { max-width: 960px; margin: 0 auto; padding: 2.5rem 1.5rem 4rem; }
.page-header { margin-bottom: 1.75rem; }
h1, h2, h3 { color: var(--accent); line-height: 1.3; font-weight: 650; }
h1 { margin: 0 0 .5rem; font-size: clamp(1.8rem, 4vw, 2.4rem); letter-spacing: -.025em; }
h2 { margin: 0 0 1.25rem; font-size: 1.45rem; }
h3 { margin: 0 0 .6rem; font-size: 1rem; }
p { margin: 0 0 1.25rem; }
.notice, .metadata, .guidance { color: var(--muted); font-size: .9rem; }
.notice { margin: 0; }
.account-controls { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; margin-top: .65rem; font-size: .85rem; }
.account-controls form { margin: 0; }
.account-controls button { margin: 0; padding: .4rem .65rem; font-size: inherit; }
.pilot-feedback-prompt { border-top: 1px solid var(--border); margin-top: 1.5rem; padding-top: 1.25rem; font-size: .9rem; }
.pilot-feedback-prompt textarea { min-height: 100px; }
.week-option { border: 1px solid var(--border); border-radius: 8px; padding: 1.25rem; }
.week-option h3 { font-size: 1.15rem; }
.week-option p { margin-bottom: .75rem; }
.last-used { display: inline-block; margin-left: .5rem; color: var(--muted); font-size: .8rem; font-weight: 400; }
.resume-current { margin-bottom: 1.5rem; }
.button-link { display: inline-block; background: var(--accent); color: white; border-radius: 8px; padding: .65rem 1.1rem; font-weight: 600; text-decoration: none; }
.button-link:hover { background: #002f80; }
.metadata { margin-bottom: .65rem; }
.card, .selection-rows {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 3px 14px rgb(37 52 61 / 4%);
}
.content-card { padding: 2rem; }
.content-card > :last-child { margin-bottom: 0; }
a { color: var(--accent); text-underline-offset: .2em; }
a:hover { text-decoration-thickness: 2px; }
button, textarea, select { font: inherit; }
.account-form { max-width: 28rem; }
.account-form label { display: block; margin-top: .75rem; }
.account-form input:not([type="hidden"]) {
  display: block; width: 100%; min-height: 44px; margin: .3rem 0 .75rem;
  padding: .6rem; font: inherit; border: 1px solid var(--border); border-radius: 8px;
}
.account-form input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
button {
  min-height: 44px;
  padding: .65rem 1.1rem;
  margin: .25rem .5rem .25rem 0;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 600;
  line-height: 1.4;
  cursor: pointer;
}
button:hover:not(:disabled) { background: #002f80; border-color: #002f80; }
button.secondary {
  background: #fff;
  color: var(--muted);
  border-color: var(--border);
  font-weight: 500;
}
button.secondary:hover { background: #f0f3f9; color: var(--ink); }
:where(button, a, textarea, select):focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}
label { display: block; margin-bottom: .65rem; font-weight: 600; }
textarea, select {
  width: 100%;
  padding: .9rem 1rem;
  border: 1px solid #8797b2;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  line-height: 1.6;
}
textarea { display: block; min-height: 140px; resize: vertical; margin-bottom: .85rem; }
.content-card > form { margin-bottom: 1rem; }
.selection-rows {
  position: static;
  padding: 1.1rem 1.25rem;
  margin-bottom: 1.75rem;
}
.button-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .6rem;
}
.selection-rows form:first-child .button-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.selection-rows form + form { margin-top: 1rem; }
.button-row strong { grid-column: 1 / -1; font-size: .9rem; }
.button-row button {
  margin: 0;
  padding: .65rem .6rem;
  border: 1px solid #8797b2;
  background: #fff;
  color: var(--ink);
  font-size: .9rem;
  font-weight: 500;
}
.button-row button:hover:not(:disabled) { background: #edf2fb; border-color: var(--accent); }
.button-row button[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 700;
  box-shadow: inset 0 -3px 0 rgb(255 255 255 / 45%);
}
.button-row button[aria-pressed="true"]:hover { background: #002f80; }
.button-row button[aria-pressed="true"]::before { content: "✓ "; }
.button-row button[name="topic"] { border-color: #b98a94; }
.button-row button[name="topic"]:hover:not(:disabled) {
  background: #fcf0f2;
  border-color: var(--topic-accent);
}
.button-row button[name="topic"][aria-pressed="true"] {
  background: var(--topic-accent);
  border-color: var(--topic-accent);
}
.button-row button[name="topic"][aria-pressed="true"]:hover {
  background: #a50d26;
  border-color: #a50d26;
}
.button-row button[name="topic"]:focus-visible { outline-color: var(--topic-accent); }
.button-row button:disabled {
  background: #f0f2f2;
  color: #657178;
  border-color: var(--border);
  border-style: dashed;
  cursor: not-allowed;
}
.selection-rows p { margin: .85rem 0 0; font-size: .85rem; color: var(--muted); }
.question, .work { white-space: pre-wrap; overflow-wrap: anywhere; }
.question { font-size: 1.075rem; margin-bottom: 1.75rem; }
.problem-quote { margin: 0 0 1.75rem 1.5rem; padding-left: 1rem; border-left: 3px solid var(--border); }
.problem-quote .question { margin-bottom: 0; }
.problem-quote em { font-style: italic; }
.problem-image { display: block; max-width: min(100%, 640px); height: auto; margin: 1.5rem auto; }
.submission, .history { border-top: 1px solid var(--border); padding-top: 1.5rem; margin-top: 2rem; }
.submission { margin-bottom: 1.75rem; }
.feedback {
  background: #f0f4fa;
  border-left: 3px solid #8ba6d1;
  border-radius: 0 8px 8px 0;
  padding: 1rem 1.25rem;
  overflow-wrap: anywhere;
}
.feedback p { margin-bottom: 0; }
.history ul { list-style: none; padding: 0; margin: 0; }
.history li { padding: 1rem 0; border-bottom: 1px solid var(--border); }
.history li:last-child { border-bottom: 0; }
.history li form { margin-top: .5rem; }
[data-math] .katex-display { overflow-x: auto; overflow-y: hidden; padding: .4rem 0; }
@media (max-width: 600px) {
  main { padding: 1.5rem 1rem 2.5rem; }
  .content-card { padding: 1.25rem; }
  .selection-rows { padding: 1rem; }
  .button-row, .selection-rows form:first-child .button-row { grid-template-columns: 1fr; }
  .button-row button { text-align: left; }
  h2 { font-size: 1.3rem; }
  .feedback { padding: 1rem; }
}

dialog {
  width: min(480px, calc(100% - 2rem));
  padding: 1.75rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 12px 40px rgb(0 25 70 / 18%);
}
dialog::backdrop { background: rgb(15 30 55 / 45%); }
dialog form { display: flex; flex-wrap: wrap; gap: .75rem; }
dialog button { margin: 0; }

.table-scroll { overflow-x: auto; margin: 1.5rem 0; }
.problem-table { border-collapse: collapse; width: 100%; }
.problem-table th, .problem-table td { border: 1px solid var(--border); padding: .6rem .8rem; text-align: left; }
.problem-table th { background: #f0f4fa; }

.current-part { border-left: 3px solid var(--accent); padding-left: 1rem; margin-bottom: 1.75rem; }
.current-part h3 { font-size: 1.2rem; }
.current-part .question { margin-bottom: 0; }
.previous-part { border-top: 1px solid var(--border); padding-top: 1.5rem; margin-bottom: 1.75rem; }
.earlier-attempts summary { color: var(--accent); cursor: pointer; }

.revisiting-part { border-left: 3px solid var(--topic-accent); padding-left: 1rem; }

.tutor-working::after {
  content: "";
  display: inline-block;
  width: .8rem;
  height: .8rem;
  margin-left: .6rem;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: tutor-spin 1s linear infinite;
}
@keyframes tutor-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .tutor-working::after { animation: none; }
}
form[data-tutor-submit] button:disabled { opacity: .65; cursor: wait; }

.voice-input { margin-bottom: .85rem; }
.voice-input button[aria-pressed="true"] { background: #a32020; color: white; border-color: #a32020; }
.voice-input button:disabled { opacity: .65; cursor: wait; }

.response-tools { display: flex; flex-wrap: wrap; gap: .75rem; align-items: start; margin-bottom: .85rem; }
.submission-photo { display: block; max-width: min(100%, 320px); height: auto; margin: .75rem 0; }
[data-camera-dialog] video, [data-camera-candidate] { display: block; max-width: 100%; max-height: 55vh; width: auto; height: auto; margin: .75rem auto; }
[data-camera-dialog] [hidden] { display: none; }

.response-tools > button { flex: 0 0 auto; margin: 0; }
.voice-input > [role="status"] { display: block; }
.voice-input > [role="status"]:empty { display: none; }
.camera-instructions { font-weight: 600; }
.camera-actions, .response-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
[data-camera-remove][hidden] { display: none; }
[data-camera-candidate] { touch-action: none; cursor: crosshair; }

[data-camera-dialog] { width: min(720px, calc(100% - 1rem)); max-height: 90dvh; overflow-y: auto; }
