/* ==========================================================================
   English Trainer — "Ink & Ember" design system
   Display: Unbounded · Body: Golos Text · Data/mono: JetBrains Mono
   ========================================================================== */

:root {
  color-scheme: light dark;

  --font-display: "Unbounded", system-ui, sans-serif;
  --font-body: "Golos Text", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  /* surfaces */
  --surface-0: #0e0f1a; /* page ground */
  --surface-1: #171929; /* card */
  --surface-2: #20233a; /* elevated / inputs */
  --border-1: #2b2e47;
  --border-2: #3d4066;
  --text: #ece9f7;
  --muted: #9599b8;

  /* accents */
  --ember: #dd9a4b;
  --ember-strong: #f2ac5c;
  --on-ember: #241505;
  --tide: #4ea9a2;
  --sage: #6cb489;
  --clay: #e2836a;

  --shadow-hsl: 222deg 65% 3%;
  --shadow-1: 0 1px 2px hsl(var(--shadow-hsl) / 0.5);
  --shadow-2: 0 10px 28px hsl(var(--shadow-hsl) / 0.38);
  --shadow-3: 0 24px 56px hsl(var(--shadow-hsl) / 0.45);

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-full: 999px;
}

@media (prefers-color-scheme: light) {
  :root {
    --surface-0: #f1f3ee;
    --surface-1: #ffffff;
    --surface-2: #f7f8f4;
    --border-1: #dde0d6;
    --border-2: #c9cdbe;
    --text: #20241c;
    --muted: #656b5c;

    --ember: #c17a2e;
    --ember-strong: #a8681f;
    --tide: #2c7d76;
    --sage: #3c8a5f;
    --clay: #b0503a;

    --shadow-hsl: 100deg 15% 55%;
    --shadow-1: 0 1px 2px hsl(var(--shadow-hsl) / 0.25);
    --shadow-2: 0 10px 28px hsl(var(--shadow-hsl) / 0.22);
    --shadow-3: 0 24px 56px hsl(var(--shadow-hsl) / 0.28);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--surface-0);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.3s ease, color 0.3s ease;
}

h1, h2, h3 { font-family: var(--font-display); margin: 0; text-wrap: balance; }
h1 { font-weight: 700; }
h2 { font-weight: 600; font-size: 1.05rem; letter-spacing: -0.01em; }
h3 {
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 12px;
}

.hidden { display: none !important; }
.screen { min-height: 100vh; }

.muted { color: var(--muted); margin-top: 0; }
.muted.small, .small { font-size: 0.85rem; }

::selection { background: var(--ember); color: var(--on-ember); }

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

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---------- Motion library ---------- */

@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes ringPulse {
  0% { transform: scale(1); opacity: 0.5; }
  100% { transform: scale(1.4); opacity: 0; }
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(220%); }
}

.tab-panel.active {
  animation: fadeSlideUp 0.4s cubic-bezier(0.16, 0.84, 0.44, 1) both;
}

/* ---------- Base controls ---------- */

input {
  background: var(--surface-2);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  width: 100%;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus {
  outline: none;
  border-color: var(--ember);
  box-shadow: 0 0 0 3px hsl(var(--shadow-hsl) / 0.12);
}

button {
  border: none;
  border-radius: var(--radius-sm);
  padding: 13px 18px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  background: var(--ember);
  color: var(--on-ember);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background-color 0.2s ease, opacity 0.2s ease;
}

button:hover { box-shadow: var(--shadow-1); }
button:active { transform: scale(0.97); }

.error { color: var(--clay); min-height: 1.2em; margin: 6px 0 0; font-size: 0.87rem; }

/* ==========================================================================
   Login
   ========================================================================== */

#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    radial-gradient(60% 50% at 50% -10%, hsl(var(--shadow-hsl) / 0), transparent),
    var(--surface-0);
}

.card {
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-lg);
  padding: 36px 28px 28px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-3);
  text-align: center;
}

.brand-mark {
  width: 52px;
  height: 52px;
  margin: 0 auto 18px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--on-ember);
  background: linear-gradient(135deg, var(--ember-strong), var(--tide));
  box-shadow: var(--shadow-2);
}

.wordmark { font-size: 1.35rem; margin-bottom: 6px; }
.accent-word { color: var(--ember); }

