/* WordAssistant — simple, calm interface for desktop and phone */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #2563eb;
  --primary-ink: #ffffff;
  --primary-soft: #eff6ff;
  --success: #15803d;
  --success-soft: #ecfdf3;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(17, 24, 39, 0.06), 0 1px 3px rgba(17, 24, 39, 0.04);
  --nav-w: 220px;
  --bottom-h: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115;
    --surface: #171a21;
    --text: #e5e7eb;
    --muted: #9ca3af;
    --line: #272b35;
    --primary-soft: #1e293b;
    --success-soft: #0f2a1a;
    --danger-soft: #2a1414;
    --warn-soft: #2a2110;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0f1115;
  --surface: #171a21;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --line: #272b35;
  --primary-soft: #1e293b;
  --success-soft: #0f2a1a;
  --danger-soft: #2a1414;
  --warn-soft: #2a2110;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3 { margin: 0 0 6px; line-height: 1.3; color: var(--text); }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 13px; font-weight: 650; color: var(--muted); text-transform: none; margin-top: 18px; }
p { margin: 0 0 8px; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: var(--line); padding: 1px 6px; border-radius: 6px; font-size: 0.92em; }
kbd {
  display: inline-block; min-width: 1.5em; padding: 0 5px; margin-left: 6px;
  border-radius: 5px; border: 1px solid var(--line); background: var(--surface);
  font: 600 12px/1.6 ui-monospace, Consolas, monospace; color: var(--muted); text-align: center;
}
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error-text { color: var(--danger); }
.status-ok { color: var(--success); font-weight: 600; }
.status-off { color: var(--warn); font-weight: 600; }
.hidden { display: none !important; }

/* ---------- app shell ---------- */
.app { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--nav-w); padding: 20px 14px;
  background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 18px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; font-weight: 700; font-size: 16px; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px; background: var(--primary); color: #fff;
  display: grid; place-items: center; font-size: 16px;
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px;
  color: var(--text); font-weight: 500; position: relative;
}
.nav a:hover { background: var(--bg); text-decoration: none; }
.nav a.active { background: var(--primary-soft); color: var(--primary); font-weight: 650; }
.nav-icon { width: 20px; text-align: center; font-size: 16px; }
.nav-badge {
  margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--danger); color: #fff; font-size: 12px; display: grid; place-items: center;
}
.book-box { margin-top: auto; padding: 12px; border-radius: var(--radius); background: var(--bg); }
.book-box .label { font-size: 12px; color: var(--muted); }
.book-box a { font-weight: 650; color: var(--text); display: block; margin: 2px 0 8px; }
.bar { height: 6px; border-radius: 6px; background: var(--line); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--primary); border-radius: 6px; transition: width .3s; }

.topbar { display: none; }
.bottom-nav { display: none; }

.content {
  margin-left: var(--nav-w); padding: 28px 32px 56px; max-width: 920px; min-width: 0;
}

/* ---------- controls ---------- */
.btn {
  appearance: none; border: 1px solid transparent; cursor: pointer; font: inherit; font-weight: 600;
  font-size: 15px; padding: 10px 16px; border-radius: 10px; display: inline-flex; align-items: center;
  justify-content: center; gap: 8px; line-height: 1.2; white-space: nowrap;
  background: var(--primary); color: var(--primary-ink); transition: background .15s, opacity .15s;
  text-decoration: none !important;
}
.btn:hover { filter: brightness(0.96); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--line); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-quiet { background: transparent; color: var(--muted); padding: 8px 10px; }
.btn-quiet:hover { color: var(--text); background: var(--bg); filter: none; }
.btn-sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn-lg { padding: 13px 20px; font-size: 16px; }
.btn-block { width: 100%; }

.select, .input, textarea.input {
  appearance: none; font: inherit; font-size: 15px; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; min-width: 0; width: 100%;
}
.select {
  padding-right: 32px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
  linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 55%, calc(100% - 11px) 55%; background-size: 5px 5px; background-repeat: no-repeat;
}
.select:focus, .input:focus, textarea.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.input.num { width: 110px; }
textarea.input { font-family: ui-monospace, Consolas, monospace; font-size: 13px; resize: vertical; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 550; }
.field-hint { font-size: 12px; color: var(--muted); font-weight: 400; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 550; }

