/* Словарь — картотека: белые карточки с красной линией и голубыми линейками на столе,
   чернильно-синие действия, цвета отделений — язычки разделителей в коробке. */

:root {
  --desk: #e4e8ee;
  --card: #ffffff;
  --ink: #1a2433;
  --muted: #5d6878;
  --rule: #c9daf0;
  --red-line: #d9473b;
  --pen: #1f4fbf;
  --pen-text: #ffffff;
  --ok: #217a3c;
  --ok-soft: #e3f3e7;
  --bad: #b8322a;
  --bad-soft: #fbe6e4;
  --edge: #cfd6e0;
  --tab1: #e5534b;
  --tab2: #ee8a2e;
  --tab3: #e8b923;
  --tab4: #4aa564;
  --tab5: #3a7bd5;
  --tab6: #7a5ad8;
  --shadow: 0 1px 0 rgba(26, 36, 51, 0.06), 0 6px 16px -10px rgba(26, 36, 51, 0.35);
  --word: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --ui: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --desk: #161b23;
    --card: #222935;
    --ink: #e8ecf2;
    --muted: #9aa5b5;
    --rule: #2f3a4b;
    --red-line: #e0675d;
    --pen: #6f9cff;
    --pen-text: #0f1726;
    --ok: #74d68f;
    --ok-soft: #1d3326;
    --bad: #ff8f86;
    --bad-soft: #3a2224;
    --edge: #313a48;
    --shadow: 0 6px 16px -10px rgba(0, 0, 0, 0.8);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--desk);
  color: var(--ink);
  font: 16px/1.45 var(--ui);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: 14px 16px calc(92px + env(safe-area-inset-bottom));
  touch-action: pan-y;
}

h1 { font-size: 22px; margin: 6px 0 12px; font-weight: 700; }
h2 { font-size: 16px; margin: 22px 0 8px; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
a { color: var(--pen); }

:focus-visible { outline: 3px solid var(--pen); outline-offset: 2px; }

/* ---------- Карточка картотеки ---------- */

.index-card {
  position: relative;
  background-color: var(--card);
  background-image: repeating-linear-gradient(to bottom, transparent 0 31px, var(--rule) 31px 32px);
  background-position: 0 58px;
  border-radius: 6px;
  box-shadow: var(--shadow);
  padding: 18px 18px 16px;
  margin: 10px 0 14px;
}
.index-card::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 52px;
  height: 2px;
  background: var(--red-line);
  opacity: 0.85;
}
.card-head { height: 34px; display: flex; align-items: center; justify-content: space-between; font-size: 14px; color: var(--muted); }

/* Поле, на котором пишут: строка карточки, а не коробка. */
.line-input {
  display: block;
  width: 100%;
  border: 0;
  border-bottom: 2px solid var(--edge);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font: 24px/1.3 var(--word);
  padding: 10px 2px 6px;
  margin-top: 4px;
}
.line-input::placeholder { color: var(--muted); opacity: 0.55; }
.line-input:focus { outline: none; border-bottom-color: var(--pen); }
.line-input.ru { font-size: 21px; }
.line-input.shake { animation: shake 0.3s; border-bottom-color: var(--bad); }

textarea.line-input { font: 17px/1.5 var(--ui); min-height: 64px; resize: vertical; }

.field-label { display: block; font-size: 13px; color: var(--muted); margin-top: 16px; }

@keyframes shake {
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}
@media (prefers-reduced-motion: reduce) {
  .line-input.shake { animation: none; }
}

