/* Web app chrome. Panel, balloon and caption styles come from player.css,
   so the editor shows panels exactly as the published player does. */

:root {
  --ui: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  /* Titles: the geometric, extra bold sans of the logo, with lower case (never all capitals). */
  --display: "Outfit", "Inter", system-ui, sans-serif;
  --radius: 10px;
  color-scheme: light;
  /* Theme tokens. --paper and --ink also come from player.css (the page and its text and borders). */
  --line: #d9d2c3;
  --muted: #6b665c;
  --card: #fffdf8;
  --surface: #fff;          /* buttons, fields, boxes */
  --surface-2: #f1ece1;     /* hover, soft boxes */
  --field-border: #b9b2a3;
  --soft-border: #e1dacb;
  --accent: #d63b2f;
  --accent-ink: #fff;
  --ok: #2f7d4f;
  --ok-bg: #e6f2ea;
  --warn: #b26b00;
  --warn-bg: #fff3cd;
  --warn-border: #e5c76b;
  --danger: #a32a20;
  --danger-bg: #fde8e6;
  --on-ink: #fff;           /* text on an --ink background */
  --thumb-bg: #e8e2d5;
  --brand-2: #6419f9;       /* the purple "2" of the logo */
  --current-bg: rgba(100, 25, 249, 0.1);
  --current-fg: #4b12c0;
  --shadow: rgba(0, 0, 0, 0.12);
  --frame: #141414;         /* the comic-like borders of cards, buttons, bars */
}

/* Dark theme: chosen in the top bar, or the device's when "auto" (app.js sets data-theme). */
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #16141c;
  --ink: #ebe7f2;
  --line: #3b3746;
  --muted: #aaa4b6;
  --card: #201d28;
  --surface: #2a2633;
  --surface-2: #353040;
  --field-border: #5a5468;
  --soft-border: #3b3746;
  --accent: #e5533f;
  --ok: #5cc28a;
  --ok-bg: #1d3328;
  --warn: #e6a640;
  --warn-bg: #3a3020;
  --warn-border: #7a6230;
  --danger: #ff7b6b;
  --danger-bg: #3d2226;
  --on-ink: #16141c;
  --thumb-bg: #2a2633;
  --brand-2: #9a6bff;
  --current-bg: rgba(154, 107, 255, 0.18);
  --current-fg: #cdb6ff;
  --shadow: rgba(0, 0, 0, 0.45);
  --frame: #8a84a0;
}
/* The comic itself stays on paper, as the published story: white pages, black ink, the story's colours. */
:root[data-theme="dark"] .story .panel, :root[data-theme="dark"] .samples {
  --paper: #f5f0e6;
  --ink: #141414;
  --frame: #141414;
  color: #141414;
}

*, *::before, *::after { box-sizing: border-box; } /* player.css has it too; the administration page has no player.css */

body.app, body.admin-app {
  padding: 0 0 64px;
  font-family: var(--ui);
  font-size: 15px;
  line-height: 1.45;
}

a { color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.15; }
h1 { font-family: var(--display); font-weight: 800; letter-spacing: 0; font-size: clamp(1.9rem, 4vw, 2.6rem); }
h2 { font-size: 1.15rem; }
h3 { font-size: 0.95rem; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---- top bar ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 20px;
  background: var(--paper);
  border-bottom: 2px solid var(--frame);
}
.brand { display: inline-flex; align-items: center; gap: 8px; font-family: var(--display); font-weight: 800; font-size: 1.6rem; letter-spacing: 0; text-decoration: none; }
.brand-mark { width: 48px; height: 48px; margin: -6px 0; flex: none; }
.brand-name { line-height: 1; }
.brand-admin { margin-left: 10px; font: 600 14px var(--ui); color: var(--muted); } /* the administration app */
/* The administration sign-in: the QR code of the authenticator, the key, the code, the recovery codes */
.auth .qr svg { display: block; width: 190px; height: 190px; margin: 4px auto; padding: 8px; background: #fff; border-radius: 10px; }
.auth .secret { font-size: 14px; letter-spacing: 0.06em; word-break: break-all; }
.auth .code-input { font-size: 22px; letter-spacing: 0.25em; text-align: center; }
.auth .recovery { columns: 2; list-style: none; margin: 0; padding: 0; }
.auth .recovery li { padding: 3px 0; font-size: 17px; letter-spacing: 0.05em; }
.brand-name > span { color: var(--brand-2); font-size: 1.28em; line-height: 0; vertical-align: -0.05em; } /* the purple "2" of the logo, larger than the letters */
.topbar nav { display: flex; align-items: center; gap: 14px; }
.topbar nav a:not(.button) { text-decoration: none; font-weight: 600; }
.topbar nav a.current:not(.button) { text-decoration: underline; text-underline-offset: 4px; }
/* The language and theme switches, side by side (in the menu on a phone). */
.prefs { display: inline-flex; gap: 6px; }
#lang-switch, #theme-switch { width: auto; padding: 5px 8px; border-radius: 999px; font: 600 13px var(--ui); background: transparent; cursor: pointer; }
#theme-switch { min-width: 34px; padding: 4px 8px; border: 1.5px solid var(--field-border); font-size: 15px; line-height: 1; }
.signed-out .topbar nav > :not(.prefs) { display: none; } /* only the language switch before signing in */
.user-box { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); }
.user-box #user-name { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sign-in-icon { display: inline-flex; vertical-align: -3px; margin-right: 5px; color: var(--muted); }
.sign-in-icon svg { display: block; }
/* Side menu on a phone (see the media query at the end): the same nav, slid in from the right. */
/* hidden wins over the display of the menu entries (e.g. Admin for a user, on a phone). */
[hidden] { display: none !important; }
.menu-toggle, .menu-head, #menu-backdrop { display: none; }
/* The number of stories next to "My stories". */
.nav-count { display: inline-block; min-width: 1.5em; margin-left: 6px; padding: 1px 7px; border-radius: 999px; background: var(--ink); color: var(--on-ink); font-size: 12px; font-weight: 700; line-height: 1.4; text-align: center; vertical-align: 1px; }

