/* ===== Escuela de Programación — estilos ===== */
:root {
  --bg: #faf7f5;
  --surface: #ffffff;
  --surface-2: #f6f0ed;
  --border: #ece2dd;
  --text: #1b1f2a;
  --muted: #667085;
  --primary: #c8201a;
  --primary-600: #a3150f;
  --primary-50: #fdecea;
  --gold: #f2b705;
  --gold-50: #fff6d6;
  --ok: #2f9e44;
  --ok-50: #ebfbee;
  --warn: #e67700;
  --warn-50: #fff4e6;
  --err: #e03131;
  --err-50: #fff5f5;
  --violet: #8e1410; /* bordó: segundo tono de los degradés */
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .06);
  --radius: 14px;
  --radius-sm: 9px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'Cascadia Code', Consolas, monospace;
  --sidebar: 244px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141011; --surface: #1d1718; --surface-2: #271f20; --border: #3a2e2f;
    --text: #f1e9e7; --muted: #b3a3a0; --primary: #f0544a; --primary-600: #ff7d73; --primary-50: #3a1816; --violet: #b3241c; --gold: #f5c431; --gold-50: #3a2f10;
    --ok-50: #11261a; --warn-50: #2b1f0e; --err-50: #2c1416; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141011; --surface: #1d1718; --surface-2: #271f20; --border: #3a2e2f;
  --text: #f1e9e7; --muted: #b3a3a0; --primary: #f0544a; --primary-600: #ff7d73; --primary-50: #3a1816; --violet: #b3241c; --gold: #f5c431; --gold-50: #3a2f10;
  --ok-50: #11261a; --warn-50: #2b1f0e; --err-50: #2c1416; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; }
