:root {
  --bg: #0f1419;
  --surface: #1a222d;
  --surface2: #232d3b;
  --text: #e8edf4;
  --muted: #8b9cb3;
  --accent: #3d9cf5;
  --accent-dim: #2a6fad;
  --success: #3ecf8e;
  --warning: #f0b429;
  --danger: #e85d5d;
  --radius: 12px;
  --font: "DM Sans", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 120% 80% at 100% 0%, rgba(61, 156, 245, 0.12), transparent 50%),
    radial-gradient(ellipse 80% 60% at 0% 100%, rgba(62, 207, 142, 0.08), transparent 45%);
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: var(--bg);
  z-index: 100;
}

.skip-link:focus {
  left: 0;
}

code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: var(--surface2);
  padding: 0.15em 0.4em;
  border-radius: 6px;
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--surface2);
  background: rgba(15, 20, 25, 0.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.brand-mark {
  font-size: 1.75rem;
  color: var(--accent);
}

.brand h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.tagline {
  margin: 0.15rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.main-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.nav-btn {
  font-family: inherit;
  font-size: 0.875rem;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--surface2);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.nav-btn i {
  font-size: 1.15rem;
}

.nav-btn:hover {
  color: var(--text);
  border-color: var(--muted);
}

.nav-btn.active {
  color: var(--bg);
  background: var(--accent);
  border-color: var(--accent);
}

.nav-text-short {
  display: none;
}

.main {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.75rem 1.5rem 3rem;
}

.view[hidden] {
  display: none !important;
}

.view h2 {
  margin: 0 0 0.75rem;
  font-size: 1.5rem;
  font-weight: 700;
}

.lead {
  color: var(--muted);
  max-width: 65ch;
}

.lead strong {
  color: var(--text);
}

.muted {
  color: var(--muted);
  font-size: 0.95rem;
}

.home-actions {
  margin-top: 1.5rem;
}

.game-hud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 1rem;
}

.game-pill {
  background: var(--surface);
  border: 1px solid var(--surface2);
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  font-size: 0.82rem;
  color: var(--muted);
  display: inline-flex;
  gap: 0.45rem;
  align-items: center;
}

.game-pill strong {
  color: var(--text);
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}

.action-card {
  text-align: left;
  padding: 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--surface2);
  background: var(--surface);
  color: inherit;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s, transform 0.15s;
}

.action-card:hover {
  border-color: var(--accent-dim);
  transform: translateY(-2px);
}

.action-card strong {
  display: block;
  margin: 0.35rem 0 0.2rem;
  font-size: 1.05rem;
}

.action-card span:last-child {
  font-size: 0.85rem;
  color: var(--muted);
}

.action-icon {
  font-size: 1.75rem;
}

.unit-list {
  display: grid;
  gap: 0.75rem;
  margin-top: 1rem;
}

.unit-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.15rem;
  border-radius: var(--radius);
  border: 1px solid var(--surface2);
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  color: inherit;
  width: 100%;
  transition: border-color 0.15s;
}

.unit-card:hover {
  border-color: var(--accent-dim);
}

.unit-card-title {
  font-weight: 600;
}

.unit-card-meta {
  font-size: 0.85rem;
  color: var(--muted);
}

.unit-detail {
  margin-top: 1rem;
}

.back-unit {
  margin-bottom: 1rem;
}

.vocab-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.85rem;
  margin-top: 1rem;
}

.vocab-card {
  position: relative;
  padding: 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--surface2);
  background: var(--surface2);
  min-height: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.vocab-emoji {
  font-size: 2rem;
  line-height: 1;
  margin-bottom: 0.35rem;
}

.vocab-img {
  width: 72px;
  height: 72px;
  object-fit: contain;
  margin-bottom: 0.35rem;
  border-radius: 8px;
  background: var(--surface);
}

.vocab-es {
  font-weight: 600;
  font-size: 0.95rem;
}

.vocab-en {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--accent);
  margin-top: 0.25rem;
}

.vocab-note {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.35rem;
}

.pron-block {
  margin-top: 0.4rem;
  text-align: center;
  width: 100%;
  max-width: 280px;
}

.pron-line {
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--muted);
  margin-top: 0.25rem;
}

.pron-label {
  display: inline-block;
  margin-right: 0.35rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  opacity: 0.9;
}

.lemma-text {
  color: var(--text);
  font-weight: 600;
  font-family: var(--mono);
  font-size: 0.85rem;
}

.spell-detail {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--warning);
  margin-top: 0.15rem;
}

.ipa-text {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--accent);
}

.pronEs-text {
  font-style: italic;
  color: var(--text);
}

