:root {
  color-scheme: dark;
  --bg: #071014;
  --panel: #0d1a20;
  --panel-2: #12232a;
  --line: #24414a;
  --line-soft: #173038;
  --text: #f4f7f5;
  --muted: #93aab1;
  --mint: #72f5c7;
  --mint-deep: #0d3a30;
  --amber: #ffc66d;
  --danger: #ff7c78;
  --blue: #7bc8ff;
  --radius: 14px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; background: var(--bg); color: var(--text); }
body { min-width: 1180px; overflow-x: auto; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(114,245,199,.4);
  outline-offset: 2px;
}

#device-warning { display: none; padding: 20px; background: #241a0d; color: var(--amber); }
#app { min-height: 100vh; }

.language-choice { min-height: 100vh; display: grid; place-items: center; padding: 32px; background: radial-gradient(circle at 50% 35%, #10262b 0, #071014 46%, #04090b 100%); }
.language-panel { width: min(540px, 90vw); padding: 48px; border: 1px solid var(--line); border-radius: 20px; background: rgba(13,26,32,.94); text-align: center; box-shadow: 0 30px 90px rgba(0,0,0,.32); }
.language-panel .brand-mark { margin: 0 auto 22px; }
.language-panel h1 { margin: 8px 0 30px; font-size: clamp(2rem, 5vw, 3.2rem); line-height: 1.08; letter-spacing: -.035em; }
.language-panel h1 span { color: var(--muted); font-weight: 500; }
.language-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.language-actions .btn { min-height: 56px; font-size: 1rem; }

.shell { min-height: 100vh; display: grid; grid-template-columns: 276px 1fr; }
.sidebar {
  padding: 28px 22px;
  border-right: 1px solid var(--line-soft);
  background: linear-gradient(180deg, #09151a 0%, #071014 100%);
  display: flex;
  flex-direction: column;
  gap: 28px;
}
.brand { display: flex; gap: 12px; align-items: center; }
.brand-mark {
  width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 12px;
  display: grid; place-items: center; color: var(--mint); background: var(--panel);
}
.brand-mark svg { width: 25px; height: 25px; }
.brand strong { display: block; font-size: .95rem; letter-spacing: .02em; }
.brand span { display: block; margin-top: 3px; color: var(--muted); font-size: .78rem; }

.steps { display: grid; gap: 4px; }
.step {
  display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 8px;
  min-height: 42px; padding: 7px 9px; border-radius: 9px; color: var(--muted); font-size: .88rem;
}
.step .index { width: 24px; height: 24px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; font-size: .72rem; }
.step.active { background: var(--panel-2); color: var(--text); }
.step.active .index { border-color: var(--mint); color: var(--mint); }
.step.done { color: #b7c8cc; }
.step.done .index { background: var(--mint-deep); border-color: #287360; color: var(--mint); }
.step small { color: var(--amber); font-size: .7rem; }
.sidebar-foot { margin-top: auto; font-size: .75rem; color: #6f8991; line-height: 1.5; }

.workspace { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  min-height: 74px; padding: 16px 34px; border-bottom: 1px solid var(--line-soft);
  display: flex; justify-content: space-between; align-items: center;
}
.eyebrow { margin: 0 0 5px; color: var(--mint); font-size: .72rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.topbar h1 { margin: 0; font-size: 1.18rem; font-weight: 650; }
.session-chip { padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); font: .75rem ui-monospace, SFMono-Regular, Menlo, monospace; }
.content { width: min(1100px, calc(100vw - 320px)); margin: 0 auto; padding: 46px 36px 80px; }
.content.narrow { width: min(820px, calc(100vw - 320px)); }

.page-head { display: flex; justify-content: space-between; gap: 28px; align-items: flex-start; margin-bottom: 30px; }
.page-head h2 { margin: 0 0 9px; font-size: clamp(1.9rem, 3vw, 3rem); line-height: 1.04; letter-spacing: -.035em; }
.page-head p { max-width: 720px; margin: 0; color: var(--muted); line-height: 1.6; }
.version-pill { white-space: nowrap; padding: 7px 10px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: .75rem; }

.card { background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 24px; }
.card + .card { margin-top: 16px; }
.card h3 { margin: 0 0 18px; font-size: 1rem; }
.card p { color: var(--muted); line-height: 1.55; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.field { display: grid; gap: 8px; }
.field.full { grid-column: 1 / -1; }
.field label, .field-label { color: #bdd0d5; font-size: .82rem; font-weight: 600; }
.req::after { content: " · obligatorio"; color: var(--mint); font-size: .68rem; font-weight: 500; }
input, select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 9px; background: #081419; color: var(--text);
}
textarea { min-height: 84px; resize: vertical; }
input::placeholder, textarea::placeholder { color: #55717a; }
.check-row { display: flex; align-items: flex-start; gap: 10px; color: #bdd0d5; font-size: .88rem; line-height: 1.45; }
.check-row input { width: 18px; min-height: 18px; height: 18px; margin-top: 2px; accent-color: var(--mint); }
.actions { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 24px; }
.btn {
  min-height: 44px; padding: 10px 16px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--panel-2); color: var(--text); font-weight: 650;
}
.btn:hover { border-color: #47707b; }
.btn.primary { background: var(--mint); border-color: var(--mint); color: #062018; }
.btn.primary:hover { background: #91ffda; }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.danger { border-color: #6f3b3b; color: #ffc0bd; background: #241416; }
.btn:disabled { cursor: not-allowed; opacity: .42; }
.hint { color: var(--muted); font-size: .8rem; }

.metric { padding: 18px; border: 1px solid var(--line-soft); border-radius: 11px; background: #09161b; }
.metric .label { color: var(--muted); font-size: .75rem; }
.metric strong { display: block; margin-top: 9px; font: 1.35rem ui-monospace, SFMono-Regular, Menlo, monospace; }
.metric small { display: block; margin-top: 5px; color: #6f8991; font-size: .7rem; }
.status-list { display: grid; gap: 1px; overflow: hidden; border: 1px solid var(--line-soft); border-radius: 11px; background: var(--line-soft); }
.status-row { display: grid; grid-template-columns: 1fr auto; gap: 18px; padding: 13px 15px; background: #09161b; align-items: center; }
.status-row span { color: #b9cbd0; font-size: .86rem; }
.badge { padding: 4px 8px; border-radius: 999px; background: #173229; color: var(--mint); font-size: .72rem; font-weight: 700; }
.badge.warn { background: #352718; color: var(--amber); }
.badge.fail { background: #381d20; color: var(--danger); }
.callout { padding: 15px 17px; border-left: 3px solid var(--amber); background: #171811; color: #dfd0b4; line-height: 1.5; font-size: .85rem; }

.task-shell { min-height: 100vh; display: grid; grid-template-rows: 58px 1fr; background: #030708; }
.task-bar { padding: 0 22px; border-bottom: 1px solid #182328; display: flex; align-items: center; justify-content: space-between; color: #778a90; font-size: .78rem; }
.task-bar strong { color: #afc2c7; font-weight: 600; }
.task-stage { display: grid; place-items: center; position: relative; overflow: hidden; }
.task-card { width: min(760px, 70vw); padding: 34px; text-align: center; }
.task-card h2 { margin: 0 0 14px; font-size: 2rem; }
.task-card p { margin: 0 auto 24px; max-width: 600px; color: #a3b6bb; line-height: 1.65; }
.instruction-keys { display: flex; justify-content: center; gap: 22px; margin: 28px 0; }
kbd { min-width: 58px; padding: 12px 16px; border: 1px solid #3a5159; border-bottom-width: 4px; border-radius: 9px; background: #111d21; color: var(--text); font: 700 1.05rem ui-monospace, monospace; }
.canvas-wrap { width: 100%; height: 100%; display: grid; place-items: center; position: relative; }
canvas { display: block; touch-action: none; }
.task-prompt { position: absolute; top: 7%; left: 50%; transform: translateX(-50%); z-index: 3; color: white; font-weight: 700; letter-spacing: .01em; }
.task-progress { width: min(560px, 60vw); height: 4px; border-radius: 4px; background: #152226; overflow: hidden; }
.task-progress > span { display: block; height: 100%; background: var(--mint); transition: width 160ms linear; }
.feedback { min-height: 28px; margin-top: 20px; font-weight: 650; color: var(--mint); }
.feedback.error { color: var(--danger); }
.crt-grid { display: grid; grid-template-columns: repeat(4, 108px); gap: 30px; }
.crt-target { height: 108px; display: grid; place-items: center; border: 2px solid #314149; border-radius: 16px; color: #75888e; font-size: 1.5rem; }
.crt-target.lit { border-color: var(--mint); background: #d9fff1; color: #042319; box-shadow: 0 0 50px rgba(114,245,199,.16); }
.flanker-stimulus { font: 700 clamp(4rem, 8vw, 7rem) ui-monospace, monospace; letter-spacing: -.12em; color: #fff; white-space: pre; }
.slow-prompt { position: absolute; top: 67%; color: var(--amber); font-weight: 700; }
.flanker-transition { color: #789098; font-size: 1rem; letter-spacing: .02em; }
.flanker-second { display: grid; gap: 16px; place-items: center; text-align: center; }
.flanker-command { font-size: 3rem; font-weight: 800; letter-spacing: .08em; }
.flanker-rule-steps { display: grid; gap: 12px; margin: 24px auto 28px; max-width: 620px; text-align: left; }
.flanker-rule-steps > div { display: grid; grid-template-columns: 34px 1fr; gap: 12px; align-items: center; padding: 13px 15px; border: 1px solid #263b43; border-radius: 10px; background: #09161b; color: #c7d5d9; line-height: 1.45; }
.flanker-rule-steps b { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: var(--mint-deep); color: var(--mint); }

.break-screen { text-align: center; }
.break-screen .big-number { margin: 8px 0; font: 4rem ui-monospace, monospace; color: var(--mint); }
.break-screen p { color: var(--muted); }

.df-layout { display: grid; grid-template-columns: 1fr 230px; gap: 28px; align-items: center; }
.df-side { align-self: stretch; padding: 20px; border-left: 1px solid #1b2b31; display: flex; flex-direction: column; justify-content: center; }
.df-side strong { display: block; margin-top: 8px; font: 2rem ui-monospace, monospace; }

.completion { min-height: 100vh; display: grid; place-items: center; background: #050c0f; text-align: center; }
.completion-mark { width: 74px; height: 74px; margin: 0 auto 24px; border-radius: 50%; display: grid; place-items: center; background: var(--mint); color: #05231a; font-size: 2rem; }
.completion h1 { margin: 0 0 12px; font-size: 2.6rem; }
.completion p { color: var(--muted); font-size: 1.05rem; }
.researcher-entry { margin-top: 70px; display: grid; justify-items: center; gap: 10px; color: #536970; font-size: .75rem; }

.modal-backdrop { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: rgba(0,0,0,.76); }
.modal { width: min(700px, 70vw); max-height: 86vh; overflow: auto; padding: 26px; border: 1px solid var(--line); border-radius: 15px; background: var(--panel); box-shadow: 0 24px 80px #000; }
.modal h2 { margin: 0 0 18px; }
.table-wrap { overflow: auto; border: 1px solid var(--line-soft); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: .78rem; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--line-soft); text-align: left; }
th { color: var(--muted); font-weight: 600; }
td { color: #d5e1e4; }
.summary-value { font: .82rem ui-monospace, monospace; }
#toast { position: fixed; right: 20px; bottom: 20px; z-index: 50; padding: 11px 14px; border-radius: 9px; background: #173229; color: var(--mint); opacity: 0; transform: translateY(8px); transition: 180ms ease; pointer-events: none; }
#toast.show { opacity: 1; transform: none; }

@media (max-width: 1179px), (max-height: 719px) {
  #device-warning { display: block; }
  #app { display: none; }
  body { min-width: 0; }
}

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