/* GenVN3: pages of an adult graphic novel. Paper, ink line and four process plates:
   teal for actions and selection, caption yellow for the narrator, crimson for danger, ink for text. */

@font-face { font-family: "Pangolin"; font-weight: 400; font-display: swap;
  src: url("../fonts/pangolin-cyrillic-400-normal.woff2") format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Pangolin"; font-weight: 400; font-display: swap;
  src: url("../fonts/pangolin-latin-400-normal.woff2") format("woff2"); unicode-range: U+0000-00AA, U+00AC-00BA, U+00BC-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-2038, U+203B-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
/* « » and ‹ › come from Rubik: Pangolin draws double guillemets like single ones */
@font-face { font-family: "Rubik"; font-weight: 400; font-display: swap; src: url("../fonts/rubik-cyrillic-400-normal.woff2") format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Rubik"; font-weight: 400; font-display: swap; src: url("../fonts/rubik-latin-400-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122, U+2212; }
@font-face { font-family: "Rubik"; font-weight: 500; font-display: swap; src: url("../fonts/rubik-cyrillic-500-normal.woff2") format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Rubik"; font-weight: 500; font-display: swap; src: url("../fonts/rubik-latin-500-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122, U+2212; }
@font-face { font-family: "Rubik"; font-weight: 700; font-display: swap; src: url("../fonts/rubik-cyrillic-700-normal.woff2") format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Rubik"; font-weight: 700; font-display: swap; src: url("../fonts/rubik-latin-700-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122, U+2212; }
@font-face { font-family: "Russo One"; font-weight: 400; font-display: swap; src: url("../fonts/russo-one-cyrillic-400-normal.woff2") format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Russo One"; font-weight: 400; font-display: swap; src: url("../fonts/russo-one-latin-400-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2122, U+2212; }

:root {
  --page: #e9e7e1;          /* bristol board in the shade: the ground of every screen */
  --paper: #fbfaf7;         /* panels */
  --paper-2: #f2f0eb;       /* rows and wells inside panels */
  --white: #ffffff;         /* balloons and fields */
  --art-well: #dedbd3;      /* behind a picture that has not arrived */
  --rule: #d6d3cc;          /* dividers inside panels */
  --ink: #161616;
  --ink-2: #3b3a37;
  --ink-3: #67645e;
  --teal: #1fae9f;          /* C plate: fills that carry ink lettering */
  --teal-hover: #36bfb1;
  --teal-ink: #0b6e68;      /* teal as text and lines on paper */
  --teal-wash: #d5efeb;
  --yellow: #f7e28f;        /* Y plate: the narrator's captions */
  --yellow-deep: #ecc94a;
  --crimson: #c22f4b;       /* M plate: danger and reports */
  --crimson-hover: #d23a57;
  --crimson-ink: #a3233d;
  --crimson-wash: #f7dce1;
  --line: 2px;
  --panel-line: 2.5px;
  --frame-line: 3px;
  --r: 3px;
  --float: 0 1px 0 rgba(22, 22, 22, .1), 0 18px 36px -18px rgba(22, 22, 22, .55);
  --float-sm: 0 1px 0 rgba(22, 22, 22, .08), 0 8px 18px -10px rgba(22, 22, 22, .45);
  --font-ui: "Rubik", "Segoe UI", sans-serif;
  --font-letter: "Pangolin", "Rubik", "Segoe UI", sans-serif;
  --font-story: "Sitka Subheading", "Sitka Text", Georgia, Cambria, serif;   /* Windows serif, the optical size for 17–23px */
  --font-title: "Russo One", "Rubik", sans-serif;
  --scale: 1;               /* the «Размер текста» setting */
  --ui-scale: calc(1 + (var(--scale) - 1) * .5);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font-ui);
  font-size: calc(16px * var(--ui-scale));
  line-height: 1.45;
  color: var(--ink);
  background: var(--page);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
#app { height: 100%; }
button, input, textarea, select { font: inherit; color: inherit; }
::selection { background: var(--yellow); color: var(--ink); }
input, textarea { caret-color: var(--teal-ink); }
* { scrollbar-width: thin; scrollbar-color: #9c9890 transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #9c9890; border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
:focus-visible { outline: 3px solid var(--teal-ink); outline-offset: 2px; }
a { color: var(--teal-ink); text-underline-offset: 3px; }
h1, h2, h3 { text-wrap: balance; }
.icon { flex: none; display: block; }
.num { font-variant-numeric: tabular-nums; }

/* ---- type helpers ------------------------------------------------------------------------- */
.muted { color: var(--ink-3); }
.small { font-size: .9375em; }
.err { color: var(--crimson-ink); font-weight: 500; }

/* The narrator's caption, used as the name of every screen and modal. */
.caption-title {
  display: inline-block; margin: 0;
  background: var(--yellow); border: var(--panel-line) solid var(--ink); border-radius: 2px;
  padding: 5px 14px 6px; font: 400 1.3em/1.15 var(--font-title); letter-spacing: .02em; color: var(--ink);
  text-transform: uppercase;
}

/* ---- controls ------------------------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 7px 16px; border-radius: var(--r);
  background: var(--paper); color: var(--ink); border: var(--line) solid var(--ink);
  font: 500 1em/1.2 var(--font-ui); letter-spacing: .005em; white-space: nowrap; cursor: pointer;
  transition: background-color .12s, box-shadow .12s, transform .12s;
}
.btn:hover { background: var(--teal-wash); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--teal); }
.btn.primary:hover { background: var(--teal-hover); box-shadow: var(--float-sm); }
.btn.danger { background: var(--crimson); color: #fff; }
.btn.danger:hover { background: var(--crimson-hover); box-shadow: var(--float-sm); }
.btn.quiet { background: transparent; border-color: transparent; padding-left: 10px; padding-right: 12px; }
.btn.quiet:hover { background: rgba(22, 22, 22, .07); }
.btn.big { min-height: 52px; padding: 10px 24px; font-size: 1.12em; font-weight: 700; }
.btn.small { min-height: 32px; padding: 4px 11px; font-size: .9em; }
.btn.block { width: 100%; }
.btn:disabled, .btn:disabled:hover {
  background: var(--paper-2); color: #8d8a83; border-color: #a9a69f; box-shadow: none; transform: none; cursor: not-allowed;
}
.btn.quiet:disabled { background: transparent; border-color: transparent; }

.icon-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: var(--r); border: var(--line) solid transparent;
  background: transparent; color: var(--ink); cursor: pointer; transition: background-color .12s;
}
.icon-btn:hover { background: rgba(22, 22, 22, .07); }
.icon-btn.on { background: var(--teal); border-color: var(--ink); }
.icon-btn:disabled { color: #a3a098; cursor: not-allowed; background: transparent; }
.icon-btn.bad:hover { background: var(--crimson-wash); color: var(--crimson-ink); }

/* Tooltips are lettered like small captions. */
[data-tip]:hover::after, [data-tip]:focus-visible::after {
  content: attr(data-tip); position: absolute; top: calc(100% + 7px); left: 50%; transform: translateX(-50%);
  background: var(--yellow); color: var(--ink); border: var(--line) solid var(--ink); border-radius: 2px;
  padding: 3px 9px 4px; font: 500 14px/1.3 var(--font-ui); white-space: nowrap; pointer-events: none;
  z-index: 60; box-shadow: var(--float-sm);
}
[data-tip].tip-end:hover::after, [data-tip].tip-end:focus-visible::after { left: auto; right: 0; transform: none; }

.field { display: block; margin: 0 0 16px; }
.field-label { display: block; font-weight: 500; font-size: .92em; margin-bottom: 6px; color: var(--ink-2); }
label.field small { display: block; color: var(--ink-3); font-size: .9em; margin-top: 6px; line-height: 1.4; }
input[type=text], input[type=number], input[type=email], input[type=password], textarea, select, .style-trigger {
  width: 100%; background: var(--white); color: var(--ink);
  border: var(--line) solid var(--ink); border-radius: var(--r); padding: 9px 12px; outline: none;
  transition: border-color .12s, box-shadow .12s; user-select: text; -webkit-user-select: text;
}
input::placeholder, textarea::placeholder { color: #6a675f; }
input:disabled, textarea:disabled, select:disabled { background: var(--paper-2); color: #8d8a83; border-color: #a9a69f; cursor: not-allowed; }
textarea { resize: vertical; min-height: 96px; line-height: 1.5; }
textarea.fit { field-sizing: content; min-height: calc(2lh + 22px); max-height: calc(14lh + 22px); resize: none; }
select, .style-trigger { appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23161616' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }
input:focus, textarea:focus, select:focus, .style-trigger:focus { border-color: var(--teal-ink); box-shadow: 0 0 0 3px var(--teal-wash); }
input:focus-visible, textarea:focus-visible, select:focus-visible, .style-trigger:focus-visible { outline: none; }
input[type=range] { width: 100%; accent-color: var(--teal-ink); cursor: pointer; }
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; accent-color: var(--teal-ink); margin: 0; cursor: pointer; }
.check { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.check input { flex: none; margin-top: 2px; }

.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }

/* status chips */
.chip {
  display: inline-flex; align-items: center; gap: 7px; min-height: 28px; padding: 2px 11px;
  border: var(--line) solid var(--ink); border-radius: 999px; background: var(--paper);
  font-size: .9em; font-weight: 500; white-space: nowrap;
}
.chip .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--teal); border: 1.5px solid var(--ink); }
.chip.warn .dot { background: var(--yellow-deep); }
.chip.bad { background: var(--crimson-wash); }
.chip.bad .dot { background: var(--crimson); }
.chip.busy { background: var(--teal-wash); }
button.chip { cursor: pointer; font-family: inherit; }
button.chip:hover { background: var(--crimson-wash); }

.spinner {
  width: 16px; height: 16px; flex: none; display: inline-block; border-radius: 50%;
  border: 2.5px solid var(--ink); border-right-color: transparent; animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- screens -------------------------------------------------------------------------------- */
.screen { height: 100%; overflow: auto; padding: 20px 28px 44px; }
/* Centred while it fits; taller than the window it starts at the top and scrolls. `align-content: center` pushed the
   top of a tall menu above the viewport where no scrolling reaches it, so the free space goes to auto margins of the
   one child instead: they share positive space and are 0 when the content overflows. */
.screen.centered { display: grid; }
.screen.centered > .wrap { margin: auto; }
.wrap { max-width: 1240px; margin: 0 auto; }
.wrap.narrow { max-width: 980px; }
.screen-head { display: flex; align-items: center; gap: 16px; min-height: 52px; margin-bottom: 20px; }
.screen-head .head-actions { margin-left: auto; display: flex; gap: 10px; align-items: center; }

.panel { background: var(--paper); border: var(--panel-line) solid var(--ink); border-radius: var(--r); padding: 22px 24px; }
.panel.tight { padding: 14px 16px; }
.panel h2 { font: 400 1.2em/1.2 var(--font-title); margin: 0 0 16px; letter-spacing: .01em; }
.panel h3 { font-size: 1em; font-weight: 700; margin: 22px 0 12px; }
.panel > :last-child { margin-bottom: 0; }
.stack { display: flex; flex-direction: column; gap: 18px; }

.list { display: flex; flex-direction: column; }
.list-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 4px;
  border-bottom: 1.5px solid var(--rule);
}
.list-item:first-child { padding-top: 4px; }
.list-item:last-child { border-bottom: 0; padding-bottom: 4px; }
.list-item .title { font-weight: 500; }
.list-item .meta { font-size: .92em; color: var(--ink-3); }
.pick { width: 100%; text-align: left; background: transparent; border: var(--line) solid transparent;
  border-radius: var(--r); padding: 10px 12px; cursor: pointer; display: flex; gap: 12px; align-items: center; }
.pick:hover { background: rgba(22, 22, 22, .05); }
.pick.on { background: var(--teal-wash); border-color: var(--ink); }
.empty { padding: 26px 8px; color: var(--ink-3); text-align: center; }

/* ---- toasts & modals ------------------------------------------------------------------------ */
.toasts { position: fixed; right: 18px; top: 62px; display: flex; flex-direction: column; gap: 10px; z-index: 100; align-items: flex-end; }
.toast {
  display: flex; gap: 10px; align-items: center; max-width: 440px;
  background: var(--yellow); border: var(--panel-line) solid var(--ink); border-radius: 2px; padding: 9px 14px;
  font-weight: 500; box-shadow: var(--float); animation: place .16s ease-out;
}
.toast.bad { background: var(--crimson-wash); }
.modal-back {
  position: fixed; inset: 0; background: rgba(22, 22, 22, .58); display: flex; align-items: center;
  justify-content: center; z-index: 50; padding: 24px;
}
.modal {
  width: min(720px, 100%); max-height: calc(100vh - 48px); display: flex; flex-direction: column;
  background: var(--paper); border: var(--panel-line) solid var(--ink); border-radius: var(--r);
  box-shadow: var(--float); animation: place .16s ease-out;
}
.modal.wide { width: min(1080px, 100%); }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 16px 16px 0 22px; }
.modal-head .icon-btn { margin-left: auto; }
.modal-body { padding: 18px 24px 22px; overflow: auto; }
.modal-body > p:first-child { margin-top: 0; }

@keyframes place { from { opacity: 0; transform: translateY(4px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---- reader --------------------------------------------------------------------------------- */
.reader {
  position: fixed; inset: 0; display: grid; grid-template-rows: 52px 1fr; background: var(--page);
  user-select: none; -webkit-user-select: none;
}
.quickbar { display: flex; align-items: center; gap: 2px; padding: 0 10px 0 8px; min-width: 0; z-index: 6; }
.quickbar .btn.quiet { min-height: 40px; }
.qb-title { min-width: 0; margin: 0 14px 0 6px; font: 400 1.08em/1.2 var(--font-title); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qb-title .no { color: var(--teal-ink); margin-right: 8px; }
.qb-sep { width: 1.5px; height: 24px; background: #b9b6ae; margin: 0 6px; flex: none; }
.qb-spacer { flex: 1; min-width: 8px; }
.quickbar .chip { margin-right: 6px; }
/* what the next chapters are drawn as: a two-option switch */
.qb-seg { display: inline-flex; flex: none; border: var(--line) solid var(--ink); border-radius: var(--r); overflow: visible; }
.qb-opt {
  position: relative; display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 11px;
  background: transparent; color: var(--ink); border: 0; font: 500 .92em/1 var(--font-ui); cursor: pointer;
}
.qb-opt + .qb-opt { border-left: var(--line) solid var(--ink); }
.qb-opt:hover { background: rgba(22, 22, 22, .07); }
.qb-opt.on, .qb-opt.on:hover { background: var(--teal); font-weight: 700; }
.qb-opt:disabled { cursor: progress; }
.qb-opt:disabled:not(.on) { color: #8d8a83; }
/* Rereading adds a chip and two buttons. When the bar runs out of room they keep only their icons and say the rest in a
   tip: at the 1100×680 window, the smallest the game's window gets, their labels pushed save, undo and the settings
   183px off the bar (2026-11-05). The chip folds only in a narrower browser window. */
.qb-past-btn, .qb-past-chip { position: relative; }
@media (min-width: 1441px) { .qb-past-btn:hover::after, .qb-past-btn:focus-visible::after { content: none; } }
@media (min-width: 1001px) { .qb-past-chip:hover::after { content: none; } }
@media (max-width: 1440px) {
  .quickbar .btn.qb-past-btn { padding-left: 10px; padding-right: 10px; }
  .qb-past-btn .qb-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}
@media (max-width: 1000px) {
  .qb-past-chip .qb-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}
@media (max-width: 1280px) {
  .qb-opt { padding: 0 9px; }
  .qb-opt span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }   /* icons only; the label stays for screen readers */
}

.stage-wrap { position: relative; margin: 0 12px 12px; min-height: 0; }
.stage {
  position: absolute; inset: 0; overflow: hidden; border: var(--frame-line) solid var(--ink); border-radius: 2px;
  background-color: var(--art-well);
}
.tone::before {    /* screentone where a picture has not arrived yet */
  content: ""; position: absolute; inset: 0;
  background-image: radial-gradient(circle, rgba(22, 22, 22, .2) 1.15px, transparent 1.55px);
  background-size: 9px 9px;
  -webkit-mask-image: linear-gradient(160deg, #000 10%, transparent 75%); mask-image: linear-gradient(160deg, #000 10%, transparent 75%);
}
.stage .bg-img, .stage .scene-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; animation: fade .3s ease-out; }
/* the background blurs behind the sprites; it overhangs the stage by twice the blur so its edges do not fade */
.stage .bg-img {
  --o: calc(var(--bg-blur, 5px) * -2); inset: var(--o); width: calc(100% - 2 * var(--o)); height: calc(100% - 2 * var(--o));
  filter: blur(var(--bg-blur, 5px));
}
.sprites { position: absolute; inset: 0; pointer-events: none; }
.sprite {
  position: absolute; bottom: 0; height: 93%; max-width: 46%; object-fit: contain; object-position: bottom;
  transform: translateX(-50%); animation: fade .25s ease-out;
  filter: drop-shadow(0 0 1.5px rgba(22, 22, 22, .55)); transition: filter .18s ease-out;
}
.sprite.dim { filter: brightness(.62) saturate(.72) drop-shadow(0 0 1.5px rgba(22, 22, 22, .4)); }
.sprite-stub {
  position: absolute; bottom: 0; height: 90%; width: 30%; max-width: 300px; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end; animation: fade .25s ease-out;
}
.sprite-stub svg { width: 100%; height: 100%; overflow: visible; animation: stub-pulse 1.6s ease-in-out infinite; }
.sprite-stub svg * {
  fill: rgba(255, 255, 255, .22); stroke: var(--ink); stroke-width: 2.2; stroke-dasharray: 7 6;
  vector-effect: non-scaling-stroke;
}
.stub-note {
  position: absolute; top: 48%; display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  background: var(--yellow); border: var(--line) solid var(--ink); border-radius: 2px; padding: 3px 9px;
  font-weight: 500; font-size: .85em; box-shadow: var(--float-sm);
}
@keyframes stub-pulse { 50% { opacity: .55; } }
/* a stand-in sprite (the same look drawn earlier): a small quiet spinner says the exact picture is on its way. It sits
   above the character's head: the reader's text box covers the bottom of the stage, so a mark at the bottom was never seen */
.standin-mark {
  position: absolute; top: 6%; transform: translateX(-50%); opacity: .6; display: inline-flex;
}
.standin-mark .spinner { width: 12px; height: 12px; border-width: 2px; }
.art-note {
  position: absolute; left: 14px; top: 14px; display: inline-flex; align-items: center; gap: 9px;
  background: var(--yellow); border: var(--line) solid var(--ink); border-radius: 2px; padding: 5px 11px;
  font-weight: 500; font-size: .92em; box-shadow: var(--float-sm); z-index: 2;
}

/* The text column: one fixed place at the bottom, breaking the panel's lower border. */
.textcol {
  position: absolute; left: 50%; bottom: -7px; transform: translateX(-50%); z-index: 5;
  width: min(880px, calc(100% - 56px)); display: flex; flex-direction: column; align-items: center;
}
.caption-box, .balloon { position: relative; cursor: pointer; box-shadow: var(--float); }
.caption-box {
  width: 100%; background: var(--yellow); border: var(--panel-line) solid var(--ink); border-radius: 2px;
  padding: 16px 30px 18px; animation: place .16s ease-out; transform-origin: 0 0;
}
.caption-box .story {
  font: 400 calc(23px * var(--scale))/1.52 var(--font-story); color: var(--ink); margin: 0;
  white-space: pre-wrap; user-select: text; -webkit-user-select: text; hanging-punctuation: first;
}
.balloon {
  width: 100%; background: var(--white); border: var(--panel-line) solid var(--ink); border-radius: 34px / 30px;
  padding: 14px 30px 18px; animation: pop .16s ease-out; transform-origin: var(--tail-x, 50%) 0;
}
.balloon.from-below { transform-origin: 50% 100%; }
.balloon .who {
  display: block; font: 700 calc(15px * var(--ui-scale))/1.2 var(--font-ui); letter-spacing: .09em; text-transform: uppercase;
  color: var(--teal-ink); margin: 0 0 4px;
}
.balloon .lines { margin: 0; user-select: text; -webkit-user-select: text; }
.balloon .say { font: 400 calc(26px * var(--scale))/1.4 var(--font-letter); color: var(--ink); }
.balloon .aside {
  font: italic 400 calc(22px * var(--scale))/1.45 var(--font-story); color: var(--ink-2);
  padding: 0 .15em;
}
@keyframes pop { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: none; } }
.tail { position: absolute; width: 46px; height: 36px; overflow: visible; pointer-events: none; }
.tail.up { bottom: calc(100% - 3px); left: var(--tail-x, 50%); transform: translateX(-50%); }
.tail.up.lean-left { transform: translateX(-50%) scaleX(-1); }
.tail.down { top: calc(100% - 3px); left: 50%; transform: translateX(-50%) scaleY(-1); }
.tail path { fill: var(--white); stroke: var(--ink); stroke-width: 2.5; stroke-linejoin: round; }
.box-meta {
  position: absolute; right: 12px; bottom: 2px; display: flex; align-items: center; gap: 2px;
  font-size: calc(15px * var(--ui-scale)); font-weight: 500; color: var(--ink-3); font-variant-numeric: tabular-nums;
  cursor: default;
}
.caption-box .box-meta { color: #5a574f; }
.balloon .box-meta { right: 24px; }
.box-meta .icon { color: var(--teal-ink); }
.box-meta button {
  position: relative; display: inline-flex; align-items: center; height: 26px; padding: 0 6px;
  border: 0; border-radius: var(--r); background: none; color: inherit; font: inherit; cursor: pointer;
  transition: background-color .12s;
}
.box-meta .meta-btn { padding: 0 3px; }
.box-meta button:hover:not(:disabled) { background: var(--teal-wash); }
.box-meta button:disabled { cursor: default; opacity: .35; }
/* the text sits on the bottom edge of the frame: its tips open upward */
.box-meta [data-tip]:hover::after, .box-meta [data-tip]:focus-visible::after { top: auto; bottom: calc(100% + 7px); }

/* the windows of the chapter, to read one again */
.win-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.win-line {
  display: flex; align-items: baseline; gap: 10px; width: 100%; padding: 8px 12px; text-align: left;
  border: 0; border-radius: var(--r); background: none; color: var(--ink-2); font: inherit; line-height: 1.4;
  cursor: pointer; transition: background-color .12s;
}
.win-line:hover { background: var(--teal-wash); }
.win-line.on { background: var(--teal-wash); box-shadow: inset 3px 0 0 var(--teal-ink); color: var(--ink); }
.win-line .n { flex: none; min-width: 1.6em; text-align: right; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.win-line b { flex: none; color: var(--ink); font-weight: 500; }
.win-line .t { min-width: 0; }

/* states that sit in the text column */
.note-box {
  width: min(100%, 40em); background: var(--paper); border: var(--panel-line) solid var(--ink); border-radius: var(--r);
  padding: 18px 24px; box-shadow: var(--float); animation: place .16s ease-out; cursor: default;
}
.note-box .head { display: flex; align-items: center; gap: 12px; font: 400 1.12em/1.3 var(--font-title); }
.note-box p { margin: 10px 0 0; color: var(--ink-2); }
.note-box .row { margin-top: 16px; }
.note-box.bad .head { color: var(--crimson-ink); }

.choices {
  width: 100%; max-height: 58vh; overflow: auto; background: var(--paper);
  border: var(--panel-line) solid var(--ink); border-radius: var(--r); box-shadow: var(--float);
  padding: 0 22px 12px; animation: place .16s ease-out; cursor: default; user-select: text; -webkit-user-select: text;
}
.choices-head { display: flex; align-items: center; gap: 12px; padding: 12px 0 6px; position: sticky; top: 0; background: var(--paper); z-index: 1; }
.choices-head .btn { margin-left: auto; }
.choices-head .caption-title { font-size: 1.05em; }
.choice {
  width: 100%; display: flex; align-items: flex-start; gap: 14px; text-align: left; cursor: pointer;
  background: transparent; border: var(--line) solid transparent; border-radius: var(--r); padding: 6px 12px;
  font: 400 calc(20px * var(--scale))/1.38 var(--font-story); color: var(--ink); transition: background-color .12s;
}
.choice:hover { background: var(--teal-wash); border-color: var(--ink); }
.choice .key {
  flex: none; width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; margin-top: 1px;
  border: var(--line) solid var(--ink); border-radius: 2px; background: var(--paper); font: 400 15px/1 var(--font-title);
}
.choice:hover .key { background: var(--teal); }
.own { margin: 8px 0 20px; display: flex; gap: 14px; align-items: flex-start; }
.own-field { position: relative; flex: 1; min-width: 0; }
.own textarea {
  background: var(--white); border-width: var(--panel-line); border-radius: 24px / 20px; padding: 10px 22px;
  min-height: 0; height: 52px; font: 400 calc(21px * var(--scale))/1.35 var(--font-letter); resize: none; display: block;
  transition: height .14s ease-out;
}
.own textarea:focus, .own textarea:not(:placeholder-shown) { height: 92px; }
.own-field .tail.down { left: 64px; width: 34px; height: 24px; top: calc(100% - 4px); }
.own-field:focus-within .tail path { stroke: var(--teal-ink); }
.own .btn { flex: none; min-height: 52px; }
.attach {
  display: flex; align-items: center; gap: 12px; margin: 10px 0 0; padding: 8px 8px 8px 10px;
  background: var(--paper-2); border: var(--line) solid var(--ink); border-radius: var(--r);
}
.attach img { width: 56px; height: 56px; object-fit: cover; flex: none; background: var(--white); border: 1.5px solid var(--ink); border-radius: 2px; }
.attach-text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.attach-text b { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.attach-text span { color: var(--ink-2); font-size: .92em; }
.attach.reading { background: var(--teal-wash); }
.attach.none, .attach.error { background: var(--crimson-wash); }
.own .attach-btn { flex: none; align-self: center; }
.choices.dropping { outline: 3px dashed var(--teal-ink); outline-offset: -6px; }
.textcol.lift { bottom: 30px; }

.bare-hint {
  position: absolute; right: 18px; bottom: 16px; z-index: 6; background: rgba(251, 250, 247, .88);
  border: var(--line) solid var(--ink); border-radius: 999px; padding: 4px 12px; font-size: .85em; font-weight: 500;
  animation: fade .3s ease-out; pointer-events: none;
}
.reader.bare { grid-template-rows: 0 1fr; }
.reader.bare .quickbar { visibility: hidden; }
.reader.bare .stage-wrap { margin: 0; }
.reader.bare .stage { border: 0; border-radius: 0; }

/* ---- menu ----------------------------------------------------------------------------------- */
.menu { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(320px, 1fr); gap: 26px; align-items: start; }
.cover { position: relative; aspect-ratio: 16 / 10; border: var(--frame-line) solid var(--ink); border-radius: 2px; overflow: hidden; background: var(--art-well); }
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cover .caption-title { position: absolute; left: 16px; top: 16px; font-size: 1.1em; max-width: calc(100% - 32px);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-transform: none; }
.cover-foot {
  position: absolute; left: 16px; right: 16px; bottom: 16px; display: flex; align-items: flex-end; gap: 16px;
}
.cover-foot .where {
  background: var(--paper); border: var(--panel-line) solid var(--ink); border-radius: var(--r); padding: 9px 14px;
  font: 400 calc(18px * var(--scale))/1.4 var(--font-story); max-width: 60%; box-shadow: var(--float-sm);
}
.cover-foot .btn { margin-left: auto; box-shadow: var(--float); }
.cover.empty-cover { display: flex; align-items: center; justify-content: center; }
.cover.empty-cover .pitch { position: relative; text-align: center; max-width: 30em; padding: 24px; }
.cover.empty-cover .pitch p { font: 400 calc(20px * var(--scale))/1.5 var(--font-story); margin: 0 0 18px; }
.brand { margin: 0 0 4px; font: 400 3.6em/1 var(--font-title); letter-spacing: .01em; color: var(--ink);
}
.brand .three { color: var(--teal-ink); }
.tagline { margin: 8px 0 22px; font: italic 400 1.12em/1.4 var(--font-story); color: var(--ink-2); }
.menu-nav { display: flex; flex-direction: column; gap: 4px; margin: 14px 0 22px; }
.menu-nav .btn { justify-content: flex-start; width: 100%; min-height: 44px; }
.status-line { display: flex; flex-wrap: wrap; gap: 8px; }
.status-line + .small { margin-top: 10px; }
.stories { margin-top: 26px; }
.stories .list-item .btn.small { min-height: 34px; }

/* ---- new story ------------------------------------------------------------------------------ */
.newstory { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; align-items: start; }
.confirm-bar {
  margin-top: 22px; display: flex; align-items: center; gap: 22px; background: var(--paper);
  border: var(--panel-line) solid var(--ink); border-radius: var(--r); padding: 16px 20px;
}
.confirm-bar .check { flex: 1; }

/* ---- characters ----------------------------------------------------------------------------- */
.chars { display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 22px; align-items: start; }
.char-list { max-height: calc(100vh - 128px); overflow: auto; padding: 8px; }
.char-list .pick { padding: 8px; }
.thumb {
  width: 54px; height: 70px; flex: none; object-fit: cover; object-position: top; border: var(--line) solid var(--ink);
  border-radius: 2px; background: var(--art-well);
}
.pick .title { font-weight: 500; line-height: 1.25; }
.pick .meta { font-size: .92em; color: var(--ink-3); }
.sheet { display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 26px; align-items: start; }
.portrait {
  width: 100%; aspect-ratio: 3 / 4; object-fit: cover; object-position: top; display: block;
  border: var(--frame-line) solid var(--ink); border-radius: 2px; background: var(--art-well); position: relative;
}
.portrait.placeholder { display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--ink-2); font-weight: 500; }
details.adv { margin: 4px 0 18px; border-top: 1.5px solid var(--rule); padding-top: 14px; }
details.adv summary { cursor: pointer; font-weight: 500; margin-bottom: 14px; }

/* ---- journal -------------------------------------------------------------------------------- */
.journal { max-width: 50em; margin: 0 auto; }
.jr-chapter { padding: 28px 40px 30px; }
.jr-chapter + .jr-chapter { margin-top: 20px; }
.jr-head { display: flex; align-items: flex-start; gap: 16px; }
.jr-head h2 { flex: 1; }
.jr-head .btn { flex: none; }
.jr-chapter h2 { font: 400 1.25em/1.25 var(--font-title); margin: 0 0 6px; }
.jr-chapter h2 .no { color: var(--teal-ink); margin-right: 10px; }
.jr-move { display: inline-block; margin: 6px 0 14px; padding: 6px 12px; background: var(--teal-wash);
  border: var(--line) solid var(--ink); border-radius: 18px / 16px; font: 400 calc(18px * var(--scale))/1.4 var(--font-letter); }
.jr-move b { font: 700 calc(14px * var(--ui-scale))/1 var(--font-ui); letter-spacing: .08em; text-transform: uppercase; color: var(--teal-ink); margin-right: 8px; }
.jr-text { user-select: text; -webkit-user-select: text; }
.jr-narr { font: 400 calc(19px * var(--scale))/1.6 var(--font-story); margin: 12px 0; }
.jr-line { margin: 12px 0; }
.jr-line .who { display: block; font: 700 calc(15px * var(--ui-scale))/1.3 var(--font-ui); letter-spacing: .09em; text-transform: uppercase; color: var(--teal-ink); }
.jr-line .say { font: 400 calc(21px * var(--scale))/1.45 var(--font-letter); }
.jr-line .aside { font: italic 400 calc(19px * var(--scale))/1.5 var(--font-story); color: var(--ink-2); }

/* ---- gallery -------------------------------------------------------------------------------- */
.tabs { display: inline-flex; border: var(--line) solid var(--ink); border-radius: var(--r); overflow: hidden; }
.tabs button { border: 0; background: var(--paper); padding: 7px 16px; cursor: pointer; font-weight: 500; }
.tabs button + button { border-left: var(--line) solid var(--ink); }
.tabs button:hover { background: var(--teal-wash); }
.tabs button.on { background: var(--teal); }
.frames { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.frame { margin: 0; cursor: zoom-in; background: none; border: 0; padding: 0; text-align: left; }
.frame img {
  width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block; border: var(--panel-line) solid var(--ink);
  border-radius: 2px; background: var(--art-well); transition: box-shadow .12s;
}
.frame:hover img { box-shadow: var(--float); }
.frame .cap { display: block; margin-top: 7px; font-size: .9em; color: var(--ink-2); }
.frame .cap b { font-weight: 500; color: var(--ink); }
.lightbox { position: fixed; inset: 0; background: rgba(14, 14, 14, .94); z-index: 70; display: flex; align-items: center; justify-content: center; }
.lightbox img { max-width: calc(100vw - 150px); max-height: calc(100vh - 120px); border: var(--frame-line) solid var(--ink); background: #222; }
.lightbox .icon-btn { color: var(--paper); position: absolute; }
.lightbox .icon-btn:hover { background: rgba(255, 255, 255, .12); }
.lightbox .lb-prev { left: 22px; top: 50%; transform: translateY(-50%); }
.lightbox .lb-next { right: 22px; top: 50%; transform: translateY(-50%); }
.lightbox .lb-close { right: 18px; top: 16px; }
.lightbox .lb-cap { position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%); }

/* ---- settings & logs ------------------------------------------------------------------------ */
.settings { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; align-items: start; }
.world-style { margin-bottom: 22px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.world-style .style-trigger { width: auto; min-width: 220px; }
.wf-loras { margin: 0 0 16px; }
.wf-loras > b { display: block; font-weight: 500; font-size: .92em; color: var(--ink-2); margin-bottom: 6px; }
.wf-lora { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.wf-lora-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wf-lora input { width: 84px; flex: none; }
p.small.bad, span.small.bad { color: var(--crimson-ink); }
.range-value { font-variant-numeric: tabular-nums; color: var(--teal-ink); font-weight: 700; }
.totals { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.totals .chip b { font-variant-numeric: tabular-nums; }
.table-wrap { max-height: calc(100vh - 250px); overflow: auto; }
table.log { width: 100%; border-collapse: collapse; font-size: .9em; font-variant-numeric: tabular-nums; }
table.log th, table.log td { padding: 8px 10px; text-align: left; vertical-align: top; white-space: nowrap; border-bottom: 1.5px solid var(--rule); }
table.log td.wide { white-space: normal; overflow-wrap: anywhere; width: 100%; min-width: 280px; }
/* the player's category dropdown: width:100% would be squeezed by the wide column next to it (final pass E1) */
table.log select.cat-select { width: auto; min-width: 12em; }
table.log th { position: sticky; top: 0; background: var(--paper); border-bottom: var(--line) solid var(--ink); font-weight: 500; z-index: 1; }
table.log td.n, table.log th.n { text-align: right; white-space: nowrap; }
table.log tr:hover td { background: var(--paper-2); }
table.log details summary { cursor: pointer; color: var(--ink-3); font-size: .92em; margin-top: 4px; }
table.log details code { display: block; margin-top: 4px; font: .86em/1.45 Consolas, monospace; color: var(--ink-2); }

/* ---- style picker --------------------------------------------------------------------------- */
/* Drawn as a select: the style in use and, once drawn, its picture, which keeps it as tall as the fields around it. */
.style-trigger { display: flex; align-items: center; gap: 10px; padding: 4px 36px 4px 4px; text-align: left; }
.style-trigger-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.style-mini {
  position: relative; flex: none; height: calc(1lh + 10px); aspect-ratio: 4 / 5; overflow: hidden;
  border: 1.5px solid var(--ink); border-radius: 2px; background: var(--art-well);
}
.style-mini img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: top; }
.style-intro { margin: 0 0 16px; }
.style-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(150px, calc(50% - 7px)), 1fr)); gap: 14px; }
/* every group of styles is a grid of its own, so the next one starts on a new row, under a small heading and a pencil rule;
   two classes, so `.panel h3` of the panel the picker sits in does not make the heading bold and wider spaced */
.style-group + .style-group { margin-top: 28px; }
.style-group .style-group-title { margin: 0 0 12px; padding: 0 0 6px; border-bottom: 1.5px solid var(--rule); font: 400 1.1em/1.2 var(--font-title); letter-spacing: .01em; }
.style-card {
  display: flex; flex-direction: column; gap: 8px; min-width: 0; padding: 6px 6px 8px; text-align: left; cursor: pointer;
  background: transparent; border: var(--line) solid transparent; border-radius: var(--r); transition: background-color .12s;
}
.style-card:hover { background: rgba(22, 22, 22, .05); }
.style-card.on { background: var(--teal-wash); border-color: var(--ink); }
/* a sprite is a cut-out: the whole figure on the art well, standing on the frame's lower edge as on the stage */
.style-art {
  position: relative; display: flex; align-items: center; justify-content: center; aspect-ratio: 2 / 3; overflow: hidden;
  border: var(--panel-line) solid var(--ink); border-radius: 2px; background: var(--art-well); transition: box-shadow .12s;
}
.style-card:hover .style-art { box-shadow: var(--float); }
.style-art img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; object-position: bottom;
  filter: drop-shadow(0 0 1.5px rgba(22, 22, 22, .55)); animation: fade .3s ease-out;
}
.style-art-note {
  position: relative; display: inline-flex; align-items: center; gap: 8px; padding: 0 10px; text-align: center;
  font-weight: 500; color: var(--ink-2);
}
.style-art-note.muted { font-weight: 400; color: var(--ink-3); }
.style-name { display: flex; align-items: center; gap: 6px; font-weight: 500; line-height: 1.25; }
.style-name .icon { color: var(--teal-ink); }
/* a style can be put away: a small eye over the picture's corner; the put-away ones wait, paler, under «Скрытые стили» */
.style-cell { position: relative; display: flex; flex-direction: column; min-width: 0; }
.style-cell > .style-card { flex: 1; }
.style-hide {
  position: absolute; top: 12px; right: 12px; display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; padding: 0; border: var(--line) solid var(--ink); border-radius: 999px;
  background: var(--paper); color: var(--ink); opacity: .5; cursor: pointer; transition: opacity .12s, background-color .12s;
}
.style-cell:hover .style-hide { opacity: .85; }
.style-hide:hover, .style-hide:focus-visible { opacity: 1; background: var(--crimson-wash); }
.style-away { margin-top: 28px; padding-top: 14px; border-top: 1.5px solid var(--rule); }
.style-away > p { margin: 12px 0; }
.style-cell.away .style-art { opacity: .6; transition: opacity .12s, box-shadow .12s; }
.style-cell.away:hover .style-art { opacity: 1; }
.style-back { align-self: flex-start; margin: 2px 6px 0; }

/* ---- prompts (administrator): the settings' last panel, a closed line per text ----------------------------- */
.prompt-admin { margin-top: 22px; }
.prompt-group .prompt-group-title { margin: 26px 0 6px; padding: 0 0 6px; border-bottom: 1.5px solid var(--rule); font: 400 1.1em/1.2 var(--font-title); letter-spacing: .01em; }
.prompt-section { margin: 14px 0 0; font-size: .95em; color: var(--teal-ink); }
.prompt-entry { padding: 9px 0; border-bottom: 1.5px solid var(--rule); }
.prompt-entry > summary { cursor: pointer; }
.prompt-entry .chip, .prompt-key { margin-left: 10px; }
.prompt-title { font-weight: 500; }
.prompt-key { font: .8em Consolas, "Cascadia Mono", monospace; color: var(--ink-3); }
.prompt-body { padding: 10px 0 4px; }
.prompt-vars, .prompt-notes { margin: 0 0 10px; padding-left: 20px; }
.prompt-notes.err { color: var(--crimson-ink); font-weight: 500; }
textarea.prompt-text { min-height: 9em; max-height: 65vh; field-sizing: content; font: .88em/1.5 Consolas, "Cascadia Mono", monospace; }
textarea.prompt-builtin { margin-top: 10px; background: var(--paper-2); }
.prompt-actions { margin-top: 10px; }

@media (max-width: 1180px) {
  .menu { grid-template-columns: minmax(0, 1.35fr) minmax(300px, 1fr); }
  .brand { font-size: 3em; }
  .sheet { grid-template-columns: 240px minmax(0, 1fr); }
  .chars { grid-template-columns: 250px minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .menu, .newstory, .chars, .sheet, .settings, .cols { grid-template-columns: 1fr; }
  .screen { padding: 16px 16px 36px; }
  .qb-title { display: none; }
}
@media (max-height: 760px) {   /* the 1100×680 window: five choices and the move box stay below the faces */
  .choice { padding: 4px 12px; font-size: calc(19px * var(--scale)); }
  .choice .key { width: 28px; height: 28px; }
  .choices-head { padding: 10px 0 4px; }
  .choices { max-height: 60vh; }
}
/* The «⋯» button of the reader exists for the phone only (below). */
.qb-more { display: none; }
.more-list { display: grid; gap: 8px; }
.more-list .btn { justify-content: flex-start; min-height: 48px; }

/* ---- the phone: one block, nothing above 600 px changes (the desktop window's breakpoints are 860 px and up) ---- */
@media (max-width: 600px) {
  .screen { padding: 12px 12px 28px; }
  /* viewport-fit=cover lets the page reach under a notch and the home bar: every screen keeps clear of them */
  .screen {
    padding: calc(12px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right))
      calc(28px + env(safe-area-inset-bottom)) calc(12px + env(safe-area-inset-left));
  }
  .wrap { max-width: 100%; }
  .brand { font-size: 2.4em; }
  .caption-title { font-size: 1.1em; }
  .modal-back { padding: 8px; align-items: flex-end; }
  .modal-back {
    padding: calc(8px + env(safe-area-inset-top)) calc(8px + env(safe-area-inset-right))
      calc(8px + env(safe-area-inset-bottom)) calc(8px + env(safe-area-inset-left));
  }
  /* vh first, dvh after: a browser that does not know dvh keeps the vh line (the address bar would cover the foot) */
  .modal { max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px); }
  .modal { max-height: calc(100dvh - 16px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
  .modal-body { padding: 14px 16px 18px; }
  .toasts { left: 8px; right: 8px; top: 8px; align-items: stretch; }
  .toasts { left: calc(8px + env(safe-area-inset-left)); right: calc(8px + env(safe-area-inset-right)); top: calc(8px + env(safe-area-inset-top)); }
  .toast { max-width: none; }
  .lightbox img { max-width: calc(100vw - 16px); max-height: calc(100vh - 140px); max-height: calc(100dvh - 140px); }
  .lightbox .lb-prev { left: 4px; top: auto; bottom: calc(16px + env(safe-area-inset-bottom)); transform: none; }
  .lightbox .lb-next { right: 4px; top: auto; bottom: calc(16px + env(safe-area-inset-bottom)); transform: none; }
  .lightbox .lb-cap { bottom: calc(68px + env(safe-area-inset-bottom)); max-width: calc(100vw - 16px); text-align: center; }   /* clear of the arrows */
  .table-wrap { max-height: none; }
  table.log td.wide { min-width: 160px; }

  /* the reader: the quick bar keeps «Меню», the chips and «⋯»; its icon buttons move to the «⋯» sheet */
  .reader {
    grid-template-rows: 48px 1fr;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  }
  .quickbar { padding: 0 6px; gap: 4px; overflow: hidden; }
  .quickbar .icon-btn, .quickbar .qb-sep, .quickbar .qb-seg, .quickbar .qb-past-chip { display: none; }
  /* chips shrink before «⋯» is pushed off the bar */
  .quickbar .chip { margin-right: 2px; font-size: .85em; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .qb-more { display: inline-flex; flex: none; font-size: 1.5em; min-width: 44px; }
  .stage-wrap { margin: 0 4px 4px; }
  /* --sprite-cap is set by the reader (phone.js spriteCap) so neighbours do not overlap; the old numbers are the fallback */
  .sprite { height: 78%; max-width: var(--sprite-cap, 64%); }
  .sprite-stub { height: 74%; width: var(--sprite-cap, 44%); }
  .textcol { width: calc(100% - 8px); bottom: -4px; }
  .caption-box { padding: 10px 14px 12px; }
  .caption-box .story { font-size: calc(18px * var(--scale)); line-height: 1.45; }
  .balloon { padding: 10px 14px 12px; }
  .balloon .say { font-size: calc(19px * var(--scale)); }
  .balloon .aside { font-size: calc(17px * var(--scale)); }
  .choices { max-height: 62vh; max-height: 62dvh; padding: 0 12px 10px; }
  .choice { font-size: calc(18px * var(--scale)); padding: 8px 8px; min-height: 44px; }
  .own { flex-direction: column; align-items: stretch; gap: 8px; }
  .own .btn { min-height: 48px; }
  .note-box { padding: 14px 16px; }
  .art-note { left: 8px; top: 8px; font-size: .85em; }

  /* the browser pass of 2026-11-11 (final fixes, E3 to E8) */
  .choices-head { flex-wrap: wrap; row-gap: 4px; }
  .choices-head .kbd-hint { display: none; }          /* digit keys mean nothing on a phone */
  .own textarea { font-size: calc(18px * var(--scale)); }
  .own textarea:focus, .own textarea:not(:placeholder-shown) { height: calc(6lh + 28px); }   /* six lines of what was typed */
  .confirm-bar { flex-wrap: wrap; gap: 12px; padding: 14px; }
  .confirm-bar .check { flex: 1 1 100%; }
  .confirm-bar .btn { width: 100%; }                  /* «Создать мир» stays on the screen under the line of what is missing */
  .screen-head { flex-wrap: wrap; row-gap: 8px; }
  .screen-head .head-actions { margin-left: 0; width: 100%; flex-wrap: wrap; }
  .cover { aspect-ratio: 4 / 3; }
  .cover-foot { left: 10px; right: 10px; bottom: 10px; flex-wrap: wrap; gap: 8px; align-items: stretch; }
  .cover-foot .where { flex: 1 1 100%; max-width: none; min-width: 0; }
  .cover-foot .btn { margin-left: 0; flex: 1 1 100%; padding-left: 14px; padding-right: 14px; }
  /* the quiet «Пожаловаться на кадр» keeps its colour but stands where its neighbours do, outlined like them */
  .more-list .btn.quiet { padding-left: 16px; padding-right: 16px; border-color: var(--ink); }
}
/* fingers: every control at least 44 px on a touch screen up to 860 px (a phone in landscape, a small tablet) */
@media (pointer: coarse) and (max-width: 860px) {
  .btn, .icon-btn, .qb-opt { min-height: 44px; }
  .icon-btn { width: 44px; height: 44px; }
  .btn.small { min-height: 44px; }
  .quickbar .btn, .quickbar .btn.quiet { min-height: 44px; }   /* the bar's own rule (40 px) is more specific than .btn */
  /* the window counter's buttons are 44 px high and sit over the box's last line: keep room for them under the text */
  .caption-box, .balloon { padding-bottom: 52px; }
  .box-meta button { min-height: 44px; min-width: 44px; }
  input[type="checkbox"] { width: 24px; height: 24px; }
  [data-tip]:hover::after { content: none; }      /* a tap is a hover: the tip would stick; the sheet has words */
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* model picker */
.model-picker { position: relative; display: block; }
.model-trigger {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; width: 100%; min-height: 44px; padding: 6px 36px 6px 12px;
  text-align: left; background: var(--white); color: var(--ink); border: var(--line) solid var(--ink); border-radius: var(--r);
  font: inherit; cursor: pointer; appearance: none; transition: border-color .12s, box-shadow .12s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23161616' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.model-trigger:focus, .model-trigger[aria-expanded=true] { outline: none; border-color: var(--teal-ink); box-shadow: 0 0 0 3px var(--teal-wash); }
.model-trigger-name { min-width: 0; overflow-wrap: anywhere; font-weight: 500; }
.model-trigger-chips { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.model-badge {
  display: inline-flex; align-items: center; padding: 1px 9px; border: 1.5px solid var(--ink); border-radius: 999px;
  background: var(--paper-2); font-size: .82em; font-weight: 500; line-height: 1.5; white-space: nowrap; font-variant-numeric: tabular-nums;
}
.model-badge.good { background: var(--teal-wash); }
.model-badge.warn { background: var(--yellow); }
.model-panel {
  position: absolute; z-index: 40; top: calc(100% + 6px); left: 0; right: 0; min-width: min(420px, calc(100vw - 48px)); max-height: 60vh;
  overflow-y: auto; padding: 14px 14px 16px; background: var(--paper); border: var(--panel-line) solid var(--ink);
  border-radius: var(--r); box-shadow: var(--float);
}
.model-intro { margin: 0 0 12px; font-size: .9em; line-height: 1.4; }
.model-sorts { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.model-sort {
  min-height: 32px; padding: 3px 12px; border: var(--line) solid var(--ink); border-radius: 999px; background: var(--paper);
  color: var(--ink); font: 500 .9em/1.2 var(--font-ui); cursor: pointer;
}
.model-sort:hover { background: var(--teal-wash); }
.model-sort.on { background: var(--teal); }
.model-group + .model-group { margin-top: 14px; }
.model-group-title { margin: 0 0 6px; padding: 0 0 4px; border-bottom: 1.5px solid var(--rule); font: 400 1em/1.2 var(--font-title); }
.model-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; margin: 0; text-align: left;
  background: transparent; color: var(--ink); border: var(--line) solid transparent; border-radius: var(--r);
  padding: 7px 10px; font: inherit; cursor: pointer;
}
.model-row:hover { background: rgba(22, 22, 22, .05); }
.model-row:focus-visible { outline: 3px solid var(--teal-ink); outline-offset: 1px; }
.model-row.on { background: var(--teal-wash); border-color: var(--ink); }
.model-row-main { display: flex; flex-direction: column; min-width: 0; }
.model-row-label { font-weight: 500; overflow-wrap: anywhere; line-height: 1.3; }
.model-row-note { font-size: .85em; color: var(--ink-3); line-height: 1.35; }
.model-row-badges { display: flex; gap: 6px; flex: none; flex-wrap: wrap; justify-content: flex-end; }
.model-custom { display: block; margin-top: 14px; padding-top: 12px; border-top: 1.5px solid var(--rule); }
.model-custom .field-label { display: block; font-weight: 500; font-size: .92em; margin-bottom: 6px; color: var(--ink-2); }
.model-line { display: flex; align-items: stretch; gap: 4px; }
.model-line > .model-row { flex: 1; min-width: 0; }
.model-hide {
  flex: none; width: 34px; border: 0; border-radius: var(--r); background: transparent; color: var(--ink);
  opacity: .45; cursor: pointer; font-size: 15px;
}
.model-hide:hover:not(:disabled), .model-hide:focus-visible { opacity: 1; background: var(--crimson-wash); }
.model-hide:disabled { opacity: .12; cursor: default; }
.model-removed { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--paper-2); }
.model-line.removed { align-items: center; justify-content: space-between; padding: 6px 12px; }

/* ---- the administrator's panel (screens/admin.js) ------------------------------------------- */
.code-big { font: 700 1.3em/1.2 Consolas, monospace; letter-spacing: .08em; user-select: all; }
label.field .field-error { display: block; color: var(--crimson-ink); font-weight: 500; font-size: .92em; margin-top: 6px; }
input[aria-invalid=true], select[aria-invalid=true] { border-color: var(--crimson); }
.broken-note { background: var(--crimson-wash); border: var(--line) solid var(--crimson); border-radius: var(--r);
  padding: 4px 16px; margin-bottom: 16px; color: var(--crimson-ink); font-weight: 500; }
.made-code { margin-top: 16px; padding-top: 12px; border-top: 1.5px solid var(--rule); }
table.log tr.dim td { color: var(--ink-3); }