.toast-host { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 60; width: min(92vw, 420px); }
.toast { background: var(--text); color: var(--surface); padding: 11px 16px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.18); font-size: 14px; animation: rise .2s ease; }
.toast-error { background: var(--danger); color: #fff; }
.toast-hide { opacity: 0; transition: opacity .3s; }

/* ---------- page header ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head p { color: var(--muted); margin: 0; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.back-link { font-size: 14px; display: inline-block; margin-bottom: 6px; }

/* ---------- segmented control ---------- */
.segmented { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--line); gap: 2px; margin-bottom: 16px; }
.seg { appearance: none; border: 0; background: transparent; font: inherit; font-size: 14px; font-weight: 600; color: var(--muted); padding: 7px 14px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.seg.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* ---------- panels and lists ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 14px; box-shadow: var(--shadow); }
.panel > h2 { margin-bottom: 4px; }
.row { display: flex; align-items: center; gap: 12px; justify-content: space-between; flex-wrap: wrap; }
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat span { display: block; font-size: 13px; color: var(--muted); }
.stat b { font-size: 26px; font-weight: 700; letter-spacing: -0.01em; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--line); color: var(--muted); }
.chip-blue { background: var(--primary-soft); color: var(--primary); }
.chip-green { background: var(--success-soft); color: var(--success); }
.chip-amber { background: var(--warn-soft); color: var(--warn); }
.tag { display: inline-block; font-size: 12px; font-weight: 650; padding: 2px 8px; border-radius: 6px; }
.tag-new { background: var(--primary-soft); color: var(--primary); }
.tag-learning { background: var(--line); color: var(--muted); }
.tag-review { background: var(--warn-soft); color: var(--warn); }
.tag-mastered { background: var(--success-soft); color: var(--success); }
.tag-weak { background: var(--danger-soft); color: var(--danger); }

/* ---------- study ---------- */
.progress-line { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--muted); margin-bottom: 8px; gap: 10px; }
.progress-line b { color: var(--text); }
.score-know { color: var(--success); font-weight: 600; }
.score-forget { color: var(--danger); font-weight: 600; }

.word-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow);
  padding: 36px 28px 28px; text-align: center;
}
.word-meta { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; min-height: 24px; margin-bottom: 10px; }
.word { font-size: clamp(40px, 9vw, 64px); font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; word-break: break-word; margin: 6px 0 14px; }
.say-btn {
  appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font: inherit; font-size: 14px; font-weight: 600; padding: 7px 14px; border-radius: 999px; cursor: pointer;
}
.say-btn:hover { background: var(--bg); }
.answer-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 28px; }
.answer-row .btn { padding: 14px 12px; font-size: 16px; }
.answer-row .btn kbd { color: inherit; border-color: transparent; background: rgba(255,255,255,.2); }
.answer-row .btn-secondary kbd { background: var(--line); }
.answer-row .btn-danger { background: var(--danger); }
.answer-row .btn-next { grid-column: 1 / -1; }

.details { text-align: left; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.details-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.ipa { font-size: 20px; font-family: "Charis SIL", "Doulos SIL", "Segoe UI", serif; }
.ipa-note { font-size: 12px; color: var(--muted); margin-top: 2px; }
.meaning-list { list-style: none; padding: 0; margin: 4px 0 0; }
.meaning-list li { display: flex; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.meaning-list li:last-child { border-bottom: 0; }
.pos { flex: none; font-size: 12px; font-weight: 650; color: var(--primary); min-width: 2.6em; }
.english { padding-left: 20px; margin: 4px 0 0; }
.english li { margin: 3px 0; }
.english em { color: var(--muted); font-style: normal; font-weight: 600; }
.examples { display: grid; gap: 10px; margin-top: 4px; }
.example { padding: 10px 12px; border-radius: 10px; background: var(--bg); }
.example-en { font-weight: 550; }
.example-zh { color: var(--muted); font-size: 14px; margin-top: 2px; }
.details-loading { color: var(--muted); padding: 16px 0; }

.hint { margin-top: 14px; font-size: 13px; color: var(--muted); text-align: center; }

/* ---------- summary and empty states ---------- */
.summary, .empty {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow);
  padding: 34px 24px; text-align: center;
}
.summary-icon, .empty-icon { font-size: 40px; margin-bottom: 6px; }
.summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 20px 0; }
.summary-cell { border-radius: 12px; padding: 16px 10px; }
.summary-cell b { display: block; font-size: 32px; font-weight: 700; }
.summary-cell span { font-size: 13px; font-weight: 600; }
.cell-know { background: var(--success-soft); color: var(--success); }
.cell-forget { background: var(--danger-soft); color: var(--danger); }
.empty-actions, .summary .actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }
.empty p, .summary p { color: var(--muted); max-width: 520px; margin: 6px auto 0; }

