:root {
  --bg: #f4f7ff;
  --panel: #ffffff;
  --ink: #162238;
  --muted: #5c6b85;
  --primary: #0057ff;
  --accent: #ff5f1f;
  --success: #128a57;
  --danger: #d64045;
  --line: #dde4f3;
  --shadow: 0 14px 40px rgba(18, 34, 56, 0.1);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 5% 10%, #dbe8ff 0%, transparent 35%),
    radial-gradient(circle at 80% 12%, #ffe1d3 0%, transparent 35%),
    var(--bg);
}

a {
  color: inherit;
}

.container {
  width: min(1200px, 92vw);
  margin: 28px auto 120px;
}

.hero {
  display: grid;
  gap: 20px;
  grid-template-columns: 1fr auto;
  align-items: end;
  margin-bottom: 22px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary);
  font-size: 0.75rem;
  margin: 0 0 8px;
}

h1 {
  font-family: "Merriweather", "Times New Roman", serif;
  margin: 0;
  font-size: clamp(2rem, 3vw, 3rem);
}

.subtitle {
  margin: 12px 0 0;
  max-width: 68ch;
  color: var(--muted);
}

.hero-actions {
  display: flex;
  gap: 10px;
}

button,
.ghost {
  border: none;
  border-radius: 12px;
  padding: 10px 15px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
}

