/* ============================================================
   Presenter: app.css, the ONE stylesheet for every page
   ------------------------------------------------------------
   index.html (sign-in), controller.html and display.html all load
   only this file. Everything visual is a token in section 1: fonts, weights,
   type sizes, spacing, control/icon sizes, layout sizes, layers,
   motion and every color. Rules below only read tokens; there are
   no loose px values or colors further down. Change a token and
   both pages follow.

     1. Tokens
          1a Typography   families, weights, sizes, leading, tracking
          1b Spacing      the spacing scale
          1c Controls     heights, paddings, radii, borders, focus, opacity
          1d Icons
          1e Layout       widths and heights of page parts, layers
          1f Motion
          1g Color        palette, on-dark text, roles (light, dark, always-dark)
          1h Scaling      the tokens that change with screen size
     2. Base
     3. Text styles      every piece of text uses one of these
     4. Components       fields, buttons, links, messages, pills…
     5. Sign-in page     Vistro's two-tone split (form + black panel)
     6. Controller page  toolbar, workspace, popovers, settings sheet
     6b. Admin page      /admin: a frosted sidebar, Team, Church & devices
     7. Display page     the screen itself: pairing, audience, stage
     8. Glass            every floating surface frosted (popovers, menus,
                         sheets, toasts, screen controls)

   Look: Vistro's layout and Outfit type, in ProPresenter's colors.
   The sign-in page follows the device: light = white, dark = dark grey.
   The controller page is ALWAYS dark (.theme-dark on its <html>), and
   the brand panel and slides are black everywhere. Every white on a dark
   surface is one of the brand panel's shades (--white-100/72/55/48
   for text, --white-12/8 for lines): pure white for primary text.
   Blue is the one action color, red is live/errors; blue/pink/
   purple/red mark song sections.

   Motion: the sign-in page animates in (Vistro's vx-enter). The
   controller's parts fade in top to bottom when they arrive (lib.js
   reveal, --reveal-* tokens); otherwise short fades only.

   CSP: no inline styles or scripts anywhere. Avoid the CSS :has
   selector (old church tablets); the JS toggles classes instead.
   ============================================================ */

/* ============================================================
   1. Tokens
   ============================================================ */
:root {
  /* ---- 1a Typography ---- */
  --font-sans: "Outfit", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  /* Slide fonts (design.mjs FONTS): the real one, then a free look-alike with the
     same letter widths (Google Fonts, loaded by controller.html and display.html),
     so a screen without it (Android TV sticks, Chromebooks) wraps lines the same.
     lib.js fontStack() uses these; Verdana, Trebuchet, Palatino, Impact have no twin;
     Tahoma has none either, so it falls back to Verdana (its wider sibling). */
  --font-arial: Arial, Arimo, "Liberation Sans", var(--font-sans);
  --font-helvetica: Helvetica, "Helvetica Neue", Arial, Arimo, "Liberation Sans", var(--font-sans);
  --font-times: "Times New Roman", Tinos, "Liberation Serif", serif;
  --font-courier: "Courier New", Cousine, "Liberation Mono", monospace;
  --font-georgia: Georgia, Gelasio, serif;
  --font-tahoma: Tahoma, Verdana, "DejaVu Sans", var(--font-sans);

  --weight-regular: 400;  /* body, subtitles, toolbar labels */
  --weight-medium: 500;   /* labels, links, list titles */
  --weight-semibold: 600; /* titles, buttons */

  --size-display: 34px; /* brand panel headline */
  --size-h1: 24px;      /* page title ("Connect to your church", "Nothing open yet") */
  --size-h2: 18px;      /* popover, sheet and slide-grid titles */
  --size-h3: 15px;      /* small headings */
  --size-button: 14px;  /* every button (the sign-in "Continue") */
  --size-input: 16px;   /* every input: stays 16, smaller makes iPad/iPhone zoom in on focus */
  --size-lead: 15px;    /* brand panel paragraph */
  --size-body: 14px;    /* body copy, subtitles, list rows */
  --size-ui: 13px;      /* links, messages, small buttons */
  --size-label: 12px;   /* field labels, toolbar labels, "Live" */
  --size-small: 11px;   /* hints, meta, pills */
  --size-tiny: 9px;     /* initials in the toolbar avatar */

  --leading-display: 1.1;
  --leading-tight: 1.2;  /* titles */
  --leading-snug: 1.4;   /* messages, textarea */
  --leading-body: 1.5;   /* paragraphs */
  --leading-loose: 1.6;  /* brand panel paragraph */
  --leading-none: 1;     /* toolbar labels */

  --tracking-display: -1px;
  --tracking-h1: -0.5px;
  --tracking-h2: -0.2px;
  --tracking-caps: 0.05em; /* uppercase section labels (LIBRARY, SERVICES, 8 ITEMS) */
  --underline-offset: 3px;

  /* ---- 1b Spacing ---- */
  --space-half: 2px;
  --space-1: 4px;
  --space-1-5: 6px;
  --space-2: 8px;
  --space-2-5: 10px;
  --space-3: 12px;
  --space-3-5: 14px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 28px;
  --space-8: 32px;
  --space-10: 40px;
  --space-14: 56px;
  --space-16: 64px;

  /* ---- 1c Controls ---- */
  --control-height: 44px;    /* inputs, buttons (Vistro's standard) */
  --control-height-sm: 32px; /* small buttons in lists and settings rows */
  --button-height: 46px;     /* the big button at the bottom of a sign-in form (Vistro's) */
  --row-height: 48px;        /* list rows in popovers */
  --segment-height: 56px;    /* Controller / Observer choice */
  --control-pad-x: 16px;
  --control-pad-x-sm: 12px;
  --input-pad-x: 14px;
  --input-pad-y: 11px;       /* textarea */
  --message-pad: var(--space-2-5) var(--space-3-5);
  --pill-pad: 3px 9px;
  --reveal-width: 72px;      /* "Show" next to a password */

  /* Corners: squared-off and modern. Circles (dots, lights, avatar, ×) stay 50%. */
  --radius-xs: 2px;      /* thumbnails, label bars, fact markers */
  --radius-mark: 5px;    /* brand mark */
  --radius-sm: 4px;      /* small pieces: icon buttons, pills, swatches */
  --radius-control: 6px; /* buttons, inputs */
  --radius-md: 8px;      /* tiles, toasts, the Controller/Observer picker */
  --radius-lg: 10px;     /* cards, popovers, sheets */
  --border-width: 1px;

  --focus-ring: 3px;         /* soft ring around a focused input */
  --focus-width: 2px;        /* keyboard focus outline */
  --focus-offset: 2px;

  --opacity-disabled: 0.45;
  --opacity-busy: 0.7;

  /* ---- 1d Icons ---- */
  --icon-xs: 10px;    /* fact markers, small status lights */
  --icon-dot: 9px;    /* status dots */
  --icon-sm: 14px;    /* toolbar status lights */
  --icon-md: 20px;    /* toolbar icons */
  --icon-lg: 28px;    /* empty states */
  --icon-stroke: 1.75;
  --grip-dot: 3.2;    /* the ⋮⋮ drag grip: its dots (round line caps) */
  --drag-lift-scale: 1.03;     /* a playlist row lifted to move: a touch bigger… */
  --drag-source-opacity: 0.3;  /* …the slot it left: its name faded */
  --drop-line-width: 2px;      /* where it lands: a blue line… */
  --drop-dot: 9px;             /* …with a ring at its start */
  --icon-stroke-thin: 1.5;
  --light-ring: 2px;
  --light-slot: 18px;
  --avatar-md: 46px;
  --avatar-sm: 34px;   /* the admin page's sidebar */
  --admin-nav-width: 248px; /* the admin page's sidebar… */
  --admin-width: 840px;     /* …and its page beside it */
  --brand-mark: 26px;
  --brand-mark-icon: 15px;

  /* ---- 1e Layout ---- */
  --form-side-width: 48%;     /* sign-in: form side of the split */
  --form-width: 400px;        /* sign-in form column */
  --panel-text-width: 480px;  /* brand panel column */
  --fact-label-width: 120px;
  --toolbar-btn-min: 56px;    /* scaled in 1h */
  --toolbar-btn-height: 50px;
  --toolbar-labels: flex;     /* "none" = icons only */
  --toolbar-sep-height: 28px;
  --sidebar-width: 200px;     /* controller left panel (icons, not type words, so it stays narrow) */
  --sidebar-row-height: 36px; /* library / service / item rows */
  --row-icon: 22px;           /* colored icon tile in a sidebar row */
  --outline-height: 42%;      /* the outline's share of the left panel, at first (drag the handle) */
  --outline-min: 96px;        /* never shorter: a few rows of libraries / playlists */
  --detail-min: 160px;        /* the items list keeps at least this */
  --preview-width: 380px;     /* controller live column (the grid is the main focus) */
  --preview-max-phone: 480px;
  --screen-pad: 6%;           /* inside a slide preview */
  --empty-min-height: 240px;
  --popover-width: 360px;
  --popover-tutorial-width: 420px; /* the tutorial's checklist (church menu → Tutorial) */
  --tour-card-width: 300px;        /* a tutorial step's card, beside what it points at… */
  --tour-ring-width: 2px;          /* …the ring around that… */
  --tour-dim: rgba(8, 8, 10, 0.62); /* …and the dark over everything else (both themes) */
  --popover-wide-width: 420px;  /* Themes */
  --tool-btn: 28px;             /* move / remove buttons on a service item while editing */
  --lyrics-rows-height: 220px;
  --popover-menu-min: 260px;    /* the "+" menu */
  --menu-row-height: 34px;      /* a row in the "+" menu */
  --nested-indent: 22px;        /* a playlist inside an open folder */
  --add-results-height: 240px;  /* presentation list in Add to playlist */
  --popover-add-width: 540px;   /* Add to playlist: two columns… */
  --add-side-width: 170px;      /* …the quick-add column on the right */
  --popover-max-height: min(72vh, 560px);
  --popover-screens-width: 940px; /* Screens: Audience · Stage · This device, side by side… */
  --screens-col-min: 280px;       /* …as many columns as fit (3, 2 on iPad portrait, 1 on phones) */
  --mini-seg-height: 28px;        /* Off | Audience | Stage switch in a screen row */
  --screen-name-min: 120px;       /* below this the switch wraps under the name */
  --sheet-width: 560px;
  --sheet-new-width: 1040px;    /* New presentation: name, theme, size… beside the words */
  --sheet-search-width: 1080px; /* Search: playlists · presentations (· other churches' lyrics) side by side… */
  --search-list-max: 58vh;      /* …each column scrolls past this… */
  --search-results-min: 260px;  /* …a song tapped online: the results, slid left… */
  --search-slide-min: 150px;    /* …and its slides beside them, at least this wide */
  --search-web-max: 640px;      /* …nothing shared matches: the two lyrics-site steps alone, big and centered… */
  --web-step-num: 28px;         /* …each step's number (a circle)… */
  --site-tile-height: 64px;     /* …and a lyrics site's button there */
  --new-settings-width: 400px;  /* …its left column */
  --new-lyrics-min: 46vh;       /* …the words box, tall: a whole song fits */
  --new-found-max: 30vh;        /* …the songs churches share found for its name, before they scroll */
  --new-label-width: 64px;      /* …its labels, right-aligned in a column */
  --new-themes-max: 36vh;       /* …the theme tiles scroll past this */
  --popover-words-width: 520px; /* quick words: the words as code (the { } in the grid's header)… */
  --words-code-height: 360px;   /* …its text box (shrinks with the popover) */
  --words-code-min: 120px;
  --sheet-top: 6vh;
  --setting-main-min: 200px;
  --swatch-width: 46px;
  --theme-thumb-width: 104px;   /* a theme drawn as a little slide in the Theme menu */
  --popover-look-width: 600px;  /* the theme button's picker: themes, then layouts… */
  --look-tile-min: 120px;       /* …as tiles… */
  --look-grid-max: 34vh;        /* …each grid scrolling past this */
  --swatch-height: 30px;

  /* Slide grid (Show mode) */
  --deck-cols: 4;              /* slides per row; the grid's − / + change it (2–8) */
  --deck-gap: var(--space-3);
  --thumb-floor: 140px;        /* a slide is never narrower: small screens fit fewer per row */
  --thumb-text-min: 12px;      /* slide words in a thumbnail never get smaller: readable, not
                                  exact (the live preview and the screens stay exact) */
  --deck-bar-height: 40px;     /* the bar under the views: media; Show's grid / list, size; Bible's verse controls */
  --bar-range-width: 110px;    /* its sliders */
  --bar-value-width: 34px;     /* "0.5s" */
  --list-num-width: 28px;      /* list view: the slide number… */
  --list-name-width: 110px;    /* …the section name… */
  --list-bar: 4px;             /* …and the section color down its left edge */
  --lower-height: 240px;       /* the lower panel (media) at first… */
  --lower-min: 120px;          /* …never shorter… */
  --show-top-min: 220px;       /* …and the grid above it keeps at least this */
  --split-handle: 8px;         /* the handle between them (drag to resize) */
  --split-grip: 36px;          /* the short line in its middle */
  --slide-ring: 3px;           /* ring around the live slide */
  /* a picture slide of another shape (design.mjs mediaFit): shown whole over a
     blurred, darker copy of itself. Blur in slide px (× --u, so a thumbnail
     blurs as much as the screen, to scale); zoomed a little so its soft
     edges stay outside the slide */
  --media-backdrop-blur: 48;
  --media-backdrop-dim: 0.45;
  --media-backdrop-zoom: 1.12;
  --slide-label-height: 26px;  /* colored bar under each thumbnail */
  --deck-head-height: 46px;
  --name-field-width: 420px;  /* a name edited in place (the grid's title, an item's name) */

  /* Live screen (right column) */
  --clear-strip-width: 44px;   /* the vertical clear/layer strip */
  --clear-all-size: 26px;      /* round × on the strip's edge */
  --live-bar-height: 36px;
  --slide-ref-width: 1920;     /* theme sizes are px on a 1920-wide slide */
  --slide-meta-size: 30;       /* the metadata line, px on that 1920-wide slide */
  --meta-opacity: 0.85;        /* the metadata line sits a step behind the lyrics */

  /* Editor (Edit mode) */
  --ed-nav-width: 210px;        /* slides + objects */
  --ed-inspector-width: 300px;
  --ed-ruler: 20px;
  --ed-canvas-pad: 28px;        /* room around the slide */
  --ed-tool-height: 46px;
  --ed-handle: 10px;            /* resize handles */
  --ed-sel-line: 1.5px;
  --ed-label-width: 86px;       /* inspector row labels */
  --ed-num-width: 62px;
  --ed-color-width: 44px;
  --ed-artwork: 96px;
  --ed-tab-height: 34px;
  --ed-group-bar: 3px;          /* section color beside a slide group */
  --group-swatch: 26px;         /* a group's color well (Groups tab) */
  --text-pop-width: 288px;      /* the Text popover: small, like ProPresenter's */
  --tx-step-width: 60px;        /* a number in it, with its up / down arrows */
  --tx-step-btn: 18px;          /* …the arrows' column */
  --tx-swatch-width: 36px;      /* a color well there */
  --tx-icon: 16px;              /* its alignment icons */
  --group-bar-height: 34px;     /* a group of the open presentation (Groups tab) */
  --group-bar-line: 2px;        /* …its colored underline */
  --pick-ring: 3px;             /* a slide picked in the grid (Groups tab) */

  /* Reflow (Reflow mode) */
  --rf-text-width: 760px;       /* the words: a comfortable line, centered when there's room */
  --rf-text-pad: 24px;          /* inside the text area */
  --rf-side-width: 380px;       /* the slides beside it: two thumbnails across */
  --rf-thumb-min: 150px;
  --rf-select-width: 190px;

  /* Bible (Bible mode) */
  --bible-ref-width: 210px;     /* "1 Corintios 13:4–7" */
  --bible-search-width: 260px;
  --verse-num-width: 34px;      /* the verse number column… */
  --result-ref-width: 130px;    /* …a search result's reference column */
  --popover-books-width: 600px; /* the book picker… */
  --book-col-min: 132px;        /* …its book buttons… */
  --chapter-btn: 46px;          /* …and chapter numbers (thumb-sized) */
  --books-max-height: min(58vh, 460px);
  --tpl-min: 140px;             /* a verse template tile (two across in the right column) */

  /* Media library (the lower panel) */
  --media-folders-width: 170px;
  --media-filter-width: 200px;
  --media-tile-min: 150px;
  --media-progress-height: 4px;

  /* Quick actions (under the live preview) */
  --quick-tab-height: 38px;
  --tr-type-pad: 10px;         /* a transition tile */

  /* Display page (the screen itself) */
  --size-pair-code: 28px;       /* the 6-digit code, on the screen and the controller */
  --pair-code-height: 56px;
  --tracking-code: 0.3em;
  --stage-pad: 3vw;             /* stage screen: sizes follow the screen's width */
  --stage-gap: 2vw;
  --stage-now-size: 4.4vw;
  --stage-next-size: 2.6vw;
  --stage-clock-size: 3vw;
  --stage-meta-size: 1.6vw;
  --identify-size: 7vw;         /* Identify: the screen's name, huge */
  --identify-kind-size: 2.4vw;
  --identify-pad: 3vw;

  --z-screen-media: 0;   /* a screen's layers: the background… */
  --z-screen-dim: 1;     /* …a picture behind a verse, darkened… */
  --z-screen-text: 2;    /* …the words */
  --z-screen-flash: 3;   /* Fade White's white, over all of them */
  --z-popover: 50;
  --z-sheet: 60;
  --z-tour: 65;          /* a tutorial step: over sheets (it points into them), under toasts */
  --z-drag: 68;          /* a playlist row being moved, and where it lands: over sheets, under toasts */
  --z-toast: 70;
  --z-tip: 80;           /* a hover label (lib.js initTips): over everything */
  --tip-max: 260px;      /* …wraps past this */

  /* ---- 1f Motion ---- */
  --ease-settle: cubic-bezier(0.3, 0.7, 0.4, 1);
  --duration-fast: 0.15s;      /* the controller: short fades only */
  --duration-brand: 0.6s;      /* sign-in brand mark */
  --duration-enter: 0.8s;      /* sign-in entrance */
  --duration-enter-item: 0.7s;
  --duration-reduced: 0.2s;    /* "reduce motion" fade */
  --duration-dim: 0.4s;        /* a picture behind a verse darkening / brightening */
  /* The controller's entrances (lib.js reveal): things fade in and rise a
     little, one after another, top to bottom, on load, a new presentation
     in the grid, changed slides, a tab, Edit / Reflow / Bible. */
  --reveal-duration: 0.32s;
  --reveal-step: 0.028s;       /* between one and the next */
  --reveal-cap: 14;            /* after this many, the rest come together */
  --reveal-rise: 10px;
  --reveal-panel-step: 0.07s;  /* the page's big parts on load */

  /* ---- 1g Color: palette (same in both themes) ---- */
  --black: #050506;
  --white: #ffffff;
  --blue: #2f74e0;
  --blue-hover: #3d82ee;
  --red: #e5483b;
  --pink: #d6336c;
  --purple: #7c4ddb;
  --amber: #e8a33d;   /* a playlist's Headers: a color no group (section) uses */
  --grey-950: #111113; /* controller workspace (dark) */
  --grey-900: #18181a; /* side panels (dark) */
  --grey-850: #1c1c1f; /* toolbar (always), sign-in form side (dark) */
  --grey-800: #232326; /* popovers, sheets (dark) */
  --grey-750: #2a2a2e; /* raised controls (dark) */
  --grey-700: #333338; /* hover (dark) */

  /* Dark-theme colors (used by both dark mappings below) */
  --dark-accent-soft: rgba(47, 116, 224, 0.24);
  --pick-tint: rgba(255, 255, 255, 0.14);  /* a picked slide (on the always-dark grid) */
  --dark-accent-text: #8ab8ff;      /* blue that reads on dark grey */
  --dark-tile: rgba(47, 116, 224, 0.22);
  --dark-danger: #ff6b5e;
  --dark-danger-soft: rgba(229, 72, 59, 0.16);
  --dark-danger-border: rgba(255, 107, 94, 0.5);
  --dark-success: #34c759;
  --dark-success-soft: rgba(52, 199, 89, 0.16);
  --dark-shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.55);
  --dark-glass-bg: rgba(35, 35, 38, 0.62);       /* --grey-800, see-through */
  --dark-glass-field: rgba(0, 0, 0, 0.3);        /* a field on dark glass */
  --dark-glass-well: rgba(0, 0, 0, 0.22);        /* a sunken area on dark glass */
  --dark-glass-edge: rgba(255, 255, 255, 0.16);  /* the lit top edge */
  --dark-glass-border: rgba(255, 255, 255, 0.12);
  --dark-glass-dim: rgba(0, 0, 0, 0.38);         /* the page behind a sheet */

  /* Glass (section 8): every floating surface is frosted, like Apple's
     newer look: a see-through tint over the page, the page blurred and a
     little more saturated behind it, a light sheen from the top left, a lit
     top edge and a fine grain. Browsers that can't blur keep the solid look. */
  --glass-blur: 26px;
  --glass-saturate: 170%;
  --glass-backdrop-blur: 6px;   /* the page behind a sheet: softened, not gone */
  --glass-sheen: linear-gradient(160deg, rgba(255, 255, 255, 0.12) 0%, rgba(255, 255, 255, 0.03) 38%, rgba(255, 255, 255, 0) 70%);
  --glass-grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 0.1 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");  /* fractal noise, 10% grey: texture, not dirt */

  /* Shades of white: the sign-in brand panel's. The ONLY whites used for
     text and lines on any dark surface (dark mode, toolbar, panel, slides). */
  --white-100: #ffffff;                  /* headings, primary text: crisp, pure white */
  --white-72: rgba(255, 255, 255, 0.72); /* body text (panel paragraph, fact text) */
  --white-55: rgba(255, 255, 255, 0.55); /* labels (fact labels) */
  --white-48: rgba(255, 255, 255, 0.48); /* faint (panel footer, placeholders) */
  --white-12: rgba(255, 255, 255, 0.12); /* lines (fact dividers, input borders) */
  --white-8: rgba(255, 255, 255, 0.08);  /* hairlines (panel edge, dividers) */

  --text-on-dark: var(--white-100);
  --text-on-dark-secondary: var(--white-72);
  --text-on-dark-muted: var(--white-55);
  --text-on-dark-placeholder: var(--white-48);
  --text-on-accent: var(--white-100);
  --toolbar-text: var(--white-100);              /* controller toolbar: primary white… */
  --toolbar-weight: var(--weight-regular);       /* …at the sign-in subtitle's weight */

  /* Roles that never change with the theme */
  --accent: var(--blue);
  --accent-hover: var(--blue-hover);
  --accent-contrast: var(--text-on-accent);
  --live: var(--red);
  /* Section (group) colors. The church's own replace them on the controller
     (controller.js applyGroups, public/js/groups.mjs: same defaults). */
  --section-verse: var(--blue);
  --section-chorus: var(--pink);
  --section-bridge: var(--purple);
  --section-tag: var(--red);
  --section-prechorus: var(--pink);
  --section-intro: var(--section-other);
  --section-outro: var(--section-other);
  --section-interlude: var(--section-other);
  --section-other: #5b5b63;    /* sections without a kind, scripture, text, blank */
  --section-shade-1: 14%;      /* Verse 2, 3, 4… step a little darker */
  --section-shade-2: 26%;
  --section-shade-3: 36%;

  --bg-brand-panel: var(--black);
  --panel-text: var(--white-72);
  --panel-muted: var(--white-55);
  --panel-faint: var(--white-48);
  --panel-border: var(--white-12);
  --panel-edge: var(--white-8);

  --toolbar-bg: var(--grey-850);   /* controller toolbar */
  --deck-bg: var(--grey-950);      /* slide grid */
  --deck-head-bg: var(--grey-850);
  /* A playlist in the grid: each item's own head over its slides is a raised
     grey band; a Header (a divider in the playlist) is amber, a color of its
     own, here and in the items list */
  --deck-item-head-bg: var(--grey-850);
  --header-tone: var(--amber);
  --header-bg: rgba(232, 163, 61, 0.14);   /* --amber, faint, over the grid */
  --header-text: #f3c57d;                  /* --amber, light enough to read on that */
  --header-line: 3px;                      /* its edge on the left */
  --items-header-hover: var(--grey-700);   /* a Header row in the items list (it goes to it in the grid) */
  --layer-active: #5a2420;          /* a layer button while that layer is on screen */
  --library-icon: var(--pink);      /* sidebar: the song library */
  --service-icon: var(--blue);      /* sidebar: services (playlists) */
  --row-selected-bg: var(--accent); /* sidebar: the ONE blue row: what you're looking at */
  --row-selected-text: var(--text-on-accent);
  --row-current-bg: var(--white-8);    /* sidebar: the playlist you're in while one of its items is open… */
  --row-current-line: var(--white-55); /* …a white box, not a second blue */
  /* Left panel in three tones, like ProPresenter: the libraries + playlists on
     top are lighter, the items list darker, and its header rows a band between */
  --outline-bg: var(--grey-800);
  --items-bg: var(--grey-950);
  --items-header-bg: var(--grey-750);
  /* Drop-down arrow drawn by us (white, for the accent-filled select) */
  --clear-all-bg: var(--white-100);
  --clear-all-icon: var(--black);
  --checker-a: #1b1b1e;            /* transparent slide: ProPresenter's checkerboard… */
  --checker-b: #2a2a2e;
  --checker-size: 16px;            /* …one 2×2 tile; each square is half this */
  --screen-bg: #000000;            /* slides and previews */
  --screen-text: var(--white-100);
  --screen-placeholder: var(--white-48);
  --screen-text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
  --backdrop: rgba(0, 0, 0, 0.5);

  /* ---- Color roles, light theme (default): white ---- */
  color-scheme: light;
  --bg-base: var(--white);  /* sign-in form side */
  --bg-page: #e9e9ee;       /* controller workspace */
  --bg-panel: #f7f7f9;      /* controller live column */
  --bg-card: var(--white);  /* popovers, sheets */
  --bg-elevated: #f1f1f4;
  --bg-hover: #e6e6ea;
  --bg-input: var(--white);
  --accent-soft: rgba(47, 116, 224, 0.14);
  --accent-text: #1f5fcc;
  --tile: rgba(47, 116, 224, 0.12);
  --danger: #d93025;
  --danger-soft: rgba(217, 48, 37, 0.08);
  --danger-border: rgba(217, 48, 37, 0.45);
  --success: #1f9d4b;
  --success-soft: rgba(31, 157, 75, 0.16);
  --text: #1a1a1a;
  --text-secondary: #3f3f46;
  --text-muted: #6b7280;
  --text-placeholder: #9ca3af;
  --border: rgba(0, 0, 0, 0.1);
  --border-light: rgba(0, 0, 0, 0.16);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.12);
  --glass-bg: rgba(255, 255, 255, 0.66);
  --glass-field: rgba(255, 255, 255, 0.55);
  --glass-well: rgba(0, 0, 0, 0.04);
  --glass-edge: rgba(255, 255, 255, 0.9);
  --glass-border: rgba(0, 0, 0, 0.08);
  --glass-dim: rgba(0, 0, 0, 0.28);
}

