/* Lisa School — mobile first */
:root {
  --bg: #f4f5fb;
  --surface: #ffffff;
  --surface-2: #f0f1fa;
  --text: #1b1d36;
  --muted: #6a6e8c;
  --line: #e4e6f3;
  --brand: #5b5ef4;
  --brand-2: #9a5cf6;
  --brand-soft: #ebebff;
  --ok: #12a06a;
  --ok-soft: #e0f6ec;
  --bad: #e2454b;
  --bad-soft: #fdeaea;
  --warn: #b7791f;
  --warn-soft: #fff4dc;
  --radius: 20px;
  --shadow: 0 1px 2px rgba(27, 29, 54, 0.05), 0 10px 30px rgba(27, 29, 54, 0.07);
  --shadow-btn: 0 6px 18px rgba(91, 94, 244, 0.35);
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12131f;
    --surface: #1c1e30;
    --surface-2: #25283d;
    --text: #eceefb;
    --muted: #9a9eba;
    --line: #2c2f47;
    --brand-soft: #2a2c55;
    --ok-soft: #12352a;
    --bad-soft: #3d1c21;
    --warn-soft: #3a2f14;
    --warn: #f0c060;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px rgba(0, 0, 0, 0.25);
  }
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}

.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(60% 40% at 90% -5%, rgba(154, 92, 246, 0.22), transparent 70%),
    radial-gradient(60% 40% at 0% 0%, rgba(91, 94, 244, 0.2), transparent 70%);
}

[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }

.ic { flex: none; display: block; }