.card .muted { margin-bottom: 4px; }

#login-form { display: flex; flex-direction: column; gap: 12px; margin-top: 22px; text-align: left; }
#login-form button { margin-top: 4px; }

/* ==========================================================================
   Profile picker
   ========================================================================== */

#profile-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
}

.eyebrow {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--tide);
  margin-bottom: 10px;
}

.profile-picker h1 { font-size: 1.6rem; margin: 0 0 32px; }

.profile-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 24px 20px;
  justify-content: center;
  max-width: 520px;
}

.profile-tile {
  background: none;
  border: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 104px;
  animation: fadeSlideUp 0.5s cubic-bezier(0.16, 0.84, 0.44, 1) both;
  animation-delay: calc(var(--i, 0) * 70ms);
}

.profile-avatar-btn {
  background: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
  transition: transform 0.2s ease;
}

.profile-avatar-btn:hover { transform: translateY(-3px); }
.profile-avatar-btn:active { transform: scale(0.96); }

.profile-avatar {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: linear-gradient(150deg, var(--ember), var(--tide));
  color: var(--on-ember);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  box-shadow: var(--shadow-2);
  border: 3px solid var(--surface-1);
  outline: 2px solid var(--border-1);
  transition: outline-color 0.2s ease, box-shadow 0.2s ease;
}

.profile-avatar-btn:hover .profile-avatar { outline-color: var(--ember); }

.profile-avatar-add {
  background: var(--surface-1);
  border: 2px dashed var(--border-2);
  color: var(--muted);
  font-size: 1.8rem;
  font-weight: 400;
  outline: none;
  box-shadow: none;
}

.profile-tile-add:hover .profile-avatar-add { border-color: var(--ember); color: var(--ember); }

.profile-name { font-size: 0.9rem; font-weight: 600; }

.profile-tile-actions { display: flex; gap: 6px; }

.profile-tile-actions button {
  background: transparent;
  border: 1px solid var(--border-2);
  color: var(--muted);
  padding: 4px 9px;
  font-size: 0.78rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
}

.profile-tile-actions button:hover { color: var(--text); border-color: var(--muted); }

.profile-tile-add { cursor: pointer; }

/* ==========================================================================
   App shell
   ========================================================================== */

.topbar {
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.topbar .wordmark { font-size: 1.05rem; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-dictionary-btn {
  display: none;
  flex-direction: row;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-2);
  font-size: 0.82rem;
}

.topbar-dictionary-btn.active { color: var(--ember); border-color: var(--ember); }

.profile-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
}

.profile-badge-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(150deg, var(--ember), var(--tide));
  color: var(--on-ember);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
}

.profile-badge #active-profile-name { font-weight: 700; }

.profile-badge button {
  background: transparent;
  border: 1px solid var(--border-2);
  color: var(--muted);
  padding: 7px 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.profile-badge button:hover { color: var(--text); border-color: var(--muted); }

.app-grid {
  display: block;
  max-width: 640px;
  margin: 0 auto;
  padding: 0 16px;
}

.col { min-width: 0; }

.tab-panel { display: none; padding-bottom: 16px; }
.tab-panel.active { display: block; }

#app-screen { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }

/* ---------- Bottom nav (mobile) + left toggle (desktop) ---------- */

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  background: hsl(var(--shadow-hsl) / 0.02);
  background: var(--surface-1);
  border-top: 1px solid var(--border-1);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  z-index: 10;
  box-shadow: 0 -8px 24px hsl(var(--shadow-hsl) / 0.18);
}

.nav-btn {
  border: none;
  background: none;
  cursor: pointer;
  color: var(--muted);
  font-family: var(--font-body);
  font-weight: 600;
  transition: color 0.2s ease, background-color 0.2s ease, transform 0.15s ease;
}

.nav-icon { width: 20px; height: 20px; flex-shrink: 0; }

.bottom-nav .nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 4px 7px;
  border-radius: 14px;
  font-size: 0.66rem;
}

.bottom-nav .nav-btn:active { transform: scale(0.94); }
.nav-btn.active { color: var(--ember); background: hsl(var(--shadow-hsl) / 0.06); }

/* ==========================================================================
   Practice tab
   ========================================================================== */

.topic-card {
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-top: 14px;
  box-shadow: var(--shadow-1);
}