/* ---------- quiz ---------- */
.quiz-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.quiz-type {
  appearance: none; text-align: left; cursor: pointer; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; min-height: 112px;
}
.quiz-type:hover { border-color: var(--primary); }
.quiz-type .qt-title { font-weight: 650; font-size: 16px; }
.quiz-type .qt-desc { font-size: 13px; color: var(--muted); }
.quiz-type .qt-tag { margin-top: auto; align-self: flex-start; }

.quiz-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 22px 24px 26px; max-width: 720px; margin: 0 auto; }
.quiz-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; color: var(--muted); font-size: 13px; }
.quiz-head b { color: var(--text); font-size: 14px; }
.quiz-body { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; padding-top: 10px; }
.q-prompt { color: var(--muted); font-size: 14px; }
.q-word { font-size: clamp(34px, 7vw, 52px); font-weight: 700; letter-spacing: -0.01em; }
.q-meaning { font-size: 19px; font-weight: 600; display: grid; gap: 4px; }
.mask { font-size: 30px; font-weight: 600; letter-spacing: .12em; font-family: ui-monospace, Consolas, monospace; min-height: 40px; }
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; margin-top: 6px; }
.option {
  appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font: inherit; font-size: 15px; font-weight: 550; padding: 14px; border-radius: 12px; cursor: pointer;
  text-align: left; display: flex; align-items: center; gap: 10px;
}
.option:hover:not(:disabled) { border-color: var(--primary); background: var(--primary-soft); }
.option:disabled { cursor: default; }
.option kbd { margin-left: 0; }
.option-right { border-color: var(--success) !important; background: var(--success-soft) !important; color: var(--success) !important; }
.option-wrong { border-color: var(--danger) !important; background: var(--danger-soft) !important; color: var(--danger) !important; }
.spell-form { display: flex; gap: 8px; width: 100%; max-width: 480px; justify-content: center; flex-wrap: wrap; margin-top: 4px; }
.spell-form .input { flex: 1 1 220px; font-size: 18px; text-align: center; padding: 11px 12px; }
.verdict { width: 100%; border-radius: 12px; padding: 12px 16px; text-align: center; }
.verdict-line { font-weight: 700; font-size: 16px; }
.verdict-text { font-size: 14px; margin-top: 3px; }
.verdict-ok { background: var(--success-soft); color: var(--success); }
.verdict-bad { background: var(--danger-soft); color: var(--danger); }
.reveal { width: 100%; text-align: left; background: var(--bg); border-radius: 12px; padding: 12px 16px; }
.reveal b { font-size: 18px; }
.quiz-foot { width: 100%; display: flex; justify-content: flex-end; margin-top: 4px; }
.mic-btn {
  width: 92px; height: 92px; border-radius: 50%; border: 0; cursor: pointer; font-size: 38px; color: #fff;
  background: var(--primary); box-shadow: 0 10px 24px -10px rgba(37,99,235,.7);
}
.mic-btn:disabled { opacity: .55; cursor: wait; }
.mic-btn.listening { background: var(--danger); animation: pulse 1.2s ease-in-out infinite; }
.mic-status { min-height: 20px; font-size: 14px; color: var(--muted); }
.q-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.wrong-list { text-align: left; margin-top: 16px; }
.wrong-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; margin-top: 8px; }
.wrong-item b { font-weight: 650; }
.wrong-item span { flex: 1; color: var(--muted); font-size: 14px; }

