/* The app. Plain CSS with custom properties; the colours follow the Android app's theme. */

:root {
  --primary: #4f46e5;
  --on-primary: #fff;
  --primary-container: #e0e7ff;
  --on-primary-container: #1e1b4b;
  --secondary: #7c3aed;
  --secondary-container: #ede9fe;
  --on-secondary-container: #2e1065;
  --bg: #fbf8ff;
  --surface: #fbf8ff;
  --surface-lowest: #fff;
  --surface-low: #f6f3fc;
  --surface-mid: #f0edf7;
  --surface-high: #eae7f1;
  --surface-highest: #e4e1ec;
  --text: #1c1b22;
  --muted: #5f5c6b;
  --outline: #79767f;
  --outline-variant: #cbc6d6;
  --error: #dc2626;
  --good: #16a34a;
  --on-good: #fff;
  --good-container: #dcfce7;
  --on-good-container: #14532d;
  --partial: #d97706;
  --partial-container: #fef3c7;
  --on-partial-container: #78350f;
  --bad: #dc2626;
  --bad-container: #fee2e2;
  --on-bad-container: #7f1d1d;
  --scrim: rgb(20 16 40 / 45%);
  --shadow: 0 1px 2px rgb(20 16 40 / 8%), 0 4px 14px rgb(20 16 40 / 8%);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --max: 680px;
  --gutter: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --primary: #a5b4fc;
    --on-primary: #1e1b4b;
    --primary-container: #3730a3;
    --on-primary-container: #e0e7ff;
    --secondary: #c4b5fd;
    --secondary-container: #4c1d95;
    --on-secondary-container: #ede9fe;
    --bg: #13121a;
    --surface: #13121a;
    --surface-lowest: #0e0d14;
    --surface-low: #1b1a22;
    --surface-mid: #1f1e27;
    --surface-high: #2a2931;
    --surface-highest: #35343c;
    --text: #e6e1ec;
    --muted: #a9a6b6;
    --outline: #938f9e;
    --outline-variant: #48464f;
    --error: #f87171;
    --good: #4ade80;
    --on-good: #052e16;
    --good-container: #14532d;
    --on-good-container: #dcfce7;
    --partial: #fbbf24;
    --partial-container: #78350f;
    --on-partial-container: #fef3c7;
    --bad: #f87171;
    --bad-container: #7f1d1d;
    --on-bad-container: #fee2e2;
    --scrim: rgb(0 0 0 / 60%);
    --shadow: 0 1px 2px rgb(0 0 0 / 35%), 0 4px 14px rgb(0 0 0 / 30%);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  min-height: 100dvh;
  font: 16px/1.45 var(--font);
  color: var(--text);
  background: var(--bg);
  overscroll-behavior-y: none;
}
h1, h2, h3 { line-height: 1.25; margin: 0; font-weight: 650; }
p { margin: 0; }
a { color: var(--primary); }
img { max-width: 100%; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 55%, transparent); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.noscript { padding: 24px; }
.boot { height: 100dvh; }

.icon { width: 24px; height: 24px; fill: currentColor; flex: none; }

/* --- screens and the top bar ------------------------------------------------------------- */