/* ---- Color roles, dark ----
   The dark VALUES are palette tokens above (--grey-*, --white-*, --dark-*);
   change a color there and both uses below follow. This mapping appears
   twice (as in Vistro), KEEP THE TWO COPIES IDENTICAL:
     1. the device is in dark mode   → the sign-in page follows the device
     2. .theme-dark, always dark     → the whole controller page (on <html>),
                                       and the toolbar + slide grid */
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg-base: var(--grey-850);
    --bg-page: var(--grey-950);
    --bg-panel: var(--grey-900);
    --bg-card: var(--grey-800);
    --bg-elevated: var(--grey-750);
    --bg-hover: var(--grey-700);
    --bg-input: var(--grey-950);
    --accent-soft: var(--dark-accent-soft);
    --accent-text: var(--dark-accent-text);
    --tile: var(--dark-tile);
    --danger: var(--dark-danger);
    --danger-soft: var(--dark-danger-soft);
    --danger-border: var(--dark-danger-border);
    --success: var(--dark-success);
    --success-soft: var(--dark-success-soft);
    --text: var(--text-on-dark);
    --text-secondary: var(--text-on-dark-secondary);
    --text-muted: var(--text-on-dark-muted);
    --text-placeholder: var(--text-on-dark-placeholder);
    --border: var(--white-8);
    --border-light: var(--white-12);
    --shadow-lg: var(--dark-shadow-lg);
    --glass-bg: var(--dark-glass-bg);
    --glass-field: var(--dark-glass-field);
    --glass-well: var(--dark-glass-well);
    --glass-edge: var(--dark-glass-edge);
    --glass-border: var(--dark-glass-border);
    --glass-dim: var(--dark-glass-dim);
  }
}
.theme-dark {
  color-scheme: dark;
  --bg-base: var(--grey-850);
  --bg-page: var(--grey-950);
  --bg-panel: var(--grey-900);
  --bg-card: var(--grey-800);
  --bg-elevated: var(--grey-750);
  --bg-hover: var(--grey-700);
  --bg-input: var(--grey-950);
  --accent-soft: var(--dark-accent-soft);
  --accent-text: var(--dark-accent-text);
  --tile: var(--dark-tile);
  --danger: var(--dark-danger);
  --danger-soft: var(--dark-danger-soft);
  --danger-border: var(--dark-danger-border);
  --success: var(--dark-success);
  --success-soft: var(--dark-success-soft);
  --text: var(--text-on-dark);
  --text-secondary: var(--text-on-dark-secondary);
  --text-muted: var(--text-on-dark-muted);
  --text-placeholder: var(--text-on-dark-placeholder);
  --border: var(--white-8);
  --border-light: var(--white-12);
  --shadow-lg: var(--dark-shadow-lg);
  --glass-bg: var(--dark-glass-bg);
  --glass-field: var(--dark-glass-field);
  --glass-well: var(--dark-glass-well);
  --glass-edge: var(--dark-glass-edge);
  --glass-border: var(--dark-glass-border);
  --glass-dim: var(--dark-glass-dim);
}

/* "Reduce transparency" (macOS / iOS accessibility): glass goes solid again */
@media (prefers-reduced-transparency: reduce) {
  :root, .theme-dark {
    --glass-bg: var(--bg-card);
    --glass-field: var(--bg-input);
    --glass-well: var(--bg-panel);
    --glass-sheen: none;
    --glass-grain: none;
    --glass-blur: 0px;
    --glass-saturate: 100%;
    --glass-backdrop-blur: 0px;
  }
}

/* ---- 1h Scaling: only tokens change here ---- */
@media (max-width: 1100px) {
  :root {
    --toolbar-btn-min: 50px;
    --sidebar-width: 190px;
    --preview-width: 330px;
    --ed-nav-width: 170px;
    --ed-inspector-width: 270px;
    --ed-canvas-pad: 16px;
    --rf-side-width: 300px;
    --rf-text-pad: 16px;
    --rf-thumb-min: 120px;
  }
}
@media (max-width: 860px) { /* iPad portrait and below: toolbar icons only */
  :root {
    --toolbar-btn-min: 42px;
    --toolbar-btn-height: 42px;
    --toolbar-labels: none;
  }
}
@media (max-height: 720px) { /* short landscape tablets */
  :root { --size-h1: 22px; }
}
@media (max-width: 420px) { /* phones */
  :root {
    --size-display: 28px;
    --size-h1: 22px;
  }
}

/* ============================================================
   2. Base
   ============================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { min-height: 100%; }
body {
  font-family: var(--font-sans);
  font-size: var(--size-body);
  font-weight: var(--weight-regular);
  line-height: var(--leading-body);
  background: var(--bg-base);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
}
body.page-controller, body.page-admin { background: var(--bg-page); }
/* A page whose script fades it in (controller, admin): nothing drawn until the
   script has what it needs and starts the entrance (lib.js reveal) in the same
   frame, so the bare page never flashes first. Only the background shows. */
body.is-booting > * { visibility: hidden; }
/* select too: without it drop-downs fall back to the browser's Arial */
button, input, select, textarea { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ============================================================
   3. Text styles: every piece of text in the app uses one of these
   ============================================================ */
.panel-headline {                                  /* display */
  font-size: var(--size-display);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-display);
  line-height: var(--leading-display);
}
.form-title, .empty-state h2, .admin-title, .search-web-headline {       /* title 1 (sign-in title) */
  font-size: var(--size-h1);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-h1);
  line-height: var(--leading-tight);
}
.pop-title, .sheet-head h2, .deck-title, .new-heading, .form-input.deck-title-input { /* title 2 */
  font-size: var(--size-h2);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-h2);
  line-height: var(--leading-tight);
}
.status-church, .search-empty-title,
.search-preview-title {                            /* title 3 */
  font-size: var(--size-h3);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
}
.panel-text {                                      /* lead */
  font-size: var(--size-lead);
  line-height: var(--leading-loose);
}
.form-subtitle, .empty-state p, .pop-sub, .media-drop, .search-empty-text, .search-web-sub,
.sheet-intro, .status-who, .fact dd, .admin-sub,
.tour-text {                                       /* subtitle (sign-in subtitle) */
  font-size: var(--size-body);
  font-weight: var(--weight-regular);
  color: var(--text-secondary);
}
.brand, .setting-label, .segment-title, .admin-church, .tour-title, .new-find-title,
.group-bar-name, .tx-head, .device-check-title, .web-step-title, .web-step-num, .site-tile-name {  /* body, strong */
  font-size: var(--size-body);
  font-weight: var(--weight-semibold);
}
.pop-item-title, .fact dd strong, .audio-name,
.form-input.deck-item-input, .deck-item-title, .slide-num, .new-theme-name,
.ed-title, .ed-group-title, .admin-tab {           /* body, medium */
  font-size: var(--size-body);
  font-weight: var(--weight-medium);
}
.pop-note, .pop-empty, .setting-sub, .new-manual-toggle,
.signup-link, .check-row, .detail-more {           /* ui, supporting */
  font-size: var(--size-ui);
  color: var(--text-secondary);
}
.form-label, .live-screens,
.fact dt, .panel-foot, .mini-seg-btn, .bar-label, .bar-value,
.quick-tab, .tr-type-label, .screen-placeholder,
.ed-tab, .ed-label, .ed-tool-label, .ed-toggle,
.ed-suffix, .ed-condition, .tpl-name,
.media-name, .media-badge, .group-name,
.group-chip, .group-bar-count, .new-label,
.admin-kicker, .tour-step {                      /* label (sign-in field label) */
  font-size: var(--size-label);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
}
/* compact field: a field in a bar or a side column reads like its label
   (12/500), in primary text. controller.html stops iOS zooming in on
   fields under 16px. Popover / sheet forms keep the sign-in standard (16). */
.quick-field .form-input, .ed-panel .form-input, .sidebar .form-input,
.form-input.bar-select, .form-input.rf-select, .side-filter .filter-input,
.quick-panel .group-row .form-input, .group-add .form-input, .popover-text .form-input,
.media-link .form-input {
  font-size: var(--size-label);
  font-weight: var(--weight-medium);
  color: var(--text);
}
.tip {                                            /* hover label: a label, in primary text */
  font-size: var(--size-label);
  font-weight: var(--weight-medium);
  line-height: var(--leading-snug);
  color: var(--text);
}
.tb-label {                                       /* toolbar label: primary white, subtitle weight */
  font-size: var(--size-label);
  font-weight: var(--toolbar-weight);
  color: var(--toolbar-text);
}
.tb-title {                                       /* toolbar title (church name): same, body size */
  font-size: var(--size-body);
  font-weight: var(--toolbar-weight);
  color: var(--toolbar-text);
}
.section-label, .ed-group {                       /* sidebar section: LIBRARY, SERVICES, 8 ITEMS */
  font-size: var(--size-label);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--text-muted);
}
.row-title, .ed-object-name, .book-btn, .chapter-btn { /* sidebar row */
  font-size: var(--size-body);
  font-weight: var(--weight-regular);
  color: var(--text);
}
.row-hint {                                       /* explains a ProPresenter word: "songs" */
  font-size: var(--size-small);
  font-style: italic;
  color: var(--text-muted);
}
.row-meta {                                       /* sidebar row, right side */
  font-size: var(--size-label);
  color: var(--text-muted);
}
.slide-name, .slide-row-text {                   /* slide label name, list-view words: subtitle weight */
  font-size: var(--size-body);
  font-weight: var(--weight-regular);
}
.form-hint, .pop-item-meta, .segment-sub, .deck-meta, .deck-item-meta, .add-note,
.church-code, .status-code, .screens-hint,
.quick-hint, .ed-tick, .ed-saved, .ed-slide-num, .ed-under, .popover-text .form-label, .tx-status, .tx-for,
.ed-hint-inline, .ed-artwork.is-empty, .rf-hint, .new-hint, .words-status, .web-step-hint, .site-tile-sub,
.app-version {                                     /* small, meta */
  font-size: var(--size-small);
  color: var(--text-muted);
}
.bible-verse-text {                               /* reading text: the Bible verses, a step up */
  font-size: var(--size-lead);
  font-weight: var(--weight-regular);
  line-height: var(--leading-body);
}
.bible-verse-num {                                /* a verse number: label, figures lined up */
  font-size: var(--size-label);
  font-weight: var(--weight-semibold);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.words-input, .words-backdrop {                    /* code: the quick words box, monospace */
  font-family: var(--font-mono);
  font-size: var(--size-body);
  font-weight: var(--weight-regular);
  line-height: var(--leading-body);
  letter-spacing: normal;
}
.rf-input, .rf-backdrop, .new-lyrics-input, .new-backdrop { /* typed text: 16 like every input (iOS zoom) */
  font-family: var(--font-sans);
  font-size: var(--size-input);
  font-weight: var(--weight-regular);
  line-height: var(--leading-body);
  letter-spacing: normal;
}
.mono { font-family: var(--font-mono); }
.muted { color: var(--text-muted); }

/* ============================================================
   4. Components
   ============================================================ */

/* ---- Fields ---- */
.form-group { margin-bottom: var(--space-4); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.form-row .form-group { margin-bottom: 0; }
.form-label { display: block; margin-bottom: var(--space-1-5); }
.form-input {
  width: 100%;
  height: var(--control-height);
  padding: 0 var(--input-pad-x);
  border-radius: var(--radius-control);
  border: var(--border-width) solid var(--border-light);
  background: var(--bg-input);
  color: var(--text);
  font-size: var(--size-input);
  outline: none;
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
}
.form-input::placeholder { color: var(--text-placeholder); }
.form-input:hover { border-color: var(--text-muted); }
.form-input:focus { border-color: var(--accent); box-shadow: 0 0 0 var(--focus-ring) var(--accent-soft); }
.form-input:disabled { opacity: var(--opacity-disabled); }
textarea.form-input {
  height: auto;
  min-height: calc(var(--control-height) * 1.8);
  padding: var(--input-pad-y) var(--input-pad-x);
  line-height: var(--leading-snug);
  resize: vertical;
}
.form-hint { margin: var(--space-2) 0 var(--space-1); }
.input-row { display: flex; gap: var(--space-2); }
.input-row .form-input { flex: 1; min-width: 0; }

/* ---- Buttons: one text size (the sign-in "Continue") ---- */
.btn, .submit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: var(--control-height);
  padding: 0 var(--control-pad-x);
  border-radius: var(--radius-control);
  border: var(--border-width) solid transparent;
  font-size: var(--size-button);
  font-weight: var(--weight-semibold);
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--duration-fast), border-color var(--duration-fast), opacity var(--duration-fast);
  touch-action: manipulation;
}
.btn-primary, .submit-btn { background: var(--accent); color: var(--accent-contrast); }
.btn-primary:hover:not(:disabled), .submit-btn:hover:not(:disabled) { background: var(--accent-hover); }
.btn-ghost, .reveal { background: var(--bg-elevated); border-color: var(--border-light); color: var(--text); }
.btn-ghost:hover:not(:disabled), .reveal:hover { background: var(--bg-hover); }
.btn-ghost.is-on { background: var(--accent); border-color: transparent; color: var(--accent-contrast); }
.btn-danger { color: var(--danger); }
.btn-block { width: 100%; }
/* Small buttons: lists, settings rows, "Show" next to a password */
.btn-sm, .reveal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: var(--control-height-sm);
  padding: 0 var(--control-pad-x-sm);
  border-radius: var(--radius-control);
  font-size: var(--size-ui);
  font-weight: var(--weight-medium);
  white-space: nowrap;
  cursor: pointer;
}
.reveal {
  flex: 0 0 auto;
  height: var(--control-height);
  min-width: var(--reveal-width);
  border-width: var(--border-width);
  border-style: solid;
}
.submit-btn { width: 100%; height: var(--button-height); margin-top: var(--space-2); }
.btn:disabled, .submit-btn:disabled { opacity: var(--opacity-disabled); cursor: not-allowed; }
.btn.is-busy, .submit-btn.is-busy { opacity: var(--opacity-busy); cursor: progress; }
.btn:focus-visible, .submit-btn:focus-visible, .reveal:focus-visible,
.mode-toggle:focus-visible, .text-link:focus-visible {
  outline: var(--focus-width) solid var(--accent);
  outline-offset: var(--focus-offset);
}