/* ---------- Кнопки ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 18px;
  border: 1.5px solid var(--edge);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  font: 600 16px var(--ui);
  cursor: pointer;
  text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn.pen { background: var(--pen); border-color: var(--pen); color: var(--pen-text); }
.btn.quiet { background: transparent; border-color: transparent; color: var(--pen); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: 0.45; cursor: default; }
.row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.row > .btn { flex: 1 1 140px; }

.link-btn { border: 0; background: none; color: var(--pen); font: inherit; font-size: 14px; padding: 8px 0; cursor: pointer; }

/* ---------- Подсказки слов ---------- */

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chips:empty { display: none; }
.chip {
  min-height: 34px;
  padding: 0 12px;
  border: 1.5px solid var(--edge);
  border-radius: 17px;
  background: var(--card);
  color: var(--ink);
  font: 16px var(--word);
  cursor: pointer;
}
.rank { font-size: 13px; color: var(--muted); margin-top: 6px; min-height: 18px; }
.note-box { margin: 8px 0 0; padding: 10px 12px; border-radius: 8px; font-size: 15px; }
.note-box.bad { background: var(--bad-soft); color: var(--bad); }
.note-box.ok { background: var(--ok-soft); color: var(--ok); }
.note-box .chip { min-height: 30px; margin: 2px 2px 0 0; }

/* ---------- Полоса «сегодня» ---------- */

.today {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 12px 12px 12px 16px;
  margin-bottom: 4px;
}
.today .count { font: 700 34px/1 var(--word); }
.today .what { flex: 1; font-size: 14px; color: var(--muted); }
.today .btn { flex: none; }

/* ---------- Коробка Лейтнера: отделения как язычки ---------- */

.box-strip { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin-top: 8px; }
.tab {
  background: var(--card);
  border-radius: 8px 8px 4px 4px;
  border-top: 5px solid var(--tab-color);
  box-shadow: var(--shadow);
  padding: 8px 4px 6px;
  text-align: center;
}
.tab b { display: block; font: 700 20px/1.1 var(--word); }
.tab span { font-size: 11px; color: var(--muted); }
.streak { font-size: 14px; color: var(--muted); margin-top: 10px; }

/* ---------- Список слов ---------- */

.list { background: var(--card); border-radius: 10px; box-shadow: var(--shadow); padding: 2px 12px; }
.word {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 11px 0;
  border-bottom: 1px solid var(--rule);
}
.word:last-child { border-bottom: 0; }
.word .txt { flex: 1; min-width: 0; }
.word .en { font: 600 18px/1.3 var(--word); }
.word .ru { color: var(--muted); }
.word .ex { font-size: 13px; color: var(--muted); font-style: italic; }
.dot { flex: none; width: 10px; height: 34px; border-radius: 3px; background: var(--tab-color); }
.icon-btn {
  flex: none;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 17px;
  cursor: pointer;
}
.icon-btn:active { background: var(--rule); }
.word form { flex: 1; }
.empty { text-align: center; padding: 22px 10px; color: var(--muted); }

/* ---------- Испытание ---------- */

.progress { height: 4px; background: var(--edge); border-radius: 2px; overflow: hidden; margin: 2px 0 6px; }
.progress div { height: 100%; background: var(--pen); transition: width 0.2s; }
.prompt { font: 600 34px/1.2 var(--word); margin: 14px 0 2px; word-break: break-word; min-height: 41px; }
.prompt.ru { font-size: 28px; }
.example { font: italic 15px/1.4 var(--word); color: var(--muted); margin-top: 6px; }
.verdict { margin-top: 10px; font-size: 16px; min-height: 22px; }
.verdict.ok { color: var(--ok); }
.verdict.bad { color: var(--bad); }
.verdict b { font-family: var(--word); font-size: 19px; color: var(--ink); }
.swipe-hint { text-align: center; font-size: 13px; color: var(--muted); margin-top: 8px; }

.summary { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.summary div { background: var(--card); border-radius: 10px; box-shadow: var(--shadow); padding: 12px; }
.summary b { display: block; font: 700 30px/1.1 var(--word); }
.summary span { font-size: 13px; color: var(--muted); }

/* ---------- Вход ---------- */

.login { min-height: 70vh; display: flex; flex-direction: column; justify-content: center; }

/* ---------- Навигация ---------- */

.nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--edge);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 10;
}
.nav a {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 9px 0 10px;
  color: var(--muted);
  text-decoration: none;
  font-size: 12px;
}
.nav a svg { width: 22px; height: 22px; }
.nav a.active { color: var(--pen); font-weight: 700; }
.nav .badge {
  position: absolute;
  top: 4px;
  left: calc(50% + 6px);
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--red-line);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
}
.nav .badge:empty { display: none; }

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