/* ---- sign in / sign up ---- */
/* Sign in / sign up: the logo on the left and the form on the right; one column on a phone. */
.auth { max-width: 820px; margin: 36px auto; padding: 24px 28px; display: grid; grid-template-columns: 250px 1fr; gap: 32px; align-items: center; }
.auth .auth-side { align-self: stretch; display: flex; align-items: center; justify-content: center; padding-right: 28px; border-right: 1.5px solid var(--line); }
.auth h1 { font-size: 2rem; }
.auth .auth-main.stack > * + * { margin-top: 12px; }
.auth form.stack > * + * { margin-top: 10px; }
.auth .label-text { display: block; margin-bottom: 3px; }
.auth input::placeholder { color: transparent; } /* the labels say it; on a phone the placeholders do */
.auth .auth-logo { display: block; width: 200px; max-width: 100%; height: auto; }

.auth label input { margin-top: 0; font-weight: 400; }
.auth button[type="submit"] { width: 100%; }
/* The eye inside the password box: shows or hides the password */
.password-field { position: relative; display: block; margin-top: 4px; }
.auth .password-field input { margin-top: 0; padding-right: 44px; }
.password-field .reveal {
  position: absolute; top: 50%; right: 4px; transform: translateY(-50%);
  padding: 6px; border: 0; border-radius: 6px; background: transparent; color: var(--muted);
}
.password-field .reveal:hover { background: transparent; color: var(--ink); }
.password-field .reveal:focus-visible { outline: 2px solid var(--highlight); }
.auth .terms { font-size: 14px; }
.auth .terms a, .auth .legal a { color: inherit; }
.auth .legal { margin: 4px 0 0; text-align: center; }
/* Continue with Google / Facebook, under the form. */
.auth .social { gap: 8px; }
.auth .social .or { display: flex; align-items: center; gap: 10px; }
.auth .social .or::before, .auth .social .or::after { content: ""; flex: 1; border-top: 1.5px solid var(--line); }
.social-btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 10px 14px; border: 1.5px solid var(--field-border); border-radius: 999px; background: var(--surface); color: var(--ink); font: 600 15px var(--ui); cursor: pointer; }
.social-btn:hover { background: var(--surface-2); }
.owner { color: var(--muted); font-style: italic; }

#banner { padding: 10px 20px; background: var(--warn-bg); border-bottom: 1px solid var(--warn-border); font-size: 14px; }
#view { max-width: 1320px; margin: 0 auto; padding: 24px 20px; }

/* ---- controls ---- */
.button, button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border: 2px solid var(--frame);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font: 600 14px var(--ui);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.button:hover, button:hover { background: var(--surface-2); }
.button.primary, button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.button.primary:hover, button.primary:hover { filter: brightness(0.95); background: var(--accent); }
button.danger { border-color: var(--danger); color: var(--danger); }
button.ghost, .button.ghost { border-color: transparent; background: transparent; }
button:disabled, .button[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
button.big, .button.big { padding: 12px 22px; font-size: 16px; }

label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 4px; }
input[type="text"], input[type="search"], input[type="email"], input[type="password"], select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1.5px solid var(--field-border);
  border-radius: 8px;
  background: var(--surface);
  font: 15px var(--ui);
  color: var(--ink);
}
textarea { resize: vertical; min-height: 60px; font-family: "Comic Neue", var(--ui); font-size: 16px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--highlight); outline-offset: 1px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
.check input { margin-top: 3px; width: 18px; height: 18px; flex: none; }