/* ---- Links ---- */
.mode-toggle {
  display: inline-block;
  margin-top: var(--space-4);
  min-height: var(--space-8);
  background: none;
  border: none;
  font-size: var(--size-ui);
  color: var(--text-secondary);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: var(--underline-offset);
}
.mode-toggle:hover { color: var(--text); }
.mode-toggle.inline { margin: 0; flex: 0 0 auto; }
.text-link {
  background: none;
  border: none;
  color: var(--accent-text);
  font-weight: var(--weight-medium);
  cursor: pointer;
}
.text-link:hover { text-decoration: underline; text-underline-offset: var(--underline-offset); }

/* ---- Messages ---- */
.form-error, .form-notice, .next-step {
  padding: var(--message-pad);
  border-radius: var(--radius-control);
  font-size: var(--size-ui);
  line-height: var(--leading-snug);
  color: var(--text);
}
.form-error {
  border: var(--border-width) solid var(--danger-border);
  background: var(--danger-soft);
  margin-bottom: var(--space-4);
}
.form-notice, .next-step {
  border: var(--border-width) solid var(--accent);
  background: var(--accent-soft);
  margin-bottom: var(--space-4);
}
.toast {
  position: fixed;
  z-index: var(--z-toast);
  left: 50%;
  bottom: max(var(--space-6), env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: calc(100% - var(--space-8));
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  color: var(--text);
  border: var(--border-width) solid var(--border-light);
  box-shadow: var(--shadow-lg);
  font-size: var(--size-ui);
  animation: vx-fade var(--duration-fast) ease-out;
}
/* something worked ("Added …"): a green check, a green edge */
.toast.is-done { border-color: var(--success); }
.toast.is-done::before { content: "✓"; margin-right: var(--space-2); color: var(--success); font-weight: var(--weight-semibold); }
@keyframes vx-fade { from { opacity: 0; } }

/* ---- Pills, avatars, status ---- */
.pill, .kind {
  flex: 0 0 auto;
  padding: var(--pill-pad);
  border-radius: var(--radius-sm);
  font-size: var(--size-small);
  font-weight: var(--weight-semibold);
  background: var(--bg-elevated);
  color: var(--text-secondary);
}
.pill.on { background: var(--success-soft); color: var(--success); }

.avatar {
  flex: 0 0 auto;
  width: var(--avatar-md);
  height: var(--avatar-md);
  border-radius: var(--radius-md);
  background: var(--tile);
  color: var(--accent-text);
  display: grid;
  place-items: center;
  font-size: var(--size-h3);
  font-weight: var(--weight-semibold);
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.status { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--size-label); color: var(--text-muted); }
.dot { width: var(--icon-dot); height: var(--icon-dot); border-radius: 50%; background: var(--text-muted); }
.status.live .dot { background: var(--success); }
.status.down .dot { background: var(--live); }

/* ---- Brand ---- */
.brand { display: flex; align-items: center; gap: var(--space-2-5); letter-spacing: var(--tracking-h2); }
.brand-mark {
  width: var(--brand-mark);
  height: var(--brand-mark);
  border-radius: var(--radius-mark);
  background: var(--accent);
  color: var(--accent-contrast);
  display: flex;
  align-items: center;
  justify-content: center;
}
.brand-mark svg { width: var(--brand-mark-icon); height: var(--brand-mark-icon); }

/* ============================================================
   5. Sign-in page (index.html): Vistro's two-tone split
   ============================================================ */
.auth-split { display: flex; min-height: 100vh; min-height: 100dvh; }

/* ---- Form side ---- */
.form-side {
  flex: 0 0 var(--form-side-width);
  display: flex;
  flex-direction: column;
  background: var(--bg-base);
  padding: max(var(--space-8), env(safe-area-inset-top)) var(--space-10) max(var(--space-10), env(safe-area-inset-bottom));
}
.form-wrap { width: 100%; max-width: var(--form-width); margin: auto; padding: var(--space-10) 0 var(--space-6); }
/* the version, at the foot of the form side (package.json, lib.js showVersion) */
.app-version { font-variant-numeric: tabular-nums; }
.app-version:empty { display: none; }
.form-title { margin-bottom: var(--space-2); }
.form-subtitle { margin-bottom: var(--space-7); }
.signup-link {
  margin-top: var(--space-7);
  padding-top: var(--space-5);
  border-top: var(--border-width) solid var(--border);
}

/* Church header on the password step */
.church-head { display: flex; align-items: center; gap: var(--space-3-5); margin-bottom: var(--space-6); }
.church-meta { flex: 1; min-width: 0; }
.church-meta .form-title { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.church-code { margin-top: var(--space-half); }

/* Controller / Observer picker */
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-1-5);
  padding: var(--space-1);
  margin-bottom: var(--space-4);
  border: var(--border-width) solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-input);
}
.segment {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: var(--segment-height);
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: center;
  transition: background var(--duration-fast);
}
.segment input { position: absolute; opacity: 0; pointer-events: none; }
.segment.is-checked { background: var(--accent); color: var(--accent-contrast); }
.segment.is-checked .segment-sub { color: var(--text-on-accent); }
.segment:focus-within { outline: var(--focus-width) solid var(--accent); outline-offset: var(--focus-offset); }
.segment.is-disabled { opacity: var(--opacity-disabled); cursor: not-allowed; }

/* ---- Brand panel: always black, facts on the right ---- */
.brand-panel {
  flex: 1;
  background: var(--bg-brand-panel);
  color: var(--text-on-dark);
  border-left: var(--border-width) solid var(--panel-edge);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: var(--space-14) var(--space-16);
}
.panel-inner { max-width: var(--panel-text-width); }
.panel-headline { margin-bottom: var(--space-4); color: var(--text-on-dark); }
.panel-text { color: var(--panel-text); margin-bottom: var(--space-10); }
.facts { border-top: var(--border-width) solid var(--panel-border); }
.fact {
  display: grid;
  grid-template-columns: var(--fact-label-width) 1fr;
  gap: var(--space-4);
  padding: var(--space-5) 0;
  border-bottom: var(--border-width) solid var(--panel-border);
}
.fact dt {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  align-self: start;
  padding-top: var(--space-half);
  color: var(--panel-muted);
}
/* Each pointer carries a slide-label color: blue, pink, purple, red. */
.fact dt::before {
  content: "";
  flex: 0 0 auto;
  width: var(--icon-xs);
  height: var(--icon-xs);
  border-radius: var(--radius-xs);
  background: var(--section-verse);
}
.fact:nth-child(2) dt::before { background: var(--section-chorus); }
.fact:nth-child(3) dt::before { background: var(--section-bridge); }
.fact:nth-child(4) dt::before { background: var(--section-tag); }
.fact dd { color: var(--panel-text); }
.fact dd strong { display: block; color: var(--text-on-dark); }
.panel-foot { color: var(--panel-faint); margin-top: var(--space-7); }

/* ---- Entrance (Vistro's vx-enter), sign-in only ----
   Replays on every view switch: a section going from hidden to
   shown restarts its animations. */
.brand { animation: vx-enter-item var(--duration-brand) var(--ease-settle) backwards; }
.view { animation: vx-enter var(--duration-enter) var(--ease-settle) backwards; }
.view > *, .view form > * {
  animation: vx-enter-item var(--duration-enter-item) var(--ease-settle) backwards;
}
.view > :nth-child(1) { animation-delay: 0.06s; }
.view > :nth-child(2) { animation-delay: 0.12s; }
.view > :not(form):nth-child(n+3) { animation-delay: 0.5s; }
.view form > :nth-child(1) { animation-delay: 0.18s; }
.view form > :nth-child(2) { animation-delay: 0.24s; }
.view form > :nth-child(3) { animation-delay: 0.3s; }
.view form > :nth-child(4) { animation-delay: 0.36s; }
.view form > :nth-child(5) { animation-delay: 0.42s; }
.view form > :nth-child(n+6) { animation-delay: 0.46s; }
.panel-headline, .panel-text, .fact, .panel-foot {
  animation: vx-enter-item var(--duration-enter-item) var(--ease-settle) backwards;
}
.panel-headline { animation-delay: 0.2s; }
.panel-text { animation-delay: 0.28s; }
.fact:nth-child(1) { animation-delay: 0.38s; }
.fact:nth-child(2) { animation-delay: 0.46s; }
.fact:nth-child(3) { animation-delay: 0.54s; }
.fact:nth-child(4) { animation-delay: 0.62s; }
.panel-foot { animation-delay: 0.72s; }

@keyframes vx-enter {
  0%   { opacity: 0; filter: blur(16px); transform: translateY(28px) scale(0.96); }
  42%  { opacity: 1; filter: blur(0); transform: translateY(-6px) scale(1.012); }
  66%  { transform: translateY(2.5px) scale(0.996); }
  84%  { transform: translateY(-1px) scale(1.001); }
  100% { opacity: 1; filter: none; transform: none; }
}
@keyframes vx-enter-item {
  0%   { opacity: 0; filter: blur(8px); transform: translateY(16px) scale(0.97); }
  50%  { opacity: 1; filter: blur(0); transform: translateY(-3px) scale(1.01); }
  75%  { transform: translateY(1px) scale(0.998); }
  100% { opacity: 1; filter: none; transform: none; }
}

/* Layout changes (structure only; sizes scale in 1h) */
@media (max-width: 959px) {
  .brand-panel { display: none; }
  .form-side { flex: 1; padding: max(var(--space-6), env(safe-area-inset-top)) var(--space-5) max(var(--space-8), env(safe-area-inset-bottom)); }
  .form-wrap { padding-top: var(--space-6); }
}
@media (max-width: 420px) {
  .form-row { grid-template-columns: 1fr; gap: 0; }
  .form-row .form-group { margin-bottom: var(--space-4); }
}
@media (max-height: 720px) {
  .form-wrap { padding: var(--space-4) 0; }
  .form-subtitle { margin-bottom: var(--space-5); }
}

/* ============================================================
   6. Controller page (controller.html)
   ============================================================ */
.controller {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}

/* ---- Toolbar: .theme-dark, dark grey with white text in both themes ---- */
.toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-half);
  padding: max(var(--space-1-5), env(safe-area-inset-top)) max(var(--space-2-5), env(safe-area-inset-right)) var(--space-1-5) max(var(--space-2-5), env(safe-area-inset-left));
  background: var(--toolbar-bg);
  color: var(--text);
  border-bottom: var(--border-width) solid var(--border-light);
  overflow-x: auto;
  scrollbar-width: none;
}
.toolbar::-webkit-scrollbar { display: none; }
.tb-group { display: flex; gap: var(--space-half); flex: 0 0 auto; }
.tb-sep {
  flex: 0 0 auto;
  width: var(--border-width);
  height: var(--toolbar-sep-height);
  margin: 0 var(--space-1-5);
  background: var(--border-light);
}
.tb-title {
  flex: 1 1 auto;
  min-width: var(--space-4);
  padding: 0 var(--space-2-5);
  text-align: center;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.tb-btn {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  min-width: var(--toolbar-btn-min);
  height: var(--toolbar-btn-height);
  padding: var(--space-1) var(--space-2);
  border: 0;
  border-radius: var(--radius-control);
  background: transparent;
  color: var(--toolbar-text);
  cursor: pointer;
  transition: background var(--duration-fast), color var(--duration-fast);
  touch-action: manipulation;
}
.tb-btn:hover:not(:disabled) { background: var(--bg-hover); }
.tb-btn.is-active, .tb-btn.is-open { background: var(--bg-hover); }
.tb-btn.is-active .tb-icon { color: var(--accent-text); }
/* Show while the audience screens are showing: filled, with the pause icon */
.tb-btn.is-showing, .tb-btn.is-showing:hover:not(:disabled) { background: var(--accent); }
.tb-btn.is-showing .tb-icon, .tb-btn.is-showing .tb-label { color: var(--text-on-accent); }
.tb-btn:disabled { opacity: var(--opacity-disabled); cursor: not-allowed; }
.tb-btn:focus-visible { outline: var(--focus-width) solid var(--accent); outline-offset: 1px; }
.tb-icon {
  flex: 0 0 auto;
  width: var(--icon-md);
  height: var(--icon-md);
  fill: none;
  stroke: currentColor;
  stroke-width: var(--icon-stroke);
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tb-icon .fill { fill: currentColor; stroke: none; }
.tb-label { display: var(--toolbar-labels); line-height: var(--leading-none); white-space: nowrap; }
/* Icons only (narrow screens): hide the church name too; it still pushes the right-hand group over. */
@media (max-width: 860px) { .tb-title { font-size: 0; padding: 0; } }

/* Audience / Stage lights: red ring = nothing connected, green = connected */
.light { display: grid; place-items: center; }
.light::before {
  content: "";
  width: var(--icon-sm);
  height: var(--icon-sm);
  box-sizing: border-box;
  border-radius: 50%;
  border: var(--light-ring) solid var(--live);
}
.light.on::before { background: var(--success); border-color: var(--success); }
.small-light { flex: 0 0 auto; width: var(--light-slot); }
.small-light::before { width: var(--icon-xs); height: var(--icon-xs); }

.tb-avatar {
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: var(--size-tiny);
  font-weight: var(--weight-semibold);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.tb-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ---- Workspace: the mode's view + the live column ---- */
.workspace {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr) var(--preview-width);
  grid-template-rows: minmax(0, 1fr);
  grid-template-areas: "side main live";
  min-height: 0;
  background: var(--bg-page);
}
.sidebar { grid-area: side; }
/* the mode's view on top; under it (Show and Bible) the bar, the handle and the media library */
.mode-area { grid-area: main; min-width: 0; min-height: 0; overflow: auto; display: flex; flex-direction: column; }
.workspace.is-editing .mode-area > .deck-bar,
.workspace.is-editing .mode-area > .split-handle,
.workspace.is-editing .mode-area > .lower-panel { display: none; }
.preview-col { grid-area: live; }

/* ---- Left panel: outline (Library + Services) over the detail list ---- */
.sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg-panel);
  border-right: var(--border-width) solid var(--border-light);
}
.outline {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  height: var(--outline-height);
  min-height: var(--outline-min);
  max-height: calc(100% - var(--detail-min) - var(--split-handle));
  background: var(--outline-bg);
  border-bottom: var(--border-width) solid var(--border-light);
}
.outline.is-collapsed { height: auto; min-height: 0; max-height: none; padding-bottom: var(--space-2); }
.side-split { border-top: 0; background: var(--outline-bg); }
.outline-body { min-height: 0; overflow: auto; padding-bottom: var(--space-2); }
.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  min-height: var(--sidebar-row-height);
  padding: 0 var(--space-2) 0 var(--space-3);
}
.side-subhead { margin-top: var(--space-1); }
.side-actions { display: flex; gap: var(--space-half); }
.icon-btn-sm { width: var(--sidebar-row-height); height: calc(var(--sidebar-row-height) - var(--space-2)); }
.icon-btn-sm svg { width: var(--icon-sm); height: var(--icon-sm); }
#outline-collapse svg { transition: transform var(--duration-fast); }
.outline.is-collapsed #outline-collapse svg { transform: rotate(180deg); }

.outline-row, .detail-row {
  display: flex;
  align-items: center;
  gap: var(--space-2-5);
  width: 100%;
  min-height: var(--sidebar-row-height);
  padding: 0 var(--space-3);
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: background var(--duration-fast);
}
.outline-row:hover, .detail-row:hover { background: var(--bg-hover); }
/* a long press opens the row's menu (Delete…): no text selection, no iOS callout */
.outline-row, .detail-row { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.outline-row.is-selected, .detail-row.is-selected { background: var(--row-selected-bg); }
/* The playlist / library you're in while one of its items is the blue row */
.outline-row.is-current { background: var(--row-current-bg); box-shadow: inset 0 0 0 var(--border-width) var(--row-current-line); }
.outline-row.is-nested { padding-left: calc(var(--space-3) + var(--nested-indent)); }
/* A playlist folder: ▶ turns ▼ when open */
.disclosure { flex: 0 0 auto; display: grid; place-items: center; width: var(--space-3); margin-right: calc(-1 * var(--space-1)); color: var(--text-muted); }
.disclosure svg { width: var(--space-3); height: var(--space-3); transition: transform var(--duration-fast); }
.disclosure svg .fill { fill: currentColor; }
.folder-row.is-open .disclosure svg { transform: rotate(90deg); }
.outline-row.is-selected .row-title, .detail-row.is-selected .row-title,
.outline-row.is-selected .row-meta, .detail-row.is-selected .row-meta,
.outline-row.is-selected .row-hint { color: var(--row-selected-text); }
.outline-row .row-hint { flex: 0 0 auto; }
.outline-row:focus-visible, .detail-row:focus-visible { outline: var(--focus-width) solid var(--accent); outline-offset: -2px; }
.row-title { flex: 1 1 auto; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.row-meta { flex: 0 0 auto; white-space: nowrap; }
.row-icon {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: var(--row-icon);
  height: var(--row-icon);
  border-radius: var(--radius-sm);
  color: var(--text-on-accent);
  background: var(--service-icon);
}
.row-icon-library { background: var(--library-icon); }
.row-icon svg, .row-glyph svg {
  width: var(--icon-sm);
  height: var(--icon-sm);
  fill: none;
  stroke: currentColor;
  stroke-width: var(--icon-stroke);
  stroke-linecap: round;
  stroke-linejoin: round;
}
.row-glyph { flex: 0 0 auto; display: grid; place-items: center; width: var(--row-icon); color: var(--text-muted); }
.detail-row.is-selected .row-glyph { color: var(--row-selected-text); }
/* A playlist item whose presentation was deleted: red crossed-out icon, faint name */
.detail-row.is-missing:not(.is-selected) .row-glyph { color: var(--danger); }
.detail-row.is-missing:not(.is-selected) .row-title { color: var(--text-muted); }
/* The service item that's live: a red dot */
.live-dot { flex: 0 0 auto; width: var(--icon-dot); height: var(--icon-dot); border-radius: 50%; background: var(--live); }
.detail-row.is-header {
  cursor: pointer; /* it goes to that part of the playlist in the grid */
  min-height: calc(var(--sidebar-row-height) - var(--space-1-5));
  background: var(--items-header-bg);
}
.detail-row.is-header .row-title { font-weight: var(--weight-semibold); color: var(--header-text); }
.detail-row.is-header { box-shadow: inset var(--header-line) 0 0 var(--header-tone); } /* a Header: amber, as in the grid */
.detail-row.is-header:hover { background: var(--items-header-hover); }

.new-service { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-1) var(--space-3) var(--space-3); }
.new-service .form-input { height: var(--control-height-sm); }
.new-service-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }

.detail { flex: 1 1 auto; display: flex; flex-direction: column; min-height: var(--detail-min); background: var(--items-bg); }
.detail-head { border-bottom: var(--border-width) solid var(--border); }
.detail-list { flex: 1 1 auto; min-height: 0; overflow: auto; padding: var(--space-1) 0; }
.detail-empty { padding: var(--space-3); font-size: var(--size-ui); color: var(--text-muted); }
/* the next page of a long list (DETAIL_PAGE rows at a time) */
.detail-more {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  width: 100%;
  min-height: var(--sidebar-row-height);
  padding: 0 var(--space-3);
  border: 0;
  background: transparent;
  color: var(--accent-text);
  text-align: left;
  cursor: pointer;
}
.detail-more:hover { background: var(--bg-hover); }
.detail-more:focus-visible { outline: var(--focus-width) solid var(--accent); outline-offset: -2px; }
.side-filter {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: var(--space-2);
  padding: 0 var(--space-2-5);
  height: var(--control-height-sm);
  border: var(--border-width) solid var(--border-light);
  border-radius: var(--radius-control);
  background: var(--bg-input);
  color: var(--text-muted);
}
.side-filter svg { flex: 0 0 auto; width: var(--icon-sm); height: var(--icon-sm); fill: none; stroke: currentColor; stroke-width: var(--icon-stroke); stroke-linecap: round; }
.filter-input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
}
.filter-input::placeholder { color: var(--text-placeholder); }
.side-filter:focus-within { border-color: var(--accent); }
.mode-view { flex: 1 1 auto; min-height: 0; }
.empty-state {
  height: 100%;
  min-height: var(--empty-min-height);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-6);
  text-align: center;
  color: var(--text-muted);
}
.empty-state svg {
  width: var(--icon-lg);
  height: var(--icon-lg);
  margin-bottom: var(--space-2);
  fill: none;
  stroke: currentColor;
  stroke-width: var(--icon-stroke-thin);
  stroke-linecap: round;
  stroke-linejoin: round;
}
.empty-state h2 { color: var(--text); }
.empty-state p { max-width: var(--form-width); }

.preview-col {
  min-height: 0;
  overflow: auto;
  background: var(--bg-panel);
  border-left: var(--border-width) solid var(--border-light);
}

/* The preview, edge to edge, with the clear strip on its right */
.live-stage {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--clear-strip-width);
  background: var(--screen-bg);
}
.screen {
  position: relative;
  container-type: inline-size;
  aspect-ratio: 16 / 9;
  display: grid;
  overflow: hidden;
  background: var(--screen-bg);
}
/* Screen layers (preview + audience screen, lib.js slideScreen): all in one
   grid cell; media under text; a leaving layer fades over the new one */
.layer { grid-area: 1 / 1; min-width: 0; min-height: 0; }
.layer-media { z-index: var(--z-screen-media); position: relative; overflow: hidden; } /* holds a background video */
.layer-text { z-index: var(--z-screen-text); display: grid; container-type: size; }
/* a picture behind a verse, darkened so the words read (lib.js slideScreen; opacity = the Bible's Dim) */
.layer-dim { z-index: var(--z-screen-dim); background: var(--black); opacity: 0; pointer-events: none; transition: opacity var(--duration-dim) ease; }
.layer.is-leaving { pointer-events: none; }
.layer-flash { grid-area: 1 / 1; z-index: var(--z-screen-flash); background: var(--white); opacity: 0; pointer-events: none; }
.layer-logo { align-self: center; justify-self: center; max-width: 50%; max-height: 50%; object-fit: contain; }

/* A media-library video on the background layer (lib.js paintMedia) */
.layer-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
/* A shared screen fits whole (letterboxed), never cropped */
.layer-video[data-screen] { object-fit: contain; }
/* The controller's preview names a shared screen until its picture is here */
.layer-screen-note {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--white-55);
  font-size: var(--size-label);
  font-weight: var(--weight-medium);
}
.layer-media.has-stream .layer-screen-note { display: none; }
/* A slide's design (lib.js drawSlide): a box in the slide's own aspect ratio,
   letterboxed in its holder; objects placed in % of it, every length in --u
   (one slide px). Holders are grids with container-type: size. */
.slide-box {
  position: relative;
  place-self: center;
  width: 100%;
  aspect-ratio: var(--slide-ar, 16 / 9);
  overflow: hidden;
  container-type: inline-size;
}
@supports (width: 1cqh) {
  .slide-box { width: min(100cqw, calc(100cqh * (var(--slide-ar-n, 1.7778)))); }
}
.obj { position: absolute; }
.obj-frame { position: absolute; inset: 0; box-sizing: border-box; overflow: hidden; }
.obj-text { display: flex; flex-direction: column; overflow: hidden; }
.obj-words { white-space: pre-line; overflow-wrap: break-word; }
.obj-words.lines-full .obj-line { display: block; position: relative; }
.obj-words.lines-fit .obj-line {
  position: relative;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
.obj-words.lines-fit .obj-line + .obj-line::before { content: "\A"; white-space: pre; }
.obj-text.scroll-x .obj-words { white-space: pre; width: max-content; }
.obj-track { display: flex; width: max-content; }
.obj-text.scroll-y .obj-track { flex-direction: column; width: 100%; }
.obj-svg { width: 100%; height: 100%; overflow: visible; }
.obj-media { display: grid; place-items: center; }
/* exactly the object's box (absolute: a grid item's 100% height would follow
   the picture's own shape instead, and Fit would crop and zoom it); the
   backdrop first, the picture over it */
.obj-media img, .obj-media video { position: absolute; inset: 0; width: 100%; height: 100%; }
.obj-media .obj-media-backdrop {
  object-fit: cover;
  filter: blur(calc(var(--u) * var(--media-backdrop-blur))) brightness(var(--media-backdrop-dim));
  transform: scale(var(--media-backdrop-zoom));
}
.obj-media.is-empty { background: var(--white-8); }
.obj-media-hint { color: var(--screen-placeholder); font-size: calc(var(--u) * 28); }
.slide-meta {
  position: absolute;
  left: 6%;
  right: 6%;
  bottom: 4%;
  white-space: pre-line;
  line-height: var(--leading-snug);
  opacity: var(--meta-opacity);
}
.screen-placeholder {
  grid-area: 1 / 1;
  z-index: 2;
  align-self: center;
  justify-self: center;
  color: var(--screen-placeholder);
}

.clear-strip {
  display: flex;
  flex-direction: column;
  background: var(--toolbar-bg);
  border-left: var(--border-width) solid var(--border-light);
}
.layer-btn {
  flex: 1 1 0;
  display: grid;
  place-items: center;
  min-height: 0;
  border: 0;
  border-bottom: var(--border-width) solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: background var(--duration-fast);
  touch-action: manipulation;
}
.layer-btn:last-child { border-bottom: 0; }
.layer-btn:hover:not(:disabled) { background: var(--bg-hover); }
.layer-btn.is-active { background: var(--layer-active); }
.layer-btn:disabled { opacity: var(--opacity-disabled); cursor: not-allowed; }
.layer-btn:focus-visible { outline: var(--focus-width) solid var(--accent); outline-offset: -2px; }
.layer-btn svg, .clear-all svg {
  width: var(--icon-md);
  height: var(--icon-md);
  fill: none;
  stroke: currentColor;
  stroke-width: var(--icon-stroke);
  stroke-linecap: round;
  stroke-linejoin: round;
}
.layer-btn svg .fill { fill: currentColor; stroke: none; }
/* Clear all: the round × on the strip's edge, like ProPresenter */
.clear-all {
  position: absolute;
  top: 50%;
  right: var(--clear-strip-width);
  transform: translate(50%, -50%);
  display: grid;
  place-items: center;
  width: var(--clear-all-size);
  height: var(--clear-all-size);
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--clear-all-bg);
  color: var(--clear-all-icon);
  cursor: pointer;
  box-shadow: var(--shadow-lg);
}
.clear-all svg { width: var(--icon-sm); height: var(--icon-sm); stroke-width: 2.5; }
.clear-all:disabled { opacity: var(--opacity-disabled); cursor: not-allowed; }
.clear-all:focus-visible { outline: var(--focus-width) solid var(--accent); outline-offset: var(--focus-offset); }

.live-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  min-height: var(--live-bar-height);
  padding: 0 var(--space-3);
  border-bottom: var(--border-width) solid var(--border);
}
.status.on-air .dot { background: var(--live); }
.live-screens-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-width: 0;
  height: var(--control-height-sm);
  margin-right: calc(var(--space-2) * -1);
  padding: 0 var(--space-2);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  transition: background var(--duration-fast);
}
.live-screens-btn:hover, .live-screens-btn.is-open { background: var(--bg-hover); }
.live-fullscreen { margin-left: auto; margin-right: 0; color: var(--accent-text); }
/* This device (Screens panel): can it drive the projector too? (js/screencheck.mjs) */
.device-check {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin-bottom: var(--space-2);
  padding: var(--space-2-5) var(--space-3);
  border: var(--border-width) solid var(--border-light);
  border-left: var(--ed-group-bar) solid var(--text-muted);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
}
.device-check[data-state="ready"] { border-left-color: var(--success); }
.device-check[data-state="ask"] { border-left-color: var(--accent); }
.device-check[data-state="denied"], .device-check[data-state="hidden"] { border-left-color: var(--danger); }
.device-check-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-1); }
.device-check-actions:empty { display: none; }
.live-screens-btn:focus-visible { outline: var(--focus-width) solid var(--accent); outline-offset: var(--focus-offset); }
.live-screens-btn svg { flex: 0 0 auto; width: var(--icon-sm); height: var(--icon-sm); fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Quick actions under the preview: tabs (the active one filled, like
   ProPresenter's), then Transition or Metadata */
.quick { border-top: var(--border-width) solid var(--border); }
.quick-tabs { display: flex; border-bottom: var(--border-width) solid var(--border); }
.quick-tab {
  flex: 1 1 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1-5);
  height: var(--quick-tab-height);
  border: 0;
  background: transparent;
  cursor: pointer;
  transition: background var(--duration-fast), color var(--duration-fast);
}
.quick-tab + .quick-tab { border-left: var(--border-width) solid var(--border); }
.quick-tab:hover:not(.is-active) { background: var(--bg-hover); }
.quick-tab.is-active { background: var(--accent); color: var(--text-on-accent); }
.quick-tab:focus-visible { outline: var(--focus-width) solid var(--accent); outline-offset: calc(var(--focus-width) * -1); }
.quick-tab svg { flex: 0 0 auto; width: var(--icon-sm); height: var(--icon-sm); fill: none; stroke: currentColor; stroke-width: var(--icon-stroke); stroke-linecap: round; stroke-linejoin: round; }
.quick-panel { display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-3); }
/* a part of a panel that shows / folds as one (Background: its controls, Song info) */
.quick-panel-part { display: flex; flex-direction: column; gap: var(--space-3); }
.quick-seg { display: flex; }
.quick-seg .mini-seg-btn { flex: 1 1 0; }
.tr-types { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-2); }
.tr-type {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1-5);
  padding: var(--tr-type-pad) var(--space-1);
  border: var(--border-width) solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-input);
  color: var(--text);
  cursor: pointer;
  transition: background var(--duration-fast), border-color var(--duration-fast);
}
.tr-type:hover:not(:disabled):not(.is-on) { background: var(--bg-hover); }
.tr-type.is-on { border-color: var(--accent); background: var(--accent-soft); }
.tr-type.is-on .tr-type-label { color: var(--text); }
.tr-type:disabled { opacity: var(--opacity-disabled); cursor: not-allowed; }
.tr-type:focus-visible { outline: var(--focus-width) solid var(--accent); outline-offset: var(--focus-offset); }
.tr-type svg { width: var(--icon-lg); height: var(--icon-lg); fill: none; stroke: currentColor; stroke-width: var(--icon-stroke); stroke-linecap: round; stroke-linejoin: round; }
.tr-type svg .fill { fill: currentColor; stroke: none; }
.quick-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); }
/* a slider and its value: Transition's Duration, the clock's slide timer */
.quick-range, .pop-range { display: flex; align-items: center; gap: var(--space-2); }
.quick-range .bar-range, .pop-range .bar-range { flex: 1 1 auto; width: auto; min-width: 0; }
.quick-field { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; }
.quick-field .form-input { height: var(--control-height-sm); padding: 0 var(--space-2-5); }
.quick .form-input { height: var(--control-height-sm); }
.meta-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2) var(--space-3); }
.check-row { display: flex; align-items: center; gap: var(--space-2); cursor: pointer; }
.check-row input { accent-color: var(--accent); }
.check-row input:disabled { cursor: not-allowed; }

/* Groups tab (js/groupspanel.js): the open presentation's groups, then the colors */
.group-title { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.group-bars { display: flex; flex-direction: column; gap: var(--space-1-5); }
.group-bars:empty, .group-chips:empty { display: none; }
.group-bar-row { display: flex; align-items: stretch; gap: var(--space-1); }
.group-bar {
  --label: var(--section-other);
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-width: 0;
  min-height: var(--group-bar-height);
  padding: 0 var(--space-2);
  border: 0;
  border-bottom: var(--group-bar-line) solid var(--label);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: var(--bg-input);
  color: var(--label);
  cursor: pointer;
  transition: background var(--duration-fast);
}
.group-bar:hover:not(:disabled) { background: var(--bg-hover); }
.group-bar:disabled { cursor: not-allowed; opacity: var(--opacity-disabled); }
.group-bar:focus-visible, .group-chip:focus-visible, .group-fold:focus-visible { outline: var(--focus-width) solid var(--accent); outline-offset: var(--focus-offset); }
.group-bar-name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: inherit; }
.group-bar.is-resting .group-bar-name { opacity: var(--opacity-disabled); }
.group-bar-count { flex: 0 0 auto; color: var(--text-muted); }
.group-block { display: flex; flex-direction: column; gap: var(--space-1-5); }
.group-chips { display: flex; flex-wrap: wrap; gap: var(--space-1-5); }
.group-chip {
  --label: var(--section-other);
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  height: var(--control-height-sm);
  padding: 0 var(--space-2);
  border: var(--border-width) solid var(--border-light);
  border-left: var(--ed-group-bar) solid var(--label);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text);
  cursor: pointer;
}
.group-chip:hover:not(:disabled) { background: var(--bg-hover); }
.group-chip:disabled { cursor: not-allowed; opacity: var(--opacity-disabled); }
.group-chip .icon-btn { width: var(--icon-md); height: var(--icon-md); }
.group-chip .icon-btn svg { width: var(--icon-sm); height: var(--icon-sm); }
.group-fold {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--space-1);
  padding: var(--space-2) 0 0;
  border: 0;
  border-top: var(--border-width) solid var(--border);
  background: transparent;
  cursor: pointer;
}
.group-fold svg { width: var(--icon-sm); height: var(--icon-sm); fill: none; stroke: var(--text-secondary); stroke-width: var(--icon-stroke); stroke-linecap: round; stroke-linejoin: round; transition: transform var(--duration-fast); }
.group-fold[aria-expanded="true"] svg { transform: rotate(90deg); }
.group-colors { display: flex; flex-direction: column; gap: var(--space-3); }
/* the colors (Groups tab, Colors) */
.group-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2) var(--space-3); }
.group-row { display: flex; align-items: center; gap: var(--space-2); min-width: 0; }
.group-row .group-name { flex: 1 1 auto; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.group-row .form-input { flex: 1 1 auto; min-width: 0; height: var(--control-height-sm); padding: 0 var(--space-2-5); }
.group-list { display: flex; flex-direction: column; gap: var(--space-2); }
.group-list:empty { display: none; }
.group-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); margin-top: var(--space-1); }
.group-add { display: flex; gap: var(--space-2); }
.group-add .form-input { flex: 1 1 auto; min-width: 0; height: var(--control-height-sm); padding: 0 var(--space-2-5); }
/* Text popover (js/textpanel.js): the words' look for a whole presentation.
   Compact, like ProPresenter's: 32px rows, 12/500 fields; Stroke is one row
   (on / off, width, color), Shadow one row and its four numbers under it. */
