/* Estudio — a workshop for turning books into games, of the same family as the player's app: warm paper, ink
   outlines and hard «sticker» shadows on what can be pressed or what holds a whole part of the page, bright colours
   for states, Fraunces titles, Nunito text and Caveat for small notes; calmer and denser than the app (no confetti,
   no game animations). Layout: top bar + left stage rail + content column (max 1180px); phones below (≤ 720 px). */
/* Colours, type, radii and the sticker shadows are in tokens.css (the player app's design language, loaded first).
   Layout sizes here. */
:root { --rail: 236px; --top: 58px; }

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--paper); background-image: radial-gradient(var(--grain) 1px, transparent 1.2px); background-size: 14px 14px; color: var(--ink); font: 500 15px/1.55 var(--font-ui); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-underline-offset: 3px; text-decoration-thickness: 1.5px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--violet); outline-offset: 2px; border-radius: 8px; }
h1, h2, h3 { font-family: var(--font-display); font-variation-settings: var(--display-axes); line-height: 1.15; text-wrap: balance; margin: 0; letter-spacing: -.01em; }
h1 { font-size: clamp(1.9rem, 3.2vw, 2.5rem); font-weight: 800; }
h2 { font-size: 1.5rem; font-weight: 750; }
h3 { font-size: 1.15rem; font-weight: 700; }
p { margin: 0 0 .7em; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.small { font-size: .85rem; }
.tiny { font-size: .76rem; }
.mono { font-family: var(--font-mono); font-size: .85em; }
/* A small handwritten note, a touch tilted (the app's eyebrows). */
.eyebrow { font: 700 1.3rem/1 var(--font-hand); color: var(--coral-ink); margin: 0 0 4px; display: table; transform: rotate(-2deg); transform-origin: left; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
/* A field in a row (a label holding a select) never pushes the row wider than its card: the select shrinks. */
.row > label { min-width: 0; max-width: 100%; }
.row.tight { gap: 6px; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.stack { display: grid; gap: 14px; align-content: start; }
/* Nothing in a column pushes it wider than its card (a grid item's min-width is its content otherwise). */
.stack > * { min-width: 0; }
.stack.tight { gap: 8px; }
.grow { flex: 1; min-width: 0; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ------------------------------------------------------------ boot */
.boot { min-height: 100vh; display: grid; place-items: center; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--sun-soft); border-top-color: var(--coral); border-right-color: var(--violet); animation: spin .8s linear infinite; display: inline-block; vertical-align: middle; }
.spinner.sm { width: 14px; height: 14px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------ shell */
.topbar { position: sticky; top: 0; z-index: 30; height: calc(var(--top) + env(safe-area-inset-top, 0px)); padding: env(safe-area-inset-top, 0px) 16px 0; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 2px solid var(--edge); display: flex; align-items: center; gap: 14px; }
.brand { display: flex; align-items: center; gap: 9px; font: 800 1.3rem var(--font-display); font-variation-settings: var(--display-axes); color: var(--ink); text-decoration: none; }
.brand svg { width: 32px; height: 32px; transform: rotate(-6deg); }
.topbar .crumb { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--ink-2); }
.topbar .crumb b { color: var(--ink); font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 32vw; }
.topbar .sp { flex: 1; }
.shell { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); min-height: calc(100vh - var(--top)); }
.rail { position: sticky; top: var(--top); align-self: start; height: calc(100vh - var(--top)); overflow-y: auto; padding: 18px 12px 24px; border-right: 2px solid var(--edge); background: var(--surface); display: grid; align-content: start; gap: 18px; }
.rail .stage { display: grid; gap: 2px; }
.rail .stage-name { font: 700 1.2rem/1.1 var(--font-hand); color: var(--coral-ink); padding: 0 10px 4px; display: flex; justify-content: space-between; }
.rail a { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 12px; border: 2px solid transparent; color: var(--ink); text-decoration: none; font-weight: 700; }
.rail a:hover { background: var(--surface-2); }
.rail a.on { background: var(--violet-soft); color: var(--ink); border-color: var(--edge); box-shadow: var(--pop-sm); font-weight: 800; }
.rail a svg { width: 18px; height: 18px; flex: none; color: var(--ink-3); }
.rail a.on svg { color: var(--accent); }
.rail .count { margin-left: auto; font: 800 .72rem var(--font-ui); font-variant-numeric: tabular-nums; padding: 0 8px; border-radius: 99px; border: 1.5px solid var(--rule); background: var(--surface); color: var(--ink-2); }
.rail .count.warn { background: var(--warn-soft); color: var(--warn); }
.rail .count.ok { background: var(--ok-soft); color: var(--ok); }
.rail .advanced { margin-top: 6px; padding-top: 14px; border-top: 2px dashed var(--rule); }
.main { min-width: 0; padding: 28px clamp(16px, 3vw, 40px) 80px; }
.page { max-width: 1180px; margin: 0 auto; display: grid; gap: 22px; }
.page.narrow { max-width: 820px; }
.page > * { min-width: 0; }
@media (max-width: 640px) { .main .btn { white-space: normal; text-align: center; } .main .btn.lg { width: 100%; } }
.page-head { display: flex; gap: 16px; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; }
.page-head > div { min-width: 0; flex: 1 1 300px; }
.page-head .lede { color: var(--ink-2); max-width: min(64ch, 100%); margin: 6px 0 0; }
/* A page's title gets the app's hand-drawn underline. */
.page-head h1 { display: inline-block; padding-bottom: 8px; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 14'%3E%3Cpath d='M3 9c30-6 60-7 95-4s70 4 99-3' fill='none' stroke='%23ff6b5b' stroke-width='5' stroke-linecap='round'/%3E%3C/svg%3E") left bottom / min(100%, 180px) 10px no-repeat; }
.stack > .btn, .card .stack > .btn { white-space: normal; text-align: center; }
.ent-head { display: flex; gap: 20px; align-items: flex-start; }
.ent-head > .grow { min-width: 0; }
.ent-head .select { max-width: 100%; }
@media (max-width: 640px) { .ent-head { gap: 12px; } .ent-head .avatar.xl { width: 64px; height: 64px; } }
/* On phones and narrow windows the rail is a sheet, opened from a bar that says where you are. */
.rail-bar, .rail-head, .rail-back { display: none; }
.phone-only { display: none; }
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail-bar { display: flex; align-items: center; gap: 10px; position: sticky; top: calc(var(--top) + env(safe-area-inset-top, 0px)); z-index: 20; padding: 8px 16px; background: var(--surface); border-bottom: 2px solid var(--edge); }
  .rail-bar .rail-here { font-weight: 800; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .rail { position: fixed; top: 0; left: 0; bottom: 0; z-index: 65; width: min(320px, 86vw); height: 100vh; height: 100dvh; padding: calc(12px + env(safe-area-inset-top, 0px)) 12px 24px; border-right: 2px solid var(--edge); box-shadow: var(--shadow-lg); transform: translateX(-105%); transition: transform .2s ease; visibility: hidden; }
  .rail.open { transform: none; visibility: visible; }
  .rail .rail-head { display: flex; align-items: center; justify-content: space-between; padding: 0 4px 0 10px; }
  .rail-back { display: block; position: fixed; inset: 0; z-index: 64; background: var(--scrim); animation: fade .15s ease; }
  .topbar .crumb b { max-width: 40vw; }
  .hide-narrow { display: none !important; }
}
@media (max-width: 640px) {
  .topbar { gap: 8px; padding-inline: 12px; }
  .brand-text { display: none; }
  .topbar .crumb { flex: 1 1 auto; }
  .topbar .crumb b { max-width: none; flex: 0 1 auto; }
  .pub-state .pill { padding: 2px 6px; }
  .pub-state .pub-text { display: none; }
  .topbar .sp { display: none; }
  .topbar .btn.primary { padding-inline: 9px; }
}

/* ------------------------------------------------------------ buttons */
/* Stickers: an ink outline and a hard shadow that the button lifts off on hover and presses into when clicked. */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 38px; padding: 6px 15px; border-radius: var(--radius-btn); border: 2px solid var(--edge); background: var(--surface); color: var(--ink); font-weight: 800; box-shadow: var(--pop-sm); cursor: pointer; text-decoration: none; white-space: nowrap; transition: transform .1s ease, box-shadow .1s ease, background .12s; }
.btn:not(:disabled):hover { transform: translate(-1px, -1px); box-shadow: var(--pop); }
.btn:not(:disabled):active { transform: translate(1px, 1px); box-shadow: 0 0 0 var(--edge); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--primary); color: var(--on-primary); }
.btn.ghost { border-color: transparent; background: transparent; box-shadow: none; color: var(--accent); padding-inline: 8px; }
.btn.ghost:not(:disabled):hover { background: var(--accent-soft); transform: none; box-shadow: none; }
.btn.ghost:not(:disabled):active { transform: none; }
.btn.danger { color: var(--crit); }
.btn.danger:not(:disabled):hover { background: var(--crit-soft); }
.btn.sm { min-height: 32px; padding: 3px 11px; font-size: .86rem; border-radius: 10px; }
.btn.lg { min-height: 46px; padding: 10px 22px; font-size: 1rem; border-radius: 14px; box-shadow: var(--pop); }
.btn svg { width: 16px; height: 16px; }
.icon-btn { width: 34px; height: 34px; border-radius: 10px; border: 1px solid transparent; background: transparent; display: inline-grid; place-items: center; cursor: pointer; color: var(--ink-2); }
.icon-btn:hover { background: var(--surface-2); border-color: var(--rule); color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; }
.seg { display: inline-flex; padding: 3px; gap: 3px; background: var(--surface-2); border: 2px solid var(--edge); border-radius: 13px; flex-wrap: wrap; }
.seg button { border: 1.5px solid transparent; background: transparent; padding: 4px 12px; border-radius: 9px; cursor: pointer; color: var(--ink-2); font-weight: 700; }
.seg button:hover { color: var(--ink); background: var(--surface); }
.seg button.on { background: var(--sun); color: var(--on-color); border-color: var(--edge); font-weight: 800; }

/* ------------------------------------------------------------ surfaces */
.card { background: var(--surface); border: 2px solid var(--edge); border-radius: var(--radius); box-shadow: var(--pop); padding: 18px 20px; min-width: 0; }
.card.flat { box-shadow: none; }
.card.raised { box-shadow: var(--pop-big); }
.card.tint { background: var(--violet-soft); }
/* A card inside another part (a card, a sheet, a group): only a soft line, no shadow. */
.card .card, .modal .card, .m-group-body .card, .tl-group-body .card { border-width: 1.5px; border-color: var(--rule); box-shadow: none; }
.card h3 { margin-bottom: 8px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }
.grid.cards { grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); }
.grid.wide-cards { grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); }
.divider { height: 2px; background: var(--rule); border: 0; margin: 4px 0; }
.callout { border-radius: var(--radius); padding: 12px 16px; background: var(--info-soft); border: 1.5px dashed color-mix(in srgb, var(--edge) 40%, transparent); color: var(--ink); display: flex; gap: 12px; align-items: flex-start; }
.callout svg { width: 20px; height: 20px; flex: none; margin-top: 1px; color: var(--info); }
.callout.warn { background: var(--warn-soft); } .callout.warn svg { color: var(--warn); }
.callout.crit { background: var(--crit-soft); } .callout.crit svg { color: var(--crit); }
.callout.ok { background: var(--ok-soft); } .callout.ok svg { color: var(--ok); }
.empty { text-align: center; padding: 48px 20px; color: var(--ink-2); display: grid; justify-items: center; gap: 10px; }
/* The empty state's icon: a sun sticker, as in the app. */
.empty > svg { box-sizing: border-box; width: 60px; height: 60px; padding: 13px; border-radius: 18px; background: var(--sun); color: var(--on-color); border: 2px solid var(--edge); box-shadow: var(--pop); transform: rotate(-6deg); margin-bottom: 4px; }
.empty h3 { color: var(--ink); }

