:root {
  --bg: #f5f7fb; --fg: #111827; --muted: #6b7280; --card: #ffffff; --line: #e5e7eb;
  --primary: #2563eb; --primary-fg: #ffffff; --danger: #dc2626; --ok: #16a34a; --bar: #93c5fd;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #0f172a; --fg: #e5e7eb; --muted: #94a3b8; --card: #1e293b; --line: #334155; --bar: #1d4ed8; }
}
:root[data-theme="dark"] { --bg: #0f172a; --fg: #e5e7eb; --muted: #94a3b8; --card: #1e293b; --line: #334155; --bar: #1d4ed8; }
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--fg); }
a { color: var(--primary); }
main.wrap { max-width: 980px; margin: 0 auto; padding: 16px; }
.narrow { max-width: 420px; margin: 24px auto; }
.nav { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.nav a { text-decoration: none; font-weight: 600; }
.nav .brand { font-size: 1.15rem; }
.spacer { flex: 1; }
h2 { margin: 8px 0 12px; }
h3 { margin: 4px 0 8px; }
.muted { color: var(--muted); }
.tagline { text-align: center; color: var(--muted); }
.error { color: var(--danger); font-weight: 600; margin: 4px 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 10px 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.grid .card { margin: 0; }
.form { display: flex; flex-direction: column; gap: 10px; }
input, textarea, select { font: inherit; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); width: 100%; }
input[type=radio], input[type=checkbox] { width: auto; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row > input { flex: 1; }
.btn { display: inline-block; font: inherit; font-weight: 600; padding: 10px 16px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--fg); cursor: pointer; text-decoration: none; }
.btn.primary { background: var(--primary); color: var(--primary-fg); border-color: var(--primary); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 10px; font-size: .9rem; }
.table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius); overflow: hidden; }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.right { text-align: right; white-space: nowrap; }
.right .btn { margin-left: 6px; }
.scroll { overflow-x: auto; }
.qtext { font-weight: 600; margin: 4px 0; }
.qtext.big { font-size: 1.3rem; }
.qchoices { margin: 6px 0; padding-left: 22px; }
.qchoices li.ok { color: var(--ok); font-weight: 600; }
.choice .radio { white-space: nowrap; font-weight: 600; }
.qpick { display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
.qpick label { display: flex; gap: 8px; align-items: center; }
.badge { display: inline-block; min-width: 22px; text-align: center; background: var(--primary); color: #fff; border-radius: 999px; font-size: .8rem; }
.badge:empty { display: none; }

/* barras de resultados */
.bars { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.barrow { display: grid; grid-template-columns: 34px 1fr 40px; align-items: center; gap: 8px; }
.barrow .letter { font-weight: 800; font-size: 1.2rem; text-align: center; }
.barwrap { position: relative; background: var(--line); border-radius: 8px; height: 38px; overflow: hidden; }
.barwrap .fill { position: absolute; inset: 0 auto 0 0; background: var(--bar); transition: width .4s; }
.barwrap .ctext { position: absolute; inset: 0; display: flex; align-items: center; padding: 0 10px; font-weight: 600; }
.barrow .count { font-weight: 700; text-align: right; }
.barrow.correct .fill { background: var(--ok); }
.barrow.correct .ctext { color: #fff; }
.barrow.dim { opacity: .45; }
.bars.big .barwrap { height: 64px; }
.bars.big .letter, .bars.big .count { font-size: 2rem; }
.bars.big .ctext { font-size: 1.6rem; }
.bars.big .barrow { grid-template-columns: 56px 1fr 64px; }

/* cámara */
.camera { position: relative; max-width: 640px; margin-top: 8px; }
.camera video { width: 100%; display: none; border-radius: 8px; background: #000; }
.camera video.on { display: block; }
.camera .overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.chip { padding: 4px 10px; border-radius: 999px; background: var(--line); font-size: .85rem; }
.chip.done { background: #bbf7d0; color: #14532d; }
.dot { display: inline-block; min-width: 24px; text-align: center; border-radius: 6px; margin-right: 3px; font-weight: 700; padding: 0 4px; }
.dot.ok { background: #bbf7d0; color: #14532d; }
.dot.bad { background: #fecaca; color: #7f1d1d; }
.dot.none { color: var(--muted); }

/* proyección */
body.presenting .nav { display: none; }
.present { padding: 8px 4vw; }
.qtext.xl { font-size: clamp(1.6rem, 4vw, 3rem); line-height: 1.2; }

/* tarjetas imprimibles */
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, 8.6cm); gap: 0; justify-content: center; }
.pcard { position: relative; width: 8.6cm; height: 8.6cm; border: 1px dashed #888; background: #fff; color: #000; break-inside: avoid; page-break-inside: avoid; }
.pcard .pmk { position: absolute; left: 1.5cm; top: 1.5cm; width: 5.6cm; height: 5.6cm; }
.pcard .pmk svg { width: 100%; height: 100%; display: block; }
.pl { position: absolute; font: 800 1.1cm/1 system-ui, sans-serif; width: 1.5cm; height: 1.5cm; display: flex; align-items: center; justify-content: center; }
.pl.top { top: 0; left: 3.55cm; }
.pl.bottom { bottom: 0; left: 3.55cm; transform: rotate(180deg); }
.pl.right { right: 0; top: 3.55cm; transform: rotate(90deg); }
.pl.left { left: 0; top: 3.55cm; transform: rotate(-90deg); }
.pno { position: absolute; left: .25cm; top: .2cm; font: 700 .55cm/1 system-ui, sans-serif; }
.pnm { position: absolute; right: .25cm; bottom: .2cm; font: .38cm/1 system-ui, sans-serif; max-width: 3cm; text-align: right; overflow: hidden; white-space: nowrap; }
@media print {
  body { background: #fff; }
  .noprint, .nav { display: none !important; }
  main.wrap { max-width: none; padding: 0; }
  .pgrid { grid-template-columns: repeat(2, 8.6cm); }
  @page { size: A4; margin: 1.2cm; }
}
@media (max-width: 520px) {
  main.wrap { padding: 12px; }
  .barrow { grid-template-columns: 28px 1fr 32px; }
}

/* pantalla remota y código de sesión */
.code { font: 800 1.6rem/1 ui-monospace, Menlo, Consolas, monospace; letter-spacing: .12em; color: var(--primary); }
.small-url { word-break: break-all; font-size: .85rem; margin: 4px 0 8px; }
.codeinput { text-align: center; font: 700 1.6rem ui-monospace, Menlo, Consolas, monospace; letter-spacing: .15em; text-transform: uppercase; }
.fs { position: fixed; right: 12px; bottom: 12px; opacity: .5; }
.fs:hover { opacity: 1; }
body.presenting .fs { display: inline-block; }
:fullscreen .fs { display: none; }

/* controles cómodos en el celular durante la sesión */
@media (max-width: 640px) {
  .row.wrap.ctrls .btn { flex: 1 1 calc(50% - 8px); text-align: center; padding: 14px 10px; }
  .qtext.big { font-size: 1.15rem; }
}
.center { text-align: center; }

/* ===== Encabezado, sidebar y barra inferior ===== */
.nav { justify-content: space-between; }
.avatar { width: 38px; height: 38px; border-radius: 50%; border: 2px solid var(--line); background: var(--primary); color: #fff; font: 700 1rem/1 system-ui, sans-serif; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.avatar:hover, .avatar:focus-visible { border-color: var(--primary); outline: none; }
.avatar.big { width: 56px; height: 56px; font-size: 1.4rem; cursor: default; flex: none; }

.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 20; }
.sidebar { position: fixed; top: 0; right: 0; bottom: 0; width: min(320px, 88vw); background: var(--card); border-left: 1px solid var(--line); z-index: 21; display: flex; flex-direction: column; transform: translateX(105%); transition: transform .22s ease; box-shadow: -8px 0 24px rgba(0, 0, 0, .18); padding-top: env(safe-area-inset-top); }
.sidebar.open { transform: translateX(0); }
.sb-head { display: flex; align-items: center; gap: 12px; padding: 18px 16px; border-bottom: 1px solid var(--line); }
.sb-head .who { min-width: 0; }
.sb-head .who strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-head .who span { display: block; color: var(--muted); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-close { margin-left: auto; background: none; border: 0; color: var(--muted); font-size: 1.6rem; line-height: 1; cursor: pointer; padding: 4px 8px; }
.sb-body { flex: 1; overflow-y: auto; padding: 10px 8px; }
.sb-section { margin: 14px 10px 4px; font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.sb-link { display: flex; align-items: center; gap: 10px; width: 100%; padding: 11px 12px; border: 0; border-radius: 10px; background: none; color: var(--fg); font: inherit; text-align: left; text-decoration: none; cursor: pointer; }
.sb-link:hover, .sb-link.active { background: var(--bg); }
.sb-link.active { color: var(--primary); font-weight: 600; }
.sb-link.danger { color: var(--danger); }
.sb-foot { padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); color: var(--muted); font-size: .8rem; }

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; justify-content: center; gap: 4px; background: var(--card); border-top: 1px solid var(--line); padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); }
.tabbar[hidden] { display: none; }
.tab { flex: 1; max-width: 200px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px; border-radius: 10px; color: var(--muted); text-decoration: none; font-size: .78rem; font-weight: 600; }
.tab svg { width: 24px; height: 24px; }
.tab:hover { background: var(--bg); }
.tab.active { color: var(--primary); }
body.has-tabbar main.wrap { padding-bottom: calc(88px + env(safe-area-inset-bottom)); }
body.presenting .tabbar, body.presenting .sidebar, body.presenting .scrim { display: none; }
@media print { .tabbar, .sidebar, .scrim { display: none !important; } }

/* ===== Cuenta y configuración ===== */
.settings { max-width: 640px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-weight: 600; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { font: inherit; padding: 9px 16px; border: 0; background: var(--card); color: var(--fg); cursor: pointer; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--primary); color: #fff; font-weight: 600; }
.switch { display: flex; align-items: center; gap: 10px; }
.danger-zone { border-color: var(--danger); }
.ok { color: var(--ok); font-weight: 600; margin: 4px 0; }
.help ol { padding-left: 20px; }
.help li { margin: 6px 0; }

/* ===== Conjuntos de preguntas ===== */
.setbar { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.chip-btn { font: inherit; font-size: .9rem; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--fg); cursor: pointer; }
.chip-btn:hover { border-color: var(--primary); }
.chip-btn.on { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.setactions { margin-bottom: 8px; }
.tag { display: inline-block; font-size: .75rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); color: var(--muted); margin-bottom: 4px; }
.qgroup { margin-bottom: 10px; }
.qgroup-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--line); margin-bottom: 6px; }

/* Pantallas con muesca o barra de estado (PWA instalada): respeta las áreas seguras */
.nav { padding-top: calc(10px + env(safe-area-inset-top)); padding-left: calc(16px + env(safe-area-inset-left)); padding-right: calc(16px + env(safe-area-inset-right)); }

/* ===== Tiempo real: aviso, avance de escaneo y lista de alumnos ===== */
.banner { position: fixed; left: 12px; right: 12px; bottom: calc(86px + env(safe-area-inset-bottom)); z-index: 12; display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--card); border: 1px solid var(--primary); border-radius: 12px; box-shadow: 0 6px 20px rgba(0, 0, 0, .25); max-width: 560px; margin: 0 auto; }
.banner[hidden] { display: none; }
.bn-text { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bn-close { background: none; border: 0; color: var(--muted); font-size: 1.4rem; line-height: 1; cursor: pointer; padding: 2px 6px; }
body.presenting .banner { display: none; }
.pbar { position: relative; height: 14px; background: var(--line); border-radius: 999px; overflow: hidden; margin: 6px 0 10px; }
.pbar .pfill { position: absolute; inset: 0 auto 0 0; background: var(--primary); transition: width .35s; }
.pbar.big { height: 36px; margin: 14px 0; }
.pbar .ptext { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: 700; color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, .5); }
.roster { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 70px; }
.rchip { padding: 6px 12px; border-radius: 999px; background: var(--line); color: var(--muted); font-weight: 600; font-size: clamp(.85rem, 1.6vw, 1.1rem); transition: background .25s, color .25s; }
.rchip.done { background: var(--primary); color: #fff; }
.rchip.done.ok { background: var(--ok); }
.rchip.done.bad { background: var(--danger); }
.screenbar { position: fixed; right: 12px; bottom: 12px; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; opacity: .6; }
.screenbar:hover { opacity: 1; }

/* ===== Editor de preguntas ===== */
.small { font-size: .85rem; }
.center { text-align: center; }
.ed-head { align-items: center; margin-bottom: 8px; }
.ed-title { margin: 0; font-size: 1.3rem; }
.save-status { font-size: .85rem; color: var(--muted); min-width: 96px; text-align: right; }
.save-status.ok { color: var(--ok); }
.save-status.bad { color: var(--danger); }
.editor { display: flex; gap: 16px; align-items: flex-start; }
.slides { width: 230px; flex: none; display: flex; flex-direction: column; gap: 6px; max-height: calc(100vh - 230px); overflow-y: auto; position: sticky; top: 70px; padding-right: 2px; }
.slide { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--fg); font: inherit; cursor: pointer; }
.slide.on { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(37, 99, 235, .3); }
.slide .sn { flex: none; width: 24px; height: 24px; border-radius: 6px; background: var(--bg); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem; }
.slide .st { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9rem; }
.slide .tag { margin: 0; flex: none; }
.slide.add { justify-content: center; border-style: dashed; color: var(--primary); font-weight: 600; }
.tag.warn { color: #b45309; border-color: #f59e0b; }
.stage { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.tbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tgroup { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.tb { min-width: 38px; height: 36px; border: 0; border-right: 1px solid var(--line); background: var(--card); color: var(--fg); font: 600 1rem system-ui, sans-serif; cursor: pointer; }
.tb:last-child { border-right: 0; }
.tb:hover { background: var(--bg); }
.tb-i { font-style: italic; }
.tb-u { text-decoration: underline; }
.seg.icons button { padding: 6px 10px; display: inline-flex; align-items: center; }
.seg.icons svg { width: 20px; height: 20px; }
.qedit { min-height: 120px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); font-size: 1.35rem; line-height: 1.4; outline: none; word-break: break-word; }
.qedit:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(37, 99, 235, .3); }
.qedit:empty::before { content: attr(data-placeholder); color: var(--muted); }
.qedit h3 { margin: .2em 0; font-size: 1.6rem; }
.qedit.layout-center, .qedit.layout-grid { text-align: center; }
.choices-edit { display: flex; flex-direction: column; gap: 8px; }
.crow { display: flex; align-items: center; gap: 8px; }
.crow input { flex: 1; }
.cletter { width: 40px; height: 40px; flex: none; border: 2px solid var(--line); border-radius: 8px; background: var(--card); color: var(--fg); font: 700 1.1rem system-ui, sans-serif; cursor: pointer; }
.cletter.on { background: var(--ok); border-color: var(--ok); color: #fff; }
.cletter:disabled { cursor: default; opacity: .7; }
.ctf { flex: 1; font-weight: 600; }
.preview { margin-top: 8px; padding: 12px; border: 1px dashed var(--line); border-radius: 12px; }
.qprev-text { font-size: 1.4rem; font-weight: 600; margin: 6px 0 12px; word-break: break-word; }
.qprev-text h3, .qtext h3 { margin: .2em 0; }
.qprev-choices { display: flex; flex-direction: column; gap: 8px; }
.qprev-choice { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; }
.qprev-choice.correct { border-color: var(--ok); }
.ql { width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; border: 2px solid var(--line); border-radius: 6px; font-weight: 700; flex: none; }
.qprev.layout-center .qprev-choices, .qprev.layout-grid .qprev-choices { display: grid; grid-template-columns: 1fr 1fr; }
.qprev.layout-grid .qprev-choice { min-height: 90px; justify-content: center; text-align: center; flex-direction: column; }
.qprev-text.layout-center, .qprev-text.layout-grid, .qtext.layout-center, .qtext.layout-grid { text-align: center; }
.bars.layout-center, .bars.layout-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; }
.qtext b, .qprev-text b { font-weight: 800; }
@media (max-width: 760px) {
  .editor { flex-direction: column; }
  .slides { width: 100%; flex-direction: row; overflow-x: auto; overflow-y: hidden; position: static; max-height: none; }
  .slide { flex: none; width: 170px; }
}

/* ===== Imágenes y GIF ===== */
.qblock { display: block; }
.qblock.layout-center, .qblock.layout-grid { text-align: center; }
.qimg { display: block; max-width: 100%; max-height: 46vh; height: auto; margin: 10px 0; border-radius: 10px; object-fit: contain; }
.qblock.layout-center .qimg, .qblock.layout-grid .qimg, .qprev.layout-center .qimg, .qprev.layout-grid .qimg { margin-left: auto; margin-right: auto; }
.present .qimg { max-height: 34vh; }
.qprev.layout-center .qprev-text, .qprev.layout-grid .qprev-text { text-align: center; }
.cthumb { height: 56px; width: auto; max-width: 96px; border-radius: 6px; object-fit: contain; background: rgba(127, 127, 127, .12); flex: none; }
.barrow.hasimg .barwrap { height: 72px; }
.barrow.hasimg .barwrap .cthumb { position: absolute; left: 6px; top: 8px; z-index: 1; }
.barrow.hasimg .ctext { padding-left: 112px; }
.bars.big .barrow.hasimg .barwrap { height: 110px; }
.bars.big .barrow.hasimg .barwrap .cthumb { height: 94px; max-width: 160px; }
.bars.big .barrow.hasimg .ctext { padding-left: 180px; }
/* diseño cuadrícula: cada alternativa es una tarjeta con su imagen grande */
.bars.layout-grid .barrow.hasimg { grid-template-columns: 1fr; gap: 6px; text-align: center; }
.bars.layout-grid .barrow.hasimg .barwrap { height: auto; display: flex; flex-direction: column; align-items: center; padding: 8px; background: var(--line); }
.bars.layout-grid .barrow.hasimg .barwrap .cthumb { position: static; height: auto; width: auto; max-width: 100%; max-height: 26vh; }
.bars.layout-grid .barrow.hasimg .ctext { position: static; padding: 6px 4px 0; justify-content: center; }
.bars.layout-grid .barrow.hasimg .fill { opacity: .35; }
.btn svg { width: 18px; height: 18px; vertical-align: middle; }
.qimg-box:empty { display: none; }
.imgthumb { display: flex; align-items: center; gap: 12px; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.imgthumb img { max-height: 120px; max-width: 45%; border-radius: 8px; object-fit: contain; }
.cimg-wrap { display: inline-flex; align-items: center; gap: 2px; }
.cimg-thumb { height: 40px; width: auto; max-width: 70px; border-radius: 6px; object-fit: contain; cursor: pointer; border: 1px solid var(--line); background: var(--card); }
.qprev-choice .cthumb { height: 48px; }
.qprev.layout-grid .qprev-choice .cthumb { height: 110px; max-width: 100%; }
.modal-scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 40; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { width: min(520px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; font-size: 1.1rem; }
.dropzone { border: 2px dashed var(--line); border-radius: 12px; padding: 28px 16px; text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.dropzone.over { border-color: var(--primary); background: rgba(37, 99, 235, .08); }
.dz-title { margin: 0; font-weight: 600; }

/* Los botones de la pantalla en vivo van arriba a la derecha para no tapar resultados */
.screenbar { top: 10px; bottom: auto; }
.fs { top: 10px; bottom: auto; }
.present { padding-bottom: 40px; }

/* Miniatura de alternativa con su botón para quitar la imagen */
.cimg-wrap { position: relative; margin-right: 6px; }
.cimg-x { position: absolute; top: -7px; right: -7px; width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); color: var(--fg); font-size: 13px; line-height: 1; padding: 0; cursor: pointer; }
.cimg-x:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

.linkbox { flex: 1; min-width: 0; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--fg); font: inherit; font-size: 13px; }
.qrbox { display: flex; justify-content: center; margin: 12px 0; }
.qrbox img { background: #fff; padding: 8px; border-radius: 8px; image-rendering: pixelated; }

/* =====================================================================
   NEUMORFISMO (Soft UI): superficie de un solo color, relieve con dos sombras
   (una clara arriba-izquierda y otra oscura abajo-derecha). Elevado = se puede tocar;
   hundido = campos de texto, pistas y zonas de entrada.
   ===================================================================== */
:root {
  --bg: #e4e9f1; --card: #e4e9f1; --fg: #1d2636; --muted: #586277; --line: rgba(110, 125, 150, .24);
  --primary: #2f5fe8; --primary-fg: #ffffff; --link: #2551c9; --danger: #c0302d; --ok: #15803d; --bar: #7aa5f7;
  --sh-d: #bac3d4; --sh-l: #ffffff; --radius: 20px;
  --raise: 8px 8px 18px var(--sh-d), -8px -8px 18px var(--sh-l);
  --raise-s: 4px 4px 9px var(--sh-d), -4px -4px 9px var(--sh-l);
  --raise-xs: 2px 2px 5px var(--sh-d), -2px -2px 5px var(--sh-l);
  --press: inset 5px 5px 10px var(--sh-d), inset -5px -5px 10px var(--sh-l);
  --press-s: inset 3px 3px 6px var(--sh-d), inset -3px -3px 6px var(--sh-l);
  --grad: linear-gradient(145deg, #3d70f7, #2552d6);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #222836; --card: #222836; --fg: #e8ecf5; --muted: #9ba7bd; --line: rgba(150, 165, 195, .22); --primary: #4a78f0; --link: #92b2ff; --danger: #ff7b78; --ok: #4ade80; --bar: #3b66d9; --sh-d: #161a25; --sh-l: #2e3648; --grad: linear-gradient(145deg, #5584f6, #3a64dc); }
}
:root[data-theme="dark"] { --bg: #222836; --card: #222836; --fg: #e8ecf5; --muted: #9ba7bd; --line: rgba(150, 165, 195, .22); --primary: #4a78f0; --link: #92b2ff; --danger: #ff7b78; --ok: #4ade80; --bar: #3b66d9; --sh-d: #161a25; --sh-l: #2e3648; --grad: linear-gradient(145deg, #5584f6, #3a64dc); }

body { background: var(--bg); letter-spacing: .005em; }
a { color: var(--link); }
h2 { font-weight: 800; letter-spacing: -.01em; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; }
main.wrap { padding: 20px 20px 28px; }

/* Encabezado */
.nav { background: var(--bg); border-bottom: 0; box-shadow: 0 6px 16px -6px var(--sh-d); }
.nav .brand { display: inline-flex; align-items: center; gap: 10px; color: var(--fg); font-weight: 800; letter-spacing: -.01em; }
.nav .brand img { width: 28px; height: 28px; border-radius: 8px; box-shadow: var(--raise-xs); }
.avatar { border: 0; background: var(--grad); box-shadow: var(--raise-s); transition: box-shadow .15s; }
.avatar:hover { box-shadow: var(--raise-xs); }
.avatar:active { box-shadow: var(--press-s); }

/* Tarjetas y rejillas */
.card { background: var(--bg); border: 0; border-radius: var(--radius); padding: 20px; margin: 16px 0; box-shadow: var(--raise); }
.grid { gap: 26px; padding: 6px 4px 12px; }
.grid .card { margin: 0; }
.danger-zone { box-shadow: var(--raise), inset 0 0 0 2px var(--danger); }
.narrow { margin: 28px auto; }

/* Campos: hundidos */
input, textarea, select { border: 0; border-radius: 14px; background: var(--bg); box-shadow: var(--press-s); padding: 12px 14px; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .85; }
input[type=radio], input[type=checkbox] { box-shadow: none; accent-color: var(--primary); width: 18px; height: 18px; }
input:focus, textarea:focus, select:focus { outline: 3px solid color-mix(in srgb, var(--primary) 55%, transparent); outline-offset: 1px; }
.linkbox { border: 0; background: var(--bg); box-shadow: var(--press-s); border-radius: 14px; }

/* Botones: elevados; al presionar se hunden */
.btn { border: 0; border-radius: 14px; background: var(--bg); color: var(--fg); box-shadow: var(--raise-s); padding: 11px 18px; transition: box-shadow .15s, transform .15s; }
.btn:hover { box-shadow: var(--raise-xs); }
.btn:active { box-shadow: var(--press-s); transform: translateY(1px); }
.btn.primary { background: var(--grad); color: var(--primary-fg); text-shadow: 0 1px 1px rgba(0, 0, 0, .25); box-shadow: 5px 5px 12px color-mix(in srgb, var(--primary) 38%, var(--sh-d)), -4px -4px 10px var(--sh-l); }
.btn.primary:hover { box-shadow: 3px 3px 8px color-mix(in srgb, var(--primary) 38%, var(--sh-d)), -2px -2px 6px var(--sh-l); }
.btn.primary:active { box-shadow: inset 3px 3px 7px rgba(0, 0, 0, .3), inset -2px -2px 6px rgba(255, 255, 255, .12); }
.btn.danger { color: var(--danger); border: 0; }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.ghost:hover { box-shadow: var(--raise-xs); }
.btn.small { padding: 7px 12px; border-radius: 12px; }
.apkcta { display: inline-flex; align-items: center; gap: 8px; color: var(--link); }
.apkcta::before { content: ""; width: 14px; height: 22px; border: 2px solid currentColor; border-radius: 4px; box-sizing: border-box; }

/* Identidad en la pantalla de acceso */
.authbrand { text-align: center; margin-bottom: 18px; }
.authbrand img { border-radius: 20px; box-shadow: var(--raise); }
.authbrand h1 { margin: 14px 0 2px; font-size: 1.9rem; letter-spacing: -.02em; }
.authbrand .tagline { margin: 0 auto; max-width: 320px; }

/* Tablas */
.table { background: transparent; border-radius: var(--radius); }
.table th { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; }
.table th, .table td { border-bottom: 1px solid var(--line); }
.table tr:last-child td { border-bottom: 0; }

/* Resultados y progreso: pistas hundidas, relleno elevado */
.barwrap { background: var(--bg); box-shadow: var(--press-s); border-radius: 14px; }
.barwrap .fill { background: linear-gradient(90deg, color-mix(in srgb, var(--bar) 80%, #fff), var(--bar)); border-radius: 14px; }
.barrow.correct .fill { background: linear-gradient(90deg, #22a35a, var(--ok)); }
.barrow.correct .ctext { color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, .35); }
.pbar { background: var(--bg); box-shadow: var(--press-s); height: 16px; }
.pbar .pfill { background: var(--grad); border-radius: 999px; }
.pbar.big { height: 38px; }
.bars.layout-grid .barrow.hasimg .barwrap { background: var(--bg); box-shadow: var(--raise-s); }

/* Chips y etiquetas */
.chip, .rchip { background: var(--bg); box-shadow: var(--raise-xs); color: var(--muted); }
.chip.done { background: var(--bg); color: var(--ok); box-shadow: var(--press-s); font-weight: 700; }
.rchip.done { background: var(--grad); color: #fff; box-shadow: var(--raise-xs); }
.rchip.done.ok { background: linear-gradient(145deg, #2cb868, #15803d); }
.rchip.done.bad { background: linear-gradient(145deg, #e5524f, #b52a27); }
.chip-btn { border: 0; background: var(--bg); box-shadow: var(--raise-xs); transition: box-shadow .15s; }
.chip-btn:hover { box-shadow: var(--raise-s); }
.chip-btn.on { background: var(--bg); color: var(--primary); box-shadow: var(--press-s); }
.tag { background: var(--bg); border: 0; box-shadow: var(--press-s); }
.tag.warn { color: #9a4a06; }
.badge { background: var(--grad); }
.dot.ok { background: var(--bg); color: var(--ok); box-shadow: var(--press-s); }
.dot.bad { background: var(--bg); color: var(--danger); box-shadow: var(--press-s); }

/* Selectores segmentados e interruptores */
.seg { border: 0; border-radius: 14px; background: var(--bg); box-shadow: var(--press-s); padding: 4px; gap: 4px; }
.seg button { border: 0; background: transparent; border-radius: 10px; color: var(--muted); }
.seg button.on { background: var(--bg); color: var(--primary); box-shadow: var(--raise-xs); font-weight: 700; }

/* Barra lateral y barra inferior */
.sidebar { background: var(--bg); border-left: 0; box-shadow: none; border-radius: 24px 0 0 24px; }
.sidebar.open { box-shadow: -14px 0 34px rgba(0, 0, 0, .25); }
.sb-head { border-bottom: 0; }
.sb-head .avatar.big { box-shadow: var(--raise); }
.sb-link { border-radius: 14px; margin: 3px 0; transition: box-shadow .15s; }
.sb-link:hover { background: transparent; box-shadow: var(--raise-xs); }
.sb-link.active { background: transparent; box-shadow: var(--press-s); }
.sb-foot { border-top: 0; }
.tabbar { background: var(--bg); border-top: 0; box-shadow: 0 -8px 18px -8px var(--sh-d); padding-top: 10px; }
.tab { border-radius: 16px; transition: box-shadow .15s; }
.tab:hover { background: transparent; box-shadow: var(--raise-xs); }
.tab.active { box-shadow: var(--press-s); }
.banner { background: var(--bg); border: 0; box-shadow: var(--raise); border-radius: 18px; }

/* Editor de preguntas */
.slide { border: 0; background: var(--bg); box-shadow: var(--raise-xs); border-radius: 14px; }
.slide.on { box-shadow: var(--press-s), 0 0 0 2px var(--primary); }
.slide .sn { background: var(--bg); box-shadow: var(--press-s); }
.tgroup { border: 0; border-radius: 12px; box-shadow: var(--raise-xs); background: var(--bg); }
.tb { border-right: 1px solid var(--line); background: transparent; }
.tb:hover { background: transparent; color: var(--primary); }
.qedit { border: 0; border-radius: 18px; background: var(--bg); box-shadow: var(--press); }
.qedit:focus { box-shadow: var(--press), 0 0 0 3px color-mix(in srgb, var(--primary) 55%, transparent); }
.cletter { border: 0; background: var(--bg); box-shadow: var(--raise-xs); border-radius: 12px; color: var(--fg); }
.cletter.on { background: linear-gradient(145deg, #2cb868, #15803d); color: #fff; }
.preview, .dropzone { border: 2px dashed var(--line); border-radius: 18px; box-shadow: var(--press-s); }
.dropzone.over { border-color: var(--primary); }
.qprev-choice { border: 0; box-shadow: var(--raise-xs); border-radius: 14px; }
.qprev-choice.correct { box-shadow: var(--press-s), 0 0 0 2px var(--ok); }
.ql { border: 0; box-shadow: var(--press-s); border-radius: 10px; }
.imgthumb { border: 0; box-shadow: var(--press-s); border-radius: 16px; background: var(--bg); }
.cimg-thumb { border: 0; box-shadow: var(--raise-xs); background: var(--bg); }
.cimg-x { border: 0; background: var(--bg); box-shadow: var(--raise-xs); }
.qpick { border: 0; border-radius: 16px; box-shadow: var(--press-s); }
.qgroup-head { border-bottom-color: var(--line); }
.modal { background: var(--bg); border: 0; border-radius: 24px; box-shadow: var(--raise), 0 30px 60px rgba(0, 0, 0, .35); padding: 22px; }
.qrbox img { box-shadow: var(--raise-s); border-radius: 16px; }
.code { text-shadow: 1px 1px 0 var(--sh-l), -1px -1px 0 var(--sh-d); }

/* Cámara */
.camera video { border-radius: 18px; box-shadow: var(--raise); }

/* Pantalla de proyección: relieve más sobrio */
body.presenting .card { box-shadow: var(--raise-s); }

@media (max-width: 520px) {
  main.wrap { padding: 14px 14px 24px; }
  .card { padding: 16px; box-shadow: var(--raise-s); }
  .grid { gap: 20px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Controles de la cámara */
.camtools { margin: 10px 0 4px; align-items: center; }
.camtools[hidden], .camtools [hidden] { display: none !important; }
.btn.on { color: var(--primary); box-shadow: var(--press-s); }
.zoombox { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.zoomrange { width: 140px; padding: 0; box-shadow: none; background: transparent; accent-color: var(--primary); }

/* Importación: vista previa y guía */
.modal.imp { width: min(680px, 100%); max-height: 90vh; overflow-y: auto; }
.imppreview { padding-left: 20px; margin: 8px 0; }
.impq { margin: 8px 0; word-break: break-word; }
.impq .tag { margin-left: 8px; }
.impwhy { margin: 8px 0; }
.impwhy summary, .impguide summary { cursor: pointer; font-weight: 600; }
.impwhy ul { margin: 6px 0 0; padding-left: 20px; }
.impguide ol { padding-left: 20px; }
.impguide li { margin: 6px 0; }

/* Libreta de notas y administración */
.grade.pass { color: var(--ok); font-weight: 700; }
.grade.fail, strong.fail { color: var(--danger); font-weight: 700; }
strong.pass { color: var(--ok); }
.table.gb th, .table.gb td { white-space: nowrap; text-align: left; }
.table.gb .gbc { text-align: center; }
.table.gb th.gbs { text-align: center; font-size: .8rem; text-transform: none; letter-spacing: 0; }
.table.gb tfoot td { border-top: 2px solid var(--line); }
.table.gb tr td:first-child, .table.gb tr th:first-child { color: var(--muted); }
.scalefields { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
.grid.stats { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 18px; }
.stat { text-align: center; padding: 14px; }
.statn { font-size: 1.8rem; font-weight: 800; color: var(--primary); }
.wk { display: flex; align-items: flex-end; gap: 10px; min-height: 110px; }
.wkc { flex: 1; text-align: center; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; }
.wkb { width: 70%; max-width: 36px; border-radius: 8px 8px 4px 4px; background: var(--grad); box-shadow: var(--raise-xs); }
.wkn { font-weight: 700; font-size: .8rem; }
.wkl { font-size: .7rem; margin-top: 4px; }
input[type=search] { margin: 8px 0; }
button.rchip { border: 0; cursor: pointer; font: inherit; font-weight: 600; font-size: clamp(.85rem, 1.6vw, 1.1rem); }
button.rchip:disabled { cursor: default; opacity: .7; }
.rosterlist { columns: 2; padding-left: 22px; margin: 8px 0; }
.rosterlist li { break-inside: avoid; }
.table td.acts { white-space: normal; min-width: 210px; text-align: right; }
.table td.acts .btn { margin: 2px 0 2px 6px; }
.table td .tag { margin-left: 8px; }

/* Al imprimir no hay relieve */
@media print {
  .card, .btn, input, .chip, .rchip, .nav, .tabbar { box-shadow: none !important; }
  body { background: #fff; }
}