.popover.popover-text { width: var(--text-pop-width); padding: var(--space-3); }
.popover-text .form-input { height: var(--control-height-sm); padding: 0 var(--space-2); }
.popover-text .mini-seg-btn { height: calc(var(--control-height-sm) - var(--space-1-5)); padding: 0 var(--space-2); }
.tx-for { flex: 1 1 auto; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; text-align: right; }
.tx-body { display: flex; flex-direction: column; gap: var(--space-2); }
.tx-row { display: flex; align-items: center; gap: var(--space-2); }
.tx-row > .form-input { flex: 1 1 auto; min-width: 0; }
.tx-grow { flex: 1 1 auto; min-width: 0; }
.tx-seg { display: flex; }
.tx-seg .mini-seg-btn { flex: 1 1 0; display: grid; place-items: center; padding: 0; }
.tx-across { flex: 4 1 0; }
.tx-updown { flex: 3 1 0; }
.tx-seg svg { width: var(--tx-icon); height: var(--tx-icon); fill: none; stroke: currentColor; stroke-width: var(--icon-stroke); stroke-linecap: round; stroke-linejoin: round; }
/* Stroke / Shadow: a line above, then the name, On | Off and its settings */
.tx-part-row { padding-top: var(--space-2); border-top: var(--border-width) solid var(--border); }
.tx-part { display: flex; align-items: center; gap: var(--space-2); }
[data-tx-part].is-off { opacity: var(--opacity-disabled); }
.tx-fields { align-items: flex-start; }
.tx-field { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: stretch; gap: var(--space-half); text-align: center; }
.tx-foot { justify-content: space-between; }
.tx-reset { padding: 0; }
/* A number with up / down arrows (ProPresenter's stepper); the field can be typed in too */
.tx-step {
  flex: 0 0 auto;
  display: flex;
  align-items: stretch;
  width: var(--tx-step-width);
  height: var(--control-height-sm);
  border: var(--border-width) solid var(--border-light);
  border-radius: var(--radius-control);
  background: var(--bg-input);
  overflow: hidden;
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
}
.tx-field .tx-step { width: 100%; }
.tx-step:hover { border-color: var(--text-muted); }
.tx-step:focus-within { border-color: var(--accent); box-shadow: 0 0 0 var(--focus-ring) var(--accent-soft); }
.tx-step.is-disabled { opacity: var(--opacity-disabled); }
.popover-text .tx-step .form-input {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
  height: auto;
  padding: 0 0 0 var(--space-2);
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  -moz-appearance: textfield;
  appearance: textfield;
}
.tx-step .form-input::-webkit-inner-spin-button, .tx-step .form-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.tx-step-btns { flex: 0 0 var(--tx-step-btn); display: flex; flex-direction: column; border-left: var(--border-width) solid var(--border-light); }
.tx-step-btn { flex: 1 1 0; display: grid; place-items: center; padding: 0; border: 0; background: transparent; color: var(--text-secondary); cursor: pointer; touch-action: manipulation; }
.tx-step-btn + .tx-step-btn { border-top: var(--border-width) solid var(--border-light); }
.tx-step-btn:hover { background: var(--bg-hover); color: var(--text); }
.tx-step.is-disabled .tx-step-btn { cursor: not-allowed; }
.tx-step-btn svg { width: var(--icon-xs); height: var(--icon-xs); fill: none; stroke: currentColor; stroke-width: var(--icon-stroke); stroke-linecap: round; stroke-linejoin: round; }
/* (a part that's off dims as a whole: its fields don't dim again) */
.tx-step .form-input:disabled, [data-tx-part].is-off .tx-step.is-disabled, [data-tx-part].is-off .tx-color:disabled { opacity: 1; }
.group-color, .tx-color {
  flex: 0 0 auto;
  width: var(--group-swatch);
  height: var(--group-swatch);
  padding: 0;
  border: var(--border-width) solid var(--border-light);
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.tx-color { width: var(--tx-swatch-width); height: var(--control-height-sm); }
.group-color::-webkit-color-swatch-wrapper, .tx-color::-webkit-color-swatch-wrapper { padding: 0; }
.group-color::-webkit-color-swatch, .tx-color::-webkit-color-swatch { border: 0; border-radius: var(--radius-xs); }
.group-color::-moz-color-swatch, .tx-color::-moz-color-swatch { border: 0; border-radius: var(--radius-xs); }
.group-color:disabled, .tx-color:disabled { cursor: not-allowed; opacity: var(--opacity-disabled); }
.group-color:focus-visible { outline: var(--focus-width) solid var(--accent); outline-offset: var(--focus-offset); }
.side-text-btn:disabled { opacity: var(--opacity-disabled); cursor: not-allowed; }

/* ---- Slide grid (Show mode): dark in both themes, like ProPresenter ---- */
.deck {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  background: var(--deck-bg);
  overflow: hidden;
}
.deck-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--deck-head-height);
  padding: 0 var(--space-3) 0 var(--space-4);
  background: var(--deck-head-bg);
  border-bottom: var(--border-width) solid var(--border-light);
}
.deck-title { color: var(--text); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
/* room inside the clip for a name's hover tint (.name-btn), the title where it was */
.deck-title { padding: 0 var(--space-1); margin: 0 calc(-1 * var(--space-1)); }
.deck-meta { flex: 1 1 auto; white-space: nowrap; }
.deck-actions { display: flex; gap: var(--space-1); }
.icon-btn {
  display: grid;
  place-items: center;
  width: var(--control-height-sm);
  height: var(--control-height-sm);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: background var(--duration-fast);
}
.icon-btn:hover:not(:disabled) { background: var(--bg-hover); }
.icon-btn:disabled { opacity: var(--opacity-disabled); cursor: not-allowed; }
.icon-btn:focus-visible { outline: var(--focus-width) solid var(--accent); outline-offset: 1px; }
.icon-btn svg {
  width: var(--icon-md);
  height: var(--icon-md);
  fill: none;
  stroke: currentColor;
  stroke-width: var(--icon-stroke);
  stroke-linecap: round;
  stroke-linejoin: round;
}

.deck-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: var(--space-4);
  display: grid;
  /* --deck-cols across, each at least --thumb-floor (fewer across when they'd be smaller) */
  grid-template-columns: repeat(auto-fill, minmax(max(var(--thumb-floor), calc((100% - (var(--deck-cols) - 1) * var(--deck-gap)) / var(--deck-cols))), 1fr));
  align-content: start;
  gap: var(--deck-gap);
}
/* A service shows every item: its head (a raised band) before its slides; a
   Header (a divider) is an amber band of its own, with an amber edge */
.deck-item-head {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--control-height-sm);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--deck-item-head-bg);
}
.deck-item-head:not(:first-child) { margin-top: var(--space-2); }
.deck-item-title { color: var(--text); }
.deck-item-head.is-header {
  background: var(--header-bg);
  box-shadow: inset var(--header-line) 0 0 var(--header-tone);
}
.deck-item-head.is-header .deck-item-title { color: var(--header-text); font-weight: var(--weight-semibold); }
.deck-empty { grid-column: 1 / -1; color: var(--text-muted); font-size: var(--size-ui); padding: var(--space-1) var(--space-half); }

/* Show mode: the grid on top, the lower panel under it, the handle between */
.mode-show { display: flex; flex-direction: column; min-height: 0; }
.show-top { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }
.show-top > .deck, .show-top > .empty-state { flex: 1 1 auto; height: auto; min-height: 0; }

/* The bar under the grid */
.deck-bar {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-4);
  min-height: var(--deck-bar-height);
  padding: var(--space-1) var(--space-3) var(--space-1) var(--space-4);
  background: var(--deck-head-bg);
  border-top: var(--border-width) solid var(--border-light);
}
.bar-group { display: flex; align-items: center; gap: var(--space-2); }
.bar-spacer { flex: 1 1 auto; }
.bar-select { width: auto; height: var(--control-height-sm); padding: 0 var(--space-2); }
.bar-range { width: var(--bar-range-width); accent-color: var(--accent); cursor: pointer; }
.bar-range:disabled { opacity: var(--opacity-disabled); cursor: not-allowed; }
.bar-value { min-width: var(--bar-value-width); font-variant-numeric: tabular-nums; }
.bar-icon-btn { display: grid; place-items: center; color: inherit; }
.bar-icon-btn svg, .bar-zoom-icon {
  width: var(--icon-sm);
  height: var(--icon-sm);
  fill: none;
  stroke: currentColor;
  stroke-width: var(--icon-stroke);
  stroke-linecap: round;
  stroke-linejoin: round;
}
.bar-zoom-icon { color: var(--text-muted); }

/* List view: one row per slide, the section color down its left edge */
.deck-body.is-list { grid-template-columns: minmax(0, 1fr); gap: var(--space-1-5); }
/* The row is a plain block (a button) and its columns a grid span inside it:
   WebKit (Safari, every iPad browser) won't size a <button> grid by its
   lines, so a slide of several lines would overlap the next row. Nor does
   a row need the card's container sizing. */
.slide.slide-row {
  display: block;
  container-type: normal;
  min-height: var(--slide-label-height);
  padding: var(--space-2) var(--space-3);
  background: var(--bg-panel);
  box-shadow: inset var(--list-bar) 0 0 var(--label);
  color: var(--text);
}
.slide-row .slide-num { padding-left: var(--space-1); }
.slide-row .slide-name { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--text-secondary); }
.slide-row-grid {
  display: grid;
  grid-template-columns: var(--list-num-width) var(--list-name-width) minmax(0, 1fr);
  align-items: start;
  gap: var(--space-2);
}
.slide-row-text { white-space: pre-line; overflow-wrap: anywhere; line-height: var(--leading-body); }

/* The handle: drag (or ↑ ↓ when focused) to set the lower panel's height */
.split-handle {
  flex: 0 0 auto;
  position: relative;
  height: var(--split-handle);
  background: var(--deck-head-bg);
  border-top: var(--border-width) solid var(--border-light);
  cursor: row-resize;
  touch-action: none;
}
.split-handle::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: var(--split-grip);
  height: var(--border-width);
  transform: translate(-50%, -50%);
  background: var(--white-48);
}
.split-handle:hover, .split-handle.is-dragging { background: var(--bg-hover); }
.split-handle:focus-visible { outline: var(--focus-width) solid var(--accent); outline-offset: calc(var(--focus-width) * -1); }
.lower-panel {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  height: var(--lower-height);
  min-height: var(--lower-min);
  max-height: calc(100% - var(--show-top-min) - var(--deck-bar-height) - var(--split-handle)); /* the view above keeps its room */
  background: var(--bg-panel);
}
.lower-head { flex: 0 0 auto; border-bottom: var(--border-width) solid var(--border); }
/* Link: a picture or video by its link, one row under the head */
.media-link { flex: 0 0 auto; display: flex; gap: var(--space-2); padding: var(--space-2) var(--space-3); border-bottom: var(--border-width) solid var(--border); }
.media-link .form-input { flex: 1 1 auto; min-width: 0; height: var(--control-height-sm); }

/* One slide: the thumbnail + its colored label bar */
/* The section color lives on the whole slide (data-section / data-shade),
   so the label bar AND the live ring use it. Grey sections (scripture,
   text…) ring in the accent blue instead; a grey ring would barely show. */
.slide {
  --label: var(--section-other);
  --ring: var(--accent);
  container-type: inline-size;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 0;
  border: var(--slide-ring) solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
  transition: border-color var(--duration-fast);
  touch-action: manipulation;
}
.slide:hover:not(:disabled) { border-color: var(--border-light); }
.slide:focus-visible { outline: var(--focus-width) solid var(--ring); outline-offset: var(--focus-offset); }
.slide.is-live { border-color: var(--ring); }
.slide:disabled { cursor: default; }
.slide-screen {
  aspect-ratio: 16 / 9;
  display: grid;
  container-type: size;
  overflow: hidden;
  background: var(--screen-bg);
  border-radius: var(--radius-xs) var(--radius-xs) 0 0;
}
/* Thumbnails (grid, editor and Reflow lists): slide words at least
   --thumb-text-min (lib.js textSize reads --slide-text-min) */
.slide-screen, .ed-thumb { --slide-text-min: var(--thumb-text-min); }
/* A slide with no background of its own (theme background "none") */
.slide-screen.is-transparent, .swatch.is-transparent,
.slide-box.is-transparent, .ed-thumb.is-transparent {
  background-color: var(--checker-a);
  background-image: conic-gradient(var(--checker-b) 25%, var(--checker-a) 0 50%, var(--checker-b) 0 75%, var(--checker-a) 0);
  background-size: var(--checker-size) var(--checker-size);
}
.slide-label {
  display: flex;
  align-items: center;
  gap: var(--space-1-5);
  min-height: var(--slide-label-height);
  padding: 0 var(--space-2);
  color: var(--text-on-dark);
  background: var(--label);
  background: color-mix(in srgb, var(--label), var(--black) var(--shade, 0%));
  border-radius: 0 0 var(--radius-xs) var(--radius-xs);
  overflow: hidden;
  white-space: nowrap;
}
.slide-name { overflow: hidden; text-overflow: ellipsis; }
/* Picked for the Groups tab (Select slides, or Shift / ⌘-click): a white ring over the slide */
.slide { position: relative; }
.slide.is-picked::after {
  content: "";
  position: absolute;
  inset: 0;
  border: var(--pick-ring) solid var(--white-100);
  border-radius: var(--radius-xs);
  background: var(--pick-tint);
  pointer-events: none;
}
/* A picture / video from the media library held over the grid (controller.js
   "Pictures and videos as slides"): the slide it would take the place of
   (a Blank, a picture slide) is ringed in blue, else a see-through ghost of
   the new slide stands where it goes */
.slide.is-drop-target::after {
  content: "";
  position: absolute;
  inset: 0;
  border: var(--pick-ring) solid var(--accent);
  border-radius: var(--radius-xs);
  background: var(--accent-soft);
  pointer-events: none;
}
.slide.drop-ghost { border-color: var(--accent); opacity: var(--opacity-busy); cursor: copy; }
.detail-row.is-drop-target { background: var(--accent-soft); box-shadow: inset 0 0 0 var(--focus-width) var(--accent); }
.detail-row.is-drop-after { box-shadow: inset 0 calc(-1 * var(--focus-width)) 0 var(--accent); }
.detail-list.is-drop-target { background: var(--accent-soft); }
/* Renaming (controller.js "renaming"): a name a click edits reads as text
   until hovered; then it's a field for a moment (a row keeps its icon) */
/* Its hover tint reaches --space-1 past the words each side (the padding),
   while the words stay in line with the text around (the margins take it
   back). The widest it gets counts that back in: else the words lose the
   padding's room and every name ends in "…". */
.name-btn {
  max-width: calc(100% + 2 * var(--space-1));
  padding: 0 var(--space-1);
  margin: 0 calc(-1 * var(--space-1));
  border: 0;
  border-radius: var(--radius-xs);
  background: transparent;
  color: inherit;
  letter-spacing: inherit; /* (the font: the base rule; a text style on it, e.g. .deck-item-title, wins) */
  text-align: left;
  cursor: text;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  transition: background var(--duration-fast);
}
.name-btn:hover { background: var(--bg-hover); }
.name-btn:focus-visible { outline: var(--focus-width) solid var(--accent); outline-offset: calc(-1 * var(--focus-width)); } /* inside: the title clips what's outside */
.form-input.deck-title-input, .form-input.deck-item-input { width: var(--name-field-width); max-width: 100%; }
.form-input.deck-item-input { height: var(--control-height-sm); }
/* the words stay where they were while they're a field (its padding taken back, like .name-btn) */
.form-input.deck-title-input {
  height: auto;
  max-width: calc(100% + 2 * var(--space-1));
  margin: 0 calc(-1 * var(--space-1));
  padding: var(--space-half) var(--space-1);
}
.detail-row.is-renaming { cursor: default; -webkit-user-select: text; user-select: text; }
.detail-row.is-renaming:hover { background: transparent; }
.detail-name-input { flex: 1 1 auto; min-width: 0; height: var(--control-height-sm); }
.slide[data-section="verse"] { --label: var(--section-verse); }
.slide[data-section="prechorus"] { --label: var(--section-prechorus); }
.slide[data-section="chorus"] { --label: var(--section-chorus); }
.slide[data-section="bridge"] { --label: var(--section-bridge); }
.slide[data-section="tag"] { --label: var(--section-tag); }
.slide[data-section="intro"] { --label: var(--section-intro); }
.slide[data-section="outro"] { --label: var(--section-outro); }
.slide[data-section="interlude"] { --label: var(--section-interlude); }
/* (a church's own group: lib.js tintGroup sets --label: var(--group-<id>) on the slide) */
.slide[data-shade="1"] { --shade: var(--section-shade-1); }
.slide[data-shade="2"] { --shade: var(--section-shade-2); }
.slide[data-shade="3"] { --shade: var(--section-shade-3); }
/* Named sections: the ring is the label's own (shaded) color */
.slide[data-section]:not([data-section="other"]) {
  --ring: var(--label);
  --ring: color-mix(in srgb, var(--label), var(--black) var(--shade, 0%));
}

/* ---- Popovers (under toolbar buttons) ---- */
.popover {
  position: fixed;
  z-index: var(--z-popover);
  width: var(--popover-width);
  max-width: calc(100vw - var(--space-4));
  max-height: var(--popover-max-height);
  overflow: auto;
  padding: var(--space-5);
  background: var(--bg-card);
  border: var(--border-width) solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: vx-fade var(--duration-fast) ease-out;
}
.pop-title { margin-bottom: var(--space-1); }
.pop-title:not(:first-child) { margin-top: var(--space-6); }
.pop-sub { margin-bottom: var(--space-4); }
.pop-note { margin-top: var(--space-3); }
.pop-list { display: flex; flex-direction: column; margin-top: var(--space-2); }
.pop-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--row-height);
  padding: var(--space-1-5) var(--space-half);
  border-bottom: var(--border-width) solid var(--border);
}
.pop-item:last-child { border-bottom: 0; }
.pop-item-btn {
  width: 100%;
  background: none;
  border-width: 0 0 var(--border-width);
  border-style: solid;
  border-color: var(--border);
  border-radius: var(--radius-sm);
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: background var(--duration-fast);
}
.pop-item-btn:hover { background: var(--bg-elevated); }
.pop-item-btn:focus-visible { outline: var(--focus-width) solid var(--accent); outline-offset: -2px; }
.pop-item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pop-item-title, .pop-item-meta { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.pop-empty { padding: var(--space-2-5) var(--space-half); color: var(--text-muted); }
.pop-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); }
.pop-row { display: flex; gap: var(--space-2); }
.pop-row .form-input { flex: 1; min-width: 0; }
.pop-wide { width: 100%; margin-top: var(--space-2); }
.theme-item { gap: var(--space-3); }
/* The theme button's picker (controller.js renderLook): tiles like the Bible templates */
.popover-look { width: var(--popover-look-width); }
.look-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--look-tile-min), 1fr)); gap: var(--space-2); max-height: var(--look-grid-max); overflow: auto; margin-top: var(--space-2); }
/* a suite open on its own: ‹ on the left, its name in the very middle (the third column balances the first) */
.look-suite-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: var(--space-2); margin-bottom: var(--space-1); }
.look-suite-head .icon-btn { justify-self: start; }
.look-suite-title { margin-bottom: 0; text-align: center; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.deck-item-head .look-btn, .deck-item-head .words-btn { margin-left: auto; }
.deck-item-head .words-btn + .look-btn { margin-left: 0; }
.theme-thumb { flex: 0 0 auto; width: var(--theme-thumb-width); border-radius: var(--radius-xs); --slide-text-min: 0px; } /* exact scale */
.theme-group { padding: var(--space-3) 0 var(--space-1); }
.theme-group:first-child { padding-top: 0; }
.swatch {
  flex: 0 0 auto;
  width: var(--swatch-width);
  height: var(--swatch-height);
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  border: var(--border-width) solid var(--border-light);
  font-size: var(--size-label);
  font-weight: var(--weight-semibold);
}
/* Add another screen: the pairing code, big */
.pair-code-big {
  font-size: var(--size-pair-code);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-code);
  text-align: center;
  color: var(--text);
}
/* Screens: like a computer's display settings */
.popover-screens { width: var(--popover-screens-width); }
/* The tutorial: the checklist (a popover) and a step's card + ring (js/tutorial.js) */
.popover-tutorial { width: var(--popover-tutorial-width); }
.tutorial-blurb { white-space: normal; }
.tour-card {
  position: fixed;
  z-index: var(--z-tour);
  width: min(var(--tour-card-width), calc(100vw - var(--space-4)));
  padding: var(--space-4);
  background: var(--bg-card);
  border: var(--border-width) solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}
.tour-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.tour-title { margin-top: var(--space-1); }
.tour-text { margin-top: var(--space-1-5); }
.tour-actions { display: flex; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-3); }
.tour-actions:empty { display: none; }
/* The lit area: its shadow (as big as any screen) is the dark around it. It never
   takes a tap, so the page under the dark still works. */
