:root {
  --bg: #07070b; --bg-2: #0b0b11; --card: #101018; --card-2: #161620;
  --line: rgba(255,255,255,.08); --line-2: rgba(255,255,255,.15);
  --text: #f4f4f7; --muted: #a3a3b6; --dim: #6c6c82;
  --accent: #ff6d5a; --accent-2: #ea4b71; --green: #34d399; --red: #f87171;
  --grad: linear-gradient(100deg,#ff8a5c 0%,#ff6d5a 28%,#ea4b71 62%,#a855f7 100%);
  --font-display: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --font-body: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --r: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.55 var(--font-body); -webkit-font-smoothing: antialiased; min-height: 100vh; }
a { color: inherit; }
h1, h2, h3 { font-family: var(--font-display); letter-spacing: -.02em; line-height: 1.1; margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
.hidden { display: none !important; }
.grad-text { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- Marca ---------- */
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-family: var(--font-display); font-weight: 800; font-size: 19px; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: var(--grad); display: grid; place-items: center; font-size: 18px; color: #fff; }
.brand small { display: block; font: 500 11px/1 var(--font-body); color: var(--muted); letter-spacing: .14em; text-transform: uppercase; margin-top: 3px; }

/* ---------- Botones y formularios ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 12px; padding: 13px 20px; font-weight: 600; cursor: pointer; text-decoration: none; transition: transform .15s, opacity .15s, background .15s; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .55; cursor: wait; }
.btn-primary { background: var(--grad); color: #fff; }
.btn-ghost { background: transparent; border: 1px solid var(--line-2); color: var(--text); }
.btn-ghost:hover { background: rgba(255,255,255,.05); }
.btn-soft { background: rgba(255,255,255,.06); color: var(--text); }
.btn-soft:hover { background: rgba(255,255,255,.1); }
.btn-danger { background: rgba(248,113,113,.12); color: var(--red); }
.btn-sm { padding: 8px 12px; font-size: 13px; border-radius: 10px; }
.btn-block { width: 100%; }
.link-btn { background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; cursor: pointer; font-size: 14px; }
.link-btn:hover { color: var(--text); }

label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
.input, textarea.input, select.input { width: 100%; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 11px; padding: 12px 14px; outline: none; transition: border-color .15s, box-shadow .15s; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255,109,90,.18); }
textarea.input { min-height: 90px; resize: vertical; }
.pass-wrap { position: relative; }
.pass-wrap .input { padding-right: 84px; }
.pass-wrap button { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); background: none; border: 0; color: var(--muted); font-size: 13px; cursor: pointer; padding: 6px 8px; }

.alert { border-radius: 11px; padding: 11px 14px; font-size: 14px; margin-bottom: 14px; }
.alert-error { background: rgba(248,113,113,.1); border: 1px solid rgba(248,113,113,.3); color: #fecaca; }
.alert-ok { background: rgba(52,211,153,.1); border: 1px solid rgba(52,211,153,.3); color: #bbf7d0; }
.alert a { color: #fff; word-break: break-all; }

/* ---------- Pantalla de acceso (dividida) ---------- */
.auth { display: grid; grid-template-columns: 1.05fr 1fr; min-height: 100vh; }
.auth-hero { position: relative; overflow: hidden; padding: 44px 56px; display: flex; flex-direction: column; justify-content: space-between; gap: 36px; background:
  radial-gradient(800px 500px at 10% 110%, rgba(234,75,113,.28), transparent 60%),
  radial-gradient(700px 500px at 100% 0%, rgba(168,85,247,.18), transparent 60%), var(--bg-2);
  border-right: 1px solid var(--line); }
.auth-hero .kicker { font-size: 12px; letter-spacing: .2em; text-transform: uppercase; color: var(--accent); font-weight: 700; margin-bottom: 14px; }
.auth-hero h1 { font-size: clamp(38px, 4.6vw, 62px); font-weight: 800; }
.auth-hero p.lead { color: var(--muted); max-width: 460px; margin-top: 18px; font-size: 16px; }
.auth-feats { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 28px; }
.auth-feats span { border: 1px solid var(--line-2); border-radius: 999px; padding: 7px 13px; font-size: 13px; color: var(--muted); background: rgba(255,255,255,.03); }
.auth-side { display: flex; flex-direction: column; justify-content: center; padding: 44px clamp(24px, 6vw, 84px); }
.auth-box { width: 100%; max-width: 420px; margin: 0 auto; }
.auth-box .tag { display: inline-flex; align-items: center; gap: 7px; font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--line-2); border-radius: 999px; padding: 6px 11px; margin-bottom: 18px; }
.auth-box h2 { font-size: 34px; font-weight: 800; margin-bottom: 8px; }
.auth-box p.sub { color: var(--muted); margin: 0 0 26px; }
.auth-links { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; align-items: flex-start; }
.auth-foot { margin-top: 34px; font-size: 12px; color: var(--dim); display: flex; gap: 8px; align-items: center; }
@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  .auth-hero { padding: 28px 22px 34px; border-right: 0; border-bottom: 1px solid var(--line); }
  .auth-hero h1 { font-size: 34px; }
  .auth-hero .hero-bottom { display: none; }
  .auth-side { padding: 32px 22px 48px; }
}

/* ---------- App (después de entrar) ---------- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px clamp(16px, 4vw, 40px); background: rgba(7,7,11,.85); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.topbar nav { display: flex; align-items: center; gap: 8px; }
.user-chip { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--card-2); border: 1px solid var(--line-2); display: grid; place-items: center; font-weight: 700; color: var(--text); font-size: 13px; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 36px clamp(16px, 4vw, 40px) 80px; }
.page-head { margin-bottom: 28px; }
.page-head h1 { font-size: clamp(28px, 3.4vw, 40px); font-weight: 800; }
.page-head p { color: var(--muted); margin: 8px 0 0; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 20px; }
.course-card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; text-decoration: none; display: flex; flex-direction: column; transition: transform .2s, border-color .2s; }
.course-card:hover { transform: translateY(-3px); border-color: var(--line-2); }
.cover { aspect-ratio: 16/9; background: var(--card-2) center/cover no-repeat; position: relative; }
.cover.placeholder { background: radial-gradient(400px 200px at 20% 120%, rgba(234,75,113,.45), transparent 60%), radial-gradient(400px 220px at 100% 0%, rgba(168,85,247,.35), transparent 60%), var(--card-2); display: grid; place-items: center; }
.cover.placeholder span { font-family: var(--font-display); font-weight: 800; font-size: 22px; padding: 0 22px; text-align: center; }
.course-card .body { padding: 18px 18px 20px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.course-card h3 { font-size: 19px; }
.course-card p { color: var(--muted); margin: 0; font-size: 14px; }
.progress { margin-top: auto; padding-top: 14px; }
.progress .bar { height: 6px; border-radius: 99px; background: rgba(255,255,255,.08); overflow: hidden; }
.progress .bar i { display: block; height: 100%; background: var(--grad); border-radius: 99px; }
.progress small { display: flex; justify-content: space-between; color: var(--dim); font-size: 12px; margin-top: 7px; }
.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 99px; background: rgba(255,255,255,.08); color: var(--muted); }
.badge-warn { background: rgba(251,191,36,.12); color: #fcd34d; }
.badge-ok { background: rgba(52,211,153,.12); color: var(--green); }

.empty { text-align: center; border: 1px dashed var(--line-2); border-radius: 18px; padding: 56px 24px; color: var(--muted); }
.empty h3 { color: var(--text); margin-bottom: 8px; }

/* ---------- Curso / lección ---------- */
.course-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 26px; align-items: start; }
.player { aspect-ratio: 16/9; background: #000; border-radius: 16px; overflow: hidden; border: 1px solid var(--line); }
.player iframe, .player video { width: 100%; height: 100%; border: 0; display: block; }
.player .no-video { height: 100%; display: grid; place-items: center; color: var(--dim); text-align: center; padding: 20px; }
.lesson-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin: 22px 0 10px; flex-wrap: wrap; }
.lesson-head h1 { font-size: clamp(22px, 2.6vw, 30px); font-weight: 800; }
.lesson-head .crumb { color: var(--dim); font-size: 13px; margin-bottom: 6px; }
.lesson-desc { color: var(--muted); white-space: pre-line; }
.resources { margin-top: 22px; }
.resources h3 { font-size: 16px; margin-bottom: 10px; }
.resources a { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; text-decoration: none; margin-bottom: 8px; background: var(--card); }
.resources a:hover { border-color: var(--line-2); }
.lesson-nav { display: flex; justify-content: space-between; gap: 10px; margin-top: 26px; flex-wrap: wrap; }
.btn-done { background: rgba(52,211,153,.12); color: var(--green); }