h2 { font-size: 1.2rem; font-weight: 700; }
h3 { font-size: 1.02rem; font-weight: 700; }
p { margin: 0 0 .8em; }
code, pre, kbd { font-family: var(--mono); font-size: .88em; }
:not(pre) > code { background: var(--surface-2); border: 1px solid var(--border); padding: .08em .35em; border-radius: 5px; }
pre { background: var(--surface-2); border: 1px solid var(--border); padding: 10px 12px; border-radius: var(--radius-sm); overflow: auto; white-space: pre-wrap; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hidden { display: none !important; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.stack > * + * { margin-top: 12px; }

/* ===== Botones y formularios ===== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 8px 14px; border-radius: 10px; font: inherit; font-weight: 600; font-size: .92rem; cursor: pointer; transition: background .15s, border-color .15s, transform .05s; white-space: nowrap; text-decoration: none !important; }
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-600); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { color: var(--err); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 5px 10px; font-size: .84rem; border-radius: 8px; }
.btn.block { width: 100%; }
.icon-btn { border: 0; background: transparent; color: var(--muted); padding: 6px; border-radius: 8px; cursor: pointer; font-size: 1.1rem; line-height: 1; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.form { display: grid; gap: 12px; }
.form label, label.field { display: grid; gap: 5px; font-weight: 600; font-size: .9rem; }
.form label.check, label.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 9px 11px; width: 100%; font-weight: 400; }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--primary); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-50); border-color: var(--primary); }
textarea { min-height: 90px; resize: vertical; }
textarea.code { font-family: var(--mono); font-size: 13px; }
.form-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

.alert { padding: 10px 14px; border-radius: 10px; margin: 10px 0; border: 1px solid transparent; }
.alert.ok { background: var(--ok-50); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.alert.err { background: var(--err-50); color: var(--err); border-color: color-mix(in srgb, var(--err) 25%, transparent); }
.alert.warn { background: var(--warn-50); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.alert.info { background: var(--primary-50); color: var(--primary-600); }

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: .74rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.badge.ok { background: var(--ok-50); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-50); color: var(--warn); border-color: transparent; }
.badge.err { background: var(--err-50); color: var(--err); border-color: transparent; }
.badge.primary { background: var(--primary-50); color: var(--primary-600); border-color: transparent; }
.lang { font-family: var(--mono); font-size: .7rem; font-weight: 700; padding: 2px 7px; border-radius: 6px; color: #fff; text-transform: uppercase; }
.lang.html { background: #e8590c; } .lang.css { background: #1c7ed6; } .lang.js { background: #f59f00; color: #1b1f2a; } .lang.php { background: #7048e8; } .lang.ino { background: #00979d; }

/* ===== Layout ===== */
.boot { display: grid; place-items: center; min-height: 100vh; color: var(--muted); }
.brand-mark { width: 44px; height: 44px; border-radius: 12px; background: linear-gradient(135deg, var(--primary), var(--violet)); color: #fff; display: grid; place-items: center; font-family: var(--mono); font-weight: 700; font-size: 15px; }

.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; background: var(--surface); border-right: 1px solid var(--border); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 14px; font-weight: 800; letter-spacing: -.01em; line-height: 1.2; }
.sidebar .brand .brand-mark { width: 36px; height: 36px; font-size: 12px; flex: none; }
.nav-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; padding: 14px 10px 4px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; color: var(--text); font-weight: 500; text-decoration: none; }
.nav a:hover { background: var(--surface-2); }
.nav a.active { background: var(--primary-50); color: var(--primary-600); font-weight: 700; }
.nav a .ico { width: 20px; text-align: center; }
.nav a .soon { margin-left: auto; font-size: .66rem; }
.nav a .count { margin-left: auto; background: var(--err); color: #fff; border-radius: 999px; font-size: .7rem; padding: 0 7px; font-weight: 700; }
.sidebar .me { margin-top: auto; border-top: 1px solid var(--border); padding: 12px 8px 0; display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: inline-grid; vertical-align: middle; place-items: center; font-weight: 700; font-size: .8rem; color: #fff; flex: none; background: var(--primary); }
.avatar.sm { width: 26px; height: 26px; font-size: .68rem; }
.avatars { display: flex; } .avatars .avatar { border: 2px solid var(--surface); margin-left: -8px; } .avatars .avatar:first-child { margin-left: 0; }

.main { min-width: 0; }
.topbar { display: none; }
.page { padding: 28px 32px 60px; max-width: 1200px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head p { margin: 0; }
.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: 6px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card.flat { box-shadow: none; }
.card h2, .card h3 { margin-top: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-head h2, .card-head h3 { margin: 0; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.auto { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.dash { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; }

.hero { background: linear-gradient(120deg, var(--primary), var(--violet)); color: #fff; border-radius: 18px; padding: 24px; display: flex; justify-content: space-between; gap: 20px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; position: relative; overflow: hidden; }
.hero h1 { margin: 0 0 4px; }
.hero p { margin: 0; opacity: .9; }
.hero::after { content: '</>'; position: absolute; right: -10px; bottom: -40px; font-family: var(--mono); font-size: 140px; opacity: .09; font-weight: 700; }
.ring { --p: 0; width: 88px; height: 88px; border-radius: 50%; background: conic-gradient(#fff calc(var(--p) * 1%), rgba(255,255,255,.25) 0); display: grid; place-items: center; flex: none; }
.ring span { width: 70px; height: 70px; border-radius: 50%; background: color-mix(in srgb, var(--primary) 70%, var(--violet)); display: grid; place-items: center; font-weight: 800; font-size: 1.1rem; }

.stat { display: grid; gap: 2px; }
.stat b { font-size: 1.7rem; letter-spacing: -.02em; }
.stat span { color: var(--muted); font-size: .85rem; }

.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 11px 0; border-bottom: 1px solid var(--border); }
.list > li:last-child { border-bottom: 0; }
.ann { border-left: 4px solid var(--primary); padding: 10px 14px; background: var(--surface-2); border-radius: 0 10px 10px 0; margin-bottom: 10px; }
.ann.aviso { border-color: var(--warn); } .ann.trabajo { border-color: var(--violet); }
.ann h3 { margin: 0 0 4px; font-size: .98rem; }
.ann .body { font-size: .93rem; }
.ann .body p:last-child { margin: 0; }

.progress { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--border); }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--violet)); border-radius: 999px; transition: width .3s; }
.progress.ok > i { background: var(--ok); }

.topic { overflow: hidden; padding: 0; }
.topic-head { padding: 16px 18px; display: flex; gap: 14px; align-items: flex-start; border-bottom: 1px solid var(--border); }
.topic-ico { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; color: #fff; font-family: var(--mono); font-weight: 700; flex: none; font-size: .78rem; text-transform: uppercase; }
.ex-row { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--border); color: var(--text); text-decoration: none !important; }
.ex-row:last-child { border-bottom: 0; }
.ex-row:hover { background: var(--surface-2); }
.ex-state { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--border); font-size: .8rem; flex: none; color: var(--muted); }
.ex-state.in_progress { border-color: var(--primary); color: var(--primary); }
.ex-state.completed, .ex-state.submitted { background: var(--ok); border-color: var(--ok); color: #fff; }
.dots { display: inline-flex; gap: 2px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--border); }
.dots i.on { background: var(--warn); }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table th { font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--surface-2); position: sticky; top: 0; }
.table tr:last-child td { border-bottom: 0; }
.matrix td.cell { text-align: center; padding: 6px; }
.matrix th.ex { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; max-height: 160px; text-transform: none; font-size: .8rem; letter-spacing: 0; }
.cellbox { display: inline-grid; place-items: center; min-width: 34px; height: 28px; border-radius: 7px; font-size: .74rem; font-weight: 700; background: var(--surface-2); color: var(--muted); text-decoration: none !important; }
.cellbox.in_progress { background: var(--primary-50); color: var(--primary-600); }
.cellbox.completed { background: var(--ok-50); color: var(--ok); }
.cellbox.submitted { background: var(--ok); color: #fff; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs button { border: 0; background: transparent; font: inherit; font-weight: 600; color: var(--muted); padding: 10px 14px; cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }

.empty { text-align: center; padding: 30px 16px; color: var(--muted); }
.empty .big { font-size: 2rem; margin-bottom: 6px; }

/* ===== Auth ===== */
.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--primary) 18%, transparent), transparent), radial-gradient(900px 500px at 110% 110%, color-mix(in srgb, var(--violet) 18%, transparent), transparent), var(--bg); }
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--primary) 18%, transparent), transparent), radial-gradient(900px 500px at 110% 110%, color-mix(in srgb, var(--violet) 18%, transparent), transparent), var(--bg); }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 28px; box-shadow: var(--shadow); }
.auth-card h1 { margin-top: 14px; }
.auth-card h2 { margin: 12px 0 0; font-size: 1rem; }
.checklist { list-style: none; padding: 0; } .checklist li { padding: 4px 0; } .checklist .pass { color: var(--ok); } .checklist .fail { color: var(--err); }
.switch-link { text-align: center; margin-top: 14px; font-size: .9rem; }

