/* ==========================================================================
   MANUAL DEL OPERARIO — FLEXO
   Sistema de diseño: industrial / editorial, claro + oscuro, responsive
   ========================================================================== */

:root {
  --font-sans: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;

  --ink: #10202f;
  --ink-soft: #40566b;
  --ink-mute: #6b8195;
  --paper: #f6f4ee;
  --paper-2: #fffefb;
  --panel: #ffffff;
  --panel-2: #f1eee6;
  --line: #e2ddd1;
  --line-strong: #cfc8b8;

  --accent: #e4571f;
  --accent-ink: #ffffff;
  --accent-soft: #fbe8df;
  --blue: #1f5fbf;
  --blue-soft: #e6eefc;
  --green: #1f8a55;
  --green-soft: #e3f4ea;
  --amber: #b37700;
  --amber-soft: #fbf0d8;
  --red: #bf3535;
  --red-soft: #fbe6e3;
  --violet: #6a4bc4;
  --violet-soft: #eee9fb;

  --radius-s: 8px;
  --radius: 14px;
  --radius-l: 22px;
  --shadow-s: 0 1px 2px rgba(16, 32, 47, .06), 0 2px 8px rgba(16, 32, 47, .05);
  --shadow: 0 2px 6px rgba(16, 32, 47, .07), 0 12px 32px rgba(16, 32, 47, .09);
  --shadow-l: 0 24px 60px rgba(16, 32, 47, .18);
  --sidebar-w: 312px;
  --topbar-h: 64px;
  --read-w: 860px;
  --ease: cubic-bezier(.22, .8, .25, 1);
}

[data-theme="dark"] {
  --ink: #e8eef5;
  --ink-soft: #a9bccd;
  --ink-mute: #7d93a6;
  --paper: #0c131c;
  --paper-2: #101a25;
  --panel: #141f2b;
  --panel-2: #1a2734;
  --line: #24323f;
  --line-strong: #33465a;

  --accent: #ff7a45;
  --accent-soft: #35211a;
  --blue: #6aa5ff;
  --blue-soft: #152640;
  --green: #52c98a;
  --green-soft: #12291f;
  --amber: #e9b44c;
  --amber-soft: #2c2413;
  --red: #ff7b72;
  --red-soft: #331a19;
  --violet: #b39dff;
  --violet-soft: #241f3d;
  --shadow-s: 0 1px 2px rgba(0,0,0,.4);
  --shadow: 0 12px 32px rgba(0,0,0,.45);
  --shadow-l: 0 30px 80px rgba(0,0,0,.6);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16.5px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--accent); color: #fff; }

/* iconos inline: tamaño controlado (los SVG sin width/height se expanden) */
.btn svg, .search-btn svg, .icon-btn svg, .chip svg, .lab-tag svg, .mc-go svg,
.done-state svg, .brand-mark svg, .m-icon svg, .m-icon-lg svg, .gl-item span svg,
.lesson-nav svg, .bottom-bar svg { width: 17px; height: 17px; flex: 0 0 auto; }
.nav-module-btn .m-icon svg, .lab-tag svg, .mc-go svg, .gl-item span svg, .done-state svg { width: 14px; height: 14px; }
.search-btn > svg { width: 16px; height: 16px; }
.icon-btn svg { width: 18px; height: 18px; }
.brand-mark svg { width: 24px; height: 24px; }
.m-icon-lg svg { width: 19px; height: 19px; }

a { color: var(--blue); text-decoration-thickness: 1.5px; text-underline-offset: 2px; }
a:hover { color: var(--accent); }

h1, h2, h3, h4 { font-family: var(--font-sans); line-height: 1.18; letter-spacing: -.015em; margin: 0 0 .5rem; }
h1 { font-size: clamp(1.9rem, 3.4vw, 2.7rem); font-weight: 800; }
h2 { font-size: clamp(1.35rem, 2.1vw, 1.7rem); font-weight: 750; margin-top: 2.4rem; }
h3 { font-size: 1.15rem; font-weight: 700; margin-top: 1.8rem; }
h4 { font-size: 1rem; font-weight: 700; }
p { margin: 0 0 1rem; max-width: 74ch; }

