/* Concepto: carpeta editorial sobre fondo vino con cuadrícula; tarjetas de papel crema, washi tape azul y estrellas plateadas. */
:root {
  --wine-900: #2b110f;
  --wine-800: #3a1714;
  --wine-700: #4f1e1b;
  --wine-500: #7a2e2a;
  --cream: #f3eadf;
  --cream-2: #e9dccb;
  --ink: #2b110f;
  --ink-soft: #6b4a44;
  --mauve: #c79c96;
  --mauve-soft: #d9b9b4;
  --sky: #a9c4e2;
  --sky-ink: #23384f;
  --ok: #3f7d5c;
  --line: rgba(43, 17, 15, .14);
  --display: "Oranienbaum", "Bodoni 72", "Didot", Georgia, serif;
  --script: "Mrs Saint Delafield", "Snell Roundhand", cursive;
  --body: "Jost", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --radius: 4px;
  --shadow: 0 10px 30px rgba(20, 6, 5, .35);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--cream);
  background-color: var(--wine-800);
  background-image:
    linear-gradient(rgba(255,255,255,.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.045) 1px, transparent 1px),
    radial-gradient(ellipse at 20% 0%, var(--wine-700), var(--wine-900) 70%);
  background-size: 96px 96px, 96px 96px, 100% 100%;
  background-attachment: fixed;
  min-height: 100vh;
}
a { color: inherit; }
img { max-width: 100%; height: auto; display: block; }
svg:not(.ic):not(.star) { width: 1.1em; height: 1.1em; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.media-placeholder .over svg { width: 40px; height: 40px; margin: 0 auto; }
button, input, select, textarea { font: inherit; }
:focus-visible { outline: 2px solid var(--sky); outline-offset: 2px; }
.wrap { max-width: 1120px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }

/* ---------- barra superior */
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(43, 17, 15, .92); backdrop-filter: blur(8px); border-bottom: 1px solid rgba(255,255,255,.08); }
.topbar .wrap { display: flex; align-items: center; gap: 20px; min-height: 64px; }
.brand { display: flex; flex-direction: column; text-decoration: none; line-height: 1; }
.brand b { font-family: var(--display); font-weight: 400; font-size: 20px; letter-spacing: .04em; text-transform: uppercase; }
.brand i { font-family: var(--script); font-style: normal; font-size: 22px; color: var(--mauve-soft); margin-top: 2px; }
.nav { display: flex; gap: 18px; margin-left: auto; align-items: center; flex-wrap: wrap; }
.nav a { text-decoration: none; font-size: 14px; letter-spacing: .08em; text-transform: uppercase; color: var(--mauve-soft); }
.nav a:hover, .nav a.on { color: var(--cream); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--mauve); color: var(--wine-900); display: grid; place-items: center; font-weight: 600; overflow: hidden; border: 0; cursor: pointer; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.demo-band { background: var(--sky); color: var(--sky-ink); font-size: 13px; text-align: center; padding-block: 6px; padding-left: 16px; padding-right: 16px; }
.demo-band button { background: none; border: 1px solid currentColor; border-radius: 99px; color: inherit; padding: 1px 10px; margin-left: 8px; cursor: pointer; font-size: 12px; }

main { padding-block: 32px 80px; }

/* ---------- tipografía */
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .3em; text-transform: uppercase; color: var(--mauve-soft); }
h1, h2, h3 { text-wrap: balance; }
.display { font-family: var(--display); font-weight: 400; text-transform: uppercase; line-height: 1; letter-spacing: .01em; margin: 0; }
.script { font-family: var(--script); font-size: clamp(30px, 5vw, 44px); color: var(--cream-2); line-height: 1.1; }

/* ---------- hero del inicio */
.hero { position: relative; text-align: center; padding-block: 40px 28px; }
.hero .display { font-size: clamp(40px, 7.4vw, 84px); margin-top: 12px; }
.hero .script { margin-top: 2px; }
.hero p.welcome { max-width: 60ch; margin: 18px auto 0; color: var(--cream-2); }
.star { position: absolute; width: 46px; height: 46px; filter: drop-shadow(0 3px 5px rgba(0,0,0,.5)); }