/* ------------------------------------------------------------ pills & chips */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 1px 10px; border-radius: 99px; border: 1.5px solid color-mix(in srgb, currentColor 30%, transparent); font: 800 .76rem var(--font-ui); background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.pill .dot, .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; flex: none; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.crit { background: var(--crit-soft); color: var(--crit); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.accent { background: var(--accent-soft); color: var(--accent-2); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 99px; border: 1.5px solid var(--edge); background: var(--surface); font-size: .85rem; font-weight: 700; color: var(--ink); }
.chip button { border: 0; background: none; padding: 0; cursor: pointer; color: var(--ink-3); display: inline-grid; }
.chip button:hover { color: var(--crit); }
.chip button svg { width: 13px; height: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* ------------------------------------------------------------ forms */
label.field, .field { display: grid; gap: 6px; min-width: 0; align-content: start; }
.field > .label { font-weight: 800; font-size: .9rem; display: flex; align-items: center; gap: 8px; }
.field > .hint { font-size: .82rem; color: var(--ink-3); margin-top: -2px; }
/* Fields: a calmer outline than the stickers; in focus, the app's violet. */
.input, .select, .textarea { width: 100%; border: 2px solid var(--field-edge); background: var(--surface); border-radius: 12px; padding: 7px 11px; min-height: 40px; font-weight: 600; transition: border-color .12s, box-shadow .12s; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--violet); box-shadow: 0 0 0 3px color-mix(in srgb, var(--violet) 28%, transparent); }
.input::placeholder, .textarea::placeholder { color: var(--ink-3); font-weight: 500; }
.textarea { min-height: 88px; resize: vertical; line-height: 1.5; }
.select { max-width: 100%; min-width: 0; text-overflow: ellipsis; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%), linear-gradient(135deg, var(--ink-2) 50%, transparent 50%); background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
input[type="range"] { accent-color: var(--accent); width: 100%; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { width: 42px; height: 24px; border-radius: 99px; background: var(--surface-2); border: 2px solid var(--edge); position: relative; transition: background .15s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; box-sizing: border-box; border-radius: 50%; background: var(--surface); border: 2px solid var(--edge); transition: transform .15s; }
.switch input:checked + .track { background: var(--mint); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 3px solid var(--violet); outline-offset: 2px; }

/* In-place editing: one look for everything editable. At rest a light underline and a faint pen (always visible
   on touch screens); on hover or focus, a field. Read-only values have neither. */
.editable { position: relative; border-radius: 8px 8px 0 0; padding: 6px 30px 6px 8px; margin: -6px -8px; border: 1px solid transparent; border-bottom: 1px dashed color-mix(in srgb, var(--ink-3) 45%, transparent); cursor: text; white-space: pre-wrap; overflow-wrap: anywhere; min-height: 1.5em; transition: background .12s, border-color .12s; }
.editable:hover, .editable:focus-visible { background: var(--surface-2); border-color: var(--rule); border-bottom-style: solid; border-radius: 8px; }
.editable:focus-visible { outline: 3px solid var(--violet); outline-offset: 1px; }
.editable.empty-text { color: var(--ink-3); font-style: italic; }
.editable .pen { position: absolute; top: 7px; right: 7px; width: 15px; height: 15px; color: var(--ink-3); opacity: .45; transition: opacity .12s; display: inline-grid; }
.editable .pen svg { width: 15px; height: 15px; }
.editable:hover .pen, .editable:focus-visible .pen { opacity: 1; color: var(--accent); }
@media (hover: none) { .editable .pen { opacity: .8; } .editable { border-bottom-style: solid; } }
.editable .saved-tick { position: absolute; top: 5px; right: 6px; background: var(--surface); padding: 0 4px; border-radius: 6px; }
.edit-box { display: grid; gap: 4px; }
.edit-box.busy { opacity: .75; }
.edit-hint { font-size: .74rem; color: var(--ink-3); display: inline-flex; gap: 6px; align-items: center; }
@media (max-width: 640px) { .edit-hint { display: none; } }
/* The «Guardado» tick next to what was just saved (and «Deshacer»). */
.saved-tick { display: inline-flex; align-items: center; gap: 4px; font: 800 .76rem var(--font-ui); color: var(--ok); white-space: nowrap; animation: fade .2s ease; font-style: normal; }
.saved-tick svg { width: 13px; height: 13px; }
.saved-tick .linkish { color: var(--ink-2); font-size: .76rem; }
.with-tick { display: inline-flex; align-items: center; gap: 8px; min-width: 0; max-width: 100%; flex-wrap: wrap; }
.with-tick.block { display: flex; flex-wrap: nowrap; }
.with-tick.block > .select { flex: 1; min-width: 0; }
.field > .with-tick:not(.block) { justify-self: start; }
/* Short values (numbers, dice): the same bordered box everywhere; an empty one shows the game's own value. */
.num-field { display: inline-flex; align-items: center; gap: 8px; min-width: 0; max-width: 100%; }
.num-field .input.num { width: 9.5em; max-width: 100%; font-variant-numeric: tabular-nums; min-height: 34px; padding: 5px 9px; }
.num-field.sm .input.num { width: 6.5em; }
.num-field .input.num::placeholder { color: var(--ink-3); font-style: italic; opacity: 1; }
.info-toggle { border: 0; background: none; padding: 0; color: var(--ink-3); cursor: pointer; display: inline-grid; }
.info-toggle svg { width: 15px; height: 15px; }
.info-toggle[aria-expanded="true"], .info-toggle:hover { color: var(--accent); }
.field > .hint.more { color: var(--ink-2); background: var(--surface-2); border-radius: 8px; padding: 6px 9px; margin-top: 0; }
/* Where something comes from: a quiet outlined badge (not a pill), the same in every card. */
/* Where something comes from: a small tag in the colour of its origin (the book: sun; the AI: violet; the author: mint). */
.src-badge { display: inline-flex; align-items: center; gap: 5px; padding: 0 9px 0 7px; border: 1.5px solid color-mix(in srgb, var(--edge) 25%, transparent); border-radius: 99px; font: 800 .72rem/1.6 var(--font-ui); color: var(--ink-2); background: var(--surface-2); white-space: nowrap; }
.src-badge svg { width: 12px; height: 12px; color: var(--ink-3); }
.src-badge.src-book { background: var(--sun-soft); }
.src-badge.src-book svg { color: var(--warn); }
.src-badge.src-ai { background: var(--violet-soft); }
.src-badge.src-ai svg { color: var(--accent); }
.src-badge.src-author { background: var(--mint-soft); }
.src-badge.src-author svg { color: var(--ok); }
.src-badge .src-detail { color: var(--ink-3); }
.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; flex-wrap: wrap; min-width: 0; }
.card-top .badges { flex-wrap: wrap; justify-content: flex-end; min-width: 0; }
.card-top > .src-badge, .card-top > .badges { margin-left: auto; }
.title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.title-row > .grow { flex: 1 1 260px; }
/* Rules of a record («una vez», «la primera vez»): quiet uppercase text. */
.meta-tag { font: 800 .68rem var(--font-ui); letter-spacing: .07em; text-transform: uppercase; color: var(--ink-3); white-space: nowrap; }
.meta-row { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }
/* What a player can type, as quoted text (never buttons). */
.says { font-size: .86rem; color: var(--ink-2); margin: 0; }
.says q { font-style: italic; quotes: "«" "»"; }
/* A choice that is on or off: a box with a check. */
.check-chip { display: inline-flex; align-items: center; gap: 8px; padding: 3px 11px 3px 8px; border: 1.5px solid var(--field-edge); border-radius: 10px; background: var(--surface); cursor: pointer; font-size: .88rem; font-weight: 700; user-select: none; }
.check-chip input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.check-chip.on { border-color: var(--edge); background: var(--sun-soft); color: var(--ink); box-shadow: var(--pop-sm); }
.check-chip:focus-within { outline: 3px solid var(--violet); outline-offset: 1px; }
.check-chip.off { cursor: default; opacity: .75; }
/* «⋯»: the less used actions of a record. */
.more { position: relative; display: inline-flex; }
.more .menu { position: absolute; top: calc(100% + 6px); right: 0; z-index: 45; min-width: 210px; background: var(--surface); border: 2px solid var(--edge); border-radius: 14px; box-shadow: var(--pop); padding: 5px; display: grid; }
.menu-item { display: flex; align-items: center; gap: 9px; border: 0; background: none; padding: 8px 10px; border-radius: 9px; font-weight: 700; cursor: pointer; text-align: left; font-size: .9rem; color: var(--ink); white-space: nowrap; }
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-2); }
.menu-item svg { width: 16px; height: 16px; color: var(--ink-3); }
.menu-item.danger { color: var(--crit); }
.menu-item.danger svg { color: var(--crit); }
.saving { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; color: var(--ink-3); }
.saved { color: var(--ok); }
.prose-field { font-size: 1rem; line-height: 1.6; }
.title-edit { font: 800 clamp(1.7rem, 3vw, 2.3rem)/1.15 var(--font-display); font-variation-settings: var(--display-axes); }

/* ------------------------------------------------------------ tabs */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--rule); overflow-x: auto; }
.tabs a, .tabs button { border: 0; background: none; padding: 10px 14px; color: var(--ink-2); font-weight: 700; border-bottom: 3px solid transparent; margin-bottom: -2px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.tabs a.on, .tabs button.on { color: var(--ink); font-weight: 800; border-bottom-color: var(--accent); }

/* ------------------------------------------------------------ images */
.slot { position: relative; border-radius: 14px; overflow: hidden; background: repeating-linear-gradient(135deg, var(--surface) 0 10px, var(--surface-2) 10px 20px); border: 2px dashed var(--field-edge); display: grid; place-items: center; color: var(--ink-3); text-align: center; }
.slot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.slot.portrait { aspect-ratio: 2 / 3; }
.slot.portrait img { object-fit: contain; background: radial-gradient(circle at 50% 35%, var(--surface-2), var(--rule-2)); }
.slot.scene { aspect-ratio: 9 / 16; }
.slot.wide { aspect-ratio: 16 / 9; }
.slot.square { aspect-ratio: 1; }
.slot.square img { object-fit: contain; }
/* An object's picture seen in detail (GamePack 0.4): large, 3:4, shown whole */
.slot.detail { aspect-ratio: 3 / 4; }
.slot.detail img { object-fit: contain; background: #111; }
.slot.has { border-style: solid; border-color: var(--edge); background: var(--surface-2); }
.slot.drop { outline: 3px dashed var(--violet); outline-offset: -5px; }
.slot .slot-empty { display: grid; gap: 6px; justify-items: center; padding: 12px; font-size: .82rem; }
.slot .slot-empty svg { width: 26px; height: 26px; }
.slot .slot-actions { position: absolute; inset: auto 6px 6px 6px; display: flex; gap: 4px; justify-content: center; flex-wrap: wrap; opacity: 0; transition: opacity .15s; }
.slot:hover .slot-actions, .slot:focus-within .slot-actions, .slot.touch .slot-actions { opacity: 1; }
.slot .slot-actions .btn { background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(6px); }
.slot .badge { position: absolute; top: 6px; left: 6px; }
.slot .badge .src-badge { background: color-mix(in srgb, var(--surface) 92%, transparent); }
.slot .busy { position: absolute; inset: 0; display: grid; place-items: center; background: color-mix(in srgb, var(--surface) 70%, transparent); }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--pink-soft); color: var(--ink); border: 2px solid var(--edge); display: grid; place-items: center; font-weight: 800; overflow: hidden; flex: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 12%; }
.avatar.lg { width: 64px; height: 64px; font-size: 1.2rem; }
.avatar.xl { width: 88px; height: 88px; font-size: 1.5rem; }

/* ------------------------------------------------------------ entity cards */
.ent-card { display: grid; gap: 10px; background: var(--surface); border: 2px solid var(--edge); border-radius: var(--radius); box-shadow: var(--pop-sm); padding: 10px; text-decoration: none; color: inherit; transition: box-shadow .12s, transform .12s; min-width: 0; }
.ent-card:hover { box-shadow: var(--pop); transform: translate(-1px, -2px); }
.ent-card .ent-name { font-weight: 800; line-height: 1.3; }
.ent-card .ent-meta { font-size: .82rem; color: var(--ink-2); }
.list { display: grid; gap: 1px; background: var(--rule); border: 2px solid var(--edge); border-radius: var(--radius); overflow: hidden; }
.list > * { background: var(--surface); }
.list-row { display: flex; align-items: center; gap: 12px; padding: 11px 14px; color: inherit; text-decoration: none; min-width: 0; }
.list-row > svg { width: 18px; height: 18px; flex: none; color: var(--ink-3); }
a.list-row:hover { background: var(--surface-2); }
details.fold > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; font-weight: 800; padding: 8px 0; color: var(--ink-2); }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::before { content: "▸"; transition: transform .15s; display: inline-block; }
details.fold[open] > summary::before { transform: rotate(90deg); }

/* ------------------------------------------------------------ projects */
.project-card { position: relative; display: grid; grid-template-rows: 150px auto; border-radius: 20px; overflow: hidden; background: var(--surface); border: 2px solid var(--edge); box-shadow: var(--pop); text-decoration: none; color: inherit; transition: box-shadow .12s, transform .12s; }
.project-card:hover { box-shadow: var(--pop-big); transform: translate(-2px, -2px); }
.project-card .cover { background: linear-gradient(160deg, #7c5cff, #3b2a8f 60%, #1d1440); border-bottom: 2px solid var(--edge); position: relative; overflow: hidden; }
.project-card .cover img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 30%; }
.project-card .cover::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 40%, rgba(0, 0, 0, .45)); }
.project-card .cover .pill { position: absolute; left: 12px; top: 12px; z-index: 1; }
.project-card .body { padding: 14px 16px 16px; display: grid; gap: 4px; }
.project-card .title { font: 800 1.2rem/1.2 var(--font-display); font-variation-settings: var(--display-axes); }
.new-card { display: grid; place-items: center; min-height: 250px; border-radius: 20px; border: 2px dashed var(--field-edge); color: var(--accent); text-decoration: none; font-weight: 800; gap: 8px; transition: background .15s, border-color .15s; }
.new-card:hover { background: var(--violet-soft); border-color: var(--edge); }
.new-card svg { width: 34px; height: 34px; }

