:root {
  --ink: #1c2440;
  --muted: #6d7489;
  --paper: #fffdf8;
  --lavender: #ece9ff;
  --purple: #6257df;
  --purple-dark: #453bad;
  --mint: #45ba91;
  --coral: #ee6a6a;
  --sun: #f4b843;
  --line: #e7e5ef;
  --shadow: 0 20px 55px rgba(47, 39, 111, .12);
}

body.dark-mode {
  --ink: #f3f1fc;
  --muted: #b8b4ca;
  --paper: #25243a;
  --lavender: #353255;
  --purple: #aaa1ff;
  --purple-dark: #cbc6ff;
  --mint: #61d3aa;
  --coral: #ff9292;
  --sun: #f5ca63;
  --line: #45435d;
  --shadow: 0 20px 55px rgba(0, 0, 0, .28);
  background: radial-gradient(circle at 5% 5%, #252248 0, transparent 25rem), radial-gradient(circle at 95% 75%, #173b34 0, transparent 24rem), #181724;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: #f7f6fb; }
body { margin: 0; min-height: 100vh; color: var(--ink); background: radial-gradient(circle at 5% 5%, #eeebff 0, transparent 25rem), radial-gradient(circle at 95% 75%, #e3f9f0 0, transparent 24rem), #f9f8fc; font-family: "DM Sans", sans-serif; transition: background .25s, color .25s; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.app-shell { width: min(100% - 32px, 1050px); margin: 0 auto; padding: 54px 0 44px; }
.screen { animation: appear .35s ease both; }
.hidden { display: none !important; }
.theme-toggle { position: fixed; top: 20px; right: 24px; z-index: 5; display: flex; align-items: center; gap: 8px; padding: 9px 13px; color: var(--ink); border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.78); box-shadow: 0 5px 16px rgba(33, 30, 70, .08); font-size: .76rem; font-weight: 700; backdrop-filter: blur(8px); }.theme-toggle:hover { transform: translateY(-1px); }.theme-icon { display: grid; place-items: center; width: 18px; height: 18px; color: var(--purple); font-size: 1.15rem; line-height: 1; }
.hero { max-width: 665px; margin: 0 auto 36px; text-align: center; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; margin: 0 auto 19px; color: white; border-radius: 13px; background: linear-gradient(145deg, #8279f1, #5548cf); box-shadow: 0 7px 17px rgba(84,72,207,.3); font-family: Fraunces, serif; font-size: 24px; font-weight: 700; transform: rotate(-7deg); }
.eyebrow { margin: 0 0 7px; color: var(--purple); font-size: .73rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
h1, h2 { font-family: Fraunces, Georgia, serif; }
h1 { margin: 0; font-size: clamp(2.55rem, 6vw, 4.6rem); letter-spacing: -.065em; line-height: .98; }
h1 em { color: var(--purple); font-style: normal; }
.hero-copy { max-width: 560px; margin: 18px auto 0; color: var(--muted); font-size: 1.04rem; line-height: 1.6; }
.setup-grid { display: grid; grid-template-columns: 1fr 1.22fr; gap: 18px; align-items: stretch; }
.panel, .prompt-card, .summary-card { border: 1px solid rgba(224,221,237,.9); border-radius: 22px; background: rgba(255,255,255,.88); box-shadow: 0 10px 32px rgba(37,35,82,.045); }
.panel { padding: 25px; }
.panel-heading { display: flex; align-items: center; gap: 11px; margin-bottom: 21px; }
.step { display: grid; place-items: center; width: 24px; height: 24px; color: var(--purple); border-radius: 50%; background: var(--lavender); font-size: .7rem; font-weight: 700; }
h2 { margin: 0; font-size: 1.43rem; letter-spacing: -.035em; }
.fields-grid { display: grid; gap: 16px; }
.fields-grid > label, .field-group { display: grid; gap: 7px; font-size: .82rem; font-weight: 700; }
input[type="number"], select, textarea { width: 100%; color: var(--ink); border: 1px solid var(--line); border-radius: 10px; outline: none; background: white; transition: border .2s, box-shadow .2s; }
input[type="number"], select { height: 43px; padding: 0 12px; }
textarea { min-height: 160px; padding: 13px; resize: vertical; font-family: "SFMono-Regular", Consolas, monospace; font-size: .78rem; line-height: 1.55; }
input:focus, select:focus, textarea:focus { border-color: #8a82e9; box-shadow: 0 0 0 3px rgba(98,87,223,.13); }
.input-with-toggle { display: flex; gap: 9px; align-items: center; }
.input-with-toggle input[type="number"] { flex: 1; }
.toggle-label { flex: 0 0 auto; cursor: pointer; }
.toggle-label input { position: absolute; opacity: 0; }
.toggle { display: block; position: relative; width: 41px; height: 24px; border-radius: 20px; background: #c9c6d3; transition: background .2s; }
.toggle::after { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; content: ""; border-radius: 50%; background: white; box-shadow: 0 1px 4px #7776; transition: transform .2s; }
.toggle-label input:checked + .toggle { background: var(--purple); }
.toggle-label input:checked + .toggle::after { transform: translateX(17px); }
.field-hint, .data-status { margin: 15px 0 0; color: var(--muted); font-size: .76rem; line-height: 1.45; }
.source-tabs { display: flex; gap: 4px; margin: -1px 0 14px; padding: 4px; border-radius: 9px; background: #f2f1f6; }
.source-tab { flex: 1; padding: 7px 9px; color: var(--muted); border: 0; border-radius: 6px; background: transparent; font-size: .78rem; font-weight: 600; }
.source-tab.active { color: var(--ink); background: white; box-shadow: 0 2px 5px #28243c12; }
.text-button { margin-top: 9px; padding: 2px 0; color: var(--purple); border: 0; background: none; font-size: .78rem; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.file-drop { display: flex; min-height: 160px; align-items: center; justify-content: center; gap: 14px; padding: 20px; color: var(--muted); border: 1.5px dashed #c9c5e7; border-radius: 12px; background: #faf9ff; text-align: left; cursor: pointer; transition: background .2s, border .2s; }
.file-drop:hover, .file-drop.dragover { border-color: var(--purple); background: #f2f0ff; }
.file-drop input { display: none; }
.file-drop strong, .file-drop small { display: block; }
.file-drop strong { color: var(--purple); font-size: .9rem; }
.file-drop small { margin-top: 4px; font-size: .75rem; }
.upload-icon { display: grid; place-items: center; width: 37px; height: 37px; color: white; border-radius: 50%; background: var(--purple); font-size: 21px; }
.data-status.valid { color: #18835e; }
.data-status.invalid { color: #bd4141; }
.prompt-card { margin-top: 18px; overflow: hidden; }
.prompt-card summary { display: flex; align-items: center; gap: 9px; padding: 17px 22px; list-style: none; cursor: pointer; font-size: .9rem; font-weight: 700; }
.prompt-card summary::-webkit-details-marker { display: none; }
.sparkle { color: var(--purple); }
.summary-arrow { margin-left: auto; font-size: 1.2rem; transition: transform .2s; }
.prompt-card[open] .summary-arrow { transform: rotate(180deg); }
.prompt-content { padding: 0 22px 21px; }
.prompt-content p { margin: 0 0 11px; color: var(--muted); font-size: .84rem; line-height: 1.5; }
pre { margin: 0; padding: 13px; overflow: auto; white-space: pre-wrap; color: #3c386b; border-radius: 11px; background: #f3f1ff; font: .76rem/1.55 "SFMono-Regular", Consolas, monospace; }
.primary-button, .secondary-button { border-radius: 11px; font-weight: 700; transition: transform .18s, box-shadow .18s, background .18s; }
.primary-button { display: flex; align-items: center; justify-content: center; gap: 12px; min-height: 52px; color: white; border: 0; background: linear-gradient(110deg, var(--purple), #796fe7); box-shadow: 0 10px 20px rgba(98,87,223,.24); }
.primary-button:hover { transform: translateY(-2px); box-shadow: 0 13px 24px rgba(98,87,223,.3); }
.primary-button span { font-size: 1.2em; }
.secondary-button { padding: 9px 13px; color: var(--purple); border: 1px solid #d9d5f6; background: #faf9ff; font-size: .8rem; }
.secondary-button:hover { background: var(--lavender); }
.setup-screen > .primary-button { width: min(100%, 380px); margin: 23px auto 0; }

/* Estudio */
.study-screen { min-height: calc(100vh - 98px); display: flex; flex-direction: column; }
.study-header { display: grid; grid-template-columns: 42px 1fr 60px; gap: 14px; align-items: center; width: min(100%, 720px); margin: 0 auto; }
.icon-button { display: grid; place-items: center; width: 38px; height: 38px; color: var(--muted); border: 1px solid var(--line); border-radius: 50%; background: #fff; font-size: 1.6rem; line-height: 1; }
.progress-wrap p { margin: 0 0 7px; color: var(--muted); font-size: .75rem; font-weight: 700; text-align: center; }
.progress-track { height: 7px; overflow: hidden; border-radius: 10px; background: #e9e7ef; }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--purple); transition: width .35s ease; }
.timer-wrap { display: flex; align-items: baseline; justify-content: center; min-height: 42px; color: var(--purple); border-radius: 11px; background: #eeecff; font-weight: 700; }
.timer-wrap span { font-size: 1.32rem; }.timer-wrap small { font-size: .7rem; }.timer-wrap.warning { color: #c45151; background: #ffe9e9; }
.study-stage { display: flex; flex: 1; flex-direction: column; align-items: center; justify-content: center; min-height: 450px; }
.swipe-hint { margin: 0 0 17px; color: var(--muted); font-size: .8rem; }
.card-stack { position: relative; width: min(86vw, 480px); height: min(58vh, 345px); min-height: 285px; perspective: 1300px; }
.card-stack::before, .card-stack::after { position: absolute; inset: 9px -4px -8px 4px; z-index: -2; content: ""; border: 1px solid #e5e2ee; border-radius: 24px; background: #f4f2f8; transform: rotate(1deg); }.card-stack::after { inset: 4px 3px -4px -2px; z-index: -1; background: #fbfaff; transform: rotate(-.7deg); }
.flashcard { position: relative; width: 100%; height: 100%; cursor: grab; transform-style: preserve-3d; transition: transform .4s cubic-bezier(.2,.7,.2,1), opacity .25s; user-select: none; touch-action: none; }
.flashcard:focus-visible { outline: 3px solid #a8a0f2; outline-offset: 5px; border-radius: 24px; }
.flashcard.flipped { transform: rotateY(180deg); }
.flashcard.dragging { cursor: grabbing; transition: none; }
.flashcard.swipe-left { opacity: 0; transform: translateX(-130%) rotate(-16deg); }
.flashcard.swipe-right { opacity: 0; transform: translateX(130%) rotate(16deg); }
.flashcard.swipe-down { opacity: 0; transform: translateY(100%) rotate(3deg); }
.card-face { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 38px; overflow: hidden; border: 1px solid #e1deed; border-radius: 24px; backface-visibility: hidden; background: var(--paper); box-shadow: var(--shadow); text-align: center; }
.card-back { background: linear-gradient(145deg, #655add, #4f44c4); color: white; transform: rotateY(180deg); }.card-back .card-label, .card-back .flip-note { color: #d9d5ff; }
.card-label { position: absolute; top: 23px; color: var(--purple); font-size: .68rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.card-face p { margin: 0; font-family: Fraunces, Georgia, serif; font-size: clamp(1.65rem, 5vw, 2.8rem); font-weight: 600; letter-spacing: -.04em; line-height: 1.16; }
.flip-note { position: absolute; bottom: 19px; color: var(--muted); font-size: .71rem; }
.swipe-stamp { position: absolute; z-index: 3; display: none; padding: 7px 11px; border: 3px solid; border-radius: 7px; font-size: 1.2rem; font-weight: 700; letter-spacing: .05em; }.no-stamp { top: 35px; right: 27px; color: var(--coral); transform: rotate(14deg); }.yes-stamp { top: 35px; left: 27px; color: var(--mint); transform: rotate(-14deg); }.review-stamp { bottom: 48px; left: 50%; color: var(--sun); transform: translateX(-50%) rotate(-3deg); }
.keyboard-hint { margin: 23px 0 0; color: #9592a2; font-size: .7rem; }
.answer-controls { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; width: min(100%, 630px); margin: 12px auto 10px; }.answer-btn { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 11px 8px; border: 1px solid; border-radius: 15px; background: white; font-size: .73rem; transition: transform .16s, background .16s; }.answer-btn:hover { transform: translateY(-3px); }.answer-btn span { font-size: 1.3rem; line-height: 1; }.knew { color: #22C55E; border-color: #22C55E; }.knew:hover { background: #edfbf5; }.review { color: #F59E0B; border-color: #F59E0B; }.review:hover { background: #fff9ea; }.missed { color: #EF4444; border-color: #EF4444; }.missed:hover { background: #fff0f0; }

/* Resumen */
.summary-screen { display: grid; min-height: calc(100vh - 98px); place-items: center; }.summary-card { width: min(100%, 520px); padding: 44px 34px; text-align: center; }.summary-card h2 { font-size: clamp(2rem, 6vw, 3rem); }.summary-card > p:not(.eyebrow) { color: var(--muted); }.score-ring { display: grid; place-content: center; width: 145px; height: 145px; margin: 28px auto; border-radius: 50%; background: conic-gradient(var(--mint) var(--score, 0%), #eeeef3 0); position: relative; }.score-ring::before { position: absolute; inset: 10px; content: ""; border-radius: 50%; background: white; }.score-ring strong, .score-ring span { z-index: 1; }.score-ring strong { font-size: 2rem; }.score-ring span { color: var(--muted); font-size: .7rem; }.stats { display: grid; grid-template-columns: repeat(3, 1fr); margin: 0 -10px 28px; }.stats div { display: grid; place-items: center; gap: 3px; border-right: 1px solid var(--line); }.stats div:last-child { border: 0; }.stats strong { font-size: 1.4rem; }.stats small { color: var(--muted); font-size: .7rem; }.stat-dot { width: 9px; height: 9px; border-radius: 50%; }.knew-dot { background: var(--mint); }.review-dot { background: var(--sun); }.missed-dot { background: var(--coral); }.summary-actions { display: grid; gap: 10px; }.summary-actions .primary-button { width: 100%; }
.toast { position: fixed; bottom: 24px; left: 50%; z-index: 10; max-width: calc(100vw - 30px); padding: 11px 16px; color: white; border-radius: 9px; background: #252840; box-shadow: 0 10px 25px #24253c40; font-size: .83rem; opacity: 0; pointer-events: none; transform: translate(-50%, 18px); transition: opacity .22s, transform .22s; }.toast.show { opacity: 1; transform: translate(-50%, 0); }.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
@keyframes appear { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: translateY(0); } }
@media (max-width: 700px) { .app-shell { padding-top: 33px; }.setup-grid { grid-template-columns: 1fr; }.panel { padding: 22px; }.hero { margin-bottom: 26px; }.study-stage { min-height: 420px; }.keyboard-hint { display: none; }.answer-controls { gap: 7px; }.answer-btn { padding: 10px 4px; font-size: .68rem; }.summary-card { padding: 36px 20px; } }
@media (max-width: 390px) { .card-stack { width: 90vw; }.card-face { padding: 28px 22px; }.answer-btn strong { max-width: 67px; }.study-header { gap: 8px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* Paleta nocturna: mantiene la identidad visual sin comprometer contraste. */
body.dark-mode .theme-toggle, body.dark-mode .panel, body.dark-mode .prompt-card, body.dark-mode .summary-card, body.dark-mode .card-face, body.dark-mode .answer-btn, body.dark-mode .icon-button { border-color: var(--line); background: rgba(37,36,58,.92); }
body.dark-mode .source-tabs { background: #2e2d47; }
body.dark-mode .source-tab.active { color: var(--ink); background: #464362; box-shadow: none; }
body.dark-mode input[type="number"], body.dark-mode select, body.dark-mode textarea { background: #1e1e31; }
body.dark-mode .file-drop { background: #232238; border-color: #615d91; }
body.dark-mode .file-drop:hover, body.dark-mode .file-drop.dragover { background: #2d2b48; }
body.dark-mode pre { color: #e6e3ff; background: #272541; }
body.dark-mode .secondary-button { color: #c6c0ff; border-color: #605b91; background: #292740; }
body.dark-mode .card-stack::before { border-color: #334155; background: #151d2d; }.dark-mode .card-stack::after { background: #1e293b; }
body.dark-mode .card-front { color: #F8FAFC; border-color: #334155; background: #0F172A; }
body.dark-mode .card-front .card-label { color: #E2E8F0; }.dark-mode .card-front .flip-note { color: #CBD5E1; }
body.dark-mode .card-back { color: #F3F4F6; border-color: #38BDF8; background: #374151; box-shadow: 0 20px 55px rgba(14, 165, 233, .18); }
body.dark-mode .card-back .card-label, body.dark-mode .card-back .flip-note, body.dark-mode .card-back p { color: #F3F4F6; text-shadow: none; }
body.dark-mode .answer-btn.knew:hover { background: rgba(34, 197, 94, .13); }.dark-mode .answer-btn.review:hover { background: rgba(245, 158, 11, .13); }.dark-mode .answer-btn.missed:hover { background: rgba(239, 68, 68, .13); }
body.dark-mode .progress-track { background: #334155; }.dark-mode .timer-wrap { background: #1e3a5f; }.dark-mode .timer-wrap.warning { background: #4b3038; }
body.dark-mode .score-ring::before { background: #25243a; }.dark-mode .stats div { border-color: var(--line); }
@media (max-width: 700px) { .theme-toggle { top: 12px; right: 14px; }.theme-label { display: none; }.theme-toggle { width: 40px; height: 40px; justify-content: center; padding: 0; } }
