@font-face {
  font-family: 'Bricolage Grotesque';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/spanish/fonts/bricolage-grotesque-600.woff2') format('woff2');
}
@font-face {
  font-family: 'Bricolage Grotesque';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/spanish/fonts/bricolage-grotesque-700.woff2') format('woff2');
}
@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/spanish/fonts/plus-jakarta-sans-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/spanish/fonts/plus-jakarta-sans-500.woff2') format('woff2');
}
@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/spanish/fonts/plus-jakarta-sans-600.woff2') format('woff2');
}
@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/spanish/fonts/plus-jakarta-sans-700.woff2') format('woff2');
}

:root {
  --ground: #f6f8f7;
  --surface: #ffffff;
  --ink: #16202a;
  --muted: #50606e;
  --line: #d4dde0;
  --rojo: #b8293d;
  --rojo-deep: #8f1d2e;
  --rojo-soft: #fae8eb;
  --sol: #f4c430;
  --sol-hover: #e4b41e;
  --sol-surface: #fff4cc;
  --sol-ink: #4a3500;
  --olive: #1b7a58;
  --olive-soft: #e4f4ed;
  --radius-card: 18px;
  --radius-control: 10px;
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--ink);
  background: var(--ground);
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

button,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: default;
  opacity: 0.42;
}

button,
select,
a,
summary {
  touch-action: manipulation;
}

button:focus-visible,
select:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--rojo);
  outline-offset: 3px;
}

::selection {
  background: var(--sol);
  color: var(--ink);
}

/* Header */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  max-width: 820px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  text-decoration: none;
  color: var(--ink);
  font-family: 'Bricolage Grotesque', 'Plus Jakarta Sans', sans-serif;
  font-weight: 700;
  font-size: 1.35rem;
  letter-spacing: -0.025em;
}

.brand-mark {
  color: var(--rojo);
}

.accent-switch {
  display: inline-flex;
  background: var(--ground);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}

.accent-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 6px 13px;
  border-radius: 999px;
  transition: background 0.15s ease, color 0.15s ease;
}

.accent-btn[aria-pressed='true'] {
  background: var(--rojo);
  color: #ffffff;
}

.accent-btn:hover:not([aria-pressed='true']) {
  color: var(--ink);
}

/* Main layout */
main {
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  padding: 28px 24px 36px;
  flex: 1;
}

.intro {
  margin-bottom: 22px;
}

h1 {
  font-family: 'Bricolage Grotesque', 'Plus Jakarta Sans', sans-serif;
  font-size: clamp(1.75rem, 4.2vw, 2.35rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin: 0 0 8px;
  text-wrap: balance;
}

.intro p {
  margin: 0;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.5;
  max-width: 60ch;
}

/* Controls row */
.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.select-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.select-wrap select {
  -webkit-appearance: none;
  appearance: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  padding: 9px 36px 9px 13px;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
}

.select-wrap::after {
  content: '';
  position: absolute;
  right: 13px;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg) translateY(-2px);
  pointer-events: none;
}

.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 9px 13px;
  border-radius: var(--radius-control);
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.tool-btn:hover {
  background: #edf2f3;
}

.tool-btn[aria-pressed='true'] {
  background: var(--rojo-soft);
  border-color: var(--rojo);
  color: var(--rojo-deep);
}

.tool-btn svg,
.audio-btn svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.actions-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Progress strip */
.deck-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 0.88rem;
  color: var(--muted);
  font-weight: 600;
}

.deck-counts {
  display: flex;
  align-items: center;
  gap: 14px;
  font-variant-numeric: tabular-nums;
}

.mastered-pill {
  color: var(--olive);
  font-weight: 700;
}

.progress-track {
  height: 5px;
  background: #dfe7ea;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 18px;
}

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

