:root {
  --bg: #f6f5f0;
  --card: #ffffff;
  --ink: #1d2521;
  --muted: #5d6a63;
  --line: #dde2da;
  --brand: #1f7a53;
  --brand-ink: #ffffff;
  --brand-soft: #e2f1e9;
  --ok: #1f7a53;
  --ok-soft: #e2f1e9;
  --warn: #8a5300;
  --warn-soft: #fff1d6;
  --bad: #b3261e;
  --bad-soft: #fde6e3;
  --rec: #c62828;
  --amber: #ffcf5c;
  --shadow: 0 1px 2px rgb(0 0 0 / .06), 0 3px 10px rgb(0 0 0 / .05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121614;
    --card: #1b211e;
    --ink: #e8ede9;
    --muted: #9eaba4;
    --line: #2d3632;
    --brand: #43b383;
    --brand-ink: #07130d;
    --brand-soft: #1b3328;
    --ok: #5cc996;
    --ok-soft: #1b3328;
    --warn: #f2b860;
    --warn-soft: #382a13;
    --bad: #ff8a80;
    --bad-soft: #3c1d1b;
    --rec: #ff6b6b;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 18px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-tap-highlight-color: transparent;
}
#app {
  max-width: 560px;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom));
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
h1 { font-size: 26px; line-height: 1.25; margin: 8px 0 2px; }
h2 { font-size: 20px; margin: 24px 0 8px; }
h3 { font-size: 18px; margin: 16px 0 6px; }
p { margin: 8px 0; }
[hidden] { display: none !important; }

.muted { color: var(--muted); }
.small { font-size: 15px; }
.center { text-align: center; }
.pad { padding: 24px 0; }
.bold { font-weight: 700; }
.grow { flex: 1; }
.big-emoji { font-size: 56px; line-height: 1.2; margin-top: 24px; }

.card {
  background: var(--card);
  border-radius: 16px;
  padding: 16px;
  margin: 12px 0;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.card.tap { width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer; display: block; }
.card.tap:active { transform: scale(.99); }
.card .title { font-weight: 700; font-size: 19px; }

.chip {
  display: inline-block;
  font-size: 14px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
}
.chip.warn { background: var(--warn-soft); color: var(--warn); }

.cue { font-size: 22px; font-weight: 600; line-height: 1.4; margin: 12px 0 16px; }
.en { font-size: 21px; font-weight: 700; line-height: 1.35; }
.heard { font-size: 15px; color: var(--muted); margin-top: 6px; }

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 56px;
  padding: 10px 16px;
  border-radius: 14px;
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  touch-action: manipulation;
}
.btn:active:not(:disabled) { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: transparent; }
.btn.big { min-height: 88px; font-size: 22px; border-radius: 22px; }
.btn.rec { background: var(--rec); color: #fff; border-color: transparent; animation: pulse 1.4s infinite; }
.btn.small { min-height: 44px; font-size: 16px; border-radius: 12px; padding: 6px 12px; }
.btn.inline { width: auto; display: inline-flex; }
.btn.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); }
.btn.danger { color: var(--bad); border-color: var(--bad); }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgb(198 40 40 / .45); }
  70% { box-shadow: 0 0 0 16px rgb(198 40 40 / 0); }
  100% { box-shadow: 0 0 0 0 rgb(198 40 40 / 0); }
}
.row { display: flex; gap: 10px; margin: 10px 0; flex-wrap: wrap; }
.row > .btn { flex: 1 1 0; min-width: 0; }
.stack > * + * { margin-top: 10px; }

.link {
  background: none;
  border: none;
  color: var(--brand);
  font: inherit;
  font-weight: 650;
  font-size: 16px;
  padding: 10px 4px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.answer { margin: 8px 0; }
.answer .link { display: block; margin: 4px auto 0; }

.panel { border-radius: 14px; padding: 14px 16px; margin: 12px 0; }
.panel.ok { background: var(--ok-soft); }
.panel.ok .head { color: var(--ok); }
.panel.hint { background: var(--warn-soft); }
.panel.hint .head { color: var(--warn); }
.panel.plain { background: var(--card); border: 1px solid var(--line); }
.panel .head { font-weight: 700; margin-bottom: 4px; }

.model { border-left: 4px solid var(--brand); padding: 4px 0 4px 12px; margin: 12px 0; }
.model .label { font-size: 14px; color: var(--muted); font-weight: 650; }
.tag { font-size: 13px; color: var(--muted); font-weight: 500; }

.options .btn { justify-content: flex-start; text-align: left; margin: 8px 0; font-size: 20px; }
.btn.correct { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.btn.wrong { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }

textarea, input[type=text], input[type=password] {
  font: inherit;
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--ink);
  margin: 6px 0 10px;
}
textarea:focus, input:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: transparent; }

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg);
  padding: 6px 0 10px;
}
.iconbtn {
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--ink);
  font-size: 24px;
  cursor: pointer;
}
.progress { flex: 1; height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; }
.progress > div { height: 100%; width: 0; background: var(--brand); transition: width .3s; }
.footer {
  position: sticky;
  bottom: 0;
  margin-top: auto;
  padding: 16px 0 calc(4px + env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, transparent, var(--bg) 35%);
}

.calendar .cal-row { display: flex; gap: 10px; align-items: stretch; margin-top: 8px; }
.calendar .cal-day { font-weight: 700; width: 84px; flex: none; padding-top: 8px; }
.calendar .cal-items { flex: 1; }
.calendar .cal-item { padding: 8px 10px; border-radius: 10px; margin-bottom: 6px; font-weight: 600; }
.calendar .busy { background: var(--bad-soft); color: var(--bad); }
.calendar .free { background: var(--ok-soft); color: var(--ok); }

.rating { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 12px 0; }
.rating .btn { min-height: 72px; flex-direction: column; gap: 0; font-size: 18px; padding: 6px 4px; }
.rating .btn small { font-size: 12px; font-weight: 500; color: var(--muted); line-height: 1.2; }
.rating .btn.suggest { border-color: var(--brand); border-width: 3px; }

.banner { background: var(--amber); color: #2b2100; border-radius: 12px; padding: 10px 14px; margin: 8px 0; font-size: 15px; font-weight: 600; }
.banner .link { color: #2b2100; font-size: inherit; padding: 0; }
.status { font-size: 14px; color: var(--muted); text-align: center; margin: 12px 0 0; }
.tabs { display: flex; gap: 6px; margin: 4px 0 8px; }
.tabs .btn { min-height: 44px; font-size: 15px; padding: 6px 8px; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.kv:last-child { border-bottom: none; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 15px;
  z-index: 10;
  max-width: calc(100% - 32px);
}