.topic-day {
  color: var(--tide);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

.topic-card h2 { margin: 0 0 8px; font-size: 1.3rem; }
.topic-card p { margin: 3px 0; }

.topic-vocab { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }

.vocab-chip {
  background: hsl(var(--shadow-hsl) / 0.05);
  border: 1px solid var(--border-1);
  color: var(--ember);
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 600;
}

.prompts { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }

.prompt-chip {
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  color: var(--muted);
  padding: 9px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  transition: color 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}

.prompt-chip:hover { border-color: var(--border-2); color: var(--text); }
.prompt-chip.active { color: var(--on-ember); border-color: var(--ember); background: var(--ember); }

.status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
  margin-bottom: 12px;
  font-size: 0.9rem;
  font-weight: 500;
}

.status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-2);
  transition: background-color 0.3s ease;
}

#tab-practice:has(.mic-btn.active) .status::before {
  background: var(--clay);
  box-shadow: 0 0 0 4px hsl(var(--shadow-hsl) / 0.12);
}

.transcript {
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-md);
  padding: 16px;
  min-height: 35vh;
  max-height: 45vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-1);
}

.msg {
  max-width: 85%;
  padding: 9px 13px;
  border-radius: 14px;
  line-height: 1.4;
  font-size: 0.94rem;
  animation: fadeSlideUp 0.3s ease both;
}

.msg.user { align-self: flex-end; background: var(--ember); color: var(--on-ember); border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--border-1); border-bottom-left-radius: 4px; }

.controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 20px;
}

.wave-canvas {
  display: block;
  width: 100%;
  max-width: 340px;
  height: 56px;
  margin-bottom: 8px;
}

.mic-btn {
  position: relative;
  width: 100%;
  max-width: 340px;
  padding: 19px;
  border-radius: var(--radius-full);
  font-size: 1.02rem;
  box-shadow: var(--shadow-2);
}

.mic-btn::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 2px solid var(--clay);
  opacity: 0;
  pointer-events: none;
}

.mic-btn.active {
  background: var(--clay);
  color: var(--on-ember);
}

.mic-btn.active::after {
  opacity: 0.7;
  animation: ringPulse 1.6s ease-out infinite;
}

/* ==========================================================================
   Analysis tab
   ========================================================================== */

.ring-stat {
  position: relative;
  width: 168px;
  height: 168px;
  margin: 8px auto 18px;
}

.ring-svg { width: 100%; height: 100%; transform: rotate(-90deg); }

.ring-track {
  fill: none;
  stroke: var(--surface-2);
  stroke-width: 10;
}

.ring-progress {
  fill: none;
  stroke: var(--ember);
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.8s cubic-bezier(0.16, 0.84, 0.44, 1);
}

.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.ring-value {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.ring-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.meter-block { margin: 16px 0; }

.meter-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 7px;
}

.meter-label span:last-child {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.bar-track {
  background: var(--surface-2);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-full);
  height: 10px;
  overflow: hidden;
}

.bar-fill {
  position: relative;
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.6s cubic-bezier(0.16, 0.84, 0.44, 1);
  overflow: hidden;
}

.bar-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 40%;
  background: linear-gradient(90deg, transparent, hsl(0deg 0% 100% / 0.35), transparent);
  animation: shimmer 2.6s ease-in-out infinite;
}

.bar-fill.cefr { background: var(--ember); }
.bar-fill.confidence { background: var(--tide); }
.bar-fill.simple { background: var(--muted); }
.bar-fill.compound { background: var(--ember); }
.bar-fill.complex { background: var(--sage); }

.complexity-chart { display: flex; flex-direction: column; gap: 11px; margin: 14px 0 20px; }

.complexity-row { display: grid; grid-template-columns: 84px 1fr 40px; align-items: center; gap: 10px; }
.complexity-label { font-size: 0.83rem; font-weight: 600; color: var(--muted); }
.complexity-pct { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 0.83rem; text-align: right; }

.corrections-list, .vocab-upgrades-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }

.correction-card, .vocab-card {
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  animation: fadeSlideUp 0.4s cubic-bezier(0.16, 0.84, 0.44, 1) both;
  animation-delay: calc(var(--i, 0) * 90ms);
}