/* ------------------------------------------------------------ hero (summary) */
.hero { position: relative; border-radius: 24px; overflow: hidden; background: #1d1533; color: #fbf3e6; border: 2px solid var(--edge); box-shadow: var(--pop-big); min-height: 260px; display: grid; }
.hero .bg { position: absolute; inset: 0; background-size: cover; background-position: center 30%; filter: saturate(1.05); transform: scale(1.02); }
.hero .shade { position: absolute; inset: 0; background: linear-gradient(90deg, rgba(29, 21, 51, .94) 0%, rgba(29, 21, 51, .76) 45%, rgba(29, 21, 51, .18) 100%); }
.hero .content { position: relative; padding: clamp(20px, 4vw, 40px); display: grid; gap: 12px; align-content: end; max-width: 720px; }
.hero h1 { color: #fff; }
.hero .editable:hover { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .2); }
.hero .editable .pen { color: #C9CFE0; }
.hero .input.hero-title { font: 800 clamp(1.7rem, 3vw, 2.4rem)/1.15 var(--font-display); font-variation-settings: var(--display-axes); background: rgba(29, 21, 51, .6); color: #fff; }
.hero .quote { font: italic 1.08rem/1.55 var(--font-display); color: #E6E9F3; max-width: 60ch; }
.hero .meta { display: flex; flex-wrap: wrap; gap: 8px 18px; color: #C9CFE0; font-size: .92rem; }
/* the text the game opens with, edited in place; the cover (3:4) and «Cambiar portada» */
.hero-intro { display: grid; gap: 6px; justify-items: start; max-width: 60ch; }
.hero .edit-box { width: 100%; }
.hero .edit-box .textarea { background: rgba(29, 21, 51, .6); color: #fff; font: italic 1.02rem/1.5 var(--font-display); }
.hero .edit-hint { color: #C9CFE0; }
.hero-cover-row { display: flex; align-items: center; gap: 12px; }
.hero-cover { width: 66px; aspect-ratio: 3 / 4; flex-shrink: 0; display: grid; place-items: center; padding: 0; overflow: hidden; border-radius: 10px; border: 2px solid rgba(255, 255, 255, .35); background: rgba(255, 255, 255, .08); color: #C9CFE0; cursor: pointer; }
.hero-cover img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 30%; }
/* the cover's sheet: the preview of the app's card, then the ways to change it */
.cover-sheet { display: grid; grid-template-columns: minmax(0, 240px) minmax(0, 1fr); gap: 22px; align-items: start; }
.cover-preview { margin: 0; display: grid; gap: 8px; }
.cover-card { overflow: hidden; border: 2px solid var(--edge); border-radius: 18px; background: var(--surface); box-shadow: var(--pop-sm); }
.cover-card-img { position: relative; aspect-ratio: 3 / 4; display: grid; place-items: center; background: var(--violet-soft); }
.cover-card-img img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 30%; }
.cover-card-empty { font: 800 3rem/1 var(--font-display); color: var(--violet); }
.cover-card-body { display: grid; gap: 2px; padding: 10px 12px; }
.cover-actions { flex-wrap: wrap; gap: 8px; }
.cover-own { display: flex; align-items: center; gap: 10px; padding: 6px 10px 6px 6px; border: 1.5px solid var(--rule); border-radius: 12px; background: var(--surface); color: inherit; text-align: left; cursor: pointer; justify-self: start; }
.cover-own img { width: 48px; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 6px; }
.cover-picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 104px), 1fr)); gap: 10px; }
.cover-pick { position: relative; min-width: 0; display: grid; gap: 4px; padding: 5px; border: 1.5px solid var(--rule); border-radius: 12px; background: var(--surface); color: inherit; text-align: left; cursor: pointer; }
.cover-pick:hover, .cover-pick.on { border-color: var(--accent); }
.cover-pick.on { box-shadow: 0 0 0 2px var(--accent); }
.cover-pick img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; object-position: 50% 30%; border-radius: 7px; background: var(--surface-2); }
.cover-pick > span.small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cover-pick .busy { position: absolute; inset: 0; display: grid; place-items: center; background: color-mix(in srgb, var(--surface) 70%, transparent); }
@media (max-width: 720px) { .cover-sheet { grid-template-columns: minmax(0, 1fr); } .cover-preview { max-width: 200px; } }
.hero .meta b { color: #fff; font-weight: 800; }
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1180px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .tiles { grid-template-columns: minmax(0, 1fr); } }
/* The summary's tiles: stickers with a band of colour on top, as the app's cards. */
.tile { --tint: var(--sky); display: grid; gap: 6px; padding: 18px 16px 16px; border-radius: var(--radius); background: var(--surface); border: 2px solid var(--edge); box-shadow: inset 0 6px 0 var(--tint), var(--pop-sm); text-decoration: none; color: inherit; transition: box-shadow .12s, transform .12s; position: relative; }
.tiles > .tile:nth-child(4n+1) { --tint: var(--coral); }
.tiles > .tile:nth-child(4n+2) { --tint: var(--mint); }
.tiles > .tile:nth-child(4n+3) { --tint: var(--violet); }
.tiles > .tile:nth-child(4n+4) { --tint: var(--sun); }
a.tile:hover { box-shadow: inset 0 6px 0 var(--tint), var(--pop); transform: translate(-1px, -1px); }
.tile .big { font: 800 1.7rem/1 var(--font-display); font-variation-settings: var(--display-axes); font-variant-numeric: tabular-nums; }
/* Its state beside its title (never over it). */
.tile { grid-template-columns: minmax(0, 1fr) auto; column-gap: 8px; }
.tile > * { grid-column: 1 / -1; }
.tile > .state { grid-column: 2; grid-row: 1; align-self: start; }
.tile > .state + .row { grid-column: 1; grid-row: 1; }
.tile .go { color: var(--accent); font-weight: 800; font-size: .88rem; margin-top: 2px; }

/* ------------------------------------------------------------ wizard */
.wizard { max-width: 760px; margin: 0 auto; display: grid; gap: 22px; }
.steps { display: flex; gap: 8px; list-style: none; margin: 0; padding: 0; }
.steps li { flex: 1; display: grid; gap: 6px; font-size: .85rem; color: var(--ink-3); }
.steps li::before { content: ""; height: 6px; border-radius: 6px; background: var(--rule); }
.steps li.on, .steps li.done { color: var(--ink); font-weight: 800; }
.steps li.on::before { background: var(--coral); }
.steps li.done::before { background: var(--mint); }
.dropzone { border: 2px dashed var(--field-edge); border-radius: 22px; padding: 40px 20px; text-align: center; display: grid; gap: 10px; justify-items: center; background: var(--surface); cursor: pointer; transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone.over { border-color: var(--edge); background: var(--violet-soft); }
.dropzone svg { width: 44px; height: 44px; color: var(--accent); }
.dropzone .big { font: 800 1.25rem var(--font-display); font-variation-settings: var(--display-axes); }
.bookinfo { display: flex; gap: 16px; align-items: center; padding: 14px 16px; border-radius: var(--radius); background: var(--ok-soft); }
.bookinfo svg { width: 34px; height: 34px; color: var(--ok); flex: none; }
.choice-cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }
.choice-card { border: 2px solid var(--edge); border-radius: var(--radius); padding: 14px 16px; background: var(--surface); cursor: pointer; text-align: left; display: grid; gap: 4px; transition: border-color .15s, background .15s; }
.choice-card:hover { box-shadow: var(--pop-sm); }
.choice-card.on { background: var(--sun-soft); box-shadow: var(--pop); }
.choice-card b { font-size: 1rem; }
.choice-card svg { width: 18px; height: 18px; flex: none; color: var(--accent); }
.estimate { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background: var(--rule); border-radius: var(--radius); overflow: hidden; border: 2px solid var(--edge); }
.estimate > div { background: var(--surface); padding: 14px 16px; display: grid; gap: 2px; }
.estimate b { font: 800 1.4rem var(--font-display); font-variation-settings: var(--display-axes); }

/* ------------------------------------------------------------ progress */
.progress { height: 12px; border-radius: 99px; background: var(--surface-2); border: 2px solid var(--edge); overflow: hidden; }
.progress > div { height: 100%; background: var(--coral); border-radius: 99px; transition: width .6s ease; }
.progress.thin { height: 7px; border-width: 1.5px; }
.phases { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.phases li { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 10px; align-items: center; color: var(--ink-3); }
.phases li .mk { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--rule); display: grid; place-items: center; }
.phases li.done { color: var(--ink-2); }
.phases li.done .mk { background: var(--ok); border-color: var(--ok); color: #fff; }
.phases li.done .mk svg { width: 11px; height: 11px; }
.phases li.now { color: var(--ink); font-weight: 800; }
.phases li.now .mk { border-color: var(--accent); border-top-color: transparent; animation: spin .9s linear infinite; }

/* ------------------------------------------------------------ review */
.qcard { display: grid; gap: 10px; padding: 18px 20px; border-radius: var(--radius); background: var(--surface); border: 2px solid var(--edge); box-shadow: var(--pop); animation: rise .25s ease; }
.qcard .q { font: 700 1.12rem/1.35 var(--font-display); font-variation-settings: var(--display-axes); }
.qcard .ctx { color: var(--ink-2); }
.qcard.leaving { animation: leave .3s ease forwards; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes leave { to { opacity: 0; transform: translateX(24px); height: 0; padding: 0; margin: 0; border-width: 0; } }
/* «Revisar»: both counts under the title, a control to jump between the sections (a Seg on a computer, chips on a
   phone), each section with its heading; an empty one is a single friendly line. */
.rv-summary { font-weight: 700; color: var(--ink); }
.rv-jump { align-self: start; justify-self: start; }
.rv-jump a { display: inline-flex; align-items: center; gap: 8px; border: 1.5px solid transparent; padding: 6px 14px; border-radius: 9px; color: var(--ink-2); font-weight: 700; text-decoration: none; }
.rv-jump a:hover { color: var(--ink); background: var(--surface); }
.rv-jump a.on { background: var(--sun); color: var(--on-color); border-color: var(--edge); font-weight: 800; }
.rv-jump .n { font: 800 .74rem var(--font-ui); font-variant-numeric: tabular-nums; min-width: 22px; padding: 1px 7px; border-radius: 99px; background: var(--surface); border: 1.5px solid var(--rule); color: var(--ink-2); text-align: center; }
.rv-jump a.on .n { border-color: var(--edge); color: var(--ink); }
.rv-section { display: grid; gap: 14px; min-width: 0; scroll-margin-top: calc(var(--top) + 16px); }
.rv-section + .rv-section { padding-top: 22px; border-top: 2px dashed var(--rule); }
.rv-head { display: flex; align-items: flex-start; gap: 12px; min-width: 0; }
.rv-head h2 { font-size: 1.4rem; }
.rv-head p { margin: 4px 0 0; max-width: 64ch; }
.rv-mark { flex: none; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: var(--violet-soft); color: var(--accent-2); border: 2px solid var(--edge); box-shadow: var(--pop-sm); }
.rv-mark svg { width: 20px; height: 20px; }
.rv-mark.ok { background: var(--ok-soft); color: var(--ok); }
.rv-empty { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 14px; padding: 12px 14px; border: 2px solid var(--edge); border-radius: var(--radius); background: var(--surface); box-shadow: var(--pop-sm); min-width: 0; }
.rv-empty > .grow { flex: 1 1 260px; min-width: 0; }
.rv-empty .rv-mark { width: 32px; height: 32px; box-shadow: none; border-width: 1.5px; }
.rv-empty .rv-mark svg { width: 17px; height: 17px; }
.tile-lines { display: grid; gap: 2px; }

/* ------------------------------------------------------------ knowledge buckets */
.buckets { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }
.bucket { border-radius: var(--radius); padding: 12px; display: grid; gap: 8px; align-content: start; }
.bucket h4 { margin: 0; font: 800 .95rem var(--font-ui); display: flex; justify-content: space-between; }
.bucket.freely { background: var(--ok-soft); }
.bucket.trusted { background: var(--info-soft); }
.bucket.persuaded { background: var(--warn-soft); }
.bucket.never { background: var(--rule-2); }
.fact { background: var(--surface); border-radius: 8px; padding: 8px 10px; font-size: .9rem; display: grid; gap: 6px; border: 1px solid var(--rule-2); }
.fact .row { justify-content: space-between; }
.fact select { font-size: .8rem; padding: 2px 24px 2px 8px; min-height: 26px; }

/* ------------------------------------------------------------ chat */
.chat { display: grid; gap: 10px; max-height: 460px; overflow-y: auto; padding: 4px; }
.bubble { max-width: 82%; padding: 9px 13px; border-radius: 16px; line-height: 1.45; }
.bubble.me { justify-self: end; background: var(--primary); color: var(--on-primary); border: 2px solid var(--edge); border-bottom-right-radius: 4px; }
.bubble.npc { background: var(--surface-2); border: 2px solid var(--rule); border-bottom-left-radius: 4px; }
.bubble .who { font-size: .76rem; font-weight: 800; color: var(--ink-3); margin-bottom: 2px; }
.bubble .told { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px; }

/* ------------------------------------------------------------ timeline (views/story.js)
   Each event: its tag as a small pill above its text, then «cuándo · dónde»; only «Empezar aquí» beside it, so the
   text keeps the width. On a phone (below), full-width cards in folding groups and a bar to jump to the start. */
.timeline { position: relative; display: grid; gap: 0; list-style: none; margin: 0; padding: 0; }
.timeline::before { content: ""; position: absolute; left: 11px; top: 8px; bottom: 8px; width: 2px; background: var(--rule); }
.tl-item { position: relative; display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; gap: 4px 12px; align-items: start; padding: 10px 0; }
.tl-item .node { width: 14px; height: 14px; border-radius: 50%; background: var(--mint); border: 2px solid var(--edge); margin: 4px 0 0 5px; z-index: 1; }
.tl-item.past .node { background: var(--rule); border-color: var(--ink-3); }
.tl-item.is-start .node { background: var(--violet); border-color: var(--edge); }
.tl-body { display: grid; gap: 3px; min-width: 0; }
.tl-text { margin: 0; font-weight: 700; line-height: 1.35; overflow-wrap: anywhere; }
.tl-item.past .tl-text { color: var(--ink-2); font-weight: 600; }
.tl-item .when { margin: 0; font-size: .8rem; color: var(--ink-3); overflow-wrap: anywhere; }
.tl-tag { justify-self: start; display: inline-flex; align-items: center; padding: 0 8px; border-radius: 99px; border: 1.5px solid color-mix(in srgb, var(--edge) 25%, transparent); background: var(--surface-2); color: var(--ink-2); font: 800 .64rem/1.6 var(--font-ui); letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; }
.tl-tag.fixed { background: var(--coral-soft); }
.tl-tag.flex { background: var(--sky-soft); }
.tl-item .tl-actions { opacity: 0; transition: opacity .15s; }
.tl-item:hover .tl-actions, .tl-item:focus-within .tl-actions { opacity: 1; }
.tl-start { position: relative; margin: 4px 0 10px 32px; padding: 10px 14px; border-radius: 14px; background: var(--primary); color: var(--on-primary); border: 2px solid var(--edge); box-shadow: var(--pop-sm); font-weight: 800; display: flex; gap: 10px; align-items: center; scroll-margin: 120px 0; }
.tl-start svg { width: 16px; height: 16px; flex: none; }
.tl-start:focus { outline: none; }
.tl-start:focus-visible { outline: 3px solid var(--violet); outline-offset: 2px; }
.tl-phone { gap: 10px; }
.tl-group > summary { list-style: none; display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 6px 4px; cursor: pointer; font: 800 1.1rem var(--font-display); font-variation-settings: var(--display-axes); }
.tl-group > summary::-webkit-details-marker { display: none; }
.tl-group > summary > svg { width: 18px; height: 18px; color: var(--ink-3); transition: transform .15s; flex: none; }
.tl-group[open] > summary > svg { transform: rotate(90deg); }
.tl-group-body { display: grid; gap: 10px; padding-bottom: 6px; }
.tl-phone .timeline { gap: 10px; }
.tl-phone .timeline::before { display: none; }
.tl-phone .tl-item { grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 12px 14px; background: var(--surface); border: 2px solid var(--edge); border-radius: 14px; box-shadow: var(--pop-sm); }
.tl-phone .tl-item .node { display: none; }
.tl-phone .tl-item.past { background: var(--surface-2); border-color: var(--rule); box-shadow: none; }
.tl-phone .tl-item.is-start { background: var(--violet-soft); border-color: var(--edge); box-shadow: var(--pop); }
.tl-phone .tl-actions { opacity: 1; justify-self: end; }
.tl-phone .tl-start { margin: 0; }
.tl-more { justify-self: center; }
/* Where the game starts, always in view above the bottom bar, with the jump to it. */
.tl-jump { position: sticky; bottom: calc(70px + env(safe-area-inset-bottom, 0px)); z-index: 15; display: flex; align-items: center; gap: 10px; margin-top: 4px; padding: 8px 8px 8px 12px; border-radius: 16px; background: var(--surface); border: 2px solid var(--edge); box-shadow: var(--pop); }
.tl-jump > svg { width: 18px; height: 18px; color: var(--accent); flex: none; }
.tl-jump-text { flex: 1; min-width: 0; display: grid; line-height: 1.25; }
.tl-jump-text span { font-size: .74rem; font-weight: 700; color: var(--ink-3); }
.tl-jump-text b { font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main .tl-jump .btn { flex: none; max-width: 48%; line-height: 1.15; }

/* ------------------------------------------------------------ the map of places (lib/map.js, views/places.js) */
.map { width: 100%; height: auto; display: block; max-height: 520px; }
.pm-overview .pm-edge-o { stroke: color-mix(in srgb, var(--ink-3) 75%, transparent); stroke-width: 2.5; fill: none; }
.pm-overview a { cursor: pointer; }
.pm-overview a:hover .pm-box, .pm-overview a:focus-visible .pm-box { fill: var(--violet-soft); stroke: var(--accent); }
.avatar.sm { width: 30px; height: 30px; font-size: .72rem; border-width: 1.5px; }
.page.map-page { max-width: none; gap: 14px; }
.main:has(.map-page) { padding-bottom: 12px; }
/* on the map, what was just done is said over the map's lower left, never over the panel of what is chosen */
@media (min-width: 721px) { body:has(.map-page) .toasts { right: auto; left: calc(var(--rail) + 40px); } }
@media (min-width: 721px) and (max-width: 900px) { body:has(.map-page) .toasts { left: 24px; } }
.pm-views button { display: inline-flex; align-items: center; gap: 6px; }
.pm-views svg { width: 15px; height: 15px; }
.pm-shell { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; min-height: 0; }
.pm-shell.has-panel { grid-template-columns: minmax(0, 1fr) 340px; }
.pm-stage { position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column; border: 2px solid var(--edge); border-radius: var(--radius); box-shadow: var(--pop); overflow: hidden;
  background-color: var(--surface-2); background-image: radial-gradient(color-mix(in srgb, var(--ink-3) 22%, transparent) 1.2px, transparent 1.4px); background-size: 22px 22px; }
.pm { position: relative; flex: 1; min-height: 0; }
.pm-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab; }
.pm.moving .pm-svg { cursor: grabbing; }
.pm-world { transform-origin: 0 0; transition: transform .18s ease; }
.pm.moving .pm-world { transition: none; }
.pm-loading { flex: 1; display: grid; place-items: center; }
.pm-controls { position: absolute; right: 10px; bottom: 10px; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.pm-controls .btn { min-width: 38px; font-size: .95rem; }
/* regions: soft labelled groups */
.pm-region rect { fill: var(--sun-soft); stroke: color-mix(in srgb, var(--edge) 22%, transparent); stroke-width: 1.5; stroke-dasharray: 6 5; }
.pm-region.r1 rect { fill: var(--mint-soft); } .pm-region.r2 rect { fill: var(--sky-soft); } .pm-region.r3 rect { fill: var(--pink-soft); } .pm-region.r4 rect { fill: var(--violet-soft); }
.pm-region text { font: 700 17px var(--font-hand); fill: var(--ink-2); }
/* ways between places */
.pm-edge { cursor: pointer; }
.pm-edge .pm-hit { stroke: transparent; stroke-width: 18; fill: none; }
.pm-edge .pm-line { stroke: color-mix(in srgb, var(--ink-3) 75%, transparent); stroke-width: 2.5; fill: none; stroke-linecap: round; }
.pm-edge.locked .pm-line { stroke: var(--crit); stroke-dasharray: 8 6; }
.pm-edge.guarded .pm-line { stroke: var(--info); stroke-dasharray: 2 6; stroke-width: 3; }
.pm-edge.near .pm-line { stroke: var(--accent); }
.pm-edge:hover .pm-line { stroke-width: 3.5; }
.pm-edge.sel .pm-line { stroke: var(--accent); stroke-width: 4; }
.pm-arrowhead { fill: color-mix(in srgb, var(--ink-3) 85%, transparent); } .pm-arrowhead.sel { fill: var(--accent); }
.pm-mark circle { fill: var(--surface); stroke: var(--edge); stroke-width: 1.5; }
.pm-edge.locked .pm-mark .pm-glyph { stroke: var(--crit); } .pm-edge.guarded .pm-mark .pm-glyph { stroke: var(--info); }
.pm-elabel rect { fill: var(--surface); stroke: var(--edge); stroke-width: 1.5; }
.pm-elabel text { font: 700 12px var(--font-ui); fill: var(--ink); }
.pm-drawing { stroke: var(--accent); stroke-width: 3; stroke-dasharray: 6 5; fill: none; pointer-events: none; }
.pm-glyph { fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
/* places: stickers with their picture, name and badges */
.pm-node { cursor: pointer; outline: none; color: var(--ink-2); }
.pm-node .pm-shadow { fill: var(--edge); }
.pm-node .pm-box { fill: var(--surface); stroke: var(--edge); stroke-width: 2; }
.pm-node:hover .pm-box { fill: color-mix(in srgb, var(--violet-soft) 40%, var(--surface)); }
.pm-node.start .pm-box { stroke-width: 3; }
.pm-node.sel .pm-box { fill: var(--violet-soft); stroke: var(--accent); stroke-width: 3.5; }
.pm-node:focus-visible .pm-box { stroke: var(--violet); stroke-width: 4; }
.pm-node.unreach .pm-box { stroke-dasharray: 7 5; }
.pm-node.target .pm-box { stroke: var(--accent); stroke-dasharray: 5 4; }
.pm-node .pm-noimg rect { fill: var(--surface-2); stroke: var(--rule); }
.pm-node .pm-noimg { color: var(--ink-3); }
.pm-name { font: 800 13.5px var(--font-ui); fill: var(--ink); }
.pm-badge rect { fill: var(--surface-2); stroke: color-mix(in srgb, var(--edge) 35%, transparent); stroke-width: 1; }
.pm-badge text { font: 800 11px var(--font-ui); fill: var(--ink-2); }
.pm-badge.start { color: var(--on-color); } .pm-badge.start rect { fill: var(--sun); stroke: var(--edge); }
.pm-badge.warn { color: var(--warn); } .pm-badge.warn rect { fill: var(--warn-soft); stroke: var(--warn); }
.pm-handle { cursor: crosshair; opacity: 0; transition: opacity .12s; color: var(--accent-ink); }
.pm-handle circle { fill: var(--accent); stroke: var(--edge); stroke-width: 2; }
.pm-node:hover .pm-handle, .pm-node.sel .pm-handle, .pm-node:focus-visible .pm-handle { opacity: 1; }
@media (hover: none) { .pm-handle { display: none; } }
/* connecting: what to tap */
.pm-banner { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 10px; background: var(--violet-soft); border-bottom: 2px solid var(--edge); font-weight: 700; z-index: 2; }
.pm-banner .pm-pick { width: auto; max-width: 240px; }
/* the panel of what is chosen (a computer: beside the map; a phone: a sheet over its lower part) */
.pm-panel { min-height: 0; overflow-y: auto; border: 2px solid var(--edge); border-radius: var(--radius); background: var(--surface); box-shadow: var(--pop); overscroll-behavior: contain; }
.pm-panel-body { padding: 14px 16px 18px; }
.pm-panel-head { display: flex; align-items: flex-start; gap: 8px; }
.pm-panel-head .eyebrow { font-size: 1.1rem; }
.pm-title { font-size: 1.35rem; overflow-wrap: anywhere; margin-bottom: 4px; }
.pm-title .linkish { color: inherit; font-weight: inherit; text-align: left; }
.pm-img { aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; border: 2px solid var(--edge); background: var(--surface-2); display: grid; place-items: center; color: var(--ink-3); }
.pm-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pm-noimg-link { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 1.5px dashed var(--rule); border-radius: 12px; color: var(--ink-2); text-decoration: none; font-weight: 700; }
.pm-noimg-link svg { width: 18px; height: 18px; color: var(--ink-3); }
.pm-desc { margin: 0; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.pm-who { color: inherit; text-decoration: none; font-weight: 700; font-size: .9rem; }
.pm-ways { display: grid; gap: 2px; }
.pm-way { display: flex; align-items: center; gap: 4px; min-height: 44px; border-bottom: 1px solid var(--rule-2); }
.pm-way:last-child { border-bottom: 0; }
.pm-way .linkish { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; text-align: left; color: var(--ink); text-decoration: none; font-weight: 700; min-height: 40px; }
.pm-way .linkish svg { color: var(--ink-3); }
.pm-dir { width: 22px; text-align: center; color: var(--accent); font-weight: 800; flex: none; }
.pm-actions { display: grid; gap: 8px; }
.pm-actions .btn { justify-content: flex-start; }
.pm-dirs { display: grid; grid-template-columns: minmax(0, 1fr); width: 100%; }
.pm-dirs button { text-align: left; }
.pm-legend { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 8px; color: var(--ink-2); }
.pm-legend li { display: flex; align-items: center; gap: 10px; }
.pm-legend li > span, .pm-legend li > svg { flex: none; width: 34px; display: inline-grid; place-items: center; }
.pm-legend .lg-star { color: var(--on-color); } .pm-legend .lg-star svg { background: var(--sun); border-radius: 99px; padding: 2px; border: 1.5px solid var(--edge); box-sizing: content-box; }
.pm-legend .lg-warn { color: var(--warn); }
.pm-legend .lg-line { stroke: var(--ink-3); stroke-width: 2.5; fill: none; } .pm-legend .lg-arrow { fill: var(--ink-3); }
.pm-legend .lg-line.locked { stroke: var(--crit); stroke-dasharray: 6 4; } .pm-legend .lg-line.guarded { stroke: var(--info); stroke-dasharray: 2 4; stroke-width: 3; }
.rm-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.rm-list li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rm-block > svg { color: var(--warn); }
@media (max-width: 1100px) { .pm-shell.has-panel { grid-template-columns: minmax(0, 1fr) 300px; } }
.pm-legend-pop { position: absolute; left: 10px; bottom: 10px; z-index: 3; width: min(320px, calc(100% - 20px)); max-height: calc(100% - 20px); overflow-y: auto; padding: 12px 14px; background: var(--surface); border: 2px solid var(--edge); border-radius: 14px; box-shadow: var(--pop); }
@media (max-width: 720px) {
  .main:has(.map-page) { padding-bottom: calc(66px + env(safe-area-inset-bottom, 0px)); }
  .pm-shell, .pm-shell.is-phone { display: block; position: relative; margin: 0 -16px; }
  .pm-shell .pm-stage { height: 100%; border-radius: 0; border-inline: 0; box-shadow: none; }
  .pm-controls { top: 10px; bottom: auto; right: 10px; flex-direction: column; }
  .pm-controls .btn { min-width: 44px; }
  .pm-sheet { position: absolute; left: 0; right: 0; bottom: 0; max-height: 58%; overflow-y: auto; overscroll-behavior: contain; background: var(--paper); border-top: 2px solid var(--edge); border-radius: 22px 22px 0 0; box-shadow: 0 -4px 0 color-mix(in srgb, var(--edge) 18%, transparent); z-index: 5; animation: sheet-up .2s ease; }
  .pm-sheet::before { content: ''; display: block; width: 44px; height: 5px; border-radius: 99px; background: var(--rule); margin: 8px auto 0; }
  .pm-sheet .pm-img { aspect-ratio: 21 / 9; }
  .pm-banner { font-size: .9rem; }
  .pm-banner > .grow { flex: 1 1 100%; }
  .pm-banner .pm-pick { flex: 1 1 160px; max-width: none; }
}

/* ------------------------------------------------------------ phone frame */
.phone { width: min(100%, 390px); aspect-ratio: 390 / 800; border-radius: 42px; padding: 12px; background: #17122a; border: 2px solid var(--edge); box-shadow: var(--pop-big); margin: 0 auto; }
.phone iframe { width: 100%; height: 100%; border: 0; border-radius: 32px; background: #000; }

/* ------------------------------------------------------------ interactions */
.rule-card { display: grid; gap: 8px; padding: 14px 16px; border-radius: var(--radius); background: var(--surface); border: 2px solid var(--edge); box-shadow: var(--pop-sm); }
.rule-card .sentence { line-height: 1.7; }
.rule-card .sentence > .src-badge { float: right; margin: 3px 0 4px 10px; line-height: 1.5; }
.rule-card .sentence b { color: var(--accent-2); font-weight: 800; }
.rule-card .sentence .when { color: var(--ink-3); font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 800; margin-right: 4px; }
.rule-card .text { font-family: var(--font-display); font-style: italic; color: var(--ink-2); border-left: 3px solid var(--sun); padding-left: 10px; }
.rule-card.arrival { border-left: 6px solid var(--violet); }
/* quests: each step a soft card (its text, «Se cumple cuando…» and what is wrong with it), with its tools */
.quest-steps { margin: 0 0 4px; padding: 0; list-style: none; display: grid; gap: 8px; }
.quest-step { display: grid; gap: 6px; padding: 10px 12px; border-radius: var(--radius); border: 1.5px solid var(--rule); background: var(--surface-2); min-width: 0; }
.quest-step.bad { border-color: var(--warn); }
.quest-step-head { display: flex; gap: 8px; align-items: flex-start; min-width: 0; }
.quest-step-head > .grow { min-width: 0; }
.quest-step-num { color: var(--ink-3); font-weight: 800; font-variant-numeric: tabular-nums; padding-top: 4px; }
.quest-step-tools { flex: none; flex-wrap: nowrap; }
.quest-when, .quest-preview p { line-height: 1.6; overflow-wrap: anywhere; }
.quest-when .when, .quest-preview .when { color: var(--ink-3); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 800; margin-right: 6px; }
.quest-preview { box-shadow: none; border-width: 1.5px; border-color: var(--rule); }
.warn-text svg { vertical-align: -2px; }
.starters { margin: 0; padding-left: 1.1em; display: grid; gap: 4px; }
.starter-link { display: inline-flex; gap: 6px; align-items: center; text-align: left; font-weight: 700; color: var(--accent-2); }
.quest-card.focus { outline: 3px solid var(--accent); outline-offset: 2px; }
@media (max-width: 720px) {
  .quest-step-head { flex-wrap: wrap; }
  .quest-step-head > .grow { flex: 1 1 calc(100% - 2em); }
  .quest-step-tools { width: 100%; justify-content: flex-end; }
}
/* encounters: each enemy and its numbers (they wrap into two or three columns on a phone) */
.enemy { display: grid; gap: 8px; padding: 12px 14px; border-radius: var(--radius); border: 1.5px solid var(--rule); background: var(--surface-2); min-width: 0; }
.enemy .enemy-name { font-weight: 800; }
.enemy-stats { display: grid; gap: 10px 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 112px), 1fr)); }
.enemy-stat { display: grid; gap: 4px; align-content: start; min-width: 0; }
.enemy-stat > .label { font: 800 .7rem var(--font-ui); letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); }
.enemy-stat .editable { font-variant-numeric: tabular-nums; }
/* object states: each as the player sees it (name, description), how it starts and what changes it */
.obj-state { display: grid; gap: 6px; padding: 10px 12px; border-radius: var(--radius); border: 1.5px solid var(--rule); background: var(--surface-2); min-width: 0; }
.obj-state .obj-state-name { font-weight: 800; }
.obj-state-add { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto; gap: 8px; align-items: center; }
@media (max-width: 640px) { .obj-state-add { grid-template-columns: 1fr; } }
/* playable roles: characteristics and skills as small number fields; adding a weapon of their own */
.role-numbers { display: grid; gap: 10px 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 132px), 1fr)); }
.role-number { display: grid; gap: 4px; align-content: start; min-width: 0; }
.role-number > .label { font: 800 .7rem var(--font-ui); letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); }
.role-number .input { font-variant-numeric: tabular-nums; }
.role-weapon-add { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, .8fr) auto; gap: 8px; align-items: center; }
@media (max-width: 640px) { .role-weapon-add { grid-template-columns: 1fr; } }
/* classic levels (d20): the numbers in one line, the skills as chips that cycle (untrained, trained, mastered),
   and how an enemy takes each kind of damage */
