@font-face {
  font-family: "CS Lettering";
  src: url("fonts/ComicNeue-Bold.ttf") format("truetype");
  font-weight: 400 900;
}

@font-face {
  font-family: "CS comic-neue";
  src: url("fonts/ComicNeue-Bold.ttf") format("truetype");
  font-weight: 100 900;
}
@font-face {
  font-family: "CS patrick-hand";
  src: url("fonts/PatrickHand-Regular.ttf") format("truetype");
  font-weight: 100 900;
}
@font-face {
  font-family: "CS bangers";
  src: url("fonts/Bangers-Regular.ttf") format("truetype");
  font-weight: 100 900;
}
@font-face {
  font-family: "CS permanent-marker";
  src: url("fonts/PermanentMarker-Regular.ttf") format("truetype");
  font-weight: 100 900;
}
@font-face {
  font-family: "CS luckiest-guy";
  src: url("fonts/LuckiestGuy-Regular.ttf") format("truetype");
  font-weight: 100 900;
}
@font-face { font-family: "CS cinzel"; src: url("fonts/CinzelDecorative-Bold.ttf") format("truetype"); font-weight: 100 900; }
@font-face { font-family: "CS bebas"; src: url("fonts/BebasNeue-Regular.ttf") format("truetype"); font-weight: 100 900; }
@font-face { font-family: "CS crimson"; src: url("fonts/CrimsonText-Regular.ttf") format("truetype"); font-weight: 100 900; }

@font-face { font-family: "CS display"; src: url("fonts/ArchivoBlack-Regular.ttf") format("truetype"); }

/* Tinta y papel: papel crema, tinta negra, rojo solo para generar, amarillo para lo activo */
:root {
  --bg: #efe6d2;          /* mesa (papel kraft claro) */
  --panel: #fbf6ea;       /* hojas: paneles laterales y diálogos */
  --paper: #fffdf7;       /* papel blanco: campos, tarjetas */
  --ink: #141210;         /* tinta */
  --line: #d6c9ae;        /* líneas suaves de lápiz */
  --line-ink: #141210;    /* bordes entintados (viñetas, botón principal) */
  --muted: #5c5246;       /* texto secundario (≥ 7:1 sobre papel) */
  --accent: #d0311f;      /* rojo: generar / acción principal */
  --accent-ink: #fff;
  --hi: #ffd21f;          /* amarillo: activo y seleccionado */
  --hi-soft: #fff3b8;
  --danger: #a61b0f;
  --sel: #1f5fd1;         /* azul: selección sobre el lienzo */
  --radius: 4px;
  --shadow-ink: 3px 3px 0 var(--ink);
  --font-display: "CS display", "Arial Black", Impact, sans-serif;
  --font-brand: "CS bangers", "CS display", Impact, sans-serif;
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 24px;
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  color: var(--ink);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); }
body { display: flex; flex-direction: column; overflow: hidden; }