.card { background: var(--card); border: 2px solid var(--frame); border-radius: var(--radius); box-shadow: 4px 4px 0 var(--shadow); }
.stack > * + * { margin-top: 16px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.spacer { flex: 1; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; border: 1.5px solid currentColor; }
.badge.ready { color: var(--ok); }
.badge.processing { color: var(--warn); }
.badge.error { color: var(--danger); }
.badge.new { color: var(--muted); }
.error-box { padding: 12px 14px; border: 2px solid var(--danger); border-radius: 8px; background: var(--danger-bg); }
.notice { padding: 10px 14px; border-radius: 8px; background: var(--warn-bg); border: 1px solid var(--warn-border); }

/* ---- list ---- */
.list-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 270px), 1fr)); gap: 20px; }
/* Under the heading of the list: the search by title (the browser's own x clears it) and the kind
   switches (Comic, Storyboard: real on/off switches with a knob, both on at first). On a phone the
   search box shrinks so that the two switches stay on its row. */
.list-filters { display: flex; align-items: center; gap: 8px 16px; margin: -8px 0 20px; }
.list-filters .search-box { flex: 1 1 200px; min-width: 0; max-width: 420px; position: relative; }
.list-filters input[type="search"] { padding-right: 30px; }
.list-filters input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; display: none; }
/* The x that clears the search: on the right inside the box, only while there is text */
.list-filters .clear {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 24px; height: 24px; padding: 0;
  border: 0; border-radius: 50%; background: transparent; color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer;
}
.list-filters .clear:hover { background: var(--surface-2); color: var(--ink); }
@media (max-width: 760px) {
  .list-filters { gap: 10px; }
  .list-filters .search-box { flex: 1 1 80px; }
  .list-filters input[type="search"] { padding: 8px 26px 8px 10px; }
  .list-filters .switch { gap: 5px; font-size: 13px; }
  .list-filters .switch input { width: 36px; height: 20px; }
  .list-filters .switch input::after { width: 12px; height: 12px; }
  .list-filters .switch input:checked::after { left: 18px; }
}
.list-filters .switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; font-size: 14px; user-select: none; }
.list-filters .switch input {
  appearance: none; -webkit-appearance: none; width: 40px; height: 22px; margin: 0; border-radius: 999px; position: relative; cursor: pointer;
  background: var(--surface-2); border: 2px solid var(--frame); transition: background 0.15s;
}
.list-filters .switch input::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--frame);
  transition: left 0.15s, background 0.15s;
}
.list-filters .switch input:checked { background: var(--accent); border-color: var(--accent); }
.list-filters .switch input:checked::after { left: 20px; background: var(--accent-ink); }
.empty-filter { padding: 24px 0; }
/* The list in two groups: portrait stories (a phone held upright) get tall pictures in narrower cards */
.list-group + .list-group { margin-top: 32px; }
.list-group h2 { font-size: 19px; margin: 0 0 12px; }
.grid.portrait { grid-template-columns: repeat(auto-fill, minmax(min(100%, 180px), 1fr)); }
.grid.portrait .thumb { aspect-ratio: 9 / 16; }
/* On a phone two portrait cards side by side (half the width of a landscape card, a quarter of its
   area), with a compact body: one wide tall card per row wasted the screen. */
@media (max-width: 760px) {
  .grid.portrait { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .grid.portrait .story-card .body { padding: 8px 10px; gap: 4px; }
  .grid.portrait .story-card .title { font-size: 14px; }
  .grid.portrait .card-actions { flex-wrap: wrap; gap: 6px; }
  .grid.portrait .card-actions .button { padding: 4px 10px; font-size: 12px; }
  .grid.portrait .cover-nav { width: 30px; height: 30px; font-size: 18px; }
}
/* The card is not a link (no lift on hover): only its buttons act. */
.story-card { overflow: hidden; display: flex; flex-direction: column; }
/* The status on the picture, top left; on a card background so it reads on any picture. */
.badge.on-thumb { position: absolute; top: 8px; left: 8px; z-index: 1; background: var(--card); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25); }
.badge.on-thumb.new { color: var(--ink); }
/* The bottom of a card: Edit on the left, Share (or Shared) on the right, each an icon and a word;
   a portrait card is narrow, so there only the icons stay (the word is in the title attribute). */