/* Flashcard */
.card-stage {
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 6px solid var(--rojo);
  border-radius: var(--radius-card);
  box-shadow: 0 12px 28px rgba(22, 32, 42, 0.07);
  min-height: 360px;
  overflow: hidden;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.card-stage.is-back {
  background: var(--sol-surface);
  border-color: #e6d18a;
  border-top-color: #d69e00;
}

.card-stage.turn {
  animation: cardTurn 0.26s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes cardTurn {
  from {
    transform: perspective(1000px) rotateY(-6deg);
    opacity: 0.92;
  }
  to {
    transform: perspective(1000px) rotateY(0);
    opacity: 1;
  }
}

.face {
  min-height: 354px;
  padding: 22px 28px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.face[hidden] {
  display: none;
}

.face-top {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.88rem;
  font-weight: 700;
}

.side-tag {
  color: var(--rojo);
}

.is-back .side-tag {
  color: var(--sol-ink);
}

.topic-tag {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.85rem;
}

.is-back .topic-tag {
  color: #6b5314;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
}

.status-badge.known {
  background: var(--olive-soft);
  color: var(--olive);
}

.status-badge.learning {
  background: var(--rojo-soft);
  color: var(--rojo-deep);
}

.status-badge[hidden] {
  display: none;
}

.flip-surface {
  width: 100%;
  flex: 1;
  border: 0;
  background: transparent;
  color: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 8px;
  border-radius: 12px;
}

.word-es {
  font-family: 'Bricolage Grotesque', 'Plus Jakarta Sans', sans-serif;
  font-size: clamp(2rem, 5.6vw, 3.35rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.025em;
  color: var(--ink);
  text-wrap: balance;
  overflow-wrap: anywhere;
}

.pron-box {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  max-width: 100%;
}

.pron-guide {
  font-size: clamp(1.08rem, 2.6vw, 1.32rem);
  font-weight: 600;
  color: var(--rojo-deep);
  background: var(--rojo-soft);
  padding: 7px 16px;
  border-radius: 10px;
  line-height: 1.45;
  text-wrap: balance;
}

.pron-ipa {
  font-family: 'DejaVu Sans', 'Noto Sans', 'Segoe UI', Arial, sans-serif;
  font-size: 0.96rem;
  color: var(--muted);
  letter-spacing: 0.015em;
  line-height: 1.4;
}

.word-en {
  font-family: 'Bricolage Grotesque', 'Plus Jakarta Sans', sans-serif;
  font-size: clamp(1.75rem, 4.8vw, 2.75rem);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-wrap: balance;
}

.card-note {
  margin-top: 18px;
  max-width: 48ch;
  font-size: 0.97rem;
  line-height: 1.55;
  color: var(--sol-ink);
  background: rgba(255, 255, 255, 0.55);
  border-radius: 10px;
  padding: 10px 16px;
}

.card-note:empty {
  display: none;
}

.audio-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.audio-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: var(--rojo);
  color: #ffffff;
  font-size: 0.94rem;
  font-weight: 700;
  padding: 10px 18px;
  border-radius: var(--radius-control);
  min-height: 44px;
  transition: background 0.15s ease;
}

.audio-btn:hover {
  background: var(--rojo-deep);
}

.audio-slow-btn {
  border: 1px solid #dfb4bc;
  background: var(--surface);
  color: var(--rojo-deep);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 10px 15px;
  border-radius: var(--radius-control);
  min-height: 44px;
  transition: background 0.15s ease;
}

.audio-slow-btn:hover {
  background: var(--rojo-soft);
}

.back-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.mark-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid #d4bf7a;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 700;
  padding: 10px 16px;
  border-radius: var(--radius-control);
  min-height: 44px;
}

.mark-btn.know:hover,
.mark-btn.know[aria-pressed='true'] {
  background: var(--olive);
  border-color: var(--olive);
  color: #ffffff;
}

.mark-btn.again:hover,
.mark-btn.again[aria-pressed='true'] {
  background: var(--rojo);
  border-color: var(--rojo);
  color: #ffffff;
}

.back-audio-btn {
  border: 0;
  background: transparent;
  color: var(--sol-ink);
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 4px;
  padding: 8px 10px;
}

.tap-hint {
  margin-top: 12px;
  font-size: 0.83rem;
  color: var(--muted);
}

.is-back .tap-hint {
  color: #6b5314;
}

.audio-status {
  margin: 10px 0 0;
  min-height: 20px;
  text-align: center;
  font-size: 0.86rem;
  color: var(--muted);
}

/* Primary navigation */
.card-nav {
  display: grid;
  grid-template-columns: 1fr 1.45fr 1fr;
  gap: 12px;
  margin-top: 8px;
}

.card-nav button {
  min-height: 48px;
  border-radius: var(--radius-control);
  font-size: 0.96rem;
  font-weight: 700;
  padding: 12px 14px;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.nav-btn {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
}

.nav-btn:hover:not(:disabled) {
  background: #edf2f3;
}

.flip-btn {
  background: var(--sol);
  border: 1px solid #e0b323;
  color: var(--ink);
}

.flip-btn:hover {
  background: var(--sol-hover);
}

.shortcuts {
  text-align: center;
  font-size: 0.82rem;
  color: var(--muted);
  margin: 14px 0 28px;
}

.shortcuts kbd {
  display: inline-block;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.78rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 6px;
  color: var(--ink);
}

/* Empty filtered state */
.empty-state {
  text-align: center;
  padding: 46px 24px;
}

.empty-state h2 {
  font-family: 'Bricolage Grotesque', 'Plus Jakarta Sans', sans-serif;
  font-size: 1.5rem;
  margin: 0 0 8px;
}

.empty-state p {
  color: var(--muted);
  margin: 0 0 18px;
}

/* Reference sections */
.reference-block {
  border-top: 1px solid var(--line);
  padding: 16px 0;
}

.reference-block summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 0.96rem;
  color: var(--ink);
  line-height: 1.4;
}

.ref-body {
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.93rem;
  line-height: 1.65;
  max-width: 70ch;
}

.ref-body p {
  margin: 0 0 12px;
}

.ref-body dl {
  display: grid;
  grid-template-columns: 78px 1fr;
  gap: 8px 14px;
  margin: 12px 0 14px;
}

.ref-body dt {
  font-weight: 700;
  color: var(--ink);
}

.ref-body dd {
  margin: 0;
}

.ref-body a {
  color: var(--rojo-deep);
  text-underline-offset: 3px;
}

/* Word list table */
.word-list-wrap {
  margin-top: 14px;
  overflow-x: auto;
}

.word-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.word-table th,
.word-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid #e7edf0;
  vertical-align: top;
}

.word-table th {
  background: #f0f4f5;
  color: var(--ink);
  font-weight: 700;
  font-size: 0.84rem;
}

.word-table tr:last-child td {
  border-bottom: 0;
}

.word-table .col-es {
  font-weight: 700;
  color: var(--ink);
}

.word-table .col-pron {
  color: var(--rojo-deep);
  font-weight: 600;
}

.word-table .col-ipa {
  display: block;
  font-family: 'DejaVu Sans', 'Noto Sans', Arial, sans-serif;
  font-size: 0.82rem;
  font-weight: 400;
  color: var(--muted);
  margin-top: 2px;
}

.table-play-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--rojo-deep);
  border-radius: 7px;
  padding: 4px 9px;
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}

