/* Sistema visual: superficies neomórficas suaves, cristal fino, jade y esmeralda. */

:root {
  --r: 16px;
  --r-sm: 10px;

  --jade-900: #05372c;
  --jade-700: #0b6b52;
  --jade-500: #12a077;
  --jade-300: #58cfa8;
  --jade-100: #d3f0e4;

  --amber: #d99e26;
  --coral: #cf4b4b;

  --bg: #eef4f1;
  --surface: #f4f9f6;
  --surface-glass: rgba(255, 255, 255, 0.62);
  --ink: #10241e;
  --ink-soft: #5b736b;
  --line: rgba(11, 107, 82, 0.14);

  --lift: -6px -6px 14px rgba(255, 255, 255, 0.9), 6px 6px 16px rgba(9, 62, 48, 0.10);
  --press: inset -3px -3px 8px rgba(255, 255, 255, 0.85), inset 4px 4px 10px rgba(9, 62, 48, 0.13);

  --sans: "Inter", "Segoe UI", "Helvetica Neue", system-ui, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", "Georgia", serif;
}

html[data-theme="dark"] {
  color-scheme: dark;
}

html[data-theme="dark"] {
  --bg: #0d1714;
  --surface: #13211d;
  --surface-glass: rgba(24, 46, 39, 0.55);
  --ink: #e2f0ea;
  --ink-soft: #90aaa1;
  --line: rgba(88, 207, 168, 0.18);
  --jade-100: #123a2e;
  --lift: -6px -6px 14px rgba(255, 255, 255, 0.03), 6px 6px 18px rgba(0, 0, 0, 0.45);
  --press: inset -3px -3px 8px rgba(255, 255, 255, 0.03), inset 4px 4px 12px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(120% 80% at 12% -10%, rgba(18, 160, 119, 0.16), transparent 60%),
    radial-gradient(90% 70% at 95% 0%, rgba(88, 207, 168, 0.12), transparent 55%),
    var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { line-height: 1.18; margin: 0 0 .6rem; letter-spacing: -0.015em; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
.muted { color: var(--ink-soft); font-size: .9rem; }

.skip {
  position: absolute; left: -999px; top: 0; z-index: 50;
  background: var(--jade-700); color: #fff; padding: .6rem 1rem; border-radius: 0 0 var(--r-sm) 0;
}
.skip:focus { left: 0; }

/* ---------- Barra superior ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1rem clamp(1rem, 4vw, 2.5rem);
  position: sticky; top: 0; z-index: 20;
  background: var(--surface-glass);
  backdrop-filter: blur(14px) saturate(1.3);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .7rem; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 9px;
  background: linear-gradient(145deg, var(--jade-300), var(--jade-700));
  box-shadow: var(--lift);
}
.brand-name { display: flex; flex-direction: column; font-weight: 620; letter-spacing: -0.02em; }
.brand-sub { font-size: .72rem; font-weight: 400; color: var(--ink-soft); letter-spacing: 0; }
.topbar-actions { display: flex; align-items: center; gap: .5rem; }

/* ---------- Contenedores ---------- */
main { max-width: 1120px; margin: 0 auto; padding: clamp(1.2rem, 4vw, 2.6rem) clamp(1rem, 4vw, 2rem) 4rem; }
.view { animation: enter .32s ease both; }
@keyframes enter { from { opacity: 0; transform: translateY(8px); } }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--lift);
  padding: clamp(1.1rem, 3vw, 1.6rem);
  margin-bottom: 1.1rem;
}
.panel.narrow { max-width: 420px; margin-inline: auto; }

/* ---------- Hero ---------- */
.hero { max-width: 44ch; margin: clamp(1rem, 5vw, 3rem) 0 1.6rem; }
.hero-kicker { color: var(--jade-700); font-weight: 600; font-size: .88rem; margin-bottom: .35rem; }
.hero-title { font-family: var(--serif); font-size: clamp(2rem, 5.5vw, 3.1rem); font-weight: 600; }
.hero-lead { color: var(--ink-soft); font-size: 1.02rem; }
.hero-steps { color: var(--ink-soft); font-size: 1.02rem; margin: .5rem 0 0; padding-left: 1.2rem; }
.hero-steps li { margin-bottom: .3rem; }

