:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --ink: #1c2430;
  --muted: #7a8598;
  --accent: #2f6fed;
  --accent-dark: #2458c4;
  --good: #2e9e6b;
  --warn: #d9822b;
  --bad: #d9534f;
  --radius: 16px;
  --shadow: 0 2px 10px rgba(20, 30, 50, 0.07);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  padding-bottom: 84px;
}

.page { max-width: 640px; margin: 0 auto; padding: 12px 14px 24px; }

.head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 2px 12px;
}
.head h1 { font-size: 22px; margin: 0; }
.counter { color: var(--muted); font-size: 14px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}
.card h2 { font-size: 16px; margin: 0 0 10px; }

.muted { color: var(--muted); font-size: 14px; line-height: 1.45; }
.small { font-size: 12px; }
.center { text-align: center; }
.center-block { display: block; text-align: center; margin: 12px 0; }

/* кнопки */
.btn {
  display: inline-block; width: auto;
  border: 0; border-radius: 12px;
  padding: 13px 18px; font-size: 15px; font-weight: 600;
  cursor: pointer; text-decoration: none; text-align: center;
  transition: filter .15s ease;
}
.btn:active { filter: brightness(0.92); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-ghost { background: #eef1f6; color: var(--ink); }
.btn-block { display: block; width: 100%; margin-top: 10px; }
.link-quiet { color: var(--muted); font-size: 13px; text-decoration: none; }

/* таббар */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: space-around;
  background: rgba(255,255,255,0.96);
  border-top: 1px solid #e4e8ef;
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  text-decoration: none; color: var(--muted); font-size: 11px;
  padding: 4px 10px; border-radius: 10px;
}
.tabbar a .ico { font-size: 20px; }
.tabbar a.active { color: var(--accent); font-weight: 600; }

/* кольцо прогресса */
.ring-card { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; }
.ring {
  --pct: 0;
  width: 120px; height: 120px; border-radius: 50%;
  background: conic-gradient(var(--accent) calc(var(--pct) * 1%), #e6eaf2 0);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.ring-inner {
  width: 96px; height: 96px; border-radius: 50%;
  background: var(--card);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.ring-num { font-size: 26px; font-weight: 700; }
.ring-label { font-size: 10px; color: var(--muted); text-align: center; line-height: 1.2; }
.ring-side { display: flex; flex-direction: column; gap: 10px; flex: 1; min-width: 120px; }
.ring-card .btn-block { width: 100%; flex-basis: 100%; }

.stat { display: flex; flex-direction: column; }
.stat b { font-size: 20px; }
.stat span { font-size: 12px; color: var(--muted); }
.stat-row { display: flex; justify-content: space-between; gap: 8px; }

/* темы */
.topic-item {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px; margin-bottom: 10px;
  cursor: pointer;
}
.topic-item input { width: 22px; height: 22px; margin-top: 2px; accent-color: var(--accent); }
.topic-name { font-weight: 600; font-size: 15px; }
.topic-desc { color: var(--muted); font-size: 13px; margin-top: 2px; line-height: 1.4; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip {
  background: #e8eefb; color: var(--accent-dark);
  border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600;
}

/* карточка слова */
.card-word { text-align: center; padding: 24px 16px; }
.word-en { font-size: 26px; font-weight: 700; line-height: 1.3; }
.word-context {
  color: var(--muted); font-size: 15px; font-style: italic;
  margin: 10px 0 18px; line-height: 1.5;
}
.answer { display: none; margin-top: 16px; }
.answer.open { display: block; }
.word-ru {
  font-size: 20px; font-weight: 600; color: var(--accent-dark);
  padding: 12px; background: #eef3fd; border-radius: 12px; margin-bottom: 14px;
}
.grade-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grade { font-size: 14px; padding: 12px 8px; color: #fff; }
.grade-again { background: var(--bad); }
.grade-hard { background: var(--warn); }
.grade-good { background: var(--good); }
.grade-easy { background: var(--accent); }

.progress {
  height: 6px; background: #e6eaf2; border-radius: 999px; overflow: hidden;
  margin-bottom: 14px;
}
.progress-bar { height: 100%; background: var(--accent); border-radius: 999px; }

/* словарь */
.search-row { display: flex; gap: 8px; margin-bottom: 12px; }
.search-row input {
  flex: 1; border: 1px solid #dfe4ec; border-radius: 12px; padding: 12px; font-size: 15px;
}
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
input[type="text"], input[type="password"] {
  width: 100%; border: 1px solid #dfe4ec; border-radius: 12px;
  padding: 12px; font-size: 16px;
}
.word-list { list-style: none; margin: 0; padding: 0; }
.word-item {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 10px; padding: 12px 0; border-bottom: 1px solid #eef1f6;
}
.word-item:last-child { border-bottom: 0; }
.word-en-sm { font-weight: 700; font-size: 15px; }
.word-ru-sm { font-size: 14px; color: var(--ink); }
.btn-del {
  border: 0; background: #f2f4f8; color: var(--muted);
  width: 32px; height: 32px; border-radius: 50%; cursor: pointer; font-size: 13px;
}

/* подборка */
.digest { list-style: none; margin: 0; padding: 0; }
.digest li { padding: 10px 0; border-bottom: 1px solid #eef1f6; line-height: 1.45; }
.digest li:last-child { border-bottom: 0; }
.digest a { color: var(--accent-dark); font-weight: 600; text-decoration: none; }
.badge {
  display: inline-block; font-size: 11px; font-weight: 700;
  border-radius: 6px; padding: 2px 7px; margin-right: 6px;
}
.badge-video { background: #fde8e8; color: var(--bad); }
.badge-article { background: #e5f4ec; color: var(--good); }

/* вход */
.login-wrap { max-width: 340px; margin: 60px auto; text-align: center; }
.login-logo { font-size: 30px; font-weight: 800; color: var(--accent); }
.login-sub { color: var(--muted); margin: 6px 0 22px; font-size: 14px; }
.login-wrap .card { text-align: left; }

/* флеш-сообщения */
.flashes { max-width: 640px; margin: 10px auto 0; padding: 0 14px; }
.flash {
  padding: 11px 14px; border-radius: 12px; font-size: 14px; margin-bottom: 8px;
}
.flash-ok { background: #e5f4ec; color: var(--good); }
.flash-error { background: #fde8e8; color: var(--bad); }

/* финал сессии */
.big-emoji { font-size: 52px; }
.big-num { font-size: 44px; font-weight: 800; margin: 6px 0 0; }

/* --- тактильность и скорость отклика --- */
* {
  -webkit-tap-highlight-color: transparent;
}
.btn, .btn-del, .btn-add, .tabbar a, .grade, .api-key, summary, input[type="submit"] {
  touch-action: manipulation;
  transition: transform .06s ease, filter .06s ease;
}
.btn:active, .btn-del:active, .btn-add:active, .grade:active, .api-key:active {
  transform: scale(.95);
  filter: brightness(.9);
}
.tabbar a:active { transform: scale(.9); }
.topic-item { transition: transform .06s ease; }
.topic-item:active { transform: scale(.98); }

/* --- аккордеон «Инструкция» --- */
.acc {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  margin-bottom: 10px; overflow: hidden;
}
.acc summary {
  padding: 15px 16px; font-weight: 600; font-size: 15px; cursor: pointer;
  list-style: none; display: flex; justify-content: space-between; align-items: center;
}
.acc summary::after { content: '＋'; color: var(--accent); font-size: 18px; }
.acc[open] summary::after { content: '−'; }
.acc-body { padding: 0 16px 14px; font-size: 14px; line-height: 1.55; color: var(--ink); }
.acc-body p { margin: 6px 0; }
.acc-body ul { margin: 6px 0; padding-left: 18px; }
.acc-body code {
  background: #eef1f6; padding: 2px 6px; border-radius: 6px; font-size: 12.5px;
  word-break: break-all;
}
.api-key {
  display: block; width: 100%; text-align: left;
  background: #eef3fd; color: var(--accent-dark); border: 1px dashed var(--accent);
  border-radius: 10px; padding: 12px; font-size: 12px; word-break: break-all;
  cursor: pointer; font-family: ui-monospace, monospace;
}

/* --- фразы в словаре --- */
.word-main { flex: 1; min-width: 0; }
.phrase-block {
  margin-top: 8px; padding: 8px 10px; background: #f7f9fc;
  border-radius: 10px;
}
.phrase-row {
  display: flex; justify-content: space-between; align-items: center;
  gap: 8px; padding: 5px 0;
}
.phrase-en { font-size: 13px; font-weight: 600; }
.btn-add {
  border: 0; background: #e5f4ec; color: var(--good);
  width: 32px; height: 32px; border-radius: 50%; cursor: pointer; font-size: 14px;
  flex-shrink: 0;
}