/* ---------- Layout shell ---------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}
.app.is-hidden-sidebar { grid-template-columns: 0 minmax(0, 1fr); }

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--paper-2);
  border-right: 1px solid var(--line);
  padding: 22px 18px 40px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  z-index: 40;
  scrollbar-width: thin;
}
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 99px; }

.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; padding: 4px 6px 10px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px; flex: 0 0 auto;
  background: linear-gradient(140deg, var(--ink) 0%, #24435c 55%, var(--accent) 140%);
  display: grid; place-items: center; color: #fff; box-shadow: var(--shadow-s);
}
.brand-mark svg { width: 24px; height: 24px; }
.brand-name { font-weight: 800; font-size: .98rem; letter-spacing: -.01em; line-height: 1.2; }
.brand-sub { font-size: .72rem; color: var(--ink-mute); letter-spacing: .06em; text-transform: uppercase; }

.progress-global { padding: 12px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-s); }
.progress-global-head { display: flex; justify-content: space-between; align-items: baseline; font-size: .78rem; color: var(--ink-mute); margin-bottom: 8px; }
.progress-global-head b { color: var(--ink); font-size: .95rem; }
.progress-track { height: 8px; border-radius: 99px; background: var(--panel-2); overflow: hidden; }
.progress-fill { height: 100%; width: 0%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), #f0913f); transition: width .5s var(--ease); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-module { margin-top: 10px; }
.nav-module-btn {
  width: 100%; display: flex; align-items: center; gap: 10px; text-align: left;
  background: none; border: 0; cursor: pointer; padding: 9px 10px; border-radius: 10px;
  font: inherit; font-size: .8rem; font-weight: 750; letter-spacing: .055em; text-transform: uppercase;
  color: var(--ink-soft);
}
.nav-module-btn:hover { background: var(--panel-2); color: var(--ink); }
.nav-module-btn .chev { margin-left: auto; transition: transform .25s var(--ease); opacity: .55; }
.nav-module.is-open .nav-module-btn .chev { transform: rotate(90deg); }
.nav-module-btn .m-icon { width: 22px; height: 22px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 6px; background: var(--panel-2); color: var(--ink-soft); }
.nav-module-btn .m-icon svg { width: 13px; height: 13px; }
.nav-module-btn:hover .m-icon { color: var(--accent); }
.nav-lessons { display: none; flex-direction: column; gap: 1px; padding: 2px 0 4px 8px; border-left: 1.5px solid var(--line); margin-left: 18px; }
.nav-module.is-open .nav-lessons { display: flex; }
.nav-lesson {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 8px;
  font-size: .875rem; color: var(--ink-soft); text-decoration: none; line-height: 1.3;
}
.nav-lesson:hover { background: var(--panel-2); color: var(--ink); }
.nav-lesson.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
[data-theme="dark"] .nav-lesson.is-active { color: var(--accent); }
.nav-lesson .dot { width: 15px; height: 15px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; border: 1.5px solid var(--line-strong); font-size: 9px; }
.nav-lesson.is-done .dot { background: var(--green); border-color: var(--green); color: #fff; }
.nav-lesson .num { font-variant-numeric: tabular-nums; color: var(--ink-mute); font-size: .74rem; min-width: 16px; }

.sidebar-foot { margin-top: auto; display: flex; gap: 8px; flex-wrap: wrap; padding-top: 14px; border-top: 1px solid var(--line); }

/* ---------- Main column ---------- */
.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px; padding: 0 clamp(16px, 3vw, 40px);
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar .crumb { font-size: .82rem; color: var(--ink-mute); display: flex; align-items: center; gap: 8px; min-width: 0; }
.topbar .crumb b { color: var(--ink); font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .spacer { flex: 1; }

.search-btn {
  display: flex; align-items: center; gap: 10px; padding: 9px 14px; min-width: 200px; flex-wrap: nowrap; white-space: nowrap;
  background: var(--panel); border: 1px solid var(--line); border-radius: 99px;
  color: var(--ink-mute); font: inherit; font-size: .86rem; cursor: pointer; box-shadow: var(--shadow-s);
}
.search-btn:hover { border-color: var(--line-strong); color: var(--ink); }
.search-btn kbd { margin-left: auto; font-family: var(--font-mono); font-size: .7rem; background: var(--panel-2); border: 1px solid var(--line); border-radius: 5px; padding: 2px 5px; color: var(--ink-mute); white-space: nowrap; flex: 0 0 auto; }

.icon-btn {
  width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px;
  background: var(--panel); border: 1px solid var(--line); color: var(--ink-soft); cursor: pointer;
  box-shadow: var(--shadow-s); transition: transform .15s var(--ease), color .15s;
}
.icon-btn:hover { color: var(--accent); transform: translateY(-1px); }
.icon-btn svg { width: 18px; height: 18px; }
.menu-btn { display: none; }

.content-wrap { width: 100%; max-width: var(--read-w); margin: 0 auto; padding: clamp(22px, 3.4vw, 52px) clamp(18px, 4vw, 44px) 40px; flex: 1; }

/* ---------- Home / hero ---------- */
.hero { position: relative; overflow: hidden; border-radius: var(--radius-l); background: linear-gradient(135deg, #12212f 0%, #1b3448 48%, #2a2216 100%); color: #f4f1e8; padding: clamp(30px, 5vw, 56px); box-shadow: var(--shadow-l); margin-bottom: 34px; }
.hero::after {
  content: ""; position: absolute; inset: -40% -10% auto auto; width: 460px; height: 460px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,122,69,.34), transparent 62%); filter: blur(10px); pointer-events: none;
}
.hero::before {
  content: ""; position: absolute; inset: auto -60px -120px auto; width: 340px; height: 340px; border-radius: 50%;
  background: radial-gradient(circle, rgba(31,95,191,.35), transparent 65%); pointer-events: none;
}
.hero .eyebrow { color: #f2a07a; letter-spacing: .14em; text-transform: uppercase; font-size: .72rem; font-weight: 700; margin: 0 0 14px; }
.hero h1 { color: #fff; font-size: clamp(2rem, 4.4vw, 3.1rem); margin: 0 0 16px; letter-spacing: -.03em; }
.hero p { color: #cfdae4; max-width: 62ch; font-size: 1.02rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 26px; }
.hero-stats { display: flex; flex-wrap: wrap; gap: 26px; margin-top: 30px; padding-top: 22px; border-top: 1px solid rgba(255,255,255,.14); }
.hero-stat b { display: block; font-size: 1.5rem; color: #fff; letter-spacing: -.02em; }
.hero-stat span { font-size: .78rem; color: #9fb3c4; text-transform: uppercase; letter-spacing: .08em; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px; padding: 12px 20px;
  border-radius: 12px; font: inherit; font-size: .94rem; font-weight: 650; text-decoration: none;
  border: 1px solid transparent; cursor: pointer; transition: transform .15s var(--ease), box-shadow .2s, background .2s;
}
.btn svg { width: 17px; height: 17px; }
.btn--primary { background: var(--accent); color: #fff; box-shadow: 0 8px 22px rgba(228,87,31,.32); }
.btn--primary:hover { background: #f0662c; color: #fff; transform: translateY(-1px); }
.btn--ghost { background: rgba(255,255,255,.07); color: #eaf1f7; border-color: rgba(255,255,255,.22); }
.btn--ghost:hover { background: rgba(255,255,255,.14); color: #fff; }
.btn--soft { background: var(--panel); color: var(--ink); border-color: var(--line); box-shadow: var(--shadow-s); }
.btn--soft:hover { border-color: var(--line-strong); color: var(--accent); transform: translateY(-1px); }
.btn--danger { background: var(--red-soft); color: var(--red); }
.btn[disabled] { opacity: .55; cursor: not-allowed; transform: none; }

/* ---------- Course map ---------- */
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin: 0 0 18px; flex-wrap: wrap; }
.section-head h2 { margin: 0; }
.section-head p { margin: 4px 0 0; color: var(--ink-mute); font-size: .9rem; }

.mod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); gap: 16px; }
.mod-card {
  position: relative; display: flex; flex-direction: column; gap: 10px; text-align: left; padding: 20px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-s);
  text-decoration: none; color: inherit; transition: transform .2s var(--ease), box-shadow .2s, border-color .2s;
  overflow: hidden;
}
.mod-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 4px; background: var(--m-color, var(--accent)); opacity: .9; }
.mod-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--line-strong); }
.mod-card .m-top { display: flex; align-items: center; justify-content: space-between; }
.mod-card .m-num { font-family: var(--font-mono); font-size: .72rem; color: var(--ink-mute); letter-spacing: .08em; }
.mod-card .m-icon-lg { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--m-soft, var(--accent-soft)); color: var(--m-color, var(--accent)); }
.mod-card .m-icon-lg svg { width: 19px; height: 19px; }
.mod-card h3 { font-size: 1.06rem; margin: 2px 0 0; }
.mod-card p { font-size: .86rem; color: var(--ink-mute); margin: 0; }
.mod-card .m-foot { display: flex; align-items: center; gap: 10px; margin-top: 6px; font-size: .78rem; color: var(--ink-mute); }
.mod-card .m-progress { flex: 1; height: 5px; border-radius: 99px; background: var(--panel-2); overflow: hidden; }
.mod-card .m-progress i { display: block; height: 100%; background: var(--m-color, var(--accent)); transition: width .5s var(--ease); }

/* ---------- Lesson ---------- */
.lesson { animation: fadeUp .38s var(--ease) both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.lesson-head { margin-bottom: 30px; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.lesson-head .eyebrow { color: var(--accent); font-size: .74rem; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; margin: 0 0 10px; }
.lesson-head h1 { margin: 0 0 12px; }
.lesson-head .lead { font-size: 1.08rem; color: var(--ink-soft); margin: 0; max-width: 68ch; }
.lesson-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: .76rem; font-weight: 600; color: var(--ink-soft); background: var(--panel); border: 1px solid var(--line); padding: 4px 10px; border-radius: 99px; }
.chip svg { width: 13px; height: 13px; opacity: .7; }

.lesson h2 { padding-top: 6px; }
.lesson h2::before { content: ""; display: block; width: 34px; height: 3px; background: var(--accent); border-radius: 2px; margin-bottom: 12px; }
.lesson h3 { color: var(--ink); }
.lesson ul, .lesson ol { margin: 0 0 1.1rem; padding-left: 1.35rem; max-width: 72ch; }
.lesson li { margin: .35rem 0; }
.lesson li::marker { color: var(--accent); }
.lesson strong { font-weight: 700; }
.lesson blockquote { margin: 1.4rem 0; padding: 14px 20px; border-left: 3px solid var(--accent); background: var(--panel); border-radius: 0 var(--radius-s) var(--radius-s) 0; color: var(--ink-soft); }

/* Callouts */
.callout { margin: 1.6rem 0; padding: 16px 20px 15px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel); box-shadow: var(--shadow-s); border-left-width: 4px; }
.callout p { margin: 0; }
.callout p + p { margin-top: .55rem; }
.callout-title { font-weight: 750; font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 6px !important; }
.callout--info { border-left-color: var(--blue); background: var(--blue-soft); }
.callout--info .callout-title { color: var(--blue); }
.callout--tip { border-left-color: var(--green); background: var(--green-soft); }
.callout--tip .callout-title { color: var(--green); }
.callout--warn { border-left-color: var(--amber); background: var(--amber-soft); }
.callout--warn .callout-title { color: var(--amber); }
.callout--danger { border-left-color: var(--red); background: var(--red-soft); }
.callout--danger .callout-title { color: var(--red); }

/* Figures */
.fig { margin: 1.8rem 0; padding: 0; }
.fig img { width: 100%; height: auto; display: block; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel); cursor: zoom-in; box-shadow: var(--shadow); transition: transform .25s var(--ease); }
.fig img:hover { transform: scale(1.006); }
.fig figcaption { margin-top: 10px; font-size: .83rem; color: var(--ink-mute); line-height: 1.55; padding-left: 2px; }
.fig .src { display: block; margin-top: 3px; font-size: .74rem; color: var(--ink-mute); opacity: .85; font-style: italic; }
.fig--narrow img { max-width: 520px; }

