:root {
  --bg: #08080c;
  --surface: rgba(18, 18, 24, 0.78);
  --border: rgba(255, 255, 255, 0.08);
  --text: #f4f4f5;
  --muted: #a1a1aa;
  --faint: rgba(255, 255, 255, 0.35);
  --accent: #a78bfa;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
  padding: 20px 28px;
  padding-top: max(20px, env(safe-area-inset-top));
  background: rgba(8, 8, 12, 0.9);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.topbar-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-left: auto;
  flex: 1 1 220px;
  min-width: 0;
}

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

.topbar-search {
  flex: 1 1 160px;
  min-width: 0;
  max-width: 260px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.85rem;
}

.back-link:hover { color: var(--text); text-decoration: none; }

.theme-title h1 {
  font-family: "Noto Sans Georgian", Inter, sans-serif;
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.theme-title p {
  margin-top: 4px;
  font-size: 0.85rem;
  color: var(--muted);
}

.search {
  width: min(260px, 40vw);
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: max(16px, 0.875rem);
  outline: none;
  -webkit-appearance: none;
}

.search:focus {
  border-color: rgba(167, 139, 250, 0.45);
  box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.12);
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 28px 28px 80px;
}

.meta-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 24px;
  font-size: 0.8rem;
  color: var(--muted);
}

.word-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.word-card {
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.02);
}

.word-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.word-ka {
  font-family: "Noto Sans Georgian", sans-serif;
  font-size: 1.6rem;
  font-weight: 600;
  line-height: 1.15;
}

.word-sub {
  margin-top: 6px;
  font-size: 0.85rem;
  color: var(--muted);
}

.play-btn {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
}

.play-btn:hover {
  background: rgba(167, 139, 250, 0.12);
  border-color: rgba(167, 139, 250, 0.35);
}

.play-btn.playing {
  background: rgba(167, 139, 250, 0.2);
  border-color: var(--accent);
}

.play-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.word-en {
  margin-top: 12px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.88);
}

.word-glosses {
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.45;
}

details {
  margin-top: 12px;
  font-size: 0.82rem;
  color: var(--muted);
}

details summary {
  cursor: pointer;
  color: var(--faint);
  user-select: none;
}

.example {
  margin-top: 8px;
  padding-left: 12px;
  border-left: 2px solid rgba(167, 139, 250, 0.25);
}

.example .ka {
  font-family: "Noto Sans Georgian", sans-serif;
  color: var(--text);
}

.example .en {
  margin-top: 2px;
  font-size: 0.8rem;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 0;
}

.verbs-page main {
  max-width: 860px;
}

.conj-details summary {
  color: var(--accent);
}

.conj-wrap {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.conj-group {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.conj-tense {
  padding: 8px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--border);
}

.conj-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  background: var(--border);
}

.conj-cell {
  padding: 10px 12px;
  background: rgba(8, 8, 12, 0.6);
}

.conj-label {
  font-size: 0.7rem;
  color: var(--faint);
  margin-bottom: 4px;
}

.conj-ka {
  font-family: "Noto Sans Georgian", sans-serif;
  font-size: 1rem;
  line-height: 1.2;
}

.conj-roman {
  margin-top: 3px;
  font-size: 0.75rem;
  color: var(--muted);
}

.conj-empty {
  font-size: 0.82rem;
  color: var(--muted);
  padding: 8px 0;
}