.correction-card .said { color: var(--clay); text-decoration: line-through; font-size: 0.9rem; }
.correction-card .arrow { color: var(--muted); margin: 3px 0; font-size: 0.85rem; }
.correction-card .correct { color: var(--sage); font-weight: 700; }
.correction-card .explanation { color: var(--muted); font-size: 0.85rem; margin-top: 6px; }

.vocab-card .row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.vocab-card .original { color: var(--muted); text-decoration: line-through; }
.vocab-card .upgrade { color: var(--ember); font-weight: 700; font-family: var(--font-display); font-size: 0.95rem; }
.vocab-card .example { color: var(--muted); font-style: italic; font-size: 0.86rem; margin-top: 6px; }
.vocab-card .add-to-dict-btn {
  margin-top: 10px;
  padding: 7px 13px;
  font-size: 0.8rem;
  background: transparent;
  border: 1px solid var(--ember);
  color: var(--ember);
}
.vocab-card .add-to-dict-btn:hover { background: var(--ember); color: var(--on-ember); }

/* ==========================================================================
   History tab
   ========================================================================== */

.history-section { margin-bottom: 24px; }

.session-history-list, .glossary-list { display: flex; flex-direction: column; gap: 8px; }

.session-card {
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-md);
  padding: 12px 15px;
}

.session-card .row { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; }
.session-card .session-date { color: var(--muted); font-weight: 500; font-size: 0.78rem; font-family: var(--font-mono); }
.session-card .session-stats { color: var(--muted); font-size: 0.8rem; margin-top: 5px; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.glossary-item {
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-sm);
  padding: 9px 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
}

.glossary-item .original { color: var(--muted); text-decoration: line-through; }
.glossary-item .upgrade { color: var(--ember); font-weight: 700; }

.danger-btn {
  width: 100%;
  background: transparent;
  border: 1px solid var(--clay);
  color: var(--clay);
  margin-top: 10px;
}

.danger-btn:hover { background: var(--clay); color: var(--on-ember); }

.word-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  padding: 18px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}

.word-form-simple { flex-direction: row; flex-wrap: wrap; align-items: center; }
.word-form-simple #word-input { flex: 1; min-width: 180px; }
.word-form-simple button { flex-shrink: 0; }
.word-form-hint {
  flex-basis: 100%;
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.word-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }

.word-item {
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-md);
  padding: 13px 15px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.word-item:hover { border-color: var(--border-2); }
.word-item.learned { border-color: hsl(var(--shadow-hsl) / 0.1); background: var(--surface-1); }

.learned-toggle {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  margin-top: 2px;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  border: 2px solid var(--border-2);
  color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.learned-toggle svg { width: 14px; height: 14px; }
.learned-toggle:hover { border-color: var(--sage); }
.word-item.learned .learned-toggle { background: var(--sage); border-color: var(--sage); color: var(--on-ember); }

.word-item-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }

.word-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.word-item .word { font-weight: 700; font-size: 1.05rem; font-family: var(--font-display); }
.word-item.learned .word { color: var(--sage); }
.word-item .translation { color: var(--muted); }
.word-item .example { color: var(--muted); font-style: italic; font-size: 0.9rem; }

.delete-icon-btn {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  margin-top: 1px;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

.delete-icon-btn svg { width: 15px; height: 15px; }
.delete-icon-btn:hover { color: var(--clay); background: hsl(var(--shadow-hsl) / 0.06); }

/* ---------- Pronounce buttons (Web Speech API) ---------- */

.pronounce-btn {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--border-2);
  color: var(--tide);
  display: flex;
  align-items: center;
  justify-content: center;
}

.pronounce-btn svg { width: 15px; height: 15px; }
.pronounce-btn:hover { background: var(--tide); color: var(--on-ember); border-color: var(--tide); }

.pronounce-btn-sm { width: 26px; height: 26px; }
.pronounce-btn-sm svg { width: 12px; height: 12px; }

.transcription {
  color: var(--tide);
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

/* ==========================================================================
   Dictionary tab (Словарь — full page)
   ========================================================================== */

.dictionary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.dictionary-stats {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}

.stat-tile {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-md);
  padding: 12px 8px;
}

.stat-num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 1.4rem;
  font-weight: 700;
}

.stat-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.dictionary-filters {
  display: flex;
  gap: 6px;
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  padding: 4px;
  border-radius: var(--radius-sm);
  margin: 14px 0 16px;
}