button {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 8px 22px rgba(0, 87, 255, 0.28);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(0, 87, 255, 0.24);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.ghost {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  background: #fff;
  text-decoration: none;
}

.panel {
  background: var(--panel);
  border-radius: 18px;
  border: 1px solid var(--line);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.stats article {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  background: linear-gradient(180deg, #fff 0%, #fbfdff 100%);
}

.stats h3 {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
}

.stats strong {
  display: block;
  margin-top: 8px;
  font-size: 1.6rem;
}

.stats p {
  margin: 7px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.filters {
  display: grid;
  gap: 14px;
}

.search-box {
  display: grid;
  gap: 8px;
}

.search-box span,
label span {
  font-size: 0.88rem;
  color: var(--muted);
}

input[type="search"],
input[type="text"] {
  width: 100%;
  border: 1px solid #c6d4f0;
  border-radius: 10px;
  font-size: 0.96rem;
  padding: 11px 12px;
  background: #fff;
}

input:focus {
  outline: 2px solid #bad1ff;
  border-color: #95b6ff;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  background: #eef3ff;
  color: #294785;
  box-shadow: none;
  border: 1px solid transparent;
}

.chip.active {
  background: var(--ink);
  color: #fff;
}

.tab-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.tab-nav > button {
  background: #fff;
  color: var(--ink);
  box-shadow: none;
  border: 1px solid var(--line);
}

.tab-nav > button.active {
  background: var(--primary);
  color: #fff;
  border-color: transparent;
}

.tab-nav .danger {
  background: #fff5f5;
  color: var(--danger);
  border-color: #ffd6d8;
  margin-left: auto;
}

.word-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.word-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  background: #fff;
  box-shadow: var(--shadow);
}

.word-card.learned {
  border-color: #afe7c6;
  background: #f1fff6;
}

.word-card header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.word-tag {
  background: color-mix(in oklab, var(--tag) 13%, #fff);
  color: #1f345f;
  font-size: 0.75rem;
  border-radius: 999px;
  padding: 4px 10px;
  border: 1px solid color-mix(in oklab, var(--tag) 40%, #fff);
}

.word-type {
  color: var(--muted);
  font-size: 0.78rem;
}

.word-card h3 {
  margin: 12px 0 4px;
  font-family: "Merriweather", serif;
  font-size: 1.35rem;
}

.ipa {
  margin: 0;
  color: #3e5d95;
  font-size: 0.85rem;
}

.meaning {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 8px 0;
}

.example,
.example-vi {
  color: var(--muted);
  margin: 4px 0;
  line-height: 1.5;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.actions > button {
  box-shadow: none;
  background: #eff4ff;
  color: #203a72;
  border: 1px solid #d5e1fa;
}

.actions > button:nth-child(1) {
  background: #e8f0ff;
}

.actions > button:nth-child(2) {
  background: #fff1ea;
  border-color: #ffd6c1;
  color: #8c3f1e;
}

.listen-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

input[type="range"] {
  width: 100%;
  margin: 8px 0 14px;
}

.prompt-box {
  background: #f9fbff;
  border: 1px dashed #b8c9eb;
  border-radius: 12px;
  padding: 14px;
  margin: 10px 0 14px;
}

.prompt-box .label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #4d6491;
  margin: 0;
}

.hint {
  margin-top: 10px;
  color: #6138ad;
}

.feedback {
  margin-top: 12px;
  border-radius: 10px;
  padding: 10px 12px;
}

.feedback.ok {
  background: #ecfff4;
  border: 1px solid #b6e7cb;
  color: #0e7c49;
}

.feedback.fail {
  background: #fff2f2;
  border: 1px solid #ffd0d0;
  color: #ac2c32;
}

.quiz-word {
  font-family: "Merriweather", serif;
  margin: 2px 0 14px;
  font-size: 1.8rem;
}

.quiz-options {
  display: grid;
  gap: 8px;
}

.quiz-option {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: none;
  text-align: left;
}

.quiz-option span {
  min-width: 28px;
  height: 28px;
  border-radius: 8px;
  display: inline-grid;
  place-items: center;
  background: #eaf0ff;
  color: #2c4f95;
  font-weight: 700;
}

.flashcards-panel {
  padding: 24px;
}

.flashcards-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
  margin-bottom: 18px;
}

.flashcards-head h2 {
  margin: 0 0 6px;
}

.flashcards-head p {
  margin: 0;
  color: var(--muted);
}

.flashcards-meta {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.flashcards-meta strong {
  font-size: 1.1rem;
}

.flashcard {
  position: relative;
  display: grid;
  min-height: 340px;
  width: 100%;
  padding: 0;
  border-radius: 24px;
  border: 1px solid #ced9f7;
  background: linear-gradient(140deg, #fefefe 0%, #f0f5ff 100%);
  box-shadow: 0 20px 40px rgba(22, 34, 56, 0.12);
  overflow: hidden;
}

.flashcard:hover {
  transform: translateY(-2px);
}

.flashcard-face {
  grid-area: 1 / 1;
  display: grid;
  align-content: center;
  gap: 12px;
  padding: 32px;
  transition: opacity 0.24s ease, transform 0.24s ease;
}

.flashcard-front {
  background:
    radial-gradient(circle at top right, rgba(0, 87, 255, 0.12), transparent 26%),
    linear-gradient(180deg, #ffffff 0%, #f4f8ff 100%);
}

.flashcard-back {
  opacity: 0;
  transform: rotateY(180deg) scale(0.98);
  background:
    radial-gradient(circle at top left, rgba(255, 95, 31, 0.14), transparent 28%),
    linear-gradient(180deg, #fffaf7 0%, #ffffff 100%);
}

.flashcard.is-flipped .flashcard-front {
  opacity: 0;
  transform: rotateY(-180deg) scale(0.98);
}

.flashcard.is-flipped .flashcard-back {
  opacity: 1;
  transform: rotateY(0) scale(1);
}

.flashcard small {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #4d6491;
  font-weight: 700;
}

.flashcard h3 {
  margin: 0;
  font-family: "Merriweather", serif;
  font-size: clamp(1.9rem, 4vw, 2.8rem);
}

.flashcard p,
.flashcard em {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.flashcard-toolbar,
.flashcard-rating {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.flashcard-toolbar > button,
.flashcard-rating > button {
  box-shadow: none;
}

.flashcard-toolbar > button {
  background: #eef4ff;
  color: #1f3970;
  border: 1px solid #d2def8;
}

.flashcard-rating > button[data-result="miss"] {
  background: #fff1f1;
  color: #9d2630;
  border: 1px solid #ffd2d4;
}

.flashcard-rating > button[data-result="hard"] {
  background: #fff8e8;
  color: #93651f;
  border: 1px solid #ffe1a5;
}

.flashcard-rating > button[data-result="know"] {
  background: #ecfff4;
  color: #0f7a48;
  border: 1px solid #b8e8cd;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(18px);
  border-radius: 10px;
  padding: 10px 14px;
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s ease;
  font-weight: 700;
  z-index: 1000;
}

.toast[data-type="success"] {
  background: var(--success);
}

.toast[data-type="error"] {
  background: var(--danger);
}

.toast[data-type="info"] {
  background: #1f4fc0;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 960px) {
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .hero {
    grid-template-columns: 1fr;
  }

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

  .stats {
    grid-template-columns: 1fr;
  }

  .flashcards-head {
    grid-template-columns: 1fr;
    display: grid;
  }

  .flashcards-meta {
    justify-items: start;
  }

  .tab-nav .danger {
    margin-left: 0;
  }

  button,
  .ghost {
    width: 100%;
    justify-content: center;
  }

  .actions > button,
  .tab-nav > button,
  .chip,
  .flashcard-toolbar > button,
  .flashcard-rating > button {
    width: auto;
  }
}