.d20-line { margin: 0; font: 500 .82rem var(--font-mono); color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.skill-chip { font: inherit; font-size: .85rem; color: var(--ink); }
.skill-chip b { font-variant-numeric: tabular-nums; font-weight: 600; }
.skill-chip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-2); }
.skill-chip.mastered { border-width: 2px; padding: 3px 10px 3px 7px; }
.damage-grid { display: grid; gap: 6px 18px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); padding: 4px 0 6px; }
.builder { display: grid; gap: 8px; }
.builder-row { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.5fr) auto; gap: 8px; align-items: center; }
@media (max-width: 640px) { .builder-row { grid-template-columns: 1fr; } }

/* ------------------------------------------------------------ conversations */
.stats { display: grid; gap: 12px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stat { display: grid; gap: 4px; align-content: start; padding: 14px 16px; border-radius: var(--radius); background: var(--surface); border: 2px solid var(--edge); box-shadow: var(--pop-sm); min-width: 0; color: inherit; text-decoration: none; }
.stat .stat-label { font-size: .82rem; font-weight: 700; color: var(--ink-2); }
.stat .stat-value { font: 800 1.6rem/1.1 var(--font-display); font-variation-settings: var(--display-axes); font-variant-numeric: tabular-nums; }
.stat .stat-sub { font-size: .8rem; color: var(--ink-3); }
.stat.warn { background: var(--warn-soft); }
.stat.warn .stat-value { color: var(--warn); }
a.stat:hover { box-shadow: var(--pop); }
.list-row.plain { width: 100%; border: 0; border-radius: 0; background: var(--surface); font: inherit; color: inherit; text-align: left; cursor: pointer; }
.list-row.plain:hover { background: var(--surface-2); }
.linkish { border: 0; background: none; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
details.list-item > summary { list-style: none; cursor: pointer; }
details.list-item > summary::-webkit-details-marker { display: none; }
details.list-item > summary svg { color: var(--ink-3); transition: transform .15s; }
details.list-item[open] > summary svg { transform: rotate(90deg); }
.list-detail { padding: 0 14px 12px; }
.conv-row { flex-wrap: wrap; align-items: flex-start; }
.conv-row > .grow { flex: 1 1 260px; }
.conv-actions { flex: 0 1 auto; flex-wrap: nowrap; }
.conv-actions .select { width: auto; max-width: 230px; min-width: 0; }
.select.sm { min-height: 30px; padding: 3px 28px 3px 9px; font-size: .86rem; }
.phrase { font: italic 500 1.02rem/1.4 var(--font-display); overflow-wrap: anywhere; }
.reason { display: grid; gap: 4px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); overflow-wrap: anywhere; }
.code-block { margin: 0; padding: 8px 10px; border: 1px solid var(--rule); border-radius: 8px; background: var(--surface); white-space: pre-wrap; overflow-wrap: anywhere; }
.bar { height: 8px; border-radius: 99px; background: var(--rule-2); overflow: hidden; }
.bar > div { height: 100%; border-radius: 99px; background: var(--accent); }
.funnel-step { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(80px, 1fr) auto; gap: 12px; align-items: center; }
@media (max-width: 640px) { .funnel-step { grid-template-columns: minmax(0, 1fr) auto; } .funnel-step .bar { grid-column: 1 / -1; grid-row: 2; } }
.split-bar { display: flex; height: 12px; border-radius: 99px; overflow: hidden; background: var(--rule-2); }
.split-bar .finished, .dot.finished { background: var(--ok); }
.split-bar .playing, .dot.playing { background: var(--info); }
.split-bar .left, .dot.left { background: var(--warn); }
.finding { display: grid; gap: 8px; align-content: start; padding: 14px 16px; border-radius: var(--radius); border: 1.5px solid var(--rule); background: var(--surface); overflow-wrap: anywhere; }
.finding.warn { border-left: 6px solid var(--sun); }
.finding.alert { border-left: 6px solid var(--coral); }
.finding .suggestion { padding: 8px 10px; border-radius: 8px; background: var(--accent-soft); font-size: .92rem; }
.finding .suggestion svg { vertical-align: -2px; color: var(--accent); }
.transcript { display: grid; gap: 18px; }
.turn { display: grid; gap: 6px; padding: 6px; border-radius: 12px; }
.turn.focus { background: var(--accent-soft); }
.turn .bubble { max-width: 86%; overflow-wrap: anywhere; white-space: pre-wrap; }
.turn-meta { display: flex; gap: 4px; justify-content: flex-end; }
.turn-meta.start { justify-content: flex-start; }
.bubble.msg { border: 2px dashed var(--accent); background: var(--surface); color: var(--ink); }
.bubble.msg.sent { justify-self: end; border-bottom-right-radius: 4px; }
.bubble.msg.received { justify-self: start; border-bottom-left-radius: 4px; }
.bubble.msg .who { color: var(--accent-2); }
.understood { font-size: .82rem; color: var(--ink-2); }
.understood.crit { color: var(--crit); }
.understood.warn { color: var(--warn); }
.chips.end { justify-content: flex-end; }
.clip-line { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ------------------------------------------------------------ style presets */
.presets { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); }
.preset { border: 2px solid var(--edge); border-radius: 14px; overflow: hidden; cursor: pointer; background: var(--surface); padding: 0; text-align: left; display: grid; }
.preset .sw { aspect-ratio: 600 / 662; width: auto; height: auto; border-radius: 0; display: block; }
.preset span.sw { padding: 0; }
.preset .sw img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: top; }
.preset span { padding: 7px 9px; font-size: .84rem; font-weight: 700; }
.preset.on { background: var(--sun-soft); box-shadow: 0 0 0 3px var(--sun), var(--pop-big); }
.preset.on span { font-weight: 800; }
.sample-text { font: italic 1.08rem/1.6 var(--font-display); padding: 14px 18px; border-left: 4px solid var(--sun); background: var(--surface-2); border-radius: 0 10px 10px 0; }

