:root {
  --ink: #101218; --ink2: #171a22; --ink3: #20242f; --line: #2b3040;
  --gold: #d6aa4f; --gold2: #f0cd7d; --text: #eef0f5; --muted: #9aa1b2;
  --ok: #4fc08d; --bad: #e86a6a; --warn: #e6b450;
  --r: 16px; --serif: "Fraunces", Georgia, serif; --sans: "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--ink); color: var(--text); font: 16px/1.5 var(--sans); -webkit-tap-highlight-color: transparent; }
a { color: var(--gold2); }
button { font: inherit; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.7rem; } h2 { font-size: 1.3rem; } h3 { font-size: 1.05rem; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .center { text-align: center; }
.hidden { display: none !important; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top)); background: rgba(16,18,24,.92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { display: flex; gap: 10px; align-items: center; color: var(--text); text-decoration: none; font-family: var(--serif); font-size: 1.1rem; }
.brand small { font-family: var(--sans); font-size: .7rem; color: var(--muted); display: block; margin-top: -3px; }
.logo { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: linear-gradient(135deg, var(--gold2), var(--gold)); color: var(--ink); font: 700 .85rem var(--sans); letter-spacing: .5px; }
.top-r { display: flex; gap: 6px; }
.pill { padding: 4px 10px; border-radius: 999px; background: var(--ink3); border: 1px solid var(--line); font-size: .85rem; white-space: nowrap; }

.view { max-width: 760px; margin: 0 auto; padding: 18px 16px calc(96px + var(--safe-b)); }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; justify-content: space-around; padding: 6px 4px calc(6px + var(--safe-b)); background: rgba(16,18,24,.96); border-top: 1px solid var(--line); }
.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 4px; color: var(--muted); text-decoration: none; font-size: .72rem; border-radius: 10px; }
.tabs a span { font-size: 1.25rem; }
.tabs a.on { color: var(--gold2); background: var(--ink2); }
body.focus .tabs { display: none; }
body.focus .view { padding-bottom: calc(24px + var(--safe-b)); }

@media (min-width: 900px) {
  .tabs { top: 70px; bottom: auto; left: 20px; right: auto; flex-direction: column; width: 120px; border: 1px solid var(--line); border-radius: var(--r); gap: 4px; padding: 8px; }
  .tabs a { flex-direction: row; gap: 8px; font-size: .9rem; justify-content: flex-start; padding: 8px 10px; }
  .view { padding-bottom: 40px; }
}

.card { background: var(--ink2); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin-bottom: 12px; }
.card.gold { border-color: rgba(214,170,79,.5); background: linear-gradient(180deg, rgba(214,170,79,.10), var(--ink2)); }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--ink3); color: var(--text); cursor: pointer; text-decoration: none; font-weight: 500; }
.btn:hover { border-color: #3a4156; }
.btn.primary { background: linear-gradient(135deg, var(--gold2), var(--gold)); color: var(--ink); border: 0; font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 7px 12px; font-size: .9rem; border-radius: 10px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.ok { background: rgba(79,192,141,.15); border-color: rgba(79,192,141,.5); }
.btn.bad { background: rgba(232,106,106,.12); border-color: rgba(232,106,106,.45); }

label { display: block; font-size: .88rem; color: var(--muted); margin: 10px 0 4px; }
input, textarea, select { width: 100%; padding: 11px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--ink); color: var(--text); font: inherit; }
textarea { min-height: 80px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid rgba(214,170,79,.5); border-color: transparent; }

/* Hoy */
.hero { display: flex; gap: 14px; align-items: center; }
.ring { --p: 0; width: 74px; height: 74px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--gold) calc(var(--p) * 1%), var(--ink3) 0); flex: none; }
.ring b { width: 60px; height: 60px; border-radius: 50%; background: var(--ink2); display: grid; place-items: center; font: 600 1.1rem var(--sans); }
.slot { display: flex; gap: 12px; align-items: center; }
.slot .ic { width: 44px; height: 44px; border-radius: 12px; background: var(--ink3); display: grid; place-items: center; font-size: 1.3rem; flex: none; }
.slot.done .ic { background: rgba(79,192,141,.18); }
.slot.now { border-color: rgba(214,170,79,.6); }
.badge { font-size: .72rem; padding: 2px 8px; border-radius: 999px; background: var(--ink3); color: var(--muted); }
.badge.ok { background: rgba(79,192,141,.18); color: var(--ok); }
.badge.gold { background: rgba(214,170,79,.18); color: var(--gold2); }