.outline { background: var(--card); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; position: sticky; top: 84px; max-height: calc(100vh - 104px); display: flex; flex-direction: column; }
.outline-head { padding: 18px; border-bottom: 1px solid var(--line); }
.outline-head h2 { font-size: 17px; }
.outline-list { overflow-y: auto; }
.mod-title { padding: 14px 18px 8px; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--dim); font-weight: 700; }
.lesson-item { display: flex; align-items: center; gap: 12px; padding: 11px 18px; text-decoration: none; font-size: 14px; color: var(--muted); border-left: 3px solid transparent; }
.lesson-item:hover { background: rgba(255,255,255,.03); color: var(--text); }
.lesson-item.active { background: rgba(255,109,90,.08); border-left-color: var(--accent); color: var(--text); }
.check { flex: none; width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--line-2); display: grid; place-items: center; font-size: 11px; }
.lesson-item.done .check { background: var(--green); border-color: var(--green); color: #052e1f; }
.lesson-item .dur { margin-left: auto; font-size: 12px; color: var(--dim); }
@media (max-width: 960px) {
  .course-layout { grid-template-columns: 1fr; }
  .outline { position: static; max-height: none; }
}

/* ---------- Administración ---------- */
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 26px; }
.tabs button { background: none; border: 0; padding: 12px 16px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 600; }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 20px; margin-bottom: 18px; }
.panel h3 { font-size: 17px; margin-bottom: 14px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 700px) { .cols { grid-template-columns: 1fr; } }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; color: var(--dim); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.muted { color: var(--muted); }
.dim { color: var(--dim); font-size: 13px; }
.mod-block { border: 1px solid var(--line); border-radius: 14px; margin-bottom: 14px; overflow: hidden; }
.mod-block > .row { padding: 12px 14px; background: var(--card-2); }
.les-row { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-top: 1px solid var(--line); font-size: 14px; }
.les-row .t { flex: 1; min-width: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 4px 6px 4px 10px; border-radius: 99px; background: rgba(255,255,255,.06); }
.chip button { background: none; border: 0; color: var(--dim); cursor: pointer; padding: 0 4px; font-size: 14px; line-height: 1; }
.chip button:hover { color: var(--red); }
.checks { display: flex; flex-direction: column; gap: 8px; }
.checks label { display: flex; gap: 10px; align-items: center; font-size: 14px; cursor: pointer; }
.res-row { display: grid; grid-template-columns: 1fr 1.4fr auto; gap: 8px; margin-bottom: 8px; }

/* Ventana emergente */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal { background: var(--card); border: 1px solid var(--line-2); border-radius: 18px; width: 100%; max-width: 620px; max-height: calc(100vh - 40px); overflow-y: auto; padding: 24px; }
.modal h3 { font-size: 20px; margin-bottom: 18px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

@media (max-width: 600px) { .hide-sm { display: none; } .topbar .brand small { display: none; } }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--card-2); border: 1px solid var(--line-2); padding: 12px 18px; border-radius: 12px; z-index: 60; font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.4); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line-2); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; margin: 60px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