@media (max-width: 640px) {
  .topbar {
    padding: 14px 16px;
    padding-top: max(14px, env(safe-area-inset-top));
    align-items: flex-start;
  }

  .theme-title {
    flex: 1 1 auto;
    min-width: 0;
  }

  .theme-title h1 { font-size: 1.25rem; }
  .theme-title p { font-size: 0.8rem; }

  .topbar-tools {
    flex: 1 1 100%;
    width: 100%;
    margin-left: 0;
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .topbar-search,
  .search {
    width: 100%;
    max-width: none;
    flex: none;
  }

  main {
    padding: 16px 16px max(48px, env(safe-area-inset-bottom));
  }

  .meta-row {
    gap: 8px;
    font-size: 0.75rem;
  }

  .word-card { padding: 16px; }

  .word-head {
    flex-wrap: wrap;
  }

  .word-head > div:first-child {
    flex: 1 1 calc(100% - 130px);
    min-width: 0;
  }

  .word-actions {
    gap: 6px;
    margin-left: auto;
  }

  .word-ka { font-size: 1.4rem; }

  .flag-btn,
  .know-btn,
  .play-btn {
    width: 38px;
    height: 38px;
  }

  .review-page .topbar {
    flex-wrap: wrap;
  }

  .review-page .theme-title {
    order: 2;
    flex: 1 1 calc(100% - 80px);
  }

  .review-page .review-badge {
    order: 3;
    width: 100%;
    text-align: center;
  }

  .review-ka { font-size: 2rem; }

  .review-card { padding: 24px 18px; }

  .quiz-panel {
    padding: 20px 16px;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
  }

  .quiz-modes {
    flex-direction: column;
  }

  .quiz-mode-btn {
    text-align: center;
  }

  .quiz-prompt.ka { font-size: 1.65rem; }

  .quiz-actions {
    flex-wrap: wrap;
  }

  .quiz-actions .action-btn {
    flex: 1 1 calc(50% - 4px);
    min-width: 0;
  }

  .conj-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.word-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.flag-btn,
.know-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.flag-btn:hover,
.know-btn:hover {
  background: rgba(167, 139, 250, 0.12);
  border-color: rgba(167, 139, 250, 0.35);
}

.flag-btn.active {
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.45);
  background: rgba(251, 191, 36, 0.1);
}

.know-btn.active {
  color: #4ade80;
  border-color: rgba(74, 222, 128, 0.45);
  background: rgba(74, 222, 128, 0.1);
}

.word-card.known {
  border-color: rgba(74, 222, 128, 0.2);
}

.word-card.flagged {
  border-color: rgba(251, 191, 36, 0.2);
}

.review-page main {
  max-width: 560px;
}

.review-badge {
  font-size: 0.8rem;
  color: var(--muted);
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}

.empty-state .hint {
  margin-top: 8px;
  font-size: 0.85rem;
}

.review-card {
  padding: 32px 28px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.02);
  text-align: center;
}

.review-theme {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.review-ka {
  margin-top: 16px;
  font-family: "Noto Sans Georgian", sans-serif;
  font-size: 2.4rem;
  font-weight: 600;
  line-height: 1.15;
}

.review-sub {
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--muted);
}

.review-play {
  margin: 20px auto 0;
}

.review-en {
  margin-top: 20px;
  font-size: 1.1rem;
  line-height: 1.5;
}

.reveal-btn {
  margin-top: 16px;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.review-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 20px;
}

.action-btn {
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.action-btn.accent {
  border-color: rgba(74, 222, 128, 0.35);
  color: #4ade80;
}

.review-progress {
  margin-top: 16px;
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
}

.theme-menu a .progress {
  color: var(--accent);
  font-size: 0.7rem;
}

.quiz-open-btn {
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid rgba(167, 139, 250, 0.35);
  background: rgba(167, 139, 250, 0.1);
  color: var(--accent);
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}

.quiz-open-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.quiz-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(4, 4, 8, 0.82);
  backdrop-filter: blur(8px);
}

.quiz-overlay.open {
  display: flex;
}

.quiz-panel {
  width: min(480px, 100%);
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(14, 14, 18, 0.96);
}

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

.quiz-head h2 {
  font-size: 1rem;
  font-weight: 600;
}

.quiz-close {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.2rem;
  cursor: pointer;
}

.quiz-modes {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.quiz-mode-btn {
  flex: 1;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}

.quiz-mode-btn.active {
  color: var(--text);
  border-color: rgba(167, 139, 250, 0.45);
  background: rgba(167, 139, 250, 0.12);
}

.quiz-progress {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 12px;
}

.quiz-prompt {
  font-size: 1.2rem;
  line-height: 1.4;
  min-height: 2.8rem;
}

.quiz-prompt.ka {
  font-family: "Noto Sans Georgian", sans-serif;
  font-size: 2rem;
  font-weight: 600;
}

.quiz-sub {
  margin-top: 6px;
  font-size: 0.82rem;
  color: var(--muted);
}

.quiz-input {
  width: 100%;
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  outline: none;
}

.quiz-input:focus {
  border-color: rgba(167, 139, 250, 0.45);
}

.quiz-feedback {
  margin-top: 12px;
  min-height: 1.2rem;
  font-size: 0.88rem;
}

.quiz-feedback.ok { color: #4ade80; }
.quiz-feedback.miss { color: #fbbf24; }

.quiz-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.quiz-score {
  font-size: 2.4rem;
  font-weight: 600;
  text-align: center;
}

.quiz-score-label {
  text-align: center;
  color: var(--muted);
  margin: 8px 0 20px;
}

.core-progress {
  margin-top: 10px;
  max-width: 220px;
}

.core-progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 5px;
}

.core-progress-bar {
  height: 5px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.core-progress-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #a78bfa, #4ade80);
  transition: width 0.3s ease;
}
