/* Tabla interactiva de fonética internacional (AFI / IPA) */
:root,
[data-theme="dark"] {
  --font-main: 'Inter', system-ui, -apple-system, sans-serif;
  --font-heading: 'Outfit', 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --bg-page: #0b0f17;
  --bg-surface: #131b2e;
  --bg-surface-2: #192338;
  --bg-input: #0f1626;
  --border-color: #26334d;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent: #38bdf8;
  --accent-strong: #0284c7;
  --accent-soft: rgba(56, 189, 248, 0.14);
  --ok: #10b981;
  --ok-soft: rgba(16, 185, 129, 0.14);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.15);
  --shadow-card: 0 12px 32px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

[data-theme="light"] {
  --bg-page: #f1f5f9;
  --bg-surface: #ffffff;
  --bg-surface-2: #f8fafc;
  --bg-input: #ffffff;
  --border-color: #cbd5e1;
  --text-main: #0f172a;
  --text-muted: #475569;
  --accent: #0284c7;
  --accent-strong: #0369a1;
  --accent-soft: rgba(2, 132, 199, 0.1);
  --ok: #059669;
  --ok-soft: rgba(5, 150, 105, 0.12);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.12);
  --shadow-card: 0 8px 24px rgba(15, 23, 42, 0.08);
  color-scheme: light;
}