/* Tables */
.tbl-wrap { overflow-x: auto; margin: 1.6rem 0; border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow-s); background: var(--panel); }
table.tbl { width: 100%; border-collapse: collapse; font-size: .87rem; min-width: 520px; }
table.tbl th { text-align: left; padding: 11px 14px; background: var(--panel-2); font-weight: 700; font-size: .78rem; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-soft); border-bottom: 1px solid var(--line); white-space: nowrap; }
table.tbl td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.tbl tr:last-child td { border-bottom: 0; }
table.tbl tbody tr:hover { background: color-mix(in srgb, var(--accent-soft) 40%, transparent); }
[data-theme="dark"] table.tbl tbody tr:hover { background: var(--panel-2); }

/* Key points */
.keypoints { margin: 2rem 0; padding: 20px 22px; border-radius: var(--radius); background: linear-gradient(135deg, var(--panel-2), var(--panel)); border: 1px solid var(--line); }
.keypoints h3 { margin: 0 0 10px; font-size: .82rem; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
.keypoints ul { margin: 0; padding-left: 1.2rem; }
.keypoints li { margin: .45rem 0; }

/* Checklist */
.checklist { margin: 1.6rem 0; padding: 18px 20px; border: 1px dashed var(--line-strong); border-radius: var(--radius); background: var(--panel); }
.checklist ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.checklist li { display: flex; gap: 10px; align-items: flex-start; margin: 0; font-size: .92rem; }
.checklist li::before { content: ""; flex: 0 0 auto; width: 17px; height: 17px; margin-top: 2px; border: 1.5px solid var(--line-strong); border-radius: 5px; background: var(--panel-2); }

/* Terms */
.term { border-bottom: 1px dotted var(--ink-mute); cursor: help; position: relative; }
.term:focus { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
.term-pop { position: fixed; z-index: 200; max-width: 320px; background: var(--ink); color: var(--paper); padding: 12px 14px; border-radius: 10px; font-size: .82rem; line-height: 1.5; box-shadow: var(--shadow-l); opacity: 0; transform: translateY(4px); transition: opacity .15s, transform .15s; pointer-events: none; }
.term-pop.is-visible { opacity: 1; transform: none; }
[data-theme="dark"] .term-pop { background: #05090d; color: #e8eef5; }
.term-pop b { display: block; margin-bottom: 3px; }

/* Quiz */
.quiz { margin: 2.4rem 0 1rem; padding: 22px 22px 16px; border-radius: var(--radius-l); background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); }
.quiz > h3 { margin: 0 0 4px; font-size: .82rem; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
.quiz .q { padding: 16px 0 4px; border-top: 1px solid var(--line); margin-top: 14px; }
.quiz .q:first-of-type { border-top: 0; margin-top: 6px; }
.q-text { font-weight: 650; margin: 0 0 12px; font-size: .98rem; }
.opt { display: block; width: 100%; text-align: left; margin: 7px 0; padding: 11px 14px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--panel-2); color: var(--ink); font: inherit; font-size: .9rem; cursor: pointer; transition: border-color .15s, background .15s, transform .1s; }
.opt:hover { border-color: var(--accent); }
.opt:active { transform: scale(.995); }
.opt.is-correct { border-color: var(--green); background: var(--green-soft); }
.opt.is-wrong { border-color: var(--red); background: var(--red-soft); }
.opt[disabled] { cursor: default; }
.q-feedback { margin: 10px 0 0; font-size: .87rem; padding: 10px 12px; border-radius: 8px; background: var(--panel-2); color: var(--ink-soft); }
.q-feedback.is-correct { background: var(--green-soft); color: var(--green); }
.q-feedback.is-wrong { background: var(--red-soft); color: var(--red); }
.quiz-score { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); font-size: .9rem; }

/* Lesson footer nav */
.lesson-nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 36px; padding-top: 22px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.lesson-nav .btn { max-width: 48%; }
.lesson-nav .btn span { display: block; font-size: .7rem; opacity: .7; font-weight: 500; }
.lesson-actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 26px 0 0; align-items: center; }
.done-state { display: inline-flex; align-items: center; gap: 8px; font-size: .86rem; color: var(--green); font-weight: 650; }

