/* ===== Paleta ===== */
:root {
  --green:  #90C85B;  /* primario */
  --olive:  #555D51;  /* texto / oscuro */
  --purple: #A57AB5;  /* acento */
  --mint:   #E2F4EB;  /* superficie */
  --lgreen: #BCFEB7;  /* éxito / highlight */

  --green-d: #6fb53f;
  --rail-bg: #e9f4e2;
  --chip-bg: #e8f3e0;
  --bg:      #ffffff;
  --tinted:  #eef7ea;   /* fondo de pantallas "player" */
  --card:    #ffffff;
  --border:  #e6ece4;
  --text:    #2f352d;
  --muted:   #8a938a;
  --input-bg:#eef6e8;

  --correct-bg: #b8ef98;
  --correct-bd: #7fc24d;
  --wrong-bg:   #fde8e6;
  --wrong-bd:   #ecaaa4;
  --danger:     #c0584f;

  --radius:    16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(85,93,81,.05), 0 6px 18px rgba(85,93,81,.05);
  --rail: 96px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
[x-cloak] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
body.tinted { background: var(--tinted); }

a { color: var(--green-d); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { color: var(--olive); font-weight: 700; line-height: 1.2; }
h1 { font-size: 1.95rem; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 1.2rem; }
p { margin: .4rem 0; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .88em; }

/* ===== Nav superior ===== */
.topnav {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 1.6rem;
  background: var(--rail-bg); border-bottom: 1px solid var(--border);
  padding: .6rem clamp(1rem, 4vw, 3.2rem);
}
.topnav .brand { display: flex; align-items: center; gap: .6rem; }
.topnav .brand:hover { text-decoration: none; }
.topnav .brand .badge-circle {
  width: 44px; height: 44px; border-radius: 50%; background: #fff;
  display: grid; place-items: center; overflow: hidden; border: 1px solid var(--border); flex: none;
}
.topnav .brand .badge-circle .brand-logo { width: 168%; height: 168%; object-fit: contain; }
.topnav .brand .brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.topnav .brand .brand-name { color: var(--green-d); font-weight: 800; font-size: 1rem; }
.topnav .brand .brand-sub { color: var(--muted); font-size: .68rem; font-weight: 600; }

.topnav-links { display: flex; align-items: center; gap: .4rem; }
.topnav-links a, .nav-trigger {
  display: flex; align-items: center; gap: .4rem;
  color: var(--olive); font-size: .86rem; font-weight: 600; opacity: .85;
  padding: .45rem .7rem; border-radius: var(--radius-sm);
  background: transparent; border: none; cursor: pointer; font-family: inherit;
}
.topnav-links a:hover, .nav-trigger:hover { opacity: 1; text-decoration: none; background: rgba(0,0,0,.04); }
.topnav-links a.active, .nav-trigger.active { color: var(--green-d); opacity: 1; }
.topnav-links .icon { width: 18px; height: 18px; }

.nav-dropdown { position: relative; }
.nav-trigger .chev { width: 15px; height: 15px; opacity: .7; }
.nav-menu {
  position: absolute; top: calc(100% + .4rem); left: 0; z-index: 40;
  min-width: 190px; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow); padding: .35rem;
  display: flex; flex-direction: column; gap: .15rem;
}
.nav-menu a {
  display: flex; align-items: center; gap: .55rem; padding: .55rem .7rem;
  border-radius: 8px; color: var(--text); font-size: .88rem; font-weight: 600; opacity: 1;
}
.nav-menu a:hover { background: var(--mint); text-decoration: none; }
.nav-menu a.active { color: var(--green-d); background: var(--mint); }

.topnav-actions { margin-left: auto; display: flex; align-items: center; gap: .6rem; }
.topnav-actions .icon { width: 22px; height: 22px; color: var(--olive); }
.topnav-actions span, .topnav-actions a { color: var(--olive); display: inline-grid; place-items: center; cursor: pointer; }
.topnav-actions a:hover { color: var(--green-d); }

/* ===== Main ===== */
main { margin: 0 auto; padding: 1.6rem clamp(1rem, 4vw, 3.2rem) 4rem; max-width: 1240px; }

.crumbs { display: none; }

/* ===== Íconos ===== */
.icon { width: 1.2em; height: 1.2em; vertical-align: -.18em; stroke-width: 2; }
.icon.big { width: 48px; height: 48px; color: var(--green); }
.icon-missing { display: inline-block; width: 1.1em; height: 1.1em; }

/* chip de ícono (motivo recurrente) */
.icon-chip { width: 42px; height: 42px; border-radius: 12px; background: var(--chip-bg);
  display: inline-grid; place-items: center; flex: none; color: var(--green-d); }
.icon-chip .icon { width: 22px; height: 22px; }

/* ===== Botones ===== */
.btn, .icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  font: inherit; cursor: pointer; border: 1px solid var(--border);
  background: var(--card); color: var(--olive); border-radius: 999px;
}
.btn { padding: .55rem 1.1rem; font-weight: 600; }
.btn:hover { border-color: var(--green); text-decoration: none; }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.primary:hover { background: var(--green-d); }
.btn.primary[disabled], .btn[disabled] { opacity: .55; cursor: default; background: var(--border); border-color: var(--border); color: var(--muted); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn .icon { width: 1.05em; height: 1.05em; }

.icon-btn { width: 36px; height: 36px; padding: 0; color: var(--olive);
  background: transparent; border-color: transparent; }
.icon-btn:hover { background: var(--mint); color: var(--green-d); }
.icon-btn.danger { color: var(--danger); }
.icon-btn.danger:hover { background: #fbeceb; }
.icon-btn .icon { width: 19px; height: 19px; }

/* ===== Cards / listas ===== */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.5rem 1.6rem; }
.card-head { display: flex; align-items: center; gap: .8rem; margin-bottom: 1rem; }
.card-head h2 { margin: 0; }

.grid { display: grid; gap: 1.1rem; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }

.row { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.row.head { margin-bottom: 1.8rem; }
.row .actions { display: flex; align-items: center; gap: .35rem; }
.spacer { flex: 1; }

/* tarjeta (materia / documento / material) */
.tile {
  display: flex; flex-direction: column; gap: .6rem; background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 1.3rem 1.4rem;
  box-shadow: var(--shadow); transition: border-color .12s, box-shadow .12s; position: relative;
}
.tile:hover { border-color: var(--green); box-shadow: 0 2px 6px rgba(85,93,81,.08), 0 12px 28px rgba(85,93,81,.07); }
.tile .tile-title { font-weight: 700; font-size: 1.15rem; color: var(--olive); }
.tile .tile-title a { color: var(--olive); }
.tile .tile-title a:hover { text-decoration: none; color: var(--green-d); }
.tile:hover .tile-title a { color: var(--green-d); }
.tile .meta { color: var(--muted); font-size: .9rem; }

/* Card entera clickeable: el link del título se estira sobre toda la tile */
.tile { cursor: pointer; }
.tile .tile-title a::after { content: ""; position: absolute; inset: 0; z-index: 0; }
/* Botones quedan por encima del link estirado (preservando el absolute de .tile-del) */
.tile .icon-btn { position: relative; z-index: 2; }
.tile .icon-btn.tile-del { position: absolute; }
.tile .tile-del { position: absolute; top: .8rem; right: .8rem; opacity: 0; transition: opacity .12s; }
.tile:hover .tile-del { opacity: 1; }
.tile .tile-row { display: flex; align-items: center; gap: .8rem; }

/* ===== Formularios ===== */
input[type=text], input[type=number], input[type=password], select, textarea {
  font: inherit; color: var(--text); background: #fff;
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .6rem .8rem;
}
input::placeholder { color: #aab2a8; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--lgreen); border-color: var(--green); }
textarea { width: 100%; resize: vertical; min-height: 8rem; line-height: 1.5; }
label.field { display: flex; flex-direction: column; gap: .35rem; font-size: .82rem; color: var(--muted); font-weight: 500; }
.inline-form { display: inline-flex; align-items: center; gap: .5rem; }

/* ===== Edición inline ===== */
.inline-edit { display: inline-flex; align-items: center; gap: .4rem; }
.inline-edit .value { font-weight: inherit; }
.inline-edit .icon-btn { width: 30px; height: 30px; opacity: .55; }
.inline-edit:hover .icon-btn { opacity: 1; }
h1 .inline-edit .value { font-size: 1.95rem; }

/* ===== Chip de idioma + switch de carrera ===== */
.lang { display: inline-flex; align-items: center; gap: .4rem; border: 1px solid var(--border);
  border-radius: 999px; padding: .2rem .5rem .2rem .85rem; color: var(--olive); }
.lang .icon { color: var(--olive); width: 18px; height: 18px; }
.lang select, .career-switch { border: none; background: transparent; padding: .25rem 1.4rem .25rem .2rem; font-weight: 500; }
.lang select:focus, .career-switch:focus { outline: none; }
.career-switch { border: 1px solid var(--border); border-radius: 999px; padding: .4rem 1.6rem .4rem .8rem; }

/* ===== Badges / alerts ===== */
.badge { display: inline-flex; align-items: center; gap: .35rem; font-size: .76rem; font-weight: 700;
  padding: .25rem .7rem; border-radius: 999px; background: var(--chip-bg); color: var(--green-d); }
.badge .icon { width: 14px; height: 14px; }
.badge.ok      { background: var(--lgreen); color: #2f6d2c; }
.badge.warn    { background: #fdf3da; color: #8a6d1f; }
.badge.err     { background: #fbeceb; color: var(--danger); }
.badge.running { background: #efe1f6; color: #7a4b91; }

.alert { padding: .75rem 1rem; border-radius: var(--radius-sm); margin: .6rem 0; font-size: .9rem;
  display: flex; align-items: center; gap: .5rem; }
.alert.error { background: #fbeceb; color: var(--danger); }
.alert.info  { background: var(--lgreen); color: #2f6d2c; }

/* ===== Progreso ===== */
progress { width: 100%; height: 10px; border: none; border-radius: 999px; background: #fff; }
progress::-webkit-progress-bar { background: #fff; border-radius: 999px; }
progress::-webkit-progress-value { background: var(--green); border-radius: 999px; }
progress::-moz-progress-bar { background: var(--green); border-radius: 999px; }

/* ===== Estado vacío ===== */
.empty { text-align: center; color: var(--muted); padding: 3rem 1rem; display: flex;
  flex-direction: column; align-items: center; gap: .5rem; }
.empty h1 { color: var(--olive); }

/* ===== htmx ===== */
.htmx-indicator { opacity: 0; transition: opacity .2s; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
.htmx-request .when-idle { display: none; }

/* ===== Markdown (traducción) ===== */
.prose { max-width: 74ch; }
.prose h1, .prose h2, .prose h3 { margin-top: 1.6rem; }
.prose p { margin: .7rem 0; }
.prose table { border-collapse: collapse; margin: 1rem 0; }
.prose th, .prose td { border: 1px solid var(--border); padding: .4rem .6rem; }
.prose pre { background: var(--mint); padding: .8rem; border-radius: var(--radius-sm); overflow-x: auto; }
.prose code { background: var(--mint); padding: .1rem .3rem; border-radius: 4px; }
.term { color: var(--purple); font-weight: 600; }
.term[data-def] { cursor: help; border-bottom: 1px dashed color-mix(in srgb, var(--purple) 45%, transparent); }
.term[data-def]:hover, .term[data-def]:focus-visible { outline: none; background: var(--mint); border-radius: 4px; }

/* Popover de significado al hacer hover sobre un término del glosario */
.term-popover {
  position: fixed; z-index: 1000; max-width: 280px;
  background: var(--olive); color: #fff;
  padding: .5rem .7rem; border-radius: var(--radius-sm);
  font-size: .82rem; line-height: 1.4; font-weight: 400;
  box-shadow: var(--shadow); pointer-events: none;
  opacity: 0; transform: translateY(4px); transition: opacity .12s ease, transform .12s ease;
}
.term-popover.show { opacity: 1; transform: translateY(0); }
.term-popover .tp-term { display: block; color: var(--lgreen); font-weight: 700; margin-bottom: .15rem; }
.term-popover::after {
  content: ""; position: absolute; left: var(--tp-arrow, 50%); transform: translateX(-50%);
  border: 6px solid transparent;
}
.term-popover.below::after { top: -12px; border-bottom-color: var(--olive); }
.term-popover.above::after { bottom: -12px; border-top-color: var(--olive); }

/* Notas al margen y apéndice de glosario: solo existen al imprimir (PDF). */
.glossary-print, .prose .sidenote-box { display: none; }

/* ===== Glosario / conceptos ===== */
dl.glossary, dl.concepts { margin: 0; }
dl.glossary > div, dl.concepts > div { padding: .6rem 0; border-bottom: 1px solid var(--border); }
dl.glossary dt, dl.concepts dt { font-weight: 700; color: var(--olive); }
dl.concepts .core dt { color: var(--green-d); }
dl.glossary dd, dl.concepts dd { margin: .15rem 0 0; color: var(--text); }

/* ===== Quiz ===== */
.quiz .question { position: relative; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.4rem 1.6rem; margin: 0 0 1.1rem; background: #fff; box-shadow: var(--shadow); }
.quiz legend, .quiz .q-title { font-weight: 700; color: var(--olive); padding: 0; font-size: 1.05rem; margin-bottom: .9rem; display: block; }
.quiz .q-corner { position: absolute; top: 1.2rem; right: 1.3rem; }
.quiz .q-corner .icon { width: 22px; height: 22px; }
.quiz .q-corner.ok { color: var(--green-d); }
.quiz .q-corner.bad { color: var(--danger); }
.quiz label { display: flex; align-items: center; gap: .7rem; padding: .8rem 1rem; border-radius: 12px;
  cursor: pointer; border: 1px solid var(--border); margin-bottom: .6rem; transition: background .1s; }
.quiz label:hover { border-color: var(--green); }
.quiz label .opt-mark { margin-left: auto; display: inline-flex; }
.quiz label .opt-mark .icon { width: 20px; height: 20px; }
.quiz label.is-correct { background: var(--correct-bg); border-color: var(--correct-bd); color: #234e16; font-weight: 600; }
.quiz label.is-correct .opt-mark { color: #2f6d2c; }
.quiz label.is-wrong { background: var(--wrong-bg); border-color: var(--wrong-bd); color: var(--danger); }
.quiz label.is-correct input { accent-color: var(--green-d); }
.quiz label.is-wrong input { accent-color: var(--danger); }
.quiz input[type=radio], .quiz input[type=checkbox] { width: 18px; height: 18px; }
.quiz .explain { margin: .8rem 0 0; padding: .9rem 1.1rem; background: var(--mint); border-radius: 12px; font-size: .92rem; color: var(--olive); }
.quiz .explain .explain-head { display: flex; align-items: center; gap: .4rem; font-weight: 700; margin-bottom: .25rem; }
.quiz .explain .explain-head .icon { width: 16px; height: 16px; }

/* barra de acciones del quiz */
.quiz .actions { display: flex; align-items: center; gap: 1rem; border-top: 1px solid var(--border);
  margin-top: 1.4rem; padding-top: 1.2rem; }
.quiz .actions .score { font-size: 1rem; color: var(--olive); }
.quiz .actions .score b { color: var(--green-d); font-size: 1.15rem; }

/* ===== Completar espacios ===== */
.fill .sentence { margin: .7rem 0; line-height: 2.4; font-size: 1.02rem; }
.fill input { width: 10ch; text-align: center; padding: .3rem .4rem; }
.fill input.ok { background: var(--correct-bg); border-color: var(--correct-bd); }
.fill input.no { background: var(--wrong-bg); border-color: var(--wrong-bd); }
.fill .hint { color: var(--muted); font-size: .82rem; }

/* ===== Slides ===== */
.deck { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.deck .stage { background: var(--mint); min-height: 400px; padding: 2.5rem 3rem; display: flex; flex-direction: column; justify-content: center; }
.deck .stage h2 { font-size: 1.9rem; margin: 0 0 1rem; }
.deck .stage.title-layout { align-items: center; text-align: center; }
.deck .stage ul { font-size: 1.15rem; line-height: 1.9; }
.deck .two-col ul { columns: 2; gap: 2rem; }
.deck .bar { display: flex; align-items: center; gap: .75rem; padding: .7rem 1rem; border-top: 1px solid var(--border); background: #fff; }
.deck .dots { display: flex; gap: .35rem; flex: 1; flex-wrap: wrap; }
.deck .dot { width: 9px; height: 9px; border-radius: 999px; background: var(--border); border: none; padding: 0; cursor: pointer; }
.deck .dot.on { background: var(--purple); }
.deck .notes { padding: .9rem 1rem; background: #fff; border-top: 1px dashed var(--border); font-size: .9rem; color: var(--muted); }

/* ===== Unir con flechas ===== */
.match { position: relative; }
.match .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 7rem; position: relative; z-index: 1; }
.match .col { display: flex; flex-direction: column; gap: .7rem; }
.match .item { padding: .7rem .9rem; border: 1px solid var(--border); border-radius: 12px; background: #fff; cursor: pointer; text-align: center; box-shadow: var(--shadow); }
.match .item.sel { border-color: var(--purple); box-shadow: 0 0 0 2px #a57ab533; }
.match .item.done { background: var(--mint); }
.match svg.wires { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
.match svg line { stroke: var(--purple); stroke-width: 2.5; }
.match svg line.ok { stroke: var(--green); }
.match svg line.no { stroke: var(--danger); }

/* ===== Mapa conceptual ===== */
.cmap { width: 100%; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); }
.cmap svg { display: block; }
.cmap .node rect { fill: #fff; stroke: var(--green); stroke-width: 2; }
.cmap .node.root rect { fill: var(--green); }
.cmap .node text { fill: var(--olive); font-size: 13px; }
.cmap .node.root text { fill: #fff; font-weight: 600; }
.cmap .edge path { stroke: var(--purple); stroke-width: 1.5; fill: none; }
.cmap .edge text { fill: var(--muted); font-size: 11px; }

/* ===== Resumen ===== */
.summary .tldr { font-size: 1.05rem; background: var(--mint); padding: 1rem 1.2rem; border-radius: var(--radius); border-left: 4px solid var(--green); }
.summary .takeaways li { margin: .3rem 0; }

/* ===== Layouts auxiliares ===== */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 1.2rem; align-items: start; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .9rem 1.1rem; align-items: end; margin-bottom: 1.1rem; }

.divider { border: none; border-top: 1px solid var(--border); margin: 1.1rem 0 1.6rem; }
.back { color: var(--olive); display: inline-grid; place-items: center; }
.back .icon { width: 24px; height: 24px; }

.status-box { background: var(--mint); border-radius: 12px; padding: .9rem 1rem; margin: 1rem 0; }
.status-box .row { margin-bottom: .6rem; }

.prompt-body { white-space: pre-wrap; background: var(--mint); padding: .9rem; border-radius: var(--radius-sm);
  font-size: .85rem; max-height: 340px; overflow: auto; margin: .6rem 0 0; }

.section-label { color: var(--muted); font-size: .9rem; font-weight: 600; margin: 1.6rem 0 .7rem; }
.material { margin-top: .5rem; }

/* utilidades */
.muted { color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.mt { margin-top: 1.25rem; }
.tag-list { display: flex; flex-wrap: wrap; gap: .4rem; margin: .2rem 0 .8rem; }
.tag-list code { background: #eef0ec; padding: .25rem .55rem; border-radius: 999px; color: #6b746a; font-size: .8rem; }

/* back link de texto */
.back-link { display: inline-flex; align-items: center; gap: .4rem; color: var(--muted); font-weight: 600; font-size: .9rem; margin-bottom: .6rem; }
.back-link:hover { color: var(--green-d); text-decoration: none; }
.back-link .icon { width: 18px; height: 18px; }

/* fila de documento (full-width) */
.doc-row { display: flex; flex-direction: row; align-items: center; gap: 1rem; padding: 1.1rem 1.3rem; }
.doc-row .icon-chip { width: 46px; height: 46px; }
.doc-row .doc-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .3rem; }
.doc-row .doc-body .tile-title { font-size: 1.1rem; }
.doc-row.is-error { border-color: var(--wrong-bd); background: #fef7f6; }
.icon-chip.err { background: var(--wrong-bg); color: var(--danger); }

/* selector de archivo (pill) */
.file-field { display: inline-flex; align-items: center; gap: .5rem; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: #fff; padding: .3rem .3rem .3rem .9rem; }
.file-field input[type=file] { border: none; padding: 0; background: transparent; max-width: 220px; }
.file-field input[type=file]::file-selector-button { display: none; }
.file-field .upload-go { width: 38px; height: 38px; border-radius: 8px; padding: 0; }

/* traducción: lector + glosario */
.reader .reader-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; border-bottom: 1px solid var(--border); padding-bottom: 1rem; margin-bottom: 1.2rem; }
.reader .reader-head h2 { margin: 0; }
.reader .reader-actions { display: flex; gap: .2rem; }
.reader .reader-nav { display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--border); margin-top: 1.4rem; padding-top: 1.2rem; }
.gloss .gloss-search { width: 100%; background: var(--input-bg); border-color: transparent; margin: .2rem 0 1rem; }
.gloss .g-term { padding: .5rem 0; }
.gloss .g-term .t { color: var(--purple); font-weight: 700; }
.gloss .g-term .d { color: var(--text); display: flex; align-items: center; gap: .4rem; }
.gloss .g-term .d .icon { width: 14px; height: 14px; color: var(--muted); }
.add-term { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; border-top: 1px dashed var(--border); margin-top: .8rem; padding-top: .9rem; }
.add-term input { flex: 1; min-width: 90px; background: var(--input-bg); border-color: transparent; }
.btn.dashed { border: 1px dashed var(--green); color: var(--green-d); background: transparent; width: 100%; }

/* traducción: ancho completo + acciones */
body.wide main { max-width: none; }
.reader-full { width: 100%; }
.reader-full .prose { max-width: none; }
.trans-actions { display: flex; gap: .5rem; align-items: center; }
.count-chip { background: rgba(255,255,255,.28); border-radius: 999px; padding: 0 .45rem;
  font-size: .75rem; font-weight: 700; line-height: 1.5; margin-left: .1rem; }

/* glosario: drawer deslizable desde la derecha */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(20,30,16,.28); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 50;
  width: min(440px, 92vw); margin: 0; border-radius: 0; border: none; border-left: 1px solid var(--border);
  overflow-y: auto; transform: translateX(100%); transition: transform .28s ease; }
.drawer.open { transform: translateX(0); box-shadow: -10px 0 36px rgba(0,0,0,.16); }
.drawer .drawer-head { display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; border-bottom: 1px solid var(--border); padding-bottom: 1rem; margin-bottom: 1.1rem; }

/* prompts */
.card.editing { border-color: var(--green); box-shadow: 0 0 0 2px #90c85b22, var(--shadow); }
.prompt-foot { display: flex; align-items: center; justify-content: flex-end; gap: .6rem;
  border-top: 1px solid var(--border); margin-top: 1rem; padding-top: 1rem; }
.page-sub { color: var(--muted); margin: -.2rem 0 1.6rem; }

/* settings */
.info-box { background: var(--mint); border-radius: 12px; padding: .9rem 1rem; margin: 1rem 0 .8rem;
  display: flex; gap: .6rem; align-items: flex-start; }
.info-box .icon { width: 18px; height: 18px; color: var(--green-d); flex: none; margin-top: .15rem; }
.info-box .t { font-weight: 600; color: var(--olive); }
.info-box .s { color: var(--muted); font-size: .88rem; }
.field-help { color: var(--muted); font-size: .85rem; }
.set-foot { display: flex; justify-content: flex-end; border-top: 1px solid var(--border); margin-top: 1.1rem; padding-top: 1.1rem; }
details.cred summary { color: var(--green-d); font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: .4rem; list-style: none; }
details.cred summary::-webkit-details-marker { display: none; }
details.cred summary .icon { width: 16px; height: 16px; }
details.cred .body { color: var(--muted); font-size: .9rem; margin-top: .5rem; }

.gen-foot { display: flex; justify-content: flex-end; }

/* ===== Slides (refinado) ===== */
.deck .stage { background: #eaf0e6; border: 1px solid var(--border); border-radius: 18px; min-height: 420px; padding: 3rem 3.5rem; box-shadow: none; }
.deck .stage ul { list-style: none; padding: 0; margin: 0; }
.deck .stage li { display: flex; align-items: center; gap: .75rem; margin: .8rem 0; font-size: 1.15rem; }
.deck .stage li .icon { color: var(--green-d); width: 20px; height: 20px; flex: none; }
.deck .bar { background: transparent; border: none; padding: 0; margin-top: 1.5rem; justify-content: space-between; }
.deck .bar .icon-btn { width: 42px; height: 42px; }
.deck .bar .icon-btn .icon { width: 24px; height: 24px; }
.deck .bar .center { display: flex; align-items: center; gap: 1.2rem; }

/* ===== Mapa conceptual (refinado) ===== */
.cmap { position: relative; min-height: 560px; background-color: #fff;
  background-image: radial-gradient(#dbe4d6 1.4px, transparent 1.4px); background-size: 20px 20px; padding: 0; }
.cmap svg { display: block; transform-origin: top center; transition: transform .12s; }
.cmap .cmap-export { position: absolute; top: 14px; right: 14px; z-index: 2; padding: .45rem .9rem; }
.cmap .cmap-zoom { position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 2;
  display: flex; align-items: center; gap: .3rem; background: #fff; border: 1px solid var(--border);
  border-radius: 999px; padding: .25rem .5rem; box-shadow: var(--shadow); }
.cmap .cmap-zoom .sep { width: 1px; height: 18px; background: var(--border); margin: 0 .2rem; }

/* ===== Unir con flechas (refinado) ===== */
.match .subtitle, .fill .subtitle { color: var(--muted); margin: -.3rem 0 1.6rem; }
.match .col.left .item, .match .col.right .item { position: relative; }
.match .col.left .item::after, .match .col.right .item::after {
  content: ""; position: absolute; top: 50%; transform: translateY(-50%);
  width: 13px; height: 13px; border-radius: 50%; background: #fff; border: 2px solid var(--purple); }
.match .col.left .item::after { right: -7px; }
.match .col.right .item::after { left: -7px; }
.match .actions { display: flex; align-items: center; gap: 1rem; border-top: 1px solid var(--border); margin-top: 2rem; padding-top: 1.3rem; }
.match .actions .score { color: var(--olive); display: inline-flex; align-items: center; gap: .45rem; }
.match .actions .score.ok { color: var(--green-d); font-weight: 700; }
.match svg path.wire { stroke: var(--purple); stroke-width: 2.5; fill: none; }
.match svg path.wire.ok { stroke: var(--green); }
.match svg path.wire.no { stroke: var(--danger); }
.match svg circle.end { fill: #fff; stroke: var(--purple); stroke-width: 2; }

/* ===== Completar espacios (refinado) ===== */
.fill .sentence-card { border: 1px solid var(--border); border-radius: var(--radius); background: #fff;
  padding: 1.2rem 1.4rem; margin-bottom: 1rem; box-shadow: var(--shadow); font-size: 1.05rem; line-height: 2.2; }
.fill .sentence-card.bad { border-color: var(--wrong-bd); background: #fef7f6; }
.fill input.blank { width: 11ch; text-align: center; background: var(--input-bg); border-color: transparent; }
.fill .pill { display: inline-flex; align-items: center; gap: .4rem; padding: .15rem .7rem; border-radius: 999px; font-weight: 600; vertical-align: middle; }
.fill .pill.ok { background: var(--correct-bg); color: #234e16; }
.fill .pill.no { background: var(--wrong-bg); color: var(--danger); }
.fill .pill .icon { width: 16px; height: 16px; }
.fill .feedback { display: flex; align-items: center; gap: .4rem; color: var(--danger); font-size: .9rem; margin-top: .7rem; line-height: 1.4; }
.fill .feedback .icon { width: 16px; height: 16px; flex: none; }
.fill .progress-bar { display: flex; align-items: center; gap: 1rem; border-top: 1px solid var(--border); margin-top: 1.6rem; padding-top: 1.3rem; }
.fill .progress-bar .prog { display: inline-flex; align-items: center; gap: .45rem; color: var(--olive); }
.fill .progress-bar .prog .icon { color: var(--green-d); }

/* ===== Impresión / Export PDF (página de traducción) ===== */
@media print {
  @page { margin: 1.8cm 1.8cm 2cm; }

  /* Ocultar chrome de UI: nav, drawer, acciones e íconos.
     Lucide reemplaza <i data-lucide> por <svg class="icon">, así que ocultamos por ambas. */
  .topnav, .back-link, .trans-actions, .trans-status,
  .drawer, .drawer-backdrop, .alert, .reader-actions,
  .row.head .icon, .reader-head .icon, [data-lucide] { display: none !important; }

  /* Imprimir colores de fondo/acentos (Chrome "Guardar como PDF"). */
  html, body, .reader.card, .prose th, .prose tr td, .prose blockquote,
  .prose pre, .prose code, .reader .reader-head {
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }

  html, body { background: #fff !important; }
  body { font-size: 11.5pt; line-height: 1.62; color: var(--text); }
  main { margin: 0 !important; max-width: none !important; padding: 0 !important; }

  /* Encabezado tipo portada: "TRADUCCIÓN" como kicker + título destacado. */
  .row.head { margin: 0 0 .1rem !important; }
  .row.head h1 {
    font-size: .72rem !important; font-weight: 700; letter-spacing: .16em;
    text-transform: uppercase; color: var(--green-d); gap: 0 !important;
  }
  .reader.card { border: none !important; box-shadow: none !important; padding: 0 !important; background: #fff !important; }
  .reader .reader-head { border-bottom: 3px solid var(--green); padding-bottom: .5rem; margin-bottom: 1.5rem; }
  .reader .reader-head h2 { font-size: 1.85rem; color: var(--olive); letter-spacing: -.01em; }

  /* Cuerpo del documento. */
  .prose { max-width: none !important; }
  .prose h1, .prose h2, .prose h3 { color: var(--olive); break-after: avoid; }
  .prose h2 { border-bottom: 1px solid var(--mint); padding-bottom: .15rem; }
  .prose h3 { color: var(--green-d); }
  .prose p { text-align: justify; orphans: 3; widows: 3; }
  .prose li { orphans: 3; widows: 3; }
  .prose blockquote {
    border-left: 3px solid var(--green); background: #f5fbf1; color: #4a5146;
    margin: 1rem 0; padding: .55rem .95rem; font-style: italic; border-radius: 0 8px 8px 0;
    break-inside: avoid;
  }
  .prose pre, .prose table, .prose img, .prose figure { break-inside: avoid; }
  .prose pre { background: #f3f8ee; border: 1px solid var(--border); }
  .prose code { background: var(--mint); }
  .prose table { width: 100%; }
  .prose th { background: var(--mint); color: var(--olive); }
  .prose th, .prose td { border-color: #d6e3cd; }
  .prose tbody tr:nth-child(even) td { background: #f6fbf3; }
  .prose a { color: inherit; text-decoration: none; }
  a[href]::after { content: ""; }
  .prose .term { color: var(--purple); background: none; font-weight: 600; }

  /* Notas al margen (sidenotes): reservamos un margen derecho ancho y colgamos
     en él la traducción de cada término, anclada a su párrafo. */
  .prose.with-sidenotes { margin-right: 6.6cm; }
  .prose.with-sidenotes .sidenote-box {
    display: block; position: absolute; top: 0; right: -6.6cm; width: 6cm;
  }
  .prose .sidenote {
    display: block; margin-bottom: .32cm; padding-left: .42cm;
    border-left: 2px solid var(--purple);
    font-size: 8.4pt; line-height: 1.32; text-align: left;
    break-inside: avoid;
  }
  .prose .sidenote .sn-term { display: block; color: var(--purple); font-weight: 700; }
  .prose .sidenote .sn-def { display: block; color: var(--text); }

  /* Apéndice de glosario: arranca en página nueva al final del documento. */
  .glossary-print { display: block; break-before: page; }
  .glossary-print h2 {
    color: var(--olive); border-bottom: 1px solid var(--mint);
    padding-bottom: .15rem; break-after: avoid;
  }
  .glossary-print dl.glossary { margin: 0; }
  .glossary-print dl.glossary > div {
    padding: .35rem 0; border-bottom: 1px solid var(--border); break-inside: avoid;
  }
  .glossary-print dl.glossary dt { font-weight: 700; color: var(--purple); }
  .glossary-print dl.glossary dd { margin: .1rem 0 0; color: var(--text); }
}

/* =========================================================================
   Biblioteca de componentes
   Controles de formulario, tablas de datos y listas. Clases reutilizables
   (.ctrl, .form-field, .check, .radio, .switch, .data-table, .doc-item, …).
   ========================================================================= */

/* ----- Layout de sección ----- */
.section-title { font-size: 1.15rem; color: var(--olive); margin: 0 0 1rem; }
.section-title.ruled { border-bottom: 1px solid var(--border); padding-bottom: .6rem; }
.cols-2 { display: grid; gap: 1.4rem; grid-template-columns: 1fr 1fr; align-items: start; }
.cols-form { display: grid; gap: 1.4rem; grid-template-columns: 1.55fr 1fr; align-items: start; }
@media (max-width: 880px) { .cols-2, .cols-form { grid-template-columns: 1fr; } }

/* ----- Campo (label + control) ----- */
.form-field { display: flex; flex-direction: column; gap: .4rem; }
.form-field > .lbl { font-size: .92rem; font-weight: 500; color: var(--text); }
.field-grid { display: grid; gap: 1.1rem 1.2rem; grid-template-columns: 1fr 1fr; }
@media (max-width: 560px) { .field-grid { grid-template-columns: 1fr; } }
.field-error { color: var(--danger); font-size: .82rem; }

/* ----- Control base (input / select / textarea) ----- */
.ctrl {
  width: 100%; font: inherit; color: var(--text);
  background: var(--input-bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .7rem .85rem;
  transition: border-color .12s, box-shadow .12s, background .12s;
}
.ctrl::placeholder { color: #9aa69a; }
.ctrl:hover { border-color: color-mix(in srgb, var(--green) 45%, var(--border)); }
.ctrl:focus, .ctrl.is-focus {
  outline: none; background: #fff; border-color: var(--green-d);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 28%, transparent);
}
.ctrl.is-error {
  background: #fdecec; border-color: #e3a39c; color: var(--danger);
}
.ctrl.is-error::placeholder { color: color-mix(in srgb, var(--danger) 55%, #fff); }
textarea.ctrl { resize: vertical; min-height: 7rem; line-height: 1.5; }

/* Control con ícono/botón adosado (lupa, ojo, chevron, etc.) */
.input-affix { position: relative; display: flex; align-items: center; }
.input-affix .ctrl { width: 100%; }
.input-affix.has-leading .ctrl { padding-left: 2.5rem; }
.input-affix.has-trailing .ctrl { padding-right: 2.6rem; }
.input-affix .affix { position: absolute; display: inline-grid; place-items: center; color: var(--muted); }
.input-affix .affix .icon { width: 18px; height: 18px; }
.input-affix .affix.lead { left: .75rem; pointer-events: none; }
.input-affix .affix.trail { right: .55rem; }
.input-affix button.affix { background: none; border: none; cursor: pointer; padding: .3rem; border-radius: 8px; }
.input-affix button.affix:hover { color: var(--green-d); background: rgba(0,0,0,.04); }
/* select: flecha propia (chevron-down) para un look consistente con el affix */
select.ctrl {
  appearance: none; -webkit-appearance: none; padding-right: 2.4rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238a938a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .8rem center; background-size: 1rem;
}

/* ----- Checkbox / Radio ----- */
.check, .radio { display: inline-flex; align-items: center; gap: .55rem; cursor: pointer; font-size: .95rem; color: var(--text); }
.check input, .radio input { width: 18px; height: 18px; margin: 0; accent-color: var(--green-d); cursor: pointer; flex: none; }
.opt-group { display: flex; flex-direction: column; gap: .6rem; }
.opt-label { font-size: .92rem; font-weight: 500; color: var(--text); margin-bottom: .2rem; }

/* ----- Switch (toggle) ----- */
.switch {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  background: var(--input-bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .65rem .85rem; cursor: pointer;
}
.switch .switch-label { font-weight: 500; }
.switch .switch-ctl { position: relative; display: inline-flex; flex: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  width: 44px; height: 24px; border-radius: 999px; background: #c8d2c2;
  position: relative; transition: background .15s;
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s;
}
.switch input:checked + .track { background: var(--green); }
.switch input:checked + .track::after { transform: translateX(20px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 30%, transparent); }

/* ----- Footer de formulario ----- */
.card-foot {
  display: flex; justify-content: flex-end; align-items: center; gap: .6rem;
  margin-top: 1.3rem; padding-top: 1.1rem; border-top: 1px solid var(--border);
}

/* ----- Panel con cabecera (tabla) ----- */
.panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1rem 1.3rem; background: var(--mint); border-bottom: 1px solid var(--border); }
.panel-head h3 { margin: 0; font-size: 1.05rem; color: var(--olive); }

/* ----- Tabla de datos ----- */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left; font-size: .8rem; font-weight: 600; color: var(--muted);
  padding: .7rem 1.3rem; background: color-mix(in srgb, var(--mint) 50%, #fff);
  border-bottom: 1px solid var(--border);
}
.data-table td { padding: .9rem 1.3rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--tinted); }
.data-table .col-right { text-align: right; }
.th-sort { display: inline-flex; align-items: center; gap: .25rem; cursor: pointer; color: inherit; }
.th-sort .icon { width: 13px; height: 13px; opacity: .7; }
.th-sort:hover { color: var(--green-d); }
.cell-name { display: flex; align-items: center; gap: .7rem; font-weight: 600; color: var(--olive); }
.cell-name .folder { width: 20px; height: 20px; flex: none; }
.cell-name .folder.g { color: var(--green-d); }
.cell-name .folder.p { color: var(--purple); }
.cell-name .folder.o { color: var(--olive); }
.data-table .muted { color: var(--muted); }
.row-actions { opacity: 0; transition: opacity .12s; }
.data-table tr:hover .row-actions { opacity: 1; }

/* ----- Lista de documentos ----- */
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .4rem; }
.list-head h3 { margin: 0; font-size: 1.02rem; color: var(--olive); }
.doc-list { display: flex; flex-direction: column; }
.doc-item { display: flex; align-items: center; gap: .9rem; padding: .85rem .2rem; }
.doc-item + .doc-item { border-top: 1px solid var(--border); }
.doc-item.is-active { background: var(--tinted); border-radius: var(--radius-sm); padding: .85rem .8rem; }
.doc-item.is-active + .doc-item, .doc-item + .doc-item.is-active { border-top: none; }
.doc-ico { width: 44px; height: 44px; border-radius: 10px; background: var(--mint);
  display: grid; place-items: center; color: var(--green-d); flex: none; }
.doc-ico .icon { width: 22px; height: 22px; }
.doc-ico.pdf { background: #efe1f6; color: var(--purple); font-size: .55rem; font-weight: 800; letter-spacing: .02em; }
.doc-main { flex: 1; min-width: 0; }
.doc-name { font-weight: 600; color: var(--olive); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-sub { color: var(--muted); font-size: .85rem; }
.doc-progress { margin-top: .5rem; }
.doc-progress .p-label { color: var(--purple); font-size: .82rem; margin-top: .3rem; }
.list-foot { text-align: center; margin-top: .5rem; padding-top: .9rem; border-top: 1px solid var(--border); }
.list-foot a { font-weight: 600; }

/* Badge en mayúsculas tipo etiqueta de estado (LISTO / PROCESANDO) */
.badge.tag { text-transform: uppercase; letter-spacing: .04em; font-size: .68rem; }

/* progress variante "procesando" (violeta) */
progress.proc::-webkit-progress-value { background: var(--purple); }
progress.proc::-moz-progress-bar { background: var(--purple); }
progress.proc { background: #ece2f2; }
progress.proc::-webkit-progress-bar { background: #ece2f2; }

/* ----- Lista de términos del glosario ----- */
.search-box { position: relative; display: inline-flex; align-items: center; }
.search-box .icon { position: absolute; left: .75rem; width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.search-box input { padding-left: 2.2rem; border-radius: 999px; min-width: 220px; }
.term-list { display: flex; flex-direction: column; }
.term-item { padding: .9rem 0; }
.term-item + .term-item { border-top: 1px solid var(--border); }
.term-item .t-name { color: var(--green-d); font-weight: 700; margin: 0 0 .25rem; }
.term-item .t-def { color: var(--text); font-size: .92rem; line-height: 1.5; margin: 0; }
