:root {
  --bg: #f7f8fa;
  --card: #ffffff;
  --border: #e5e7eb;
  --text: #1f2430;
  --muted: #6b7280;
  --accent: #4f46e5;
  --accent-soft: #eef2ff;
  --danger: #dc2626;
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

.app-shell {
  max-width: 430px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 24px 20px 48px;
  display: flex;
  flex-direction: column;
}

/* Sticky top bar: pinned to the viewport top while scrolling. Bleeds over the
   shell's padding (negative margins) and re-adds it inside, so content slides
   underneath edge-to-edge within the 430px column. */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg);
  margin: -24px -20px 20px;
  padding: 16px 20px;
  /* FIXED height: the bar occupies this exact space from the very first paint,
     whether or not its contents have loaded — the menu must never push the page
     down when it appears. 40px controls + 16px padding top/bottom. */
  height: 72px;
  box-sizing: border-box;
}

.top-bar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 40px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.muted {
  color: var(--muted);
}

h1 {
  font-size: 22px;
  font-weight: 650;
  margin: 0 0 4px;
}

h2 {
  font-size: 17px;
  font-weight: 600;
  margin: 0 0 12px;
}

a {
  color: var(--accent);
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 14px 18px;
  font-size: 16px;
  font-weight: 550;
}

.btn-primary:disabled {
  opacity: 0.5;
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 18px;
  font-size: 15px;
  font-weight: 500;
}

.progress-track {
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.4s ease;
}

.chip {
  display: inline;
  padding: 1px 0;
  border-radius: 4px;
}

.chip-word {
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.chip-unknown {
  color: var(--danger);
  border-bottom: 2px solid var(--danger);
}

.chip-name {
  color: var(--muted);
  cursor: default;
}

/* Reading view (P1.4): a tapped word that was NOT studied yet — it's already
   waiting in the new-word queue, shown muted-dotted instead of danger-red. */
.chip-queued {
  color: var(--muted);
  border-bottom: 2px dotted var(--muted);
}

/* Reading view (P1.7): per-paragraph listen button + active highlight. */
.para-play {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin-right: 8px;
  border: none;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10px;
  line-height: 1;
  vertical-align: middle;
  flex-shrink: 0;
}

.para-active {
  background: var(--accent-soft);
  border-radius: 8px;
  padding: 4px 6px;
}

/* Reading view: gloss tooltip anchored under the tapped word. */
.read-tip {
  position: absolute;
  z-index: 20;
  background: var(--text);
  color: #fff;
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 14px;
  line-height: 1.4;
  max-width: 260px;
  box-shadow: 0 2px 8px rgba(31, 36, 48, 0.18);
  cursor: pointer;
}

/* Small inline secondary button (e.g. «читать» on a goal card) — the ghost
   look without the full-width block layout. */
.btn-mini {
  display: inline-flex;
  align-items: center;
  background: var(--card);
  color: var(--accent);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px 10px;
  font-size: 13px;
  font-weight: 500;
}

.phase-pill {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 13px;
  font-weight: 550;
}

.play-btn {
  width: 96px;
  height: 96px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  box-shadow: 0 4px 16px rgba(79, 70, 229, 0.25);
}

/* Prev/Next word navigation buttons (P1.0 indexed learn sequence). */
.nav-btn {
  width: 48px;
  height: 48px;
  border-radius: 999px;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

.nav-btn:disabled {
  color: var(--border);
  cursor: default;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.stat-row:last-child {
  border-bottom: none;
}

.stat-value {
  font-weight: 600;
}

.big-percent {
  font-size: 56px;
  font-weight: 700;
  line-height: 1;
}