/* botón principal: rojo entintado con sombra dura, como una viñeta */
button, .btnlike {
  font: inherit; font-weight: 600; border: 2px solid var(--ink); background: var(--accent); color: var(--accent-ink);
  padding: 6px 14px; min-height: 34px; border-radius: var(--radius); cursor: pointer; white-space: nowrap;
  box-shadow: 2px 2px 0 var(--ink); transition: transform .06s, box-shadow .06s;
}
button:hover:not(:disabled), .btnlike:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--ink); }
button:active:not(:disabled) { transform: translate(1px, 1px); box-shadow: 0 0 0 var(--ink); }
button:disabled { background: #e7dfcd; border-color: #d6c9ae; color: #7d7263; cursor: not-allowed; filter: none; }
button:focus-visible, .btnlike:focus-visible, a:focus-visible, [tabindex]:focus-visible, summary:focus-visible {
  outline: 3px solid var(--sel); outline-offset: 2px;
}
/* botón secundario: papel con borde de lápiz; al pasar, se entinta */
button.ghost { background: var(--paper); color: var(--ink); border: 1.5px solid #b8a883; box-shadow: none; font-weight: 500; }
button.ghost:hover:not(:disabled) { border-color: var(--ink); background: #fff; box-shadow: 2px 2px 0 var(--ink); }
button.ghost:disabled { background: transparent; }
button.small, .btnlike.small { padding: 4px 10px; min-height: 30px; font-size: 13px; }
button.ghost.danger { color: var(--danger); border-color: #e0b2a8; }
button.ghost.danger:hover:not(:disabled) { background: #fdebe7; border-color: var(--danger); box-shadow: 2px 2px 0 var(--danger); }
button.danger { color: var(--danger); }
input, select, textarea {
  font: inherit; color: inherit; background: var(--paper); border: 1.5px solid #c9b994;
  border-radius: var(--radius); padding: 7px 9px; min-width: 0;
}
textarea { resize: vertical; width: 100%; line-height: 1.4; }
input:focus, select:focus, textarea:focus { outline: 3px solid color-mix(in srgb, var(--sel) 35%, transparent); border-color: var(--sel); }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 16px; height: 16px; }
input[type=range] { accent-color: var(--ink); }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 600; }
label.check { flex-direction: row; align-items: center; gap: 6px; font-weight: 500; }
.muted { color: var(--muted); font-size: 12.5px; }
.spacer { flex: 1; }
.sep { width: 1px; height: 24px; background: var(--line); }
h2 { font-family: var(--font-display); font-weight: 400; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; margin: 0; }
h3 { font-family: var(--font-display); font-weight: 400; margin: 0 0 8px; font-size: 19px; letter-spacing: .01em; }

/* barra superior */
.topbar {
  display: flex; align-items: center; gap: 8px; padding: 8px 14px; background: var(--panel);
  border-bottom: 2px solid var(--ink); flex-wrap: wrap;
}
.brand { font-family: var(--font-brand); font-weight: 400; font-size: 26px; letter-spacing: .04em; line-height: 1; margin-right: 6px; text-transform: uppercase; }
.brand span { color: var(--accent); }
#titleInput { width: 200px; font-weight: 600; }
#styleCustom { width: 220px; }
.pill { font-size: 12px; font-weight: 600; padding: 4px 11px; min-height: 28px; border-radius: 99px; background: #ece3cf; color: #3f372d; border: 1.5px solid #b8a883; box-shadow: none; }
.pill:hover:not(:disabled) { transform: none; box-shadow: none; border-color: var(--ink); }
.engine-opt { flex-direction: row; align-items: flex-start; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; cursor: pointer; color: var(--ink); }
.engine-opt span { display: flex; flex-direction: column; gap: 2px; font-weight: 500; }
.engine-opt b { font-size: 14px; }
.engine-opt small { color: var(--muted); font-weight: 400; }
.engine-opt:has(input:checked) { border-color: var(--sel); box-shadow: 0 0 0 1px var(--sel); }
.pill.ok { background: #e2f1d6; color: #1f4d0c; border-color: #8cbb6b; }
.pill.warn { background: var(--hi-soft); color: #5a4300; border-color: #d9b84a; }
.pill.bad { background: #fde2df; color: var(--danger); border-color: #e0a59a; }

/* rejilla principal */
.layout { flex: 1; display: grid; grid-template-columns: 250px 1fr 360px; min-height: 0; }
.library, .inspector { background: var(--panel); overflow-y: auto; padding: 12px; }
.library { border-right: 2px solid var(--ink); }
.inspector { border-left: 2px solid var(--ink); }
.aside-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.hint { font-size: 12.5px; color: var(--muted); line-height: 1.5; }

.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.tabs button { padding: 3px 10px; min-height: 28px; font-size: 12.5px; font-weight: 500; background: transparent; color: var(--muted); border: 1.5px solid transparent; border-radius: 99px; box-shadow: none; }
.tabs button:hover:not(:disabled) { transform: none; box-shadow: none; color: var(--ink); border-color: #b8a883; }
.tabs button.on { background: var(--hi); color: var(--ink); border-color: var(--ink); font-weight: 700; }

.asset-list { display: flex; flex-direction: column; gap: 6px; }
.asset {
  display: flex; gap: 8px; align-items: center; padding: 6px; border-radius: var(--radius);
  border: 1.5px solid var(--line); background: var(--paper); cursor: pointer; transition: box-shadow .08s;
}
.asset:hover { border-color: var(--ink); box-shadow: 2px 2px 0 var(--ink); }
.asset img, .asset .noimg {
  width: 44px; height: 44px; object-fit: cover; border-radius: 2px; border: 1.5px solid var(--ink); background: #eee5d1; flex: none;
  display: grid; place-items: center; color: var(--muted); font-size: 18px;
}
.asset b { display: block; font-size: 13px; }
.asset small { color: var(--muted); }
.asset .insert { margin-left: auto; padding: 2px 7px; font-size: 12px; }

/* zona de trabajo */
.workspace { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.pagebar { display: flex; align-items: center; gap: 6px; padding: 8px 12px; border-bottom: 1.5px solid var(--line); background: var(--panel); flex-wrap: wrap; }
.page-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.page-tabs button { min-width: 32px; min-height: 30px; padding: 3px 8px; font-size: 13px; font-weight: 600; background: var(--paper); color: var(--ink); border: 1.5px solid #b8a883; box-shadow: none; }
.page-tabs button:hover:not(:disabled) { transform: none; border-color: var(--ink); box-shadow: 2px 2px 0 var(--ink); }
.page-tabs button.on { background: var(--hi); color: var(--ink); border: 2px solid var(--ink); box-shadow: 2px 2px 0 var(--ink); }
/* mesa de trabajo con trama de puntos muy suave; la página, entintada con sombra dura */
.stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 18px 24px 24px 18px; overflow: auto;
  background-color: var(--bg); background-image: radial-gradient(rgba(20,18,16,.09) 1px, transparent 1.3px); background-size: 11px 11px; }
#pageSvg { height: 100%; max-width: 100%; aspect-ratio: 2 / 3; background: #fff; border: 2px solid var(--ink); box-shadow: 7px 7px 0 var(--ink); user-select: none; touch-action: none; }
#pageSvg .panel { cursor: pointer; }
#pageSvg .bubble { cursor: move; }
#pageSvg .handle { cursor: grab; }
#pageSvg text { font-family: "CS Lettering", "Comic Sans MS", sans-serif; font-weight: 700; }
#pageSvg .ph { font-family: Inter, system-ui, sans-serif; font-weight: 500; fill: #9a8f80; }
#pageSvg .busy { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* inspector */
.inspector section { border-bottom: 1.5px dashed var(--line); padding-bottom: 14px; margin-bottom: 14px; display: flex; flex-direction: column; gap: 8px; }
/* títulos de sección subrayados con rotulador amarillo */
.inspector section > h2, .library .aside-head h2 { align-self: flex-start; background: linear-gradient(transparent 58%, var(--hi) 58%, var(--hi) 92%, transparent 92%); padding: 0 3px; }
.inspector .row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--paper); border: 1.5px solid var(--line); border-radius: 99px; padding: 2px 8px 2px 2px; font-size: 12px; }
.chip img { width: 20px; height: 20px; border-radius: 50%; object-fit: cover; }
.chip.noref { padding-left: 8px; color: var(--muted); }
.cands { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.cand { position: relative; border-radius: 2px; overflow: hidden; border: 2px solid var(--line); cursor: pointer; aspect-ratio: 1; background: #eee5d1; }
.cand:hover { border-color: var(--ink); }
.cand img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cand.on { border: 3px solid var(--ink); box-shadow: 0 0 0 3px var(--hi); }
.cand .x { position: absolute; top: 2px; right: 2px; background: rgba(0,0,0,.6); color: #fff; border: 0; border-radius: 4px; padding: 0 5px; font-size: 12px; }
.bubble-item { background: var(--paper); border: 1.5px solid var(--line); border-radius: var(--radius); padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.bubble-item.on { border: 2px solid var(--ink); box-shadow: 3px 3px 0 var(--hi); }
.bubble-item textarea { min-height: 44px; }
.empty-insp { color: var(--muted); text-align: center; margin-top: 40px; line-height: 1.6; }
input[type=range] { padding: 0; }

/* diálogos */
dialog { border: 2px solid var(--ink); border-radius: 6px; padding: 0; background: var(--panel); color: var(--ink); box-shadow: 8px 8px 0 var(--ink); max-width: 96vw; }
dialog::backdrop { background: rgba(20,16,10,.5); }
.dlg { padding: 18px; width: 560px; max-width: 100%; display: flex; flex-direction: column; gap: 10px; }
.dlg.wide { width: 760px; }
.dlg pre { white-space: pre-wrap; background: #f6f3ee; padding: 10px; border-radius: 8px; font-size: 12px; max-height: 60vh; overflow: auto; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dlg-actions { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.imgs-head { display: flex; justify-content: space-between; align-items: center; font-size: 12px; font-weight: 600; color: var(--muted); }
.asset-images { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; min-height: 40px; }
.asset-images .cand { aspect-ratio: 3/4; }
.gen-box { background: #f6f3ee; border-radius: 8px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }

/* menú de menciones */
.mention-menu { position: fixed; z-index: 50; background: var(--paper); border: 2px solid var(--ink); border-radius: 4px; box-shadow: 4px 4px 0 var(--ink); min-width: 200px; max-height: 240px; overflow: auto; }
.mention-menu div { display: flex; align-items: center; gap: 8px; padding: 6px 10px; cursor: pointer; font-size: 13px; }
.mention-menu div.on, .mention-menu div:hover { background: var(--hi-soft); }
.mention-menu img, .mention-menu .noimg { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; background: #eee8dc; }

/* trabajos */
.jobs-dock { position: fixed; right: 376px; bottom: 14px; display: flex; flex-direction: column; gap: 6px; z-index: 40; max-width: 320px; }
.job { background: var(--ink); color: var(--paper); border-radius: 4px; border-left: 5px solid var(--hi); padding: 8px 10px; font-size: 12px; display: flex; gap: 8px; align-items: center; box-shadow: 4px 4px 0 rgba(20,18,16,.35); }
.job.error { background: #8f1d14; border-left-color: #ffb4a8; }
.job .spin { width: 12px; height: 12px; border: 2px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin 1s linear infinite; flex: none; }
.job button { padding: 1px 8px; min-height: 24px; font-size: 11px; background: transparent; color: var(--paper); border: 1px solid rgba(255,255,255,.5); box-shadow: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 9px 16px; border-radius: 4px; box-shadow: 4px 4px 0 var(--hi); z-index: 60; font-size: 13px; max-width: calc(100vw - 32px); }

@media (max-width: 1100px) {
  .layout { grid-template-columns: 210px 1fr 300px; }
  .jobs-dock { right: 316px; }
}

label.inline { display: flex; flex-direction: row; align-items: center; gap: 8px; }
label.inline input[type=range] { flex: 1; }

.edit-zone { border: 2px solid #ff3b30; border-radius: var(--radius); padding: 10px; background: #fff6f5; }

.import-preview { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; display: grid; gap: 4px; max-height: 9em; overflow: auto; }

.sheet-views { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 6px; }
.sheet-views figure { margin: 0; background: #fff; border-radius: 6px; overflow: hidden; display: flex; flex-direction: column; }
.sheet-views img { width: 100%; aspect-ratio: 3/4; object-fit: contain; background: #fff; }
.sheet-views figure.body img { aspect-ratio: 1/2; }
.sheet-views figcaption { font-size: 11px; text-align: center; color: var(--muted); padding: 2px; }

#editLayoutBtn.on { background: var(--hi); color: var(--ink); border-color: var(--ink); box-shadow: 2px 2px 0 var(--ink); }
.layout-zone { border-color: var(--sel); background: #f3f7ff; }

.audit-ask input { flex: 1; }
.audit-results { display: grid; gap: 10px; max-height: 55vh; overflow: auto; }
.audit-summary { background: #fff; border-radius: var(--radius); padding: 8px 10px; margin: 0; }
.audit-issue { background: #fff; border: 1px solid var(--line); border-left: 5px solid #c9b98f; border-radius: var(--radius); padding: 10px; display: grid; gap: 6px; }
.audit-issue p { margin: 0; }
.audit-issue.sev-alta { border-left-color: #c8452c; }
.audit-issue.sev-media { border-left-color: #e0a12b; }
.audit-issue.sev-baja { border-left-color: #8fb3c9; }
.audit-issue.done { opacity: .6; }
.audit-issue .tag { font-size: 11px; background: #f1ede4; border-radius: 10px; padding: 1px 8px; }

.sec-group { display: flex; align-items: center; gap: 3px; background: var(--paper); border: 1.5px solid var(--line); border-radius: 4px; padding: 2px 4px; }
.sec-group .sec-label { background: transparent; border: 0; box-shadow: none; color: var(--muted); font-family: var(--font-display); font-weight: 400; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; padding: 4px 6px; min-width: 0; min-height: 0; }
.sec-group .sec-label:hover:not(:disabled) { transform: none; box-shadow: none; }
.sec-group .sec-label:hover { color: var(--ink); }
.sec-group .sec-add { background: transparent; border: 1.5px dashed #b8a883; box-shadow: none; color: var(--muted); min-width: 26px; min-height: 28px; padding: 2px 6px; }
.sec-group .sec-add:hover:not(:disabled) { transform: none; box-shadow: none; border-color: var(--ink); color: var(--ink); }
.sec-cover, .sec-backcover { background: #f4ead2; }
.page-tabs button.hole { border-style: dashed; color: var(--muted); background: transparent; }
.page-tabs button.hole.on { background: var(--hi-soft); color: var(--ink); border-style: dashed; }
.popup-menu { position: fixed; z-index: 50; background: var(--paper); border: 2px solid var(--ink); border-radius: 4px; box-shadow: 4px 4px 0 var(--ink); display: flex; flex-direction: column; padding: 4px; min-width: 200px; }
.popup-menu button { background: transparent; color: var(--ink); border: 0; box-shadow: none; font-weight: 500; text-align: left; padding: 7px 10px; }
.popup-menu button:hover:not(:disabled) { background: var(--hi-soft); transform: none; box-shadow: none; }
.popup-menu button.danger { color: #b42318; }

.styles-dlg { width: min(1100px, 96vw); }
.styles-dlg #stylesSearch { width: 240px; }
.styles-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; max-height: 46vh; overflow: auto; padding: 2px; }
.style-card { background: var(--paper); border: 2px solid var(--line); border-radius: 4px; overflow: hidden; display: flex; flex-direction: column; }
.style-card.on { border-color: var(--ink); box-shadow: 4px 4px 0 var(--hi); }
.style-pic { aspect-ratio: 3/4; background: #f1ede4; display: flex; align-items: center; justify-content: center; }
.style-pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.style-body { padding: 8px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.style-body p { margin: 0; font-size: 12px; line-height: 1.35; flex: 1; }
.style-body .tag { font-size: 10px; background: #f1ede4; border-radius: 10px; padding: 1px 7px; margin-left: auto; }
.styles-mix { display: flex; gap: 14px; align-items: flex-start; border-top: 1px solid var(--line); padding-top: 10px; }
.styles-mix .mix-left { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.mix-list { display: flex; flex-direction: column; gap: 6px; }
.mix-item { display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; }
.mix-item img { width: 30px; height: 40px; object-fit: cover; border-radius: 4px; }
.mix-item b { min-width: 150px; }
.mix-item .weights { display: flex; gap: 4px; flex: 1; }
.mix-item .weights button { background: var(--paper); color: var(--ink); border: 1.5px solid #b8a883; box-shadow: none; padding: 3px 8px; min-height: 28px; font-size: 12px; }
.mix-item .weights button.on { background: var(--hi); color: var(--ink); border-color: var(--ink); }
.mix-sample { width: 180px; border-radius: 8px; border: 1px solid var(--line); }
.style-pic { position: relative; }
.style-pic .redo-sample { position: absolute; top: 6px; right: 6px; background: rgba(0,0,0,.55); color: #fff; border: 0; border-radius: 6px; padding: 2px 8px; opacity: 0; }
.style-card:hover .redo-sample, .style-pic .redo-sample:focus { opacity: 1; }

.auto-dlg { width: min(820px, 96vw); }
.auto-steps { display: grid; gap: 8px; }
.auto-step { background: var(--paper); border: 1.5px solid var(--line); border-radius: var(--radius); padding: 8px 10px; display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; }
.auto-step.sub { margin-left: 24px; }
.auto-step small, .auto-step .sub-opts { grid-column: 1 / -1; }
.auto-step [data-cost] { font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.auto-step input.tiny { width: 52px; padding: 2px 4px; }
.auto-total { background: var(--hi-soft); border: 2px solid var(--ink); border-radius: var(--radius); padding: 10px; font-size: 15px; }
.jobs-dock .job.summary { font-weight: 600; }

#spendPill { background: var(--hi-soft); color: #4d3a00; border-color: #d9b84a; font-variant-numeric: tabular-nums; }
.spend-totals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.spend-totals > div { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; }
.spend-totals b { font-size: 22px; font-variant-numeric: tabular-nums; }
.spend-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.spend-block { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; margin-top: 10px; }
.spend-block table { width: 100%; border-collapse: collapse; font-size: 13px; }
.spend-block td { padding: 3px 0; border-bottom: 1px solid #f1ede4; }
.spend-block td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.cover-texts .row { flex-wrap: wrap; }

#delComicBtn { padding: 6px 9px; }
#delComicBtn:hover { background: #fdeaea; border-color: #e3a3a3; }
#delGoBtn.danger { background: var(--danger); border-color: var(--ink); color: #fff; }
#delGoBtn.danger:disabled { opacity: .45; cursor: not-allowed; }
#delInfo p { margin: 4px 0; }
#delInfo .warn { color: #b03a2e; font-weight: 600; }

/* ---------------------------------------------------------------- Tinta y papel · pantallas */
button.hi { background: var(--hi); color: var(--ink); }
.tb-group { display: flex; align-items: center; gap: 6px; }
.tb-comic { padding-right: 10px; border-right: 1.5px dashed var(--line); }
#comicSelect { max-width: 200px; font-weight: 600; }
#titleInput { width: 210px; }
.tb-pop-wrap { position: relative; }
.tb-popover { position: absolute; top: calc(100% + 8px); left: 0; z-index: 70; width: 320px; background: var(--paper);
  border: 2px solid var(--ink); border-radius: 4px; box-shadow: 5px 5px 0 var(--ink); padding: 12px; display: grid; gap: 10px; }
.tb-popover .row { display: flex; gap: 6px; }
.tb-popover .row select { flex: 1; }
.tb-popover input#styleCustom { width: 100%; }
.tb-history button { min-width: 36px; padding: 6px 8px; }
.tb-status { padding-left: 10px; border-left: 1.5px dashed var(--line); }
.aside-head { gap: 6px; }
.aside-head h2 { margin-right: auto; }
.asset .insert { min-height: 26px; }
.empty-card { border: 2px dashed #b8a883; border-radius: 4px; padding: 12px; display: grid; gap: 8px; background: var(--paper); }
.empty-card p { margin: 0; color: var(--muted); font-size: 12.5px; line-height: 1.45; }
.empty-card .row { display: flex; gap: 6px; flex-wrap: wrap; }
.mobile-tabs { display: none; }

@media (max-width: 1250px) {
  #titleInput { width: 150px; }
  .tb-actions #pngBtn { display: none; }
}

/* móvil: barra compacta desplazable, una sección a la vez y pestañas abajo */
@media (max-width: 760px) {
  body { overflow: hidden; }
  .topbar { flex-wrap: nowrap; overflow-x: auto; padding: 8px 12px; gap: 8px; scrollbar-width: none; }
  .topbar::-webkit-scrollbar { display: none; }
  .topbar > * { flex: none; }
  .brand { font-size: 22px; }
  .topbar .spacer, .tb-title, .tb-actions #pngBtn { display: none; }
  #comicSelect { max-width: 150px; }
  .layout { display: block; position: relative; overflow: hidden; }
  .library, .workspace, .inspector { position: absolute; inset: 0; border: 0; }
  body:not([data-m="lib"]) .library, body:not([data-m="page"]) .workspace, body:not([data-m="insp"]) .inspector { display: none; }
  .library, .inspector { padding: 14px 16px 20px; }
  .pagebar { overflow-x: auto; flex-wrap: nowrap; padding: 8px 12px; scrollbar-width: none; }
  .pagebar > * { flex: none; }
  .pagebar .spacer { display: none; }
  .stage { padding: 12px 18px 18px 12px; }
  #pageSvg { height: auto; width: 100%; max-height: 100%; box-shadow: 5px 5px 0 var(--ink); }
  .mobile-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    background: var(--panel); border-top: 2px solid var(--ink); flex: none; }
  .mobile-tabs button { min-height: 44px; font-size: 13px; justify-content: center; }
  .mobile-tabs button.on { background: var(--hi); border: 2px solid var(--ink); font-weight: 700; box-shadow: 2px 2px 0 var(--ink); }
  .jobs-dock { right: 12px; left: 12px; bottom: 76px; max-width: none; }
  .toast { bottom: 80px; }
  button.small, .btnlike.small, .tabs button, .page-tabs button { min-height: 38px; }
  .dlg, .dlg.wide { width: 100%; padding: 14px; }
  .row2, .spend-cols, .spend-totals { grid-template-columns: 1fr; }
}
#spendPill, #statusPill { max-width: 190px; overflow: hidden; text-overflow: ellipsis; }
.topbar { row-gap: 6px; }
@media (max-width: 1500px) {
  #titleInput { width: 170px; }
  #spendPill, #statusPill { max-width: 130px; }
}
@media (max-width: 1600px) {
  .tb-actions #pngBtn { display: none; }
  #comicSelect { max-width: 170px; }
  #titleInput { width: 150px; }
}
#logoutBtn { min-width: 34px; padding: 6px 8px; }
@media (max-width: 1600px) {
  .brand { font-size: 22px; }
  #comicSelect { max-width: 150px; }
  #statusPill { max-width: 112px; }
  .tb-comic { padding-right: 6px; }
  .tb-status { padding-left: 6px; }
}

/* barra de página en columna vertical entre la biblioteca y la página: el lienzo gana toda la altura */
.workspace { flex-direction: row; }
.pagebar { flex-direction: column; align-items: stretch; flex-wrap: nowrap; width: 178px; flex: none; gap: 6px;
  padding: 12px 10px; border-bottom: 0; border-right: 1.5px solid var(--line); overflow-y: auto; }
.pagebar > button, .pagebar > select { width: 100%; }
.pagebar .spacer { flex: none; height: 0; border-top: 1.5px dashed var(--line); margin: 6px 0; }
.pagebar .page-tabs { flex-direction: column; gap: 6px; }
.pagebar .sec-group { flex-wrap: wrap; }
.pagebar .sec-group .sec-label { flex: 1 0 100%; text-align: left; }
.stage { min-width: 0; }
@media (max-width: 760px) {
  .workspace { flex-direction: column; }
  .pagebar { flex-direction: row; width: auto; border-right: 0; border-bottom: 1.5px solid var(--line); overflow-x: auto; overflow-y: hidden; }
  .pagebar > button, .pagebar > select { width: auto; }
  .pagebar .page-tabs { flex-direction: row; }
  .pagebar .sec-group { flex-wrap: nowrap; }
  .pagebar .sec-group .sec-label { flex: none; }
}

/* desplegable del cómic */
.comic-menu-btn { font-weight: 700; max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
#comicMenu { width: 300px; }
#comicMenu select, #comicMenu input { width: 100%; max-width: none; }
#comicMenu .row { display: flex; align-items: center; gap: 6px; }
.tb-comic { border-right: 0; padding-right: 0; }

/* ---------------------------------------------------------------- sin barra superior: cabeceras en las columnas */
.side-col { display: flex; flex-direction: column; min-height: 0; background: var(--panel); position: relative; z-index: 5; }
.left-col { border-right: 2px solid var(--ink); }
.right-col { border-left: 2px solid var(--ink); }
.side-col > .library, .side-col > .inspector { flex: 1; min-height: 0; border: 0; }
.side-head { flex: none; display: flex; flex-direction: column; gap: 8px; padding: 12px; border-bottom: 2px solid var(--ink); background: var(--panel); }
.side-head .brand { font-size: 26px; margin: 0; }
.side-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.left-col .side-row > .tb-pop-wrap:first-child { flex: 1; min-width: 0; }
.left-col .comic-menu-btn { width: 100%; max-width: none; text-align: left; }
.left-col .side-row button { padding-left: 10px; padding-right: 10px; }
.left-col #pngBtn { display: none; }
.right-col #autoBtn { flex: 1; }
.right-col #spendPill, .right-col #statusPill { max-width: none; flex: 1; }
.side-head #comicSettings { left: 0; }
@media (max-width: 760px) {
  .side-col { position: absolute; inset: 0; }
  .side-col > .library, .side-col > .inspector { position: static; }
  body:not([data-m="lib"]) .left-col, body:not([data-m="insp"]) .right-col { display: none; }
  body:not([data-m="lib"]) .library, body:not([data-m="insp"]) .inspector { display: block; }
}
.layout { grid-template-columns: 280px 1fr 360px; }
.left-col .side-row:last-child > * { flex: 1 1 auto; }
.left-col .side-row:last-child button { font-size: 13px; padding-left: 8px; padding-right: 8px; }
@media (max-width: 1100px) { .layout { grid-template-columns: 250px 1fr 320px; } }
.left-col .side-row:last-child > .tb-pop-wrap { flex: none; }
.left-col .side-row:last-child > button { flex: 1 1 0; min-width: 0; padding-left: 6px; padding-right: 6px; }
.left-col .aside-head { flex-wrap: wrap; }

/* bocadillos en el inspector: tarjeta compacta, ajustes solo en el seleccionado */
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.b-head { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.b-head select { flex: 1; min-width: 0; }
.b-num { flex: none; width: 24px; height: 24px; display: grid; place-items: center; border: 2px solid var(--ink); border-radius: 50%;
  background: var(--paper); font-family: var(--font-display); font-size: 11px; }
.bubble-item.on .b-num { background: var(--hi); }
.b-del { min-width: 30px; padding: 2px 8px; }
.b-opts { display: grid; gap: 6px; padding-top: 6px; border-top: 1.5px dashed var(--line); }
.bubble-item:not(.on) .b-opts { display: none; }
.bubble-item:not(.on) textarea { min-height: 0; }
.b-opt { display: grid; grid-template-columns: 110px 1fr; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--muted); flex-direction: row; }
.b-opt > :last-child { min-width: 0; width: 100%; }
.b-opt .row { display: flex; gap: 6px; align-items: center; }
.b-opt input[type=color] { width: 44px; height: 30px; padding: 2px; }
.b-checks { display: flex; gap: 14px; flex-wrap: wrap; padding-left: 118px; }
.b-add { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.b-add-label { font-size: 12px; font-weight: 700; color: var(--muted); margin-right: 2px; }

/* progreso del cómic */
.progress { flex: none; border-bottom: 2px solid var(--ink); background: var(--panel); padding: 8px 12px 10px; }
.progress summary { cursor: pointer; font-family: var(--font-display); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; list-style: none; display: flex; align-items: center; gap: 6px; }
.progress summary::-webkit-details-marker { display: none; }
.progress summary::before { content: "▸"; font-family: Inter, sans-serif; }
.progress[open] summary::before { content: "▾"; }
#progressSum { margin-left: auto; font-family: Inter, sans-serif; font-weight: 700; letter-spacing: 0; background: var(--hi-soft); border: 1.5px solid #d9b84a; border-radius: 99px; padding: 0 8px; }
.progress ol { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; }
.progress li { display: flex; align-items: center; gap: 8px; min-height: 28px; font-size: 13px; color: var(--muted); }
.progress li .p-dot { flex: none; width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid #b8a883; display: grid; place-items: center; font-size: 11px; font-weight: 700; }
.progress li.ok { color: var(--ink); }
.progress li.ok .p-dot { background: var(--ink); color: var(--hi); border-color: var(--ink); }
.progress li.next { color: var(--ink); font-weight: 700; }
.progress li.next .p-dot { background: var(--hi); border: 2px solid var(--ink); }
.progress .p-label small { font-weight: 400; color: var(--muted); }
.progress .p-count { margin-left: auto; font-variant-numeric: tabular-nums; font-size: 12px; }
.progress li.next button { margin-left: 6px; min-height: 26px; padding: 2px 10px; font-size: 12px; }
.progress li.next .p-count + button { margin-left: 6px; }
.progress li.next:not(:has(.p-count)) button { margin-left: auto; }

/* diálogos: un solo botón rojo por diálogo, miniaturas y opciones con el estilo de tinta */
.btnlike { display: inline-flex; align-items: center; justify-content: center; }
.btnlike.ghost { background: var(--paper); color: var(--ink); border: 1.5px solid #b8a883; box-shadow: none; font-weight: 500; }
.btnlike.ghost:hover { border-color: var(--ink); background: #fff; box-shadow: 2px 2px 0 var(--ink); }
.cand .x { min-height: 0; padding: 0 6px; border: 0; border-radius: 3px; background: rgba(20,18,16,.75); color: #fff; box-shadow: none; font-weight: 700; line-height: 20px; }
.cand .x:hover:not(:disabled) { transform: none; box-shadow: none; background: var(--danger); }
.engine-opt { border: 1.5px solid var(--line); border-radius: 4px; background: var(--paper); }
.engine-opt:has(input:checked) { border: 2px solid var(--ink); box-shadow: 3px 3px 0 var(--hi); }
.gen-box { background: var(--bg); border: 1.5px dashed #b8a883; border-radius: 4px; }
.dlg pre { background: var(--paper); border: 1.5px solid var(--line); border-radius: 4px; }
.audit-issue { background: var(--paper); border-radius: 4px; }
.audit-summary { background: var(--paper); border: 1.5px solid var(--line); }
.import-preview { background: var(--paper); border-width: 1.5px; }
#importDlg .btnlike.ghost { align-self: flex-start; }
.auto-why { margin: 8px 0 0; font-size: 13px; line-height: 1.45; color: var(--ink); }