.btn-speak {
  margin-top: 0.5rem;
  font-family: inherit;
  font-size: 0.8rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--accent-dim);
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.btn-speak:hover {
  background: rgba(61, 156, 245, 0.15);
}

.quiz-feedback .btn-speak {
  margin-top: 0.75rem;
}

.btn {
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn-primary {
  background: var(--accent);
  color: var(--bg);
}

.btn-primary:hover {
  filter: brightness(1.08);
}

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border-color: var(--surface2);
}

.btn-secondary:hover {
  border-color: var(--muted);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
}

.btn-ghost:hover {
  color: var(--text);
}

.practice-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
  margin-top: 1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.field select {
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--surface2);
  background: var(--surface);
  color: var(--text);
  min-width: 200px;
}

.practice-area {
  margin-top: 1.5rem;
  padding: 1.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--surface2);
  background: var(--surface);
}

.practice-stats {
  display: flex;
  justify-content: space-between;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.score {
  color: var(--success);
  font-weight: 600;
}

.flashcard-panel {
  text-align: center;
}

.flashcard {
  width: 100%;
  max-width: 420px;
  margin: 0 auto 0.5rem;
  min-height: 200px;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  perspective: 1000px;
  display: block;
}

.flashcard-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
  border-radius: var(--radius);
  border: 2px solid var(--accent-dim);
  background: var(--surface2);
  min-height: 200px;
  transition: transform 0.35s ease, box-shadow 0.2s;
}

.flashcard:hover .flashcard-inner {
  box-shadow: 0 8px 32px rgba(61, 156, 245, 0.15);
}

.flashcard.is-flipped .flashcard-inner {
  transform: rotateY(0);
}

.flashcard-front,
.flashcard-back {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  width: 100%;
  max-width: 100%;
  font-size: 1.35rem;
  font-weight: 600;
}

.fc-media {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

.fc-media.fc-media--empty {
  display: none;
}

.fc-media-img {
  width: min(140px, 40vw);
  height: min(140px, 40vw);
  object-fit: contain;
  border-radius: 12px;
  background: var(--surface);
  pointer-events: none;
}

.fc-media-emoji {
  font-size: clamp(2.5rem, 12vw, 3.5rem);
  line-height: 1;
  pointer-events: none;
}

.flashcard-back {
  display: none;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 1.1rem;
}

.fc-front-extra,
.fc-back-extra {
  margin-top: 0.75rem;
  font-size: 0.85rem;
}

.flashcard.is-flipped .flashcard-front {
  display: none;
}

.flashcard.is-flipped .flashcard-back {
  display: block;
}

.fc-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin-top: 1rem;
}

.quiz-prompt {
  font-size: 1.2rem;
  font-weight: 600;
  margin: 0 0 1rem;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.quiz-opt {
  font-family: inherit;
  text-align: left;
  padding: 0.85rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--surface2);
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
}

.quiz-opt:hover:not(:disabled) {
  border-color: var(--accent-dim);
}

.quiz-opt.correct {
  border-color: var(--success);
  background: rgba(62, 207, 142, 0.15);
}

.quiz-opt.wrong {
  border-color: var(--danger);
  background: rgba(232, 93, 93, 0.12);
}

.quiz-opt:disabled {
  cursor: default;
}

.quiz-feedback {
  min-height: 1.5rem;
  margin-top: 1rem;
  font-weight: 600;
}

.cloze-input {
  width: 100%;
  margin-top: 0.4rem;
  border: 1px solid var(--surface2);
  border-radius: 8px;
  background: var(--surface2);
  color: var(--text);
  padding: 0.7rem 0.85rem;
  font-size: 1rem;
  font-family: inherit;
}

.conversation-wrap {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

.conv-lines {
  display: grid;
  gap: 0.6rem;
}

.conv-line {
  padding: 0.85rem 1rem;
  border: 1px solid var(--surface2);
  border-radius: 10px;
  background: var(--surface);
}

.conv-line strong {
  display: block;
  margin-bottom: 0.25rem;
}

.roleplay-box {
  border: 1px solid var(--surface2);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 1rem;
}

.roleplay-box h3 {
  margin: 0 0 0.45rem;
}

.progress-list {
  display: grid;
  gap: 0.5rem;
  margin: 1rem 0;
}

.progress-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.65rem 1rem;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--surface2);
  font-size: 0.9rem;
}

.progress-row-stack {
  flex-direction: column;
  align-items: stretch;
  gap: 0.35rem;
}

.progress-bar-wrap {
  flex: 1;
  max-width: 200px;
  height: 8px;
  background: var(--surface2);
  border-radius: 4px;
  overflow: hidden;
  margin-left: 1rem;
}

.progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.3s ease;
}

@media (max-width: 600px) {
  body {
    padding-bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px));
  }

  .site-header {
    flex-direction: column;
    align-items: stretch;
    padding-bottom: 0.5rem;
    border-bottom: none;
  }

  .brand {
    justify-content: center;
    text-align: center;
  }

  .main-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(15, 20, 25, 0.95);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--surface2);
    padding: 0.6rem 0.5rem calc(0.6rem + env(safe-area-inset-bottom, 0px));
    display: flex;
    flex-wrap: nowrap;
    justify-content: space-around;
    gap: 0.25rem;
    z-index: 100;
  }

  .nav-btn {
    flex-direction: column;
    gap: 0.35rem;
    padding: 0.5rem 0.25rem;
    border: none;
    border-radius: 8px;
    font-size: 0.7rem;
    font-weight: 500;
    flex: 1;
    text-align: center;
    background: transparent;
  }

  .nav-btn i {
    font-size: 1.45rem;
  }

  .nav-btn.active {
    background: transparent;
    color: var(--accent);
    border-color: transparent;
  }

  .nav-text-short {
    display: inline;
  }

  .nav-text-full {
    display: none;
  }

  html.theme-light .main-nav {
    background: rgba(255, 255, 255, 0.96);
    border-top-color: #dde3ea;
  }
}

/* —— Ajustes globales: foco, movimiento, tema claro, texto grande —— */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

:focus:not(:focus-visible) {
  outline: none;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .flashcard-inner,
  .progress-bar,
  .action-card {
    transition: none;
  }
}

html.theme-light {
  --bg: #eef1f6;
  --surface: #ffffff;
  --surface2: #e4e9f0;
  --text: #1a2230;
  --muted: #5a6b80;
  --accent: #1a7ee6;
  --accent-dim: #1560b3;
}

html.theme-light body {
  background-image:
    radial-gradient(ellipse 120% 80% at 100% 0%, rgba(26, 126, 230, 0.08), transparent 50%),
    radial-gradient(ellipse 80% 60% at 0% 100%, rgba(62, 207, 142, 0.06), transparent 45%);
}

html.font-large {
  font-size: 112.5%;
}

html.font-large .cloze-input,
html.font-large .search-input {
  font-size: 1.125rem;
  min-height: 48px;
}

.app-settings-bar {
  display: flex;
  justify-content: flex-end;
  gap: 0.35rem;
  padding: 0.35rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--surface2);
}

.btn-settings {
  font-size: 0.8rem !important;
  padding: 0.35rem 0.65rem !important;
}

.field-search {
  width: 100%;
  max-width: 100%;
  margin-top: 0.75rem;
}

.search-input {
  width: 100%;
  max-width: 520px;
  padding: 0.55rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--surface2);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
}

.search-results {
  margin-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-height: 280px;
  overflow-y: auto;
}

.search-hit {
  text-align: left;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--surface2);
  background: var(--surface2);
  color: inherit;
  font-family: inherit;
  cursor: pointer;
  font-size: 0.9rem;
}

.search-hit:hover {
  border-color: var(--accent-dim);
}

.search-hit-meta {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

.practice-session-bar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.75rem;
}

.practice-progress-wrap {
  margin: 0.75rem 0 1rem;
}

.progress-label {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.practice-progress-wrap progress {
  width: 100%;
  height: 10px;
  border-radius: 6px;
  overflow: hidden;
  accent-color: var(--accent);
}

.session-summary {
  margin: 1rem 0;
  padding: 1rem 1.15rem;
  border-radius: var(--radius);
  border: 1px solid var(--surface2);
  background: var(--surface);
  text-align: left;
}

.session-summary h3 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}

.session-summary ul {
  margin: 0.35rem 0 0;
  padding-left: 1.2rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.quiz-toolbar {
  margin-bottom: 0.75rem;
}

.quiz-hint {
  margin: 0.5rem 0 0;
  font-size: 0.9rem;
}

.progress-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin: 1rem 0;
  align-items: center;
}

.import-label {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}

.favorite-row {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  display: flex;
  gap: 0.25rem;
}

.btn-favorite {
  font-family: inherit;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0.2rem 0.35rem;
  border: none;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.2);
  color: var(--warning);
  cursor: pointer;
}

html.theme-light .btn-favorite {
  background: rgba(0, 0, 0, 0.06);
}

.btn-favorite.is-on {
  color: var(--warning);
}

.btn-favorite[aria-pressed="true"] {
  color: #ffd54a;
}