.filter-chip {
  flex: 1;
  background: transparent;
  color: var(--muted);
  padding: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: 8px;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.filter-chip.active { background: var(--ember); color: var(--on-ember); }

.ai-section h3 {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-section-icon { width: 14px; height: 14px; color: var(--tide); }

.icon-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--border-2);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover { color: var(--text); border-color: var(--muted); }

.dictionary-search {
  margin: 14px 0;
}

/* ---------- Word detail modal ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: hsl(var(--shadow-hsl) / 0.55);
  backdrop-filter: blur(3px);
  animation: fadeSlideUp 0.2s ease both;
}

.modal-card {
  position: relative;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 28px 24px calc(24px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow-3);
}

.modal-close { position: absolute; top: 16px; right: 16px; }

.word-detail-word { font-size: 1.6rem; margin-right: 40px; }

.word-detail-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 18px;
  min-height: 32px;
}

.word-detail-transcription { color: var(--tide); font-family: var(--font-mono); font-size: 1rem; }

.word-detail-translation { font-size: 1.05rem; margin: 0 0 8px; }
.word-detail-example { color: var(--muted); font-style: italic; margin: 0 0 20px; }

.word-detail-actions { display: flex; flex-direction: column; gap: 10px; }

#word-detail-learned-btn {
  background: transparent;
  border: 1px solid var(--sage);
  color: var(--sage);
}

#word-detail-learned-btn.learned-active { background: var(--sage); color: var(--on-ember); }

@media (min-width: 768px) {
  .modal-overlay { align-items: center; }
  .modal-card { border-radius: var(--radius-lg); padding: 28px; }
}

/* ==========================================================================
   Plan tab
   ========================================================================== */

.roadmap-list { display: flex; flex-direction: column; gap: 8px; }

.roadmap-day {
  position: relative;
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  text-align: left;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 13px;
  color: var(--text);
  font-family: var(--font-body);
  font-weight: 400;
  transition: border-color 0.2s ease, transform 0.15s ease;
}

.roadmap-day:hover { border-color: var(--border-2); }
.roadmap-day:active { transform: scale(0.99); }

.day-icon-wrap {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease, background-color 0.2s ease;
}

.day-icon { width: 19px; height: 19px; }

.day-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.roadmap-day .day-num {
  color: var(--muted);
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.roadmap-day .day-topic { font-weight: 700; font-family: var(--font-display); font-size: 0.98rem; margin-top: 1px; }
.roadmap-day .day-grammar { color: var(--muted); font-size: 0.8rem; }

.roadmap-day.current { border-color: var(--ember); box-shadow: 0 0 0 1px var(--ember); }
.roadmap-day.current .day-num { color: var(--ember); }
.roadmap-day.current .day-icon-wrap { color: var(--ember); background: hsl(var(--shadow-hsl) / 0.1); }
.roadmap-day.done .day-num { color: var(--sage); }
.roadmap-day.done .day-icon-wrap { color: var(--sage); }
.roadmap-day.done { padding-right: 36px; }

.roadmap-day .day-check {
  position: absolute;
  top: 50%;
  right: 14px;
  transform: translateY(-50%);
  color: var(--sage);
  font-weight: 700;
}

/* ==========================================================================
   Desktop layout
   ========================================================================== */

@media (min-width: 768px) {
  .topbar { padding: 20px 28px; }

  .app-grid {
    display: grid;
    grid-template-columns: 288px 1fr 344px;
    gap: 22px;
    max-width: 1240px;
    padding: 0 28px 28px;
    align-items: start;
  }

  #app-screen { padding-bottom: 24px; }

  .col-left, .col-center, .col-right { background: transparent; }

  .bottom-nav { display: none; }

  .topbar-dictionary-btn { display: flex; }

  #app-screen.dictionary-open .app-grid {
    display: block;
    max-width: 780px;
  }

  .transcript { min-height: 40vh; max-height: 50vh; }

  .card:hover { box-shadow: var(--shadow-3); }

  .roadmap-day:hover { transform: translateX(2px); }
}

@media (max-width: 380px) {
  .profile-grid { gap: 18px 14px; }
  .profile-tile { width: 88px; }
  .profile-avatar { width: 64px; height: 64px; }
}
