/* Whole-site app surfaces, using the shared Apple design tokens. */
:root { --page-space: clamp(22px, 3vw, 34px); --success-ink: #19713d; --error-ink: #b32e27; }
html { scroll-padding-bottom: 110px; }
body { overflow-wrap: break-word; }
#app { min-width: 0; }
.page-head { margin: 12px 2px 28px; }
.page-head h1 { font-size: clamp(30px, 4vw, 38px); line-height: 1.22; font-weight: 700; letter-spacing: -.04em; overflow-wrap: anywhere; }
.page-head .sub { margin-top: 10px; max-width: 650px; font-size: 14px; line-height: 1.85; }
.page-head .eyebrow { color: var(--text-2); font-size: 12px; font-weight: 500; margin-bottom: 7px; }
.card { border-radius: var(--r-panel); padding: var(--page-space); box-shadow: var(--shadow); margin-bottom: 22px; min-width: 0; }
.card h2 { font-size: 17px; font-weight: 600; line-height: 1.5; margin-bottom: 18px; letter-spacing: -.02em; }
.card .hint { line-height: 1.85; }
.btn { min-height: 44px; font-weight: 500; text-decoration: none; line-height: 1.4; }
.btn .ui-icon { width: 19px; height: 19px; }
.btn.sm { min-height: 44px; padding: 10px 16px; }
.btn.danger { color: var(--error-ink); background: var(--danger-weak); }
.btn.secondary { color: var(--text); background: var(--bg); }
.btn:disabled { cursor: default; }
.back-link { min-height: 44px; gap: 3px; margin: -4px 0 10px -7px; padding: 8px 7px; border-radius: var(--r-thumb); font-weight: 400; }
.back-link .ui-icon { width: 19px; height: 19px; }
.group-label { margin: 28px 18px 10px; font-size: 12px; font-weight: 500; letter-spacing: .03em; color: var(--text-2); }
.set-list { padding: 0 22px; overflow: hidden; }
.set-list .set-item { min-height: 84px; padding: 18px 0; gap: 16px; text-decoration: none; color: var(--text); }
.set-item .t { font-size: 16px; line-height: 1.6; font-weight: 500; }
.set-item .meta { font-size: 12px; line-height: 1.7; color: var(--text-2); margin-top: 4px; }
.list-leading { color: var(--text-2); flex: none; }
.list-copy { flex: 1; min-width: 0; }
.list-trailing { display: flex; align-items: center; gap: 10px; flex: none; color: var(--text-3); }
.list-trailing > .ui-icon { width: 16px; height: 16px; }
.set-item .score { background: transparent; color: var(--text-2); padding: 0; font-weight: 500; }
.subtabs { max-width: 440px; min-height: 44px; padding: 4px; border-radius: var(--r-thumb); margin-bottom: 26px; background: var(--track); }
.subtabs .stab { min-height: 38px; border-radius: 9px; font-size: 13px; padding: 9px 14px; transition: background .2s var(--ease-out), box-shadow .2s var(--ease-out); }
.subtabs .stab.active { box-shadow: 0 1px 3px rgba(0, 0, 0, .08), 0 3px 7px rgba(0, 0, 0, .04); }
.state-symbol { display: flex; justify-content: center; align-items: center; width: 64px; height: 64px; border-radius: var(--r-pill); margin: 0 auto 20px; color: var(--text-2); background: var(--bg); }
.state-symbol .ui-icon { width: 29px; height: 29px; }
.done-state { padding: 42px 8px; }
.done-state .msg { font-size: 20px; letter-spacing: -.025em; margin: 0 0 8px; }
.done-state .sub, .done-state .stats-line { font-size: 13px; line-height: 1.85; color: var(--text-2); }
.done-state .btn-row { max-width: 300px; margin: 24px auto 0; }
.loading { min-height: 220px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; font-size: 13px; }
.loading::before { content: ''; width: 20px; height: 20px; border: 2px solid var(--track); border-top-color: var(--accent); border-radius: var(--r-pill); animation: ios-spin .8s linear infinite; }
@keyframes ios-spin { to { transform: rotate(360deg); } }
/* Vocabulary: one quiet surface, with definition and actions underneath. */
.word-card { max-width: 720px; min-height: 340px; padding: 56px clamp(20px, 4vw, 44px) 30px; }
.word-card .word { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; font-size: clamp(32px, 6vw, 48px); font-weight: 650; line-height: 1.3; letter-spacing: -.04em; overflow-wrap: anywhere; }
.word-card .phon { margin-top: 10px; color: var(--text-2); font-size: 16px; }
.chip-tag, .chip-tag.review { left: 22px; top: 20px; background: var(--bg); color: var(--text-2); font-weight: 500; padding: 4px 11px; }
.star-btn { top: 9px; right: 12px; width: 44px; height: 44px; display: grid; place-items: center; opacity: 1; color: var(--text-2); border-radius: var(--r-pill); }
.star-btn.on { color: var(--accent); background: var(--accent-weak); }
.star-btn.on .ui-icon { fill: currentColor; stroke-width: 1.2; }
.speak-btn { width: 44px; height: 44px; color: var(--text-2); background: var(--bg); flex: none; }
.speak-btn .ui-icon { width: 20px; height: 20px; }
.word-card .meaning { margin: 26px 0 18px; font-size: 21px; line-height: 1.7; font-weight: 500; }
.word-card .example { margin-top: 18px; padding: 18px; line-height: 1.85; background: var(--bg); }
.word-card .example .ex-label { display: flex; justify-content: space-between; align-items: center; color: var(--text-2); font-size: 12px; margin-bottom: 10px; }
.word-card .btn-row { margin-top: 28px; }
.word-card .btn-row .btn { min-height: 48px; }
.word-feedback { border-top: 1px solid var(--hairline); margin-top: 22px; padding-top: 17px; font-size: 13px; color: var(--text-2); line-height: 1.85; }
.vocab-progress { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; color: var(--text-2); margin: 0 0 12px; font-variant-numeric: tabular-nums; }
.vocab-progress .bar { flex: 1; max-width: 240px; margin-block: auto; height: 5px; }
.starred-item { min-height: 80px; gap: 14px; }
.starred-item .w { font-size: 17px; }
.starred-item .m { line-height: 1.7; margin-top: 2px; }
.star-mini { min-width: 44px; min-height: 44px; display: grid; place-items: center; border-radius: var(--r-pill); }
.star-mini.on { color: var(--accent); }
.star-mini .ui-icon { width: 20px; height: 20px; fill: currentColor; }
.detail-pop { line-height: 1.85; padding: 16px; }
.starred-toggle { border: 0; background: transparent; color: inherit; text-align: left; font: inherit; flex: 1; min-height: 44px; cursor: pointer; }
/* Reading, listening and wrong answers. */
.passage, .task-text { background: transparent; border-radius: 0; padding: 0; font-size: 16px; line-height: 1.95; color: var(--text-body); }
.passage { max-height: none; }
.passage.reading { max-height: none; overflow: visible; }
.q-item { padding-top: 24px; margin-top: 24px; }
.q-item:first-child { padding-top: 0; margin-top: 0; border-top: 0; }
.q-item .q-text, .wrong-item .q-text { font-size: 15px; line-height: 1.85; font-weight: 500; margin-bottom: 16px; }
.q-num { display: inline-flex; align-items: center; justify-content: center; min-width: 28px; height: 28px; margin-right: 9px; border-radius: var(--r-pill); background: var(--bg); color: var(--text-2); font-size: 12px; font-variant-numeric: tabular-nums; }
.q-item .q-num { color: var(--text-2); background: var(--bg); padding: 0 7px; border-radius: var(--r-pill); }
.opt { display: flex; align-items: baseline; gap: 12px; border-color: var(--hairline); border-radius: var(--r-thumb); min-height: 50px; padding: 13px 16px; font-size: 14px; line-height: 1.85; transition: background .15s var(--ease-out), border-color .15s var(--ease-out); }
.opt .opt-key { flex: none; margin: 0; color: var(--text-2); font-weight: 500; }
.opt.correct, .letter-row .lbtn.correct, .blank-row select.correct { border-color: #7aab8a; background: #f2f8f4; color: var(--success-ink); }
.opt.correct .opt-key { color: var(--success-ink); }
.opt.wrong, .letter-row .lbtn.wrong, .blank-row select.wrong { border-color: #cf9995; background: #fff6f5; color: var(--error-ink); }
.opt.wrong .opt-key { color: var(--error-ink); }
.opt:disabled { opacity: 1; cursor: default; }
.explain { margin-top: 16px; padding: 16px; line-height: 1.9; border-radius: var(--r-thumb); color: var(--text-2); }
.explain b { color: var(--text); font-weight: 600; }
.explain.bad b { color: var(--error-ink); }
.result-banner, .result-banner.good, .result-banner.bad { text-align: left; padding: 20px 24px; background: var(--surface); color: var(--text); border-radius: var(--r-panel); box-shadow: var(--shadow); font-weight: 500; font-size: 15px; line-height: 1.85; }
.result-banner[data-status="error"] { color: var(--error-ink); }
.letter-row { gap: 8px; }
.letter-row .lbtn { width: 44px; height: 44px; border-radius: var(--r-thumb); }
.letter-row .lbtn:disabled { opacity: 1; cursor: default; }
.bank { margin: 0; padding: 0; background: transparent; gap: 8px; }
.bank .chip { border: 0; background: var(--bg); padding: 7px 12px; font-size: 13px; }
.bank .chip b { color: var(--text-2); font-weight: 500; }
.blank-row { margin-top: 18px; gap: 8px; }
.blank-row select { min-height: 48px; min-width: 0; font: 16px var(--font); border-radius: var(--r-thumb); }
.blank-row > .q-num { margin: 0; }
.wrong-item { padding-block: 24px; }
.wrong-item:first-child { padding-top: 0; }
.wrong-item:last-child { padding-bottom: 0; }
.wrong-meta { font-size: 12px; margin-bottom: 16px; color: var(--text-2); }
.audio-panel { margin-top: 20px; gap: 10px; }
.audio-panel select { min-height: 44px; font: 16px var(--font); border-radius: var(--r-pill); max-width: 100%; }
.script-toggle { padding-top: 16px; border-top: 1px solid var(--hairline); margin-top: 18px; }
.script-box { background: transparent; padding: 14px 0 0; }
.script-line { display: block; width: 100%; text-align: left; border: 0; background: transparent; font: inherit; color: var(--text-body); line-height: 1.9; min-height: 44px; padding: 12px 0; border-radius: 0; border-bottom: 1px solid var(--hairline); }
.script-line:last-child { border-bottom: 0; }
/* Writing: requirements, a dedicated editor and unified history. */
.writing-layout { display: grid; gap: 22px; align-items: start; }
.writing-layout > .card { margin: 0; }
.writing-history { grid-column: 1 / -1; }
.task-text.en { font-family: var(--font); line-height: 1.95; }
.ref-box { border: 0; border-top: 1px solid var(--hairline); border-radius: 0; padding: 20px 0 0; margin-top: 22px; background: transparent; font-size: 15px; line-height: 1.95; }
.ref-box summary { min-height: 44px; cursor: pointer; font-size: 14px; color: var(--text-2); }
.ref-box .ref-label { font-size: 12px; color: var(--text-2); letter-spacing: .02em; font-weight: 500; margin-bottom: 12px; }
textarea.answer { margin-top: 0; min-height: 250px; background: var(--hover); border-radius: var(--r-thumb); font-size: 16px; padding: 18px; line-height: 1.85; }
.draft-toolbar { gap: 10px; margin: 16px 0 22px; font-variant-numeric: tabular-nums; }
.draft-toolbar .hint { font-size: 12px; }
.draft-toolbar .btn { margin-left: auto; }
#show-ref { background: var(--bg); color: var(--accent-deep); font-size: 14px; }
.rate-row { flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.rate-row .btn { flex: 1; min-width: 130px; }
.history-item { padding: 18px 0; }
.history-item:first-child { padding-top: 0; }
.history-item:last-child { padding-bottom: 0; border-bottom: 0; }
.history-item summary { min-height: 44px; line-height: 1.85; color: var(--text-2); }
.history-text { color: var(--text-body); font-size: 15px; line-height: 1.95; background: var(--bg); border-radius: var(--r-thumb); padding: 16px; }
#draft-conflict { padding: 18px; border: 1px solid var(--faint); border-radius: var(--r-thumb); background: var(--bg); }
#draft-conflict p { margin-bottom: 14px; font-size: 13px; }
#server-draft { min-height: 150px; margin-top: 10px; background: var(--surface); }
.form-message { font-size: 13px; line-height: 1.85; margin-top: 12px; }
.form-message:empty { margin: 0; min-height: 0; }
/* Personal account and sign-in. */
.account-hero { display: flex; align-items: center; gap: 16px; margin-bottom: 26px; }
.account-avatar { display: grid; place-items: center; width: 60px; height: 60px; background: var(--bg); color: var(--text-2); border-radius: var(--r-pill); }
.account-avatar .ui-icon { width: 27px; height: 27px; }
.account-hero strong { display: block; font-size: 18px; font-weight: 600; }
.account-hero p { font-size: 13px; color: var(--text-2); margin-top: 3px; }
.account-form, .login-card form { gap: 12px; }
.account-form label, .login-card label { color: var(--text-2); font-size: 13px; }
.account-form input, .login-card input { min-height: 48px; border-radius: var(--r-thumb); padding: 13px 16px; background: var(--hover); font-size: 16px; }
.account-form .btn { justify-self: start; margin-top: 8px; }
.account-grid { display: grid; gap: 22px; }
.account-grid .card { margin: 0; }
.account-data p { margin-bottom: 20px; }
.account-logout { margin-top: 24px; }
.account-logout .btn { background: transparent; color: var(--error-ink); padding-left: 0; }
.signed-out #app { width: 100%; max-width: 460px; min-height: 100svh; display: flex; align-items: center; padding: 40px 22px; }
.login-card { width: 100%; padding: 34px 28px; border-radius: var(--r-hero); margin: 0; }
.login-mark { display: grid; place-items: center; width: 56px; height: 56px; border-radius: var(--r-card); background: var(--accent-weak); color: var(--accent); margin-bottom: 26px; }
.login-mark .ui-icon { width: 29px; height: 29px; }
.login-card h1 { font-size: 30px; letter-spacing: -.035em; margin-bottom: 8px; }
.login-card > .hint { margin-bottom: 28px; }
.login-card .btn.big { margin-top: 6px; min-height: 48px; }
.account-link { color: var(--text-2); gap: 7px; }
.account-link .ui-icon { width: 18px; height: 18px; }
.account-link[aria-current="page"] { color: var(--accent-deep); }
@media (hover: hover) {
  .set-item:hover { background: var(--hover); }
  .btn.secondary:hover, #show-ref:hover { background: var(--track); }
  .starred-toggle:hover { color: var(--accent-deep); }
}
@media (min-width: 900px) {
  #app { max-width: 1336px; }
  .page-head { margin-top: 10px; margin-bottom: 34px; }
  .page-head h1 { max-width: 900px; }
  .quiz-cols { gap: 24px; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
  .quiz-left { top: 28px; }
  .quiz-left .card + .card { margin-top: 22px; }
  .quiz-cols .passage.reading { max-height: calc(100svh - 220px); overflow-y: auto; padding-right: 12px; scrollbar-width: thin; }
  #app[data-route="vocab"] { max-width: 1060px; }
  #app[data-route="vocab"] > .card { max-width: 720px; margin-inline: auto; }
  .writing-layout { grid-template-columns: minmax(0, .9fr) minmax(0, 1.2fr); gap: 24px; }
  .writing-brief { position: sticky; top: 28px; }
  textarea.answer { min-height: 360px; }
  .account-grid { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); align-items: start; }
  .account-hero { margin-bottom: 32px; }
}
@media (max-width: 480px) {
  #app { padding-inline: 16px; }
  .page-head { margin-bottom: 24px; }
  .set-list { padding-inline: 20px; }
  .list-leading { display: none; }
  .set-item .t { font-size: 15px; }
  .card { padding: 22px; }
  .set-list { padding-block: 0; }
  .word-card { padding-top: 64px; }
  .opt { padding: 12px; gap: 9px; }
  .audio-panel .btn { flex: 1; }
  .audio-panel select { width: 100%; }
  .writing-layout { gap: 20px; }
  .rate-row { flex-direction: column; }
  .starred-item { gap: 8px; }
  .starred-actions { display: flex; flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) {
  .loading::before { animation: none; border-color: var(--accent); }
}
@media (prefers-contrast: more) {
  .card, .opt, .account-form input, .login-card input, textarea.answer { outline: 1px solid var(--text-2); }
}
