/* Student phone page: the textbook's warm paper + coral palette, serif questions, big tap targets.
   Dark mode follows the phone. System fonts only (no font downloads on students' data plans). */
:root {
  --serif: "Iowan Old Style", "Source Serif 4", "Source Serif Pro", Charter, "Apple Garamond", Georgia, "Noto Serif", ui-serif, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --bg: #faf7f2; --card: #fffdf9; --surface: #f2ece2; --ink: #1d1915; --ink-2: #5c544a; --line: #e3d9ca; --line-2: #d4c8b6;
  --accent: #b4532f; --accent-ink: #ffffff; --accent-soft: rgba(180, 83, 47, 0.09); --sel: #fbeee6;
  --good: #157a5b; --good-bg: rgba(21, 122, 91, 0.09); --part: #8a5a00; --part-bg: #fbf0d7; --bad: #b8441f; --bad-bg: #fbe9e1;
  --focus: #e0a019; --shadow: 0 1px 2px rgba(60, 40, 20, .05), 0 6px 20px rgba(60, 40, 20, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1712; --card: #24201a; --surface: #2c261f; --ink: #f5ecdc; --ink-2: #c4b9a8; --line: rgba(232, 223, 209, 0.13); --line-2: rgba(232, 223, 209, 0.24);
    --accent: #e08562; --accent-ink: #1a1712; --accent-soft: rgba(224, 133, 98, 0.14); --sel: #3a261c;
    --good: #5fd0a6; --good-bg: rgba(95, 208, 166, 0.11); --part: #f0c062; --part-bg: rgba(240, 192, 98, 0.12); --bad: #f19a78; --bad-bg: rgba(241, 154, 120, 0.12);
    --shadow: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.5 var(--sans); -webkit-font-smoothing: antialiased;
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column;
}

/* header */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 18px 10px; position: sticky; top: 0; z-index: 2;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.set-title { font-family: var(--serif); font-weight: 600; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conn { font-size: 12.5px; font-weight: 600; color: var(--ink-2); display: flex; align-items: center; gap: 6px; flex: none; padding: 3px 10px 3px 8px; border-radius: 999px; background: var(--surface); }
.conn .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-2); opacity: .5; }
.conn.ok .dot { background: var(--good); opacity: 1; }
.conn.bad { color: var(--bad); }
.conn.bad .dot { background: var(--bad); opacity: 1; }

