/* Colours from ui/Theme.kt of the Android app. */
:root {
  --primary: #6a4bc4;
  --on-primary: #fff;
  --primary-container: #e9ddff;
  --on-primary-container: #22005d;
  --secondary-container: #ffdcc6;
  --on-secondary-container: #331200;
  --bg: #fffbff;
  --surface: #f6f1fa;
  --text: #1c1b1f;
  --muted: #625b71;
  --outline: #cac4d0;
  --good: #2eb872;
  --bad: #e5484d;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --primary: #cfbcff;
    --on-primary: #381e72;
    --primary-container: #4f378b;
    --on-primary-container: #e9ddff;
    --secondary-container: #6b3300;
    --on-secondary-container: #ffdcc6;
    --bg: #141218;
    --surface: #211f26;
    --text: #e6e0e9;
    --muted: #cac4d0;
    --outline: #49454f;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
  -webkit-text-size-adjust: 100%;
}
#app { max-width: 640px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }
h1, h2, h3 { margin: 0; }
h1 { font-size: 1.35rem; }
p { margin: 0; }

button, .button {
  font: inherit; color: inherit; border: 0; background: none; cursor: pointer;
  border-radius: 18px; padding: 12px 18px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
button:disabled { cursor: default; }
.primary { background: var(--primary); color: var(--on-primary); font-weight: 600; }
.tonal { background: var(--secondary-container); color: var(--on-secondary-container); border-radius: 999px; padding: 10px 18px; }
.tonal:disabled { opacity: 0.55; }
.outlined { border: 1px solid var(--outline); }
.text { color: var(--primary); padding: 8px 12px; }
.danger { color: var(--bad); }
.big { width: 100%; min-height: 56px; font-size: 1.15rem; }
.icon { font-size: 1.4rem; padding: 8px 12px; border-radius: 999px; }

.row { display: flex; align-items: center; gap: 8px; }
.row.end { justify-content: flex-end; }
.row.gap { gap: 12px; margin: 12px 0; }
.grow { flex: 1; min-width: 0; }
.small { font-size: 0.9rem; color: var(--muted); }

.card { background: var(--surface); border-radius: 16px; padding: 16px; }

.topbar {
  position: sticky; top: 0; z-index: 2; background: var(--bg);
  display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 8px) 12px 8px;
}
.list-picker {
  flex: 1; min-width: 0; font: inherit; font-size: 1.2rem; font-weight: 700; color: var(--text);
  background: transparent; border: 0; padding: 8px 4px; appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: right 10px center, right 4px center; background-size: 6px 6px; background-repeat: no-repeat;
  padding-right: 24px; text-overflow: ellipsis;
}
.list-picker option { color: #000; }

main { padding: 8px 16px calc(env(safe-area-inset-bottom) + 24px); display: flex; flex-direction: column; gap: 10px; }
main.list { padding-bottom: 110px; }

.bar { height: 12px; border-radius: 999px; background: color-mix(in srgb, var(--good) 20%, transparent); overflow: hidden; }
.bar > div { height: 100%; background: var(--good); border-radius: 999px; transition: width 0.4s; }
.bar.thin { height: 6px; margin-top: 6px; }

.overview { background: var(--primary-container); color: var(--on-primary-container); border-radius: 24px; padding: 20px; }
.overview p { margin: 8px 0 12px; font-size: 1.05rem; }
.section-title { margin-top: 8px; min-height: 40px; }
.section-title h3 { flex: 1; font-weight: 500; }
.chapter { display: flex; align-items: center; gap: 12px; padding: 12px 16px 12px 12px; cursor: pointer; }
.chapter .name { flex: 1; font-weight: 600; }
input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--primary); flex: none; }

.bottom {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 2;
  padding: 12px 16px calc(env(safe-area-inset-bottom) + 12px);
  background: linear-gradient(to top, var(--bg) 70%, transparent);
  max-width: 640px; margin: 0 auto;
}
.bottom .big { min-height: 60px; border-radius: 20px; font-size: 1.25rem; }

.empty, .summary { flex: 1; justify-content: center; align-items: center; text-align: center; padding: 32px; }
.big-emoji { font-size: 72px; line-height: 1.1; }

/* Quiz */
.stats { display: flex; gap: 16px; font-size: 1.1rem; }
.quiz { align-items: center; }
.quiz .note { text-align: center; font-size: 0.95rem; }
.quiz .label { color: var(--muted); font-size: 0.9rem; font-weight: 500; text-align: center; }
.lights { display: flex; gap: 8px; margin: 6px 0; flex-wrap: wrap; justify-content: center; }
.light {
  width: 22px; height: 22px; border-radius: 50%;
  background: color-mix(in srgb, var(--bad) 25%, transparent);
  transition: transform 0.25s cubic-bezier(.3, 1.8, .5, 1), background 0.25s;
}
.light.on { background: var(--good); transform: scale(1.15); }
.light.failed { background: var(--bad); transform: scale(1.15); }
.prompt {
  width: 100%; min-height: 140px; display: flex; align-items: center; justify-content: center; text-align: center;
  background: var(--primary-container); color: var(--on-primary-container); border-radius: 28px; padding: 20px;
  font-size: 1.9rem; font-weight: 700; overflow-wrap: anywhere;
}
.prompt.long { font-size: 1.25rem; font-weight: 500; }
.hint { width: 100%; background: var(--secondary-container); color: var(--on-secondary-container); }
.answers { width: 100%; display: flex; flex-direction: column; gap: 10px; }
.answer {
  width: 100%; min-height: 56px; border: 1px solid var(--outline); background: var(--bg);
  font-size: 1.06rem; padding: 12px 16px; text-align: center; overflow-wrap: anywhere;
  transition: background 0.2s, transform 0.25s cubic-bezier(.3, 1.6, .5, 1);
}
.answer:active:not(:disabled) { transform: scale(0.98); }
.answer.correct { background: var(--good); border-color: var(--good); color: #fff; transform: scale(1.03); }
.answer.wrong { background: var(--bad); border-color: var(--bad); color: #fff; }
.answer.faded { opacity: 0.5; }
.feedback { font-size: 1.35rem; font-weight: 700; text-align: center; padding: 6px 0; animation: pop 0.3s ease-out; }
.feedback.good { color: var(--good); }
.feedback.bad { color: var(--bad); }
@keyframes pop { from { transform: scale(0.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* Summary */
.summary h1 { font-size: 1.8rem; margin-top: 8px; }
.summary > p { margin: 8px 0 28px; font-size: 1.05rem; }
.stats-row { display: flex; gap: 12px; width: 100%; margin-bottom: 36px; }
.stat { flex: 1; display: flex; flex-direction: column; align-items: center; border-radius: 20px; }
.stat .e { font-size: 28px; }
.stat b { font-size: 1.4rem; }
.stat span { font-size: 0.8rem; color: var(--muted); }
.summary .big { margin-bottom: 12px; }

/* Settings */
.settings .card { display: flex; flex-direction: column; gap: 10px; }
.settings h3 { margin-top: 4px; }
.settings label { display: block; }
input[type="range"] { width: 100%; accent-color: var(--primary); margin-top: 8px; }
.check { display: flex !important; align-items: center; gap: 10px; padding: 4px 0; }
.confirm { border: 1px solid var(--outline); background: var(--bg); }
.confirm p { margin: 8px 0; }

.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 96px); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 12px; z-index: 10;
  max-width: calc(100% - 32px); transition: opacity 0.4s;
}
.toast.hide { opacity: 0; }
.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 5; }
