:root {
  --bg: #fbf6ef;
  --card: #ffffff;
  --ink: #221c18;
  --muted: #6f655d;
  --line: #e8ded3;
  --accent: #c8102e;
  --accent-ink: #ffffff;
  --gold: #f1bf00;
  --ok: #1f8a4c;
  --ok-bg: #e5f5ea;
  --warn: #9a6400;
  --warn-bg: #fdf1d6;
  --bad: #b3261e;
  --bad-bg: #fbe5e3;
  --shadow: 0 1px 2px rgb(60 40 20 / 8%), 0 4px 14px rgb(60 40 20 / 6%);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17130f; --card: #221c17; --ink: #f3ece4; --muted: #b0a498; --line: #3a3029;
    --accent: #ff4d5e; --accent-ink: #1a0a0c; --gold: #f1bf00;
    --ok: #5fd08c; --ok-bg: #173523; --warn: #f2c14e; --warn-bg: #3a2d0d; --bad: #ff7a70; --bad-bg: #3d1a17;
    --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.45 ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
.top {
  background: var(--accent); color: var(--accent-ink);
  border-bottom: 6px solid var(--gold);
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
}
.brand { color: inherit; text-decoration: none; font-weight: 800; font-size: 20px; letter-spacing: .2px; display: inline-flex; align-items: center; gap: 10px; }
.logo { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--gold); color: #c8102e; font-family: Georgia, serif; font-size: 22px; }
main { max-width: 680px; margin: 0 auto; padding: 18px 16px 48px; }
h1 { font-size: 24px; margin: 4px 0 14px; }
h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 28px 0 10px; }
p { margin: 8px 0; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; box-shadow: var(--shadow); margin-bottom: 12px; }
.card.current { border: 2px solid var(--accent); }
.badge { display: inline-block; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; background: var(--accent); color: var(--accent-ink); border-radius: 99px; padding: 2px 9px; vertical-align: 2px; }
.badge.gold { background: var(--gold); color: #3b2a00; }
.title { font-weight: 750; font-size: 18px; margin: 6px 0 2px; }
.meta { color: var(--muted); font-size: 14px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; align-items: center; }
.row.end { justify-content: flex-end; }
button, .btn {
  font: inherit; font-weight: 650; border: 0; border-radius: 12px; padding: 11px 16px; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; touch-action: manipulation;
}
button.ghost, .btn.ghost { background: transparent; color: var(--accent); border: 1.5px solid var(--line); }
button.plain { background: transparent; color: var(--muted); padding: 8px 10px; min-height: 36px; }
button.big, .btn.big { width: 100%; font-size: 18px; padding: 14px; }
button:disabled { opacity: .5; cursor: default; }
.dirs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.dirs button { padding: 10px 6px; font-size: 15px; flex-direction: column; gap: 0; }
.dirs button small { font-weight: 500; font-size: 12px; opacity: .85; }
.old .dirs button { background: transparent; color: var(--accent); border: 1.5px solid var(--line); min-height: 40px; }
select, input[type=text], textarea {
  font: inherit; color: var(--ink); background: var(--card); border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 12px; width: 100%;
}
select { width: auto; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.note { border-radius: 12px; padding: 12px 14px; margin: 12px 0; }
.note.warn { background: var(--warn-bg); color: var(--warn); }
.note.bad { background: var(--bad-bg); color: var(--bad); }
.note.ok { background: var(--ok-bg); color: var(--ok); }

/* quiz */
.progress { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 6px 0 18px; }
.progress > div { height: 100%; background: var(--accent); width: 0; transition: width .3s; }
.ask { font-size: 14px; color: var(--muted); margin-bottom: 4px; }
.prompt { font-size: 28px; font-weight: 750; line-height: 1.25; margin: 2px 0 16px; overflow-wrap: anywhere; }
.answer { font-size: 22px; padding: 12px 14px; }
.keys { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; }
.keys button { min-height: 38px; min-width: 40px; padding: 6px 10px; background: var(--card); color: var(--ink); border: 1.5px solid var(--line); font-weight: 600; }
.feedback { border-radius: 14px; padding: 14px 16px; margin-top: 14px; }
.feedback.ok { background: var(--ok-bg); color: var(--ok); }
.feedback.almost { background: var(--warn-bg); color: var(--warn); }
.feedback.bad { background: var(--bad-bg); color: var(--bad); }
.feedback .head { font-weight: 800; font-size: 18px; }
.feedback .sol { color: var(--ink); font-weight: 700; font-size: 19px; margin-top: 4px; }
.feedback .ex { color: var(--ink); font-size: 15px; margin-top: 8px; opacity: .85; }
.feedback .ex i { display: block; color: var(--muted); }
.score { font-size: 54px; font-weight: 800; text-align: center; margin: 8px 0 0; color: var(--accent); }
.list { list-style: none; padding: 0; margin: 0; }
.list li { padding: 10px 0; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.list li b { font-weight: 700; }

/* edit */
.photos { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.photos img { height: 120px; border-radius: 10px; border: 1px solid var(--line); }
.word { border-top: 1px solid var(--line); padding: 12px 0; display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: start; }
.word textarea { min-height: 0; resize: vertical; font-size: 15px; }
.word .ex { grid-column: 1 / 3; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.word .ex textarea { font-size: 14px; color: var(--muted); }
.word > button { grid-row: 1; grid-column: 3; }
@media (max-width: 520px) {
  .word { grid-template-columns: 1fr auto; }
  .word > button { grid-column: 2; grid-row: 1 / 3; }
  .word .ex { grid-column: 1 / 2; grid-template-columns: 1fr; }
  .list li { grid-template-columns: 1fr; gap: 0; }
}
.sticky { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0 calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); margin-top: 12px; }
.drop { border: 2px dashed var(--line); border-radius: 16px; padding: 22px 16px; text-align: center; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; justify-content: center; }
.thumbs img { height: 110px; border-radius: 10px; }
.spinner { width: 46px; height: 46px; border-radius: 50%; border: 5px solid var(--line); border-top-color: var(--accent); animation: spin 1s linear infinite; margin: 18px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } .progress > div { transition: none; } }