/* ---------- progreso */
.progress { height: 6px; background: rgba(255,255,255,.12); border-radius: 99px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--sky); border-radius: 99px; transition: width .4s; }
.paper .progress { background: var(--cream-2); }
.paper .progress > span { background: var(--wine-500); }

/* ---------- papel crema */
.paper { background: var(--cream); color: var(--ink); border-radius: var(--radius); box-shadow: var(--shadow); }
.paper a { color: var(--wine-500); }

/* ---------- tarjeta de continuar */
.resume { display: grid; grid-template-columns: 220px 1fr auto; gap: 20px; align-items: center; padding: 16px; margin: 8px 0 28px; text-decoration: none; }
.resume img { width: 220px; aspect-ratio: 16/9; object-fit: cover; border-radius: 2px; max-width: 100%; }
.resume .meta { min-width: 0; }
.resume strong { display: block; font-size: 18px; line-height: 1.3; }
.resume small { color: var(--ink-soft); }

/* ---------- tarjetas de secciones */
.sections { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.sec-card { display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: center; padding: 20px 22px; text-decoration: none; position: relative; transition: transform .18s, box-shadow .18s; }
.sec-card:hover { transform: translateY(-2px); box-shadow: 0 16px 34px rgba(20,6,5,.45); }
.sec-card svg.ic { width: 30px; height: 30px; stroke: var(--wine-500); fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.sec-card h3 { margin: 0; font-family: var(--display); font-weight: 400; text-transform: uppercase; font-size: 26px; line-height: 1; letter-spacing: .02em; }
.sec-card p { margin: 4px 0 0; color: var(--ink-soft); font-size: 14px; }
.sec-card .count { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-soft); white-space: nowrap; }
.sec-card .mini { grid-column: 1 / -1; }
.biblio-link { display: inline-flex; gap: 8px; align-items: center; margin-top: 18px; color: var(--mauve-soft); font-size: 14px; letter-spacing: .06em; }

/* ---------- breadcrumbs */
.crumbs { font-size: 13px; color: var(--mauve-soft); margin-bottom: 18px; display: flex; flex-wrap: wrap; gap: 6px; }
.crumbs a { text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.crumbs span.sep { opacity: .5; }

/* ---------- página de sección */
.section-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; align-items: start; }
.side { padding: 0; overflow: hidden; position: sticky; top: 84px; }
.side img { width: 100%; aspect-ratio: 16/9; object-fit: cover; }
.side .side-body { padding: 16px 18px 20px; }
.side strong { display: block; margin-bottom: 10px; }
.module { padding: 22px 24px; margin-bottom: 18px; }
.module-head { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: baseline; justify-content: space-between; margin-bottom: 6px; }
.module-head h2 { margin: 0; font-family: var(--display); font-weight: 400; text-transform: uppercase; font-size: 30px; line-height: 1.05; }
.module-head p { margin: 0; color: var(--ink-soft); font-size: 14px; }
.lessons { list-style: none; margin: 10px 0 0; padding: 0; }
.lesson-row { display: grid; grid-template-columns: 128px minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.lesson-row:first-child { border-top: 0; }
.lesson-row img { width: 128px; aspect-ratio: 16/9; object-fit: cover; border-radius: 2px; }
.lesson-row .t { font-weight: 600; line-height: 1.35; }
.lesson-row .d { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }
.lesson-row.locked img { filter: grayscale(.8) brightness(.8); }
.lesson-row.locked .t { color: var(--ink-soft); }

.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; padding: 4px 9px; border-radius: 99px; white-space: nowrap; border: 1px solid transparent; }
.chip.lock { background: var(--cream-2); color: var(--ink-soft); }
.chip.open { background: var(--sky); color: var(--sky-ink); }
.chip.rec { background: var(--wine-500); color: var(--cream); }
.chip.done { background: transparent; color: var(--ok); border-color: var(--ok); }
.chip.draft { background: transparent; color: var(--ink-soft); border-color: var(--line); }
.chip svg { width: 12px; height: 12px; stroke: currentColor; fill: none; stroke-width: 2; }

/* ---------- página de lección */
.lesson-page { max-width: 880px; margin: 0 auto; }
.lesson-media { margin-bottom: 0; }
.embed { margin: 0; }
.embed-frame { position: relative; aspect-ratio: 16/9; background: #000; border-radius: var(--radius) var(--radius) 0 0; overflow: hidden; }
.embed-doc .embed-frame { aspect-ratio: 4/3; background: #fff; }
.embed-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.embed figcaption { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; padding: 8px 12px; background: var(--wine-900); color: var(--mauve-soft); letter-spacing: .06em; }
.embed figcaption a { color: var(--mauve-soft); }
.media-placeholder { position: relative; aspect-ratio: 16/9; border-radius: var(--radius) var(--radius) 0 0; overflow: hidden; }
.media-placeholder img { width: 100%; height: 100%; object-fit: cover; filter: blur(6px) brightness(.4); transform: scale(1.06); }
.media-placeholder .over { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; padding: 20px; gap: 10px; }
.media-placeholder .over strong { font-family: var(--display); font-weight: 400; text-transform: uppercase; font-size: clamp(22px, 3.4vw, 34px); line-height: 1.05; }
.media-placeholder .over small { color: var(--cream-2); max-width: 46ch; margin: 0 auto; }
.lesson-body { padding: 28px clamp(18px, 4vw, 44px) 36px; border-radius: 0 0 var(--radius) var(--radius); }
.lesson-body h1 { font-family: var(--display); font-weight: 400; text-transform: uppercase; font-size: clamp(30px, 4.6vw, 48px); line-height: 1.02; margin: 6px 0 14px; }
.lesson-body .lead { font-size: 18px; color: var(--ink); max-width: 65ch; }
.lesson-body h2 { font-family: var(--display); font-weight: 400; text-transform: uppercase; font-size: 24px; margin: 32px 0 10px; letter-spacing: .02em; }
.tape { display: inline-block; background: var(--sky); color: var(--sky-ink); font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; padding: 6px 14px; transform: rotate(-2deg); box-shadow: 0 4px 10px rgba(0,0,0,.18); }
.takeaways { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.takeaways li { display: grid; grid-template-columns: 22px 1fr; gap: 10px; }
.takeaways li::before { content: "✦"; color: var(--wine-500); }
.materials { display: grid; gap: 10px; }
.material-pending { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--ink-soft); font-size: 14px; }
.linkcard { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; background: #fbf6ef; color: var(--ink) !important; }
.linkcard:hover { border-color: var(--wine-500); }
.linkcard img { border-radius: 6px; }
.linkcard .lc-text { min-width: 0; display: flex; flex-direction: column; }
.linkcard strong { overflow-wrap: anywhere; }
.linkcard small { color: var(--ink-soft); }
.linkcard .lc-go { color: var(--wine-500); font-size: 18px; }
.paper .embed { margin: 14px 0; }
.paper .embed-frame { border-radius: var(--radius) var(--radius) 0 0; }

.md { max-width: 68ch; }
.md h3 { font-size: 18px; margin: 26px 0 6px; color: var(--wine-500); letter-spacing: .02em; }
.md blockquote { margin: 16px 0; padding: 12px 16px; background: #f8efe3; border-left: 3px solid var(--sky); color: var(--ink); }
.md blockquote p { margin: 0; }
.md table { border-collapse: collapse; width: 100%; font-size: 14px; }
.md th, .md td { border-bottom: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
.md th { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); }
.md .table-wrap { overflow-x: auto; margin: 12px 0; }
.md img { border-radius: var(--radius); margin: 12px 0; box-shadow: 0 6px 16px rgba(0,0,0,.18); }
.md li { margin: 4px 0; }
.md code { background: var(--cream-2); padding: 1px 5px; border-radius: 3px; font-size: .9em; }

.quiz { margin-top: 12px; display: grid; gap: 18px; }
.quiz fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 0; }
.quiz legend { font-weight: 600; padding: 0 6px; }
.quiz label { display: flex; gap: 10px; align-items: flex-start; padding: 6px 8px; border-radius: 4px; cursor: pointer; }
.quiz label:hover { background: #f8efe3; }
.quiz label.right { background: #e3efe7; }
.quiz label.wrong { background: #f6e1de; }
.quiz .result { font-weight: 600; }

.lesson-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; margin-top: 18px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; cursor: pointer; padding: 11px 20px; border-radius: 2px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; font-size: 13px; text-decoration: none; background: var(--cream); color: var(--wine-800); }
.btn:hover { background: #fff; }
.btn.dark { background: var(--wine-800); color: var(--cream); }
.btn.dark:hover { background: var(--wine-500); }
.btn.sky { background: var(--sky); color: var(--sky-ink); }
.btn.ghost { background: transparent; color: inherit; border: 1px solid currentColor; }
.btn.small { padding: 6px 12px; font-size: 11px; }
.btn.danger { background: transparent; color: #a3322b; border: 1px solid #a3322b; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.done { background: var(--ok); color: #fff; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 20px; }
.pager .pos { font-size: 13px; color: var(--mauve-soft); }

/* ---------- login */
.login { min-height: calc(100vh - 40px); display: grid; place-items: center; text-align: center; padding-block: 40px; }
.login-card { max-width: 560px; }
.login-card img { border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 26px; }
.login-card p { color: var(--cream-2); }

/* ---------- admin */
.admin-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 20px; }
.admin-tabs a { text-decoration: none; padding: 8px 14px; border: 1px solid rgba(255,255,255,.2); border-radius: 99px; font-size: 13px; letter-spacing: .06em; color: var(--cream-2); }
.admin-tabs a.on { background: var(--cream); color: var(--wine-800); border-color: var(--cream); }
.panel { padding: 22px 24px; margin-bottom: 18px; }
.panel h2 { margin: 0 0 4px; font-family: var(--display); font-weight: 400; text-transform: uppercase; font-size: 28px; }
.panel > p.hint { margin: 0 0 16px; color: var(--ink-soft); font-size: 14px; max-width: 70ch; }
.admin-table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 640px; }
.admin-table th { text-align: left; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-soft); padding: 8px; border-bottom: 1px solid var(--line); }
.admin-table td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.admin-table td.actions { white-space: nowrap; text-align: right; }
.admin-table td.actions .btn { margin-left: 4px; }
.admin-table .tnum { font-variant-numeric: tabular-nums; white-space: nowrap; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); }
.field small { color: var(--ink-soft); font-size: 12px; }
.field input[type=text], .field input[type=url], .field input[type=email], .field input[type=date], .field input[type=time], .field input[type=datetime-local], .field input[type=number], .field select, .field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); background: #fffaf3; color: var(--ink); border-radius: 3px; color-scheme: light; }
.field textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
.field textarea.tall { min-height: 320px; font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.check input { margin-top: 4px; }
.preview-box { border: 1px dashed var(--line); border-radius: var(--radius); padding: 10px; min-height: 40px; background: #fffaf3; }
.preview-box:empty::before { content: "Pega un link y verás aquí la vista previa."; color: var(--ink-soft); font-size: 13px; }
.row-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 18px; }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--cream); color: var(--wine-800); padding: 12px 18px; border-radius: 3px; box-shadow: var(--shadow); font-weight: 600; z-index: 50; max-width: calc(100% - 32px); }
.notice { padding: 12px 16px; border-radius: var(--radius); background: rgba(169,196,226,.16); border: 1px solid rgba(169,196,226,.5); color: var(--cream); font-size: 14px; margin-bottom: 18px; }
.paper .notice { color: var(--ink); background: #e9f0f8; border-color: var(--sky); }
.empty { padding: 30px; text-align: center; color: var(--ink-soft); }
.confirm { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; }

@media (max-width: 860px) {
  .section-layout { grid-template-columns: 1fr; }
  .side { position: static; order: -1; display: grid; grid-template-columns: 140px 1fr; }
  .side img { height: 100%; }
}
@media (max-width: 640px) {
  .sections { grid-template-columns: 1fr; }
  .resume { grid-template-columns: 1fr; }
  .resume img { width: 100%; }
  .lesson-row { grid-template-columns: 96px minmax(0, 1fr); }
  .lesson-row img { width: 96px; }
  .lesson-row .chip { grid-column: 2; justify-self: start; }
  .form-grid { grid-template-columns: 1fr; }
  .topbar .wrap { flex-wrap: wrap; gap: 8px 16px; padding-block: 8px; }
  .nav { margin-left: 0; width: 100%; justify-content: space-between; }
  .star { display: none; }
  .side { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.paper { color-scheme: light; }