.tour-ring {
  position: fixed;
  z-index: var(--z-tour);
  pointer-events: none;
  border: var(--tour-ring-width) solid var(--accent);
  border-radius: var(--radius-control);
  box-shadow: 0 0 0 var(--focus-ring) var(--accent-soft), 0 0 0 100vmax var(--tour-dim);
}
.tour-ring.is-empty { border-color: transparent; box-shadow: 0 0 0 100vmax var(--tour-dim); } /* nothing to light: all dark */
.pop-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-1); }
.pop-head .pop-title { margin-bottom: 0; }
.screens-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(var(--screens-col-min), 100%), 1fr));
  gap: var(--space-5) var(--space-6);
}
.screens-group { min-width: 0; }
.screens-hint { margin-top: var(--space-1); }
.screens-connect { padding: var(--space-1) var(--space-half) var(--space-2); }
.screens-foot .screens-hint { flex: 1 1 var(--screens-col-min); margin-top: 0; }
.screen-row .row-tools { align-items: center; }
/* An offline screen in the list is just off, not an error: grey ring (the toolbar lights stay red) */
.screen-row .small-light:not(.on)::before { border-color: var(--text-muted); }
.screens-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3) var(--space-5);
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: var(--border-width) solid var(--border);
}
.pair-inline { display: flex; align-items: center; gap: var(--space-4); flex: 1 1 var(--screens-col-min); min-width: 0; }
.pair-inline .pop-note { margin-top: 0; }
.screens-label { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-2); }
.screen-row { flex-wrap: wrap; gap: var(--space-2) var(--space-2-5); }
.screen-row .pop-item-main { flex: 1 1 var(--screen-name-min); }
/* Rename: the name becomes a field in place (Enter saves, Esc keeps it) */
.screen-row .screen-name-input { height: var(--control-height-sm); }
.mini-seg {
  display: inline-flex;
  flex: 0 0 auto;
  gap: var(--space-half);
  padding: var(--space-half);
  border: var(--border-width) solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-input);
}
.mini-seg-btn {
  height: var(--mini-seg-height);
  padding: 0 var(--space-2-5);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  transition: background var(--duration-fast);
}
.mini-seg-btn:hover:not(:disabled):not(.is-on) { background: var(--bg-hover); }
.mini-seg-btn.is-on { background: var(--accent); color: var(--text-on-accent); }
/* The bar's icons: red = on the screens / playing (like the layer buttons) */
.bar-icon-btn.is-live:not(.is-on) { color: var(--dark-danger); }
.bar-icon-btn.is-live.is-on { background: var(--live); }
.bar-tools { gap: var(--space-1); }
.bar-tools .bar-icon-btn { border-radius: var(--radius-sm); }
.mini-seg-btn:focus-visible { outline: var(--focus-width) solid var(--accent); outline-offset: var(--focus-offset); }
.mini-seg-btn:disabled { opacity: var(--opacity-disabled); cursor: not-allowed; }
.status-head { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-3); }
.status-meta { min-width: 0; }
.status-church { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.status-who { margin-bottom: var(--space-2); }
.pop-version { margin-top: var(--space-3); text-align: center; }

/* ---- New presentation (controller.js openNewSheet): ProPresenter's New window, plus the words ---- */
.sheet.sheet-new { max-width: var(--sheet-new-width); }
/* two columns: the settings on the left, the words filling the right */
.new-columns {
  display: grid;
  grid-template-columns: minmax(0, var(--new-settings-width)) minmax(0, 1fr);
  gap: var(--space-6);
  align-items: stretch;
}
.new-columns > .new-grid { align-self: start; }
.new-words-label { margin: 0; }
/* the words box: a see-through textarea over a backdrop tinting the [Group] lines (like Reflow's) */
.new-code {
  position: relative;
  flex: 1 1 auto;
  min-height: var(--new-lyrics-min);
  border: var(--border-width) solid var(--border-light);
  border-radius: var(--radius-control);
  background: var(--bg-input);
  overflow: hidden;
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
}
.new-code:hover { border-color: var(--text-muted); }
.new-code:focus-within { border-color: var(--accent); box-shadow: 0 0 0 var(--focus-ring) var(--accent-soft); }
.new-backdrop, .new-lyrics-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: var(--input-pad-y) var(--input-pad-x) var(--input-pad-y) calc(var(--input-pad-x) + var(--space-2));
  border: 0;
  border-radius: 0;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: normal;
  overflow-x: hidden;
  overflow-y: scroll;
}
.new-backdrop { color: transparent; pointer-events: none; }
.new-lyrics-input { background: transparent; color: var(--text); caret-color: var(--accent); resize: none; outline: none; }
.new-lyrics-input::placeholder { color: var(--text-placeholder); }
/* a phone or an iPad held upright: the words under the settings */
@media (max-width: 860px) {
  .new-columns { grid-template-columns: minmax(0, 1fr); }
  /* Search's columns, one under the other; a song tapped online takes the whole width (× goes back) */
  .search-columns, .search-columns.is-browsing, .search-columns.is-browsing.is-previewing { grid-template-columns: minmax(0, 1fr); }
  .search-columns.is-previewing #search-col-shared { display: none; }
  /* the box on its own line, the buttons under it */
  .search-head { flex-wrap: wrap; }
  .search-head .form-input { flex-basis: 100%; }
}
.new-heading { margin-bottom: var(--space-5); }
.new-grid {
  display: grid;
  grid-template-columns: var(--new-label-width) minmax(0, 1fr);
  align-items: center;
  gap: var(--space-2-5) var(--space-3);
}
.new-grid > .new-label { text-align: right; }
.new-theme-btn {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-1-5) var(--input-pad-x) var(--space-1-5) var(--space-1-5);
  border: var(--border-width) solid var(--border-light);
  border-radius: var(--radius-control);
  background: var(--bg-input);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color var(--duration-fast);
}
.new-theme-btn:hover { border-color: var(--text-muted); }
.new-theme-btn[aria-expanded="true"] { border-color: var(--accent); }
.new-theme-btn:focus-visible { outline: var(--focus-width) solid var(--accent); outline-offset: var(--focus-offset); }
.new-theme-thumb { flex: 0 0 auto; display: flex; }
.new-theme-name { flex: 1 1 auto; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.new-chevron { flex: 0 0 auto; width: var(--icon-sm); height: var(--icon-sm); fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform var(--duration-fast); }
.new-theme-btn[aria-expanded="true"] .new-chevron { transform: rotate(180deg); }
.new-themes {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--look-tile-min), 1fr));
  gap: var(--space-2);
  max-height: var(--new-themes-max);
  overflow: auto;
  padding: var(--space-2);
  border: var(--border-width) solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-panel);
}
.new-themes > .section-label { grid-column: 1 / -1; padding-top: var(--space-1); }
.new-words { display: flex; flex-direction: column; gap: var(--space-2); min-width: 0; }
/* the words in steps: Search (churches) for the Name, then a lyrics site, typing them last (folded, muted) */
.new-find {
  display: grid;
  gap: var(--space-2);
  padding: var(--space-3);
  border: var(--border-width) solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
}
.new-find-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.new-found { max-height: var(--new-found-max); overflow-y: auto; }
.new-found-item.is-on { background: var(--bg-hover); border-radius: var(--radius-sm); }
.new-web { display: grid; gap: var(--space-2); }
.new-manual-toggle {
  align-self: flex-start;
  padding: 0;
  background: none;
  border: 0;
  color: var(--text-muted);
  text-decoration: underline;
  text-underline-offset: var(--underline-offset);
  cursor: pointer;
}
.new-manual-toggle:hover { color: var(--text); }
.new-manual { display: flex; flex-direction: column; gap: var(--space-2); flex: 1 1 auto; min-height: 0; }
.new-link { display: flex; gap: var(--space-2); }
.new-link .form-input { flex: 1 1 auto; min-width: 0; }
.new-link .btn { flex: 0 0 auto; }
.new-hint:empty { display: none; }
.new-hint.is-error { color: var(--danger); }
.sheet-foot { display: flex; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-5); }

/* ---- Quick words: the words as code (the { } in the grid's header) ----
   Like Reflow's text: a see-through textarea over a backdrop that tints the
   [Group] lines in their group's color (same text, same wrapping, same
   scroll). The box scrolls; the title and Save stay put. */
.popover-words { width: var(--popover-words-width); display: flex; flex-direction: column; overflow: hidden; }
.words-form { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.words-code {
  position: relative;
  flex: 1 1 var(--words-code-height);
  height: var(--words-code-height);
  min-height: var(--words-code-min);
  border: var(--border-width) solid var(--border-light);
  border-radius: var(--radius-control);
  background: var(--bg-input);
  overflow: hidden;
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
}
.words-code:focus-within { border-color: var(--accent); box-shadow: 0 0 0 var(--focus-ring) var(--accent-soft); }
.words-backdrop, .words-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: var(--space-2) var(--space-3) var(--space-2) var(--space-4);
  border: 0;
  border-radius: 0;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: normal;
  overflow-x: hidden;
  overflow-y: scroll;
}
.words-backdrop { color: transparent; pointer-events: none; }
.words-input { background: transparent; color: var(--text); caret-color: var(--accent); resize: none; outline: none; }
.words-status { margin-top: var(--space-2); }
.words-status.is-error { color: var(--danger); }
.pop-actions { display: flex; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-3); }

/* A hover label (lib.js initTips): under the icon, never in the way of the pointer */
.tip {
  position: fixed;
  z-index: var(--z-tip);
  max-width: var(--tip-max);
  padding: var(--space-1) var(--space-2);
  border: var(--border-width) solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-lg);
  pointer-events: none;
  animation: vx-fade var(--duration-fast) ease-out;
}

/* Wide popovers and the "+" menu */
.popover-wide { width: var(--popover-wide-width); }
.popover-menu { width: auto; min-width: var(--popover-menu-min); padding: var(--space-1-5); }
.menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-height: var(--menu-row-height);
  padding: var(--space-1) var(--space-2-5);
  font-size: var(--size-body);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: background var(--duration-fast);
}
.menu-item:hover:not(:disabled), .menu-item:focus-visible { background: var(--accent); color: var(--text-on-accent); outline: none; }
.menu-item:hover:not(:disabled) .menu-hint,
.menu-item:hover:not(:disabled) .row-hint { color: var(--text-on-accent); }
.menu-item:disabled { opacity: var(--opacity-disabled); cursor: not-allowed; }
.menu-item.is-danger { color: var(--danger); }
.menu-item.is-danger:hover:not(:disabled), .menu-item.is-danger:focus-visible { background: var(--danger); color: var(--text-on-accent); }
.menu-main { flex: 1 1 auto; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.menu-hint { flex: 0 0 auto; font-size: var(--size-small); color: var(--text-muted); }
.menu-chevron { flex: 0 0 auto; width: var(--icon-sm); height: var(--icon-sm); fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.menu-back .menu-main { font-weight: var(--weight-semibold); }
.menu-sep { margin: var(--space-1) var(--space-2); border: 0; border-top: var(--border-width) solid var(--border-light); }
#template-list { max-height: var(--add-results-height); overflow: auto; }
.lyrics-input { min-height: var(--lyrics-rows-height); font-family: var(--font-sans); }
/* Add to playlist: compact, two columns */
.popover-add { width: var(--popover-add-width); padding: var(--space-4); }
.add-title { margin-bottom: var(--space-3); }
.add-columns { display: grid; grid-template-columns: minmax(0, 1fr) var(--add-side-width); gap: var(--space-4); }
.add-main { min-width: 0; }
.add-search { height: var(--control-height-sm); }
.add-results { max-height: var(--add-results-height); overflow: auto; margin-top: var(--space-1); }
.add-results .pop-item { min-height: var(--sidebar-row-height); padding: var(--space-1) var(--space-half); gap: var(--space-2-5); }
.add-side {
  display: flex;
  flex-direction: column;
  gap: var(--space-half);
  padding-left: var(--space-4);
  border-left: var(--border-width) solid var(--border);
}
.add-side .section-label { margin-bottom: var(--space-1); }
.add-kind {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  min-height: var(--sidebar-row-height);
  padding: 0 var(--space-2);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-size: var(--size-body);
  text-align: left;
  cursor: pointer;
  transition: background var(--duration-fast);
}
.add-kind:hover { background: var(--bg-elevated); }
.add-kind.is-active { background: var(--accent-soft); color: var(--accent-text); }
.add-kind:focus-visible { outline: var(--focus-width) solid var(--accent); outline-offset: -2px; }
.add-kind svg { flex: 0 0 auto; width: var(--icon-sm); height: var(--icon-sm); fill: none; stroke: currentColor; stroke-width: var(--icon-stroke); stroke-linecap: round; stroke-linejoin: round; color: var(--text-muted); }
.add-kind.is-active svg { color: currentColor; }
.add-form { display: flex; flex-direction: column; gap: var(--space-2); margin-top: var(--space-2); }
.add-form .form-group { margin-bottom: 0; }
.add-form .form-input:not(textarea) { height: var(--control-height-sm); }
.add-form textarea.form-input { min-height: calc(var(--control-height) * 1.6); }
.add-form .btn { width: 100%; }
.add-note { margin-top: var(--space-3); }
@media (max-width: 600px) { /* phones: one column */
  .add-columns { grid-template-columns: minmax(0, 1fr); }
  .add-side { padding-left: 0; border-left: 0; border-top: var(--border-width) solid var(--border); padding-top: var(--space-3); }
}

/* Left panel: Edit toggle + move / remove tools on service items */
.side-text-btn {
  height: calc(var(--sidebar-row-height) - var(--space-2));
  padding: 0 var(--space-2);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--accent-text);
  font-size: var(--size-ui);
  font-weight: var(--weight-medium);
  cursor: pointer;
}
.side-text-btn:hover { background: var(--bg-hover); }
.side-text-btn[aria-pressed="true"] { background: var(--accent); color: var(--text-on-accent); }
.row-tools { display: flex; gap: var(--space-half); flex: 0 0 auto; }
.tool-btn {
  display: grid;
  place-items: center;
  width: var(--tool-btn);
  height: var(--tool-btn);
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  cursor: pointer;
}
.tool-btn:hover:not(:disabled) { background: var(--bg-hover); }
.tool-btn:disabled { opacity: var(--opacity-disabled); cursor: not-allowed; }
.tool-btn.is-danger { color: var(--danger); }
.tool-btn svg { width: var(--icon-sm); height: var(--icon-sm); fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.detail-list.is-editing .detail-row { cursor: default; }
/* Moving a playlist's items (controller.js): any row drags (Edit's grip at once:
   touch-action none, the list doesn't scroll under the finger). A copy of the
   row lifts off and follows the pointer; the slot it left stays, faded; a blue
   line with a ring says where it lands (the slot lights up instead when it
   would land where it is). Nothing else moves until it's let go. */
.row-grip { cursor: grab; touch-action: none; color: var(--text-muted); }
.row-grip svg { stroke-width: var(--grip-dot); }
body.is-reordering, body.is-reordering * { cursor: grabbing; user-select: none; -webkit-user-select: none; }
.detail-row.is-drag-source { background: var(--bg-hover); }
.detail-row.is-drag-source > * { opacity: var(--drag-source-opacity); }
.detail-row.is-drag-source.is-drop-home { background: var(--accent-soft); box-shadow: inset 0 0 0 var(--focus-width) var(--accent); }
.drag-lift {
  position: fixed;
  z-index: var(--z-drag);
  margin: 0;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-lg), 0 0 0 var(--focus-width) var(--accent);
  transform: scale(var(--drag-lift-scale));
  pointer-events: none;
}
.drag-lift:hover { background: var(--bg-elevated); }
.drop-line {
  position: fixed;
  z-index: var(--z-drag);
  box-sizing: border-box;
  height: var(--drop-line-width);
  margin-top: calc(var(--drop-line-width) / -2);
  border-inline: var(--space-3) solid transparent; /* in line with the rows' words */
  background: var(--accent);
  background-clip: content-box;
  pointer-events: none;
}
.drop-line::before {
  content: "";
  position: absolute;
  left: calc(var(--drop-dot) / -2);
  top: 50%;
  width: var(--drop-dot);
  height: var(--drop-dot);
  box-sizing: border-box;
  border: var(--drop-line-width) solid var(--accent);
  border-radius: 50%;
  background: var(--items-bg); /* the items list's own tone: a ring, not a dot */
  transform: translateY(-50%);
}
/* Edit: "Delete this playlist / library…" under the list */
.detail-delete { display: block; width: calc(100% - var(--space-3) * 2); margin: var(--space-3); }
.detail-list.is-editing .detail-row:not(.is-header):hover { background: transparent; }

/* ---- Editor (Edit mode, js/editor.js) ---- */
/* Edit takes the whole width: no library panel, no live column */
.workspace.is-editing { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); grid-template-areas: "main"; }
.workspace.is-editing .sidebar, .workspace.is-editing .preview-col { display: none; }
.workspace.is-editing .mode-area { overflow: hidden; }
.editor {
  display: grid;
  grid-template-columns: var(--ed-nav-width) minmax(0, 1fr) var(--ed-inspector-width);
  height: 100%;
  min-height: 0;
}

