/* Buscador de imágenes — interfaz de trabajo (misma base visual del Generador SCORM) */
:root {
  --ink: #000000;
  --ink-2: #555555;
  --ink-3: #8A8A8A;
  --line: #D6D6D6;
  --field: #B8B8B8;
  --bg: #F2F2F2;
  --paper: #FFFFFF;
  --red: #C8102E;
  --red-dark: #9E0B22;
  --ok: #1D6B35;
  --font: "Archivo", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); }
a { color: var(--ink); }
h1, h2, h3 { font-stretch: 85%; line-height: 1.15; margin: 0; }
h1 { font-size: 30px; font-weight: 750; letter-spacing: -.01em; }
h2 { font-size: 20px; font-weight: 700; }
h3 { font-size: 16px; font-weight: 700; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
[hidden] { display: none !important; }

/* Barra superior */
.topbar { height: 52px; display: flex; align-items: center; gap: 18px; padding: 0 20px; background: #000; color: #fff; position: sticky; top: 0; z-index: 20; }
.app-name { color: #fff; font-weight: 750; font-stretch: 85%; font-size: 17px; text-decoration: none; }
.project .app-name::before { content: "‹ "; }
.topbar-title { flex: 1; min-width: 0; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #D0D0D0; }
.topbar-link { margin-left: auto; color: #fff; font-size: 14px; }
.save-state { font-size: 13px; color: #A8A8A8; white-space: nowrap; }
.save-state.error { color: #FF8A99; }

/* Navegación principal */
.topnav { margin-left: auto; display: flex; align-items: center; gap: 4px; font-size: 14px; }
.topnav a { color: #fff; text-decoration: none; padding: 6px 10px; border-radius: 3px; }
.topnav a:hover { background: rgba(255,255,255,.12); }
.topnav a[aria-current="page"] { box-shadow: inset 0 -3px 0 var(--red); border-radius: 0; }
.topnav .who { color: #A8A8A8; padding: 0 10px 0 14px; border-left: 1px solid #444; margin-left: 6px; }

/* Mensajes */
.stale { margin: 0; padding: 12px 20px; background: var(--red); color: #fff; font-weight: 600; }
.flash { padding: 12px 16px; margin: 0 0 22px; background: var(--paper); border-left: 5px solid var(--ok); }
.flash.error { border-left-color: var(--red); color: var(--red); }
.danger-text { color: var(--red); font-weight: 600; }

/* Botones */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 18px; border-radius: 4px; border: 1.5px solid var(--ink); background: var(--paper); color: var(--ink); font: 600 15px/1 var(--font); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover:not(:disabled) { background: #EAEAEA; }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--red-dark); border-color: var(--red-dark); }
.btn.ghost { border-color: transparent; background: transparent; text-decoration: underline; text-underline-offset: 3px; padding: 0 8px; }
.btn.ghost:hover:not(:disabled) { background: rgba(0,0,0,.06); }
.btn.small { height: 32px; padding: 0 12px; font-size: 14px; }
.btn.icon { width: 32px; height: 32px; padding: 0; font-size: 16px; }
.btn:disabled { opacity: .4; cursor: default; }
.btn.danger { color: var(--red); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* Campos */
label, .label { display: block; font-size: 14px; font-weight: 650; margin-bottom: 6px; }
input[type=text], input[type=number], input:not([type]), select, textarea {
  width: 100%; font: 15px/1.45 var(--font); color: var(--ink); background: var(--paper);
  border: 1px solid var(--field); border-radius: 3px; padding: 9px 11px;
}
textarea { resize: vertical; min-height: 64px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
input[type=color] { width: 56px; height: 40px; padding: 2px; border: 1px solid var(--field); border-radius: 3px; background: #fff; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; font-size: 15px; }
.check input { margin-top: 4px; width: 17px; height: 17px; accent-color: var(--ink); }
.help { font-size: 13px; color: var(--ink-2); margin-top: 5px; }
.field { margin-bottom: 18px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 20px; }
.err { color: var(--red); font-size: 14px; margin: 10px 0; }

/* Inicio */
.home { max-width: 920px; margin: 0 auto; padding: 40px 24px 80px; }
.home h1 { margin-bottom: 28px; }
.new-form { background: var(--paper); border-left: 6px solid var(--red); padding: 22px 24px; margin-bottom: 36px; }
.inline { display: flex; gap: 10px; }
.inline input { flex: 1; }
.list { width: 100%; border-collapse: collapse; background: var(--paper); }
.list th { text-align: left; font-size: 13px; font-weight: 650; color: var(--ink-2); padding: 12px 16px; border-bottom: 1.5px solid var(--ink); }
.list td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.list td a { font-weight: 650; text-decoration: none; }
.list td a:hover { text-decoration: underline; }
.list .end { text-align: right; }
.empty { background: var(--paper); padding: 28px; color: var(--ink-2); max-width: 64ch; }

/* Usuarios y cuenta */
.home.wide { max-width: 1180px; }
.home.narrow { max-width: 620px; }
.new-form h2 { margin-bottom: 16px; }
.ugrid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 20px; align-items: end; }
.ugrid label { margin-bottom: 6px; }
.ugrid-end { display: flex; justify-content: flex-end; }
.list tr.off td { color: var(--ink-3); }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; align-items: flex-start; }
.row-actions form { margin: 0; }
details.pw { position: relative; }
details.pw summary { list-style: none; }
details.pw summary::-webkit-details-marker { display: none; }
.pw-form { position: absolute; right: 0; top: 38px; z-index: 5; background: var(--paper); border: 1.5px solid var(--ink); padding: 12px; display: flex; gap: 6px; width: 400px; box-shadow: 0 8px 20px rgba(0,0,0,.12); }
.pw-form input { flex: 1; min-width: 0; }
.facts { margin: 0 0 24px; background: var(--paper); padding: 18px 24px; }
.facts div { display: grid; grid-template-columns: 110px 1fr; padding: 6px 0; }
.facts dt { color: var(--ink-2); }
.facts dd { margin: 0; font-weight: 600; }
.login-box label { margin-top: 2px; }

/* Login */
.login { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.login-box { background: var(--paper); width: 100%; max-width: 400px; padding: 36px 32px; border-top: 6px solid var(--red); }
.login-box h1 { margin-bottom: 8px; }
.login-box p { color: var(--ink-2); margin-bottom: 26px; }
.login-box input { margin-bottom: 18px; }
.login-box .btn { width: 100%; }

/* Proyecto: estructura general */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: calc(100vh - 52px); }
.rail { background: var(--paper); border-right: 1px solid var(--line); padding: 20px 0; position: sticky; top: 52px; height: calc(100vh - 52px); overflow-y: auto; }
.rail ol { list-style: none; margin: 0; padding: 0; }
.step { width: 100%; display: grid; grid-template-columns: 30px 1fr; gap: 12px; align-items: start; padding: 12px 20px; background: none; border: 0; text-align: left; font: inherit; cursor: pointer; color: var(--ink); }
.step:hover { background: var(--bg); }
.step .num { width: 28px; height: 28px; border: 1.5px solid var(--ink); border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 14px; }
.step.done .num { background: var(--bg); }
.step[aria-current="step"] { box-shadow: inset 4px 0 0 var(--red); }
.step[aria-current="step"] .num { background: var(--ink); color: #fff; }
.step .t { font-weight: 650; display: block; line-height: 1.3; margin-top: 3px; }
.step .s { font-size: 13px; color: var(--ink-2); display: block; }
.main { padding: 32px 40px 96px; min-width: 0; }
.view { max-width: 1060px; }
.view-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.view-head p { color: var(--ink-2); margin-top: 6px; max-width: 70ch; }
.panel { background: var(--paper); padding: 24px 26px; margin-bottom: 20px; }
.panel > h2 { margin-bottom: 16px; }
.lead { color: var(--ink-2); max-width: 70ch; margin-bottom: 18px; }
.warn { border-left: 5px solid var(--red); background: var(--paper); padding: 14px 18px; margin-bottom: 18px; }
.count { font-size: 13px; color: var(--ink-3); text-align: right; margin-top: 4px; }

/* Estructura */
.olist { list-style: none; margin: 0 0 16px; padding: 0; background: var(--paper); }
.orow { display: grid; grid-template-columns: 36px 170px 1fr auto; gap: 12px; align-items: start; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.orow .n { font-weight: 700; padding-top: 9px; font-variant-numeric: tabular-nums; }
.orow .txt { display: grid; gap: 6px; }
.orow .txt textarea { min-height: 44px; font-size: 14px; color: var(--ink-2); }
.orow .ops { display: flex; gap: 4px; padding-top: 4px; }
.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.tag::before { content: ""; width: 9px; height: 9px; border: 1.5px solid var(--ink); }
.tag.on::before { background: var(--ink); }
.tag.warn-dot::before { border-color: var(--red); background: var(--red); }

/* Contenido: editor de diapositivas */
.editor { display: grid; grid-template-columns: 270px 1fr; gap: 20px; align-items: start; }
.slist { background: var(--paper); position: sticky; top: 72px; max-height: calc(100vh - 92px); overflow-y: auto; }
.sbtn { width: 100%; display: grid; grid-template-columns: 26px 1fr; gap: 8px; padding: 11px 14px; background: none; border: 0; border-bottom: 1px solid var(--line); text-align: left; font: inherit; cursor: pointer; }
.sbtn:hover { background: var(--bg); }
.sbtn.cur { box-shadow: inset 4px 0 0 var(--red); background: #FAFAFA; }
.sbtn .n { font-weight: 700; font-variant-numeric: tabular-nums; }
.sbtn .t { display: block; font-weight: 600; line-height: 1.3; }
.sbtn .m { display: flex; gap: 10px; margin-top: 4px; }
.sbtn .tag { font-size: 12px; }
.sedit .panel { margin-bottom: 14px; }
.sedit-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sedit-head .lay { width: 190px; }
.irow { display: grid; grid-template-columns: 26px 200px 1fr 32px; gap: 10px; align-items: start; margin-bottom: 10px; }
.irow .n { padding-top: 9px; font-weight: 700; }
.irow.noh { grid-template-columns: 26px 1fr 32px; }
.orow-q { display: grid; grid-template-columns: 30px 1fr 32px; gap: 10px; align-items: center; margin-bottom: 8px; }
.orow-q input[type=radio] { width: 18px; height: 18px; accent-color: var(--ok); }
.seg { border: 1px solid var(--line); padding: 14px; margin-bottom: 10px; }
.seg-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
.seg-top .label { margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; align-items: center; }
.chips .help { margin: 0 6px 0 0; }
.chip { height: 28px; padding: 0 10px; border: 1px solid var(--field); border-radius: 14px; background: #fff; font: 13px/1 var(--font); cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip.taken { color: var(--ink-3); border-style: dashed; }
.seg audio { width: 100%; height: 36px; margin-top: 10px; }
.imgbox { display: grid; grid-template-columns: 1fr 260px; gap: 20px; align-items: start; }
.thumb { aspect-ratio: 16 / 10; background: var(--bg); border: 1px solid var(--line); display: grid; place-items: center; overflow: hidden; color: var(--ink-3); font-size: 13px; text-align: center; padding: 0; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb.svg img { object-fit: contain; background: #fff; }
.credit { font-size: 12px; color: var(--ink-3); margin-top: 6px; }
.meta-line { font-size: 13px; color: var(--ink-2); }

/* Imágenes y voz */
.mgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; margin-top: 16px; }
.mcard { font: 13px/1.4 var(--font); background: none; border: 0; padding: 0; text-align: left; cursor: pointer; color: var(--ink); }
.mcard:hover b { text-decoration: underline; }
.mcard .thumb { margin-bottom: 6px; }
.mcard b { display: block; font-weight: 600; line-height: 1.3; }
.stats { display: flex; flex-wrap: wrap; gap: 28px; margin: 4px 0 18px; }
.stat b { display: block; font-size: 26px; font-stretch: 85%; line-height: 1.1; }
.stat span { font-size: 13px; color: var(--ink-2); }
.checklist { list-style: none; margin: 0 0 20px; padding: 0; }
.checklist li { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.checklist li::before { content: ""; flex: none; width: 10px; height: 10px; margin-top: 6px; background: var(--ink); }
.checklist li.pending::before { background: var(--red); }
.download { border: 1.5px solid var(--ink); padding: 16px 18px; margin-top: 16px; display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; }

/* Progreso de tareas */
.job { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: grid; place-items: center; padding: 20px; z-index: 50; }
.job-box { background: var(--paper); width: 100%; max-width: 540px; padding: 26px 28px; border-top: 6px solid var(--red); }
.job-box h2 { margin-bottom: 16px; }
.job-bar { height: 6px; background: var(--bg); }
#jobFill { height: 100%; width: 0; background: var(--red); transition: width .3s ease; }
.job-now { margin: 12px 0; font-size: 14px; color: var(--ink-2); min-height: 21px; }
.job-log { list-style: none; margin: 0 0 16px; padding: 0; max-height: 180px; overflow-y: auto; font-size: 13px; }
.job-log li { padding: 6px 0; border-bottom: 1px solid var(--line); color: var(--red); }
.job-actions { display: flex; justify-content: flex-end; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; padding: 0; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
  .rail ol { display: flex; }
  .step { grid-template-columns: 28px auto; padding: 10px 14px; white-space: nowrap; }
  .step .s { display: none; }
  .main { padding: 22px 16px 80px; }
  .editor, .imgbox, .grid2, .grid3 { grid-template-columns: 1fr; }
  .slist { position: static; max-height: 260px; }
  .orow { grid-template-columns: 28px 1fr; }
  .orow .ops { grid-column: 2; }
  .irow { grid-template-columns: 22px 1fr 32px; }
  .irow .h { grid-column: 2; }
  .inline { flex-direction: column; }
  .ugrid { grid-template-columns: 1fr; }
  .topnav .who { display: none; }
  .list { display: block; overflow-x: auto; }
  .pw-form { width: min(400px, 86vw); flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ================================================================ Buscador de imágenes */
.view.wide { max-width: 1320px; }
.warn { margin-bottom: 14px; }
p.warn { padding: 12px 16px; }

/* Material */
.formats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fmt { display: grid; grid-template-columns: 20px 1fr; gap: 10px; align-items: start; padding: 14px 16px; border: 1.5px solid var(--line); cursor: pointer; font-weight: 400; margin: 0; }
.fmt:hover { border-color: var(--field); }
.fmt.on { border-color: var(--ink); box-shadow: inset 4px 0 0 var(--red); }
.fmt input { margin-top: 3px; width: 17px; height: 17px; accent-color: var(--ink); }
.fmt b { display: block; font-weight: 700; margin-bottom: 2px; }
.fmt .help { margin: 0; }
.sum-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 14px; }
.ulist { list-style: none; margin: 0; padding: 0; border-top: 1.5px solid var(--ink); }
.ulist li { display: grid; grid-template-columns: 22px 120px 1fr; gap: 12px; align-items: start; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.ulist li.off { color: var(--ink-3); }
.ulist input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--ink); }
.ulist .excerpt { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 13px; color: var(--ink-2); margin-top: 2px; }
.ulist li.off .excerpt { color: var(--ink-3); }
.code { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 13px; letter-spacing: .01em; }
.code.big { font-size: 14px; color: var(--red); margin-bottom: 4px; }

/* Lista de narraciones */
.ubtn { width: 100%; display: grid; grid-template-columns: 64px 1fr; gap: 10px; padding: 10px 12px; background: none; border: 0; border-bottom: 1px solid var(--line); text-align: left; font: inherit; cursor: pointer; color: var(--ink); }
.ubtn:hover { background: var(--bg); }
.ubtn.cur { box-shadow: inset 4px 0 0 var(--red); background: #FAFAFA; }
.ubtn.off { color: var(--ink-3); }
.ubtn .t { display: block; font-weight: 600; line-height: 1.3; font-size: 14px; margin: 1px 0 4px; }
.ubtn .tag { font-size: 12px; }
.mini { width: 64px; aspect-ratio: 16 / 9; background: var(--bg); border: 1px solid var(--line); overflow: hidden; display: block; }
.mini img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Detalle */
.detail { min-width: 0; scroll-margin-top: 70px; }
.d-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 14px; }
.d-head h2 { font-size: 24px; }
.panel h3 { margin-bottom: 12px; }
.panel.slim { padding: 14px 26px; }
.narr .label { margin-bottom: 4px; }
.narr-text { white-space: pre-line; max-width: 78ch; line-height: 1.55; }
.narr-text.small { font-size: 14px; color: var(--ink-2); margin-top: 8px; }
.narr details { margin-top: 10px; }
.narr summary { cursor: pointer; font-size: 14px; font-weight: 600; }
.choice { display: grid; grid-template-columns: minmax(0, 1.4fr) 1fr; gap: 22px; align-items: start; }
.choice .thumb { aspect-ratio: 16 / 9; }
.choice .thumb.free img { object-fit: contain; background: #fff; }
.choice-meta p { margin-bottom: 4px; }
.plan { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: baseline; background: var(--paper); border-left: 5px solid var(--ink); padding: 12px 18px; margin-bottom: 20px; }
.inline-label { display: inline; margin: 0; }
.pill { font-size: 12px; font-weight: 650; border: 1.5px solid var(--ink); padding: 2px 8px; border-radius: 12px; margin-left: auto; white-space: nowrap; }

/* Opciones de imagen */
.cgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; margin-top: 14px; }
.cand { margin: 0; min-width: 0; }
.cand button { display: block; position: relative; width: 100%; aspect-ratio: 16 / 9; padding: 0; border: 0; background: var(--bg); cursor: pointer; overflow: hidden; outline-offset: 2px; }
.cand img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .2s ease; }
.cgrid.free .cand img { object-fit: contain; }
.cand button:hover img { transform: scale(1.03); }
.cand button[aria-pressed="true"] { outline: 4px solid var(--red); }
.cand figcaption { font-size: 12px; color: var(--ink-3); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cand figcaption a { color: var(--ink-3); }
.badge { position: absolute; left: 6px; top: 6px; background: rgba(0,0,0,.78); color: #fff; font-size: 12px; font-weight: 600; padding: 3px 7px; }
.badge.sel { background: var(--red); }

@media (max-width: 900px) {
  .formats, .choice { grid-template-columns: 1fr; }
  .ulist li { grid-template-columns: 22px 1fr; }
  .ulist li > span:last-child { grid-column: 2; }
  .d-head { flex-direction: column; }
}
.nochoice { background: var(--paper); border-left: 5px solid var(--red); padding: 12px 18px; margin-bottom: 20px; color: var(--ink-2); }
.d-head .actions { flex-wrap: nowrap; flex: none; }
