:root {
  --bg: #12141a;
  --bg-soft: #1a1d26;
  --bg-card: #21252f;
  --bg-hi: #2b303c;
  --fg: #e8ebf2;
  --fg-dim: #9aa3b5;
  --accent: #5b9dff;
  --accent-2: #ffd166;
  --ok: #3ddc84;
  --warn: #ffb84d;
  --bad: #ff6b6b;
  --radius: 12px;
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

body { padding-bottom: 80px; }

header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(18, 20, 26, 0.96);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid #000;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px 6px;
  font-weight: 700;
  font-size: 17px;
}
.brand small { color: var(--fg-dim); font-weight: 400; font-size: 12px; }

.flag {
  display: inline-block;
  vertical-align: middle;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  border-radius: 5px;
  margin-right: 4px;
  color: #fff;
  background: linear-gradient(to bottom, #111 0 33%, #d00 33% 66%, #fc0 66% 100%);
  border: 1px solid #444;
  text-shadow: 0 0 3px #000;
}

nav.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 0 10px 10px;
  scrollbar-width: none;
}
nav.tabs::-webkit-scrollbar { display: none; }

nav.tabs button {
  flex: 0 0 auto;
  background: var(--bg-card);
  color: var(--fg-dim);
  border: 1px solid #2f3542;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
nav.tabs button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #06101f;
}

main { padding: 12px; max-width: 900px; margin: 0 auto; }

.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
  border: 1px solid #2b303c;
}

h1, h2, h3 { margin: 0 0 8px; line-height: 1.25; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }

.muted { color: var(--fg-dim); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.mt { margin-top: 10px; }
.mb { margin-bottom: 10px; }
.center { text-align: center; }

button, .btn {
  font-family: inherit;
  font-size: 15px;
  cursor: pointer;
  border-radius: 10px;
  border: 1px solid #39404f;
  background: var(--bg-hi);
  color: var(--fg);
  padding: 9px 13px;
  transition: transform 0.06s ease, background 0.15s ease;
}
button:active { transform: scale(0.97); }
button.primary { background: var(--accent); border-color: var(--accent); color: #06101f; font-weight: 700; }
button.ghost { background: transparent; }
button.danger { background: #40222a; border-color: #6b2f3c; color: #ffb3bd; }
button:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

input[type="text"], textarea, select {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid #39404f;
  color: var(--fg);
  border-radius: 10px;
  padding: 11px 12px;
  font-family: inherit;
  font-size: 16px;
}
textarea { min-height: 90px; resize: vertical; }

/* ---------- уроки ---------- */
.lesson-row { display: flex; gap: 12px; align-items: flex-start; }
.lesson-row .num {
  flex: 0 0 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--bg-hi);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: var(--accent-2);
}
.lesson-row .meta { flex: 1; min-width: 0; }
.lesson-row .meta h3 { margin-bottom: 2px; }
.badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-hi);
  color: var(--fg-dim);
  margin-right: 6px;
}
.badge.done { background: #1c3a2a; color: var(--ok); }
.badge.progress { background: #3a3320; color: var(--accent-2); }

/* ---------- фразы ---------- */
.phrase {
  border-bottom: 1px solid #2b303c;
  padding: 12px 0;
}
.phrase:last-child { border-bottom: none; }
.phrase .de {
  font-size: 18px;
  font-weight: 600;
  word-break: break-word;
}
.phrase .ru { color: var(--fg-dim); margin-top: 3px; display: none; }
.phrase.revealed .ru { display: block; }
.phrase .tip {
  color: var(--accent-2);
  font-size: 13px;
  margin-top: 3px;
  display: none;
}
.phrase.revealed .tip { display: block; }
.phrase .ctrls { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 9px; }
.phrase .ctrls button { padding: 7px 11px; font-size: 14px; }

.spk { background: var(--accent); border-color: var(--accent); color: #06101f; font-weight: 700; }
.mic-rec { background: var(--bad) !important; border-color: var(--bad) !important; color: #fff !important; animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.55; } }

/* ---------- результат проверки ---------- */
.result { margin-top: 10px; padding: 11px; border-radius: 10px; background: var(--bg-soft); border: 1px solid #333a48; }
.result.hidden { display: none; }
.score-line { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.score-pill { font-weight: 700; font-size: 17px; padding: 3px 11px; border-radius: 999px; }
.s-ok { background: #1c3a2a; color: var(--ok); }
.s-mid { background: #3a3320; color: var(--accent-2); }
.s-bad { background: #40222a; color: var(--bad); }

.diff { font-size: 17px; line-height: 1.9; }
.diff span { padding: 1px 4px; border-radius: 5px; margin-right: 2px; }
.d-ok { background: #1c3a2a; color: var(--ok); }
.d-wrong { background: #40222a; color: var(--bad); text-decoration: line-through; }
.d-missing { background: #3a3320; color: var(--accent-2); opacity: 0.75; }
.d-extra { background: #2b303c; color: var(--fg-dim); font-style: italic; }

.heard { font-size: 14px; color: var(--fg-dim); margin-top: 7px; }
.hints { margin: 8px 0 0; padding-left: 18px; font-size: 13px; color: var(--accent-2); }
.hints li { margin-bottom: 3px; }

/* ---------- словарь ---------- */
.flash {
  min-height: 190px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 10px;
  padding: 22px 14px;
}
.flash .front { font-size: 30px; font-weight: 700; word-break: break-word; }
.flash .back { font-size: 22px; color: var(--accent); }
.flash .hint { font-size: 14px; color: var(--fg-dim); }
.grade-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin-top: 12px; }
.grade-row button { padding: 12px 4px; font-size: 14px; font-weight: 700; }
.g0 { background: #40222a; border-color: #6b2f3c; color: #ffb3bd; }
.g1 { background: #3a3320; border-color: #6b5a2f; color: var(--accent-2); }
.g2 { background: #1c3a2a; border-color: #2f6b4a; color: var(--ok); }
.g3 { background: #1e3247; border-color: #2f5a7a; color: #8ecbff; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 9px; }
.stat {
  background: var(--bg-soft);
  border-radius: 10px;
  padding: 11px;
  text-align: center;
}
.stat .v { font-size: 24px; font-weight: 700; color: var(--accent); }
.stat .k { font-size: 12px; color: var(--fg-dim); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  background: var(--bg-hi);
  border: 1px solid #39404f;
  color: var(--fg);
  padding: 11px 16px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 200;
  max-width: 90vw;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
}
.toast.hidden { display: none; }
.toast.err { background: #40222a; border-color: #6b2f3c; color: #ffb3bd; }

.warn-box {
  background: #3a3320;
  border: 1px solid #6b5a2f;
  color: var(--accent-2);
  border-radius: var(--radius);
  padding: 12px;
  font-size: 14px;
  margin-bottom: 10px;
}

details { margin-top: 8px; }
summary { cursor: pointer; font-weight: 600; color: var(--accent); padding: 4px 0; }
.grammar-item { margin-top: 10px; }
.grammar-item h4 { margin: 0 0 3px; font-size: 15px; color: var(--accent-2); }
.grammar-item p { margin: 0; font-size: 14px; color: var(--fg); }

.dialog-line { display: flex; gap: 9px; padding: 8px 0; border-bottom: 1px solid #2b303c; }
.dialog-line:last-child { border-bottom: none; }
.dialog-line .who {
  flex: 0 0 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}
.who-A { background: #1e3247; color: #8ecbff; }
.who-B { background: #3a2a47; color: #d9a8ff; }
.dialog-line .say { flex: 1; min-width: 0; }

.reading p { margin: 0 0 10px; font-size: 17px; line-height: 1.7; }

.spacer { height: 6px; }
footer.note { text-align: center; color: var(--fg-dim); font-size: 12px; padding: 16px 10px 6px; }