/* Left: slides by section, then the objects */
.ed-nav {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg-panel);
  border-right: var(--border-width) solid var(--border-light);
}
.ed-nav-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-2); padding: var(--space-3); }
.ed-title { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.ed-slides { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 0 var(--space-3) var(--space-3); }
.ed-group {
  margin: var(--space-3) 0 var(--space-1-5);
  padding-left: var(--space-2);
  border-left: var(--ed-group-bar) solid var(--label, var(--section-other));
}
.ed-group[data-section="verse"], .rf-mark[data-section="verse"],
.group-bar[data-section="verse"], .group-chip[data-section="verse"] { --label: var(--section-verse); }
.ed-group[data-section="prechorus"], .rf-mark[data-section="prechorus"],
.group-bar[data-section="prechorus"], .group-chip[data-section="prechorus"] { --label: var(--section-prechorus); }
.ed-group[data-section="chorus"], .rf-mark[data-section="chorus"],
.group-bar[data-section="chorus"], .group-chip[data-section="chorus"] { --label: var(--section-chorus); }
.ed-group[data-section="bridge"], .rf-mark[data-section="bridge"],
.group-bar[data-section="bridge"], .group-chip[data-section="bridge"] { --label: var(--section-bridge); }
.ed-group[data-section="tag"], .rf-mark[data-section="tag"],
.group-bar[data-section="tag"], .group-chip[data-section="tag"] { --label: var(--section-tag); }
.ed-group[data-section="intro"], .rf-mark[data-section="intro"],
.group-bar[data-section="intro"], .group-chip[data-section="intro"] { --label: var(--section-intro); }
.ed-group[data-section="outro"], .rf-mark[data-section="outro"],
.group-bar[data-section="outro"], .group-chip[data-section="outro"] { --label: var(--section-outro); }
.ed-group[data-section="interlude"], .rf-mark[data-section="interlude"],
.group-bar[data-section="interlude"], .group-chip[data-section="interlude"] { --label: var(--section-interlude); }
.ed-slide {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  width: 100%;
  margin-bottom: var(--space-2);
  padding: 0;
  border: var(--slide-ring) solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.ed-slide.is-selected { border-color: var(--accent); }
.ed-slide:focus-visible { outline: var(--focus-width) solid var(--accent); outline-offset: var(--focus-offset); }
.ed-thumb { aspect-ratio: 16 / 9; display: grid; container-type: size; overflow: hidden; background: var(--screen-bg); }
.ed-objects { flex: 0 0 auto; max-height: 38%; display: flex; flex-direction: column; border-top: var(--border-width) solid var(--border-light); }
.ed-objects .side-head { padding: var(--space-2) var(--space-3); }
.ed-object-list { overflow: auto; padding: 0 var(--space-1-5) var(--space-2); }
.ed-object {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  min-height: var(--sidebar-row-height);
  padding: 0 var(--space-2);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.ed-object:hover { background: var(--bg-hover); }
.ed-object.is-selected { background: var(--accent); color: var(--text-on-accent); }
.ed-object.is-selected .row-hint, .ed-object.is-selected .ed-object-name { color: var(--text-on-accent); }
.ed-object svg { flex: 0 0 auto; width: var(--icon-sm); height: var(--icon-sm); fill: none; stroke: currentColor; stroke-width: var(--icon-stroke); stroke-linecap: round; stroke-linejoin: round; }
.ed-object-name { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* Middle: tools, rulers, the slide */
.ed-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg-elevated); }
.ed-tools {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  min-height: var(--ed-tool-height);
  padding: 0 var(--space-3);
  background: var(--bg-panel);
  border-bottom: var(--border-width) solid var(--border-light);
}
.ed-tools .tb-sep { height: var(--icon-md); margin: 0 var(--space-2); }
.ed-tools-spacer { flex: 1; }
.ed-tool {
  display: flex;
  align-items: center;
  gap: var(--space-1-5);
  height: var(--control-height-sm);
  padding: 0 var(--space-2-5);
  border: 0;
  border-radius: var(--radius-control);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.ed-tool:hover:not(:disabled), .ed-tool.is-open { background: var(--bg-hover); }
.ed-tool:disabled { opacity: var(--opacity-disabled); cursor: not-allowed; }
.ed-tool svg { width: var(--icon-md); height: var(--icon-md); fill: none; stroke: currentColor; stroke-width: var(--icon-stroke); stroke-linecap: round; stroke-linejoin: round; }
.ed-tool .ed-caret { width: var(--icon-sm); height: var(--icon-sm); }
.ed-stage {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--ed-ruler) minmax(0, 1fr);
  grid-template-rows: var(--ed-ruler) minmax(0, 1fr);
}
.ed-corner, .ed-ruler { background: var(--bg-panel); }
.ed-ruler { position: relative; overflow: hidden; }
.ed-ruler-x { border-bottom: var(--border-width) solid var(--border-light); }
.ed-ruler-y { border-right: var(--border-width) solid var(--border-light); }
.ed-tick { position: absolute; color: var(--text-muted); white-space: nowrap; }
.ed-ruler-x .ed-tick { top: 0; bottom: 0; border-left: var(--border-width) solid var(--border-light); padding-left: var(--space-half); }
.ed-ruler-x .ed-tick:not(.is-major) { top: 60%; }
.ed-ruler-y .ed-tick { left: 0; right: 0; border-top: var(--border-width) solid var(--border-light); padding-top: var(--space-half); writing-mode: vertical-rl; transform: rotate(180deg); }
.ed-ruler-y .ed-tick:not(.is-major) { left: 60%; }
.ed-canvas {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  padding: var(--ed-canvas-pad);
  container-type: size;
  overflow: hidden;
}
.ed-canvas > .slide-box, .ed-canvas > .ed-overlay { grid-area: 1 / 1; box-shadow: var(--shadow-lg); }
.ed-overlay {
  position: relative;
  place-self: center;
  width: 100%;
  aspect-ratio: var(--slide-ar, 16 / 9);
  pointer-events: none;
  box-shadow: none;
}
@supports (width: 1cqh) {
  .ed-overlay { width: min(100cqw, calc(100cqh * (var(--slide-ar-n, 1.7778)))); }
}
.ed-canvas > .ed-overlay { box-shadow: none; }
.slide-box.is-editing { background-color: var(--screen-bg); }
.slide-box.is-editing .obj { cursor: move; outline: var(--border-width) solid var(--white-12); outline-offset: calc(var(--border-width) * -1); }
.slide-box.is-editing .obj.is-selected { outline-color: transparent; }
.slide-box.is-editing .obj-words.is-typing { cursor: text; outline: none; -webkit-user-select: text; user-select: text; }
.ed-sel {
  position: absolute;
  pointer-events: auto;
  cursor: move;
  outline: var(--ed-sel-line) solid var(--accent);
}
.ed-handle {
  position: absolute;
  width: var(--ed-handle);
  height: var(--ed-handle);
  margin: calc(var(--ed-handle) / -2) 0 0 calc(var(--ed-handle) / -2);
  background: var(--white-100);
  border: var(--ed-sel-line) solid var(--accent);
  border-radius: var(--radius-xs);
}
.h-nw { left: 0; top: 0; cursor: nwse-resize; }
.h-n { left: 50%; top: 0; cursor: ns-resize; }
.h-ne { left: 100%; top: 0; cursor: nesw-resize; }
.h-e { left: 100%; top: 50%; cursor: ew-resize; }
.h-se { left: 100%; top: 100%; cursor: nwse-resize; }
.h-s { left: 50%; top: 100%; cursor: ns-resize; }
.h-sw { left: 0; top: 100%; cursor: nesw-resize; }
.h-w { left: 0; top: 50%; cursor: ew-resize; }

/* Right: the inspector */
.ed-inspector {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg-panel);
  border-left: var(--border-width) solid var(--border-light);
}
.ed-tabs { display: flex; border-bottom: var(--border-width) solid var(--border-light); }
.ed-tab {
  flex: 1 1 0;
  height: var(--ed-tab-height);
  border: 0;
  background: transparent;
  cursor: pointer;
}
.ed-tab + .ed-tab { border-left: var(--border-width) solid var(--border); }
.ed-tab:hover:not(.is-active) { background: var(--bg-hover); }
.ed-tab.is-active { background: var(--accent); color: var(--text-on-accent); }
.ed-panel { flex: 1; min-height: 0; overflow: auto; padding: var(--space-2) var(--space-3) var(--space-4); }
.ed-section { padding: var(--space-3) 0; border-bottom: var(--border-width) solid var(--border); }
.ed-section:last-child { border-bottom: 0; }
.ed-group-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); min-height: var(--control-height-sm); }
.ed-switch { display: flex; align-items: center; gap: var(--space-2); cursor: pointer; }
.ed-switch input, .check-row input { accent-color: var(--accent); }
.ed-section.is-off .ed-group-title { color: var(--text-secondary); }
.ed-group-body { display: flex; flex-direction: column; gap: var(--space-2); margin-top: var(--space-2); }
.ed-row { display: flex; align-items: flex-start; gap: var(--space-2); min-width: 0; }
.ed-label { flex: 0 0 var(--ed-label-width); padding-top: var(--space-2); }
.ed-controls { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--space-1-5); }
.ed-controls > .form-input, .ed-controls > .ed-select, .ed-controls > .ed-textarea, .ed-controls > .ed-range { flex: 1 1 100%; min-width: 0; }
.ed-panel .form-input { height: var(--control-height-sm); padding: 0 var(--space-2); }
.ed-panel textarea.form-input { height: auto; min-height: calc(var(--control-height) * 2); padding: var(--space-2); resize: vertical; }
.ed-num-field { display: flex; flex-direction: column; align-items: center; gap: var(--space-half); }
.ed-num-wrap { position: relative; display: flex; align-items: center; }
.ed-num { width: var(--ed-num-width); }
.ed-suffix { margin-left: var(--space-1); }
.ed-color {
  width: var(--ed-color-width);
  height: var(--control-height-sm);
  padding: var(--space-half);
  border: var(--border-width) solid var(--border-light);
  border-radius: var(--radius-control);
  background: var(--bg-input);
  cursor: pointer;
}
.ed-range { accent-color: var(--accent); height: var(--control-height-sm); }
.ed-seg { display: flex; flex: 1 1 100%; }
.ed-seg .mini-seg-btn { flex: 1 1 0; display: grid; place-items: center; }
.ed-seg svg, .ed-toggle svg, .ed-icon-btn svg { width: var(--icon-sm); height: var(--icon-sm); fill: none; stroke: currentColor; stroke-width: var(--icon-stroke); stroke-linecap: round; stroke-linejoin: round; }
.ed-toggle, .ed-icon-btn {
  display: grid;
  place-items: center;
  min-width: var(--control-height-sm);
  height: var(--control-height-sm);
  padding: 0 var(--space-2);
  border: var(--border-width) solid var(--border-light);
  border-radius: var(--radius-control);
  background: var(--bg-input);
  color: var(--text);
  cursor: pointer;
}
.ed-toggle:hover:not(:disabled):not(.is-on), .ed-icon-btn:hover:not(:disabled) { background: var(--bg-hover); }
.ed-toggle.is-on { background: var(--accent); border-color: var(--accent); color: var(--text-on-accent); }
.ed-toggle:disabled, .ed-icon-btn:disabled { opacity: var(--opacity-disabled); cursor: not-allowed; }
.ed-b { font-weight: var(--weight-semibold); }
.ed-i { font-style: italic; }
.ed-u { text-decoration: underline; }
.ed-s { text-decoration: line-through; }
.ed-lock { align-self: center; }
.ed-align { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--space-1); }
.ed-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); padding: var(--space-2) 0; }
.ed-actions .btn { flex: 1 1 0; }
.ed-condition { flex: 1; min-width: 0; padding-top: var(--space-2); }
.ed-artwork { width: var(--ed-artwork); height: var(--ed-artwork); border-radius: var(--radius-md); object-fit: cover; border: var(--border-width) solid var(--border-light); }
.ed-artwork.is-empty { display: grid; place-items: center; color: var(--text-muted); }
.ed-slide-head { display: flex; align-items: baseline; justify-content: space-between; padding: var(--space-2) 0; }
.ed-build-row {
  display: flex;
  flex-direction: column;
  gap: var(--space-half);
  width: 100%;
  padding: var(--space-2);
  border: 0;
  border-bottom: var(--border-width) solid var(--border);
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.ed-build-row:hover { background: var(--bg-hover); }
.ed-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-top: var(--border-width) solid var(--border-light);
}

/* ---- Reflow (Reflow mode, js/reflow.js): the words on the left, their slides on the right ---- */
.reflow { display: flex; flex-direction: column; height: 100%; min-height: 0; background: var(--deck-bg); }
.rf-head { flex: 0 0 auto; flex-wrap: wrap; row-gap: var(--space-1); padding-block: var(--space-1-5); }
.rf-head .deck-meta { flex: 0 1 auto; }
.rf-tools { display: flex; align-items: center; gap: var(--space-2); margin-left: auto; }
.rf-tools .tb-sep { height: var(--icon-md); margin: 0 var(--space-1); }
.rf-select { width: auto; max-width: var(--rf-select-width); height: var(--control-height-sm); padding: 0 var(--space-2); }
.rf-hint {
  flex: 0 0 auto;
  padding: var(--space-1-5) var(--space-4);
  background: var(--deck-head-bg);
  border-bottom: var(--border-width) solid var(--border-light);
}
.rf-body { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) var(--rf-side-width); }
/* The textarea and its backdrop are the same box, text and scroll: the
   backdrop draws only the tints behind the section names, under the
   see-through textarea. Both always keep a scrollbar so they wrap alike. */
.rf-text { position: relative; min-height: 0; background: var(--bg-input); }
.rf-backdrop, .rf-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: var(--rf-text-pad) max(var(--rf-text-pad), calc((100% - var(--rf-text-width)) / 2));
  border: 0;
  border-radius: 0;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: normal;
  overflow-x: hidden;
  overflow-y: scroll;
}
.rf-backdrop { color: transparent; pointer-events: none; }
.rf-input { background: transparent; color: var(--text); caret-color: var(--accent); resize: none; outline: none; }
.rf-input:read-only, .rf-input:disabled { color: var(--text-secondary); }
.rf-mark {
  --label: var(--section-other);
  display: inline-block;
  vertical-align: top;
  width: calc(100% + var(--space-2));
  margin-left: calc(var(--space-2) * -1);
  padding-left: var(--space-2);
  border-radius: var(--radius-xs);
  background: var(--white-8);
  box-shadow: inset var(--ed-group-bar) 0 0 var(--label);
}
.rf-side {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg-panel);
  border-left: var(--border-width) solid var(--border-light);
}
.rf-slides {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--rf-thumb-min), 1fr));
  column-gap: var(--space-2);
  align-content: start;
  padding: 0 var(--space-3) var(--space-3);
}
.rf-slides .ed-group, .rf-slides .pop-empty { grid-column: 1 / -1; }
.rf-slides .rf-empty { padding-top: 0; }

/* ---- Bible (Bible mode, js/biblepanel.js) ---- */
.bible { display: flex; flex-direction: column; height: 100%; min-height: 0; background: var(--deck-bg); }
.bible-head { flex-wrap: wrap; row-gap: var(--space-1-5); padding-block: var(--space-1-5); }
.bible-ref { display: flex; align-items: center; gap: var(--space-1); }
.bible-ref-input { width: var(--bible-ref-width); height: var(--control-height-sm); padding: 0 var(--space-2-5); font-weight: var(--weight-semibold); }
.bible-search { flex: 0 1 var(--bible-search-width); margin: 0 0 0 auto; }
.bible-options { border-top: 0; border-bottom: var(--border-width) solid var(--border-light); }
.bible-verses {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-half);
  padding: var(--space-2) var(--space-3);
}
.bible-verse {
  display: grid;
  grid-template-columns: var(--verse-num-width) minmax(0, 1fr);
  align-items: baseline;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-2) var(--space-3) var(--space-2) var(--space-1);
  border: var(--slide-ring) solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: background var(--duration-fast), border-color var(--duration-fast);
  touch-action: manipulation;
}
.bible-verse.is-result { grid-template-columns: var(--result-ref-width) minmax(0, 1fr); }
.bible-verse-num { text-align: right; }
.bible-verse.is-result .bible-verse-num { text-align: left; }
.bible-verse:hover:not(:disabled) { background: var(--bg-hover); }
.bible-verse.is-selected { background: var(--accent-soft); }
/* The verse on screen: the ring, like the live slide in the grid */
.bible-verse.is-live { border-color: var(--accent); }
.bible-verse.is-live .bible-verse-num { color: var(--accent-text); }
.bible-verse:disabled { cursor: default; color: var(--text-muted); }
.bible-verse:focus-visible { outline: var(--focus-width) solid var(--accent); outline-offset: calc(var(--focus-width) * -1); }
.bible-empty { padding: var(--space-4); }
/* the bar under the views: Show's parts (grid / list, slide size, the clock) or Bible's (auto-advance, Previous / Next) */
.deck-bar .bible-only { display: none; }
.workspace.is-bible .deck-bar .bible-only { display: flex; }
.workspace.is-bible .deck-bar .deck-only, .workspace.is-bible .deck-bar .show-only { display: none; }