/* ---------- layout ---------- */
.view {
  width: 100%;
  max-width: 560px;
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.enter { animation: enter 0.28s ease both; }
@keyframes enter {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.boot { flex: 1; display: grid; place-items: center; }
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--brand-soft); border-top-color: var(--brand);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- top bar ---------- */
.topbar {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 8px;
  min-height: 48px;
}
.topbar .titles { text-align: center; min-width: 0; }
.topbar h1 { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.01em; }
.topbar .titles p { color: var(--muted); font-size: 0.82rem; }
.topbar.big { grid-template-columns: 1fr 44px; }
.topbar.big .titles { text-align: left; }
.topbar.big h1 { font-size: 1.7rem; letter-spacing: -0.02em; }
.spacer { width: 44px; height: 44px; }

.icon-btn {
  width: 44px; height: 44px; border-radius: 14px; border: 0;
  display: grid; place-items: center; cursor: pointer;
  background: var(--surface); color: var(--text);
  box-shadow: var(--shadow);
  transition: transform 0.12s ease;
}
.icon-btn:active { transform: scale(0.94); }

/* ---------- cards & lists ---------- */
.stack { display: flex; flex-direction: column; gap: 12px; }

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

.choice {
  display: flex; align-items: center; gap: 14px;
  width: 100%; padding: 16px; border: 0; text-align: left; cursor: pointer;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.choice:active { transform: scale(0.985); }
.choice .tile {
  width: 52px; height: 52px; border-radius: 16px; flex: none;
  display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 6px 14px rgba(91, 94, 244, 0.3);
}
.choice .txt { flex: 1; min-width: 0; }
.choice .txt strong { display: block; font-size: 1.1rem; }
.choice .txt span { color: var(--muted); font-size: 0.9rem; }
.choice .chev { color: var(--muted); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 54px; padding: 0 22px; border: 0; border-radius: 16px;
  font-weight: 650; font-size: 1.02rem; cursor: pointer; width: 100%;
  transition: transform 0.12s ease, opacity 0.2s ease;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.primary {
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: var(--shadow-btn);
}
.btn.soft { background: var(--brand-soft); color: var(--brand); }
@media (prefers-color-scheme: dark) { .btn.soft { color: #b9bbff; } }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.danger { background: var(--bad); color: #fff; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; width: auto; min-width: 0; padding: 0 12px; }

.link-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px; border: 0; background: none; color: var(--brand); font-weight: 600; cursor: pointer;
}
@media (prefers-color-scheme: dark) { .link-btn { color: #aeb0ff; } }

/* ---------- login ---------- */
.login { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; text-align: center; }
.logo {
  width: 84px; height: 84px; border-radius: 26px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 14px 34px rgba(91, 94, 244, 0.4);
}
.login h1 { font-size: 1.8rem; letter-spacing: -0.02em; }
.login p { color: var(--muted); }
.dots { display: flex; gap: 16px; height: 20px; }
.dots i {
  width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--muted); background: transparent;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.dots i.on { background: var(--brand); border-color: var(--brand); transform: scale(1.1); }
.dots.shake { animation: shake 0.4s ease; }
.dots.shake i { border-color: var(--bad); background: var(--bad); }
@keyframes shake {
  20%, 60% { transform: translateX(-9px); }
  40%, 80% { transform: translateX(9px); }
}
.pin-msg { min-height: 1.4em; color: var(--bad); font-weight: 600; font-size: 0.95rem; }
.keypad {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; width: min(300px, 100%);
}
.key {
  height: 66px; border: 0; border-radius: 20px; cursor: pointer;
  background: var(--surface); box-shadow: var(--shadow);
  font-size: 1.6rem; font-weight: 600; display: grid; place-items: center;
  transition: transform 0.1s ease, background 0.1s ease;
}
.key:active { transform: scale(0.94); background: var(--brand-soft); }
.key.util { background: transparent; box-shadow: none; color: var(--muted); }
.key:disabled { opacity: 0.5; }

/* ---------- setup form ---------- */
.field { display: flex; flex-direction: column; gap: 10px; }
.field h2 { font-size: 1.02rem; font-weight: 650; }
.hint { color: var(--muted); font-size: 0.9rem; }
.hint b { color: var(--text); }
.err { color: var(--bad); font-weight: 600; font-size: 0.9rem; min-height: 1.2em; }

.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg .opt {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 8px;
  border-radius: 18px; background: var(--surface); border: 2px solid transparent; box-shadow: var(--shadow);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.seg .pair { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.15rem; letter-spacing: 0.02em; }
.seg .pair .ic { color: var(--muted); }
.seg .cap { font-size: 0.82rem; color: var(--muted); }
.seg input:checked + .opt { border-color: var(--brand); background: var(--brand-soft); }
.seg input:checked + .opt .pair { color: var(--brand); }
.seg input:checked + .opt .pair .ic { color: var(--brand); }
.seg input:focus-visible + .opt { outline: 3px solid var(--brand); outline-offset: 2px; }
@media (prefers-color-scheme: dark) {
  .seg input:checked + .opt .pair, .seg input:checked + .opt .pair .ic { color: #b9bbff; }
}

.range { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.range label { display: flex; flex-direction: column; gap: 6px; min-width: 0; color: var(--muted); font-size: 0.85rem; font-weight: 600; }

.num {
  width: 100%; height: 60px; padding: 0 18px; border-radius: 16px; border: 2px solid var(--line);
  background: var(--surface); color: var(--text); font: 700 1.5rem var(--font); text-align: center;
  outline: none; transition: border-color 0.15s ease;
  -moz-appearance: textfield; appearance: textfield;
}
.num::-webkit-outer-spin-button, .num::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.num:focus { border-color: var(--brand); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 8px 14px; border-radius: 999px; border: 0; cursor: pointer; font-weight: 600; font-size: 0.92rem;
  background: var(--surface-2); color: var(--muted);
}
.chip:active { transform: scale(0.95); }
.chip.on { background: var(--brand-soft); color: var(--brand); }
@media (prefers-color-scheme: dark) { .chip.on { color: #b9bbff; } }

/* ---------- quiz ---------- */
.progress { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.progress > div {
  height: 100%; border-radius: inherit; transition: width 0.35s ease;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
}
.score-pill {
  justify-self: end; min-width: 44px; height: 44px; padding: 0 10px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center; gap: 4px;
  background: var(--ok-soft); color: var(--ok); font-weight: 700;
}

.question { text-align: center; padding: 26px 18px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.question .label { color: var(--muted); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.question .word { font-size: clamp(1.8rem, 8vw, 2.4rem); font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; overflow-wrap: anywhere; }
.badge {
  display: inline-block; padding: 4px 12px; border-radius: 999px; font-size: 0.82rem; font-weight: 600;
  background: var(--brand-soft); color: var(--brand);
}
@media (prefers-color-scheme: dark) { .badge { color: #b9bbff; } }

.answer {
  width: 100%; height: 60px; padding: 0 18px; border-radius: 16px; border: 2px solid var(--line);
  background: var(--surface); color: var(--text); font: 600 1.25rem var(--font); outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.answer:focus { border-color: var(--brand); }
.answer:disabled { opacity: 1; -webkit-text-fill-color: currentColor; }
.answer.ok { border-color: var(--ok); background: var(--ok-soft); }
.answer.bad { border-color: var(--bad); background: var(--bad-soft); }

.accents { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.accents button {
  min-width: 38px; height: 40px; border: 0; border-radius: 12px; cursor: pointer;
  background: var(--surface); box-shadow: var(--shadow); font-size: 1.1rem; font-weight: 600;
}
.accents button:active { background: var(--brand-soft); }

.feedback { border-radius: var(--radius); padding: 16px; display: flex; gap: 12px; animation: enter 0.25s ease both; }
.feedback.ok { background: var(--ok-soft); color: var(--ok); }
.feedback.bad { background: var(--bad-soft); color: var(--bad); }
.feedback .body { color: var(--text); min-width: 0; }
.feedback strong { display: block; font-size: 1.05rem; }
.feedback .fix { font-weight: 700; overflow-wrap: anywhere; }
.feedback small { display: block; margin-top: 6px; color: var(--muted); font-size: 0.86rem; }

/* ---------- results ---------- */
.hero { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 24px 18px; }
.ring { position: relative; width: 148px; height: 148px; }
.ring svg { transform: rotate(-90deg); }
.ring .track { stroke: var(--surface-2); }
.ring .bar { stroke: url(#ringGrad); transition: stroke-dashoffset 0.9s ease; }
.ring .mid { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; }
.ring .mid b { font-size: 2.2rem; letter-spacing: -0.03em; line-height: 1; }
.ring .mid span { color: var(--muted); font-size: 0.85rem; }
.hero h2 { font-size: 1.35rem; }
.tally { display: flex; gap: 10px; width: 100%; }
.tally > div { flex: 1; border-radius: 16px; padding: 12px 8px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tally b { font-size: 1.6rem; line-height: 1.1; }
.tally span { font-size: 0.85rem; }
.tally .good { background: var(--ok-soft); color: var(--ok); }
.tally .wrong { background: var(--bad-soft); color: var(--bad); }
.meta { color: var(--muted); font-size: 0.88rem; }

.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 5px; background: var(--surface-2); border-radius: 16px; }
.tabs button { border: 0; padding: 10px; border-radius: 12px; background: transparent; font-weight: 650; color: var(--muted); cursor: pointer; }
.tabs button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.review-item { display: flex; gap: 12px; align-items: flex-start; }
.review-item .mark { flex: none; margin-top: 2px; }
.review-item.ok .mark { color: var(--ok); }
.review-item.bad .mark { color: var(--bad); }
.review-item .q { font-weight: 700; font-size: 1.1rem; overflow-wrap: anywhere; }
.review-item .a { margin-top: 4px; overflow-wrap: anywhere; }
.review-item .a .lbl { color: var(--muted); font-size: 0.82rem; margin-right: 4px; }
.review-item .given { color: var(--bad); text-decoration: line-through; text-decoration-thickness: 1.5px; }
.review-item .given.none { text-decoration: none; font-style: italic; }
.review-item .right { color: var(--ok); font-weight: 650; }
.review-item .note { margin-top: 6px; color: var(--muted); font-size: 0.85rem; }

/* history */
.hist { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; border: 0; cursor: pointer; padding: 14px 16px; }
.hist .info { flex: 1; min-width: 0; }
.hist .info strong { display: block; }
.hist .info span { color: var(--muted); font-size: 0.86rem; }
.score-chip { padding: 6px 12px; border-radius: 12px; font-weight: 750; font-variant-numeric: tabular-nums; }
.score-chip.hi { background: var(--ok-soft); color: var(--ok); }
.score-chip.mid { background: var(--warn-soft); color: var(--warn); }
.score-chip.lo { background: var(--bad-soft); color: var(--bad); }

.empty { text-align: center; color: var(--muted); padding: 40px 10px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.empty .ic { opacity: 0.6; }

/* modal */
dialog {
  border: 0; border-radius: 24px; padding: 22px; width: min(380px, calc(100vw - 32px));
  background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}
dialog::backdrop { background: rgba(15, 16, 35, 0.5); backdrop-filter: blur(3px); }
dialog h2 { font-size: 1.2rem; margin-bottom: 6px; }
dialog p { color: var(--muted); margin-bottom: 18px; }

@media (min-width: 600px) {
  .view { padding-top: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