main { width: 100%; max-width: 36rem; margin: 0 auto; padding: 18px 16px 8px; flex: 1; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 20px 18px; margin-bottom: 14px; box-shadow: var(--shadow); animation: rise .3s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* waiting / done */
.waiting { text-align: center; padding: 44px 22px 40px; }
.waiting .big { font-family: var(--serif); font-size: 23px; font-weight: 600; line-height: 1.25; margin: 0 0 8px; }
.waiting p { margin: 0; color: var(--ink-2); }
.orbit { position: relative; width: 74px; height: 74px; margin: 0 auto 22px; border-radius: 50%; border: 1.5px dashed var(--line-2); animation: spin 6s linear infinite; }
.orbit .planet { position: absolute; inset: 27px; border-radius: 50%; background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.orbit .sat { position: absolute; top: -6px; left: calc(50% - 5px); width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.screen-ico { width: 74px; height: 50px; margin: 0 auto 24px; border: 2px solid var(--accent); border-radius: 7px; position: relative; display: grid; place-items: center; }
.screen-ico::after { content: ""; position: absolute; left: 50%; bottom: -12px; width: 26px; height: 2px; margin-left: -13px; background: var(--accent); border-radius: 1px; }
.screen-ico span { width: 26px; height: 3px; border-radius: 2px; background: var(--accent); box-shadow: 0 -8px 0 var(--accent), 0 8px 0 var(--accent); animation: breathe 3s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { opacity: .25; } 50% { opacity: .65; } }
.done-ico { width: 56px; height: 56px; margin: 0 auto 18px; border-radius: 50%; display: grid; place-items: center; background: var(--good-bg); color: var(--good); font-size: 28px; font-weight: 700; }

/* question */
.eyebrow, .qnum { font-size: 12.5px; color: var(--ink-2); margin: 0 0 8px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.prompt { font-family: var(--serif); font-size: 21px; line-height: 1.42; margin: 0 0 18px; overflow-wrap: anywhere; text-wrap: pretty; }
.prompt strong { font-weight: 650; }
.prompt em { color: var(--ink-2); }
.prompt img.mimg, .otext img.mimg, .reveal img.mimg, .fb img.mimg { display: block; max-width: 100%; height: auto; margin: 8px auto; border-radius: 6px; }
code { font-size: .88em; background: var(--accent-soft); padding: .05em .3em; border-radius: 4px; }
.prompt mjx-container, .opt mjx-container, .fb mjx-container, .reveal mjx-container { max-width: 100%; overflow-x: auto; overflow-y: hidden; }
.opts { display: grid; gap: 10px; margin: 0 0 18px; }
.opt {
  display: flex; align-items: flex-start; gap: 14px; width: 100%; min-height: 60px; padding: 14px 16px;
  border: 1.5px solid var(--line-2); border-radius: 14px; background: var(--card); color: var(--ink);
  font: inherit; font-size: 18px; text-align: left; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  transition: border-color .15s, background-color .15s, transform .1s;
}
.opt:active:not(:disabled) { transform: scale(.985); }
.opt .letter { flex: none; width: 30px; height: 30px; border-radius: 50%; border: 1.5px solid var(--ink-2); display: grid; place-items: center; font-weight: 700; font-size: 14px; margin-top: 0; color: var(--ink-2); transition: inherit; }
.opt .otext { flex: 1; min-width: 0; overflow-wrap: anywhere; padding-top: 2px; font-family: var(--serif); }
.opt[aria-checked="true"] { border-color: var(--accent); background: var(--sel); box-shadow: 0 0 0 1px var(--accent); }
.opt[aria-checked="true"] .letter { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.opt:disabled { cursor: default; opacity: 1; }
.opt:disabled:not([aria-checked="true"]):not(.is-correct):not(.is-wrong) { opacity: .62; }
.opt.is-correct { border-color: var(--good); background: var(--good-bg); box-shadow: 0 0 0 1px var(--good); }
.opt.is-correct .letter { background: var(--good); border-color: var(--good); color: var(--card); }
.opt.is-wrong { border-color: var(--bad); background: var(--bad-bg); box-shadow: 0 0 0 1px var(--bad); }
.opt.is-wrong .letter { background: var(--bad); border-color: var(--bad); color: var(--card); }
.opt .tag { font-family: var(--sans); font-size: 13px; font-weight: 700; white-space: nowrap; }
.opt .tag.you { color: var(--ink-2); }
.opt .tag.right { color: var(--good); }
.opt .tag.wrong { color: var(--bad); }
label.lbl { display: block; font-weight: 650; margin: 2px 0 8px; font-size: 15.5px; }
label.lbl .hint { font-weight: 400; color: var(--ink-2); }
textarea, input[type=text] {
  width: 100%; font: inherit; font-size: 18px; line-height: 1.45; color: var(--ink); background: var(--bg);
  border: 1.5px solid var(--line-2); border-radius: 14px; padding: 13px 15px; -webkit-appearance: none; appearance: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 8.6em; resize: vertical; field-sizing: content; max-height: 60vh; }
textarea::placeholder, input::placeholder { color: var(--ink-2); opacity: .7; }
textarea:focus, input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.opt:focus-visible, button:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.numrow { display: flex; align-items: center; gap: 10px; }
.numrow input { flex: 1; min-width: 0; font-variant-numeric: tabular-nums; }
.units { font-weight: 650; color: var(--ink-2); flex: none; }
.count { text-align: right; font-size: 13px; color: var(--ink-2); margin-top: 6px; min-height: 1em; }
.submit {
  display: block; width: 100%; min-height: 56px; margin-top: 16px; border: 0; border-radius: 14px;
  background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 700; font-size: 18px; letter-spacing: .01em;
  cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; transition: opacity .15s, transform .1s;
}
.submit:active:not(:disabled) { transform: scale(.985); }
.submit:disabled { background: var(--surface); color: var(--ink-2); cursor: default; }
.err { color: var(--bad); font-weight: 600; margin: 10px 0 0; }
.err:empty { display: none; }

/* after answering */
.closed-banner { display: inline-block; font-weight: 700; color: var(--ink-2); background: var(--surface); margin: 0 0 12px; padding: 3px 10px; border-radius: 999px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.mine { border-left: 4px solid var(--line-2); }
.mine.v-correct { border-left-color: var(--good); }
.mine.v-partial { border-left-color: var(--part); }
.mine.v-incorrect { border-left-color: var(--bad); }
.mine.v-pending { border-left-color: var(--accent); }
.yours { margin: 0 0 14px; padding: 10px 14px; border-radius: 10px; background: var(--surface); color: var(--ink); font-size: 16px; overflow-wrap: anywhere; }
.badge { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; padding: 5px 12px; border-radius: 999px; font-size: 15px; margin: 0 8px 10px 0; }
.badge.correct { color: var(--good); background: var(--good-bg); }
.badge.partial { color: var(--part); background: var(--part-bg); }
.badge.incorrect { color: var(--bad); background: var(--bad-bg); }
.badge.unmarked, .badge.pending, .badge.sent { color: var(--ink-2); background: var(--surface); }
.fb { margin: 0; font-family: var(--serif); font-size: 18px; line-height: 1.5; overflow-wrap: anywhere; }
.fb.pending { font-family: var(--sans); font-size: 16px; color: var(--ink-2); display: flex; align-items: center; gap: 10px; }
.spinner { flex: none; display: inline-block; width: 18px; height: 18px; border: 2.5px solid var(--line-2); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.reveal { border-left: 4px solid var(--good); background: linear-gradient(var(--good-bg), var(--good-bg)), var(--card); }
.reveal h3 { margin: 0 0 8px; font-size: 12.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--good); }
.reveal p { margin: 0; font-family: var(--serif); font-size: 18px; }
.reveal p + p { margin-top: 8px; }
.muted { color: var(--ink-2); }

/* privacy note at the foot of the page */
.privacy { max-width: 36rem; margin: 1.5rem auto 1.5rem; padding: 0 1.25rem; font-size: .76rem; line-height: 1.45; color: var(--ink-2); opacity: .8; text-align: center; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* the reasoning part of an mcq reads as the question's second part, in the form and after answering */
.why2 { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.why2 .prompt { display: block; margin-bottom: 10px; }
.why-q { margin-bottom: 14px; }

/* static copy on the book site (/present/s/<set>): banner, and previous / next kept within thumb reach */
.offline-banner { width: calc(100% - 32px); max-width: calc(36rem - 32px); margin: 16px auto 0; padding: 12px 16px; border-radius: 14px; background: var(--part-bg); border: 1px solid var(--line-2); font-size: 15px; line-height: 1.45; }
.offline-banner strong { color: var(--part); }
.qnav { position: sticky; bottom: 0; z-index: 2; display: flex; gap: 8px; align-items: center; width: 100%; max-width: 36rem; margin: 0 auto; padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--line); }
.qnav button, .qnav select { font: inherit; font-size: 15px; font-weight: 650; min-height: 44px; padding: 0 12px; border-radius: 12px; border: 1.5px solid var(--line-2); background: var(--card); color: var(--ink); flex: none; touch-action: manipulation; }
.qnav select { flex: 1; min-width: 0; text-align: center; text-align-last: center; }
.qnav button:disabled { opacity: .4; }