.auth-panel { display: grid; grid-template-columns: 1fr auto 1fr; gap: clamp(1rem, 4vw, 2.4rem); align-items: start; }
.auth-divider { width: 1px; background: var(--line); align-self: stretch; }
@media (max-width: 720px) {
  .auth-panel { grid-template-columns: 1fr; }
  .auth-divider { width: auto; height: 1px; }
}

/* ---------- Controles ---------- */
.field { display: block; margin-bottom: .85rem; }
.field > span { display: block; font-size: .82rem; color: var(--ink-soft); margin-bottom: .3rem; }
input[type="text"], input[type="password"], input[type="number"], input[type="search"], select, textarea {
  width: 100%; font: inherit; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: .62rem .8rem; box-shadow: var(--press);
}
textarea { resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--jade-500); outline-offset: 2px;
}

button { font: inherit; cursor: pointer; border-radius: var(--r-sm); border: 1px solid transparent; }
.primary-btn {
  width: 100%; padding: .72rem 1.1rem; font-weight: 600;
  background: linear-gradient(150deg, var(--jade-500), var(--jade-700)); color: #fff;
  box-shadow: 0 6px 16px rgba(11, 107, 82, 0.28);
  transition: transform .12s ease, box-shadow .12s ease;
}
.primary-btn:hover { transform: translateY(-1px); }
.primary-btn:active { transform: translateY(1px); box-shadow: none; }
.secondary-btn {
  width: 100%; padding: .68rem 1.1rem; font-weight: 560;
  background: var(--surface); color: var(--jade-700); border-color: var(--line); box-shadow: var(--lift);
}
html[data-theme="dark"] .secondary-btn { color: var(--jade-300); }
.ghost-btn { padding: .42rem .8rem; background: transparent; border-color: var(--line); color: var(--ink); }
.link-btn { width: 100%; margin-top: .5rem; background: none; color: var(--ink-soft); text-decoration: underline; padding: .4rem; }
.icon-btn { width: 34px; height: 34px; background: var(--surface); border-color: var(--line); box-shadow: var(--lift); }

.chip {
  display: inline-block; padding: .22rem .6rem; border-radius: 999px;
  background: var(--jade-100); color: var(--jade-700); font-size: .78rem; font-weight: 600;
}
html[data-theme="dark"] .chip { color: var(--jade-300); }
.chip.subtle { background: transparent; border: 1px solid var(--line); color: var(--ink-soft); font-weight: 500; }
.badge {
  margin-top: .9rem; padding: .55rem .8rem; border-radius: var(--r-sm);
  background: rgba(217, 158, 38, 0.14); border: 1px solid rgba(217, 158, 38, 0.3);
  font-size: .86rem;
}
.alert {
  margin-top: 1rem; padding: .7rem .9rem; border-radius: var(--r-sm);
  background: rgba(207, 75, 75, 0.12); border: 1px solid rgba(207, 75, 75, 0.35); color: var(--coral);
}

/* ---------- Panel del estudiante ---------- */
.dash-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 1.1rem; align-items: start; }
.bank-panel { grid-column: 1 / -1; }
@media (max-width: 780px) { .dash-grid { grid-template-columns: 1fr; } }

.ring-wrap { position: relative; width: 148px; margin: 0 auto .6rem; }
.ring { width: 148px; height: 148px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 11; stroke-linecap: round; }
.ring-track { stroke: var(--jade-100); }
.ring-value { stroke: var(--jade-500); stroke-dasharray: 327; stroke-dashoffset: 327; transition: stroke-dashoffset .7s cubic-bezier(.4,0,.2,1); }
.ring-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring-center strong { font-size: 1.7rem; font-weight: 650; }
.ring-center span { font-size: .76rem; color: var(--ink-soft); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin: 1rem 0 0; text-align: center; }
.stats dt { font-size: .74rem; color: var(--ink-soft); }
.stats dd { margin: .1rem 0 0; font-size: 1.25rem; font-weight: 620; }

