:root {
  --bg: #0e1116;
  --panel: #171c24;
  --panel2: #1e2530;
  --accent: #f4b23e;
  --accent2: #e07840;
  --es: #7ec8a9;
  --en: #d8dee7;
  --muted: #8a93a3;
  --good: #58c47e;
  --bad: #e05c5c;
  --line: #2a3242;
}
html { color-scheme: dark; }
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: radial-gradient(1200px 600px at 50% -10%, #1a2230 0%, var(--bg) 60%);
  color: var(--en);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  display: flex; flex-direction: column; align-items: center;
  padding: 24px 16px 40px;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

header { text-align: center; margin-bottom: 14px; position: relative; }
h1 {
  font-size: 2.4rem; letter-spacing: .5px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.tagline { color: var(--muted); margin-top: 6px; font-size: .95rem; max-width: 640px; margin-inline: auto; }
.tagline b { color: var(--es); font-weight: 600; }

.top-actions { position: fixed; top: 16px; right: 16px; display: flex; gap: 8px; z-index: 50; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--panel2); border: 1px solid var(--line);
  font-size: 1.05rem; cursor: pointer; transition: all .15s; color: var(--en);
}
.icon-btn:hover { border-color: var(--accent); transform: translateY(-1px); }

.xpwrap { margin-top: 12px; display: flex; align-items: center; gap: 10px; justify-content: center; font-size: .85rem; color: var(--muted); }
.xpbar { width: 160px; height: 8px; background: #232b38; border-radius: 99px; overflow: hidden; }
.xpbar div { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width .4s; }

.mode-switch {
  display: flex; gap: 6px; margin: 16px 0 18px; flex-wrap: wrap; justify-content: center;
  background: var(--panel); padding: 6px; border-radius: 12px; border: 1px solid var(--line);
}
.mode-switch button {
  background: transparent; border: none; color: var(--muted);
  padding: 8px 14px; border-radius: 8px; cursor: pointer;
  font-size: .9rem; font-weight: 600; transition: all .2s; white-space: nowrap;
}
.mode-switch button.active { background: var(--accent); color: #14100a; }

.difficulty-switch {
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 7px;
  margin: -6px 0 16px; color: var(--muted); font-size: .78rem;
}
.difficulty-switch > span { margin-right: 2px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.difficulty-switch button {
  background: transparent; border: 1px solid var(--line); color: var(--muted);
  padding: 6px 11px; border-radius: 99px; cursor: pointer; font-size: .78rem; transition: all .15s;
}
.difficulty-switch button:hover { border-color: var(--accent); color: var(--en); }
.difficulty-switch button.active { background: rgba(244,178,62,.13); border-color: var(--accent); color: var(--accent); }

.stats { display: flex; flex-wrap: wrap; justify-content: center; gap: 20px; margin-bottom: 16px; font-size: .88rem; color: var(--muted); }
.stats b { color: var(--en); font-size: 1.02rem; }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  padding: 30px 28px; width: 100%; max-width: 780px;
  box-shadow: 0 18px 50px rgba(0,0,0,.45);
}
.fusion-label { font-size: .78rem; color: var(--muted); margin-bottom: 8px; display: flex; justify-content: space-between; gap: 10px; }
.fusion-bar { height: 8px; background: #232b38; border-radius: 99px; overflow: hidden; margin-bottom: 24px; }
.fusion-bar .fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), var(--es)); transition: width .5s ease; }

.sentence {
  font-size: 1.65rem; line-height: 2.25; text-align: center; min-height: 110px;
  display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 10px; align-items: center;
}
.token { padding: 4px 10px; border-radius: 8px; white-space: nowrap; transition: all .25s; }
.token.en.clickable { cursor: pointer; border: 1px dashed #3a4456; background: var(--panel2); }
.token.en.clickable:hover { border-color: var(--accent); transform: translateY(-2px); }
.token.es { color: var(--es); font-weight: 600; cursor: pointer; }
.token.es:hover { text-decoration: underline dotted; }
.token.flip { animation: flipIn .45s ease; background: rgba(126,200,169,.12); }
@keyframes flipIn { from { transform: rotateX(90deg) scale(.8); opacity: 0; } to { transform: none; opacity: 1; } }
.token-input {
  background: #12161d; border: 1px solid var(--accent); border-radius: 6px;
  color: var(--en); font: inherit; font-size: 1.15rem; padding: 2px 8px; text-align: center; outline: none;
}
.shake { animation: shake .35s; }
@keyframes shake { 20%,60% { transform: translateX(-5px);} 40%,80% { transform: translateX(5px);} }

.hint { text-align: center; color: var(--muted); font-size: .85rem; margin-top: 16px; min-height: 1.3em; }
.note-box {
  display: none; margin-top: 14px; padding: 12px 16px; border-radius: 10px;
  background: rgba(244,178,62,.07); border: 1px solid rgba(244,178,62,.25);
  font-size: .88rem; line-height: 1.55; color: var(--en);
}
.note-box b { color: var(--accent); }

.controls { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 22px; }
.btn { border: none; border-radius: 10px; padding: 11px 18px; font-size: .92rem; font-weight: 600; cursor: pointer; transition: all .15s; }
.btn-primary { background: var(--accent); color: #14100a; }
.btn-primary:hover { filter: brightness(1.1); }
.btn-ghost { background: var(--panel2); color: var(--en); border: 1px solid var(--line); }
.btn-ghost:hover { border-color: var(--accent); }
.kbdrow { text-align: center; color: #5b6474; font-size: .75rem; margin-top: 16px; }
kbd { background: var(--panel2); border: 1px solid #3a4456; border-radius: 5px; padding: 1px 6px; font-size: .78rem; color: var(--accent); }

.dictation, .builder, .cloze, .speakmode { text-align: center; }
.big-play {
  width: 88px; height: 88px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: none; cursor: pointer; margin: 8px auto 20px; display: block;
  font-size: 1.9rem; color: #14100a; box-shadow: 0 10px 30px rgba(224,120,64,.35);
  transition: transform .15s;
}
.big-play:hover { transform: scale(1.06); }
.big-play.mic { background: linear-gradient(135deg, #7ec8a9, #4da583); }
input[type="text"] {
  width: 100%; background: var(--panel2); border: 1px solid var(--line);
  border-radius: 10px; color: var(--en); font-size: 1.2rem;
  padding: 13px 15px; text-align: center; outline: none;
}
input[type="text"]:focus { border-color: var(--accent); }
.replay-link { background: none; border: none; color: var(--muted); cursor: pointer; margin-top: 10px; font-size: .82rem; text-decoration: underline; }
.verdict { margin-top: 14px; font-size: 1rem; min-height: 1.4em; }
.verdict.good { color: var(--good); }
.verdict.bad { color: var(--bad); }
.answer-reveal { margin-top: 8px; color: var(--es); font-size: 1.1rem; min-height: 1.3em; }
.diffline { margin-top: 8px; font-size: 1.05rem; line-height: 1.9; min-height: 1.3em; }
.diffline .w-ok { color: var(--good); }
.diffline .w-miss { color: var(--bad); text-decoration: underline wavy rgba(224,92,92,.5); }
.transcript { margin-top: 10px; color: var(--muted); font-size: .95rem; min-height: 1.3em; font-style: italic; }

.chiparea {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
  min-height: 56px; padding: 10px; margin-top: 14px;
  border: 1px dashed #3a4456; border-radius: 12px; background: rgba(255,255,255,.015);
}
.chiparea.answer { border-style: solid; border-color: #3f4b60; }
.chip {
  background: var(--panel2); border: 1px solid #3f4b60; color: var(--es);
  font-weight: 600; font-size: 1.05rem; padding: 7px 14px; border-radius: 9px; cursor: pointer; transition: all .15s;
}
.chip:hover { border-color: var(--accent); transform: translateY(-2px); }
.eng-ref { color: var(--muted); font-size: .95rem; margin-top: 12px; min-height: 1.2em; }

.overlay {
  position: fixed; inset: 0; background: rgba(8,10,14,.82);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px;
}
.overlay.hidden { display: none; }
.modal {
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  max-width: 660px; width: 100%; padding: 30px 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,.6); max-height: 90vh; overflow-y: auto;
}
.modal h2 {
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  margin-bottom: 4px; font-size: 1.45rem;
}
.modal .sub { color: var(--muted); font-size: .88rem; margin-bottom: 18px; }
.modal h3 { color: var(--es); font-size: .98rem; margin: 16px 0 8px; }
.modal p, .modal li { color: var(--en); font-size: .9rem; line-height: 1.65; }
.modal ol, .modal ul { padding-left: 22px; margin-top: 6px; }
.modal li { margin-bottom: 6px; }
.example-fusion {
  background: var(--panel2); border-radius: 10px; padding: 12px 16px;
  margin-top: 8px; font-size: 1.02rem; line-height: 1.9; text-align: center;
}
.setrow { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 14px 0; font-size: .92rem; flex-wrap: wrap; }
.setrow label { color: var(--en); }
.setrow select {
  background: var(--panel2); color: var(--en); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 10px; max-width: 320px;
}
.topic-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.tcheck {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 99px;
  padding: 6px 13px; font-size: .82rem; color: var(--muted); user-select: none; transition: all .15s;
}
.tcheck.on { border-color: var(--accent); color: var(--accent); }
.tcheck input { accent-color: var(--accent); }
.statgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin: 14px 0; }
.statbox { background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; text-align: center; }
.statbox b { display: block; font-size: 1.4rem; color: var(--accent); }
.statbox span { font-size: .74rem; color: var(--muted); }
table.cards { width: 100%; border-collapse: collapse; font-size: .82rem; margin-top: 10px; }
table.cards td { padding: 7px 8px; border-bottom: 1px solid #232b38; color: var(--muted); }
table.cards td:first-child { color: var(--es); }
.dots { letter-spacing: 2px; color: var(--accent); white-space: nowrap; }
.dots .off { color: #333c4d; }

.site-footer { max-width: 700px; margin-top: 30px; text-align: center; color: #5b6474; font-size: .78rem; line-height: 1.6; }

.toasts { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column-reverse; gap: 8px; z-index: 300; pointer-events: none; width: min(92vw, 480px); }
.toast {
  background: #161a2b; border: 1px solid #2e3450; color: var(--en);
  padding: 10px 20px; border-radius: 12px; font-size: .9rem; text-align: center;
  opacity: 0; transform: translateY(14px); transition: all .3s cubic-bezier(.3,1.4,.5,1);
  box-shadow: 0 10px 30px rgba(0,0,0,.45);
}
.toast.show { opacity: 1; transform: none; }
.toast.gold { border-color: #c9a227; color: #ffe9a8; background: linear-gradient(135deg,#3a2c00,#221c06); }

.method-note { max-width: 780px; margin-top: 26px; color: var(--muted); font-size: .84rem; line-height: 1.6; text-align: center; }
.method-note b { color: var(--accent); }

@media (max-width: 640px) {
  body { padding: 16px 10px 30px; }
  h1 { font-size: 1.9rem; }
  .card { padding: 20px 14px; }
  .sentence { font-size: 1.22rem; line-height: 1.95; min-height: 90px; }
  .mode-switch button { padding: 7px 10px; font-size: .8rem; }
  .difficulty-switch { max-width: 390px; }
  .difficulty-switch > span { width: 100%; text-align: center; }
  .difficulty-switch button { padding: 6px 9px; font-size: .74rem; }
  .stats { gap: 12px; font-size: .8rem; }
  .btn { padding: 10px 13px; font-size: .86rem; }
  .big-play { width: 72px; height: 72px; font-size: 1.5rem; }
  input[type="text"] { font-size: 1.05rem; }
  .modal { padding: 22px 18px; }
  .top-actions { top: 10px; right: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