.table-play-btn:hover {
  background: var(--rojo-soft);
  border-color: var(--rojo);
}

.reset-row {
  margin-top: 14px;
  display: flex;
  justify-content: flex-end;
}

.reset-link {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.84rem;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 4px 0;
}

.reset-link:hover {
  color: var(--rojo-deep);
}

footer {
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
  padding: 10px 24px 28px;
  font-size: 0.82rem;
  color: var(--muted);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 600px) {
  .header-inner {
    padding: 14px 16px;
  }

  .brand {
    font-size: 1.15rem;
  }

  .accent-btn {
    padding: 5px 10px;
    font-size: 0.8rem;
  }

  main {
    padding: 20px 16px 28px;
  }

  .controls {
    gap: 8px;
  }

  .select-wrap,
  .select-wrap select {
    width: 100%;
  }

  .filter-group {
    width: 100%;
  }

  .actions-right {
    width: 100%;
    justify-content: space-between;
  }

  .face {
    padding: 18px 18px 20px;
    min-height: 330px;
  }

  .card-stage {
    min-height: 336px;
  }

  .card-nav {
    gap: 8px;
    grid-template-columns: 1fr 1.35fr 1fr;
  }

  .card-nav button {
    font-size: 0.88rem;
    padding: 11px 8px;
  }

  .shortcuts {
    display: none;
  }

  .word-table thead {
    display: none;
  }

  .word-table,
  .word-table tbody,
  .word-table tr,
  .word-table td {
    display: block;
    width: 100%;
  }

  .word-table tr {
    padding: 12px 12px;
    border-bottom: 1px solid #e7edf0;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 4px 10px;
    align-items: start;
  }

  .word-table tr:last-child {
    border-bottom: 0;
  }

  .word-table td {
    padding: 0;
    border: 0;
  }

  .word-table td:nth-child(1) {
    grid-column: 1;
    grid-row: 1;
    font-size: 1rem;
  }

  .word-table td:nth-child(4) {
    grid-column: 2;
    grid-row: 1 / span 2;
    align-self: center;
  }

  .word-table td:nth-child(2) {
    grid-column: 1;
    grid-row: 2;
    font-size: 0.88rem;
  }

  .word-table td:nth-child(3) {
    grid-column: 1 / -1;
    grid-row: 3;
    color: var(--muted);
    padding-top: 2px;
  }

  footer {
    padding: 8px 16px 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .card-stage.turn {
    animation: none;
  }
  * {
    transition: none !important;
  }
}