.size-picker { border: 0; padding: 0; margin: 0 0 .9rem; }
.size-picker legend { font-size: .82rem; color: var(--ink-soft); padding: 0 0 .35rem; }
.size-picker { display: flex; flex-wrap: wrap; gap: .5rem; }
.size-picker legend { flex-basis: 100%; }
.size-picker label { flex: 1; }
.size-picker input { position: absolute; opacity: 0; width: 0; }
.size-picker span {
  display: block; text-align: center; padding: .6rem; border-radius: var(--r-sm);
  border: 1px solid var(--line); box-shadow: var(--lift); font-weight: 600;
}
.size-picker input:checked + span { background: var(--jade-700); color: #fff; box-shadow: var(--press); }
.size-picker input:focus-visible + span { outline: 2px solid var(--jade-500); outline-offset: 2px; }

.heat { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .6rem; }
.heat-cell { padding: .6rem .75rem; border-radius: var(--r-sm); border: 1px solid var(--line); }
.heat-cell b { display: block; font-size: .86rem; font-weight: 600; }
.heat-cell span { font-size: .76rem; color: var(--ink-soft); }

/* ---------- Tarjetas ---------- */
.quiz-head { display: grid; gap: .6rem; margin-bottom: 1rem; }
.quiz-meta { display: flex; justify-content: space-between; align-items: center; gap: .6rem; font-size: .85rem; color: var(--ink-soft); }
.progress-bar { height: 6px; background: var(--jade-100); border-radius: 999px; overflow: hidden; }
.progress-bar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--jade-300), var(--jade-500)); transition: width .3s ease; }
.quiz-head .link-btn { width: auto; margin: 0; justify-self: end; font-size: .82rem; }

.card { padding: clamp(1.3rem, 4vw, 2rem); }
.q-text { font-family: var(--serif); font-size: clamp(1.25rem, 3vw, 1.65rem); font-weight: 600; margin-bottom: 1.2rem; }

.options { display: grid; gap: .6rem; }
.opt {
  display: flex; gap: .8rem; align-items: flex-start; width: 100%; text-align: left;
  padding: .85rem 1rem; border-radius: var(--r-sm);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--lift);
  color: var(--ink); transition: transform .12s ease, border-color .12s ease;
}
.opt:hover:not(:disabled) { transform: translateX(3px); border-color: var(--jade-300); }
.opt:disabled { cursor: default; }
.opt .key {
  flex: none; width: 24px; height: 24px; border-radius: 8px; display: grid; place-content: center;
  background: var(--jade-100); color: var(--jade-700); font-size: .78rem; font-weight: 700;
}
html[data-theme="dark"] .opt .key { color: var(--jade-300); }
.opt.correct { border-color: var(--jade-500); background: rgba(18, 160, 119, 0.13); animation: pulse .5s ease; }
.opt.wrong { border-color: var(--coral); background: rgba(207, 75, 75, 0.12); animation: shake .38s ease; }