/* ------------------------------------------------------------ modal & toast */
.modal-back { position: fixed; inset: 0; z-index: 60; background: var(--scrim); display: grid; place-items: center; padding: 16px; animation: fade .15s ease; }
.modal { width: min(100%, 640px); max-height: calc(100vh - 32px); overflow-y: auto; background: var(--paper); border: 2px solid var(--edge); border-radius: 24px; box-shadow: var(--pop-big); padding: 22px 24px; display: grid; gap: 16px; animation: rise .2s ease; }
.modal.wide { width: min(100%, 860px); }
.modal-head { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
@keyframes fade { from { opacity: 0; } }
.toasts { position: fixed; z-index: 70; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); display: grid; gap: 8px; width: min(380px, calc(100vw - 32px)); }
.toast { background: var(--surface); color: var(--ink); padding: 12px 14px; border-radius: 16px; border: 2px solid var(--edge); box-shadow: var(--pop); display: flex; gap: 10px; align-items: flex-start; animation: rise .2s ease; }
.toast.err { background: var(--crit-soft); box-shadow: inset 6px 0 0 var(--coral), var(--pop); padding-left: 18px; }
.toast .t-body { flex: 1; min-width: 0; }
.toast .t-title { font-weight: 800; }
.toast .t-text { font-size: .88rem; opacity: .9; }
.toast button { background: none; border: 0; color: inherit; cursor: pointer; font-weight: 800; padding: 0 4px; text-decoration: underline; }