[data-theme="dark"] .app-header { background: #131b2e !important; border-bottom: 1px solid #1e293b !important; }
[data-theme="dark"] .brand-title { color: #f8fafc !important; }
[data-theme="light"] .app-header { background: #ffffff !important; border-bottom: 1px solid #cbd5e1 !important; }
[data-theme="light"] .brand-title { color: #0f172a !important; }

*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: var(--font-main);
  background: var(--bg-page);
  color: var(--text-main);
  margin: 0;
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4, h5, h6, .brand-title, .section-title, .hero-title { font-family: var(--font-heading); }
.mono, code { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.tool-layout { max-width: 1200px; width: 100%; margin: 1.5rem auto 3rem; padding: 0 1rem; flex: 1 0 auto; }
.tool-with-sidebar { display: flex; gap: 2rem; align-items: flex-start; width: 100%; }
.tool-main-content { flex: 1 1 0%; min-width: 0; width: 100%; }

.card-main {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.35rem;
  box-shadow: var(--shadow-card);
  margin-bottom: 1.25rem;
}

.top-bar-flex { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; }
.badge-pill {
  display: inline-block;
  font-size: 0.74rem;
  font-weight: 700;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent);
  margin-bottom: 0.45rem;
}
.hero-title { margin: 0 0 0.35rem; font-size: 1.26rem; line-height: 1.25; }
.hero-desc { margin: 0; font-size: 0.89rem; color: var(--text-muted); line-height: 1.55; max-width: 68ch; }
.section-title { margin: 0; font-size: 1.04rem; font-weight: 700; }

.lang-filter-box { min-width: 240px; }
.form-label { display: block; font-size: 0.75rem; font-weight: 600; color: var(--text-muted); margin-bottom: 0.28rem; }
.form-select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 0.5rem 40px 0.5rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background-color: var(--bg-input);
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 0.86rem;
  appearance: none;
  -webkit-appearance: none;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
.form-select option { background-color: var(--bg-surface); color: var(--text-main); }

.inspector-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.35fr);
  gap: 1.25rem;
  align-items: stretch;
}
.anatomy-head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.65rem; }
.anatomy-tag { font-size: 0.74rem; padding: 0.22rem 0.55rem; border-radius: 999px; background: var(--bg-surface-2); border: 1px solid var(--border-color); color: var(--accent); }

.svg-stage {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 0.5rem;
  display: flex;
  justify-content: center;
}
#svg-vocal-tract { width: 100%; max-width: 310px; height: auto; display: block; }
.tract-skull { fill: rgba(148, 163, 184, 0.14); stroke: rgba(148, 163, 184, 0.45); stroke-width: 2; }
.tract-cavity { fill: rgba(56, 189, 248, 0.12); }
.tract-palate { stroke: #94a3b8; }
.tract-velum { stroke: #f59e0b; transition: d 0.25s ease; }
.tract-tooth { fill: #e2e8f0; stroke: #94a3b8; stroke-width: 1; }
.tract-lip { stroke: #fb7185; }
.tract-wall { stroke: rgba(148, 163, 184, 0.5); }
.tract-tongue { fill: rgba(244, 63, 94, 0.65); stroke: #fb7185; stroke-width: 2; transition: all 0.22s ease; }
.tract-glottis-ring { fill: rgba(16, 185, 129, 0.12); stroke: rgba(16, 185, 129, 0.55); stroke-width: 1.5; }
.tract-focus-dot { fill: rgba(56, 189, 248, 0.35); stroke: #38bdf8; stroke-width: 2.5; }
.tract-lbl { font-size: 10px; font-family: var(--font-mono); fill: var(--text-muted); }

.anatomy-legend { display: flex; flex-wrap: wrap; gap: 0.8rem; margin-top: 0.65rem; font-size: 0.76rem; color: var(--text-muted); }
.anatomy-legend span { display: inline-flex; align-items: center; gap: 0.35rem; }
.dot-focus, .dot-voiced, .dot-nasal { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot-focus { background: #38bdf8; }
.dot-voiced { background: #10b981; }
.dot-nasal { background: #f59e0b; }

.detail-card { display: flex; flex-direction: column; justify-content: space-between; gap: 1rem; }
.phoneme-hero { display: flex; gap: 1rem; align-items: flex-start; flex-wrap: wrap; }
.phoneme-symbol-box {
  width: 92px;
  height: 92px;
  border-radius: 16px;
  background: var(--accent-soft);
  border: 2px solid var(--accent);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem;
  font-weight: 700;
  flex-shrink: 0;
}
.phoneme-meta { flex: 1 1 220px; min-width: 0; }
.phoneme-name { margin: 0 0 0.25rem; font-size: 1.18rem; }
.phoneme-features { margin: 0 0 0.75rem; font-size: 0.85rem; color: var(--text-muted); line-height: 1.45; }
.phoneme-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.btn-primary,
.btn-secondary {
  min-height: 40px;
  padding: 0.48rem 0.95rem;
  border-radius: 10px;
  font-family: var(--font-main);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
}
.btn-primary { background: var(--accent-strong); color: #ffffff; }
.btn-primary:hover { background: var(--accent); color: #0b0f17; }
.btn-secondary { background: var(--bg-surface-2); border-color: var(--border-color); color: var(--text-main); }
.btn-secondary:hover { border-color: var(--accent); }

.phoneme-details-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.85rem; }
.info-box {
  background: var(--bg-surface-2);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 0.85rem;
}
.info-lbl { display: block; font-size: 0.74rem; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 0.35rem; }
.info-box p { margin: 0; font-size: 0.84rem; line-height: 1.5; color: var(--text-main); }
.examples-list { margin: 0; padding-left: 1.1rem; font-size: 0.84rem; line-height: 1.55; }

.chart-tabs { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-bottom: 0.9rem; }
.tab-btn {
  min-height: 40px;
  padding: 0.45rem 0.9rem;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface-2);
  color: var(--text-muted);
  font-family: var(--font-main);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.tab-btn.active { background: var(--accent-strong); border-color: var(--accent-strong); color: #ffffff; }

.chart-hint { margin: 0 0 0.75rem; font-size: 0.82rem; color: var(--text-muted); }

.table-scroll { overflow-x: auto; }
.ipa-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; min-width: 760px; }
.ipa-table th,
.ipa-table td {
  border: 1px solid var(--border-color);
  padding: 0.25rem;
  text-align: center;
}
.ipa-table th {
  background: var(--bg-surface-2);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.45rem 0.3rem;
}
.ipa-table th.row-head { text-align: left; padding-left: 0.5rem; white-space: nowrap; }
.ipa-cell-pair { display: flex; justify-content: center; gap: 0.2rem; }
.ipa-btn {
  min-width: 30px;
  min-height: 32px;
  padding: 0.18rem 0.35rem;
  border-radius: 7px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 0.98rem;
  font-weight: 600;
  cursor: pointer;
}
.ipa-btn:hover { background: var(--accent-soft); border-color: var(--accent); }
.ipa-btn.selected { background: var(--accent-strong); color: #ffffff; border-color: var(--accent); }
.ipa-btn.dimmed { opacity: 0.25; }
.ipa-btn.in-lang { box-shadow: inset 0 -2px 0 var(--ok); }

.affricates-bar { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin-top: 0.85rem; }
.affr-title { font-size: 0.8rem; font-weight: 700; color: var(--text-muted); }
.affr-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.affr-chips .ipa-btn { background: var(--bg-surface-2); border-color: var(--border-color); padding: 0.3rem 0.65rem; }

.vowel-trapezoid-wrap { display: flex; gap: 0.75rem; align-items: stretch; overflow-x: auto; padding-bottom: 0.5rem; }
.vowel-axis-y {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 18px 0;
  font-size: 0.74rem;
  color: var(--text-muted);
  font-weight: 600;
  min-width: 82px;
}
.vowel-stage {
  position: relative;
  flex: 1 1 560px;
  min-width: 520px;
  height: 320px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 14px;
}
.trapezoid-lines { position: absolute; inset: 0; width: 100%; height: 100%; color: var(--text-muted); pointer-events: none; }
.vowel-node {
  position: absolute;
  transform: translate(-50%, -50%);
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  padding: 2px 5px;
}

.trainer-card {
  background: var(--bg-surface-2);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 1.1rem;
}
.trainer-stats { display: flex; align-items: center; gap: 0.85rem; flex-wrap: wrap; margin-bottom: 0.65rem; font-size: 0.84rem; }
.trainer-question { margin: 0 0 0.85rem; font-size: 1.05rem; }
.trainer-controls { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-bottom: 0.9rem; }
.mp-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
.mp-opt-btn {
  padding: 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-main);
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.mp-opt-btn:hover { border-color: var(--accent); }
.mp-opt-btn.correct { border-color: var(--ok); background: var(--ok-soft); }
.mp-opt-btn.wrong { border-color: var(--danger); background: var(--danger-soft); }
.mp-opt-word { font-size: 1.05rem; font-weight: 700; }
.mp-opt-ipa { font-size: 0.86rem; color: var(--accent); }

.mp-feedback {
  margin-top: 0.85rem;
  padding: 0.8rem;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  font-size: 0.86rem;
  line-height: 1.5;
}

.faq-list { display: flex; flex-direction: column; gap: 0.55rem; margin-top: 0.65rem; }
.faq-item {
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: var(--bg-surface-2);
  padding: 0.75rem 0.95rem;
}
.faq-question { font-weight: 600; font-size: 0.9rem; cursor: pointer; }
.faq-answer { margin: 0.55rem 0 0; font-size: 0.86rem; color: var(--text-muted); line-height: 1.55; }

@media (max-width: 960px) {
  .inspector-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .lang-filter-box { width: 100%; }
  .phoneme-details-grid,
  .mp-options { grid-template-columns: 1fr; }
  .phoneme-actions .btn-primary,
  .phoneme-actions .btn-secondary,
  .trainer-controls .btn-primary,
  .trainer-controls .btn-secondary { width: 100%; }
}