.card-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 4px; }
.card-actions .button, .card-actions button { padding: 5px 14px; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.card-actions svg { width: 15px; height: 15px; flex: none; }
.card-actions .shared { border-color: var(--accent); color: var(--accent); }
.grid.portrait .card-actions svg + .label { display: none; }
.grid.portrait .card-actions .button, .grid.portrait .card-actions button { padding: 6px 10px; }
.story-card .thumb { position: relative; aspect-ratio: 16 / 9; background: var(--thumb-bg) center / cover no-repeat; border-bottom: 2px solid var(--frame); }
/* ‹ › on the picture: the cover among the panels. Shown on hover, always on touch screens. */
.cover-nav, .cover-auto {
  position: absolute; border: 2px solid var(--frame); background: var(--card); color: var(--ink);
  font-weight: 700; cursor: pointer; opacity: 0; transition: opacity 0.15s;
}
.cover-nav { top: 50%; transform: translateY(-50%); width: 36px; height: 36px; padding: 0; border-radius: 999px; font-size: 22px; line-height: 1; }
.cover-nav.prev { left: 8px; }
.cover-nav.next { right: 8px; }
.cover-auto { right: 8px; bottom: 8px; padding: 3px 10px; border-radius: 999px; font-size: 12px; }
.story-card:hover .cover-nav, .story-card:hover .cover-auto, .cover-nav:focus-visible, .cover-auto:focus-visible { opacity: 1; }
@media (hover: none) { .cover-nav, .cover-auto { opacity: 0.9; } }
.cover-nav:disabled, .cover-auto:disabled { cursor: wait; }
/* ▶ in the middle of the picture: opens the story and starts the audio. */
.play-now {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 64px; height: 64px; padding: 0 0 0 4px; border: 2px solid rgba(255, 255, 255, 0.85); border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(20, 20, 20, 0.45); color: #fff; cursor: pointer;
  backdrop-filter: blur(2px); transition: background 0.15s, transform 0.15s;
}
.play-now:hover, .play-now:focus-visible { background: rgba(214, 59, 47, 0.85); transform: translate(-50%, -50%) scale(1.06); }
.story-card .body { padding: 12px 14px; display: grid; gap: 6px; }
.story-card .title { font-weight: 700; font-size: 16px; }
.empty { text-align: center; padding: 60px 20px; }
/* The About panel: over everything, the page behind it dimmed */
.about-overlay { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, 0.55); }
.about { width: min(100%, 560px); max-height: calc(100vh - 32px); overflow: auto; padding: 22px 24px;
  overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
/* A finger on the panel scrolls the panel, never the page under it: the body is pinned (its top is
   set by the script to where it was scrolled), which holds on iOS too, where overflow hidden alone does not. */
body.modal-open { position: fixed; width: 100%; overflow: hidden; }
.app-version { font-size: 12px; color: var(--muted); padding: 1px 7px; border: 1.5px solid var(--line); border-radius: 999px; }
.about-logo { width: min(100%, 260px); display: block; margin: 0 auto 4px; }
.about h2 { margin: 0; text-align: center; }
.about h3 { font-size: 1rem; margin: 10px 0 0; }
.about p { margin: 0; }
.about-version { text-align: center; }
@media (max-width: 760px) { .about { padding: 16px; } .about-logo { width: 150px; } }
.empty p { max-width: 460px; margin: 10px auto 22px; }

/* ---- new story ---- */
.dropzone {
  display: grid;
  place-items: center;
  gap: 10px;
  min-height: 260px;
  padding: 30px;
  border: 3px dashed var(--field-border);
  border-radius: 16px;
  background: var(--card);
  text-align: center;
  cursor: pointer;
}
.dropzone.over { border-color: var(--accent); background: var(--danger-bg); }
.dropzone .icon { font-size: 44px; line-height: 1; }
/* The clips of a story (setup page): numbered, with their poster; a portrait story has tall posters */
.clips { padding: 14px; margin-top: 12px; }
.clip-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.clip { display: flex; align-items: center; gap: 10px; }
.clip .num { font-weight: 700; min-width: 1.4em; text-align: right; }
.clip img, .clip .no-poster { flex: none; width: 72px; aspect-ratio: 16 / 9; object-fit: cover; border: 2px solid var(--frame); background: var(--thumb-bg); display: block; }
#view[data-orientation="portrait"] .clip img, #view[data-orientation="portrait"] .clip .no-poster { width: 40px; aspect-ratio: 9 / 16; }
.clip .clip-name { flex: 1; min-width: 0; overflow-wrap: anywhere; font-weight: 600; }
.clip-list + .row .button { cursor: pointer; }
.progress { height: 10px; border-radius: 999px; background: var(--thumb-bg); overflow: hidden; }
.progress > div { height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }

.setup { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.setup video { width: 100%; border: 2px solid var(--frame); border-radius: var(--radius); background: #000; display: block; }
.facts { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 10px; font-size: 14px; }
.facts b { font-weight: 600; }
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mode { position: relative; padding: 14px; border: 2px solid var(--field-border); border-radius: var(--radius); background: var(--surface); cursor: pointer; font-weight: 400; margin: 0; }
.mode input { position: absolute; opacity: 0; }
.mode:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }
.mode:has(input:focus-visible) { outline: 2px solid var(--highlight); }
.mode .name { font-weight: 700; display: block; margin-bottom: 4px; }
.mode .price { display: block; margin-top: 8px; font-weight: 700; }
.estimate { padding: 12px 14px; border-radius: 8px; background: var(--surface-2); font-size: 14px; }
.estimate table { width: 100%; border-collapse: collapse; }
.estimate td { padding: 2px 0; }
.estimate td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.estimate tr.total td { border-top: 1px solid var(--field-border); padding-top: 6px; font-weight: 700; }
.flows { padding: 10px 14px; border: 1.5px solid var(--field-border); border-radius: 8px; background: var(--surface); }
.flows ul { margin: 6px 0 0; padding-left: 18px; }
.flows li + li { margin-top: 3px; }

/* ---- processing ---- */
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.steps li { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 8px; background: var(--surface); border: 1.5px solid var(--soft-border); }
.steps li .dot { width: 22px; height: 22px; flex: none; border-radius: 50%; border: 2px solid var(--field-border); display: grid; place-items: center; font-size: 13px; font-weight: 700; }
.steps li.done .dot { background: var(--ok); border-color: var(--ok); color: #fff; }
.steps li.current { border-color: var(--warn); }
.steps li.current .dot { border-color: var(--warn); border-top-color: transparent; animation: spin 0.9s linear infinite; }
.steps li.failed { border-color: var(--danger); }
.steps li.failed .dot { background: var(--danger); border-color: var(--danger); color: #fff; }
.steps li .extra { margin-left: auto; color: var(--muted); font-size: 13px; }
@keyframes spin { to { transform: rotate(360deg); } }
.processing { display: grid; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); gap: 24px; align-items: start; }
.mini-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.mini-grid figure { margin: 0; position: relative; border: 2px solid var(--frame); background: var(--thumb-bg); aspect-ratio: 16 / 9; overflow: hidden; }
.mini-grid img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mini-grid figure.pending img { filter: grayscale(1) opacity(0.55); }
.mini-grid figcaption { position: absolute; left: 4px; top: 4px; padding: 1px 6px; background: rgba(255, 255, 255, 0.9); border-radius: 4px; font-size: 12px; font-weight: 700; }

/* ---- review / editor ---- */
.review-head { display: grid; gap: 12px; margin-bottom: 18px; }
.title-input { display: block; resize: none; overflow: hidden; line-height: 1.15; font-family: var(--display); font-weight: 800; font-size: clamp(1.8rem, 4vw, 2.5rem); letter-spacing: 0; border: 2px solid transparent; background: transparent; padding: 2px 6px; margin-left: -8px; width: 100%; border-radius: 8px; }
.title-input:hover { border-color: var(--line); }
.title-input:focus { border-color: var(--ink); background: var(--surface); outline: none; }
.stats { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 14px; color: var(--muted); }
.stats b { color: var(--ink); }
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 370px; gap: 22px; align-items: start; }
/* player.css centres .story with auto margins, which inside a grid cell
   shrinks it to its content: let it fill the column instead. */
.editor .story { gap: 20px; margin: 0; width: 100%; max-width: none; }
.editor .panel { cursor: pointer; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
.editor .panel.selected { outline-color: var(--accent); }
/* Texts are dragged only in the selected panel; elsewhere a touch scrolls the page. On a touch screen a
   long press grabs a text (app.js `grab`): it lifts, then follows the finger with the page scroll off. */
.editor .panel .art .balloon.dragging { cursor: grabbing; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35); z-index: 5; transform: scale(1.03); }
.editor .panel .art .balloon.hl { box-shadow: 0 0 0 3px var(--accent); }
.editor .panel .art .caption.editable { padding-right: 18px; }
.editor .panel .art .caption.dragging { cursor: grabbing; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35); z-index: 5; transform: scale(1.03); }
.caption .resize-handle {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 14px;
  height: 14px;
  cursor: ew-resize;
  touch-action: none;
  background: linear-gradient(135deg, transparent 50%, var(--ink) 50%, var(--ink) 60%, transparent 60%, transparent 72%, var(--ink) 72%, var(--ink) 82%, transparent 82%);
}
.anchor-dot {
  position: absolute;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  color: #fff;
  font: 700 11px/18px var(--ui);
  text-align: center;
  cursor: move;
  touch-action: none;
  z-index: 6;
}
.panel-tag { position: absolute; right: 6px; bottom: 6px; padding: 1px 6px; border-radius: 4px; background: rgba(20, 20, 20, 0.75); color: #fff; font: 600 11px var(--ui); z-index: 4; }

.inspector { position: sticky; top: 76px; max-height: calc(100vh - 96px); overflow: auto; padding: 12px 14px; }
/* Compact editing panel: small gaps, one-line fields that grow with their text. */
.inspector .stack.compact > * + * { margin-top: 10px; }
.inspector h2 { font-size: 1.05rem; }
.inspector h3 { font-size: 0.9rem; }
.inspector .row.head { gap: 8px; flex-wrap: nowrap; }
.inspector .field .row { gap: 6px; margin-bottom: 4px; }
.inspector textarea { min-height: 0; padding: 6px 8px; font-size: 15px; resize: none; overflow: hidden; }
.inspector button.small { padding: 4px 10px; font-size: 13px; }
.inspector button.icon { min-width: 30px; padding: 3px 7px; }
.inspector .actions { gap: 6px; }
.inspector .font-scale { gap: 3px; }
.inspector .font-scale button { min-width: 26px; padding: 1px 6px; }
.inspector #balloons .balloon-edit + .balloon-edit { margin-top: 6px; }
/* Unsaved changes: Save or Discard, always in sight at the top of the panel. */
.edit-bar { position: sticky; top: -12px; z-index: 3; display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  margin: -12px -14px 0; padding: 8px 14px; background: var(--warn-bg); border-bottom: 2px solid var(--warn-border); }
.edit-bar.flash { animation: flash 0.3s 3; }
@keyframes flash { 50% { background: var(--accent); color: var(--accent-ink); } }
.inspector .preview { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border: 2px solid var(--frame); display: block; }
.balloon-edit { padding: 6px 8px; border: 1.5px solid var(--soft-border); border-radius: 8px; background: var(--surface); }
.balloon-edit .row { margin-bottom: 4px; gap: 5px; }
.balloon-edit select, .balloon-edit input[type="text"] { width: auto; padding: 3px 6px; font-size: 13px; }
.balloon-edit input[type="text"] { width: 64px; }
.balloon-edit .row.small { margin: 6px 0 0; }
.balloon-edit .line-delete { color: var(--danger); font-weight: 700; }
.confirm-row { padding: 10px; border-radius: 8px; background: var(--danger-bg); }

/* Panels the image AI did not draw */
.warn-box { padding: 10px 14px; border: 2px solid var(--warn); border-radius: 8px; background: var(--warn-bg); }
.warn-box a { font-weight: 700; }
.panel-tag.not-drawn { background: var(--warn); }
.mini-grid.few { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }

/* Frame picker (split, change frame) */
.picker { padding: 10px; border: 1.5px solid var(--soft-border); border-radius: 8px; background: var(--surface); }
.picker select { width: 100%; margin-top: 4px; font-size: 13px; }
.frame-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; max-height: 300px; overflow: auto; padding: 2px; }
.frame-grid .frame { display: block; padding: 0; border: 2px solid transparent; border-radius: 6px; background: var(--surface-2); overflow: hidden; cursor: pointer; text-align: left; }
.frame-grid .frame img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.frame-grid .frame span { display: block; padding: 2px 4px; font: 600 11px/1.25 var(--ui); color: var(--ink); white-space: normal; }
.frame-grid .frame.chosen { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }

/* A portrait story (a phone held upright, #view[data-orientation] set by the editor): the frame
   preview, the frame tiles and the processing grid keep its 9:16 shape, narrower rather than taller,
   so they take no more height than the 16:9 ones (little vertical room on a phone). */
#view[data-orientation="portrait"] .inspector .preview { width: 42%; aspect-ratio: 9 / 16; margin: 0 auto; }
#view[data-orientation="portrait"] .frame-grid { grid-template-columns: repeat(4, 1fr); }
#view[data-orientation="portrait"] .frame-grid .frame img { aspect-ratio: 9 / 16; }
#view[data-orientation="portrait"] .mini-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
#view[data-orientation="portrait"] .mini-grid.few { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
#view[data-orientation="portrait"] .mini-grid figure { aspect-ratio: 9 / 16; }
.saving { font-size: 12px; color: var(--muted); }

#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--on-ink);
  font-weight: 600;
  z-index: 50;
  max-width: calc(100% - 32px);
}
#toast.error { background: var(--danger); color: #fff; }