/* ------------------------------------------------------------ misc */
.kbd { font: 500 .78rem var(--font-mono); border: 1px solid var(--rule); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; background: var(--surface); }
.spoiler { filter: blur(6px); cursor: pointer; transition: filter .2s; user-select: none; }
.spoiler.shown { filter: none; user-select: auto; cursor: auto; }
.quote-box { border-left: 3px solid var(--rule); padding: 4px 0 4px 12px; color: var(--ink-2); font-family: var(--font-display); font-style: italic; }
.passage { font-family: var(--font-display); font-size: 1rem; line-height: 1.6; padding: 10px 14px; background: var(--surface-2); border-radius: 10px; }
.passage .pid { font: 500 .72rem var(--font-mono); color: var(--ink-3); display: block; margin-bottom: 4px; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--rule-2); vertical-align: top; }
.table th { font: 800 .7rem var(--font-ui); text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); border-bottom: 2px solid var(--rule); }
.scroll-x { overflow-x: auto; }
.two-col { display: grid; gap: 22px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 980px) { .two-col { grid-template-columns: 300px minmax(0, 1fr); } .two-col.right { grid-template-columns: minmax(0, 1fr) 340px; } }
.sticky { position: sticky; top: calc(var(--top) + 20px); align-self: start; }
@media (max-width: 979px) { .sticky { position: static; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ------------------------------------------------------------ panel (dashboard) */
.panel-controls { flex-wrap: wrap; }
.alert-card { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-radius: var(--radius); background: var(--surface); border: 2px solid var(--edge); border-left: 6px solid var(--sky); box-shadow: var(--pop-sm); flex-wrap: wrap; }
.alert-card > svg { width: 20px; height: 20px; flex: none; margin-top: 2px; color: var(--info); }
.alert-card > .grow { flex: 1 1 260px; }
.alert-card.warn { border-left-color: var(--sun); } .alert-card.warn > svg { color: var(--warn); }
.alert-card.crit { border-left-color: var(--coral); background: var(--crit-soft); } .alert-card.crit > svg { color: var(--crit); }
.stat.kpi { grid-template-rows: auto auto auto 1fr; }
.stat.crit { background: var(--crit-soft); }
.stat.crit .stat-value { color: var(--crit); }
.spark { display: block; width: 100%; height: 30px; margin-top: 6px; overflow: visible; }
.spark .spark-line { fill: none; stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-linecap: round; }
.spark .spark-area { fill: var(--accent-soft); opacity: .7; }
.spark .spark-base { stroke: var(--rule); stroke-width: 1; vector-effect: non-scaling-stroke; }
.spark.warn .spark-line { stroke: var(--warn); } .spark.warn .spark-area { fill: var(--warn-soft); }
.spark.ok .spark-line { stroke: var(--ok); } .spark.ok .spark-area { fill: var(--ok-soft); }
.chart { margin: 0; display: grid; gap: 4px; }
.chart svg { display: block; width: 100%; height: 110px; overflow: visible; }
.chart .axis { stroke: var(--rule); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart .hit { fill: transparent; }
.chart g:hover .col, .chart .hit:hover { opacity: .85; }
.chart .col { fill: var(--accent); }
.chart .col.ok, .sw.ok, .split-bar .seg-ok { fill: var(--ok); background: var(--ok); }
.chart .col.warn, .sw.warn, .split-bar .seg-warn { fill: var(--warn); background: var(--warn); }
.chart .col.info, .sw.info, .split-bar .seg-info { fill: var(--info); background: var(--info); }
.sw.accent, .split-bar .seg-accent { background: var(--accent); }
.chart .line { fill: none; stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-linecap: round; stroke: var(--accent); }
.chart .line.warn { stroke: var(--warn); }
.chart-axis { display: flex; justify-content: space-between; gap: 8px; font-variant-numeric: tabular-nums; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; background: var(--accent); }
.split-bar > div + div { margin-left: 2px; }
.hbar { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(60px, 1fr) auto; gap: 10px; align-items: center; }
.hbar-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-value { color: var(--ink-2); white-space: nowrap; }
.hbar.ok .bar > div { background: var(--ok); }
.hbar.warn .bar > div { background: var(--warn); }
.hbar.info .bar > div { background: var(--info); }
.hbar.muted .hbar-label { color: var(--ink-3); }
@media (max-width: 640px) { .hbar { grid-template-columns: minmax(0, 1fr) auto; } .hbar .bar { grid-column: 1 / -1; grid-row: 2; } .hbar-label { white-space: normal; } }
.mini-stats { display: flex; flex-wrap: wrap; gap: 6px 18px; color: var(--ink-2); }
.mini-stats b { color: var(--ink); font-variant-numeric: tabular-nums; }
.inputs { margin: 0; padding-left: 1.1em; display: grid; gap: 4px; }
.warn-text { color: var(--warn); font-weight: 600; }
.crit-text { color: var(--crit); }
.live-card { display: grid; gap: 10px; text-decoration: none; color: inherit; transition: box-shadow .15s; }
.live-card:hover { box-shadow: var(--pop); }
.live-card .go { color: var(--accent); font-weight: 800; }
.live-figures { display: flex; flex-wrap: wrap; gap: 10px 32px; }
.live-figures > span { display: grid; }
.live-figures b { font: 800 1.6rem/1.1 var(--font-display); font-variation-settings: var(--display-axes); font-variant-numeric: tabular-nums; }

/* ---- Objetos en la escena (lib/scene-ui.js): el fondo del lugar y sus objetos, que se arrastran */
.scene-board { position: relative; height: min(66vh, 600px); width: fit-content; max-width: 100%; margin: 0 auto; border-radius: var(--radius); overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; background: var(--surface-2, #111); }
.scene-bg { display: block; height: 100%; width: auto; max-width: 100%; object-fit: contain; pointer-events: none; }
.scene-fold { position: absolute; left: 0; right: 0; bottom: 0; height: 30%; border-top: 1px dashed rgba(255, 255, 255, .55); background: linear-gradient(180deg, rgba(10, 14, 22, .25), rgba(10, 14, 22, .55)); pointer-events: none; display: flex; align-items: flex-start; justify-content: center; }
.scene-fold span { margin-top: 6px; padding: 2px 8px; border-radius: 999px; background: rgba(10, 14, 22, .65); color: #fff; font-size: 11px; }
.scene-obj { position: absolute; transform: translate(-50%, -100%); padding: 0; border: 0; background: none; cursor: grab; touch-action: none; }
.scene-obj:active { cursor: grabbing; }
.scene-obj img { display: block; height: 100%; width: auto; max-width: none; pointer-events: none; filter: drop-shadow(0 4px 5px rgba(0, 0, 0, .5)); }
.scene-obj.on img, .scene-obj:focus-visible img { filter: drop-shadow(0 0 2px #fff) drop-shadow(0 0 8px var(--accent)); }
.scene-obj:focus-visible { outline: none; }
.scene-size input[type=range] { min-width: 120px; }
.scene-thumb { flex: 0 0 auto; width: 36px; height: 36px; border-radius: 8px; overflow: hidden; background: var(--surface-2, rgba(0, 0, 0, .06)); display: grid; place-items: center; }
.scene-thumb img { width: 100%; height: 100%; object-fit: contain; }
/* ------------------------------------------------------------ sources (Fuentes) */
.why { margin: 0; padding-left: 1.2em; display: grid; gap: 6px; }
.why li::marker { color: var(--ink-3); }
mark { background: color-mix(in srgb, #F7D44A 55%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }
mark.partial { background: color-mix(in srgb, #F7A44A 35%, transparent); }
a.fact { color: inherit; text-decoration: none; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
a.fact:hover { border-color: var(--accent); }
.fact > .icon-btn { width: 26px; height: 26px; justify-self: end; }
.nowrap { white-space: nowrap; }
.scroll-y { max-height: 320px; overflow-y: auto; display: grid; gap: 6px; align-content: start; }
.pick-list { display: grid; gap: 4px; max-height: 240px; overflow-y: auto; padding: 4px 2px; }
.pick-list .check { align-items: flex-start; }
.pick-list .check input { width: 16px; height: 16px; margin-top: 2px; flex: none; }

/* ------------------------------------------------------------ search (top bar) */
.search { position: relative; display: flex; align-items: center; width: min(320px, 28vw); }
.search > svg { position: absolute; left: 10px; width: 16px; height: 16px; color: var(--ink-3); pointer-events: none; }
.search .input { min-height: 34px; padding: 5px 10px 5px 32px; font-size: .9rem; }
.search-results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; min-width: 320px; z-index: 40; background: var(--surface); border: 2px solid var(--edge); border-radius: 14px; box-shadow: var(--pop); padding: 4px; display: grid; max-height: 60vh; overflow-y: auto; }
.search-item { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; align-items: baseline; text-align: left; border: 0; background: none; padding: 7px 10px; border-radius: 7px; cursor: pointer; font-size: .9rem; }
.search-item.on { background: var(--accent-soft); }
.search-item .kind { font: 800 .66rem var(--font-ui); text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); min-width: 92px; }

/* ------------------------------------------------------------ the rail's advanced area */
.rail details.advanced > summary { cursor: pointer; list-style: none; padding: 4px 10px; align-items: center; }
.rail details.advanced > summary::-webkit-details-marker { display: none; }
.rail details.advanced > summary svg { width: 12px; height: 12px; transition: transform .15s; }
.rail details.advanced[open] > summary svg { transform: rotate(90deg); }

/* ------------------------------------------------------------ facts */
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover, .table tr.clickable:focus-visible { background: var(--surface-2); }
.th-sort { color: inherit; text-decoration: none; font: inherit; text-transform: inherit; letter-spacing: inherit; }

/* ------------------------------------------------------------ the case: checks and reasoning */
details.check-row > summary { padding: 2px 0; font-weight: 400; }
.check-details { padding: 4px 0 8px 30px; }
.detail-list { margin: 0; padding-left: 1.1em; display: grid; gap: 2px; }
.detail-rec { display: grid; gap: 2px; }
.graph-wrap { overflow: auto; max-height: 70vh; border: 1px solid var(--rule-2); border-radius: 10px; background: var(--surface-2); }
.sgraph { display: block; }
.sgraph .col-label { font: 500 11px var(--font-mono); fill: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; }
.sgraph .g-edge { fill: none; stroke: var(--ink-3); stroke-width: 1.2; opacity: .55; }
.sgraph .g-edge.requires { stroke: var(--crit); stroke-dasharray: 4 3; }
.sgraph .g-edge.contradicts { stroke: var(--warn); }
.sgraph .arrow { fill: var(--ink-3); }
.sgraph .g-node { cursor: pointer; }
.sgraph .g-node .box { fill: var(--surface); stroke: var(--rule); }
.sgraph .g-node .strip { fill: var(--c); }
.sgraph .g-node .tid { font: 500 9px var(--font-mono); fill: var(--c); text-transform: uppercase; }
.sgraph .g-node .tcat { font: 500 9px var(--font-ui); fill: var(--ink-3); }
.sgraph .g-node .t { font: 11px var(--font-ui); fill: var(--ink); }
.sgraph .g-node:hover .box, .sgraph .g-node:focus-visible .box { stroke: var(--accent); }
.sgraph .g-node.sel .box { stroke: var(--accent); stroke-width: 2; }
.sgraph .g-node.orphan .box { stroke-dasharray: 4 3; stroke: var(--warn); }
.sgraph .g-node.unob .box { fill: var(--warn-soft); }
.sgraph.has-focus .g-node:not(.hl) { opacity: .25; }
.sgraph.has-focus .g-edge:not(.hl) { opacity: .08; }
.sgraph .g-edge.hl { opacity: 1; stroke-width: 1.8; }
.g-clue { --c: #8a5cd0; } .g-fact { --c: var(--info); } .g-interpretation { --c: #2f9c8f; } .g-deduction { --c: var(--accent); } .g-hub { --c: var(--warn); } .g-conclusion { --c: var(--crit); }
.sw.g-clue, .sw.g-fact, .sw.g-interpretation, .sw.g-deduction, .sw.g-hub, .sw.g-conclusion { background: var(--c); }
.legend .ln { display: inline-block; width: 18px; border-top: 2px solid var(--ink-3); }
.legend .ln.req { border-top: 2px dashed var(--crit); }

/* ------------------------------------------------------------ the book */
.book { font-family: var(--font-display); font-size: 1.02rem; line-height: 1.7; display: grid; gap: 10px; }
.book .para { display: grid; grid-template-columns: 74px minmax(0, 1fr); gap: 10px; }
.book .para p { margin: 0; }
.book .para-id { font: 500 .68rem var(--font-mono); color: var(--ink-3); padding-top: 6px; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 640px) { .book .para { grid-template-columns: 1fr; gap: 0; } }
.psg { border-radius: 4px; cursor: pointer; transition: background .12s; }
.psg:hover { outline: 1px solid var(--accent); }
.psg.heat-1 { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.psg.heat-2 { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.psg.heat-3 { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.psg.heat-4 { background: color-mix(in srgb, var(--accent) 32%, transparent); }
.psg.on { outline: 2px solid var(--accent); background: var(--accent-soft); }
.sw-heat { display: inline-block; width: 16px; height: 12px; }

/* ------------------------------------------------------------ findings & artifacts */
details.issue-group > summary { font-weight: 500; }
.json-tree { font: .82rem/1.6 var(--font-mono); overflow-x: auto; }
.json-tree details > summary { cursor: pointer; }
.jchildren { padding-left: 18px; border-left: 1px solid var(--rule-2); margin-left: 4px; }
.jleaf { padding-left: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.jk { color: var(--accent-2); } .js { color: var(--ok); } .jn, .jb { color: var(--warn); } .jnull, .jmeta { color: var(--ink-3); }

/* ------------------------------------------------------------ the art library */
.grid.lib-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 120px), 1fr)); }
.lib-item { position: relative; display: grid; gap: 4px; padding: 6px; border: 1.5px solid var(--rule); border-radius: 12px; background: var(--surface); cursor: pointer; text-align: left; color: inherit; }
.lib-item:hover { border-color: var(--accent); }
.lib-item img { width: 100%; aspect-ratio: 2 / 3; object-fit: contain; background: var(--surface-2); border-radius: 6px; }
.lib-item .busy { position: absolute; inset: 0; display: grid; place-items: center; background: color-mix(in srgb, var(--surface) 70%, transparent); }
.lib-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cited, .cited * { min-width: 0; }
.cited { overflow: hidden; }
.passage .pid.row { display: flex; }

/* Signing in (only from outside, with an access code) */
.signin { max-width: 420px; margin: 8vh auto 0; }
.signin h1 { margin: 0; }
.crit-text { color: var(--crit, #c0392b); margin: 0; }
.signin .row svg { width: 40px; height: 40px; flex-shrink: 0; }

/* ------------------------------------------------------------ facts as cards on phones */
@media (max-width: 640px) {
  .table.facts thead { display: none; }
  .table.facts, .table.facts tbody { display: block; }
  .table.facts tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 12px 14px; border-bottom: 1px solid var(--rule-2); }
  .table.facts td { padding: 0; border: 0; }
  .table.facts td:first-child { grid-column: 1 / -1; }
  .table.facts td.num-cell { display: none; }
  .phone-only { display: inline; }
  .card.scroll-x:has(.table.facts) { overflow: visible; }
}
/* ------------------------------------------------------------ interactions: companions, decisions */
.companions .list-row { flex-wrap: wrap; gap: 6px 14px; }
.companions .list-row > b { flex: 1 1 140px; }
.decision-title { font: 700 1.05rem/1.3 var(--font-display); font-variation-settings: var(--display-axes); }
/* Numbers in a grid of small fields (enemies, roles): the box fills its cell; the tick goes under it. */
.enemy-stat .num-field, .role-number .num-field { display: flex; flex-wrap: wrap; gap: 2px 8px; width: 100%; }
.enemy-stat .num-field .input.num, .role-number .num-field .input.num { width: 100%; }
.enemy-stats { grid-template-columns: repeat(auto-fill, minmax(min(100%, 124px), 1fr)); }
.map-wrap .map { max-width: 760px; margin: 0 auto; }
.role-numbers { grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); }
.hint .info-toggle { vertical-align: -3px; }

/* Mejoras: recommendations with their proposals, the bulk bar */
.imp-controls { align-items: flex-end; flex-wrap: wrap; gap: 12px 18px; }
.imp-bulk { align-items: center; flex-wrap: wrap; gap: 8px 12px; padding: 10px 14px; border: 2px solid var(--edge); border-radius: var(--radius); background: var(--surface-2); position: sticky; top: calc(var(--top) + 8px); z-index: 2; }
.imp-proposal { display: grid; gap: 8px; padding: 12px 14px; border: 1.5px solid var(--rule); border-radius: 12px; background: var(--surface); min-width: 0; overflow-wrap: anywhere; }
.imp-proposal.applied { background: var(--surface-2); }
.imp-head { align-items: flex-start; }
.imp-head .grow { min-width: 0; }
.imp-check { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.imp-changes { margin: 0; padding-left: 1.1em; display: grid; gap: 8px; }
.imp-changes .chips { display: inline-flex; }
.imp-says { margin-top: 4px; padding: 6px 10px; border-left: 4px solid var(--violet); background: var(--accent-soft); border-radius: 0 8px 8px 0; white-space: pre-wrap; }
@media (max-width: 640px) { .imp-bulk { position: static; } }

/* ------------------------------------------------------------ seen in detail, listened to (GamePack 0.4) */
.detail-image { max-width: 280px; }
.detail-hint { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 10px; border-radius: 10px; background: var(--accent-soft); color: var(--ink-2); }
.detail-preview { display: grid; gap: 14px; }
.detail-preview-pic { position: relative; border-radius: 12px; overflow: hidden; background: #05080c; min-height: 170px; display: grid; place-items: center; }
.detail-preview-pic img { display: block; max-width: 100%; max-height: 60vh; object-fit: contain; }
.detail-preview-pic .muted { color: #c9c3b6; padding: 24px; }
.detail-preview-bar { position: absolute; left: 0; right: 0; bottom: 0; padding: 22px 14px 10px; background: linear-gradient(180deg, transparent, rgba(5, 8, 12, .85)); color: #f5dcae; display: grid; gap: 2px; }
.detail-preview-bar b { font-size: 1.1rem; }
.detail-preview-bar span { font-size: .85rem; color: #d6d0c3; }
.detail-preview-text { max-height: 30vh; overflow: auto; }
.detail-preview-text p { margin: 0 0 10px; white-space: pre-line; line-height: 1.55; }
.sound-file { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.sound-file audio { max-width: 100%; height: 36px; }
label.btn.disabled { opacity: .6; pointer-events: none; }

/* ============================================================ phones (≤ 720 px)
   Lists of rows with a search box and filter chips; a record as a page of collapsible groups under a sticky header;
   a bar of areas at the bottom and the area's sections as chips under the top bar; editors as sheets from the bottom
   (a whole record: the whole screen) with their actions always in view; a choice among many as a searchable list;
   large tap targets. The components are in lib/ui.js (useNarrow, ChoicePicker, Group, ItemHeader), lib/lists.js
   and lib/suggest-ui.js (AiActions); desktop keeps its layout. */
.sub-nav, .bottom-nav, .item-head { display: none; }
.crumb-title { border: 0; background: none; padding: 0; margin: 0; font: inherit; color: inherit; text-align: left; cursor: default; min-width: 0; display: flex; }
.param-inputs { display: flex; gap: 6px; align-items: center; flex-wrap: nowrap; min-width: 0; }
.param-inputs > .grow { flex: 1; min-width: 0; }
/* A choice among many, as a field that opens its list (phones) */
.picker-field { display: flex; align-items: center; text-align: left; cursor: pointer; min-width: 0; }
.picker-field .picker-text { flex: 1; min-width: 0; white-space: normal; overflow-wrap: anywhere; line-height: 1.3; }
.picker-field.is-empty { color: var(--ink-3); }
.pick-sheet { display: grid; gap: 2px; }
.pick-item { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 10px 12px; border: 0; border-radius: 12px; font-weight: 700; background: none; text-align: left; font: inherit; color: var(--ink); cursor: pointer; }
.pick-item:hover, .pick-item:focus-visible { background: var(--surface-2); }
.pick-item.on { background: var(--violet-soft); color: var(--accent-2); font-weight: 800; }
.pick-item svg { width: 18px; height: 18px; flex: none; }
.pick-group { font: 800 .72rem var(--font-ui); text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); padding: 12px 12px 4px; }
/* The page's AI generators, in one sheet (phones) */
.ai-menu { display: grid; gap: 8px; }
.ai-item { display: flex; align-items: flex-start; gap: 12px; text-align: left; padding: 12px 14px; border: 2px solid var(--edge); border-radius: 14px; background: var(--surface); box-shadow: var(--pop-sm); font: inherit; color: var(--ink); cursor: pointer; min-height: 56px; }
.ai-item:hover { background: var(--violet-soft); }
.ai-item:disabled { opacity: .6; cursor: default; }
.ai-item > svg, .ai-item > .spinner { width: 20px; height: 20px; color: var(--accent); flex: none; margin-top: 2px; }
.ai-item b { display: block; font-weight: 800; }
.ai-hint { display: block; font-size: .84rem; color: var(--ink-2); margin-top: 2px; }
/* Long lists: search, filter chips, rows */
.list-tools { display: grid; gap: 10px; min-width: 0; }
.list-search { position: relative; display: flex; align-items: center; }
.list-search > svg { position: absolute; left: 12px; color: var(--ink-3); pointer-events: none; }
.list-search .input { padding-left: 36px; }
.chip-row, .sub-nav-items { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; min-width: 0; padding: 0 3px 3px 0; }
.chip-row::-webkit-scrollbar, .sub-nav-items::-webkit-scrollbar { display: none; }
/* Filter chips and the area's sections: the app's chips (an ink outline; the one chosen, sun yellow). */
.fchip { display: inline-flex; align-items: center; gap: 6px; flex: none; min-height: 40px; padding: 6px 14px; border-radius: 99px; border: 2px solid var(--edge); background: var(--surface); color: var(--ink); font: 800 .88rem var(--font-ui); text-decoration: none; white-space: nowrap; cursor: pointer; }
.fchip.on { background: var(--sun); color: var(--on-color); box-shadow: var(--pop-sm); }
.fchip .n { font: 800 .72rem var(--font-ui); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.fchip.on .n { color: var(--on-color); }
.c-list { display: grid; gap: 18px; min-width: 0; }
.c-group { display: grid; gap: 6px; min-width: 0; }
.c-group-h { font: 800 .76rem var(--font-ui); text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); margin: 0 0 0 2px; }
.c-rows { display: grid; background: var(--surface); border: 2px solid var(--edge); border-radius: var(--radius); box-shadow: var(--pop-sm); overflow: hidden; min-width: 0; }
.c-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; min-height: 64px; color: inherit; text-decoration: none; border-top: 1.5px solid var(--rule); min-width: 0; }
.c-row:first-child { border-top: 0; }
.c-row:hover, .c-row:active { background: var(--surface-2); }
.c-row > svg { width: 18px; height: 18px; color: var(--ink-3); flex: none; }
.c-thumb { flex: none; width: 48px; height: 48px; border-radius: 12px; overflow: hidden; background: var(--surface-2); border: 1.5px solid var(--edge); display: grid; place-items: center; color: var(--ink-3); font-weight: 800; font-size: .85rem; }
.c-thumb.round { border-radius: 50%; background: var(--pink-soft); color: var(--ink); }
.c-thumb.wide { width: 64px; }
.c-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.c-thumb.round img, .c-thumb.wide img { object-fit: cover; object-position: 50% 15%; }
.c-thumb svg { width: 22px; height: 22px; }
.c-main { flex: 1; min-width: 0; display: grid; gap: 3px; }
.c-name { font-weight: 800; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c-status { display: flex; align-items: center; gap: 6px; font-size: .8rem; color: var(--ink-2); min-width: 0; overflow: hidden; white-space: nowrap; }
.c-status > span:not(.src-badge):not(.c-warn) { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.c-status .src-badge { font-size: .68rem; padding: 0 5px; flex: none; }
.c-warn { display: inline-flex; align-items: center; gap: 3px; color: var(--warn); font-weight: 800; flex: none; }
.c-warn svg { width: 12px; height: 12px; }
.c-empty { margin: 8px 2px; }
/* A record's page on a phone: collapsible groups */
.m-group { background: var(--surface); border: 2px solid var(--edge); border-radius: var(--radius); box-shadow: var(--pop-sm); min-width: 0; scroll-margin-top: calc(var(--top) + 64px); }
.m-group > summary { list-style: none; display: flex; align-items: center; gap: 10px; padding: 12px 14px 12px 16px; min-height: 54px; font-weight: 800; cursor: pointer; }
.m-group > summary::-webkit-details-marker { display: none; }
.m-group > summary > svg { width: 18px; height: 18px; color: var(--ink-3); transition: transform .15s; flex: none; }
.m-group[open] > summary > svg { transform: rotate(90deg); }
.m-group[open] > summary { border-bottom: 1.5px solid var(--rule); }
.m-count { font: 800 .74rem var(--font-ui); font-variant-numeric: tabular-nums; padding: 0 8px; border-radius: 99px; border: 1.5px solid var(--rule); background: var(--surface-2); color: var(--ink-2); }
.m-group-body { padding: 14px 16px 18px; min-width: 0; }
.m-group-body > section.card { border: 0; padding: 0; background: transparent; }
.m-group-body > section.card > h3:first-child { display: none; }
/* What is shown only on hover elsewhere is always shown on a touch screen (nothing needs a long press). */
@media (hover: none) {
  .tl-item .tl-actions, .slot .slot-actions { opacity: 1; }
}
/* Editable text on a touch screen: it looks like a field (a light box, a solid line and the pen in colour). */
@media (hover: none), (max-width: 720px) {
  .editable { background: var(--surface-2); border: 1.5px solid var(--rule); border-bottom: 2px solid color-mix(in srgb, var(--accent) 45%, var(--rule)); border-radius: 10px; padding: 8px 38px 8px 10px; margin: 0; }
  .editable .pen { opacity: 1; color: var(--accent); top: 10px; right: 11px; }
  .editable.empty-text { border-bottom-style: dashed; }
  .hero .editable { background: rgba(255, 255, 255, .07); border-color: rgba(255, 255, 255, .18); }
}

@media (max-width: 720px) {
  .rail-bar { display: none !important; }
  .hide-phone { display: none !important; }
  .main { padding: 16px 16px 40px; }
  .main.has-bottom-nav { padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
  .page { gap: 18px; }
  .page-head { gap: 12px; }
  .page-head .eyebrow { display: none; }
  .page-head .lede { font-size: .92rem; }
  .page-head > .row.tight, .page-head > .row.head-actions { width: 100%; flex-wrap: nowrap; gap: 8px; }
  .page-head > .row.tight > .btn, .page-head > .btn { flex: 1 1 0; }
  h1 { font-size: 1.85rem; }

  /* the top bar: the game's title in two lines (a tap shows it whole) */
  .crumb-title { cursor: pointer; }
  .topbar .crumb-title b { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; white-space: normal; overflow: hidden; font-size: .92rem; line-height: 1.22; max-width: none; }
  .topbar .crumb-title.full b { display: block; }
  .topbar:has(.crumb-title.full) { height: auto; min-height: calc(var(--top) + env(safe-area-inset-top, 0px)); padding-block: 8px; }
  .topbar .icon-btn { width: 44px; height: 44px; }

  /* the area's sections, under the top bar */
  .sub-nav { display: flex; align-items: center; gap: 6px; position: sticky; top: calc(var(--top) + env(safe-area-inset-top, 0px)); z-index: 20; padding: 7px 12px 5px 6px; background: var(--surface); border-bottom: 2px solid var(--edge); }
  .sub-nav-items { flex: 1; }
  .sub-nav-all { flex: none; width: 44px; height: 44px; }
  /* «Revisar»: its sections start below the top bar and the area's chips */
  .rv-section { scroll-margin-top: calc(var(--top) + 70px + env(safe-area-inset-top, 0px)); }
  .rv-section + .rv-section { padding-top: 18px; }
  .rv-head h2 { font-size: 1.25rem; }
  .rv-head .rv-mark { width: 34px; height: 34px; }
  .rv-empty > .row { width: 100%; }
  /* the bar of areas */
  .bottom-nav { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: color-mix(in srgb, var(--surface) 96%, transparent); backdrop-filter: blur(8px); border-top: 2px solid var(--edge); padding: 0 env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px); }
  .bottom-nav a { display: grid; justify-items: center; align-content: center; gap: 2px; min-height: 58px; padding: 6px 2px; color: var(--ink-3); text-decoration: none; font: 800 .7rem var(--font-ui); }
  .bottom-nav a svg { width: 22px; height: 22px; padding: 2px 14px; box-sizing: content-box; border-radius: 99px; }
  .bottom-nav a.on { color: var(--ink); }
  .bottom-nav a.on svg { background: var(--violet-soft); color: var(--accent); }
  .bottom-nav a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  body:has(.modal-back) .bottom-nav, body:has(input:focus, textarea:focus) .bottom-nav { display: none; }
  .toasts { left: 12px; right: 12px; width: auto; bottom: calc(74px + env(safe-area-inset-bottom, 0px)); }

  /* a record's page: its header, always in view */
  .item-page { gap: 12px; }
  .item-head { display: flex; align-items: center; gap: 6px; position: sticky; top: calc(var(--top) + env(safe-area-inset-top, 0px)); z-index: 20; margin: -16px -16px 0; padding: 4px 12px 4px 4px; min-height: 52px; background: color-mix(in srgb, var(--surface) 96%, transparent); backdrop-filter: blur(8px); border-bottom: 2px solid var(--edge); }
  .item-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 800 1.05rem var(--font-display); font-variation-settings: var(--display-axes); }
  .item-page .title-edit { font-size: 1.45rem; }
  .item-page .ent-head { gap: 12px; align-items: center; }
  .item-page .title-row { gap: 8px; }

  /* large tap targets */
  .btn, .btn.sm { min-height: 44px; }
  .btn.sm { padding: 6px 12px; }
  .icon-btn { width: 44px; height: 44px; }
  .input, .select, .textarea { min-height: 44px; font-size: 16px; }
  .num-field .input.num { min-height: 44px; }
  .select.sm { min-height: 40px; }
  .seg { display: flex; width: 100%; }
  .seg button { flex: 1 1 auto; min-height: 40px; }
  .check-chip, .switch { min-height: 44px; }
  .menu-item { min-height: 48px; }
  .tabs a, .tabs button { padding: 12px 14px; }
  /* «⋯»: its menu as a sheet at the bottom */
  .more .menu { position: fixed; left: 8px; right: 8px; top: auto; bottom: calc(8px + env(safe-area-inset-bottom, 0px)); z-index: 80; min-width: 0; padding: 6px; border-radius: 20px; }
  .menu-item { white-space: normal; }

  /* editors: a sheet from the bottom (a whole record: the whole screen); title and actions always in view */
  .modal-back { place-items: end stretch; padding: calc(24px + env(safe-area-inset-top, 0px)) 0 0; }
  .modal-back:has(.modal.wide) { padding-top: 0; }
  .modal { width: 100%; max-height: 100%; border-radius: 24px 24px 0 0; border-bottom: 0; box-shadow: none; padding: 0 16px; gap: 14px; animation: sheet-up .22s ease; overscroll-behavior: contain; }
  .modal.wide { width: 100%; height: 100%; border-radius: 0; border: 0; padding-top: env(safe-area-inset-top, 0px); }
  .modal-head { position: sticky; top: 0; z-index: 3; background: var(--paper); margin: 0 -16px; padding: 10px 6px 10px 16px; border-bottom: 2px solid var(--rule); align-items: center; }
  .modal-head h2 { font-size: 1.22rem; }
  .modal > .row:last-child { position: sticky; bottom: 0; z-index: 3; background: var(--paper); margin: 0 -16px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px)); border-top: 2px solid var(--rule); flex-wrap: nowrap; }
  .modal > .row:last-child > .row { flex-wrap: nowrap; margin-left: auto; }
  .modal > :last-child:not(.row) { margin-bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
  /* a long list to choose from keeps its search box high on the screen (above the keyboard) */
  .modal.sheet:has(.pick-search) { height: 100%; }
  .modal .grid.two, .modal .grid.three { grid-template-columns: minmax(0, 1fr); }
  .modal .select, .modal .input:not([type=checkbox]):not([type=radio]) { width: 100% !important; max-width: 100% !important; }
  .modal .row > .switch { flex: 1 1 100%; }
  /* condition and effect builders: one card per row, its parts one under another */
  .builder-row { grid-template-columns: minmax(0, 1fr) auto; gap: 8px; padding: 10px; border: 1.5px solid var(--rule); border-radius: 14px; background: var(--surface); }
  .builder-row > .builder-type { grid-column: 1; grid-row: 1; }
  .builder-row > .builder-remove { grid-column: 2; grid-row: 1; }
  .builder-row > .param-inputs { grid-column: 1 / -1; grid-row: 2; display: grid; gap: 8px; }
  .builder-row > .param-inputs:empty { display: none; }
  .param-inputs > * { width: 100%; }
  .param-inputs label.row { justify-content: space-between; flex-wrap: nowrap; }
  .param-inputs label.row .input { width: 120px !important; max-width: 50% !important; flex: none; }
  .pick-many { display: grid; gap: 6px; }
  .pick-many .chip { justify-self: start; }
  .add-target > * { flex: 1; max-width: 100% !important; }
  .in-game { gap: 8px 12px; }
  .in-game > label { flex: 1 1 100%; flex-wrap: wrap; }
  .in-game .with-tick { flex: 1 1 100%; }
  .in-game .select { width: 100% !important; }
  /* a fight's enemy: its name, its numbers and who it is wrap instead of widening the page */
  .enemy > .row.between { flex-wrap: wrap !important; }
  .enemy > .row.between > .grow { flex: 1 1 100%; }
  .c-status .src-badge { padding: 1px 3px; gap: 0; }
}
@keyframes sheet-up { from { transform: translateY(32px); opacity: .5; } }

/* «Música» (GamePack 0.4 music.json): a row per choice (what it is for · its picker, ▶ and «Guardado»), the music files and the built-in moods. */
.music-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 6px 16px; align-items: center; padding: 8px 0; border-top: 1px solid var(--rule); }
.music-row:first-of-type { border-top: 0; }
.music-what { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.music-what a { color: inherit; }
.music-pick { display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; min-width: 0; width: 100%; }
.music-pick > .select { flex: 1 1 auto; min-width: 0; }
.music-pick .saved-tick { flex: none; }
.music-play { flex: none; min-width: 36px; justify-content: center; font-size: .8rem; }
.music-play[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }
.music-file { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-top: 1px solid var(--rule); flex-wrap: wrap; }
.music-file:first-child { border-top: 0; }
.music-file > .grow { flex: 1 1 220px; min-width: 0; }
.music-builtins { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px 18px; }
.music-builtin { display: flex; gap: 10px; align-items: flex-start; min-width: 0; }
.music-rights { align-items: flex-start; padding: 8px 10px; border: 1px solid var(--rule); border-radius: 10px; }
.music-rights input { margin-top: 3px; width: 18px; height: 18px; flex: none; }
@media (max-width: 720px) {
  /* On a phone, one control per row: what it is for above its picker. */
  .music-row { grid-template-columns: minmax(0, 1fr); padding: 10px 0; }
  .music-pick { flex-wrap: wrap; }
  .music-pick > .select { flex: 1 1 calc(100% - 60px); min-height: 44px; }
  .music-play { min-height: 44px; min-width: 44px; }
  .music-builtins { grid-template-columns: minmax(0, 1fr); }
  .music-file .row.tight { width: 100%; }
}

/* Estilo: sections that fold (views/style.js Section): the title row is the toggle; folded, it says what is chosen. */
.style-sec { gap: 14px; }
.style-sec:not(.open) { gap: 0; }
.style-sec-head { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.style-sec-head h3 { margin: 0; flex-shrink: 0; }
.style-sec-sum { flex: 1; min-width: 0; color: var(--ink-3); font-size: .9em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.style-sec-head > svg { flex-shrink: 0; width: 18px; height: 18px; transition: transform .15s; }
.style-sec.open .style-sec-head > svg { transform: rotate(180deg); }
.style-sec-head:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 6px; }
@media (prefers-reduced-motion: reduce) { .style-sec-head > svg { transition: none; } }

/* Tus juegos, for admins: whose each game is, and a filter. */
.whose-filter { margin: 0 0 14px; align-items: center; }
.project-card .owner-line { display: flex; align-items: center; gap: 4px; color: var(--ink-2); font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
