/* Estilos propios mínimos; el resto con Tailwind (CDN). */
:root {
  --cb-primary: #0f4c81;
  --cb-accent: #f5a623;
}

#sw-update[hidden] {
  display: none;
}

.cb-focus:focus-visible {
  outline: 3px solid var(--cb-accent);
  outline-offset: 2px;
}

/* --- Página del estudiante: texto del docente en Markdown --------------------------------------------- */
.cb-prose { color: #334155; line-height: 1.65; }
.cb-prose > * + * { margin-top: 0.6rem; }
.cb-prose strong { color: #0f172a; font-weight: 650; }
.cb-prose em { color: #1e293b; }
.cb-prose a { color: var(--cb-primary); text-decoration: underline; }
.cb-prose ul, .cb-prose ol { padding-left: 1.25rem; }
.cb-prose ul { list-style: disc; }
.cb-prose ol { list-style: decimal; }
.cb-prose li + li { margin-top: 0.3rem; }
.cb-prose li::marker { color: #94a3b8; }
.cb-prose h3, .cb-prose h4 { color: #0f172a; font-weight: 650; margin-top: 1rem; }
.cb-prose h1 { color: #0f172a; font-weight: 700; font-size: 1.25rem; margin-top: 1.5rem; padding-bottom: 0.25rem; border-bottom: 1px solid #e2e8f0; }
.cb-prose h2 { color: #0f172a; font-weight: 650; font-size: 1.05rem; margin-top: 1.1rem; }
.cb-prose > h1:first-child { margin-top: 0; }
.cb-prose code { background: #f1f5f9; border-radius: 0.3rem; padding: 0.05rem 0.35rem; font-size: 0.9em; }
.cb-prose blockquote { border-left: 4px solid #f59e0b; background: #fffbeb; padding: 0.5rem 0.9rem; border-radius: 0.4rem; color: #78350f; }
.cb-prose table { width: 100%; border-collapse: collapse; font-size: 0.92em; display: block; overflow-x: auto; }
.cb-prose th { background: #f8fafc; color: #0f172a; font-weight: 600; text-align: left; }
.cb-prose th, .cb-prose td { border: 1px solid #e2e8f0; padding: 0.4rem 0.6rem; }

/* Barra del cronómetro: cambia de color al acercarse el final (lo decide activity.js). */
.cb-timer[data-level="warn"] { background: #b45309; }
.cb-timer[data-level="danger"] { background: #b91c1c; }

/* --- Visor de la guía (marco con scroll interno, como un PDF) --------------------------------------- */
.cb-viewer-pane { height: min(70vh, 760px); }
[data-viewer][data-expanded] .cb-viewer { position: fixed; inset: 0.75rem; z-index: 50; display: flex; flex-direction: column; }
[data-viewer][data-expanded] .cb-viewer-body { flex: 1; min-height: 0; }
[data-viewer][data-expanded] .cb-viewer-pane { height: auto; }

/* Página con estilo de libro: barra «Parte N», requisitos numerados con marca de paso, recuadros destacados. */
.cb-book { font-family: Georgia, "Times New Roman", serif; color: #1f2937; font-size: 1.02rem; line-height: 1.75; overflow-wrap: anywhere; }
.cb-book details { font-family: ui-sans-serif, system-ui, sans-serif; }
.cb-book strong { color: #0f172a; }
.cb-book p { margin: 0.55rem 0; }
.cb-book-intro p { text-indent: 1.6em; }
.cb-book-intro p:first-child { text-indent: 0; }
.cb-book .cb-part { display: flex; align-items: stretch; margin: 2.2rem 0 1rem; font-family: ui-sans-serif, system-ui, sans-serif; line-height: 1.25; }
.cb-book .cb-part-tag { background: #e8692a; color: #fff; font-weight: 700; font-size: 1.05rem; padding: 0.45rem 1rem; white-space: nowrap; }
.cb-book .cb-part-title { flex: 1; background: linear-gradient(90deg, #f7ece2, #d6d1c9); color: #1f2937; font-size: 1.1rem; padding: 0.45rem 1rem; }
.cb-book h3 { font-family: ui-sans-serif, system-ui, sans-serif; color: #d2581f; font-weight: 700; margin: 1.4rem 0 0.4rem; padding-left: 0.6rem; border-left: 3px solid #e8692a; }
.cb-book ul { list-style: disc; padding-left: 1.6rem; }
.cb-book ul li::marker { color: #e8692a; }
.cb-book pre { white-space: pre-wrap; font-size: 0.85rem; line-height: 1.55; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 0.5rem; padding: 0.75rem 1rem; margin: 0.8rem 0; }
.cb-book-body ol, .cb-book-intro ol { list-style: none; counter-reset: paso; padding-left: 0; }
.cb-book-body ol > li, .cb-book-intro ol > li { counter-increment: paso; position: relative; padding-left: 2.9rem; margin: 0.75rem 0; }
.cb-book-body ol > li::before, .cb-book-intro ol > li::before { content: counter(paso); position: absolute; left: 0; top: 0.25rem; min-width: 2.1rem;
  padding: 0.05rem 0.9rem 0.05rem 0.55rem; background: #e8692a; color: #fff; font: 700 0.85rem/1.5 ui-sans-serif, system-ui, sans-serif;
  clip-path: polygon(0 0, 72% 0, 100% 50%, 72% 100%, 0 100%); }
.cb-book blockquote { margin: 1.2rem 0; padding: 0.9rem 1.1rem; background: #f8dcc6; border-left: 4px solid #e8692a; font-family: ui-sans-serif, system-ui, sans-serif; font-size: 0.95rem; color: #3b2416; }
.cb-book blockquote::before { content: "Importante"; display: block; font-weight: 800; font-size: 0.75rem; letter-spacing: 0.12em; text-transform: uppercase; color: #c2410c; margin-bottom: 0.25rem; }
.cb-book blockquote p { margin: 0.2rem 0; text-indent: 0; }
.cb-book table { border-collapse: collapse; margin: 1rem 0; font-family: ui-sans-serif, system-ui, sans-serif; font-size: 0.92rem; display: block; overflow-x: auto; }
.cb-book th { background: #f7ece2; text-align: left; }
.cb-book th, .cb-book td { border: 1px solid #d6d1c9; padding: 0.4rem 0.8rem; }
.cb-book em { color: #374151; }
.cb-book-end { margin-top: 2.5rem; text-align: center; font: 600 0.75rem ui-sans-serif, system-ui, sans-serif; letter-spacing: 0.15em; text-transform: uppercase; color: #94a3b8; }
/* En el examen, el cronómetro sigue a la vista con la guía ampliada. */
body:has([data-viewer][data-expanded]) .cb-timer { position: fixed; top: 0.5rem; left: 0.75rem; right: 0.75rem; z-index: 60; margin: 0; }
body:has(.cb-timer) [data-viewer][data-expanded] .cb-viewer { top: 5.25rem; }
[data-viewer][data-expanded]::before { content: ""; position: fixed; inset: 0; z-index: 49; background: rgba(15, 23, 42, 0.65); }

/* --- Cuadro de confirmación propio (static/js/confirm.js) ------------------------------------------ */
.cb-confirm { border: 0; padding: 0; border-radius: 1.25rem; max-width: min(28rem, calc(100vw - 2rem)); width: 100%;
  box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.45); background: #fff; color: #0f172a; }
.cb-confirm::backdrop { background: rgba(15, 23, 42, 0.55); backdrop-filter: blur(2px); }
.cb-confirm[open] { animation: cb-confirm-in 0.14s ease-out; }
@keyframes cb-confirm-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
.cb-confirm-box { padding: 1.6rem 1.6rem 1.25rem; text-align: center; font-family: ui-sans-serif, system-ui, sans-serif; }
.cb-confirm-icon { width: 3.25rem; height: 3.25rem; margin: 0 auto 0.75rem; border-radius: 9999px; display: flex;
  align-items: center; justify-content: center; font-size: 1.5rem; font-weight: 800; }
.cb-confirm-title { font-size: 1.15rem; font-weight: 700; margin: 0; }
.cb-confirm-text { margin: 0.5rem 0 0; color: #475569; font-size: 0.95rem; line-height: 1.55; }
.cb-confirm-actions { display: flex; gap: 0.75rem; justify-content: center; margin-top: 1.4rem; flex-wrap: wrap; }
.cb-confirm-actions button { min-width: 8rem; padding: 0.65rem 1.2rem; border-radius: 0.75rem; font-weight: 600; font-size: 0.95rem; cursor: pointer; }
.cb-confirm-cancel { background: #fff; color: #334155; border: 1px solid #cbd5e1; }
.cb-confirm-cancel:hover { background: #f8fafc; }
.cb-confirm-ok { color: #fff; border: 0; }
.cb-confirm-ok:hover { filter: brightness(1.08); }

/* --- Lectura con vista de libro (learn/reading_book.html) ------------------------------------------- */
.cb-reader { font-family: ui-sans-serif, system-ui, "Segoe UI", Roboto, Arial, sans-serif; color: #1f2937; font-size: 1.0625rem; line-height: 1.75; overflow-wrap: break-word; }
.cb-reader > * + * { margin-top: 1rem; }
.cb-reader-eyebrow { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: #4f46e5; }
.cb-reader h1 { margin-top: 0.25rem; font-size: 1.85rem; line-height: 1.2; font-weight: 800; color: #1e3a8a; }
.cb-reader h2 { margin-top: 2.25rem; padding-bottom: 0.35rem; border-bottom: 2px solid #e0e7ff; font-size: 1.3rem; font-weight: 700; color: #1d4ed8; scroll-margin-top: 1rem; }
.cb-reader h3 { margin-top: 1.5rem; font-size: 1.1rem; font-weight: 700; color: #1e3a8a; }
.cb-reader strong { color: #0f172a; font-weight: 700; }
.cb-reader em { color: #334155; }
.cb-reader a { color: #4338ca; text-decoration: underline; text-underline-offset: 2px; }
.cb-reader ul, .cb-reader ol { padding-left: 1.4rem; }
.cb-reader ul { list-style: disc; }
.cb-reader ol { list-style: decimal; }
.cb-reader li + li { margin-top: 0.4rem; }
.cb-reader li::marker { color: #2563eb; font-weight: 700; }
.cb-reader code { background: #eef2ff; color: #be185d; border-radius: 0.3rem; padding: 0.05rem 0.35rem; font-size: 0.88em; }
.cb-reader pre { background: #0f172a; color: #e2e8f0; border-radius: 0.75rem; padding: 1rem 1.1rem; overflow-x: auto; font-size: 0.88rem; line-height: 1.6; }
.cb-reader pre code { background: none; color: inherit; padding: 0; }
.cb-reader blockquote { border-left: 5px solid #2563eb; background: #eff6ff; padding: 0.8rem 1.1rem; border-radius: 0.6rem; color: #1e3a8a; }
.cb-reader blockquote > * + * { margin-top: 0.5rem; }
.cb-reader table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.93rem; line-height: 1.5; display: block; overflow-x: auto; border-radius: 0.6rem; border: 1px solid #c7d2fe; }
.cb-reader thead th { background: #1e3a8a; color: #fff; font-weight: 600; text-align: left; }
.cb-reader th, .cb-reader td { overflow-wrap: normal; word-break: normal; hyphens: manual; min-width: 6.5rem; padding: 0.55rem 0.75rem; vertical-align: top; border-bottom: 1px solid #e0e7ff; }
.cb-reader tbody tr:nth-child(even) td { background: #f8faff; }
.cb-reader tbody tr:last-child td { border-bottom: 0; }
.cb-reader figure { margin: 1.75rem 0; text-align: center; }
.cb-reader figure img { display: inline-block; max-width: 100%; height: auto; border-radius: 0.75rem; box-shadow: 0 1px 3px rgb(15 23 42 / 0.12); border: 1px solid #e2e8f0; }
.cb-reader figcaption { margin-top: 0.6rem; font-size: 0.88rem; font-style: italic; color: #64748b; }
.cb-reader-missing { border: 1px dashed #94a3b8; border-radius: 0.75rem; padding: 2rem 1rem; color: #64748b; font-size: 0.9rem; }
.cb-reader-sections { list-style: none !important; padding: 0.75rem 1rem !important; background: #f8fafc; border-radius: 0.75rem; border: 1px solid #e2e8f0; font-size: 0.92rem; }
.cb-reader-sections li::marker { content: ""; }
.cb-reader-sections a { color: #334155; text-decoration: none; }
.cb-reader-sections a:hover { color: #1d4ed8; text-decoration: underline; }

/* --- Páginas del estudiante: hoja blanca sobre un escritorio de color ------------------------------- */
.cb-desk { background: #e9eef6 linear-gradient(180deg, #dfe7f3 0, #eef2f8 22rem) no-repeat; }
.cb-sheet { background: #fff; min-height: calc(100vh - 3rem); }
@media (min-width: 640px) {
  .cb-sheet { min-height: auto; box-shadow: 0 1px 2px rgb(15 23 42 / 0.06), 0 12px 32px -8px rgb(15 23 42 / 0.14); border: 1px solid rgb(203 213 225 / 0.7); }
}

/* --- Mostrar u ocultar el índice (lectura y guía de la tarea); la preferencia la recuerda app.js ------- */
@media (min-width: 768px) {
  [data-toc-scope][data-toc-hidden] [data-toc] { display: none !important; }
  [data-toc-scope][data-toc-hidden] .cb-book { max-width: 58rem; }
}
@media (min-width: 1024px) {
  [data-toc-scope].cb-reader-grid[data-toc-hidden] { grid-template-columns: minmax(0, 1fr); }
}

/* --- Pestañas (static/js/tabs.js) ------------------------------------------------------------------ */
[data-tabs] [role="tab"] { color: #64748b; border-bottom: 2px solid transparent; }
[data-tabs] [role="tab"]:hover { color: #0f172a; }
[data-tabs] [role="tab"].cb-tab-on { color: #0f172a; border-bottom-color: var(--cb-tab-color, var(--cb-primary)); }
[data-tabs] [role="tab"][data-tone="violet"].cb-tab-on { --cb-tab-color: #6d28d9; color: #5b21b6; }
/* Sin JavaScript no hay pestañas: se ven los dos paneles. */
[data-tabs]:not(:has(.cb-tab-on)) [role="tablist"] { display: none; }