@keyframes pulse { 0% { transform: scale(1); } 45% { transform: scale(1.025); } 100% { transform: scale(1); } }
@keyframes shake { 0%,100% { transform: translateX(0); } 20% { transform: translateX(-7px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(2px); } }

.feedback {
  margin-top: 1rem; padding: 1.1rem clamp(1.1rem, 3vw, 1.6rem);
  border-radius: var(--r); border: 1px solid var(--line);
  background: var(--surface-glass); backdrop-filter: blur(12px);
  animation: slideup .3s cubic-bezier(.3,.8,.4,1) both;
}
@keyframes slideup { from { opacity: 0; transform: translateY(14px); } }
.verdict { font-weight: 650; margin-bottom: .35rem; }
.verdict.ok { color: var(--jade-700); }
.verdict.no { color: var(--coral); }
html[data-theme="dark"] .verdict.ok { color: var(--jade-300); }
.note { color: var(--ink-soft); font-size: .93rem; }
.note b { color: var(--ink); font-weight: 650; }
.feedback .primary-btn { width: auto; min-width: 160px; margin-top: .5rem; }

.hotkeys { margin-top: 1rem; font-size: .8rem; color: var(--ink-soft); }
kbd {
  font: inherit; font-size: .72rem; padding: .1rem .38rem; margin: 0 .12rem;
  border: 1px solid var(--line); border-radius: 6px; background: var(--surface);
}

/* ---------- Resultados ---------- */
.result-panel { text-align: center; position: relative; overflow: hidden; }
.burst { position: absolute; inset: 0; pointer-events: none; }
.spark {
  position: absolute; width: 8px; height: 8px; border-radius: 2px; opacity: 0;
  animation: spark 1.1s ease-out forwards;
}
@keyframes spark {
  0% { opacity: 1; transform: translateY(0) scale(1) rotate(0); }
  100% { opacity: 0; transform: translateY(180px) scale(.4) rotate(220deg); }
}
.rank { font-family: var(--serif); font-size: clamp(1.5rem, 4vw, 2.1rem); font-weight: 600; margin-bottom: .2rem; }
.result-score { display: flex; align-items: baseline; justify-content: center; gap: .5rem; margin-bottom: .3rem; }
.result-score strong { font-size: 3rem; font-weight: 650; color: var(--jade-700); }
html[data-theme="dark"] .result-score strong { color: var(--jade-300); }
.result-actions { display: flex; gap: .7rem; flex-wrap: wrap; justify-content: center; margin-top: 1.2rem; }
.result-actions button { width: auto; min-width: 200px; }

.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-size: .76rem; color: var(--ink-soft); font-weight: 600; padding: .45rem .5rem; border-bottom: 1px solid var(--line); }
.table td { padding: .55rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr.weak td { background: rgba(207, 75, 75, 0.08); }
.table-scroll { max-height: 420px; overflow: auto; }

/* ---------- Administración ---------- */
.admin-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.admin-head > div { display: flex; gap: .5rem; }
.metric-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .8rem; margin-bottom: 1.1rem; }
.metric {
  padding: .9rem 1rem; border-radius: var(--r); border: 1px solid var(--line);
  background: var(--surface); box-shadow: var(--lift);
}
.metric b { display: block; font-size: 1.6rem; font-weight: 650; }
.metric span { font-size: .78rem; color: var(--ink-soft); }
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem; align-items: start; }
@media (max-width: 900px) { .admin-grid { grid-template-columns: 1fr; } }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .8rem; }
.filters .danger-btn { margin-left: auto; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.editor-actions { display: flex; gap: .6rem; }
.editor-actions .primary-btn { width: auto; min-width: 140px; }
.preview {
  padding: 1rem; border-radius: var(--r); border: 1px dashed var(--line);
  background: var(--bg); margin-bottom: 1.2rem; font-size: .9rem;
}
.preview .pv-q { font-family: var(--serif); font-size: 1.05rem; font-weight: 600; margin-bottom: .6rem; }
.preview ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .3rem; }
.preview li { padding: .35rem .6rem; border-radius: 8px; border: 1px solid var(--line); }
.preview li.is-correct { border-color: var(--jade-500); background: rgba(18, 160, 119, 0.12); }
.row-actions { display: flex; gap: .35rem; }
.row-actions button { padding: .28rem .55rem; font-size: .78rem; background: transparent; border-color: var(--line); color: var(--ink); }
.danger-btn { padding: .42rem .8rem; background: transparent; border-color: #c0392b; color: #c0392b; }
.danger-btn:hover { background: #c0392b; color: #fff; }
.state-on { color: var(--jade-700); font-weight: 600; }
.state-off { color: var(--ink-soft); }
html[data-theme="dark"] .state-on { color: var(--jade-300); }

/* ---------- Modal y avisos ---------- */
dialog {
  border: 1px solid var(--line); border-radius: var(--r); padding: clamp(1.3rem, 4vw, 2rem);
  background: var(--surface); color: var(--ink); max-width: 380px; box-shadow: 0 24px 60px rgba(5, 55, 44, 0.3);
}
dialog::backdrop { background: rgba(5, 30, 24, 0.55); backdrop-filter: blur(3px); }
.modal-id {
  font-size: 2.8rem; font-weight: 680; letter-spacing: .12em; text-align: center;
  color: var(--jade-700); margin: .6rem 0;
}
html[data-theme="dark"] .modal-id { color: var(--jade-300); }
.modal-actions { display: flex; gap: .6rem; margin: 1rem 0; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--jade-900); color: #fff; padding: .6rem 1rem; border-radius: 999px;
  font-size: .88rem; box-shadow: 0 10px 30px rgba(5, 55, 44, 0.35); z-index: 40;
}

/* ---------- Esqueleto de carga ---------- */
.skeleton { border-radius: var(--r-sm); background: linear-gradient(100deg, var(--jade-100) 30%, var(--surface) 50%, var(--jade-100) 70%); background-size: 220% 100%; animation: shimmer 1.2s linear infinite; color: transparent; }
@keyframes shimmer { to { background-position: -220% 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