/* Bible mode: the right column shows the verse templates instead of the quick actions */
.bible-templates { display: none; }
.workspace.is-bible .preview-col > .quick { display: none; }
.workspace.is-bible .preview-col > .bible-templates {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: 0 var(--space-3) var(--space-3);
  border-top: var(--border-width) solid var(--border);
}
.bible-templates .side-head { padding: 0; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--tpl-min), 1fr)); gap: var(--space-2); }
/* Text size (Bible): a slider over the templates */
.tpl-size { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-2); }
.tpl-size .bar-range { flex: 1 1 auto; width: auto; min-width: 0; }
.tpl-group { grid-column: 1 / -1; padding-top: var(--space-1); }
.tpl-tile {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 0;
  border: var(--slide-ring) solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color var(--duration-fast);
}
.tpl-tile:hover:not(:disabled):not(.is-on) { border-color: var(--border-light); }
.tpl-tile.is-on { border-color: var(--accent); }
.tpl-tile:disabled { cursor: default; }
.tpl-tile:focus-visible { outline: var(--focus-width) solid var(--accent); outline-offset: var(--focus-offset); }
/* exact scale: a template is about where things go, not reading the words */
.tpl-thumb { --slide-text-min: 0px; }
.tpl-name { padding: var(--space-1) var(--space-2); background: var(--bg-elevated); color: var(--text); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.tpl-tile.is-on .tpl-name { background: var(--accent); color: var(--text-on-accent); }

/* ---- Media library (the lower panel, js/mediapanel.js) ---- */
.lower-panel { position: relative; }
.lower-head { gap: var(--space-2); }
.media-filter { flex: 0 1 var(--media-filter-width); margin: 0; }
.media-body { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: var(--media-folders-width) minmax(0, 1fr); }
.media-folders { display: flex; flex-direction: column; min-height: 0; background: var(--outline-bg); border-right: var(--border-width) solid var(--border); }
.media-folder-list { flex: 1 1 auto; min-height: 0; overflow: auto; padding: var(--space-1) 0; }
.media-folder {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  min-height: var(--sidebar-row-height);
  padding: 0 var(--space-3);
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.media-folder:hover { background: var(--bg-hover); }
.media-folder.is-selected { background: var(--row-selected-bg); }
.media-folder.is-selected .row-title, .media-folder.is-selected .row-meta { color: var(--row-selected-text); }
.media-folder:focus-visible { outline: var(--focus-width) solid var(--accent); outline-offset: calc(var(--focus-width) * -1); }
.media-new-folder { padding: var(--space-1) var(--space-2); }
.media-new-folder .form-input { height: var(--control-height-sm); }
.media-folder-tools { display: flex; flex-wrap: wrap; gap: var(--space-1); padding: var(--space-1-5) var(--space-2); border-top: var(--border-width) solid var(--border); }
.media-grid {
  min-height: 0;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--media-tile-min), 1fr));
  align-content: start;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
}
.media-tile { position: relative; min-width: 0; }
.media-show {
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 0;
  border: var(--slide-ring) solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color var(--duration-fast);
  touch-action: manipulation;
}
.media-show:hover:not(:disabled) { border-color: var(--border-light); }
.media-show:disabled { cursor: default; }
.media-show:focus-visible { outline: var(--focus-width) solid var(--accent); outline-offset: var(--focus-offset); }
/* The file on screen: the ring, like the live slide */
.media-tile.is-live .media-show { border-color: var(--accent); }
.media-thumb {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--screen-bg);
  border-radius: var(--radius-xs) var(--radius-xs) 0 0;
}
.media-thumb img { width: 100%; height: 100%; object-fit: cover; }
.media-thumb.is-plain { background: var(--bg-elevated); }
.media-thumb.is-audio { display: grid; place-items: center; }
.media-thumb.is-audio svg { width: var(--icon-lg); height: var(--icon-lg); fill: none; stroke: var(--text-secondary); stroke-width: var(--icon-stroke); stroke-linecap: round; stroke-linejoin: round; }
/* Audio: what's playing, over the files */
.audio-now {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1-5) var(--space-3);
  border-bottom: var(--border-width) solid var(--border);
  background: var(--items-header-bg);
}
.audio-now .icon-btn svg .fill, .audio-now .icon-btn svg path.fill { fill: currentColor; }
.audio-name { flex: 1 1 auto; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.audio-where { padding: var(--space-1) var(--space-3); }
.media-badge {
  position: absolute;
  right: var(--space-1);
  bottom: var(--space-1);
  padding: var(--pill-pad);
  border-radius: var(--radius-xs);
  background: var(--backdrop);
  color: var(--white-100);
  font-variant-numeric: tabular-nums;
}
.media-name { padding: var(--space-1) var(--space-2); background: var(--bg-elevated); color: var(--text); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.media-tile.is-live .media-name { background: var(--accent); color: var(--text-on-accent); }
.media-more {
  position: absolute;
  top: calc(var(--slide-ring) + var(--space-1));
  right: calc(var(--slide-ring) + var(--space-1));
  display: grid;
  place-items: center;
  width: var(--tool-btn);
  height: var(--tool-btn);
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--backdrop);
  color: var(--white-100);
  opacity: 0;
  cursor: pointer;
  transition: opacity var(--duration-fast);
}
.media-tile:hover .media-more, .media-more:focus-visible, .media-more.is-open { opacity: 1; }
@media (hover: none) { .media-more { opacity: 1; } } /* touch: no hover to reveal it */
.media-progress { width: 70%; height: var(--media-progress-height); border-radius: var(--radius-xs); background: var(--white-12); overflow: hidden; }
.media-progress-bar { display: block; width: 0; height: 100%; background: var(--accent); transition: width var(--duration-fast); }
.media-empty { grid-column: 1 / -1; }
.media-drop {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 var(--focus-width) var(--accent);
  color: var(--text);
  pointer-events: none;
}

/* The book picker (▾ by the reference) */
.popover-books { width: var(--popover-books-width); }
.popover-books .pop-head { margin-bottom: var(--space-2); }
.books-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--book-col-min), 1fr));
  gap: var(--space-1);
  max-height: var(--books-max-height);
  overflow: auto;
}
.books-list.is-chapters { grid-template-columns: repeat(auto-fill, minmax(var(--chapter-btn), 1fr)); }
.books-group { grid-column: 1 / -1; padding: var(--space-2) var(--space-1) var(--space-half); }
.books-group:first-child { padding-top: 0; }
.book-btn, .chapter-btn {
  min-width: 0;
  height: var(--sidebar-row-height);
  padding: 0 var(--space-2-5);
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.chapter-btn { height: var(--chapter-btn); text-align: center; font-variant-numeric: tabular-nums; }
.book-btn:hover:not(.is-on), .chapter-btn:hover:not(.is-on) { background: var(--bg-hover); }
.book-btn.is-on, .chapter-btn.is-on { background: var(--accent); color: var(--text-on-accent); }
.book-btn:focus-visible, .chapter-btn:focus-visible { outline: var(--focus-width) solid var(--accent); outline-offset: var(--focus-offset); }

/* ---- Network settings sheet ---- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-sheet);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: max(var(--sheet-top), env(safe-area-inset-top)) var(--space-4) var(--space-4);
  overflow: auto;
  background: var(--backdrop);
  animation: vx-fade var(--duration-fast) ease-out;
}
.sheet {
  width: 100%;
  max-width: var(--sheet-width);
  padding: var(--space-6);
  background: var(--bg-card);
  border: var(--border-width) solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-2); }
.sheet-intro { margin-bottom: var(--space-4); }
.setting {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2-5) var(--space-3);
  padding: var(--space-3-5) 0;
  border-top: var(--border-width) solid var(--border);
}
.setting-main { flex: 1 1 var(--setting-main-min); min-width: 0; }
.setting-actions { display: flex; gap: var(--space-2); }
.setting-form { flex: 1 1 100%; display: flex; gap: var(--space-2); }
.setting-form .form-input { flex: 1; min-width: 0; }
.link-out { flex: 1 1 100%; font-family: var(--font-mono); font-size: var(--size-ui); }
#network-panel .form-error, #bibles-sheet .form-error { margin: var(--space-3) 0 0; }
/* Search: centered, the columns side by side (stacked on narrow screens) */
.sheet.sheet-search { max-width: var(--sheet-search-width); }
.search-head { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-4); }
.search-head .form-input { flex: 1; min-width: 0; }
.search-head .btn[aria-pressed="true"] { background: var(--accent); color: var(--text-on-accent); }
.search-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-5); }
.search-columns.is-browsing { grid-template-columns: minmax(0, 1fr); } /* online: the songs churches share, one column */
/* …a song tapped: the results slide left, its slides on the right */
.search-columns.is-browsing.is-previewing { grid-template-columns: minmax(var(--search-results-min), 1fr) minmax(0, 2fr); }
.search-preview-head { display: flex; align-items: flex-start; gap: var(--space-3); margin-bottom: var(--space-3); }
.search-preview-info { flex: 1; min-width: 0; }
.search-preview-action { flex: 0 0 auto; display: flex; gap: var(--space-2); }
.search-preview-slides {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--search-slide-min), 1fr));
  gap: var(--space-2);
  max-height: var(--search-list-max);
  overflow-y: auto;
}
.search-preview-slides .slide { cursor: default; }
.shared-item.is-on { background: var(--bg-elevated); border-radius: var(--radius-sm); }
/* Add to playlist: a row just added says so */
.pill.pill-added { color: var(--success); background: var(--success-soft); }
/* nothing of the church's own matches: "Search online?" in the middle (a link in the box: "Get the words") */
.search-empty { display: flex; flex-direction: column; align-items: center; gap: var(--space-2); padding: var(--space-10) var(--space-4); text-align: center; }
.search-empty-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-2); margin-top: var(--space-2); }
.search-col-scroll { max-height: var(--search-list-max); overflow-y: auto; }
/* not shared yet: from a lyrics site, three steps, then the link pasted here */
.search-web { margin-top: var(--space-5); padding-top: var(--space-4); border-top: var(--border-width) solid var(--border); }
.web-steps { display: grid; gap: var(--space-4); margin: var(--space-3) 0 0; padding: 0; list-style: none; }
.web-step { display: flex; align-items: flex-start; gap: var(--space-3); }
.web-step-num {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: var(--web-step-num);
  height: var(--web-step-num);
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-contrast);
}
.web-step-body { flex: 1; min-width: 0; display: grid; gap: var(--space-2); }
/* a lyrics site: a big button that opens its search for what's typed */
.site-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); }
.site-tile {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2-5) var(--space-3);
  border: var(--border-width) solid var(--accent);
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  color: var(--text);
  text-decoration: none;
  transition: background var(--duration-fast), color var(--duration-fast);
}
.site-tile:hover { background: var(--accent); color: var(--accent-contrast); }
.site-tile:hover .site-tile-sub { color: inherit; }
.site-tile:focus-visible { outline: var(--focus-width) solid var(--accent); outline-offset: var(--focus-offset); }
.site-tile-text { flex: 1; min-width: 0; display: grid; }
.site-tile svg {
  flex: 0 0 auto;
  width: var(--icon-md);
  height: var(--icon-md);
  fill: none;
  stroke: currentColor;
  stroke-width: var(--icon-stroke);
  stroke-linecap: round;
  stroke-linejoin: round;
}
.search-paste { display: flex; gap: var(--space-2); }
.search-paste .form-input { flex: 1; min-width: 0; }
/* a site that turns servers away: open it, copy it, paste it, in the preview pane (controller.js copyPageSteps) */
.search-preview-slides > .copy-steps { grid-column: 1 / -1; margin-top: 0; }
.copy-open { justify-self: start; text-decoration: none; }
/* …nothing shared matches: only those steps, big and centered on a card ("Add “…” in two steps"), never a "no results" */
.search-col-scroll.is-empty > .section-label,
.search-col-scroll.is-empty > .pop-list,
.search-col-scroll.is-empty > .search-note { display: none; }
.search-col-scroll.is-empty .search-web { max-width: var(--search-web-max); margin: 0 auto; padding: var(--space-6) 0; border-top: 0; text-align: center; }
.search-web-sub { margin-top: var(--space-1-5); }
.search-col-scroll.is-empty .web-steps {
  margin-top: var(--space-5);
  gap: var(--space-5);
  padding: var(--space-5);
  border: var(--border-width) solid var(--border-light);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  text-align: left;
}
.search-col-scroll.is-empty .site-tile { min-height: var(--site-tile-height); }
.search-col { min-width: 0; }
.search-list { max-height: var(--search-list-max); overflow-y: auto; }
.search-note { margin-top: var(--space-2-5); }
/* a shared song: its row (tap = its words under it) and Add */
.shared-open {
  flex: 1;
  min-width: 0;
  padding: 0;
  background: none;
  border: 0;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.shared-open:focus-visible { outline: var(--focus-width) solid var(--accent); outline-offset: var(--focus-offset); }
/* Your church's Bibles: the file's name / short name / book names under its row */
.bibles-form { flex: 1 1 100%; }
.bibles-form .new-hint { margin-top: var(--space-2-5); }

/* Layout changes (structure only; sizes scale in 1h) */
/* iPad portrait: the live preview moves above the grid, next to the left panel */
@media (max-width: 960px) {
  .workspace {
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: "side live" "side main";
  }
  .preview-col { border-left: 0; border-bottom: var(--border-width) solid var(--border-light); }
  .live-stage { max-width: var(--preview-max-phone); }
  /* the quick actions sit beside the preview instead of under it */
  .preview-col {
    display: grid;
    grid-template-columns: minmax(0, var(--preview-max-phone)) minmax(0, 1fr);
    grid-template-rows: auto auto 1fr;
    align-content: start;
  }
  .preview-col > .quick, .workspace.is-bible .preview-col > .bible-templates { grid-column: 2; grid-row: 1 / span 3; border-top: 0; border-left: var(--border-width) solid var(--border); }
}
/* Phones: one column: live, then the left panel (collapsed), then the grid */
@media (max-width: 700px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto minmax(0, 1fr);
    grid-template-areas: "live" "side" "main";
  }
  .sidebar { border-right: 0; border-bottom: var(--border-width) solid var(--border-light); max-height: 40vh; }
  .live-stage { margin-inline: auto; }
  /* the editor stacks: slides, then the slide, then the inspector */
  .editor { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto; height: auto; }
  .workspace.is-editing .mode-area { overflow: auto; }
  .ed-nav { max-height: 40vh; border-right: 0; border-bottom: var(--border-width) solid var(--border-light); }
  .ed-main { min-height: 60vh; }
  .ed-inspector { border-left: 0; border-top: var(--border-width) solid var(--border-light); }
  /* Media: the folders become a row over the files */
  .media-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .media-folders { border-right: 0; border-bottom: var(--border-width) solid var(--border); }
  .media-folder-list { display: flex; overflow-x: auto; padding: 0; }
  .media-folder { width: auto; flex: 0 0 auto; }
  /* Bible: the verses keep real room; the main area scrolls instead */
  .bible { height: auto; min-height: 75vh; }
  .bible-search { flex-basis: 100%; margin: 0; }
  /* Reflow stacks too: the words, then the slides */
  .reflow { height: auto; }
  .rf-body { grid-template-columns: minmax(0, 1fr); }
  .rf-text { height: 60vh; }
  .rf-side { max-height: 50vh; border-left: 0; border-top: var(--border-width) solid var(--border-light); }
  /* one column again: the quick actions go back under the preview (folded until a tab is tapped) */
  .preview-col { display: block; }
  .preview-col > .quick { border-left: 0; border-top: var(--border-width) solid var(--border); }
}

/* ============================================================
   6b. Admin page (admin.html, /admin): a flat page, not the controller's.
   A frosted sidebar on the left (section 8), the page's cards beside it.
   Narrow screens: the sidebar folds into a bar on top.
   ============================================================ */
.admin {
  display: grid;
  grid-template-columns: var(--admin-nav-width) minmax(0, 1fr);
  align-items: start;
  min-height: 100vh;
  min-height: 100dvh;
}
.admin-nav {
  position: sticky;
  top: 0;
  z-index: var(--z-popover);
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  height: 100vh;
  height: 100dvh;
  padding: max(var(--space-5), env(safe-area-inset-top)) var(--space-3) max(var(--space-4), env(safe-area-inset-bottom)) max(var(--space-3), env(safe-area-inset-left));
  overflow-y: auto;
  background: var(--toolbar-bg);
  border-right: var(--border-width) solid var(--border-light);
}
.admin-brand { display: flex; align-items: center; gap: var(--space-2-5); min-width: 0; padding: 0 var(--space-1-5); color: inherit; text-decoration: none; }
.admin-brand .avatar { width: var(--avatar-sm); height: var(--avatar-sm); font-size: var(--size-body); }
.admin-brand-text { display: flex; flex-direction: column; min-width: 0; }
.admin-church { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.admin-tabs { display: flex; flex-direction: column; gap: var(--space-1); }
.admin-tab {
  display: flex;
  align-items: center;
  gap: var(--space-2-5);
  padding: var(--space-2) var(--space-2-5);
  border-radius: var(--radius-control);
  color: var(--text-secondary);
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--duration-fast), color var(--duration-fast);
}
.admin-tab svg { flex: 0 0 auto; width: var(--icon-md); height: var(--icon-md); fill: none; stroke: currentColor; stroke-width: var(--icon-stroke); stroke-linecap: round; stroke-linejoin: round; }
.admin-tab:hover { background: var(--bg-hover); color: var(--text); }
.admin-tab.is-active { background: var(--accent); color: var(--text-on-accent); }
.admin-tab:focus-visible { outline: var(--focus-width) solid var(--accent); outline-offset: 1px; }
/* Controller · Sign out · the version: at the sidebar's foot */
.admin-actions { display: flex; flex-direction: column; gap: var(--space-1); margin-top: auto; }
.admin-actions .btn { justify-content: flex-start; }
.admin-main { width: 100%; max-width: var(--admin-width); padding: var(--space-8) var(--space-8) var(--space-10); }
.admin-head { margin-bottom: var(--space-5); }
.admin-sub { margin-top: var(--space-1-5); }
.admin-card {
  margin-bottom: var(--space-4);
  padding: 0 var(--space-5);
  background: var(--bg-card);
  border: var(--border-width) solid var(--border-light);
  border-radius: var(--radius-lg);
}
.admin-card > .setting:first-child { border-top: 0; }
.admin-card .setting-form { flex-wrap: wrap; } /* a phone + a code + three buttons: wrap on narrow screens */
.admin-card:empty { display: none; }
.admin-form { flex: 1 1 100%; }
.admin-role { width: auto; }
.admin-empty { padding: var(--space-3-5) 0; }
.admin-section .next-step { margin-bottom: var(--space-4); }
.admin-section .form-error { margin: var(--space-3) 0 0; }
.admin-version { margin-top: var(--space-2); padding: 0 var(--space-1-5); }
/* a phone or an iPad held upright: the sidebar folds into a bar on top
   (church · Controller, Sign out), the sections in a row under them */
@media (max-width: 860px) {
  .admin { grid-template-columns: minmax(0, 1fr); }
  .admin-nav {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2) var(--space-3);
    height: auto;
    padding: max(var(--space-2-5), env(safe-area-inset-top)) max(var(--space-4), env(safe-area-inset-right)) var(--space-2-5) max(var(--space-4), env(safe-area-inset-left));
    border-right: 0;
    border-bottom: var(--border-width) solid var(--border-light);
  }
  .admin-brand { flex: 1 1 auto; padding: 0; }
  .admin-actions { flex-direction: row; margin: 0; }
  .admin-version { display: none; }
  .admin-tabs { order: 3; flex: 1 1 100%; flex-direction: row; }
  .admin-main { max-width: none; padding: var(--space-6) var(--space-4) var(--space-10); }
}

/* ============================================================
   7. Display page (display.html, /display): the screen itself
   ============================================================ */
body.page-display { background: var(--screen-bg); overflow: hidden; }
body.page-display.is-idle { cursor: none; }

/* Pairing */
.pair { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: var(--space-6) var(--space-4); background: var(--bg-base); }
.pair-card { width: 100%; max-width: var(--form-width); }
.pair-card .brand { margin-bottom: var(--space-8); }
.pair-code {
  height: var(--pair-code-height);
  font-family: var(--font-mono);
  font-size: var(--size-pair-code);
  letter-spacing: var(--tracking-code);
  text-align: center;
}

/* Audience: the live slide, full screen (same drawing as the controller's preview) */
.output { position: fixed; inset: 0; }
.output-screen {
  position: absolute;
  inset: 0;
  container-type: inline-size;
  display: grid;
  overflow: hidden;
  background: var(--screen-bg);
}

/* Stage: now / next / clock / message, sized to the screen */
.stage-view {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  gap: var(--stage-gap);
  padding: var(--stage-pad);
  background: var(--screen-bg);
  color: var(--text-on-dark);
}
.stage-top { display: flex; align-items: baseline; justify-content: space-between; gap: var(--stage-gap); min-width: 0; }
.stage-clock { font-size: var(--stage-clock-size); font-weight: var(--weight-semibold); font-variant-numeric: tabular-nums; }
.stage-title { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: var(--stage-meta-size); color: var(--white-55); }
/* A Bible verse's time on the stage screen; red in its last 3 s before auto-advance */
.stage-timer { flex: 0 0 auto; font-size: var(--stage-clock-size); font-weight: var(--weight-semibold); font-variant-numeric: tabular-nums; color: var(--white-72); }
.stage-timer.is-soon { color: var(--live); }
.stage-message {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--live);
  color: var(--text-on-accent);
  font-size: var(--stage-next-size);
  font-weight: var(--weight-semibold);
  text-align: center;
}
.stage-now {
  align-self: center;
  white-space: pre-line;
  font-size: var(--stage-now-size);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  overflow: hidden;
}
.stage-now.is-muted { color: var(--white-48); }
.stage-notes { white-space: pre-line; font-size: var(--stage-meta-size); color: var(--white-72); border-left: var(--ed-group-bar) solid var(--accent); padding-left: var(--space-3); }
.stage-next { border-top: var(--border-width) solid var(--white-12); padding-top: var(--stage-gap); min-width: 0; }
.stage-next-label { display: block; margin-bottom: var(--space-2); font-size: var(--stage-meta-size); color: var(--white-55); }
.stage-next-text { white-space: pre-line; font-size: var(--stage-next-size); line-height: var(--leading-tight); color: var(--white-72); }

/* On-screen controls: appear on movement, fade after 3 s */
.screen-controls {
  position: fixed;
  z-index: var(--z-toast);
  left: 50%;
  bottom: max(var(--space-6), env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-2) var(--space-2) var(--space-4);
  background: var(--bg-card);
  border: var(--border-width) solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: vx-fade var(--duration-fast) ease-out;
}
.screen-name { font-size: var(--size-ui); color: var(--text-secondary); white-space: nowrap; }
.fs-hint {
  position: fixed;
  z-index: var(--z-toast);
  top: max(var(--space-6), env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  border: var(--border-width) solid var(--border-light);
  color: var(--text);
  font-size: var(--size-ui);
  white-space: nowrap;
  pointer-events: none;
  animation: vx-fade var(--duration-fast) ease-out;
}

/* Identify: the screen's name, huge, for a few seconds */
.identify { position: fixed; inset: 0; z-index: var(--z-sheet); display: grid; place-items: center; background: var(--backdrop); }
.identify-card {
  padding: var(--identify-pad);
  border-radius: var(--radius-lg);
  background: var(--accent);
  color: var(--white-100);
  text-align: center;
  animation: vx-fade var(--duration-fast) ease-out;
}
.identify-name { font-size: var(--identify-size); font-weight: var(--weight-semibold); line-height: var(--leading-tight); }
.identify-kind { margin-top: var(--space-2); font-size: var(--identify-kind-size); color: var(--white-72); }
.screen-status {
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  padding: var(--space-1-5) var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: var(--size-label);
}

/* ============================================================
   8. Glass: every floating surface frosted (tokens in 1g)
   ------------------------------------------------------------
   Popovers (every menu and popup), sheets, toasts and the screen page's
   controls: the solid look above first, then, where the browser can blur
   what's behind, a see-through tint + sheen + grain over the blurred page,
   a lit top edge. Fields and sunken areas on glass go see-through too
   (not selects: some browsers paint their option lists with it). Last in
   the file so it wins over each surface's own background.
   ============================================================ */
@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .popover, .sheet, .toast, .screen-controls, .fs-hint, .screen-status, .tip, .tour-card {
    background: var(--glass-sheen), var(--glass-grain), var(--glass-bg);
    border-color: var(--glass-border);
    box-shadow: inset 0 var(--border-width) 0 var(--glass-edge), var(--shadow-lg);
    -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
    backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  }
  /* the admin page's sidebar (a bar on narrow screens): frosted, flat (no float shadow) */
  .admin-nav {
    background: var(--glass-sheen), var(--glass-grain), var(--glass-bg);
    border-color: var(--glass-border);
    -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
    backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  }
  .sheet-backdrop, .identify {
    background: var(--glass-dim);
    -webkit-backdrop-filter: blur(var(--glass-backdrop-blur));
    backdrop-filter: blur(var(--glass-backdrop-blur));
  }
  .popover input.form-input, .popover textarea.form-input,
  .sheet input.form-input, .sheet textarea.form-input,
  .new-theme-btn, .words-code, .new-code { background-color: var(--glass-field); }
  .new-themes { background: var(--glass-well); }
}

/* "Reduce motion": a short plain fade, no blur or movement */
@media (prefers-reduced-motion: reduce) {
  .brand, .view, .view > *, .view form > *, .panel-headline, .panel-text, .fact, .panel-foot {
    animation: vx-fade var(--duration-reduced) ease-out backwards;
    animation-delay: 0s;
  }
}