/* ---------- Interactives ---------- */
.lab { margin: 2.2rem 0; border-radius: var(--radius-l); border: 1px solid var(--line); background: var(--panel); box-shadow: var(--shadow); overflow: hidden; }
.lab-head { padding: 18px 22px 14px; border-bottom: 1px solid var(--line); background: linear-gradient(180deg, var(--panel-2), var(--panel)); }
.lab-head .lab-tag { display: inline-flex; align-items: center; gap: 6px; font-size: .7rem; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; color: var(--violet); background: var(--violet-soft); padding: 3px 9px; border-radius: 99px; margin-bottom: 8px; }
.lab-head h3 { margin: 0; font-size: 1.08rem; }
.lab-head p { margin: 5px 0 0; font-size: .86rem; color: var(--ink-mute); }
.lab-body { padding: 20px 22px 22px; }
.lab-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 22px; align-items: start; }
@media (max-width: 760px) { .lab-grid { grid-template-columns: 1fr; } }
.ctrl { display: grid; gap: 14px; }
.ctrl label { display: flex; justify-content: space-between; align-items: baseline; font-size: .84rem; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }
.ctrl output { font-family: var(--font-mono); font-size: .86rem; color: var(--accent); font-weight: 700; }
input[type="range"] { width: 100%; accent-color: var(--accent); height: 26px; cursor: pointer; }
.readout { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-top: 16px; }
.readout .ro { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.readout .ro span { display: block; font-size: .7rem; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-mute); }
.readout .ro b { font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.lab-canvas { background: var(--panel-2); border-radius: var(--radius); border: 1px solid var(--line); padding: 10px; display: grid; place-items: center; min-height: 180px; }
.lab-canvas svg { max-width: 100%; height: auto; display: block; }
.lab-note { font-size: .78rem; color: var(--ink-mute); margin: 12px 0 0; }

/* Hotspot diagrams */
.hotspot-wrap { position: relative; }
.hotspot-wrap svg { width: 100%; height: auto; display: block; }
.hotspot { cursor: pointer; transition: opacity .15s; }
.hotspot:hover { opacity: .82; }
.hotspot:focus { outline: none; }
.hotspot:focus-visible rect, .hotspot:focus-visible circle { stroke: var(--accent); stroke-width: 3; }
.hotspot-info { margin-top: 14px; min-height: 84px; padding: 14px 16px; border-radius: var(--radius); background: var(--panel-2); border: 1px solid var(--line); }
.hotspot-info h4 { margin: 0 0 4px; font-size: .98rem; color: var(--accent); }
.hotspot-info p { margin: 0; font-size: .87rem; color: var(--ink-soft); }

/* Machine selector */
.machine-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; margin: 22px 0 8px; }
.machine-card { display: flex; flex-direction: column; gap: 8px; padding: 20px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow-s); text-decoration: none; color: inherit; transition: transform .2s var(--ease), box-shadow .2s, border-color .2s; }
.machine-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--accent); }
.machine-card .mc-brand { font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-mute); }
.machine-card h3 { margin: 0; font-size: 1.15rem; }
.machine-card p { margin: 0; font-size: .84rem; color: var(--ink-mute); }
.machine-card .mc-specs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.machine-card .mc-specs span { font-size: .72rem; background: var(--panel-2); border: 1px solid var(--line); padding: 3px 8px; border-radius: 99px; color: var(--ink-soft); }
.machine-card .mc-go { margin-top: auto; display: flex; align-items: center; gap: 6px; font-size: .82rem; font-weight: 650; color: var(--accent); padding-top: 8px; }