/* Conversación */
.chat { display: flex; flex-direction: column; gap: 10px; min-height: 40vh; padding-bottom: 8px; }
.msg { max-width: 86%; padding: 10px 14px; border-radius: 16px; line-height: 1.45; }
.msg.tutor { align-self: flex-start; background: var(--ink3); border-bottom-left-radius: 4px; }
.msg.user { align-self: flex-end; background: rgba(214,170,79,.16); border: 1px solid rgba(214,170,79,.3); border-bottom-right-radius: 4px; }
.msg .play { margin-left: 6px; background: none; border: 0; color: var(--gold2); cursor: pointer; padding: 0 2px; }
.msg.pending { opacity: .6; font-style: italic; }
.hint { font-size: .85rem; color: var(--muted); text-align: center; margin: 4px 0 10px; }
.dock { position: sticky; bottom: 0; padding: 12px 0 calc(8px + var(--safe-b)); background: linear-gradient(180deg, transparent, var(--ink) 30%); }
.mic { width: 84px; height: 84px; border-radius: 50%; border: 0; cursor: pointer; display: grid; place-items: center; margin: 0 auto; font-size: 2rem; background: linear-gradient(135deg, var(--gold2), var(--gold)); color: var(--ink); box-shadow: 0 8px 30px rgba(214,170,79,.25); transition: transform .15s; }
.mic.rec { background: var(--bad); color: #fff; animation: pulse 1.2s infinite; }
.mic.busy { background: var(--ink3); color: var(--muted); box-shadow: none; }
.mic:active { transform: scale(.96); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(232,106,106,.5); } 70% { box-shadow: 0 0 0 18px rgba(232,106,106,0); } 100% { box-shadow: 0 0 0 0 rgba(232,106,106,0); } }
.state { text-align: center; font-size: .9rem; color: var(--muted); min-height: 1.4em; margin-top: 8px; }
.typebar { display: flex; gap: 8px; margin-top: 10px; }
.level-meter { height: 4px; border-radius: 4px; background: var(--ink3); overflow: hidden; margin: 8px auto 0; width: 120px; }
.level-meter i { display: block; height: 100%; width: 0; background: var(--bad); transition: width .08s; }

/* Resumen y tarjetas */
.mistake { border-left: 3px solid var(--gold); padding: 10px 12px; background: var(--ink); border-radius: 10px; margin: 8px 0; }
.mistake .o { color: var(--bad); text-decoration: line-through; text-decoration-color: rgba(232,106,106,.6); }
.mistake .c { color: var(--ok); font-weight: 500; }
.flash { min-height: 230px; display: flex; flex-direction: column; justify-content: center; text-align: center; gap: 10px; }
.flash .big { font-family: var(--serif); font-size: 1.35rem; }
.grades { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.grades .btn { flex-direction: column; gap: 0; padding: 9px 4px; font-size: .9rem; }
.grades small { color: var(--muted); font-size: .7rem; }
.progress { height: 6px; background: var(--ink3); border-radius: 6px; overflow: hidden; margin: 6px 0 14px; }
.progress i { display: block; height: 100%; background: var(--gold); width: 0; transition: width .3s; }
.w-ok { color: var(--ok); } .w-bad { color: var(--bad); text-decoration: underline wavy rgba(232,106,106,.6); }
.score { font: 700 2.6rem var(--serif); }
.stat { text-align: center; } .stat b { display: block; font: 600 1.5rem var(--serif); color: var(--gold2); }

.toast { position: fixed; left: 50%; bottom: calc(90px + var(--safe-b)); transform: translateX(-50%) translateY(20px); background: var(--ink3); border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px; opacity: 0; pointer-events: none; transition: .25s; max-width: 90vw; z-index: 20; }
.toast.on { opacity: 1; transform: translateX(-50%); }
.toast.err { border-color: rgba(232,106,106,.6); }
.spinner { width: 22px; height: 22px; border: 3px solid var(--ink3); border-top-color: var(--gold); border-radius: 50%; animation: spin 1s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.login { max-width: 420px; margin: 6vh auto; }
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; color: var(--text); font-size: .95rem; margin: 10px 0; }
.switch input { width: auto; }

/* Íconos de línea (sin emojis): trazo fino, color heredado; dorado solo en lo activo. */
.i { width: 1.1em; height: 1.1em; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.18em; flex: none; }
.i.spin, .mic.busy .i { animation: spin 1.1s linear infinite; }
.tabs a span { display: grid; place-items: center; height: 26px; }
.tabs a span .i { width: 22px; height: 22px; stroke-width: 1.5; }
.tabs a { letter-spacing: .02em; font-weight: 500; }
.tabs a.on { background: transparent; color: var(--gold2); }
.tabs a.on span::after { content: ""; display: block; width: 18px; height: 2px; border-radius: 2px; background: var(--gold); margin-top: 3px; }
.tabs a span { display: flex; flex-direction: column; align-items: center; }
@media (min-width: 900px) { .tabs a.on { background: var(--ink2); } .tabs a.on span::after { display: none; } }
.mic .i { width: 32px; height: 32px; stroke-width: 1.7; }
.slot .ic { color: var(--gold2); background: transparent; border: 1px solid var(--line); }
.slot .ic .i { width: 22px; height: 22px; }
.slot.done .ic { color: var(--ok); border-color: rgba(79,192,141,.4); background: transparent; }
.pill .i { color: var(--gold); }
h1 .i, h2 .i, h3 .i { color: var(--gold); stroke-width: 1.5; margin-right: 4px; }
.btn .i { width: 1.05em; height: 1.05em; }