/* ---- story style: fonts and colours ---- */
.style-page { display: grid; grid-template-columns: minmax(280px, 380px) 1fr; gap: 20px; align-items: start; }
.style-form { padding: 16px 18px; position: sticky; top: 76px; }
.style-form select, .style-form input[type="range"] { width: 100%; }
.style-form label { display: grid; gap: 4px; }
.style-form .colours label { flex: 1; }
.style-form input[type="color"] { width: 100%; height: 36px; padding: 2px; border: 1.5px solid var(--field-border); border-radius: 8px; background: var(--surface); }
.kinds { display: flex; flex-wrap: wrap; gap: 6px; }
.kinds button { padding: 5px 11px; font-size: 13px; }
.kinds button[aria-selected="true"] { background: var(--ink); color: var(--on-ink); }
.samples { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; padding: 18px; background: #e8e1d3; container-type: inline-size; }
.samples .sample { position: relative; visibility: visible; max-width: none; }
.samples .balloon.sample::before, .samples .balloon.sample::after { display: none; }
.samples .caption.sample { max-width: none; border: 2px solid var(--frame); }
.samples .offscreen.sample { border: 2px solid var(--frame); }
.preview .page { grid-template-columns: 1fr 1fr; }
.font-scale { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-variant-numeric: tabular-nums; }
.font-scale button { min-width: 30px; padding: 2px 8px; font-weight: 700; }

/* ---- credit ---- */
.table { width: 100%; border-collapse: collapse; font-size: 14px; background: var(--card); }
.table th, .table td { padding: 7px 10px; border-bottom: 1px solid var(--soft-border); text-align: left; vertical-align: top; }
.table th { font-size: 12px; font-weight: 700; letter-spacing: 0.01em; color: var(--muted); }
.table td { font-variant-numeric: tabular-nums; }
.pack-card, .plan-card, .free-card { padding: 16px 18px; }
.plan-card { display: flex; flex-direction: column; gap: 6px; }
.plan-card button { margin-top: auto; }
.plan-card .price, .checkout .price { font: 800 2rem var(--display); letter-spacing: 0; margin: 0; }
.big-number { margin: 4px 0; font: 700 2rem var(--ui); }
.features { margin: 4px 0 8px; padding-left: 18px; font-size: 14px; }
.features li { margin: 2px 0; }
.checkout { max-width: 520px; margin: 24px auto; padding: 22px 24px; }
.credit-ok { padding: 10px 14px; border-radius: 8px; background: var(--ok-bg); border: 1.5px solid var(--ok); margin-bottom: 8px; }
.estimate .warn-box { margin-bottom: 8px; }

/* ---- administration ---- */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; border-bottom: 2px solid var(--frame); }
.tabs a { padding: 7px 14px; border: 2px solid transparent; border-bottom: 0; border-radius: 8px 8px 0 0; text-decoration: none; font-weight: 600; }
.tabs a.current { border-color: var(--ink); background: var(--card); margin-bottom: -2px; }
.admin h2 { margin: 18px 0 8px; }
.filters { margin: 4px 0 8px; }
.filters select { width: auto; margin-left: 6px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 170px), 1fr)); gap: 12px; }
.tile { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border: 2px solid var(--frame); border-radius: var(--radius); background: var(--card); }
.tile .label { font-size: 12px; font-weight: 600; letter-spacing: 0.01em; color: var(--muted); }
.tile .value { font: 700 1.5rem var(--ui); font-variant-numeric: tabular-nums; }
.tile .note { font-size: 12px; color: var(--muted); }
.charts, .two-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 16px; }
.chart { margin: 0; padding: 12px 14px; }
.chart figcaption { font-weight: 700; font-size: 14px; margin-bottom: 6px; }
.plot { width: 100%; height: 170px; overflow: visible; }
.plot .axis { stroke: var(--field-border); stroke-width: 1; }
.plot .grid { stroke: var(--soft-border); stroke-width: 1; }
.plot .tick { font: 11px var(--ui); fill: var(--muted); }
.plot .s1 { fill: #2a78d6; }
.plot .l1, .plot .l2 { stroke-width: 2; vector-effect: non-scaling-stroke; }
.plot .l1 { stroke: #2a78d6; }
.plot .l2 { stroke: #eb6834; }
.legend { display: flex; gap: 14px; margin-top: 6px; color: var(--ink); }
.legend i { display: inline-block; width: 14px; height: 3px; margin-right: 6px; vertical-align: middle; border-radius: 2px; }
.legend .k1 { background: #2a78d6; }
.legend .k2 { background: #eb6834; }
.users tr.suspended td { opacity: 0.6; }
.users .actions { white-space: nowrap; }
.users .actions button { margin: 0 2px 4px 0; }
.gift { max-width: 460px; padding: 16px 18px; margin-top: 16px; }
.scroll { overflow-x: auto; }
.plans-edit input[type="text"] { width: 120px; padding: 4px 6px; font-size: 13px; }
.plans-edit input[type="number"] { width: 80px; padding: 4px 6px; border: 1.5px solid var(--field-border); border-radius: 6px; background: var(--surface); color: var(--ink); font: 13px var(--ui); }
.settings-form { max-width: 520px; padding: 18px; }
.settings-form label { display: grid; gap: 4px; }
.settings-form label.check { display: flex; align-items: center; gap: 10px; } /* a checkbox and its text side by side, as elsewhere */
.settings-form label.check input { width: 18px; height: 18px; margin: 0; flex: none; }
.settings-form input[type="number"] { width: 140px; padding: 6px 8px; border: 1.5px solid var(--field-border); border-radius: 8px; background: var(--surface); color: var(--ink); font: 15px var(--ui); }
/* My account */
.account-page .settings-form { max-width: 620px; }
.account-page .settings-form input, .account-page .settings-form select { width: 100%; }
.account-page .settings-form label .row { gap: 8px; }
.methods { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.method { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--surface); }
.method > svg { flex: none; width: 22px; height: 22px; }
.mail-body { padding: 14px; white-space: pre-wrap; font: 13px/1.5 var(--ui); }

@media (max-width: 980px) {
  .editor, .style-page { grid-template-columns: 1fr; }
  .style-form { position: static; }
  .inspector { position: static; max-height: none; }
  /* Under the selected panel, across the page; no frame preview: the panel is right above it. */
  .inspector.inline { grid-column: 1 / -1; margin: 0; box-shadow: 0 6px 18px var(--shadow); }
  .inspector.inline .preview { display: none; }
  .inspector.inline { overflow: visible; } /* the page scrolls, not the panel: the save bar sticks under the top bar */
}
@media (max-width: 760px) {
  .setup, .processing { grid-template-columns: 1fr; }
  .modes { grid-template-columns: 1fr; }
  .topbar { padding: 8px 16px; flex-wrap: wrap; }
  .topbar nav { gap: 10px; }
  .menu-toggle { padding: 6px; border-radius: 8px; line-height: 0; }
  /* ☰ on the left of the top bar; the menu slides in from the left, with the logo at the top. */
  .app:not(.signed-out) .topbar { justify-content: flex-start; gap: 6px; }
  .app:not(.signed-out) .menu-toggle { display: inline-flex; order: -1; margin-left: -6px; }
  .app:not(.signed-out) .topbar nav {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 2;
    width: min(300px, 84vw); flex-direction: column; align-items: stretch; gap: 2px;
    padding: 12px 14px 20px; overflow-y: auto;
    background: var(--card); border-right: 2px solid var(--frame); box-shadow: 8px 0 24px var(--shadow);
    transform: translateX(-105%); visibility: hidden; transition: transform 0.2s ease, visibility 0.2s;
  }
  /* At the top of the menu: the arrow that closes it (towards the left, where it goes), then the logo. */
  .app:not(.signed-out) .menu-head {
    display: flex; flex-direction: column; align-items: flex-start; gap: 6px; order: -2;
    margin: -4px -14px 10px; padding: 0 14px 12px; border-bottom: 2px solid var(--frame);
  }
  .topbar nav .menu-head a.brand { display: inline-flex; align-items: center; gap: 8px; padding: 0; font-size: 1.45rem; line-height: 1; }
  .menu-head .brand-mark { width: 42px; height: 42px; margin: 0; }
  .app.menu-open:not(.signed-out) .topbar nav { transform: none; visibility: visible; }
  .menu-open:not(.signed-out) { overflow: hidden; } /* the page does not scroll under the menu */
  .menu-open:not(.signed-out) #menu-backdrop { display: block; position: fixed; inset: 0; z-index: 1; background: rgba(0, 0, 0, 0.35); }
  .app:not(.signed-out) .menu-close { display: inline-flex; margin-left: -6px; padding: 6px; line-height: 0; border-radius: 8px; }
  .app:not(.signed-out) #lang-switch, #theme-switch { align-self: flex-start; order: -1; margin: 0 0 10px; }
  .topbar nav a:not(.button) { display: block; padding: 11px 10px; border-radius: 8px; font-size: 17px; }
  .topbar nav a.current:not(.button) { text-decoration: none; background: var(--current-bg); color: var(--current-fg); }
  .topbar nav a.button { margin-top: 10px; text-align: center; }
  .user-box { margin-top: auto; padding-top: 14px; border-top: 1.5px solid var(--line); flex-direction: column; align-items: stretch; gap: 8px; }
  .user-box #user-name { max-width: none; font-size: 15px; }
  .user-box #logout { border-color: var(--line); padding: 9px; font-size: 15px; }
  /* Sign in on a phone: one column, close to the top bar so it fits without scrolling; the field
     names inside the boxes (they go away when typing). */
  .auth { display: block; margin: -6px auto 0; padding: 14px 18px; } /* close to the top bar */
  .auth .auth-side { padding: 0 0 6px; border-right: 0; }
  .auth .auth-logo { width: 104px; }
  .auth h1 { text-align: center; font-size: 1.7rem; }
  .auth .auth-main.stack > * + * { margin-top: 10px; }
  .auth form.stack > * + * { margin-top: 8px; }
  .auth .label-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .auth input::placeholder { color: var(--muted); }
  .auth .social { gap: 6px; }
  .social-btn { padding: 8px 14px; }
  #view { padding: 18px 16px; }
}

/* Admin: the models (generation profiles): fields in a grid */
.admin .grid3 { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px 14px; align-items: end; }
.admin .grid3 label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.admin .grid3 label.check { flex-direction: row; align-items: center; }
.admin .profile h4 { margin: 10px 0 0; font-size: 14px; }
.admin .profile, .admin #new-profile { padding: 14px 18px; }
.admin .profile .row h3 { margin: 0; }