/* ---------- Glossary ---------- */
.glossary-search { display: flex; gap: 10px; margin: 0 0 22px; }
.glossary-search input { flex: 1; padding: 12px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font: inherit; }
.glossary-search input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.glossary-list { display: grid; gap: 12px; }
.gl-item { padding: 16px 18px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.gl-item dt { font-weight: 750; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.gl-item dt .en { font-weight: 500; font-size: .78rem; color: var(--ink-mute); font-style: italic; }
.gl-item dd { margin: 6px 0 0; font-size: .9rem; color: var(--ink-soft); }

/* ---------- Search overlay ---------- */
.overlay { position: fixed; inset: 0; z-index: 150; background: rgba(9, 16, 24, .55); backdrop-filter: blur(3px); display: none; padding: clamp(14px, 6vh, 80px) 16px; overflow-y: auto; }
.overlay.is-open { display: block; }
.search-panel { max-width: 640px; margin: 0 auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-l); box-shadow: var(--shadow-l); overflow: hidden; }
.search-panel input { width: 100%; padding: 20px 22px; font: inherit; font-size: 1.05rem; border: 0; background: transparent; color: var(--ink); border-bottom: 1px solid var(--line); }
.search-panel input:focus { outline: none; }
.search-results { max-height: 60vh; overflow-y: auto; padding: 8px; }
.search-hit { display: block; width: 100%; text-align: left; padding: 12px 14px; border: 0; border-radius: 10px; background: transparent; color: inherit; font: inherit; cursor: pointer; }
.search-hit:hover, .search-hit:focus { background: var(--panel-2); outline: none; }
.search-hit .sh-mod { font-size: .68rem; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
.search-hit .sh-title { font-weight: 650; font-size: .95rem; margin: 2px 0; }
.search-hit .sh-snip { font-size: .8rem; color: var(--ink-mute); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-empty { padding: 22px; text-align: center; color: var(--ink-mute); font-size: .9rem; }

/* Lightbox */
.lightbox { position: fixed; inset: 0; z-index: 160; background: rgba(5, 9, 14, .92); display: none; place-items: center; padding: 28px; }
.lightbox.is-open { display: grid; }
.lightbox img { max-width: 100%; max-height: 88vh; border-radius: 10px; box-shadow: 0 30px 80px rgba(0,0,0,.6); }
.lightbox-close { position: absolute; top: 18px; right: 18px; width: 44px; height: 44px; border-radius: 50%; border: 1px solid rgba(255,255,255,.25); background: rgba(255,255,255,.08); color: #fff; cursor: pointer; display: grid; place-items: center; }
.lightbox-close svg { width: 20px; height: 20px; }

/* ---------- Misc ---------- */
.note { font-size: .86rem; color: var(--ink-mute); border-left: 2px solid var(--line-strong); padding-left: 12px; }
.empty-state { text-align: center; padding: 70px 20px; color: var(--ink-mute); }
.toast { position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px); z-index: 170; background: var(--ink); color: var(--paper); padding: 12px 20px; border-radius: 99px; font-size: .86rem; font-weight: 600; box-shadow: var(--shadow-l); opacity: 0; pointer-events: none; transition: opacity .2s, transform .25s var(--ease); }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
[data-theme="dark"] .toast { background: #e8eef5; color: #0c131c; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
kbd { font-family: var(--font-mono); }

/* Mobile drawer */
.scrim { position: fixed; inset: 0; background: rgba(9,16,24,.5); z-index: 35; display: none; }
.scrim.is-open { display: block; }
.bottom-bar { display: none; }

@media (max-width: 1024px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(86vw, 330px); z-index: 60; transform: translateX(-102%); transition: transform .3s var(--ease); box-shadow: var(--shadow-l); }
  .app.is-nav-open .sidebar { transform: none; }
  .app.is-nav-open .scrim { display: block; }
  .menu-btn { display: grid; }
  .content-wrap { padding-bottom: 96px; }
  .search-btn { min-width: 0; flex: 0 1 auto; }
  .search-btn .sb-label, .search-btn kbd { display: none; }
  .bottom-bar {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 45;
    background: color-mix(in srgb, var(--paper) 92%, transparent); backdrop-filter: blur(14px);
    border-top: 1px solid var(--line); padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  }
  .bottom-bar .btn { flex: 1; padding: 11px 10px; font-size: .84rem; }
  .hero-stats { gap: 18px; }
}

@media (max-width: 620px) {
  body { font-size: 16px; }
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar .crumb { font-size: .76rem; }
  .content-wrap { padding-left: 14px; padding-right: 14px; }
  .hero { border-radius: var(--radius); padding: 26px 20px; }
  .lesson-nav .btn { max-width: 100%; flex: 1 1 100%; }
  .quiz { padding: 18px 16px 12px; }
  .lesson-head h1 { font-size: 1.75rem; }
  table.tbl { font-size: .82rem; }
  .modal-grid { grid-template-columns: 1fr; }
}

@media (min-width: 1400px) {
  :root { --read-w: 920px; }
}

/* Print */
@media print {
  .sidebar, .topbar, .bottom-bar, .lesson-nav, .quiz, .lab, .toast, .overlay, .lightbox, .scrim, .lesson-actions { display: none !important; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .app { display: block; }
  .content-wrap { max-width: 100%; padding: 0; }
  .lesson h2 { break-after: avoid; }
  .fig, table.tbl, .callout { break-inside: avoid; }
  a { color: #000; text-decoration: none; }
}

/* ---------- Bloques visuales inyectados (enhebrado, diagramas) ---------- */
.steps-visual { list-style: none; counter-reset: vs; margin: 1.5rem 0; padding: 0; display: grid; gap: 10px; }
.steps-visual > li { counter-increment: vs; position: relative; padding: 12px 16px 12px 54px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-s); font-size: .93rem; }
.steps-visual > li::before { content: counter(vs); position: absolute; left: 14px; top: 11px; width: 27px; height: 27px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: .82rem; }
.steps-visual > li b { color: var(--ink); }
.steps-visual > li .s-note { display: block; font-size: .78rem; color: var(--ink-mute); margin-top: 3px; }
.fig-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 1.6rem 0; align-items: start; }
.fig-grid .fig { margin: 0; }
@media (max-width: 760px) { .fig-grid { grid-template-columns: 1fr; } }
.svg-fig { margin: 1.8rem 0; padding: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-s); }
.svg-fig svg { width: 100%; height: auto; display: block; border-radius: 8px; }
.svg-fig figcaption { margin-top: 10px; font-size: .83rem; color: var(--ink-mute); line-height: 1.5; }
.visual-intro { font-size: .95rem; color: var(--ink-soft); margin: 0 0 1rem; max-width: 72ch; }

/* ---------- estados de carga ---------- */
#lessonLoading { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 40vh; font-size: .95rem; }
.loading-dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line-strong); border-top-color: var(--accent); display: inline-block; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ==========================================================================
   ÍNDICE GENERAL
   ========================================================================== */
.index-page .lesson-head { margin-bottom: 22px; }
.idx-tools { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 18px; }
.idx-tools input { flex: 1 1 320px; min-width: 0; padding: 12px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font: inherit; box-shadow: var(--shadow-s); }
.idx-tools input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.idx-module { margin: 0 0 22px; border: 1px solid var(--line); border-radius: var(--radius-l); background: var(--panel); overflow: hidden; box-shadow: var(--shadow-s); }
.idx-module-head { display: flex; align-items: center; gap: 14px; padding: 16px 18px; background: linear-gradient(135deg, var(--m-soft), var(--panel) 70%); border-left: 5px solid var(--m-color); }
.idx-mod-icon { width: 42px; height: 42px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 12px; background: var(--panel); color: var(--m-color); box-shadow: var(--shadow-s); text-decoration: none; }
.idx-mod-icon svg { width: 21px; height: 21px; }
.idx-mod-title { flex: 1; min-width: 0; }
.idx-mod-title h2 { margin: 0; font-size: 1.18rem; line-height: 1.2; }
.idx-mod-title h2 a { color: var(--ink); text-decoration: none; }
.idx-mod-title h2 a:hover { color: var(--m-color); }
.idx-mod-title p { margin: 3px 0 0; font-size: .84rem; color: var(--ink-mute); }
.idx-eyebrow { margin: 0 0 2px !important; font-size: .68rem !important; letter-spacing: .12em; text-transform: uppercase; color: var(--m-color) !important; font-weight: 750; }
.idx-progress { text-align: right; flex: 0 0 auto; }
.idx-progress b { display: block; font-size: 1.1rem; color: var(--m-color); }
.idx-progress span { font-size: .72rem; color: var(--ink-mute); }
.idx-group { border-top: 1px solid var(--line); }
.idx-group:first-of-type { border-top: 0; }
.idx-group-label { display: flex; align-items: center; gap: 8px; padding: 12px 18px 0; font-size: .74rem; font-weight: 750; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-mute); }
.idx-brand { color: var(--m-color); }
.idx-group-icon { display: inline-flex; align-items: center; }
.idx-group-icon svg { width: 13px; height: 13px; }
.index-page svg { flex: 0 0 auto; }
.idx-lessons { display: grid; grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); gap: 10px; padding: 12px 18px 18px; }
.idx-lesson { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--paper-2); color: inherit; text-decoration: none; transition: transform .15s var(--ease), border-color .15s, box-shadow .15s; }
.idx-lesson:hover { transform: translateY(-2px); border-color: var(--m-color); box-shadow: var(--shadow-s); }
.idx-lesson.is-done { background: var(--green-soft); }
.idx-num { font-family: var(--font-mono); font-size: .72rem; color: var(--ink-mute); min-width: 20px; }
.idx-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.idx-body b { font-size: .875rem; font-weight: 650; line-height: 1.25; }
.idx-meta { font-size: .7rem; color: var(--ink-mute); }
.idx-go { color: var(--m-color); opacity: .65; flex: 0 0 auto; }
.idx-go svg { width: 15px; height: 15px; }
.idx-lesson:hover .idx-go { opacity: 1; }

