/* Felt Tip Folk. "Felt tip": outlines are drawn by src/ui/ink.js as filled ribbons behind each control.
   Interface tokens are named so they never collide with the character's colour roles (--ink, --skin, --paper, ...),
   which the studio sets as custom properties on its root element. */

/* Latin Extended (č ć š ž đ and more), fetched only when a page shows one of its letters. Declared before the Latin
   face so that the code points both ranges list come from the Latin file. Ranges as Google Fonts serves the subsets. */
@font-face {
  font-family: 'Shantell Sans';
  font-style: normal;
  font-weight: 300 800;
  font-display: swap;
  src: url(fonts/ShantellSans-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Shantell Sans';
  font-style: normal;
  font-weight: 300 800;
  font-display: swap;
  src: url(fonts/ShantellSans-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --sheet: #ffffff;
  --pen: #000000;
  --hl: #ffe14a;          /* highlighter: selected, pressed */
  --hl-soft: #fff3a8;     /* highlighter, light: hover */
  --focus: #2f5bff;       /* marker blue: keyboard focus only */
  --muted: #4a4a4a;       /* 8.9:1 on white, 7:1 on the highlighter */
  --f-hand: 'Shantell Sans', 'Chalkboard SE', 'Comic Sans MS', 'Segoe Print', system-ui, sans-serif;
  --calm: "INFM" 10, "BNCE" 0;
  --lively: "INFM" 100, "BNCE" 45;
  --icon-w: 2.4;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--sheet);
  color: var(--pen);
  font-family: var(--f-hand);
  font-variation-settings: var(--calm);
  font-size: 16px;
  line-height: 1.45;
}
a { color: inherit; text-decoration-thickness: 2px; text-underline-offset: 3px; }
a:hover { background: var(--hl-soft); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.vh { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; opacity: 0; }
h1, h2, h3 { margin: 0; font-weight: 800; font-variation-settings: var(--lively); line-height: 1.1; }

/* ---------- control shapes ---------- */
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; }
.btn { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 9px 18px 9px 14px; font-size: 16px; font-weight: 650; white-space: nowrap; }
.ic { display: inline-block; width: 22px; height: 22px; flex: none; }
.ic svg { display: block; width: 100%; height: 100%; fill: currentColor; overflow: visible; }
.arrow { width: 42px; height: 42px; padding: 0; display: inline-grid; place-items: center; flex: none; }
.arrow-s { width: 32px; height: 32px; }
.arrow-s .ic { width: 18px; height: 18px; }
.lock { width: 30px; height: 30px; padding: 0; display: inline-grid; place-items: center; flex: none; }
.lock .ic { width: 17px; height: 17px; }
.chip { display: inline-flex; align-items: center; min-height: 36px; padding: 4px 13px; font-size: 15px; font-weight: 600; white-space: nowrap; }
.swatch { width: 34px; height: 34px; padding: 0; display: inline-grid; place-items: center; flex: none; cursor: pointer; }
.toggle { display: inline-flex; align-items: center; gap: 12px; padding: 0; background: none; border: 0; font-size: 16px; text-align: left; }
.toggle-track { width: 54px; height: 30px; display: block; position: relative; flex: none; }
.toggle-knob { position: absolute; width: 22px; height: 22px; top: 4px; left: 5px; transition: left .14s ease; }
.toggle[aria-checked="true"] .toggle-knob { left: 27px; }

/* ---------- Felt tip: outlines drawn by ink.js ---------- */
:where(.studio [data-ink]) { position: relative; isolation: isolate; background: none; border: 0; --i-fill: var(--sheet); }
.studio .ink { position: absolute; left: -10px; top: -10px; width: calc(100% + 20px); height: calc(100% + 20px); z-index: -1; overflow: visible; pointer-events: none; }
.ink .i-fill { fill: var(--i-fill, var(--sheet)); transition: fill .12s ease; }
.ink .i-line { fill: var(--i-line, var(--pen)); }
.ink .i-shadow { fill: var(--pen); transition: opacity .08s ease; }
.ink .i-ring { fill: var(--pen); opacity: 0; }
.ink .i-focus { fill: var(--focus); opacity: 0; }
.studio [data-ink]:focus-visible { outline: none; }
.studio [data-ink]:focus-visible > .ink .i-focus,
.studio .toggle:focus-visible .toggle-track > .ink .i-focus,
.studio .swatch-custom:focus-within > .ink .i-focus { opacity: 1; }
.studio .toggle:focus-visible { outline: none; }
/* until ink.js has drawn (or without JavaScript): plain borders */
html:not(.ink-ready) .studio [data-ink] { border: 2px solid var(--pen); background: var(--i-fill); }
@media (forced-colors: active) {
  .studio .ink { display: none; }
  .studio [data-ink] { border: 2px solid ButtonText; }
  .studio [aria-pressed="true"], .studio [aria-checked="true"] { outline: 3px solid Highlight; }
}

.btn, .arrow, .chip, .thumb, .lock, .co-open { transition: transform .06s ease; }
.btn:hover, .arrow:hover, .chip:hover, .thumb:hover, .lock:hover { --i-fill: var(--hl-soft); }
.btn:active, .arrow:active { transform: translate(3px, 3.5px); --i-fill: var(--hl); }
.arrow-s:active, .chip:active, .thumb:active, .lock:active, .co-open:active { transform: translate(1px, 1.5px); }
.btn:active > .ink .i-shadow, .arrow:active > .ink .i-shadow { opacity: 0; }
.arrow:disabled { color: #8a8a8a; --i-line: #8a8a8a; --i-fill: var(--sheet); transform: none; }
.arrow:disabled > .ink .i-shadow { opacity: 0; }
.btn-primary { --i-fill: var(--pen); color: var(--sheet); }
.btn-primary:hover, .btn-primary:active { --i-fill: var(--hl); color: var(--pen); }
.chip[aria-pressed="true"] { --i-fill: var(--hl); font-weight: 750; }
.thumb[aria-pressed="true"] { --i-fill: var(--hl); }
.lock[aria-pressed="true"] { --i-fill: var(--hl); }
.swatch { --i-fill: var(--sw); }
.swatch:hover { transform: rotate(-6deg) scale(1.06); }
.swatch[aria-pressed="true"] > .ink .i-ring, .swatch-custom.is-on > .ink .i-ring { opacity: 1; }
.swatch-custom { color: var(--sw-ink, var(--pen)); }
.swatch-custom .ic { width: 18px; height: 18px; }
.toggle-track { --i-fill: var(--sheet); }
.toggle[aria-checked="true"] .toggle-track { --i-fill: var(--hl); }
.toggle-knob { --i-fill: var(--sheet); }
.toggle[aria-checked="true"] .toggle-knob { --i-fill: var(--pen); }
.toggle:hover .toggle-track { --i-fill: var(--hl-soft); }
.toggle[aria-checked="true"]:hover .toggle-track { --i-fill: var(--hl); }

/* ---------- the studio ---------- */
.studio { max-width: 1480px; margin: 0 auto; padding: 18px 28px 14px; }
.st-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.st-brand { display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 14px; }
.st-head-btns { display: flex; align-items: center; gap: 14px; margin-left: auto; }
.st-name { font-size: 30px; }
.st-unofficial { margin: 0; font-size: 14px; color: var(--muted); }
.st-noscript, .st-error { margin: 0 0 16px; font-weight: 700; }

.st-main { display: grid; grid-template-columns: minmax(0, 1fr) 388px; gap: 30px; }
.st-stagecol { min-width: 0; }
.st-stage {
  aspect-ratio: 4 / 3; max-height: max(460px, calc(100vh - 190px)); width: 100%; --i-fill: var(--backdrop);
  /* the notes: their width, the space from the stage edge, the room left for an arrow before the drawing, the gap
     between notes in a column, and how far an arrow keeps from the drawing (read by studio.js) */
  --note-w: 196px; --note-pad: 14px; --note-room: 42px; --note-gap: 12px; --note-clear: 8px;
}
.st-stage.is-transparent { --i-fill: var(--sheet); }
.st-stage.is-transparent .st-art { background: repeating-conic-gradient(#ececec 0 25%, #fff 0 50%) 0 0 / 22px 22px; }
/* The drawing's frame (one per base kind, see stageFrame) is fitted to the svg's box; what reaches past the frame, an arm
   spread wide, is drawn past the box, and the stage's inside edge clips it. While the notes are on the stage, the box
   is the space between their gutters, and an arm may reach into a gutter: the notes make way for it. */
.st-art { position: absolute; inset: 10px 10px 6px; overflow: hidden; }
.st-art > svg { position: absolute; top: 0; left: 0; display: block; width: 100%; height: 100%; overflow: visible; }
@media (min-width: 861px) {
  .st-art > svg { --zone-in: calc(var(--note-pad) + var(--note-w) + var(--note-room) - 10px); left: var(--zone-in); width: calc(100% - 2 * var(--zone-in)); }
}
.st-leaders { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.ld-halo { fill: none; stroke: var(--backdrop); stroke-width: 6; stroke-linejoin: round; }
.st-stage.is-transparent .ld-halo { stroke: var(--sheet); }
.ld.is-active .ld-halo { stroke: var(--hl); }
.ld-ink { fill: var(--leader, var(--pen)); }   /* white on a dark backdrop */
.ld.is-active .ld-ink { fill: var(--pen); }
.st-callouts { position: absolute; inset: 0; pointer-events: none; }
/* a note: the part's name written on the backdrop, then its controls; only the controls are drawn */
.callout { position: absolute; left: 0; top: 0; pointer-events: auto; width: var(--note-w); display: grid; gap: 4px; color: var(--leader, var(--pen)); }
.callout button { color: var(--pen); }
.co-label { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.callout[data-side="left"] .co-label { flex-direction: row-reverse; }
.co-cat { font-size: 16px; font-weight: 800; font-variation-settings: var(--lively); line-height: 1.15; padding: 1px 6px; margin: 0 -6px; border-radius: 3px 9px 4px 8px; }
.callout.is-active .co-cat { background: var(--hl); color: var(--pen); }
.co-row { display: flex; align-items: center; gap: 4px; }
.co-open { flex: 1; min-width: 0; min-height: 42px; padding: 3px 8px; text-align: center; line-height: 1.1; display: grid; place-items: center; }
.co-open:hover { --i-fill: var(--hl-soft); }
.callout.is-active .co-open { --i-fill: var(--hl); }
.co-name { font-size: 15px; font-weight: 700; line-height: 1.1; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow-wrap: anywhere; }

.st-toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 14px 18px; margin-top: 18px; }
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.st-tools { display: flex; align-items: center; gap: 12px; }
.st-tools .st-wide:first-of-type { margin-left: 8px; }

/* The side panel takes the stage column's height (contain: size keeps it from growing the row), so there is no
   empty space under the stage; the thumbnails get whatever the colour section leaves, in whole rows, and scroll. */
/* it never scrolls: the item browser takes what room is left; the padding holds the outlines of what reaches into it */
.st-side { contain: size; display: flex; flex-direction: column; gap: 22px; min-width: 0; min-height: 0; overflow: hidden; padding: 4px 12px 12px; margin: -4px -12px -12px; }
.st-tabs { display: none; }
.st-drawer { display: flex; flex-direction: column; flex: 1 1 0; min-height: 0; }
.dr-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.dr-title, .side-h { font-size: 26px; }
.dr-nav { display: flex; align-items: center; gap: 8px; }
.dr-pos { display: grid; text-align: center; min-width: 10ch; max-width: 16ch; line-height: 1.2; margin: 0; }
.dr-name { font-size: 16px; line-height: 1.1; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow-wrap: anywhere; }
.dr-count { font-size: 13px; color: var(--muted); }
.dr-lock { display: none; }
/* The grid shows whole rows only: studio.js picks the columns (each card at least --card-min wide) and makes the cards
   just tall enough for whole rows to fill the room, and the scroll snaps from row to row. It has no scrollbar: the
   pager under it (drawn buttons and "Rows 1–3 of 8") shows what is in view; wheel, touch and keyboard scroll it too.
   While it scrolls, an edge with more cards beyond it fades out instead of slicing them. */
.dr-grid {
  display: grid; grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr)); align-content: start; gap: 14px;
  flex: 1 1 0; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: 9px 12px 9px 10px; margin: -7px -12px 0 -10px; scrollbar-width: none;
  scroll-snap-type: y mandatory; scroll-padding-block: 9px;   /* less than the gap: the next row's outline stays out of view */
  --card-min: 112px; --min-rows: 3; --fade-a: 0px; --fade-b: 0px;
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 var(--fade-a), #000 calc(100% - var(--fade-b)), transparent);
  mask-image: linear-gradient(to bottom, transparent, #000 var(--fade-a), #000 calc(100% - var(--fade-b)), transparent);
}
.dr-grid::-webkit-scrollbar { display: none; }
.dr-grid.more-before { --fade-a: 8px; }
.dr-grid.more-after { --fade-b: 8px; }
.dr-grid.is-scrolling.more-before { --fade-a: 30px; }
.dr-grid.is-scrolling.more-after { --fade-b: 30px; }
.dr-grid .thumb { scroll-snap-align: start; }
.thumb { display: grid; grid-template-columns: minmax(0, 1fr); justify-items: center; align-content: start; padding: 6px 6px 5px; min-width: 0; }
.thumb-art { display: block; width: 100%; min-width: 0; height: var(--art-h, auto); aspect-ratio: var(--thumb-aspect, 1); }
.thumb-art svg { display: block; width: 100%; height: 100%; }
/* two lines for a name; an ellipsis only for one that does not fit in two */
.thumb-name { font-size: 13px; line-height: 1.25; height: 2.5em; max-width: 100%; text-align: center; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow-wrap: break-word; }
.dr-pager { display: flex; align-items: center; justify-content: center; gap: 10px; flex: none; margin-top: 6px; }
.dr-rows { font-size: 13px; color: var(--muted); min-width: 13ch; text-align: center; }
.thumb .tick { position: absolute; top: -4px; right: -5px; width: 24px; height: 24px; display: none; }
.thumb[aria-pressed="true"] .tick { display: block; }

.st-colour { flex: none; }
.side-hrow { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sets-toggle { gap: 4px; min-height: 34px; padding: 3px 8px 3px 12px; font-size: 14px; }
.sets-toggle .ic { width: 16px; height: 16px; transition: transform .15s ease; }
.sets-toggle[aria-expanded="true"] .ic { transform: rotate(180deg); }
.side-hint { font-size: 14px; color: var(--muted); margin: 2px 0 12px; }
.solids { margin-top: 2px; }
.solids-hint { margin: 4px 0 12px; }
.slots { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.slot { gap: 7px; padding-left: 9px; }
.slot-dot { width: 18px; height: 18px; display: inline-block; flex: none; }
.swatches { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.swatch-list { display: contents; }
/* on a wide screen the colour sets fold away behind the toggle (named by it), leaving the item browser its rows */
.sets { margin-top: 18px; }
.sets .side-sub { display: none; }
.st-colour:not(.is-sets-open) .sets { display: none; }
.side-sub { font-size: 18px; margin-bottom: 10px; }
.presets { display: flex; flex-wrap: wrap; gap: 8px; }
.preset { gap: 8px; padding-left: 10px; }
.preset-dots { display: inline-flex; gap: 1px; }
.preset-dot { width: 13px; height: 13px; display: inline-block; }

.st-bar { display: none; }
.st-toast {
  position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 12px); margin: 0; z-index: 20;
  background: var(--pen); color: var(--sheet); padding: 10px 16px; font-size: 15px; max-width: min(92vw, 480px);
  opacity: 0; pointer-events: none; transition: opacity .15s ease, transform .15s ease; border-radius: 3px 10px 4px 9px;
}
.st-toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* export dialog */
.xp { border: 0; padding: 12px; background: transparent; color: inherit; overflow: visible; max-width: calc(100vw - 16px); }
.xp::backdrop { background: rgb(255 255 255 / .75); }
.xp-card { display: grid; gap: 20px; width: 470px; max-width: 100%; padding: 20px 24px 22px; }
.xp-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.xp-title { font-size: 26px; }
.xp-sizes { display: grid; gap: 8px; }
.xp-label { font-size: 15px; font-weight: 650; }
.xp-note { margin: -4px 0 0; font-size: 14px; color: var(--muted); }
.xp-actions { display: flex; flex-wrap: wrap; gap: 14px; }
.xp-status { margin: -6px 0 0; min-height: 1.45em; font-size: 14px; font-weight: 650; }
.ab .xp-card { width: 540px; }
.ab-body { display: grid; gap: 12px; max-height: calc(100vh - 170px); overflow-y: auto; padding: 2px 6px 2px 2px; font-size: 15.5px; line-height: 1.45; }
.ab-body p { margin: 0; }
.ab-h { font-size: 19px; margin: 6px 0 -4px; }
.ab-list { margin: 0; padding-left: 20px; display: grid; gap: 8px; }

/* ---------- the rows, labels, tools and swatches of the Comic panel (once the Frame screen's) ---------- */
.fr-row { display: grid; grid-template-columns: 104px minmax(0, 1fr); align-items: center; gap: 12px; }
.fr-row-top { align-items: start; }
.fr-row-top .fr-label { padding-top: 5px; }
.fr-label { font-size: 15px; font-weight: 800; font-variation-settings: var(--lively); }
.fr-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; }
.fr-ratio { display: inline-block; width: 12px; border: 2px solid currentColor; border-radius: 2px; margin-right: 8px; flex: none; }
.fr-ratio-p { height: 16px; }
.fr-ratio-s { height: 12px; }
.fr-swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.fr-swatches .swatch { width: 30px; height: 30px; }
.swatch-own { color: var(--sw-ink, var(--pen)); font-size: 18px; font-weight: 800; line-height: 1; }

/* ---------- the Comic screen (comic-screen.js) ---------- */
/* #app carries data-showing="comic" while it shows (the one screen); without it the Character screen shows, as the big
   view. On a wide screen comic-screen.js makes the section as tall as the window leaves it: the stage and the designer
   column take what the rows round them leave, and the page does not scroll. */
.studio[data-showing="comic"] :is(.st-main, .st-bar, .st-export) { display: none; }
.cm, .cm-export, .cm-said-top, .cm-bar { display: none; }
.studio[data-showing="comic"] .cm-export { display: inline-flex; }
:is(.cm-export, .cm-bar-export):disabled { --i-fill: #8a8a8a; cursor: default; transform: none; }
:is(.cm-export, .cm-bar-export):disabled > .ink .i-shadow { opacity: 0; }
.cm-said { margin: 0; font-size: 14px; font-weight: 650; line-height: 1.3; overflow-wrap: anywhere; }
.cm-said:empty { display: none; }
.studio[data-showing="comic"] .st-top { position: relative; }
.studio[data-showing="comic"] .cm-said-top:not(:empty) { display: block; position: absolute; right: 0; top: 100%; margin-top: 3px; max-width: 320px; text-align: right; font-size: 13px; }

.studio[data-showing="comic"] .cm { display: grid; grid-template-columns: minmax(0, 1fr) 410px; grid-template-rows: auto minmax(0, 1fr); gap: 14px 34px; min-height: 520px; --cm-ratio: 3 / 4; }
.cm [hidden] { display: none !important; }
.cm .btn-secondary:disabled { color: #8a8a8a; --i-line: #8a8a8a; --i-fill: var(--sheet); transform: none; }
.cm .btn-secondary:disabled > .ink .i-shadow { opacity: 0; }
.cm .arrow:disabled .ic { opacity: .45; }
.cm .chip:disabled { color: #8a8a8a; --i-line: #8a8a8a; cursor: default; }
.cm-h { font-size: 21px; }
.cm-note { margin: 0; font-size: 13.5px; line-height: 1.3; color: var(--muted); }
.cm-note:empty { display: none; }
.cm-link { justify-self: start; padding: 4px 2px; border: 0; background: none; font: inherit; font-size: 14.5px; font-weight: 650; color: var(--pen); text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; cursor: pointer; }
.cm-link:hover { text-decoration-color: var(--hl); background: var(--hl-soft); }
.cm-link:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.cm-link:disabled { color: #8a8a8a; text-decoration-color: #8a8a8a; background: none; cursor: default; }

/* the top row: the templates (open: four drawn cards; closed: one line), the note on what a template left out, and the
   Comic button with its panel of the comic-wide settings */
.cm-top { grid-column: 1 / -1; position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; min-width: 0; }
.cm-templates { display: flex; align-items: center; gap: 12px; min-width: 0; }
.cm-tpl-cards { display: flex; flex-wrap: wrap; gap: 12px; min-width: 0; }
.cm-tpl { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 9px; padding: 6px 12px 6px 7px; min-height: 0; text-align: left; font-size: 14px; font-weight: 700; line-height: 1.15; cursor: pointer; }
.cm-tpl-art { display: block; height: 52px; }
.cm-tpl-art svg { display: block; height: 100%; width: auto; }
.cm-tpl[aria-pressed="true"] { --i-fill: var(--hl); }
.cm-tpl .t-page { fill: var(--sheet); }
.cm-tpl .t-ink { fill: var(--pen); }
.cm-tpl .t-hl { fill: var(--hl); }
.cm-tpl[aria-pressed="true"] .t-hl { fill: #f2b705; }
.cm-tpl .t-b { fill: #b9b9b9; }
.cm-tpl-open { min-height: 38px; padding: 4px 14px; font-size: 15px; gap: 6px; }
.cm-tpl-open .ic { width: 18px; height: 18px; }
.cm-tpl-note { margin: 0; font-size: 14px; font-weight: 650; }
.cm-tpl-note:empty { display: none; }
.cm-comic-btn { margin-left: auto; min-height: 40px; padding: 5px 12px 5px 16px; gap: 6px; }
.cm-comic-btn .ic { width: 18px; height: 18px; }
.cm-comic-btn[aria-expanded="true"] { --i-fill: var(--hl); }
.cm-settings { position: absolute; right: 0; top: calc(100% + 8px); z-index: 30; width: 452px; max-width: calc(100vw - 28px); max-height: calc(100vh - 120px); overflow-y: auto; scrollbar-width: none; display: grid; gap: 14px; padding: 16px 18px 18px; --i-fill: var(--sheet); box-shadow: 0 0 0 12px var(--sheet); }
.cm-settings::-webkit-scrollbar { display: none; }
.cm-settings .fr-row { grid-template-columns: 96px minmax(0, 1fr); }
.cm-set-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.cm-set-foot { display: flex; justify-content: flex-end; padding-top: 12px; border-top: 2px dashed rgb(0 0 0 / .3); }
.cm-settings .btn { min-height: 40px; padding: 6px 14px; }
.cm-choice { display: grid; gap: 6px; min-width: 0; }
.cm-cast { display: grid; gap: 10px; justify-items: start; }
.cm-cast-one { display: flex; align-items: center; gap: 10px; }
.cm-cast-id { min-width: 1.2em; font-weight: 750; }
.cm-chip-art { display: block; width: 34px; height: 34px; flex: none; }
.cm-chip-art svg { display: block; width: 100%; height: 100%; }

/* the stage: the picture, the words on it as buttons, and the editor laid over the words being written */
.cm-stagecol { min-width: 0; min-height: 0; display: grid; grid-template-rows: minmax(0, 1fr) auto auto; }
.cm-stage { --i-fill: #f4f1ea; width: 100%; height: 100%; min-height: 300px; display: grid; grid-template-rows: minmax(0, 1fr) auto; justify-items: center; align-items: center; row-gap: 8px; padding: 20px 22px 12px; }
.cm-preview { position: relative; height: 100%; max-width: 100%; aspect-ratio: var(--cm-ratio); min-width: 0; min-height: 0; }
.cm-picture > svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; box-shadow: 0 0 0 1px rgb(0 0 0 / .08); }
.cm-picture.is-pickable > svg { cursor: pointer; }
.cm-picture .cm-hint { opacity: .5; }
/* the selected panel's highlighter ring, in the gutter round its border: on screen only, never exported */
.cm-ring { position: absolute; border: 5px solid var(--hl); border-radius: 7px; pointer-events: none; mix-blend-mode: multiply; }
.cm-spots { position: absolute; inset: 0; pointer-events: none; }
.cm-spot { position: absolute; pointer-events: auto; padding: 0; border: 0; border-radius: 12px; background: transparent; cursor: text; }
.cm-spot:hover { background: rgb(255 225 74 / .22); box-shadow: inset 0 0 0 2px rgb(0 0 0 / .25); }
.cm-spot:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; background: rgb(255 225 74 / .22); }
.cm-spot.is-editing { visibility: hidden; }
/* typing on the drawing: the editor is bare text laid exactly over the words (comic-screen.js gives it their face, size,
   line height and colour), with no box; the words' drawn outline turns amber, a title gets a highlighter underline */
.cm-edit { position: absolute; z-index: 5; display: block; padding: 0; border: 0; background: none; box-shadow: none; }
.cm-editor { display: block; width: 100%; min-height: 0; margin: 0; padding: 0; border: 0; background: transparent; box-shadow: none; resize: none; overflow: hidden; scrollbar-width: none; text-align: center; line-height: 1.2; color: var(--pen); caret-color: #000000; outline: none; }
.cm-editor[data-part="title"] { text-decoration: underline 5px var(--hl); text-underline-offset: 6px; text-decoration-skip-ink: none; }
.cm-picture path[data-edit] { fill: #f0a800; }
.cm-slides { display: flex; align-items: center; gap: 12px; }
.cm-slide-pos { margin: 0; min-width: 6ch; text-align: center; font-size: 14px; font-weight: 700; }

/* the panel strip: numbered cards (the face and the start of the line), Add at its end; the tools under it */
.cm-strip { display: flex; align-items: stretch; gap: 12px; margin-top: 16px; min-width: 0; }
.cm-cards { display: flex; gap: 12px; flex: 1 1 auto; min-width: 0; }
.cm-card { flex: 1 1 0; max-width: 150px; min-width: 0; height: 58px; display: grid; grid-template-columns: 42px minmax(0, 1fr); align-items: center; gap: 7px; padding: 5px 9px 5px 7px; text-align: left; font-size: 12.5px; font-weight: 600; line-height: 1.2; }
.cm-card[aria-pressed="true"] { --i-fill: var(--hl); }
.cm-card-n { position: absolute; left: -9px; top: -10px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--pen); color: var(--sheet); font-size: 12px; font-weight: 800; }
.cm-card-art { width: 42px; height: 42px; display: grid; place-items: center; font-size: 17px; font-weight: 800; }
.cm-card-art svg { width: 100%; height: 100%; display: block; }
.cm-card.is-flipped .cm-card-art svg { transform: scaleX(-1); }
.cm-card-line { min-width: 0; overflow: hidden; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.cm-card.is-quiet .cm-card-line { color: var(--muted); font-weight: 500; }
.cm-card-warn { display: none; position: absolute; right: 14px; top: -11px; padding: 1px 7px; border-radius: 9px; background: var(--pen); color: var(--hl); font-size: 11.5px; font-weight: 800; white-space: nowrap; }
.cm-card.is-long .cm-card-warn { display: block; }
.cm-add { flex: none; height: 58px; min-height: 0; padding: 6px 14px 6px 10px; }
.cm-toolbar { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; margin-top: 12px; }
.cm-tools { display: flex; align-items: center; gap: 10px; }
.cm-toolbar .btn { min-height: 42px; padding: 6px 14px; }
.cm-history { grid-column: 3; display: flex; gap: 12px; }

/* the side column: Who, the Panel row, a drawn rule, then the designer (studio.js's tabs, item browser and colour, moved
   here by main.js) and the link to the big view. On a wide screen it is as tall as the stage column (contain: size keeps
   it from growing the row) and never scrolls: the item browser takes the room the rest leaves, in whole rows. */
.cm-panel { align-self: stretch; display: flex; flex-direction: column; gap: 9px; min-width: 0; min-height: 0; contain: size; overflow: hidden; padding: 2px 12px 12px; margin: -2px -12px -12px; }
.cm-row-label { font-size: 15px; font-weight: 800; font-variation-settings: var(--lively); }
.cm-who-row { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 14px; flex: none; }
.cm-who-chips { gap: 6px; align-items: center; }
.cm-who-chips .chip { padding: 4px 8px; font-size: 14.5px; }
.cm-who { gap: 7px; }
.cm-who .cm-chip-art { width: 30px; height: 30px; }
.cm-add-who { gap: 6px; min-height: 40px; }
.cm-add-who .ic { width: 16px; height: 16px; }
.cm-said-row { display: flex; align-items: center; gap: 6px; flex: none; flex-wrap: nowrap; white-space: nowrap; }
.cm-said-row .cm-row-label { font-weight: 700; font-variation-settings: var(--calm); margin-right: 2px; }
.cm-said-words { display: flex; gap: 4px; }
.cm-said-row .chip { min-height: 32px; padding: 2px 6px; font-size: 13.5px; }
.cm-said-row .cm-count { flex: 1 1 8px; min-width: 44px; text-align: center; font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.cm-title-note { font-size: 15px; font-weight: 700; }
.cm-rule { height: 4px; flex: none; margin: 2px 0; --i-fill: transparent; }
.cm-big { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; flex: none; }
.cm-big .ic { width: 18px; height: 18px; }
/* the designer's pieces: one wrapper that adds no box, here and on the Character screen */
.st-design { display: contents; }
.st-key, .tab-mark { display: none; }
.st-mark, .tab-mark { width: 13px; height: 13px; --i-fill: var(--hl); flex: none; }
.cm-panel .st-key { display: flex; align-items: center; gap: 8px; margin: -4px 0 0; font-size: 13.5px; color: var(--muted); flex: none; }
.cm-panel .st-mark { display: block; }
.cm-panel .tab-mark { display: block; position: absolute; right: -5px; top: -7px; }
.cm-panel .st-tabs { display: flex; flex-wrap: wrap; gap: 8px 7px; padding: 0; margin: 0; overflow: visible; flex: none; }
.cm-panel .st-tabs .tab { position: relative; padding: 4px 10px; font-size: 14.5px; min-height: 36px; }
.cm-panel :is(.tab-lock, .dr-head, .side-hint, .sets-toggle, .solids, .sets) { display: none !important; }
.cm-panel .st-colour { flex: none; }
@media (min-width: 861px) {
  .cm-panel .st-drawer { flex: 1 1 0; min-height: 0; }
  .cm-panel .dr-grid { flex: 1 1 0; height: auto; }
}
/* a part a title panel cannot change: its thumbnails shown, but off */
.thumb[aria-disabled="true"] { color: #8a8a8a; --i-line: #8a8a8a; cursor: default; transform: none; }
.thumb[aria-disabled="true"]:hover { --i-fill: var(--sheet); }
.thumb[aria-disabled="true"][aria-pressed="true"] { --i-fill: var(--hl-soft); }
.thumb[aria-disabled="true"] .thumb-art { opacity: .45; }

/* the binding note on the Character screen (studio.js): a slim felt-tip line in the top bar while A or B is edited */
.st-bound { display: flex; align-items: center; gap: 12px; padding: 4px 5px 4px 14px; --i-fill: var(--hl-soft); }
.st-bound[hidden], .studio[data-showing] .st-bound { display: none; }
.st-bound-text { margin: 0; font-size: 15px; font-weight: 750; white-space: nowrap; }
.st-bound-back { min-height: 34px; padding: 3px 12px 3px 8px; font-size: 14.5px; gap: 6px; }
.st-bound-back .ic { width: 18px; height: 18px; }
.studio[data-bound]:not([data-showing]) .st-unofficial { display: none; }

/* ---------- mid width: the side panel moves under the stage so the labels keep their room ---------- */
@media (max-width: 1279px) {
  .studio { padding: 16px 24px 14px; }
  .st-main { grid-template-columns: minmax(0, 1fr); gap: 26px; }
  .st-side { contain: none; overflow: visible; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; gap: 22px 36px; }
  .st-tabs { grid-column: 1 / -1; }
  .st-drawer { flex: none; }
  .dr-grid { flex: none; height: 380px; --min-rows: 1; }
  .sets-toggle { display: none; }
  .st-colour:not(.is-sets-open) .sets { display: block; }
  .sets .side-sub { display: block; }
}

/* ---------- compact: labels become tabs, thumbnails a strip, actions a bottom bar ---------- */
@media (max-width: 860px) {
  .studio { padding: 12px 14px 0; }
  .st-top { margin-bottom: 12px; }
  .st-name { font-size: 22px; }
  .st-unofficial { font-size: 12.5px; }
  .st-top .st-export { display: none; }
  .st-about { min-height: 38px; padding: 6px 14px; }
  .st-main { gap: 16px; }
  .st-stage { aspect-ratio: 1 / 1; max-height: 64vh; min-height: 0; }
  .st-callouts, .st-leaders { display: none; }
  .st-toolbar { margin-top: 14px; gap: 10px 12px; }
  .st-tools { gap: 10px; }
  .st-tools .st-wide { display: none; }
  .st-tools .arrow { width: 38px; height: 38px; }
  .st-side { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .st-tabs { display: flex; gap: 5px; overflow-x: auto; padding: 10px 14px 10px; margin: -10px -14px 0; scrollbar-width: none; }
  .st-tabs::-webkit-scrollbar { display: none; }
  .tab { flex: none; gap: 5px; padding: 4px 9px; font-size: 14px; }
  .tab-lock { width: 15px; height: 15px; display: none; }
  .tab.is-locked .tab-lock { display: inline-block; }
  .dr-title { font-size: 21px; }
  .dr-nav { gap: 6px; }
  .dr-pos { min-width: 8ch; max-width: 12ch; }
  .dr-lock { display: inline-grid; margin-left: 4px; }
  /* the strip: cells sized by studio.js so a whole number of them fills its width, snapping cell by cell */
  .dr-grid {
    grid-auto-flow: column; grid-template-columns: none; grid-auto-columns: var(--strip-col, var(--strip-want)); grid-template-rows: auto;
    overflow-x: auto; overflow-y: hidden; height: auto; max-height: none; min-height: 0;
    margin: -10px -14px 0; padding: 12px 14px 14px; column-gap: 18px; scroll-snap-type: x mandatory; scroll-padding-inline: 14px;
    --strip-want: 96px;
    -webkit-mask-image: linear-gradient(to right, transparent, #000 var(--fade-a), #000 calc(100% - var(--fade-b)), transparent);
    mask-image: linear-gradient(to right, transparent, #000 var(--fade-a), #000 calc(100% - var(--fade-b)), transparent);
  }
  .dr-grid[data-slot="base"]:not([data-kind="bust"]) { --strip-want: 124px; }
  .st-colour .swatches { gap: 10px 6px; }
  .st-bar {
    display: flex; gap: 12px; align-items: center; position: sticky; bottom: 0; z-index: 10;
    margin: 18px -14px 0; padding: 12px 14px 14px; background: var(--sheet); border-top: 2px solid var(--pen);
  }
  .st-bar .btn-primary { margin-left: auto; }
  .st-toast { bottom: 88px; }
  /* the top bar: the name and About (the note while the big view shows on a row of its own) */
  .st-top { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px 12px; }
}
/* ---------- the one screen at phone width: it stacks: the top rows, the comic, Who, the Panel row, the tabs, the
   thumbnails as a sideways strip with its pager, Colour, the big view's link, then the panel cards and their tools, and
   Export in a bottom bar ---------- */
@media (max-width: 860px) {
  .studio[data-showing="comic"] :is(.cm-export, .cm-said-top:not(:empty)) { display: none; }
  .studio[data-showing="comic"] .cm { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; gap: 16px; min-height: 0; }
  .studio[data-showing="comic"] .st-about { min-height: 40px; }
  .cm-stagecol { display: contents; }
  .cm-top { order: 0; }
  .cm-stage { order: 1; }
  .cm-panel { order: 2; }
  .cm-strip { order: 3; }
  .cm-toolbar { order: 4; }
  .cm-bar { order: 5; }
  .cm-top { position: static; }
  .cm-templates { flex-wrap: wrap; flex: 1 1 100%; }
  .cm-tpl-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; flex: 1 1 100%; order: 3; }
  .cm-tpl-art { height: 44px; }
  .cm-comic-btn { min-height: 44px; }
  .cm-settings { position: fixed; left: 14px; right: 14px; top: 12px; width: auto; max-width: none; max-height: calc(100vh - 24px); }
  .cm-settings .fr-row { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .cm-settings .chip, .cm-settings .toggle { min-height: 40px; }
  .cm-settings .fr-swatches { gap: 6px; }
  .cm-settings .fr-swatches .swatch { width: 35px; height: 35px; }
  .cm-stage { height: auto; min-height: 0; padding: 14px; }
  .cm-preview { height: auto; width: 100%; }
  .cm-picture > svg { position: static; height: auto; }
  .cm-strip { margin-top: 0; }
  .cm-cards { flex-wrap: wrap; }
  .cm-card { flex: 1 1 120px; max-width: none; }
  .cm-toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; margin-top: -4px; }
  .cm-panel { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; contain: none; overflow: visible; margin: 0; padding: 0; }
  .cm-panel .chip, .cm-panel .cm-link { min-height: 40px; }
  .cm-who-chips, .cm-said-row { flex-wrap: wrap; }
  .cm-said-row .cm-count { flex: 0 0 auto; }
  .cm-panel .st-tabs { padding: 8px 0 0; }
  .studio[data-showing="comic"] .cm-bar {
    display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 8px 12px; position: sticky; bottom: 0; z-index: 10;
    margin: 0 -14px; padding: 12px 14px 14px; background: var(--sheet); border-top: 2px solid var(--pen);
  }
  .cm-bar .cm-said { flex: 1 1 160px; min-width: 0; }
  .st-bound { grid-row: 3; grid-column: 1 / -1; justify-self: start; flex-wrap: wrap; }
  .st-bound-text { white-space: normal; }
}
@media (max-width: 440px) {
  .st-bar .btn-text { display: none; }
  .st-bar .btn-icon { padding: 9px 12px; }
}
/* too narrow for the eight backdrops in a row: two rows of four, so none is left on its own */
@media (max-width: 389px) {
  .fr-swatches { display: grid; grid-template-columns: repeat(4, 40px); gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
  .swatch:hover { transform: none; }
}