.screen { max-width: var(--max); margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }
.bar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 4px;
  min-height: calc(64px + var(--safe-top)); padding: var(--safe-top) 4px 0 8px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
}
.bar h1 { flex: 1; min-width: 0; font-size: 1.35rem; font-weight: 600; padding-left: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar h1:focus { outline: none; }
.bar .icon-btn + h1 { padding-left: 0; }
.content { flex: 1; padding: 8px var(--gutter) calc(96px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 10px; }
.content.narrow { gap: 16px; }

/* --- buttons --------------------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 20px; border-radius: 999px; border: 1px solid transparent;
  font-weight: 600; font-size: .95rem; line-height: 1.2; text-decoration: none; cursor: pointer; white-space: nowrap;
  background: var(--primary); color: var(--on-primary);
  transition: background .15s, box-shadow .15s, opacity .15s;
}
.btn .icon { width: 20px; height: 20px; }
.btn:hover { box-shadow: var(--shadow); }
.btn[disabled] { opacity: .45; cursor: default; box-shadow: none; }
.btn.tonal { background: var(--primary-container); color: var(--on-primary-container); }
.btn.outlined { background: transparent; color: var(--primary); border-color: var(--outline-variant); }
.btn.text { background: transparent; color: var(--primary); padding: 10px 12px; }
.btn.text:hover, .btn.outlined:hover { box-shadow: none; background: color-mix(in srgb, var(--primary) 9%, transparent); }
.btn.good { background: var(--good); color: var(--on-good); }
.btn.danger { background: var(--bad); color: #fff; }
.danger-text, .btn.danger-text { color: var(--bad) !important; }
.btn.big { width: 100%; min-height: 54px; border-radius: 16px; font-size: 1rem; }
.btn.small { min-height: 38px; padding: 6px 14px; gap: 6px; font-size: .88rem; }
.btn.small .icon { width: 18px; height: 18px; }
.btn.text.small { padding: 6px 10px; }
.btn.wide { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center; flex: none;
  width: 48px; height: 48px; border-radius: 50%; border: 0; padding: 0;
  background: transparent; color: var(--text); cursor: pointer;
}
.icon-btn:hover { background: color-mix(in srgb, var(--text) 8%, transparent); }
.icon-btn[disabled] { opacity: .35; cursor: default; background: none; }
.icon-btn.tonal { background: var(--primary-container); color: var(--on-primary-container); }
.row { display: flex; align-items: center; gap: 12px; }
.row.end { justify-content: flex-end; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 8px; }

.fab {
  position: fixed; z-index: 20; right: max(16px, calc((100vw - var(--max)) / 2 + 16px)); bottom: calc(16px + var(--safe-bottom));
  display: inline-flex; align-items: center; gap: 10px;
  min-height: 56px; padding: 0 20px 0 16px; border-radius: 16px; border: 0; cursor: pointer;
  background: var(--primary-container); color: var(--on-primary-container); font-weight: 650;
  box-shadow: 0 3px 10px rgb(20 16 40 / 25%);
}

/* --- cards ----------------------------------------------------------------------------- */

.card { background: var(--surface-low); border-radius: 18px; }
.card.pad { padding: 16px; }
.hero-card { background: var(--primary-container); color: var(--on-primary-container); border-radius: 24px; padding: 20px; }
.hero-card h2 { font-size: 1.3rem; display: flex; align-items: center; gap: 8px; }
.hero-card h2 .icon { color: var(--primary); }
.hero-card p { margin-top: 4px; }
.hero-card .row { margin-top: 16px; }
.hero-card .btn { flex: 1; min-height: 48px; }
.hero-card.done h2 .icon { color: var(--good); }
.nights { display: flex; align-items: center; gap: 8px 14px; flex-wrap: wrap; margin-top: 14px; }
.week { display: flex; gap: 6px; list-style: none; margin: 0; padding: 0; }
.week li { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: .7rem; font-weight: 650; opacity: .7; }
.week .dot { width: 18px; height: 18px; border-radius: 50%; border: 2px solid color-mix(in srgb, currentColor 35%, transparent); }
.week .practised .dot { background: var(--primary); border-color: var(--primary); }
.week .tonight, .week .practised { opacity: 1; }
.week .tonight:not(.practised) .dot { border-color: var(--primary); border-style: dashed; }
.in-a-row { font-size: .9rem; font-weight: 600; }
.offer { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; padding: 16px; border-radius: 20px; background: var(--primary-container); color: var(--on-primary-container); }
.offer .row { flex-wrap: wrap; }
.setting .reminder-time { margin-top: 8px; align-self: flex-start; }
.setting input.time { width: auto; min-height: 44px; }
@media (prefers-color-scheme: dark) { .hero-card h2 .icon { color: var(--on-primary-container); } }

.section-head { display: flex; align-items: center; gap: 4px; margin-top: 14px; min-height: 48px; }
.section-head h2 { flex: 1; min-width: 0; font-size: 1rem; color: var(--primary); padding-left: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.section-head .count { font-size: .8rem; color: var(--muted); font-weight: 600; }
.section-empty { padding: 4px; }

.lesson-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; border-radius: 18px; background: var(--surface-low); }
.lesson-card:hover { background: var(--surface-mid); }
.lesson-open { display: flex; align-items: center; gap: 14px; min-width: 0; padding: 12px 0 12px 12px; border: 0; border-radius: 18px; background: none; text-align: left; cursor: pointer; }
.lesson-card .chip-update { grid-column: 1 / -1; justify-self: start; min-height: 36px; padding: 6px 14px; margin: -4px 0 12px 90px; font-size: .88rem; border-radius: 10px; }
.lesson-card .body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.lesson-card .title { font-weight: 600; font-size: 1.02rem; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.lesson-card .meta { font-size: .85rem; color: var(--muted); }
.lesson-card .meta .due { color: var(--primary); font-weight: 650; }
.cover { width: 64px; height: 64px; border-radius: 12px; flex: none; overflow: hidden; display: grid; place-items: center; background: var(--secondary-container); color: var(--on-secondary-container); font-size: 1.5rem; font-weight: 650; }
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mastery { position: relative; height: 6px; border-radius: 3px; overflow: hidden; background: var(--surface-highest); margin-top: 8px; }
.mastery span { position: absolute; inset: 0 auto 0 0; }
.mastery .seen { background: color-mix(in srgb, var(--primary) 30%, transparent); }
.mastery .known { background: var(--primary); }

.empty-state { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 8px; padding: 24px 8px; }
.empty-state .badge-icon, .summary .badge-icon { width: 96px; height: 96px; border-radius: 28px; display: grid; place-items: center; background: var(--primary-container); color: var(--primary); margin-bottom: 16px; }
.empty-state .badge-icon .icon, .summary .badge-icon .icon { width: 48px; height: 48px; }
.empty-state h2 { font-size: 1.5rem; }
.empty-state .actions { width: 100%; display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.free-note { display: inline-flex; align-items: center; gap: 6px; margin-top: 4px; padding: 6px 14px 6px 10px; border-radius: 999px; background: var(--primary-container); color: var(--on-primary-container); font-weight: 650; }
.free-note .icon { width: 18px; height: 18px; }

/* Choosing starter lessons on first run. */
.starter-list { width: 100%; display: flex; flex-direction: column; gap: 6px; margin-top: 12px; text-align: left; }
.starter-item { display: flex; align-items: center; gap: 12px; padding: 8px 12px 8px 8px; border-radius: 14px; background: var(--surface-low); cursor: pointer; }
.starter-item .cover { width: 48px; height: 48px; font-size: 1.1rem; border-radius: 10px; }
.starter-item .grow { display: flex; flex-direction: column; }
.starter-item .meta { font-size: .8rem; color: var(--muted); }
.starter-item input { width: 22px; height: 22px; accent-color: var(--primary); }

/* --- chips, fields ------------------------------------------------------------------------ */

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; margin: 0 calc(-1 * var(--gutter)); padding: 2px var(--gutter); scrollbar-width: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  min-height: 36px; padding: 6px 14px; border-radius: 10px; border: 1px solid var(--outline-variant);
  background: transparent; color: var(--text); font-size: .9rem; font-weight: 500; cursor: pointer;
}
.chip .icon { width: 18px; height: 18px; }
.chip[aria-pressed="true"] { background: var(--secondary-container); color: var(--on-secondary-container); border-color: transparent; }
.chip .n { color: var(--muted); font-weight: 500; }
.chip[disabled] { cursor: default; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: .85rem; font-weight: 600; color: var(--muted); }
.field .help { font-size: .82rem; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=search], input:not([type]), textarea {
  width: 100%; min-height: 52px; padding: 12px 16px; font: inherit; color: var(--text);
  background: transparent; border: 1px solid var(--outline); border-radius: 14px;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.45; }
input:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.search { position: relative; }
.search .icon { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input { padding-left: 50px; border-radius: 28px; }
.password { position: relative; }
.password input { padding-right: 56px; }
.password .icon-btn { position: absolute; right: 2px; top: 2px; }
.error-text { color: var(--error); font-size: .92rem; }

.tabs { display: flex; border-bottom: 1px solid var(--outline-variant); }
.tab { flex: 1; min-height: 48px; border: 0; background: none; cursor: pointer; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; }
.tab[aria-selected="true"] { color: var(--primary); border-bottom-color: var(--primary); }

/* --- dialogs, sheets, menus, toasts ------------------------------------------------------- */

dialog { color: var(--text); }
dialog::backdrop { background: var(--scrim); }
.dialog { border: 0; padding: 0; border-radius: 28px; background: var(--surface-mid); width: min(92vw, 420px); max-height: 85dvh; box-shadow: var(--shadow); }
.dialog-inner { padding: 24px; display: flex; flex-direction: column; gap: 16px; max-height: 85dvh; overflow-y: auto; }
.dialog-title { font-size: 1.35rem; font-weight: 600; }
.dialog-text { color: var(--muted); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.details { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; }
.details dt { color: var(--muted); }
.details dd { margin: 0; }
.issues { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.issues li { display: flex; flex-direction: column; }
.issue-label { font-size: .8rem; font-weight: 650; color: var(--error); }
.issues .warning .issue-label { color: var(--partial); }

.sheet { margin: auto auto 0; width: min(100vw, var(--max)); max-width: 100vw; border-radius: 28px 28px 0 0; max-height: 92dvh; }
.sheet .dialog-inner { padding: 12px 24px calc(20px + var(--safe-bottom)); max-height: 92dvh; }
.sheet .dialog-inner::before { content: ""; align-self: center; width: 32px; height: 4px; border-radius: 2px; background: var(--outline-variant); margin-bottom: 4px; }
.sheet-option { display: flex; align-items: center; gap: 16px; width: 100%; min-height: 64px; padding: 10px 12px; border: 0; border-radius: 16px; background: none; text-align: left; cursor: pointer; }
.sheet-option:hover { background: var(--surface-high); }
.sheet-option .badge { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: var(--primary-container); color: var(--on-primary-container); flex: none; }
.sheet-option .grow { display: flex; flex-direction: column; }
.sheet-option .muted { font-size: .85rem; }

.menu { margin: 0; position: fixed; inset: auto; border-radius: 12px; width: auto; min-width: 200px; max-width: 80vw; }
.menu::backdrop { background: transparent; }
.menu .dialog-inner { padding: 8px 0; gap: 0; }
.menu-item { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 48px; padding: 0 20px 0 14px; border: 0; background: none; text-align: left; cursor: pointer; white-space: nowrap; }
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-highest); outline: none; }
.menu-item .icon { color: var(--muted); }
.menu-item.danger-text .icon { color: var(--bad); }

.toasts { position: fixed; z-index: 100; left: 0; right: 0; bottom: calc(16px + var(--safe-bottom)); display: flex; flex-direction: column; align-items: center; pointer-events: none; padding: 0 16px; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 8px;
  max-width: min(560px, 100%); min-height: 48px; padding: 6px 8px 6px 16px; border-radius: 8px;
  background: #312f3a; color: #f2eff7; box-shadow: var(--shadow);
  opacity: 0; transform: translateY(12px); transition: opacity .2s, transform .2s;
}
.toast.shown { opacity: 1; transform: none; }
body:has(.fab:not([hidden])) .toasts { bottom: calc(88px + var(--safe-bottom)); }
.toast-action { color: #c7d2fe !important; }
@media (prefers-color-scheme: dark) { .toast { background: #e6e1ec; color: #1c1b22; } .toast-action { color: #4f46e5 !important; } }

.banner { display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 16px; border-radius: 14px; background: var(--secondary-container); color: var(--on-secondary-container); }
.banner p { flex: 1; font-size: .92rem; }

.progress { height: 4px; border-radius: 2px; background: var(--surface-highest); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--primary); transition: width .3s; }
.progress.indeterminate > span { width: 40%; animation: slide 1.2s infinite ease-in-out; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
.spinner { display: inline-block; width: 28px; height: 28px; border-radius: 50%; border: 3px solid color-mix(in srgb, var(--primary) 25%, transparent); border-top-color: var(--primary); animation: spin .8s linear infinite; flex: none; }
.spinner.small { width: 20px; height: 20px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.center { display: grid; place-items: center; padding: 32px; }
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* --- the store ----------------------------------------------------------------------------- */

.store-card { border-radius: 20px; background: var(--surface-low); overflow: hidden; }
.store-card > button.open { display: block; width: 100%; padding: 0; border: 0; background: none; text-align: left; cursor: pointer; }
.store-card .art { width: 100%; aspect-ratio: 3.2; object-fit: cover; display: block; background: var(--surface-highest); transition: aspect-ratio .2s; }
.store-card.expanded .art { aspect-ratio: 16 / 9; }
.store-card .body { padding: 14px 16px 0; display: flex; flex-direction: column; gap: 4px; }
.store-card .title { font-weight: 600; font-size: 1.05rem; }
.store-card .meta { font-size: .85rem; color: var(--muted); }
.store-card .description { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; margin-top: 2px; }
.store-card.expanded .description { -webkit-line-clamp: unset; display: block; }
.store-card .tags { font-size: .85rem; color: var(--primary); }
.store-card .actions { display: flex; justify-content: flex-end; align-items: center; padding: 10px 16px 14px; min-height: 64px; }
.installed-note { display: inline-flex; align-items: center; gap: 6px; color: var(--primary); font-weight: 600; font-size: .92rem; padding: 8px; }
.installed-note .icon { width: 18px; height: 18px; }
.section-title { margin-top: 10px; }
.section-title h2 { font-size: 1rem; color: var(--primary); }
.section-title p { font-size: .85rem; color: var(--muted); }
.store-footer { display: grid; place-items: center; gap: 8px; padding: 16px 0; text-align: center; color: var(--muted); }

/* --- sessions ------------------------------------------------------------------------------ */

.session-bar .progress { flex: 1; height: 8px; border-radius: 4px; }
.session-bar .count { font-weight: 600; font-size: .95rem; padding: 0 12px 0 8px; font-variant-numeric: tabular-nums; }
.question { flex: 1; padding: 8px 20px 24px; display: flex; flex-direction: column; gap: 20px; }
.question .from { color: var(--primary); font-weight: 600; font-size: .92rem; margin-bottom: -12px; }
.prompt { display: flex; flex-direction: column; gap: 16px; }
.prompt-text { font-size: 1.5rem; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.prompt-image { display: block; width: 100%; max-height: 320px; object-fit: contain; border-radius: 16px; cursor: zoom-in; background: none; border: 0; padding: 0; }
.prompt-image img { width: 100%; max-height: 320px; object-fit: contain; border-radius: 16px; display: block; }
.hint { color: var(--muted); font-size: .88rem; }
.label { color: var(--muted); font-weight: 600; font-size: .92rem; }

.actions-area {
  position: sticky; bottom: 0; z-index: 5;
  padding: 16px 16px calc(16px + var(--safe-bottom));
  background: var(--surface-mid); box-shadow: 0 -2px 12px rgb(20 16 40 / 10%);
  border-radius: 24px 24px 0 0;
}
.actions-area .rating { display: flex; gap: 8px; }
.actions-area .rating .btn { flex: 1; border-radius: 14px; min-height: 54px; padding: 8px; }
.rating .bad { background: var(--bad-container); color: var(--on-bad-container); }
.rating .partial { background: var(--partial-container); color: var(--on-partial-container); }
.rating .good-tone { background: var(--good-container); color: var(--on-good-container); }
.feedback { max-height: 34dvh; overflow-y: auto; margin-bottom: 14px; display: flex; flex-direction: column; gap: 6px; }
.verdict { display: flex; align-items: center; gap: 10px; font-size: 1.35rem; font-weight: 650; }
.verdict > .icon { width: 28px; height: 28px; }
.verdict.good { color: var(--good); }
.verdict.partial { color: var(--partial); }
.verdict.bad { color: var(--bad); }
.verdict .grow { flex: 1; }
.feedback .detail { font-size: 1.05rem; }
.feedback .explanation { color: var(--muted); }
/* The Explain button at the right of the verdict; what it says goes below, in the same scrolling area. */
.verdict .explain-button { flex: none; min-height: 34px; padding: 4px 12px 4px 10px; }
.verdict .report-button { width: 40px; height: 40px; margin: -3px -6px -3px 0; color: var(--muted); }
.verdict .report-button .icon { width: 22px; height: 22px; }
.feedback:has(.explain:not([hidden]) .answer) { max-height: 55dvh; }
.explain { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 4px; }
.explain .note { font-size: .82rem; color: var(--muted); }
.explain .note.failed { color: var(--bad); font-size: .9rem; }
.explain .working { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .9rem; }
.explain .answer { flex: 1 1 100%; display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border-radius: 14px; background: var(--surface-lowest); }
.explain .answer .text { white-space: pre-wrap; overflow-wrap: anywhere; }
.explain .answer .note { display: flex; align-items: center; gap: 6px; }
.explain .answer .note .icon { width: 16px; height: 16px; flex: none; }
.pill { display: inline-block; padding: 4px 10px; border-radius: 999px; font-weight: 650; font-size: .9rem; font-variant-numeric: tabular-nums; }
.pill.good { background: var(--good-container); color: var(--on-good-container); }
.pill.partial { background: var(--partial-container); color: var(--on-partial-container); }
.pill.bad { background: var(--bad-container); color: var(--on-bad-container); }

/* Options: rows, picture grid, big true/false buttons. */
.options { display: flex; flex-direction: column; gap: 10px; }
.option {
  display: flex; align-items: center; gap: 14px; width: 100%; min-height: 56px; padding: 14px 16px;
  border-radius: 16px; border: 1px solid var(--outline-variant); background: var(--surface-low);
  text-align: left; cursor: pointer; font-size: 1.05rem;
}
.option .icon { color: var(--outline); }
.option .mark { display: grid; place-items: center; }
.option .text { flex: 1; overflow-wrap: anywhere; }
.option .missed { font-size: .82rem; font-weight: 650; color: var(--good); }
.option.selected { border: 2px solid var(--primary); padding: 13px 15px; background: var(--primary-container); color: var(--on-primary-container); }
.option.selected .icon { color: var(--primary); }
.option.correct { border: 2px solid var(--good); padding: 13px 15px; background: var(--good-container); color: var(--on-good-container); }
.option.missed-option { border: 2px solid var(--good); padding: 13px 15px; }
.option.wrong { border: 2px solid var(--bad); padding: 13px 15px; background: var(--bad-container); color: var(--on-bad-container); }
.option.correct .icon, .option.missed-option .icon { color: var(--good); }
.option.wrong .icon { color: var(--bad); }
.option.dimmed { opacity: .6; }
.option[disabled] { cursor: default; }
@media (prefers-color-scheme: dark) { .option.selected .icon { color: var(--on-primary-container); } }

.picture-options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.picture-option { position: relative; flex-direction: column; justify-content: center; text-align: center; padding: 10px; gap: 6px; font-size: .95rem; }
.picture-option.selected, .picture-option.correct, .picture-option.wrong, .picture-option.missed-option { padding: 9px; }
.picture-option img { width: 100%; aspect-ratio: 1.5; object-fit: contain; border-radius: 8px; }
.picture-option .badge { position: absolute; top: 6px; right: 6px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; }
.picture-option .badge .icon { width: 26px; height: 26px; }

.big-options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.big-option { justify-content: center; min-height: 88px; font-size: 1.3rem; font-weight: 600; border-radius: 18px; }
.big-option.compact { grid-column: 1 / -1; min-height: 52px; font-size: 1.05rem; }

.answer-field { position: relative; }
.answer-field input { font-size: 1.4rem; min-height: 64px; border-radius: 16px; padding-right: 56px; }
.answer-field .suffix { position: absolute; right: 18px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 1.1rem; font-weight: 600; pointer-events: none; }
.answer-field.has-suffix input { padding-right: 90px; }
.answer-field .mark { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); }
.answer-field.good input { border-color: var(--good); }
.answer-field.partial input { border-color: var(--partial); }
.answer-field.bad input { border-color: var(--bad); }
.answer-field.good .mark { color: var(--good); }
.answer-field.partial .mark { color: var(--partial); }
.answer-field.bad .mark { color: var(--bad); }
.answer-field input[disabled] { opacity: 1; color: var(--text); }

.slider { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.slider .value { font-size: 2.8rem; font-weight: 500; font-variant-numeric: tabular-nums; }
.slider .track { position: relative; width: 100%; padding: 8px 0 18px; }
.slider input[type=range] { width: 100%; height: 36px; accent-color: var(--primary); margin: 0; }
.slider .marker { position: absolute; bottom: 0; width: 0; height: 0; border-left: 9px solid transparent; border-right: 9px solid transparent; border-bottom: 14px solid var(--good); transform: translateX(-50%); }
.slider .answer { color: var(--good); font-weight: 650; }
.slider .ends { display: flex; align-items: center; justify-content: space-between; width: 100%; font-size: .82rem; color: var(--muted); }

.model-answer { background: var(--secondary-container); color: var(--on-secondary-container); border-radius: 18px; padding: 18px; display: flex; flex-direction: column; gap: 8px; }
.model-answer .label { color: var(--secondary); }
@media (prefers-color-scheme: dark) { .model-answer .label { color: var(--on-secondary-container); } }

.order-list { display: flex; flex-direction: column; gap: 8px; touch-action: pan-y; }
.order-item {
  display: flex; align-items: center; min-height: 56px; padding: 0 4px;
  border-radius: 16px; border: 1px solid var(--outline-variant); background: var(--surface-low);
  transition: box-shadow .15s; position: relative;
}
.order-item.dragging { z-index: 2; border: 2px solid var(--primary); background: var(--primary-container); box-shadow: var(--shadow); transition: none; }
.order-item.correct { border: 2px solid var(--good); background: var(--good-container); color: var(--on-good-container); }
.order-item.wrong { border: 2px solid var(--bad); background: var(--bad-container); color: var(--on-bad-container); }
.order-item .handle { width: 44px; height: 44px; display: grid; place-items: center; color: var(--outline); cursor: grab; touch-action: none; flex: none; }
.order-item.correct .handle { color: var(--good); }
.order-item.wrong .handle { color: var(--bad); }
.order-item .n { width: 24px; color: var(--muted); font-weight: 650; flex: none; }
.order-item .item { flex: 1; display: flex; align-items: center; gap: 12px; padding: 8px 0; min-width: 0; overflow-wrap: anywhere; }
.order-item .item img { width: 72px; height: 48px; object-fit: contain; border-radius: 8px; flex: none; }
.order-item .right-place { color: var(--bad); font-weight: 650; padding: 0 12px; }
.end-label { color: var(--primary); font-weight: 650; font-size: .92rem; padding: 2px 4px; }
.right-order { display: flex; flex-direction: column; gap: 2px; }
.right-order h3 { color: var(--good); font-size: .95rem; margin-top: 4px; }

.sort-list { display: flex; flex-direction: column; gap: 10px; }
.sort-item { border-radius: 16px; border: 1px solid var(--outline-variant); background: var(--surface-low); padding: 10px 14px; display: flex; flex-direction: column; gap: 8px; }
.sort-item.correct { border: 2px solid var(--good); }
.sort-item.wrong { border: 2px solid var(--bad); }
.sort-item .item { display: flex; align-items: center; gap: 12px; }
.sort-item .item img { width: 72px; height: 48px; object-fit: contain; border-radius: 8px; }
.chip.answer { background: var(--good-container); color: var(--on-good-container); border-color: transparent; }
.chip.chosen-wrong { background: var(--bad-container); color: var(--on-bad-container); border-color: transparent; }

/* Passages: blanks to fill (fill_blanks) and words to tap (proofread). */
.passage { font-size: 1.2rem; line-height: 2.3; overflow-wrap: anywhere; }
.passage .blank {
  display: inline-block; width: 5ch; min-width: 5ch; max-width: 100%; min-height: 40px; margin: 0 2px; padding: 4px 10px;
  font: inherit; line-height: 1.3; color: var(--text); vertical-align: baseline;
  background: var(--surface-low); border: 1px solid var(--outline); border-radius: 10px;
}
.passage select.blank { width: auto; padding-right: 6px; }
.passage .blank:focus { outline: none; border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.passage .blank[disabled] { opacity: 1; color: inherit; }
.passage .blank.good { border: 2px solid var(--good); background: var(--good-container); color: var(--on-good-container); }
.passage .blank.partial { border: 2px solid var(--partial); background: var(--partial-container); color: var(--on-partial-container); }
.passage .blank.bad { border: 2px solid var(--bad); background: var(--bad-container); color: var(--on-bad-container); text-decoration: line-through; }
.passage .fix { margin: 0 4px 0 6px; color: var(--good); font-weight: 650; text-decoration: none; }
.passage .word { all: unset; cursor: pointer; padding: 6px 2px; border-radius: 6px; }
.passage .word:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.passage .word[aria-pressed="true"] { background: var(--primary-container); color: var(--on-primary-container); box-shadow: inset 0 -2px 0 var(--primary); }
.passage .word[disabled] { cursor: default; }
.passage .word.found { background: var(--good-container); color: var(--on-good-container); box-shadow: none; text-decoration: line-through; }
.passage .word.missed { background: var(--partial-container); color: var(--on-partial-container); box-shadow: none; text-decoration: line-through; }
.passage .word.wrong { background: var(--bad-container); color: var(--on-bad-container); box-shadow: none; }

/* Pictures to tap: maps and hotspots, with zoom. */
.picture { position: relative; width: 100%; border-radius: 16px; overflow: hidden; background: var(--surface-highest); touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.picture.zoomed { touch-action: none; }
.picture .layer { position: absolute; inset: 0; transform-origin: 0 0; will-change: transform; }
.picture .layer img { width: 100%; height: 100%; object-fit: contain; display: block; pointer-events: none; -webkit-user-drag: none; }
.picture svg.overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.picture .captions { position: absolute; inset: 0; pointer-events: none; }
.picture .caption { position: absolute; padding: 3px 8px; border-radius: 6px; color: #fff; font-size: .82rem; font-weight: 650; white-space: nowrap; box-shadow: var(--shadow); }
.picture .zoom { position: absolute; right: 8px; bottom: 8px; display: flex; flex-direction: column; gap: 6px; }
.picture .zoom .icon-btn { width: 40px; height: 40px; background: color-mix(in srgb, var(--surface) 88%, transparent); box-shadow: var(--shadow); }
.picture.answered { cursor: default; }
.picture:not(.answered) { cursor: crosshair; }

.viewer { border: 0; padding: 0; margin: 0; width: 100vw; height: 100dvh; max-width: none; max-height: none; background: #000; }
.viewer .dialog-inner { padding: 0; height: 100%; max-height: none; }
.viewer .picture { height: 100%; border-radius: 0; background: #000; }
.viewer .close { position: absolute; top: calc(8px + var(--safe-top)); right: 8px; color: #fff; z-index: 2; }

.audio { display: flex; align-items: center; gap: 16px; padding: 14px; border-radius: 20px; background: var(--secondary-container); color: var(--on-secondary-container); }
.audio .play { width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--primary); color: var(--on-primary); display: grid; place-items: center; cursor: pointer; flex: none; }
.audio .play .icon { width: 32px; height: 32px; }
.audio .grow { display: flex; flex-direction: column; gap: 6px; }
.audio .progress { height: 6px; cursor: pointer; }
.audio .time { font-size: .82rem; font-variant-numeric: tabular-nums; }
.video { width: 100%; max-height: 60dvh; border-radius: 16px; background: #000; display: block; }

/* The end of a session. */
.summary { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 16px 0; }
.ring { position: relative; width: 148px; height: 148px; margin-bottom: 12px; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 12; }
.ring .track { stroke: var(--surface-highest); }
.ring .value { stroke-linecap: round; transition: stroke-dashoffset .6s; }
.ring .good { stroke: var(--good); }
.ring .partial { stroke: var(--partial); }
.ring .bad { stroke: var(--bad); }
.ring span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 2.2rem; font-weight: 500; }
.summary h2 { font-size: 1.5rem; }
.results { gap: 20px; }
.result { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px; border: 0; border-radius: 14px; background: var(--surface-low); color: inherit; font: inherit; text-align: left; cursor: pointer; }
.result:hover { background: var(--surface-mid); }
.result .grow { display: flex; flex-direction: column; }
.result .when { white-space: nowrap; }
.result .text { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.summary-actions { display: flex; gap: 12px; padding: 16px 16px calc(16px + var(--safe-bottom)); position: sticky; bottom: 0; background: var(--bg); }
.summary-actions .btn { flex: 1; min-height: 54px; border-radius: 16px; }

/* --- making lessons --------------------------------------------------------------------------- */

.prompt-box { display: flex; flex-direction: column; gap: 10px; }
.prompt-box .row { justify-content: space-between; }
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; }
.dropzone { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 60px; padding: 12px 16px; border: 2px dashed color-mix(in srgb, var(--primary) 45%, var(--outline-variant)); border-radius: 14px; background: color-mix(in srgb, var(--primary) 4%, transparent); color: var(--muted); cursor: pointer; text-align: center; transition: background-color .15s, border-color .15s; }
.dropzone .icon { color: var(--primary); flex: none; }
.dropzone strong { color: var(--primary); font-weight: 650; }
.dropzone:hover:not(:disabled) { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 9%, transparent); }
.dropzone.dragging { border-style: solid; border-color: var(--primary); background: var(--primary-container); color: var(--on-primary-container); }
.dropzone.dragging strong, .dropzone.dragging .icon { color: inherit; }
.dropzone .over, .dropzone.dragging .idle { display: none; }
.dropzone.dragging .over { display: inline; }
.dropzone:disabled { opacity: .5; cursor: default; }
/* Nothing to drag from on a touch screen. */
@media (hover: none), (pointer: coarse) { .dropzone .hint { display: none; } }
.suggestions .chip { flex: 0 1 auto; max-width: 100%; text-align: left; }
.chat { display: flex; flex-direction: column; gap: 12px; }
.bubble { padding: 12px 16px; border-radius: 18px; max-width: 92%; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble.mine { align-self: flex-end; background: var(--primary-container); color: var(--on-primary-container); border-bottom-right-radius: 6px; }
.bubble.theirs { align-self: flex-start; background: var(--surface-low); border-bottom-left-radius: 6px; }
.bubble.failed { background: var(--bad-container); color: var(--on-bad-container); }
.bubble .changes { margin-top: 8px; font-size: .88rem; color: var(--muted); }
.bubble .changes summary { cursor: pointer; font-weight: 600; }
.bubble .changes ul { margin: 6px 0 0; padding-left: 18px; }
.bubble .working { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.bubble .undone { font-size: .82rem; color: var(--muted); margin-top: 6px; }
.ready-card { display: flex; flex-direction: column; gap: 12px; padding: 16px; border-radius: 20px; background: var(--good-container); color: var(--on-good-container); }
.ready-card .row { flex-wrap: wrap; }
.problems-card { display: flex; flex-direction: column; gap: 10px; padding: 16px; border-radius: 20px; background: var(--partial-container); color: var(--on-partial-container); }
.problems-card ul { margin: 0; padding-left: 18px; font-size: .9rem; }
.reports-card { display: flex; flex-direction: column; gap: 10px; padding: 16px; border-radius: 20px; background: var(--partial-container); color: var(--on-partial-container); }
.reports-card ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.reports-card li { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px 4px; border-radius: 14px; background: var(--surface-lowest); color: var(--text); }
.reports-card .asked { font-weight: 600; }
.reports-card .meta { font-size: .85rem; color: var(--muted); }
.reports-card .row { margin-left: -10px; }
.made-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; border: 0; border-radius: 16px; background: var(--surface-low); text-align: left; cursor: pointer; }
.made-item:hover { background: var(--surface-mid); }
.made-item .grow { display: flex; flex-direction: column; }
.made-item .meta { font-size: .85rem; color: var(--muted); }
.made-item .state { font-size: .8rem; font-weight: 650; padding: 3px 10px; border-radius: 999px; background: var(--surface-highest); color: var(--muted); white-space: nowrap; }
.made-item .state.ready { background: var(--good-container); color: var(--on-good-container); }
.made-item .state.working { background: var(--primary-container); color: var(--on-primary-container); }
.made-item .state.problems { background: var(--partial-container); color: var(--on-partial-container); }
.made-item .badge { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: var(--primary-container); color: var(--on-primary-container); flex: none; }

/* Documents: attached to a request, a made lesson's own, and cited after answering. */
.attachments, .documents-card ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.attachment, .documents-card .document { display: flex; align-items: center; gap: 10px; padding: 8px 6px 8px 12px; border-radius: 14px; background: var(--surface-low); }
.attachment > .icon, .documents-card .document > .icon { color: var(--primary); flex: none; }
.attachment .grow, .documents-card .document .grow { display: flex; flex-direction: column; min-width: 0; }
.attachment .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment .meta, .documents-card .meta { font-size: .85rem; color: var(--muted); }
.attachment.failed { background: var(--bad-container); color: var(--on-bad-container); }
.attachment.failed .meta { color: inherit; }
.documents-card { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; border-radius: 20px; background: var(--surface-lowest); border: 1px solid var(--outline-variant); }
.documents-card[open] { padding-bottom: 16px; }
.documents-card summary { cursor: pointer; font-weight: 650; display: flex; justify-content: space-between; gap: 12px; }
.documents-card .document a { font-weight: 600; color: var(--primary); overflow-wrap: anywhere; }
.check-row { display: inline-flex; align-items: center; gap: 8px; margin-top: 4px; font-size: .9rem; cursor: pointer; }
.check-row input { flex: none; width: 18px; height: 18px; accent-color: var(--primary); margin: 0; }
.bubble .attached { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; white-space: normal; }
.bubble .attached .chip { background: var(--surface-lowest); font-size: .85rem; padding: 4px 10px; }
.citation { display: flex; align-items: center; gap: 8px; font-size: .9rem; color: var(--muted); }
.citation .icon { width: 18px; height: 18px; flex: none; }
.citation a { font-weight: 650; color: var(--primary); white-space: nowrap; }
.dialog-subtitle { font-size: 1rem; margin: 16px 0 6px; }
.made-from { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.made-from a { color: var(--primary); font-weight: 600; }

/* --- the account --------------------------------------------------------------------------- */

.account-card { padding: 20px; border-radius: 20px; background: var(--primary-container); color: var(--on-primary-container); }
.account-card h2 { font-size: 1.3rem; }
.sync-state { display: flex; align-items: flex-start; gap: 12px; }
.sync-state .icon { color: var(--primary); margin-top: 2px; }
.sync-state.failed .icon { color: var(--error); }
.sync-state h3 { font-size: 1.05rem; }
.setting { display: flex; flex-direction: column; gap: 2px; }
.setting h3 { font-size: .95rem; }

/* Wider screens: a little more room. */
@media (min-width: 720px) {
  :root { --gutter: 24px; }
  .question { padding: 16px 24px 32px; }
}