/* ==========================================================================
   ÍNDICE DENTRO DE LA LECCIÓN + ANCLAS
   ========================================================================== */
.lesson-toc { margin: 0 0 26px; padding: 15px 18px 13px; border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow-s); transition: box-shadow .3s; }
.lesson-toc.is-flash { box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow); }
.lesson-toc h3 { display: flex; align-items: center; gap: 7px; margin: 0 0 9px; font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
.lesson-toc h3 svg { width: 13px; height: 13px; }
.lesson-toc ol { list-style: none; counter-reset: toc; margin: 0; padding: 0; columns: 2; column-gap: 24px; }
@media (max-width: 720px) { .lesson-toc ol { columns: 1; } }
.lesson-toc li { counter-increment: toc; margin: 0 0 5px; break-inside: avoid; }
.lesson-toc a { display: flex; gap: 8px; font-size: .855rem; color: var(--ink-soft); text-decoration: none; line-height: 1.35; padding: 2px 0; }
.lesson-toc a::before { content: counter(toc, decimal-leading-zero); font-family: var(--font-mono); font-size: .68rem; color: var(--accent); opacity: .8; padding-top: 2px; }
.lesson-toc a:hover { color: var(--accent); }
.lesson h2 { scroll-margin-top: 86px; position: relative; }
.lesson h2.is-target { background: var(--accent-soft); border-radius: 8px; padding: 8px 10px; margin-left: -10px; transition: background .3s; }
.anchor-link { margin-left: 8px; font-size: .78rem; color: var(--line-strong); text-decoration: none; opacity: 0; transition: opacity .15s; font-weight: 500; }
.lesson h2:hover .anchor-link, .anchor-link:focus { opacity: 1; color: var(--accent); }
@media (hover: none) { .anchor-link { opacity: .35; } }
.toc-fab { position: fixed; right: 20px; bottom: 26px; z-index: 42; display: inline-flex; align-items: center; gap: 7px; padding: 10px 14px; border-radius: 99px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font: inherit; font-size: .8rem; font-weight: 650; cursor: pointer; box-shadow: var(--shadow); opacity: .92; }
.toc-fab:hover { color: var(--accent); border-color: var(--line-strong); opacity: 1; }
.toc-fab svg { width: 15px; height: 15px; }
@media (max-width: 1024px) { .toc-fab { bottom: 84px; right: 14px; padding: 9px 12px; font-size: .76rem; } }
@media print { .toc-fab, .lesson-toc { display: none !important; } }
@media (max-width: 620px) { #printBtn { display: none; } .idx-lessons { grid-template-columns: 1fr; } .idx-module-head { flex-wrap: wrap; } .idx-progress { text-align: left; } }