/* ---------- key review, books, lookup ---------- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.card-item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px; }
.card-item.is-active { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.card-item h3 { margin: 0; font-size: 17px; color: var(--text); text-transform: none; }
.card-item .desc { font-size: 13px; color: var(--muted); }
.card-item .meta { font-size: 13px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }
.card-item .actions { display: flex; gap: 8px; margin-top: auto; flex-wrap: wrap; }
.weak-meaning { color: var(--muted); font-size: 14px; }
.word-row { display: grid; grid-template-columns: 36px minmax(90px, 160px) 1fr auto; gap: 12px; align-items: center; padding: 11px 14px; border-bottom: 1px solid var(--line); }
.word-row:last-child { border-bottom: 0; }
.word-row .w { font-weight: 650; }
.word-row .m { color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn { appearance: none; border: 1px solid var(--line); background: var(--surface); width: 32px; height: 32px; border-radius: 50%; cursor: pointer; font-size: 14px; }
.word-list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 14px; }
.lookup-form { display: flex; gap: 8px; margin-bottom: 16px; }
.lookup-form .input { font-size: 17px; padding: 11px 14px; }
.lookup-form .btn { flex: none; }
.back-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

/* ---------- stats and settings ---------- */
.bars { display: grid; grid-template-columns: repeat(14, 1fr); gap: 6px; height: 170px; align-items: end; margin-top: 12px; }
.bar-col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; }
.bar-stack { width: 100%; max-width: 26px; display: flex; flex-direction: column-reverse; border-radius: 6px 6px 3px 3px; overflow: hidden; min-height: 3px; background: var(--line); }
.bar-know { background: var(--success); }
.bar-forget { background: var(--danger); }
.bar-label { font-size: 10px; color: var(--muted); }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--muted); margin-top: 6px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.curve { width: 100%; height: auto; margin-top: 8px; }
.usage { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 8px; }
.usage th, .usage td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
.usage th { color: var(--muted); font-weight: 600; }
.setting { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.setting:last-child { border-bottom: 0; }
.setting-title { font-weight: 600; }
.code-block { background: var(--bg); padding: 12px 14px; border-radius: 10px; font-size: 13px; overflow-x: auto; line-height: 1.7; font-family: ui-monospace, Consolas, monospace; margin: 8px 0 0; }
.token-box { font-family: ui-monospace, Consolas, monospace; font-size: 18px; letter-spacing: .08em; padding: 10px 14px; background: var(--bg); border-radius: 10px; display: inline-block; }

.loading { color: var(--muted); padding: 60px 0; text-align: center; }

/* ---------- motion ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(185, 28, 28, .45); } 50% { box-shadow: 0 0 0 18px rgba(185, 28, 28, 0); } }
.fade-in { animation: rise .25s ease; }

/* ---------- phone layout ---------- */
@media (max-width: 899px) {
  .sidebar { display: none; }
  .topbar {
    display: flex; position: sticky; top: 0; z-index: 30; align-items: center; justify-content: space-between;
    height: 52px; padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--line);
  }
  .topbar-title { font-weight: 650; font-size: 16px; }
  .content { margin-left: 0; padding: 16px 14px calc(var(--bottom-h) + 24px); }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    height: var(--bottom-h); background: var(--surface); border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .bottom-nav a {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    font-size: 11px; font-weight: 600; color: var(--muted); text-decoration: none; position: relative;
  }
  .bottom-nav a .nav-icon { font-size: 19px; width: auto; }
  .bottom-nav a.active { color: var(--primary); }
  .bottom-nav .nav-badge { position: absolute; top: 6px; left: calc(50% + 6px); min-width: 16px; height: 16px; font-size: 10px; padding: 0 4px; }
  .page-head { margin-bottom: 14px; }
  h1 { font-size: 20px; }
  .word-card { padding: 28px 18px 22px; }
  .answer-row { margin-top: 22px; }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .word-row { grid-template-columns: 32px 1fr auto; }
  .word-row .m { grid-column: 2 / -1; white-space: normal; }
  .word-row .w { grid-column: 2; }
  .bars { gap: 3px; }
  .bar-label { font-size: 9px; }
  .options { grid-template-columns: 1fr; }
  .quiz-card { padding: 18px 16px 22px; }
  .lookup-form { flex-wrap: nowrap; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- access gate (phone asks for the access token once) ---------- */
.gate { position: fixed; inset: 0; background: rgba(17, 24, 39, .45); display: grid; place-items: center; padding: 20px; z-index: 80; }
.gate.hidden { display: none; }
.gate-card { background: var(--surface); border-radius: 16px; padding: 22px; width: min(92vw, 380px); box-shadow: 0 20px 50px rgba(0,0,0,.25); display: grid; gap: 12px; }
.gate-card h2 { margin: 0; }
.gate-card .input { font-size: 17px; text-align: center; letter-spacing: .06em; }
.gate-actions { display: grid; }
.gate-card .input { font-size: 16px; text-align: left; letter-spacing: normal; }

/* ---------- account: user management table ---------- */
.user-table-wrap { overflow-x: auto; }
.user-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.user-table th, .user-table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line, #e5e7eb); vertical-align: middle; }
.user-table th { color: var(--muted, #6b7280); font-size: 12px; font-weight: 600; }
.user-actions { white-space: nowrap; }
.user-actions .btn + .btn { margin-left: 4px; }
.user-table .danger { color: #dc2626; }

/* ---------- quiz setup ---------- */
.quiz-setup { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; margin-bottom: 16px; }
.quiz-setup .field { min-width: 0; }
.quiz-setup .select { width: auto; min-width: 220px; }
.quiz-setup .segmented { margin-bottom: 0; }
.order-switch { margin-bottom: 0; }
