/* Visores de imágenes y cómics: la imagen dispone de un escenario propio. */
html.cm-lock,html:has(#lb[open]) { scrollbar-gutter:auto; }
#lb {
  width:100vw; height:100dvh; max-width:none; max-height:none; inset:0;
  margin:0; padding:0; border:0; color:#edf0f5; background:#070c14;
  font:500 14px/1.5 var(--ui-font,Arial,sans-serif); overflow:hidden;
}
#lb[open] { display:grid; grid-template-rows:auto minmax(0,1fr) auto; }
#lb:not([open]), #lb [hidden], .cm [hidden] { display:none!important; }
#lb::backdrop { background:#02050bee; }
#lb .iv-header {
  display:flex; align-items:center; justify-content:space-between; gap:20px;
  min-height:76px; padding:12px max(22px,env(safe-area-inset-right)) 12px max(22px,env(safe-area-inset-left));
  border-bottom:1px solid #283448; background:#0d1522;
}
.iv-caption { min-width:0; }
.iv-eyebrow { display:block; font-size:10px; font-weight:700; letter-spacing:.14em; text-transform:uppercase; color:#bfa575; margin-bottom:3px; }
#lb #lbtitle { font:650 17px/1.4 var(--ui-font,Arial,sans-serif); text-transform:none; letter-spacing:0; margin:0; padding:0; border:0; overflow:hidden; white-space:nowrap; text-overflow:ellipsis; }
.iv-header-actions,.iv-navigation,.iv-zoom { display:flex; align-items:center; gap:8px; }
#lb button {
  display:inline-flex; align-items:center; justify-content:center; gap:8px;
  min-width:44px; min-height:44px; padding:9px 13px; border:1px solid #35445c;
  border-radius:9px; background:#131e2f; color:#e5eaf2;
  font:600 13px/1.4 var(--ui-font,Arial,sans-serif); cursor:pointer; box-shadow:none;
}
#lb button:hover { background:#203048; border-color:#b89961; }
#lb button:disabled { opacity:.3; cursor:default; }
#lb button[aria-pressed="true"] { background:#e5b65d1a; color:#f0ca84; border-color:#9e7b43; }
#lb button.iv-icon { padding:9px; }
#lb button.iv-close { border-color:#8a7149; background:#b58e4020; color:#f0ca84; }
#lb button .ifc-icon { width:19px; height:19px; flex-shrink:0; }
#lb :focus-visible { outline:2px solid #f0ca84; outline-offset:3px; }
#lb .iv-stage {
  position:relative; inset:auto; display:block; min-width:0; min-height:0;
  overflow:hidden; touch-action:none; cursor:zoom-in;
  background:radial-gradient(ellipse at 50% 50%,#14203333,transparent 72%),#070c14;
}
#lb .iv-stage:focus-visible { outline-offset:-4px; }
#lb .iv-stage.iv-zoomed { cursor:grab; }
#lb .iv-stage.iv-dragging { cursor:grabbing; }
#lb.iv-focus { grid-template-rows:0 minmax(0,1fr) 0; }
#lb.iv-focus .iv-header,#lb.iv-focus .iv-toolbar { position:absolute; visibility:hidden; pointer-events:none; }
#lb.iv-focus .iv-stage { grid-row:2; }
#lb .iv-restore { position:absolute; top:calc(12px + env(safe-area-inset-top)); right:max(12px,env(safe-area-inset-right)); z-index:8; background:#0d1522eb; }
#lb #lbimg {
  display:block; position:absolute; top:0; left:0; max-width:none; max-height:none;
  transform-origin:0 0; border:0; border-radius:2px; background:transparent;
  box-shadow:0 12px 60px #0007; user-select:none; -webkit-user-drag:none;
}
#lb .iv-toolbar {
  display:grid; grid-template-columns:minmax(130px,1fr) auto minmax(130px,1fr);
  align-items:center; gap:18px; min-height:80px;
  padding:13px max(22px,env(safe-area-inset-right)) calc(13px + env(safe-area-inset-bottom)) max(22px,env(safe-area-inset-left));
  border-top:1px solid #283448; background:#0d1522;
}
.iv-navigation { grid-column:1; }
.iv-navigation output { min-width:54px; text-align:center; color:#bdc8da; font-size:12px; font-variant-numeric:tabular-nums; }
.iv-zoom { grid-column:2; justify-content:center; }
#lbzoom { min-width:48px; text-align:center; color:#f0ca84; font:650 14px/1.5 var(--ui-font,Arial,sans-serif); font-variant-numeric:tabular-nums; }
.iv-dimensions { grid-column:3; justify-self:end; color:#93a3b9; font-size:11px; font-variant-numeric:tabular-nums; }
.iv-load { position:absolute; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:14px; color:#aab9ce; text-align:center; padding:24px; }
.iv-load p { margin:0; }
.iv-spinner { width:30px; height:30px; border:2px solid #e5b65d2b; border-top-color:#e5b65d; border-radius:50%; animation:iv-spin .8s linear infinite; }
.iv-error .iv-spinner { display:none; }
@keyframes iv-spin { to { transform:rotate(360deg); } }
#chars .char { position:relative; isolation:isolate; }
.character-enlarge {
  position:absolute; top:12px; right:12px; z-index:4; display:grid; place-items:center;
  width:44px; height:44px; padding:9px; border:1px solid #d2ad69a6; border-radius:10px;
  color:#f4d293; background:#091221e8; cursor:zoom-in; opacity:0;
  transition:opacity .15s; box-shadow:0 4px 18px #0005;
}
.character-enlarge .ifc-icon { width:20px; height:20px; }
.char:hover .character-enlarge,.character-enlarge:focus-visible { opacity:1; }
.character-enlarge:hover { background:#e5b65d; color:#0c1421; }

/* Cómic: portada original, controles fuera de la página y navegación visible. */
#cm {
  --g:var(--accent,#e5b65d); display:grid; grid-template-rows:auto minmax(0,1fr) auto;
  grid-template-areas:"top" "stage" "bottom"; background:#070c14;
  width:100vw; font:500 14px/1.5 var(--ui-font,Arial,sans-serif); letter-spacing:0;
}
#cm .cm-top {
  grid-area:top; position:relative; inset:auto; height:auto; min-height:72px;
  padding:12px max(20px,env(safe-area-inset-right)) 12px max(20px,env(safe-area-inset-left));
  gap:16px; background:#0d1522; border-bottom:1px solid #283448;
}
#cm .cm-title { gap:4px; line-height:1.3; }
#cm .cm-title b { font:650 17px/1.3 var(--ui-font,Arial,sans-serif); text-transform:none; letter-spacing:0; color:#e6c58b; }
#cm .cm-title span { font:12px/1.3 var(--ui-font,Arial,sans-serif); color:#9eafc7; }
#cm .cm-tools { display:flex; align-items:center; gap:8px; width:auto; max-width:none; padding-bottom:0; overflow:visible; }
#cm #cm-txt { min-width:44px; }
#cm #cm-txt .cm-fmt-t { font:inherit; }
#cm .cm-btn,#cm .cm-nav,#cm .cm-settings summary {
  display:inline-flex; align-items:center; justify-content:center; gap:7px;
  min-width:44px; min-height:44px; padding:9px 12px; font:600 12px/1.4 var(--ui-font,Arial,sans-serif);
  letter-spacing:0; border:1px solid #35445c; border-radius:9px; background:#131e2f; color:#e5eaf2;
  cursor:pointer; box-shadow:none;
}
#cm .cm-btn.ic { padding:9px; }
#cm .cm-btn.ic,#cm .cm-settings summary { width:44px; padding:9px; flex-shrink:0; }
#cm .ifc-icon { width:19px; height:19px; flex-shrink:0; }
#cm .cm-btn:hover,#cm .cm-nav:hover,#cm .cm-settings summary:hover { background:#203048; border-color:#b89961; }
#cm .cm-btn[aria-pressed="true"] { color:#f0ca84; border-color:#9e7b43; background:#e5b65d1a; }
#cm button:disabled { opacity:.3; cursor:default; }
#cm .cm-stage,#cm .cm-strip { grid-area:stage; position:relative; inset:auto; min-width:0; min-height:0; }
#cm .cm-stage { grid-template:minmax(0,1fr) / minmax(0,1fr); background:radial-gradient(ellipse at 50% 50%,#14203333,transparent 75%); }
#cm .cm-pg,#cm .cm-pz { width:100%; height:100%; min-width:0; min-height:0; max-width:none; max-height:none; display:flex; align-items:center; justify-content:center; }
#cm .cm-pg img { max-width:none; max-height:none; width:auto; height:auto; object-fit:contain; border:1px solid #ffffff12; border-radius:2px; box-shadow:0 10px 48px #0009; background:none; }
#cm .cm-pg.end { overflow:auto; padding:20px; }
#cm .cm-page-loading { position:absolute; inset:0; z-index:6; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:16px; padding:24px; color:#aebdd2; background:#070c14; text-align:center; font:13px/1.7 var(--ui-font,Arial,sans-serif); }
#cm .cm-endcard { max-height:100%; overflow:auto; border:1px solid #5e513b; border-radius:14px; box-shadow:0 16px 50px #0005; background:#101b2c; }
#cm .cm-endcard h2 { font:650 34px/1.2 var(--ui-font,Arial,sans-serif); text-transform:none; letter-spacing:0; }
#cm .cm-big { font:650 14px/1.4 var(--ui-font,Arial,sans-serif); padding:12px 16px; box-shadow:none; border-width:1px; }
#cm .cm-bot {
  grid-area:bottom; position:relative; inset:auto; height:auto; min-height:82px; justify-content:space-between!important;
  display:grid; grid-template-columns:auto minmax(220px,1fr) auto; gap:24px;
  padding:12px max(20px,env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) max(20px,env(safe-area-inset-left));
  border-top:1px solid #283448; background:#0d1522;
}
.cm-zoom-controls { display:flex; align-items:center; gap:7px; }
#cm-zoom { min-width:44px; text-align:center; color:#e6c58b; font:650 13px/1.5 var(--ui-font,Arial,sans-serif); font-variant-numeric:tabular-nums; }
.cm-page-position { min-width:0; display:flex; align-items:center; justify-content:center; gap:14px; }
#cm .cm-count { font:650 13px/1.5 var(--ui-font,Arial,sans-serif); color:#d9e2f0; white-space:nowrap; text-align:center; min-width:90px; }
#cm .cm-progress { width:min(210px,100%); min-width:60px; accent-color:#e5b65d; cursor:pointer; }
.cm-page-navigation { display:flex; gap:8px; }
#cm .cm-nav { position:static; inset:auto; transform:none; width:auto; height:44px; padding:9px 13px; opacity:1; pointer-events:auto; }
#cm .cm-nav:disabled { pointer-events:none; }
#cm .cm-view-options { display:flex; gap:4px; }
#cm .cm-view-options .cm-btn { min-height:38px; padding:8px 11px; }
#cm .cm-settings { position:relative; }
#cm .cm-settings summary { list-style:none; }
#cm .cm-settings summary::-webkit-details-marker { display:none; }
#cm .cm-settings summary::after { content:none; }
.cm-settings-panel { position:absolute; right:0; top:calc(100% + 12px); width:250px; padding:18px; display:grid; gap:14px; background:#111c2e; border:1px solid #4b5e79; border-radius:12px; box-shadow:0 18px 50px #0008; }
.cm-settings-panel label { display:grid; gap:10px; color:#b5c2d6; font-size:12px; }
#cm .cm-settings-panel .cm-btn { width:100%; justify-content:flex-start; }
#cm .cm-vol { width:100%; margin:0; height:6px; border:0; border-radius:10px; background:#30435e; }
#cm .cm-vol::-webkit-slider-thumb { width:17px; height:17px; border:0; border-radius:50%; background:#e5b65d; }
#cm .cm-vol::-moz-range-thumb { width:17px; height:17px; border:0; border-radius:50%; background:#e5b65d; }
#cm .cm-mood { display:none; }
#cm .cm-strip { padding:24px 24px 40px; }
#cm .cm-sp { max-width:min(1100px,100%); margin-bottom:24px; }
#cm .cm-sp img { border:1px solid #ffffff18; border-radius:2px; background:none; box-shadow:0 8px 40px #0007; }
#cm .cm-sp.cv img { aspect-ratio:auto; object-fit:contain; }
#cm .cm-sheet { background:#02060bd9; backdrop-filter:blur(10px); }
#cm .cm-sheet-in { width:min(1100px,100%); max-height:88%; border:1px solid #4b5e79; border-radius:18px 18px 0 0; padding:22px; background:#101a2b; box-shadow:0 -20px 80px #0006; }
#cm .cm-sheet-h { gap:12px; margin-bottom:18px; }
#cm .cm-sheet-h b { font:650 18px/1.5 var(--ui-font,Arial,sans-serif); text-transform:none; letter-spacing:0; }
#cm .cm-grid { grid-template-columns:repeat(auto-fill,minmax(120px,1fr)); gap:14px; padding:4px; }
#cm .cm-th { border:2px solid #304058; border-radius:9px; overflow:hidden; }
#cm .cm-th img { object-fit:contain; background:#050a12; }
#cm .cm-th span { border:0; border-radius:0 6px 0 0; font:650 12px/1.5 var(--ui-font,Arial,sans-serif); padding:3px 9px; }
#cm .cm-th.on { border-color:#e5b65d; box-shadow:0 0 0 2px #e5b65d20; }
#cm .cm-toast { bottom:100px; border:1px solid #8b744e; border-radius:9px; font:12px/1.7 var(--ui-font,Arial,sans-serif); box-shadow:0 8px 30px #0005; }
#cm.nochrome { grid-template-rows:0 minmax(0,1fr) 0; }
#cm.nochrome .cm-top,#cm.nochrome .cm-bot { position:absolute; visibility:hidden; pointer-events:none; }
#cm.nochrome .cm-stage,#cm.nochrome .cm-strip { inset:auto; }
#cm.nochrome .cm-pg img { max-height:none; }
#cm .cm-restore { position:absolute; top:calc(12px + env(safe-area-inset-top)); right:max(12px,env(safe-area-inset-right)); z-index:10; background:#0d1522e8; }

@media (max-width:1000px) {
  #cm .cm-top { flex-wrap:wrap; gap:10px; }
  #cm .cm-tools { flex-basis:100%; justify-content:center; }
  #cm .cm-bot { grid-template-columns:minmax(0,1fr) auto; gap:10px; }
  .cm-zoom-controls { grid-column:1/-1; justify-content:center; }
  .cm-page-position { grid-column:1; }
  .cm-page-navigation { grid-column:2; }
  #cm .cm-nav span { display:none; }
  #cm .cm-count { min-width:80px; }
}
@media (max-width:600px) {
  #lb .iv-header { padding:10px 14px; gap:10px; min-height:66px; }
  #lb #lbtitle { font-size:14px; }
  .iv-eyebrow { font-size:8px; }
  #lb button.iv-close span { display:none; }
  #lb .iv-toolbar { grid-template-columns:1fr; gap:8px; padding:10px 10px calc(10px + env(safe-area-inset-bottom)); }
  .iv-zoom { grid-column:1; grid-row:1; gap:5px; }
  #lb .iv-zoom button { padding-inline:9px; font-size:11px; gap:5px; }
  #lbzoom { min-width:36px; font-size:12px; }
  .iv-navigation { grid-column:1; grid-row:2; justify-content:center; }
  .iv-dimensions { display:none; }
  .character-enlarge { opacity:1; top:10px; right:10px; }
  #cm .cm-top { padding:10px 12px; gap:9px; }
  #cm .cm-title b { font-size:14px; }
  #cm .cm-title span { display:block; font-size:10px; }
  #cm .cm-tools { justify-content:space-between; gap:6px; }
  #cm #cm-txt .cm-fmt-t { display:none!important; }
  #cm .cm-btn { font-size:11px; padding-inline:10px; }
  #cm .cm-view-options .cm-btn { font-size:11px; padding-inline:9px; }
  #cm .cm-bot { padding:10px 12px calc(10px + env(safe-area-inset-bottom)); }
  #cm #cm-zin,#cm #cm-zout { display:inline-flex; }
  #cm .cm-pg img { max-width:none; max-height:none; }
  #cm .cm-settings-panel { right:-6px; }
  #cm .cm-progress { width:100%; }
  #cm .cm-sheet-in { padding:16px; }
  #cm .cm-grid { grid-template-columns:repeat(3,minmax(0,1fr)); gap:9px; }
}
@media (max-width:380px) {
  #cm .cm-tools { flex-wrap:wrap; }
  #cm #cm-txt { padding:9px; width:44px; }
  #cm .cm-view-options { order:3; flex-basis:100%; justify-content:center; }
  #cm .cm-zoom-controls { display:grid; grid-template-columns:44px 32px 44px minmax(0,1fr) 44px; width:100%; gap:6px; }
  #cm-zoom { min-width:32px; }
  #cm #cm-fit { min-width:0; white-space:normal; padding-inline:6px; }
}
@media (max-height:500px) and (min-width:520px) {
  #lb .iv-header { min-height:52px; padding-block:6px; }
  #lb .iv-toolbar { min-height:62px; padding-block:8px; }
  #cm .cm-top { flex-wrap:nowrap; min-height:54px; padding-block:6px; }
  #cm .cm-tools { flex-basis:auto; }
  #cm .cm-title span { display:none; }
  #cm .cm-bot { display:flex; min-height:62px; padding-block:8px; gap:12px; }
  #cm .cm-progress { display:none; }
}
@media (pointer:coarse) { .character-enlarge { opacity:1; } }
@media (prefers-reduced-motion:reduce) { .iv-spinner { animation:none; } }
