:root {
  --bg: #14181f; --panel: #1d232d; --line: #2c3440; --text: #eef1f5; --muted: #9aa5b4;
  --accent: #4f8cff; --red: #e5534b; --amber: #d9a13b; --green: #3fb06f;
  --radius: 16px;
}
@media (prefers-color-scheme: light) {
  :root { --bg: #f4f5f7; --panel: #ffffff; --line: #e1e4e9; --text: #17202b; --muted: #5d6877; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.err { color: var(--red); min-height: 1.4em; }

/* Login */
.screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-box { width: 100%; max-width: 340px; text-align: center; }
.login-box h1 { margin: 0 0 4px; font-size: 26px; }
#login-form { display: grid; gap: 12px; margin-top: 24px; }
input[type=password] {
  font: inherit; padding: 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text);
}

/* Layout */
#app { display: flex; flex-direction: column; min-height: 100vh; max-width: 560px; margin: 0 auto; }
header {
  display: flex; align-items: center; gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
}
.goal { flex: 1; display: flex; align-items: center; gap: 10px; }
.goal-bar { flex: 1; height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
#goal-fill { height: 100%; width: 0; background: var(--green); transition: width .4s; }
#goal-text { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 72px; text-align: right; }
main { flex: 1; padding: 8px 16px 96px; }
nav {
  position: fixed; bottom: 0; left: 0; right: 0; display: flex; justify-content: center; gap: 8px;
  padding: 8px 16px calc(8px + env(safe-area-inset-bottom));
  background: var(--panel); border-top: 1px solid var(--line);
}
nav button {
  flex: 1; max-width: 260px; font: inherit; font-size: 15px; padding: 10px; border: 0; border-radius: 10px;
  background: transparent; color: var(--muted);
}
nav button.active { background: var(--bg); color: var(--text); font-weight: 600; }

/* Buttons */
.btn {
  font: inherit; font-weight: 600; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); cursor: pointer;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.wide { width: 100%; }
.icon-btn {
  font-size: 22px; background: none; border: 0; color: var(--text); padding: 6px 8px; cursor: pointer; line-height: 1;
}
.small-btn { font-size: 16px; color: var(--muted); }

/* Card */
#status { min-height: 1.4em; margin-bottom: 8px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; display: flex; flex-direction: column; gap: 16px; min-height: 360px;
}
.card-tag { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.label { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.wrong { text-decoration: line-through; text-decoration-color: var(--red); color: var(--muted); margin-bottom: 14px; font-style: italic; }
.it { font-size: 22px; font-weight: 600; }
.back { border-top: 1px solid var(--line); padding-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.en-row { display: flex; align-items: flex-start; gap: 8px; }
.en { font-size: 22px; font-weight: 600; color: var(--green); flex: 1; }
.rule { color: var(--muted); font-size: 15px; }
.card-tools { display: flex; justify-content: flex-end; gap: 4px; }
.actions { margin-top: auto; }
.grades { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.wrong-btn { border-color: var(--red); color: var(--red); }
.unsure-btn { border-color: var(--amber); color: var(--amber); }
.right-btn { border-color: var(--green); color: var(--green); }

.banner, .done {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-top: 12px;
}
.banner p { margin: 0 0 12px; }
.row { display: flex; gap: 8px; }
.row .btn { flex: 1; }
.done { text-align: center; }
.done h2 { margin: 8px 0; }

/* Listen */
h2 { font-size: 20px; margin: 8px 0; }
.listen-total { font-weight: 600; margin: 12px 0; }
.resources { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.resources li { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.resources a { color: var(--accent); font-weight: 600; text-decoration: none; }
.resources .why { font-size: 14px; color: var(--muted); margin: 4px 0 10px; }
.resources .row .btn { padding: 8px; font-size: 14px; }

.toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 8px 14px; border-radius: 99px; font-size: 14px; z-index: 9;
}