/* ===== Espacio de trabajo (ejercicio) ===== */
.ws { display: grid; grid-template-columns: 340px minmax(0, 1fr) minmax(0, 1fr); height: 100vh; overflow: hidden; }
.ws-col { display: flex; flex-direction: column; min-height: 0; min-width: 0; border-right: 1px solid var(--border); background: var(--surface); }
.ws-col:last-child { border-right: 0; }
.ws-head { padding: 12px 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; min-height: 54px; }
.ws-scroll { overflow-y: auto; padding: 14px; flex: 1; min-height: 0; }
.ws-title { font-weight: 800; font-size: 1.02rem; line-height: 1.2; }
.owner-pick { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 4px; }
.owner-pick button { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 5px 11px; font: inherit; font-size: .83rem; font-weight: 600; cursor: pointer; color: var(--text); display: inline-flex; gap: 6px; align-items: center; }
.owner-pick button.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.step { border: 1px solid var(--border); border-radius: 12px; margin-bottom: 10px; overflow: hidden; background: var(--surface); }
.step-head { display: flex; gap: 10px; align-items: center; padding: 10px 12px; cursor: pointer; user-select: none; }
.step-num { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: .8rem; background: var(--surface-2); border: 1px solid var(--border); flex: none; }
.step.done .step-num { background: var(--ok); color: #fff; border-color: var(--ok); }
.step.current { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-50); }
.step-body { padding: 0 12px 12px 48px; font-size: .92rem; }
.step:not(.open) .step-body { display: none; }
.step .by { font-size: .75rem; color: var(--muted); }
.objectives { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 6px; }
.objectives li { display: flex; gap: 8px; align-items: flex-start; font-size: .88rem; padding: 6px 8px; border-radius: 8px; background: var(--surface-2); }
.objectives li .mark { width: 18px; flex: none; text-align: center; font-weight: 800; }
.objectives li.pass { background: var(--ok-50); color: var(--ok); }
.objectives li.fail { background: var(--err-50); color: var(--err); }
.objectives li .why { display: block; font-size: .8rem; opacity: .85; color: var(--text); }
.hint { margin-top: 8px; }
.hint summary { cursor: pointer; font-weight: 600; color: var(--warn); font-size: .88rem; }

