/* Цвета берём из темы Telegram (--tg-theme-*), запасные — на случай открытия без Telegram */
:root {
  --bg: var(--tg-theme-secondary-bg-color, #f1f1f4);
  --card: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #ffffff));
  --text: var(--tg-theme-text-color, #111114);
  --muted: var(--tg-theme-hint-color, #8a8a92);
  --accent: var(--tg-theme-button-color, #2f7cf6);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --line: color-mix(in srgb, var(--muted) 22%, transparent);
  --ok: #34c759;
  --warn: #ff9f0a;
  --bad: #ff453a;
  --radius: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; } /* иначе display: flex/grid у классов перебивает атрибут hidden */

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}

main { max-width: 560px; margin: 0 auto; padding: 8px 16px 16px; }
.tab { display: none; animation: fade .18s ease; }
.tab.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.head { display: flex; align-items: center; justify-content: space-between; margin: 12px 0 16px; gap: 12px; }
h1 { font-size: 28px; line-height: 1.1; margin: 2px 0 0; letter-spacing: -.02em; }
h2 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 22px 4px 8px; }
.eyebrow, .label { margin: 0; color: var(--muted); font-size: 13px; }
.big { margin: 2px 0 0; font-size: 17px; font-weight: 600; }

.card { background: var(--card); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; }
.text { white-space: pre-wrap; font-size: 14px; }
details summary { cursor: pointer; font-weight: 600; list-style: none; }
details[open] summary { margin-bottom: 10px; }

.list { list-style: none; margin: 0; padding: 0; background: var(--card); border-radius: var(--radius); overflow: hidden; }
.list:empty { display: none; }
.list li { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); min-height: 52px; }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { margin: 0; overflow-wrap: anywhere; }
.list .sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.time { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; min-width: 40px; }
.done-item .title { color: var(--muted); text-decoration: line-through; }
.empty { color: var(--muted); text-align: center; padding: 18px 8px; margin: 0; }

.ring {
  --p: 0;
  width: 56px; height: 56px; border-radius: 50%; flex: none;
  background: conic-gradient(var(--ok) calc(var(--p) * 1%), var(--line) 0);
  display: grid; place-items: center;
}
.ring span { width: 44px; height: 44px; border-radius: 50%; background: var(--bg); display: grid; place-items: center; font-size: 12px; font-weight: 600; }

.seg { display: flex; gap: 4px; flex: none; }
.seg button, .icon-btn {
  border: 0; background: var(--bg); color: var(--text); border-radius: 10px; width: 36px; height: 34px; font-size: 15px; cursor: pointer;
}
.seg button.on[data-s="done"] { background: color-mix(in srgb, var(--ok) 25%, var(--bg)); }
.seg button.on[data-s="partial"] { background: color-mix(in srgb, var(--warn) 25%, var(--bg)); }
.seg button.on[data-s="skipped"] { background: color-mix(in srgb, var(--bad) 22%, var(--bg)); }

.pill {
  border: 0; border-radius: 12px; padding: 10px 16px; background: var(--accent); color: var(--accent-text);
  font: inherit; font-weight: 600; cursor: pointer;
}
.pill.wide { width: 100%; }
.words-cta { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.flashcard {
  background: var(--card); border-radius: 22px; min-height: 220px; padding: 22px 20px; cursor: pointer;
  display: flex; flex-direction: column; justify-content: center; text-align: center; user-select: none;
  box-shadow: 0 1px 0 var(--line);
}
.front { font-size: 28px; font-weight: 700; margin: 10px 0; letter-spacing: -.01em; overflow-wrap: anywhere; }
.answer { font-size: 20px; margin: 4px 0; overflow-wrap: anywhere; }
.forms { color: var(--accent); font-weight: 600; margin: 2px 0 0; }
.forms:empty { display: none; }
.example { color: var(--muted); font-style: italic; margin: 6px 0 0; }
.native { color: var(--muted); font-size: 12px; margin: 6px 0 0; }
.native:empty { display: none; }
.hint { color: var(--muted); font-size: 13px; margin: 12px 0 0; }
.grades { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 10px; }
.grades button { border: 0; border-radius: 12px; padding: 12px 4px; font: inherit; font-weight: 600; color: #fff; cursor: pointer; }
.g-again { background: var(--bad); }
.g-hard { background: var(--warn); }
.g-good { background: var(--ok); }
.g-easy { background: var(--accent); color: var(--accent-text) !important; }

.add { display: grid; gap: 8px; }
input {
  width: 100%; border: 1px solid var(--line); background: var(--bg); color: var(--text);
  border-radius: 12px; padding: 11px 12px; font: inherit; outline: none;
}
input:focus { border-color: var(--accent); }
.search { margin-bottom: 10px; background: var(--card); }
.tag { font-size: 12px; color: var(--muted); white-space: nowrap; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--card); border-top: 1px solid var(--line); padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}
.tabs button {
  border: 0; background: none; color: var(--muted); font: inherit; font-size: 11px; display: flex; flex-direction: column;
  align-items: center; gap: 2px; padding: 4px 0; cursor: pointer;
}
.tabs .icon { font-size: 20px; filter: grayscale(1); opacity: .7; }
.tabs button.active { color: var(--accent); }
.tabs button.active .icon { filter: none; opacity: 1; }

.locked { position: fixed; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; background: var(--bg); color: var(--muted); }