.editor-tabs { display: flex; gap: 2px; background: #1a1b22; padding: 6px 6px 0; overflow-x: auto; }
.editor-tabs button { border: 0; background: transparent; color: #9aa0b4; font: inherit; font-family: var(--mono); font-size: .8rem; padding: 7px 14px; border-radius: 8px 8px 0 0; cursor: pointer; font-weight: 600; }
.editor-tabs button.active { background: #212121; color: #fff; }
.editor-host { flex: 1; min-height: 0; position: relative; background: #212121; }
.editor-host .CodeMirror { height: 100%; font-family: var(--mono); font-size: 14px; line-height: 1.55; }
.editor-host textarea.fallback { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: 0; background: #212121; color: #eee; font-family: var(--mono); font-size: 14px; padding: 12px; resize: none; tab-size: 2; }
.editor-bar { display: flex; gap: 8px; align-items: center; padding: 8px 10px; background: var(--surface); border-top: 1px solid var(--border); flex-wrap: wrap; }
.save-state { font-size: .8rem; color: var(--muted); margin-left: auto; }

.preview-wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--surface-2); }
.preview-frame { flex: 1; width: 100%; border: 0; background: #fff; min-height: 0; }
.console { height: 150px; background: #14151b; color: #d5d8e0; font-family: var(--mono); font-size: 12.5px; overflow-y: auto; padding: 8px 10px; border-top: 1px solid #2a2d38; flex: none; }
.console .line { white-space: pre-wrap; padding: 1px 0; border-bottom: 1px solid #1f2129; }
.console .warn { color: #ffd43b; } .console .error { color: #ff8787; } .console .sys { color: #74c0fc; }
.console-head { display: flex; align-items: center; justify-content: space-between; font-size: .75rem; color: #8e93a6; padding: 4px 10px; background: #1a1b22; font-family: var(--mono); }
.php-loading { position: absolute; inset: 0; display: grid; place-items: center; background: color-mix(in srgb, var(--surface) 85%, transparent); color: var(--muted); font-weight: 600; }
.url-bar { display: flex; align-items: center; gap: 8px; padding: 7px 10px; background: var(--surface); border-bottom: 1px solid var(--border); font-size: .8rem; color: var(--muted); }
.url-bar .dots3 { display: flex; gap: 5px; } .url-bar .dots3 i { width: 10px; height: 10px; border-radius: 50%; background: var(--border); }
.url-bar .url { flex: 1; background: var(--surface-2); border-radius: 6px; padding: 3px 10px; font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.ws-mobile-tabs { display: none; }
.celebrate { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.celebrate i { position: absolute; top: -10px; width: 9px; height: 14px; border-radius: 2px; animation: fall 1.8s ease-in forwards; }
@keyframes fall { to { transform: translateY(105vh) rotate(720deg); opacity: .7; } }

/* ===== Modal y toasts ===== */
.modal-back { position: fixed; inset: 0; background: rgba(10, 12, 20, .5); display: grid; place-items: center; z-index: 50; padding: 16px; animation: fade .15s; }
.modal { background: var(--surface); border-radius: 18px; width: 100%; max-width: 560px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.3); border: 1px solid var(--border); }
.modal.wide { max-width: 900px; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.modal-head h2 { margin: 0; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }
#toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 70; max-width: calc(100vw - 32px); }
.toast { background: #1b1f2a; color: #fff; padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); font-size: .9rem; animation: fade .2s; max-width: 380px; }
.toast.ok { background: var(--ok); } .toast.err { background: var(--err); }

/* ===== Editor de ejercicios (docente) ===== */
.step-editor { border: 1px solid var(--border); border-radius: 12px; padding: 14px; margin-bottom: 12px; background: var(--surface-2); }
.check-row { display: grid; grid-template-columns: 200px 1fr auto; gap: 8px; align-items: start; background: var(--surface); padding: 8px; border-radius: 10px; border: 1px solid var(--border); margin-bottom: 6px; }
.check-row .params { display: grid; gap: 6px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.check-row input, .check-row select { padding: 6px 8px; font-size: .86rem; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); padding: 4px 10px; border-radius: 999px; font-size: .84rem; cursor: pointer; user-select: none; }
.chip input { margin: 0; }
.chip.on { background: var(--primary-50); border-color: var(--primary); color: var(--primary-600); font-weight: 600; }
.member-pick { max-height: 260px; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; padding: 6px; display: grid; gap: 2px; }
.member-pick label { display: flex; gap: 8px; align-items: center; padding: 6px 8px; border-radius: 8px; font-weight: 500; cursor: pointer; }
.member-pick label:hover { background: var(--surface-2); }
.code-box { font-family: var(--mono); font-size: 1.4rem; font-weight: 700; letter-spacing: .12em; background: var(--primary-50); color: var(--primary-600); padding: 4px 12px; border-radius: 10px; display: inline-block; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--border); font-size: .9rem; }
.timeline li:last-child { border-bottom: 0; }
.timeline .when { color: var(--muted); font-size: .8rem; white-space: nowrap; }
.contrib-bar { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: var(--surface-2); }

/* ===== Responsive ===== */
@media (max-width: 1100px) {
  .ws { grid-template-columns: 300px minmax(0, 1fr); grid-template-rows: 1fr; }
  .ws-col.preview { position: fixed; right: 0; top: 0; bottom: 0; width: min(520px, 90vw); z-index: 30; box-shadow: -10px 0 40px rgba(0,0,0,.2); transform: translateX(100%); transition: transform .2s; }
  .ws.show-preview .ws-col.preview { transform: none; }
  .only-narrow { display: inline-flex !important; }
}
.only-narrow { display: none !important; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 270px; z-index: 40; transform: translateX(-100%); transition: transform .2s; box-shadow: 10px 0 40px rgba(0,0,0,.2); }
  .shell.nav-open .sidebar { transform: none; }
  .shell.nav-open::after { content: ''; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 35; }
  .topbar { display: flex; position: sticky; top: 0; z-index: 20; align-items: center; gap: 10px; padding: 10px 14px; background: var(--surface); border-bottom: 1px solid var(--border); }
  .topbar .brand-mark { width: 30px; height: 30px; font-size: 10px; border-radius: 9px; }
  .topbar b { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .page { padding: 18px 16px 90px; }
  .dash, .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; }
  h1 { font-size: 1.35rem; }
  .bottom-nav { display: flex !important; }
  .hero { padding: 18px; }
  .ring { width: 70px; height: 70px; } .ring span { width: 56px; height: 56px; font-size: .95rem; }
  .check-row { grid-template-columns: 1fr; }

  .ws { display: flex; flex-direction: column; height: 100dvh; }
  .ws-col { display: none; border-right: 0; flex: 1; }
  .ws-col.preview { position: static; transform: none; width: auto; box-shadow: none; }
  .ws[data-mtab="steps"] .ws-col.steps, .ws[data-mtab="code"] .ws-col.code, .ws[data-mtab="preview"] .ws-col.preview { display: flex; }
  .ws-mobile-tabs { display: flex; border-top: 1px solid var(--border); background: var(--surface); padding-bottom: env(safe-area-inset-bottom); }
  .ws-mobile-tabs button { flex: 1; border: 0; background: transparent; font: inherit; font-weight: 600; font-size: .82rem; padding: 10px 4px; color: var(--muted); display: grid; gap: 2px; justify-items: center; }
  .ws-mobile-tabs button.active { color: var(--primary); }
  .ws-mobile-tabs .ico { font-size: 1.1rem; }
  .only-narrow { display: none !important; }
  .console { height: 110px; }
  #toasts { bottom: 76px; left: 16px; right: 16px; }
}
.bottom-nav { display: none; position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface); border-top: 1px solid var(--border); z-index: 25; padding-bottom: env(safe-area-inset-bottom); }
.bottom-nav a { flex: 1; display: grid; justify-items: center; gap: 1px; padding: 8px 2px; color: var(--muted); font-size: .7rem; font-weight: 600; text-decoration: none; }
.bottom-nav a .ico { font-size: 1.15rem; }
.bottom-nav a.active { color: var(--primary); }


/* ===== Identidad del Colegio San José ===== */
.brand-mark { background: url('img/escudo.png') center / contain no-repeat !important; color: transparent !important; font-size: 0 !important; border-radius: 0 !important; }
.sidebar .brand { border-bottom: 3px solid var(--gold); padding-bottom: 14px; margin-bottom: 8px; }
.nav a.active { box-shadow: inset 3px 0 0 var(--gold); }
.progress > i { background: linear-gradient(90deg, var(--primary), var(--gold)); }
.hero { background: linear-gradient(120deg, var(--primary), var(--violet)); }
.hero::before { content: ''; position: absolute; inset: 0 0 0 auto; width: 34%; background: repeating-linear-gradient(135deg, var(--gold) 0 18px, transparent 18px 36px); opacity: .28; clip-path: polygon(30% 0, 100% 0, 100% 100%, 0 100%); pointer-events: none; }
.hero > * { position: relative; }
.hero::after { content: ''; width: 150px; height: 190px; right: 18px; bottom: -30px; background: url('img/escudo.png') center / contain no-repeat; opacity: .16; }
.ann { border-left-color: var(--gold); }
.badge.warn, .alert.warn { border-color: var(--gold); }
/* SweetAlert2 con los colores de la plataforma */
.swal2-popup { font-family: var(--font); border-radius: var(--radius) !important; background: var(--surface) !important; color: var(--text) !important; }
.swal2-title { color: var(--text) !important; }
.swal2-html-container { color: var(--muted) !important; }
.swal2-html-container b, .swal2-html-container code { color: var(--text); }
.swal2-input { background: var(--bg) !important; color: var(--text) !important; border-color: var(--border) !important; }
.swal2-styled.swal2-confirm { background: var(--primary) !important; }

/* ===== Ejercicios de Arduino: panel del simulador ===== */
.ws-col.preview.ino > .url-bar, .ws-col.preview.ino > .preview-wrap, .ws-col.preview.ino > .console-head, .ws-col.preview.ino > .console { display: none; }
.sim-panel { flex: 1; min-height: 0; overflow-y: auto; padding: 14px; display: grid; gap: 16px; align-content: start; background: var(--surface); }
.sim-panel section { display: grid; gap: 8px; }
.sim-panel h3 { margin: 0; font-size: 1rem; }
.sim-steps { margin: 0; padding-left: 20px; display: grid; gap: 8px; font-size: .92rem; }
.sim-steps .btn { margin-top: 4px; }
.sim-svg svg { width: 100%; height: auto; display: block; border-radius: 12px; }
