/* Self-hosted — this weight isn't on any public font CDN, so the
   title font ships as a local file instead of a <link>. */
/* The name on the left is an alias this stylesheet invents: the file's own
   family is "Trade Gothic Next LT Pro" with "Heavy Compressed" as its
   subfamily, so the full name only exists as a family once declared here.

   The bundled file comes first so it is always what gets used — identical
   metrics on every machine. The local() names after it are the installed
   copy the installer puts into Windows, and exist for one reason: if the
   .otf ever fails to load, the title overlay would otherwise fall through to
   Impact and lay every title out against the wrong metrics. Falling back to
   the same face by another route is recoverable; falling back to a different
   face is not. */
@font-face {
    font-family: 'Anton';
    src: url('fonts/Anton-Regular.ttf') format('truetype'),
         local('Anton'),
         local('Anton-Regular');
    font-weight: 400;
    font-style: normal;
    font-display: block;
}

@font-face {
    font-family: 'Trade Gothic Next LT Pro Heavy Compressed';
    src: url('fonts/TradeGothicNextLTProHeavyCompressed.otf') format('opentype'),
         local('Trade Gothic Next LT Pro Heavy Compressed'),
         local('TradeGothicNextLTPro-HvCm');
    font-weight: 900;
    font-style: normal;
    font-display: block;
}
* { margin: 0; padding: 0; box-sizing: border-box; }

/* Shown only when the title face failed to load. Red, full width and
   permanent, because the symptom it explains — a title laid out against
   Impact's metrics — otherwise just looks like the app is broken. */
.font-warning {
    background: #FF070C; color: #fff; font-weight: 700;
    padding: 12px 16px; border-radius: 8px; margin-bottom: 12px;
    line-height: 1.35;
}
/* Form controls don't inherit font-family from the body by default
   in most browsers (they use the platform's UI font instead) —
   this is what makes buttons/inputs pick up Raleway too. */
button, input, select, textarea { font-family: inherit; }
body {
    position: relative;
    background: #060610; color: #fff;
    font-family: 'Raleway', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    min-height: 100vh;
    padding: 0;
}
/* Soft blurred blue glow hugging the top edge, fading into a dark
   navy field — fixed behind all content (every panel/card already
   has its own opaque dark background, so this only ever shows
   through the page margins/gaps). A sharp-edged ellipse blurred by
   the browser is what gives the photographic soft-glow look, rather
   than trying to hand-tune soft gradient stops. */
body::before {
    content: "";
    position: fixed;
    inset: -15%;
    z-index: -1;
    background:
        radial-gradient(ellipse 70% 18% at 50% 0%, #c9d6ff 0%, #4d6cff 22%, #1c30c0 45%, transparent 78%),
        #080b1e;
    filter: blur(60px);
}
/* Fluid layout — everything scales with the window instead of a fixed
   900px column; the canvas size is derived from the viewport below. */
.app { width: 94vw; max-width: 1600px; margin: 0 auto; }
/* Logo stacked above the title, both centered — not fixed over the
   corner, since a fixed-position logo read as "floating",
   disconnected from the page and from the title. */
.app-header {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 10px; margin-bottom: 36px;
}
h1 {
    font-family: 'Work Sans', sans-serif;
    font-style: italic;
    font-weight: 900; /* Use 700 or 900 depending on how bold you want it */
    font-size: 32px;
    margin: 0;
    color: #fffa00;
    text-transform: uppercase;
}
h2 {
    font-size: 19px; font-weight: 900; color: #fff;
    margin: 32px 0 14px; text-align: center; text-transform: uppercase;
    letter-spacing: 0.02em;
}

.input-section { display: flex; flex-direction: column; gap: 10px; margin-bottom: 32px; max-width: 500px; margin-left: auto; margin-right: auto; }
/* Separator between the two ways in — a link above, a local file
   below. A rule with the word sitting in it, rather than a plain
   line, so the two blocks read as alternatives to each other
   instead of as two steps of one sequence. */
.source-or {
    display: flex; align-items: center; gap: 10px;
    color: #fffa00; font-size: 11px; font-weight: 900;
    text-transform: uppercase; letter-spacing: 0.08em;
    margin: 2px 0;
}
.source-or::before, .source-or::after {
    content: ""; flex: 1; height: 2px; background: #1b2fea;
}
input[type="text"] {
    background: #1b2fea; border: 2px solid #026dff; border-radius: 8px;
    padding: 10px 14px; color: #fff; font-size: 14px; outline: none; width: 100%;
    caret-color: #fffa00;
}
input[type="text"]:hover, input[type="text"]:focus { border-color: #fffa00; }
input[type="text"]::placeholder { color: #fffa00; }
/* Chrome's default selection highlight is a translucent blue, which
   all but disappears against this input's own blue background —
   selecting text looked like nothing happened, even though it did
   (copy still worked). Yellow matches the field's own accent color
   and stays visible against the blue fill. */
input[type="text"]::selection { background: #fffa00; color: #1b2fea; }
input[type="text"]::-moz-selection { background: #fffa00; color: #1b2fea; }

/* The one-block title field, for a channel whose line breaks are the
   user's own. Everything about it matches the single-line fields it
   stands in for — same fill, same border, same caret — because it is
   the same field asking for the same thing; all that differs is that
   Enter means something in it.

   One row to start with, and it grows a row at a time as the user
   breaks lines (editor.autoGrowBlock). It stands where three separate
   fields stand for every other channel, and opening four rows deep
   would read as three of them already being empty — a title with
   blank lines in it, which is exactly what this channel CAN have and
   so exactly the wrong thing to imply.

   No drag handle and no scrollbar: it is always exactly as tall as
   what is in it, so both would only be ways to make it wrong. */
.line-block {
    background: #1b2fea; border: 2px solid #026dff; border-radius: 8px;
    padding: 10px 14px; color: #fff; font-size: 14px; outline: none; width: 100%;
    caret-color: #fffa00; resize: none; overflow-y: hidden; line-height: 1.5;
}
.line-block:hover, .line-block:focus { border-color: #fffa00; }
.line-block::placeholder { color: #fffa00; }
.line-block::selection { background: #fffa00; color: #1b2fea; }

/* One button system, everywhere: blue/white idle, yellow/blue on
   hover. Toggle-style buttons (edit preset, highlight line, flip)
   show their current choice with .btn-active, which is just the
   hover pair held permanently — "selected" reads as "engaged"
   instead of introducing a third color into the palette. The
   hover rule is scoped to :not(:disabled) so a locked button (see
   setControlsLocked) can't be flipped to the hover color by the
   mouse sitting over it — it just keeps whatever it was already
   showing (idle blue, or active yellow if it's the current
   selection) until it's unlocked again. */
.btn {
    padding: 10px 18px; border: none; border-radius: 8px;
    font-size: 13px; font-weight: 900; cursor: pointer;
    text-transform: uppercase; letter-spacing: 0.02em;
    background: #1b2fea; color: #fff;
    transition: background 0.15s ease, color 0.15s ease;
}
.btn:not(:disabled):hover { background: #fffa00; color: #1b2fea; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-active { background: #fffa00; color: #1b2fea; }
.btn-red { background: #FF070C; color: #fff; }
.btn, .btn:focus, .btn:focus-visible { outline: none; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
/* Edit-preset buttons stack one above the other — switching presets
   replaces the previous pipeline outright (see setEditPreset), so
   presenting them as one-at-a-time stacked choices, rather than a
   row, reads clearer about that "only one applies" relationship. */
.btn-col { display: flex; flex-direction: column; gap: 8px; }
/* The title itself, as buttons, for a channel that highlights words
   rather than lines (see editor.renderWordButtons). One row per line
   of the block, so the panel keeps the shape of the thing it is
   describing — which is what makes it readable as the title and not
   as a bag of words.

   Smaller and tighter than a normal button: there is one per word, a
   title can carry a dozen, and at the full size they would fill the
   panel. The word has to stay legible, so what gives is the padding
   around it. */
.word-row { gap: 6px; margin-bottom: 6px; }
.btn-word {
    padding: 6px 10px; font-size: 12px; letter-spacing: 0;
    max-width: 100%; overflow-wrap: anywhere;
}
/* The colours a channel offers for its titles (see `title.colors` in
   js/channels.js). Its own block in the panel rather than four loose
   children, so the two labelled rows can be shown and hidden as the one
   thing they are; the gap repeats the panel's own, since `display:
   contents` is not available to something that also has to disappear. */
.color-rows { display: flex; flex-direction: column; gap: 14px; }
/* A swatch is the colour, not a word for it. There is nothing to write
   on one — a hex tells the user less than the colour does and a name
   somebody invented tells them less again — so the button is the paint,
   sized to be pressed and no larger.

   The dark ring is what keeps a white swatch from vanishing into the
   panel's own pale text, and it is INSIDE the button (an inset shadow,
   not a border) so that every swatch is exactly the same size whether
   it is the chosen one or not. A border that appeared on selection
   would shift the row by two pixels every time it moved. */
.swatch-row { justify-content: flex-start; }
.btn-swatch {
    width: 34px; height: 34px; padding: 0; border-radius: 8px;
    border: none; cursor: pointer;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.45);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.btn-swatch:not(:disabled):hover { transform: scale(1.08); }
/* The chosen one wears the panel's own yellow, held off the swatch by a
   ring of the page's own background first. The gap is doing real work
   rather than decorating: one of the colours a pack may offer is a
   yellow, and a yellow ring drawn straight onto a yellow swatch is a
   swatch that looks slightly larger and not one that looks chosen. A
   dark band between the two keeps the mark legible on any colour a
   pack can name, which is the only version of this that is safe to
   write once for every channel. */
.btn-swatch.btn-active {
    box-shadow:
        inset 0 0 0 1px rgba(0, 0, 0, 0.45),
        0 0 0 2px #060610,
        0 0 0 5px #fffa00;
}
.btn-swatch:disabled { opacity: 0.4; cursor: not-allowed; }
/* "No background": an empty box with a red bar struck across it, corner
   to corner, which is the sign for "none" people already read without a
   label. The bar runs bottom-left to top-right: a gradient aimed at a
   CORNER puts its midpoint on the diagonal through the other two, so
   "to bottom right" is the one that draws "/".

   Its ring is light rather than the colours' dark one, because there is
   no paint inside this box for a dark ring to stand against - on the
   panel's dark blue a dark ring would leave a red stripe floating in
   nothing. The chosen ring is the colours' own (.btn-active, above),
   restated here with the light inset, because that rule is the more
   specific of the two and would otherwise put the dark one back. */
.btn-swatch-none {
    background:
        linear-gradient(to bottom right,
            transparent calc(50% - 1.5px),
            #ff2b2b calc(50% - 1.5px), #ff2b2b calc(50% + 1.5px),
            transparent calc(50% + 1.5px));
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.75);
}
.btn-swatch-none.btn-active {
    box-shadow:
        inset 0 0 0 2px rgba(255, 255, 255, 0.75),
        0 0 0 2px #060610,
        0 0 0 5px #fffa00;
}
/* "Download selected (N)" — the count sits in its own pill so it
   stays legible regardless of the button's idle/hover colors,
   instead of having to flip in step with them. */
.count-badge {
    background: #1b2fea; color: #fffa00;
    padding: 1px 7px; border-radius: 10px; margin-left: 4px;
    font-size: 11px;
}

.status { text-align: center; padding: 6px; font-size: 13px; color: #fff; }

.progress-section { max-width: 500px; margin: 0 auto 24px; }
.progress-track {
    background: #1b2fea; border: 1px solid #1b2fea; border-radius: 8px;
    height: 10px; overflow: hidden;
}
.progress-fill {
    background: #fffa00; height: 100%; width: 0%;
    transition: width 0.4s ease;
}
.progress-text { text-align: center; font-size: 12px; color: #fff; margin-top: 6px; }

.input-section .line-input { font-weight: 600; }

/* Always 5 columns (20 frames -> 4 rows of 5). Width matches the
   editor row below (canvas + panel), so the grid's left edge lines up
   with the canvas's left edge. */
.frames-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 5px;
    width: min(calc(60vw + 404px), 100%); margin: 12px auto 24px;
}
.frame-card {
    position: relative; border-radius: 4px; overflow: hidden;
    border: 2px solid transparent; cursor: pointer;
}
.frame-card:hover { border-color: #1b2fea; }
.frame-card.selected { border-color: #fffa00; border-width: 3px; }
.frame-card img { width: 100%; aspect-ratio: 16/9; object-fit: cover; display: block; }
/* Brand blue/yellow, matching .count-badge's pill — was a plain
   black chip before, out of step with the rest of the UI. */
.frame-card .badge {
    position: absolute; top: 3px; left: 3px;
    background: #1b2fea; color: #fffa00; font-size: 10px; font-weight: 700;
    padding: 1px 5px; border-radius: 3px;
}
/* Batch-selection tick — independent of which frame is previewed */
.frame-card .pick {
    position: absolute; top: 3px; right: 3px;
    width: 18px; height: 18px; border-radius: 4px;
    background: rgba(0,0,0,0.55); border: 2px solid #1b2fea;
    cursor: pointer;
}
.frame-card .pick.on { background: #fffa00; border-color: #1b2fea; }
.frame-card .pick.on::after {
    content: "✓"; color: #1b2fea; font-size: 12px; font-weight: 700;
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
}
/* enhancing no longer draws its own outline — the card being
   worked on is always the selected one, so its existing yellow
   .selected border already communicates that, and a second
   (blue) outline stacked on top of it while loading just read as
   two competing selection indicators. */

/* Canvas and the per-frame title fields sit side by side, so the user
   edits one frame's text while looking at it. Wraps on narrow
   windows. The 20vh bottom margin leaves room below the canvas so the
   wide-frame overview shown while dragging to reframe isn't cut off
   at the page bottom. */
/* Row width = canvas + SIDE_W, where SIDE_W is the 104px gap plus
   the 300px panel. The canvas wants 60vw but gives that up rather than
   pushing the panel onto its own line, so the two stay side by side
   down to narrow windows (below --editor-min the flex wrap takes
   over). The frames grid uses the same total so its left edge lines
   up with the canvas's. */
.editor {
    /* Clears two things overhanging the canvas's right edge: the zoom
       bar (~46px) and the forward frame arrow outside it (~90px). */
    display: flex; gap: 104px;
    align-items: flex-start; justify-content: center; flex-wrap: wrap;
    margin-bottom: 20vh;
}
.canvas-col { width: 60vw; max-width: calc(100% - 404px); min-width: 320px; }
/* Card-grouped so the panel reads as one unit next to the canvas,
   and its three subsections (title, edit preset, image overlay)
   stay visually distinct via the divider rule below instead of
   just floating whitespace between them. */
.text-panel {
    width: 300px; flex: 0 0 300px; display: flex; flex-direction: column; gap: 14px;
    background: rgba(27, 47, 234, 0.18); border: 1px solid rgba(2, 109, 255, 0.5);
    border-radius: 12px; padding: 20px;
}
/* Transparent to layout by default: the panel is a flex column of the
   same loose children it always had, and the wrappers exist only so the
   captions-mode rules further down have something to turn. */
.panel-group { display: contents; }
/* The rule that draws the line between sections. It used to ask "an h2
   that is not the panel's first child"; the h2s sit in a wrapper each
   now, so it asks the same question of the wrappers. */
.panel-group:not(:first-child) > h2 {
    margin-top: 10px; padding-top: 22px; border-top: 1px solid rgba(255, 255, 255, 0.14);
}
.panel-hint { font-size: 11px; color: #fff; line-height: 1.6; }

/* Channel picker — the brand whose guidelines every title on the
   page is set with. Styled as the same blue field as the text
   inputs rather than as a button: it is a value being chosen, not
   an action, and the three fields underneath it are the thing it
   governs, so they should read as one group. */
.field-label {
    font-size: 11px; font-weight: 900; color: #fffa00;
    text-transform: uppercase; letter-spacing: 0.04em;
    margin-bottom: -8px;   /* pulls the label onto its field, against the panel's 14px gap */
}
.channel-select {
    background: #1b2fea; border: 2px solid #026dff; border-radius: 8px;
    padding: 10px 14px; color: #fff; font-size: 14px; outline: none; width: 100%;
    cursor: pointer;
}
.channel-select:hover, .channel-select:focus { border-color: #fffa00; }
/* The dropdown list itself is drawn by the OS, which does not
   inherit the field's colors — set explicitly so the open list
   isn't black-on-white against the rest of the panel. */
.channel-select option { background: #1b2fea; color: #fff; }
/* The network headings the channels are listed under (see
   editor.initChannelPicker). Upper case and bold so a heading
   cannot be mistaken for one more channel in a list where every
   other row is also a proper noun — the indent the platform gives
   its options is real but slight, and on its own it was doing all
   the work of telling a label from a choice.

   Not clickable, and not because of anything here: an optgroup
   label is inert by construction. What this styles is only how it
   READS. The colors are restated for the reason the options above
   restate them — the open list is the OS's own widget and inherits
   nothing from the field.

   The heading is the one row in the list that is not the name of
   something the user can pick, so it is also the one row allowed
   to be quieter than its neighbours: 12px against their 14. Bold
   and upper case are what make it stand out; size would only make
   it compete with the names underneath it. */
.channel-select optgroup {
    background: #1b2fea; color: #fff;
    font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
    font-size: 12px; font-style: normal;   /* Firefox italicises optgroup labels by default */
}
/* ...and the options inside a group go back to their own weight and
   case, which the label above would otherwise hand down to them. */
.channel-select optgroup option {
    font-weight: 400; text-transform: none; letter-spacing: normal; font-size: 14px;
}

/* The same picker above the link box, where the column's gap is
   10px rather than the panel's 14px — so the label's negative
   margin, which is tuned to sit ON its field, has to be eased off
   by the difference or it climbs into the field itself. */
.input-section .field-label { margin-bottom: -4px; }

/* How many frames to fetch — shown only for a channel that fetches
   them (see capture.syncCaptureFields). Same field as the link box
   above it, because it is the same kind of thing: a value being
   typed, in the same group, answering the same moment. Its own
   column so the label, the box and the hint stack the way the
   channel picker's three do. */
/* Frames with text / Frames only (Static Studio). Ordinary .btn
   buttons in a .btn-row; the one thing they need beyond that is to
   share the row's width equally, so the pair reads as one two-way
   switch the width of the link box under it rather than as two
   buttons of different lengths that happen to sit together. */
.output-mode-toggle .btn { flex: 1; }
/* "Add more images" and "Start a new set", side by side (main.syncSourceFields). */
.image-source-row .btn { flex: 1; }
#frameCountRow { display: flex; flex-direction: column; gap: 10px; }
#frameCountRow.hidden { display: none; }
/* Max characters per frame, for "Frames with text" — the label and
   its box on one line (see index.html for why). The label keeps its
   one line and the box takes the rest; the label's negative margin,
   which pulls a label down onto a field under it, has nothing to pull
   onto here. */
#captionCharsRow { display: flex; align-items: center; gap: 12px; }
#captionCharsRow.hidden { display: none; }
#captionCharsRow .field-label { margin: 0; white-space: nowrap; flex-shrink: 0; }
#captionCharsRow input { flex: 1; min-width: 0; }
/* Slider and its readout on one row, the readout wide enough for
   three digits so the track does not resize as the number changes. */
.count-control { display: flex; align-items: center; gap: 12px; }
.count-value {
    min-width: 3ch; text-align: right;
    color: #fffa00; font-size: 18px; font-weight: 900; font-variant-numeric: tabular-nums;
}
.count-slider {
    -webkit-appearance: none; appearance: none;
    flex: 1; height: 22px; background: transparent; outline: none; cursor: pointer;
    /* How much of the track is filled, set by capture.syncCountValue \u2014 the
       same arrangement the zoom bar uses, since a range input gives no way
       to style the filled portion on its own. */
    --count-fill: 0;
}
.count-slider::-webkit-slider-runnable-track {
    height: 8px; border-radius: 4px; border: 2px solid #026dff;
    background: linear-gradient(to right, #fffa00 calc(var(--count-fill) * 100%),
                                          #1b2fea calc(var(--count-fill) * 100%));
}
.count-slider::-moz-range-track {
    height: 8px; border-radius: 4px; border: 2px solid #026dff;
    background: linear-gradient(to right, #fffa00 calc(var(--count-fill) * 100%),
                                          #1b2fea calc(var(--count-fill) * 100%));
}
.count-slider::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 18px; height: 18px; margin-top: -7px; border-radius: 50%;
    background: #fff; border: 2px solid #026dff; cursor: grab;
}
.count-slider::-moz-range-thumb {
    width: 18px; height: 18px; border-radius: 50%;
    background: #fff; border: 2px solid #026dff; cursor: grab;
}
.count-slider:hover::-webkit-slider-thumb, .count-slider:focus::-webkit-slider-thumb {
    background: #fffa00; border-color: #fffa00;
}
.count-slider:hover::-moz-range-thumb, .count-slider:focus::-moz-range-thumb {
    background: #fffa00; border-color: #fffa00;
}
#frameCountRow #frameCountHint { margin: -4px 0 0; opacity: 0.75; }

/* Title fields with no channel chosen: visibly inert, but still
   focusable and still reporting keystrokes — that is what lets a
   typing attempt be answered rather than silently swallowed (see
   syncChannelFields). */
.line-input.locked, .line-block.locked { opacity: 0.45; cursor: not-allowed; }
.line-input.locked:hover, .line-input.locked:focus,
.line-block.locked:hover, .line-block.locked:focus { border-color: #026dff; }

/* The answer to that attempt. Red and inside the panel, right under
   the dropdown it is asking the user to use — a status line down at
   the page bottom would be nowhere near where they are looking. */
.panel-warn {
    background: #FF070C; color: #fff; font-weight: 700; font-size: 11px;
    padding: 8px 10px; border-radius: 6px; line-height: 1.4; text-align: center;
}
/* Restarted on every repeat attempt, so a second try gets a fresh
   answer instead of a message that has been sitting there since the
   first one. */
.panel-warn.flash { animation: warn-flash 0.28s ease-out; }
@keyframes warn-flash {
    0%   { transform: translateX(0); }
    25%  { transform: translateX(-4px); }
    60%  { transform: translateX(4px); }
    100% { transform: translateX(0); }
}

/* Displayed canvas takes 60% of the window's width (16:9 held by the
   canvas elements themselves; internal resolution stays 1280×720 for
   export). */
.canvas-container {
    width: 100%;
    margin: 0 0 12px;
    position: relative; overflow: visible;
}
.canvas-container canvas { width: 100% !important; height: auto !important; display: block; }
.canvas-container .canvas-container { width: 100% !important; height: auto !important; }
#thumbCanvas { cursor: grab; }
#thumbCanvas.dragging { cursor: grabbing; }
/* Hover feedback over the logo overlay (see setupReframeInteraction's
   logo hit-testing) — mutually exclusive with .dragging (each drag
   start clears these first), so cascade order doesn't matter. */
#thumbCanvas.hover-move { cursor: move; }
#thumbCanvas.hover-resize { cursor: nwse-resize; }
/* Over an asset's rotate handle. CSS has no "rotate" cursor, and the
   grabbing hand is what a turning knob is held with. */
#thumbCanvas.hover-rotate { cursor: grab; }

.reframe-hint { text-align: center; font-size: 12px; color: #fff; margin-bottom: 18px; }

/* Previous/next frame, flanking the canvas at its own mid-height.

   Positioned against .canvas-container rather than laid out in the
   column, so "beside the picture, halfway down it" stays true at every
   canvas size and in both modes - a portrait 540x960 and a landscape
   1280x720 have very different heights and neither number appears here.

   The offsets are not symmetrical, and that is the zoom bar's doing: it
   hangs off the right edge from +14 to +46 (see .zoom-bar), so the
   forward arrow starts outside it at +56 while the back one, with clear
   air on its side, sits at +12. Reading the two as a pair is what the
   shared mid-height does; matching their gaps would only have moved the
   crowding somewhere it could be seen. */
.frame-nav {
    position: absolute; top: 50%; transform: translateY(-50%); z-index: 4;
    background: none; border: 0; padding: 0 4px;
    font-size: 46px; line-height: 1; font-weight: 700;
    color: #fff; cursor: pointer; user-select: none;
    transition: color 0.12s ease;
}
.frame-nav.prev { right: 100%; margin-right: 12px; }
.frame-nav.next { left: 100%; margin-left: 56px; }
.frame-nav:hover { color: #fffa00; }
/* At either end of the set. Dimmed and inert rather than removed: the
   arrow's side of the canvas is how the user reads which way it goes,
   and one that disappears at the ends makes the other look like it
   moved. pointer-events keeps a disabled arrow from matching :hover, so
   it stays white under a mouse resting on it instead of flashing
   yellow at a click that will not happen. */
.frame-nav:disabled { opacity: 0.25; cursor: default; pointer-events: none; }

/* Actions sit right below the canvas; Download keeps 30% of the
   canvas's own width. */
.below-canvas {
    width: 100%; margin: 0;
    display: flex; justify-content: center; gap: 8px; flex-wrap: wrap;
}
.below-canvas #downloadBtn { width: 30%; }
/* Undo / Redo: the arrow and the word side by side, the arrow drawn in the
   button's text colour so it follows the yellow hover like the word does. */
.history-btns { display: flex; gap: 8px; }
.history-btns.hidden { display: none; }
.btn-history {
    display: inline-flex; align-items: center; gap: 6px;
}
/* The shortcut bubble over each of them, in the look of the "Split the
   text" bubble (.split-tip) so the page has one kind of tooltip, not two.
   Shown on the wrapper's hover, so it answers on a disabled button too. */
.history-tip-wrap { position: relative; display: inline-flex; }
.history-tip {
    position: absolute; left: 50%; bottom: calc(100% + 10px);
    transform: translateX(-50%) translateY(4px);
    width: max-content;
    padding: 6px 10px; border-radius: 8px;
    background: #080b1e; border: 1px solid #026dff; color: #fff;
    font-size: 12px; line-height: 1.4; text-align: center; white-space: nowrap;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
    opacity: 0; visibility: hidden; pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
    z-index: 20;
}
.history-tip::after {
    content: ""; position: absolute; top: 100%; left: 50%;
    margin-left: -6px; border: 6px solid transparent; border-top-color: #026dff;
}
.history-tip-wrap:hover .history-tip {
    opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0);
}
.history-icon {
    width: 16px; height: 16px; flex-shrink: 0;
    fill: none; stroke: currentColor; stroke-width: 2.6;
    stroke-linecap: round; stroke-linejoin: round;
}

.wide-layer {
    position: absolute; top: 0; left: 0; display: none; pointer-events: none;
    filter: grayscale(0.65) brightness(0.8); opacity: 0.45; z-index: 0;
}
.live-crop-layer {
    position: absolute; top: 0; left: 0; display: none; pointer-events: none; z-index: 3;
}

/* Vertical fine-zoom bar hugging the canvas's right edge: + circle on
   top (zoom in), − circle at the bottom (zoom out), slider between. */
.zoom-bar {
    position: absolute; left: 100%; top: 0; height: 100%;
    margin-left: 14px; width: 32px;
    display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.zoom-cap {
    width: 30px; height: 30px; border-radius: 50%; flex: 0 0 auto;
    background: #1b2fea; color: #fff; font-size: 18px; font-weight: 700;
    line-height: 1;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; user-select: none;
}
/* The glyph itself (not just its box) needs a hand-nudge to sit
   visually centered in the circle — "+" reads slightly high-left
   at this weight/size otherwise, "−" doesn't need it. */
#zoomInBtn { padding: 1px 0 0 1px; }
.zoom-cap:hover { background: #fffa00; color: #1b2fea; }
/* Divs, not <button>s (see setupReframeInteraction) — disabled via a
   class instead of the disabled attribute, while the editing
   pipeline is busy (see setControlsLocked). pointer-events:none
   means a locked cap can't match :hover at all, so it keeps
   showing its plain blue idle look (dimmed by the opacity below)
   instead of flipping yellow under a mouse that's just sitting
   over it. */
.zoom-cap.locked { opacity: 0.35; cursor: not-allowed; pointer-events: none; }
/* No hover styling here — only the +/- caps (.zoom-cap above) react
   to hover. The bar itself stays as-is regardless of mouse position.
   Custom-drawn (appearance: none) rather than accent-color: the
   browser bakes a faint gray edge into its own accent-color paint
   for this control, on both the filled and unfilled portions, and
   that edge isn't reachable through border/outline/box-shadow — it
   isn't a box-model property at all, just part of the native theme.

   Built as a HORIZONTAL slider, rotated -90deg, rather than the
   writing-mode: vertical-lr approach used earlier — that approach
   doesn't reliably center a custom (appearance: none) thumb across
   browsers (its cross-axis thumb-centering math is far less
   consistent/tested than a plain horizontal slider's), which is
   exactly the misalignment this replaces. A horizontal slider's
   thumb reliably centers when the INPUT's height matches the
   thumb's diameter — the standard, widely-used pattern — so this
   sidesteps that whole class of bug instead of fighting it.
   rotate(-90deg) on a plain min-at-left/max-at-right slider puts
   max at the top (rotating counter-clockwise swings the right end
   up), matching the bar's original vertical layout with no
   direction:rtl needed.

   The wrap (.zoom-slider-wrap) reserves the actual flex-allocated
   space (16px thick, flexible length); the input inside is
   absolutely centered in it and sized by JS (see syncZoomSliderSize)
   to the wrap's rendered height, since a CSS transform can't be
   expressed as "my own containing block's cross-axis size". */
.zoom-slider-wrap {
    position: relative; flex: 1 1 auto; min-height: 0; width: 16px;
}
.zoom-bar input[type="range"] {
    position: absolute; top: 50%; left: 50%;
    height: 16px; cursor: pointer;
    transform: translate(-50%, -50%) rotate(-90deg);
    -webkit-appearance: none; appearance: none;
    background: transparent;
    outline: none; border: none;
}
/* The blue/white split shows how far zoomed in the frame is —
   filled from the low end up to the current value, plain white
   past it. There's no native fill to read once accent-color is
   gone, so it's redrawn by hand as a gradient keyed off
   --zoom-fill, a 0..1 custom property JS keeps in sync with the
   slider's value (see updateZoomFill) — custom properties inherit
   from the input into its own pseudo-elements, so setting it once
   on the input reaches both track rules below. "to right" is the
   slider's own pre-rotation axis (min at left) — after the
   rotate(-90deg) above, that end visually lands at the bottom,
   matching "max (+) at the top". */
.zoom-bar input[type="range"]::-webkit-slider-runnable-track {
    height: 6px; border-radius: 3px; border: none; outline: none; box-shadow: none;
    background: linear-gradient(to right,
        #1b2fea 0%, #1b2fea calc(var(--zoom-fill, 0.5) * 100%),
        #fff calc(var(--zoom-fill, 0.5) * 100%), #fff 100%);
}
.zoom-bar input[type="range"]::-moz-range-track {
    height: 6px; border-radius: 3px; border: none; outline: none; box-shadow: none;
    background: linear-gradient(to right,
        #1b2fea 0%, #1b2fea calc(var(--zoom-fill, 0.5) * 100%),
        #fff calc(var(--zoom-fill, 0.5) * 100%), #fff 100%);
}
.zoom-bar input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 16px; height: 16px; border-radius: 50%;
    background: #1b2fea; cursor: pointer; border: none; outline: none; box-shadow: none;
    margin-top: -5px;  /* (16 - 6) / 2 — recenters the thumb on the 6px track within the 16px-tall input */
}
.zoom-bar input[type="range"]::-moz-range-thumb {
    width: 16px; height: 16px; border-radius: 50%;
    background: #1b2fea; cursor: pointer; border: none; outline: none; box-shadow: none;
}
.zoom-bar input[type="range"]:focus { outline: none; }
/* Thumb and track share the same <input> hit area, so one :hover
   on the input drives both at once — the filled (blue) portion of
   the track and the thumb both swap to yellow together. Only the
   filled stop moves; the white stop is untouched, so the unfilled
   portion never changes on hover. */
.zoom-bar input[type="range"]:not(:disabled):hover::-webkit-slider-thumb { background: #fffa00; }
.zoom-bar input[type="range"]:not(:disabled):hover::-moz-range-thumb { background: #fffa00; }
.zoom-bar input[type="range"]:not(:disabled):hover::-webkit-slider-runnable-track {
    background: linear-gradient(to right,
        #fffa00 0%, #fffa00 calc(var(--zoom-fill, 0.5) * 100%),
        #fff calc(var(--zoom-fill, 0.5) * 100%), #fff 100%);
}
.zoom-bar input[type="range"]:not(:disabled):hover::-moz-range-track {
    background: linear-gradient(to right,
        #fffa00 0%, #fffa00 calc(var(--zoom-fill, 0.5) * 100%),
        #fff calc(var(--zoom-fill, 0.5) * 100%), #fff 100%);
}
.zoom-bar input[type="range"]:disabled { opacity: 0.35; cursor: not-allowed; }

/* Fox-shaped loader shown over the canvas while a frame's restored
   wide view is loading — either the (at most once per frame)
   restoration pass building for the first time, or a reframe/zoom's
   crop+autofill settling. The fox starts white and a brand-blue
   fill sweeps left-to-right over it to read as progress, holds,
   fades back to white, and repeats. Both layers are masked/cut to
   the fox artwork's own alpha, so the transparent background around
   the fox stays transparent throughout. */
.reframe-spinner {
    position: absolute; inset: 0; display: none; z-index: 4;
    align-items: center; justify-content: center; pointer-events: none;
}
.fox-loader { position: relative; width: 30%; height: 30%; }
.fox-loader-base, .fox-loader-fill {
    position: absolute; inset: 0; width: 100%; height: 100%;
}
.fox-loader-base { object-fit: contain; }
.fox-loader-fill {
    -webkit-mask-image: url(fox.png); mask-image: url(fox.png);
    -webkit-mask-size: contain; mask-size: contain;
    -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
    -webkit-mask-position: center; mask-position: center;
    background: #1b2fea;
    animation: foxLoaderSweep 2s ease-in-out infinite;
}
@keyframes foxLoaderSweep {
    0%   { clip-path: inset(0 100% 0 0); opacity: 1; }
    45%  { clip-path: inset(0 0% 0 0); opacity: 1; }
    55%  { clip-path: inset(0 0% 0 0); opacity: 1; }
    65%  { clip-path: inset(0 0% 0 0); opacity: 0; }
    66%  { clip-path: inset(0 100% 0 0); opacity: 0; }
    100% { clip-path: inset(0 100% 0 0); opacity: 1; }
}

.controls { display: flex; flex-direction: column; gap: 10px; align-items: center; margin: 14px 0; }

.hidden { display: none; }

.brand-logo { height: 26px; width: auto; display: block; }

/* The frame's image overlays, one chip each. A chip is the picture
   itself plus a delete — the only per-overlay action there is. The
   active one (whose handles are on the canvas) is marked with the
   same yellow the rest of the UI uses for "this is the current one". */
.logo-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.logo-chip {
    position: relative; width: 68px; height: 68px;
    border: 2px solid #1b2fea; border-radius: 8px; overflow: hidden;
    background: #0b1533;
}
.logo-chip.active { border-color: #fffa00; }
.logo-chip img {
    width: 100%; height: 100%; object-fit: contain; display: block; cursor: pointer;
}
.logo-chip-del {
    position: absolute; top: 2px; right: 2px;
    width: 18px; height: 18px; padding: 0; line-height: 1;
    border: none; border-radius: 50%; cursor: pointer;
    background: #FF070C; color: #fff; font-size: 13px; font-weight: 900;
}
.logo-chip-del:hover { background: #fffa00; color: #FF070C; }

/* ── The mask step (js/mask.js) ───────────────────────────────────────
   Built out of parts the page already has, on purpose: the .btn pair
   with .btn-active held on the chosen shape, exactly as the edit
   presets and the output mode show theirs; the frame-count slider for
   zoom, with the canvas zoom bar's round caps either side of it; the
   side panel's blue-edged card for the box everything sits in. A step
   that looked designed for some other app would read as one.

   The backdrop is the page's own navy, translucent and blurred, so the
   frame the overlay is going onto stays faintly visible behind — the
   step is a moment in that frame's editing, not a separate place. */
.mask-step {
    position: fixed; inset: 0; z-index: 100;
    display: flex; align-items: center; justify-content: center;
    padding: 16px;
    background: rgba(6, 6, 16, 0.78);
    backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.mask-step.hidden { display: none; }
/* Nothing behind the step scrolls while it is up; the wheel over the
   stage zooms, and a page sliding underneath at the same time would
   be two things answering one gesture. */
body.mask-open { overflow: hidden; }
/* Opaque where the side panel is translucent: the panel sits on the
   page's own field, this sits on a photo, and a blue tint over a busy
   picture is a card nobody can read. The tint is kept as a gradient
   over the navy so it is still recognisably the panel's colour. */
.mask-card {
    width: 500px; max-width: 100%; max-height: 100%; overflow-y: auto;
    display: flex; flex-direction: column; gap: 14px;
    background: linear-gradient(rgba(27, 47, 234, 0.18), rgba(27, 47, 234, 0.18)), #080b1e;
    border: 1px solid rgba(2, 109, 255, 0.5); border-radius: 12px;
    padding: 20px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 250, 0, 0.04);
}
.mask-card h2 { margin: 0; }
.mask-hint { text-align: center; opacity: 0.75; margin-top: -6px; }
.mask-shape-row .btn { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
/* The shape, drawn on its own button, so the choice is legible before
   the word is read. currentColor, so it turns blue with the label when
   the button turns yellow. */
.mask-glyph { width: 12px; height: 12px; border: 2px solid currentColor; display: inline-block; flex: 0 0 auto; }
.mask-glyph-square { border-radius: 2px; }
.mask-glyph-round { border-radius: 50%; }
/* The stage is sized in mask.js (its drawing buffer follows the
   screen's density). The checkerboard behind it is the usual sign for
   "transparent": past fill, or outside the circle, that is what the
   exported picture will have there. The canvas paints over it
   everywhere the image is. */
.mask-canvas {
    display: block; margin: 0 auto; max-width: 100%; height: auto !important;
    aspect-ratio: 1 / 1;
    border-radius: 8px; cursor: grab; touch-action: none;
    background:
        repeating-conic-gradient(#141833 0% 25%, #0d1026 0% 50%) 50% / 20px 20px;
    border: 2px solid #026dff;
}
.mask-canvas.dragging { cursor: grabbing; }
/* The stage with the blur control standing to its left. min-width: 0 on
   the canvas lets it give up width on a narrow window instead of pushing
   the slider out of the card. */
.mask-stage-row { display: flex; align-items: stretch; gap: 12px; }
.mask-stage-row .mask-canvas { min-width: 0; flex: 1 1 auto; margin: 0; }
.mask-blur {
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    flex: 0 0 auto;
}
.mask-blur .field-label { margin: 0; }
.mask-blur .zoom-cap { border: none; padding: 0; font-family: inherit; }
/* The frame-count slider turned upright. writing-mode is what makes a
   range input vertical with its own keyboard and pointer handling intact
   (a rotate() would leave its hit box lying on its side), and rtl puts the
   minimum at the bottom, where "less" is everywhere else. Every rule of
   .count-slider that names a direction is restated for the other axis. */
.mask-blur .count-slider {
    writing-mode: vertical-lr; direction: rtl;
    flex: 1 1 auto; width: 22px; height: auto; min-height: 120px;
}
.mask-blur .count-slider::-webkit-slider-runnable-track {
    width: 8px; height: auto;
    background: linear-gradient(to top, #fffa00 calc(var(--count-fill) * 100%),
                                        #1b2fea calc(var(--count-fill) * 100%));
}
.mask-blur .count-slider::-moz-range-track {
    width: 8px; height: auto;
    background: linear-gradient(to top, #fffa00 calc(var(--count-fill) * 100%),
                                        #1b2fea calc(var(--count-fill) * 100%));
}
.mask-blur .count-slider::-webkit-slider-thumb { margin-top: 0; margin-left: -7px; }
.mask-zoom { display: flex; align-items: center; gap: 12px; }
/* The canvas zoom bar's caps are divs; these are real buttons, so the
   browser's own border and padding have to be taken off them first. */
.mask-zoom .zoom-cap { border: none; padding: 0; font-family: inherit; }
.mask-actions { margin-top: 6px; }
.mask-actions .btn { flex: 1; }
/* ── The asset step (js/assets.js) ────────────────────────────────────
   The mask step's card holding two views. Each view restates the card's
   own column and gap, because wrapping them in a box is what took the
   card's gap away from the things inside. Written against :not(.hidden)
   so the plain .hidden rule still wins without a fight over order. */
.asset-view:not(.hidden) { display: flex; flex-direction: column; gap: 14px; }
/* The shelf: one tile per asset, the picture on the checkerboard that
   means "transparent" in the mask step, its name underneath. Tiles are
   the overlay chips' blue-edged boxes grown to be pressed, turning
   yellow under the pointer like every other control on the page. */
.asset-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
    gap: 10px; max-height: 340px; overflow-y: auto; padding: 2px;
}
.asset-tile {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    padding: 8px; cursor: pointer;
    border: 2px solid #1b2fea; border-radius: 8px;
    background: #0b1533; color: #fff;
    font-size: 12px; font-weight: 700;
    transition: border-color 0.12s ease, transform 0.12s ease;
}
.asset-tile:hover, .asset-tile:focus-visible { border-color: #fffa00; outline: none; transform: translateY(-1px); }
.asset-tile img {
    width: 100%; aspect-ratio: 1 / 1; object-fit: contain; display: block;
    border-radius: 6px;
    background: repeating-conic-gradient(#141833 0% 25%, #0d1026 0% 50%) 50% / 14px 14px;
}
/* The preview. The canvas is sized to the asset's shape in assets.js;
   the checkerboard is behind the stage rather than the canvas so a tall
   or wide asset still sits in the same square every time.

   A LIGHT checkerboard, unlike the mask stage's dark one: the Drop shadow
   switch draws a dark shadow, and on the page's navy that switch would
   look as if it did nothing. Mid-light greys show the shadow and still
   let a white asset be told from the field. */
.asset-stage {
    display: flex; align-items: center; justify-content: center;
    width: 100%; max-width: 360px; aspect-ratio: 1 / 1; margin: 0 auto;
    padding: 20px; box-sizing: border-box;
    border: 2px solid #026dff; border-radius: 8px;
    background: repeating-conic-gradient(#c9ccd8 0% 25%, #b3b7c6 0% 50%) 50% / 20px 20px;
}
.asset-canvas { display: block; max-width: 100%; max-height: 100%; height: auto; }
/* The browser's own colour well, made the size of a swatch and stripped
   of the grey frame it is drawn in. Shared by the asset step and the mask
   step's contour, which ask the same question. */
.asset-color-row { display: flex; align-items: center; gap: 10px; }
.color-well {
    flex: 0 0 auto; width: 48px; height: 42px; padding: 0;
    border: 2px solid #026dff; border-radius: 8px; background: none; cursor: pointer;
}
.color-well:hover { border-color: #fffa00; }
.color-well::-webkit-color-swatch-wrapper { padding: 3px; }
.color-well::-webkit-color-swatch { border: none; border-radius: 5px; }
.color-well::-moz-color-swatch { border: none; border-radius: 5px; }
/* The contour's switch and its colour, side by side: the colour is a
   property of the contour, not a setting of its own. Dimmed while the
   contour is off, but still pressable — picking a colour turns it on. */
.mask-contour-row { display: flex; align-items: center; gap: 10px; }
.mask-contour-row .btn { flex: 1; }
.mask-contour-row:not(.on) .color-well { opacity: 0.45; }

/* The frame mask step (js/framemask.js). Wider than the other mask cards,
   because it holds two pictures side by side: the stage the window is drawn
   on, and the miniature of the finished frame with the controls under it.
   The stage's size is set in framemask.js from the canvas's own shape. */
.frame-mask-card { width: 760px; }
.frame-mask-body { display: flex; gap: 18px; align-items: flex-start; }
.frame-mask-canvas {
    display: block; flex: 0 0 auto; max-width: 100%;
    border-radius: 8px; cursor: crosshair; touch-action: none;
    border: 2px solid #026dff;
    background: #0d1026;
}
.frame-mask-side {
    display: flex; flex-direction: column; gap: 8px;
    flex: 1 1 auto; min-width: 0;
}
.frame-mask-side .field-label { margin: 6px 0 0; }
.frame-mask-side .field-label:first-child { margin-top: 0; }
.frame-mask-thumb {
    display: block; align-self: flex-start;
    border-radius: 6px; border: 1px solid rgba(2, 109, 255, 0.5);
    background: #0d1026;
}
.frame-mask-side .swatch-row { flex-wrap: wrap; gap: 8px; }
.frame-mask-well-hint { margin: 0; opacity: 0.7; }
/* On a narrow window the two halves stack, stage first. */
@media (max-width: 720px) {
    .frame-mask-body { flex-direction: column; align-items: center; }
    .frame-mask-side { width: 100%; }
}
/* The title panel's shadow and outline (see #textEffects), built from the
   contour row above and the frame-count slider. Its own column with a
   tighter gap than the panel's, so the three rows read as one setting.
   `:not(.hidden)` because .hidden is declared earlier in this file and a
   plain display here would win over it. The readout is widened to fit
   "12px", so the track does not jump as the number gains a digit. */
.text-effects:not(.hidden) { display: flex; flex-direction: column; gap: 10px; }
.text-effects .field-label { margin: 0; }
.text-effects .count-value { min-width: 4ch; }
/* Off, the well is swapped for the "none" swatch rather than dimmed the
   way the mask step's is: a dimmed black well still reads as "black",
   and nothing is being drawn in black. The swatch takes the well's size
   so the row does not shift as the two trade places. */
.text-effects .color-well-off { flex: 0 0 auto; width: 48px; height: 42px; }
.text-effects .mask-contour-row:not(.on) .color-well,
.text-effects .mask-contour-row.on .color-well-off { display: none; }
/* The textboxes' controls (see #textboxControls): a column with the same
   tight gap as the text effects, so each card's field, words, font, colours,
   alignment, effects and remove button read as one thing rather than seven
   settings. The same `:not(.hidden)` guard as the rule above, for the same
   reason. */
.textbox-controls:not(.hidden),
.textbox-panel:not(.hidden) { display: flex; flex-direction: column; gap: 10px; }
.textbox-panel .field-label { margin: 0; }
.textbox-controls > .btn-row .btn,
.textbox-panel > .btn-row .btn { flex: 1; }
/* One card per textbox, each ruled off from the next, so three of them
   stacked read as three blocks and not as one long list of controls. */
.textbox-list { display: flex; flex-direction: column; gap: 18px; }
.textbox-list:empty { display: none; }
.textbox-list .textbox-panel + .textbox-panel {
    padding-top: 18px; border-top: 1px solid rgba(255, 255, 255, 0.14);
}
.textbox-title { color: #fffa00; }
.asset-toggle-row .btn { flex: 1; padding-left: 8px; padding-right: 8px; }
.asset-hex { flex: 1 1 auto; text-transform: uppercase; font-family: Consolas, "Courier New", monospace; }
/* The "video ready" notice (see js/notify.js): a message, not a tool, so
   the card is narrower and its few lines centred. */
.ready-card { width: 380px; text-align: center; }
/* The framing step's stage (js/framecrop.js): the mask stage's look, with
   the shape left to the script — it is the video's, not a square. No
   checkerboard behind it, because nothing in this window is ever
   transparent: the picture always covers it. */
.frame-crop-canvas {
    display: block; margin: 0 auto; max-width: 100%; height: auto;
    border-radius: 8px; cursor: grab; touch-action: none;
    background: #0d1026;
    border: 2px solid #026dff;
}
.frame-crop-canvas.dragging { cursor: grabbing; }

/* ── The user's own text, on a "Frames only" run (js/mytext.js) ──────
   The width of the link box above it and stacked the same way, so it
   reads as the next step of the same column. The box is the title
   block's own field: the text typed here ends up as titles, and it
   looks like the field it will later be edited in.

   Unlike that field it does not grow to fit — a pasted script can run
   to pages — so it scrolls, and the user can drag it taller. */
.my-text-section {
    display: flex; flex-direction: column; gap: 10px;
    max-width: 500px; margin: 0 auto 24px;
}
.my-text-section.hidden { display: none; }
/* The run's setup and the user's own text: one column of two 500px
   blocks everywhere they do not both fit across, which is how they
   have always stood. Once both are on screen and the window holds
   them side by side, they stand side by side - the second block
   starting level with the first rather than half a screen below it.
   Keyed on the text block being shown rather than on a mode, because
   that block is the one that comes and goes (see js/mytext.js). */
.source-row { display: contents; }
@media (min-width: 1100px) {
    .source-row:has(> .my-text-section:not(.hidden)) {
        display: flex; justify-content: center; align-items: flex-start;
        gap: 40px; margin-bottom: 24px;
    }
    .source-row:has(> .my-text-section:not(.hidden)) > .input-section,
    .source-row:has(> .my-text-section:not(.hidden)) > .my-text-section {
        flex: 0 1 500px; margin: 0;
    }
}
.my-text-input {
    min-height: 120px; max-height: 40vh;
    overflow-y: auto; resize: vertical;
}
/* The box and "Max characters per frame" side by side: the number is a
   setting OF the box, and beside it is where it reads as one. The box
   takes whatever width is left; on a phone there is too little for both
   and the field drops under it.

   A grid rather than two flex columns because of the labels. "Your
   text" is one line and "Max characters per frame" wraps to two in
   110px, so two columns that each stack label-then-field start their
   fields at different heights and the box and the number no longer
   line up. Here the labels share the first row, sit on its bottom
   edge, and both fields start together on the second. The number's
   wrapper steps aside (display: contents) so its label and input can
   be placed in that grid directly; nothing in the JS looks it up. */
.my-text-row {
    display: grid; grid-template-columns: minmax(0, 1fr) 110px;
    grid-template-areas: "text-label chars-label" "text chars";
    column-gap: 10px; row-gap: 6px; align-items: end;
}
.max-chars-field { display: contents; }
.my-text-row .field-label { margin-bottom: 0; line-height: 1.3; }
.my-text-label { grid-area: text-label; }
.my-text-row .my-text-input { grid-area: text; align-self: start; }
.max-chars-field .field-label { grid-area: chars-label; }
.max-chars-input { grid-area: chars; align-self: start; width: 100%; text-align: center; }
@media (max-width: 480px) {
    .my-text-row {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas: "text-label" "text" "chars-label" "chars";
    }
    /* The 6px that holds a label onto its field is too little between
       the box and the next field's label, which would then read as a
       caption of the box above it. */
    .max-chars-field .field-label { margin-top: 6px; }
}
/* The Split button and the bubble that explains it while it is locked.
   The wrapper is what the pointer is over: a disabled button takes no
   pointer events in every browser, so it is made transparent to them
   and the wrapper answers the hover and shows the not-allowed cursor
   the button would have shown. */
.split-wrap { position: relative; }
.split-wrap .btn { width: 100%; }
.split-wrap.locked { cursor: not-allowed; }
.split-wrap.locked .btn { pointer-events: none; }
/* The bubble: the mask card's navy and blue edge, with a point aimed
   at the button. Above it rather than below, so it never lands on the
   status line or the grid the button is about. */
.split-tip {
    position: absolute; left: 50%; bottom: calc(100% + 10px);
    transform: translateX(-50%) translateY(4px);
    width: max-content; max-width: min(320px, 90vw);
    padding: 8px 12px; border-radius: 8px;
    background: #080b1e; border: 1px solid #026dff; color: #fff;
    font-size: 12px; line-height: 1.4; text-align: center;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
    opacity: 0; visibility: hidden; pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
    z-index: 20;
}
.split-tip::after {
    content: ""; position: absolute; top: 100%; left: 50%;
    margin-left: -6px; border: 6px solid transparent; border-top-color: #026dff;
}
.split-wrap.locked:hover .split-tip {
    opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0);
}


/* ── Frame-fetch mode ─────────────────────────────────────────────

   One channel does not make thumbnails: it hands back a numbered set
   of stills (see js/capture.js). Everything below is what that costs
   the page, and it is stated here rather than in each control's own
   sync function for the reason the module header gives — a dozen
   buttons each answering a second question is a dozen answers that
   have to keep agreeing, where one stylesheet rule cannot disagree
   with itself.

   !important throughout, because every one of these controls is
   shown and hidden by its own JavaScript against its own
   channel-shaped question. This is not arguing with that logic; it
   is saying the control is not part of this mode at all. */

/* There is no title, no brand, no cutout and no overlay on a fetched
   frame, so the entire side panel has nothing to ask about. The
   canvas then has the row to itself.

   Unless the frames arrive with words on them. A capture channel can
   ask for the sentence that was being said over each still (see
   `capture.captions` in js/channels.js), and then the panel is the
   only place that sentence can be edited — so the mode that hides it
   is the one that has nothing to write, not capture mode as such.
   The class is set alongside capture-mode itself, from the same
   place, so the two can never describe different runs (see
   capture.enterMode). */
body.capture-mode:not(.captions-mode) .text-panel { display: none !important; }

/* Nothing that composes a thumbnail: no flip (there is no title for
   the picture to sit beside), no gradient (nothing to darken the
   frame for), no replacement (the frame IS the deliverable). What is
   left around the canvas is the zoom bar, Variation and the
   downloads, which is what the mode is for.

   Variation stays because on a frame fetch it answers the one
   question the grid cannot: this moment is nearly right, show me the
   one beside it. The backend runs a search of its own for these
   frames — same scene, no softer, eyes open where there is a subject
   (see vary.pick_capture_variation).

   ...and Flip image stays on a capture channel that composes from a
   CUTOUT, which is the one case the paragraph above does not cover.
   It was written when a frame fetch always meant the still itself,
   where mirroring is either pointless or actively wrong — every
   sign and caption in the picture comes out backwards. On a channel
   with figures the same button mirrors ONE FIGURE against the
   channel's own ground (see editor.syncFlipButtons and toggleFlip),
   which is an ordinary compositional move and the only way to turn a
   subject to face the type. Told apart by a class set from the
   CHANNEL rather than from the run — see
   editor.syncTitlePanelMode.

   Gradient stays on a frame whose channel states a `scrim`, the other
   case the first paragraph does not cover. "Nothing to darken the frame
   for" is about the backend's side gradient; a scrim is a shade from the
   foot of the frame drawn on the canvas, and this button is its only
   switch. Hidden, the shade was on every still of such a channel for
   good. Told apart by `scrim-frame` — see editor.syncGradientButton. */
body.capture-mode:not(.cutout-channel) #flipImageBtn,
body.capture-mode #flipTextBtn,
body.capture-mode #frameUploadBtn,
body.capture-mode:not(.scrim-frame) #gradientBtn,
body.capture-mode #bgBtn,
body.capture-mode #figureGlowBtn { display: none !important; }

/* ...and the one control that only exists here. */
body.capture-mode #downloadAllBtn { display: inline-block !important; }

/* A portrait canvas at the landscape one's width would be over a
   screen tall. Sized to stay comfortably inside the viewport
   instead, since a frame nobody can see all of cannot be judged. */
body.capture-mode .canvas-col {
    width: min(340px, 70vw); max-width: 100%; min-width: 200px;
}
body.capture-mode .editor { margin-bottom: 8vh; }

/* Forty portrait cards, not twenty landscape ones: five fixed
   columns would be eight rows deep. Auto-filled to whatever the row
   holds, so the grid grows sideways with the window rather than
   downward with the count. */
body.capture-mode .frames-grid {
    grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
}
body.capture-mode .frame-card img { aspect-ratio: 9 / 16; }

/* Rearranging the grid (js/reorder.js). The grab cursor says a card
   can be picked up; the card being held is dimmed where it sits, so
   the gap it will drop into reads as a gap while the pointer carries
   the card's own picture. */
body.capture-mode .frame-card { cursor: grab; }
body.capture-mode .frame-card.dragging { opacity: 0.3; border-color: #fffa00; border-style: dashed; }
.reorder-hint { text-align: center; margin-top: -8px; }
body:not(.capture-mode) .reorder-hint { display: none; }

/* A frame the edit has not reached yet. Grey and inert, turning to
   its own colours the moment its pixels are the finished ones (see
   ui.markFrameReady) — so the grid fills in visibly, left to right,
   and what the user can click is exactly what is ready to be
   looked at.

   Two states rather than a spinner on each card, because forty
   spinners is not information: the question a user has at that
   moment is "which of these can I open", and colour answers it
   across the whole grid at a glance.

   It used to take no pointer at all (pointer-events: none), which
   was the simplest way to say "not a control yet". It has to take
   one now, because a card can be dragged into a new place at any
   point of the run, grey or not (see js/reorder.js). So the click is
   refused in main.renderGrid instead, and the card here only stops
   looking like something to open: no highlight on hover, and the
   grab cursor every card of a frame fetch wears. */
body.capture-mode .frame-card.pending,
body.capture-mode .frame-card.pending:hover {
    border-color: transparent;
}
body.capture-mode .frame-card.pending img {
    filter: grayscale(1) brightness(0.55) contrast(0.9);
}
/* The transition belongs to the image, so a card arriving does it as
   a fade rather than a jump. */
.frame-card img { transition: filter 0.35s ease; }
/* ...and the badge stays legible on a card that is still grey, since
   it is the frame's number and the number is what the user is
   waiting to be able to use. */
body.capture-mode .frame-card.pending .badge { opacity: 0.55; }
body.capture-mode .frame-card.pending .pick { display: none; }

/* The X that discards a frame (main.discardFromGrid). Top right, where
   the eye goes to close something, and at full strength on a grey card
   as on a finished one — throwing a frame out before the edit reaches
   it is the point of having it there early. The batch tick, which used
   to own that corner, moves to the bottom one on a frame fetch: a
   mark-for-download beside a throw-away is two very different clicks a
   few pixels apart. */
.frame-card .discard {
    position: absolute; top: 3px; right: 3px;
    width: 20px; height: 20px; padding: 0;
    border: none; border-radius: 4px;
    background: #e0201b; color: #fff;
    cursor: pointer; z-index: 1;
    display: flex; align-items: center; justify-content: center;
}
.frame-card .discard::before,
.frame-card .discard::after {
    content: ""; position: absolute;
    width: 12px; height: 2px; border-radius: 1px; background: currentColor;
}
.frame-card .discard::before { transform: rotate(45deg); }
.frame-card .discard::after { transform: rotate(-45deg); }
.frame-card .discard:hover { background: #ff3b30; }
.frame-card .discard:focus-visible { outline: 2px solid #fffa00; outline-offset: 1px; }
body.capture-mode .frame-card .pick { top: auto; bottom: 3px; }

/* The "Add image" tile at the end of a frame fetch's grid
   (main.addOwnFrame). The shape of a card, so it reads as the place the
   next frame goes, and dashed, so it does not read as a frame already
   there. Not a .frame-card: reorder.js rearranges exactly those, and a
   tile that could be dragged into the middle of the set would be a frame
   numbered among the others that is not one. */
.frame-add {
    aspect-ratio: 9 / 16; width: 100%;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
    border: 2px dashed rgba(2, 109, 255, 0.7); border-radius: 4px;
    background: rgba(27, 47, 234, 0.12); color: #fff;
    font-family: inherit; font-size: 12px; font-weight: 700;
    cursor: pointer; padding: 6px; text-align: center;
}
.frame-add:hover:not(:disabled) { border-color: #fffa00; color: #fffa00; }
.frame-add:focus-visible { outline: 2px solid #fffa00; outline-offset: 1px; }
.frame-add:disabled { opacity: 0.5; cursor: progress; }
.frame-add-plus { font-size: 30px; line-height: 1; font-weight: 400; }

/* ── The caption panel, turned on its side ────────────────────────

   Everywhere else the canvas is landscape and the panel is the only
   thing that can go beside it. Here the canvas is 540x960: it takes
   a third of the row's width and all of its height, which leaves a
   column of three stacked sections running far below the picture
   they belong to, and a wide band of empty page either side of it.

   So the three sections turn and sit side by side. The panel stops
   at the bottom of the canvas column instead of running to twice
   its height, the row is read across rather than scrolled down, and
   the space a portrait frame gives back is what pays for it.

   `align-items: stretch` on the row is what holds the panel to that
   height without anybody writing a height down. The canvas column
   is the tallest thing in the row, so the panel is stretched to
   exactly it - flush at the top with the canvas and at the foot
   with the download buttons under it - and if the canvas is
   resized, by the window or by a channel with a different `output`,
   the panel follows with no number here to update. That matters more than it
   looks: the 540x960 is the pack's, and content/README.md is
   explicit that neither half of the app keeps a second copy of it. */
body.captions-mode .editor { align-items: stretch; }
/* Three columns, four sections. The caption's controls and the second
   textbox's each get a column of their own, because they are what
   grew: with the colours, the textbox and its own colours, the effects
   and the hints all in the first column, that one ran far past the
   canvas and had to be scrolled while the other two stood half empty.
   "Edit preset" and "Image overlay" are a few buttons each, so they
   share the third column, one over the other.

   `contain: size` with a stated width is what holds the panel to the
   canvas column's height. Without it the panel's own content is one
   of the heights the row stretches to, and a long caption column
   makes the whole editor - canvas included - taller than the screen;
   contained, the row is as tall as the canvas column and each section
   scrolls inside it. The width is the three columns, the padding and
   the border; the min-height is for a window narrow enough that the
   panel wraps under the canvas, where there is no canvas beside it to
   take a height from. */
body.captions-mode .text-panel {
    display: grid; gap: 0; padding: 20px 4px;
    grid-template-columns: 290px 250px 190px;
    grid-template-rows: auto minmax(0, 1fr);
    width: 740px; flex: 0 0 740px;
    contain: size; min-height: 520px;
}
/* Each section becomes a column of its own. min-height: 0 is what lets
   a section scroll instead of pushing its grid row taller than the
   panel - without it a grid item refuses to shrink below its content
   and the whole point is lost. */
body.captions-mode .panel-group {
    display: flex; flex-direction: column; gap: 14px;
    padding: 0 16px; min-height: 0; overflow-y: auto;
}
body.captions-mode .panel-group:nth-child(1) { grid-column: 1; grid-row: 1 / -1; }
body.captions-mode .panel-group:nth-child(2) { grid-column: 2; grid-row: 1 / -1; }
body.captions-mode .panel-group:nth-child(3) { grid-column: 3; grid-row: 1; }
body.captions-mode .panel-group:nth-child(4) { grid-column: 3; grid-row: 2; }
/* The divider turns with them: between columns it is a line down the
   side, not across the top - except between the two sections that
   share the last column, where it is across again. */
body.captions-mode .panel-group:not(:first-child) {
    border-left: 1px solid rgba(255, 255, 255, 0.14);
}
body.captions-mode .panel-group:not(:first-child) > h2 {
    margin-top: 0; padding-top: 0; border-top: none;
}
body.captions-mode .panel-group:nth-child(4) {
    margin-top: 18px; padding-top: 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.14);
}
/* The textbox column's heading only exists where it is a column. On
   a thumbnail channel the section is part of the caption's run and a
   heading there would be a divider in the middle of one block. */
.panel-group-more > h2 { display: none; }
body.captions-mode .panel-group-more > h2 { display: block; }
/* The actions under a portrait canvas, three to a row instead of two,
   so the column they hang from - and with it the whole editor row - is
   two rows shorter. The canvas is only 340px wide here, and at the
   landscape buttons' padding three of them do not fit across it. */
body.captions-mode .below-canvas { gap: 6px; }
body.captions-mode .below-canvas .btn { padding: 8px 10px; font-size: 11px; }
body.captions-mode .below-canvas #downloadBtn { width: auto; }
/* The caption is the reason this channel has a panel at all, so it
   gets the height the other two do not need. */
body.captions-mode #lineBlock { flex: 1 1 auto; min-height: 96px; resize: none; }
/* ── Top bar: the logo on the left, the two apps on the right ─────────
   Centred on each other, which only means something once the logo's
   box IS the logo. BLUEROOM.png is a 6144px square with the artwork in
   a band across the middle - measured, rows 2374-3376 and columns
   544-5579 - so at 250px the box is mostly transparent, and centring
   or top-aligning that box against the buttons lines them up with
   empty space instead of with the word. The negative margins below
   are those measurements as fractions of the image, cutting the
   layout box down to the artwork while the picture still draws whole
   (nothing is clipped, so the glow around the fox survives). Derived
   from --logo-size, so resizing the logo cannot quietly undo it; a
   new logo file needs the fractions measured again.

   The left cut also puts the artwork's left edge on the column's,
   matching the buttons' right edge on the other side.

   The bar's bottom margin keeps the page title where it stood when
   the full 250px box was what pushed it down. */
.top-nav {
    --logo-size: 250px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    width: 100%;
    padding-top: 18px;
    margin-bottom: 126px;
}

.brand { display: flex; align-items: center; flex-shrink: 0; }

.brand-fox {
    height: var(--logo-size);
    width: auto;
    max-height: none;
    display: block;
    margin: calc(var(--logo-size) * -0.3864) calc(var(--logo-size) * -0.0919)
            calc(var(--logo-size) * -0.4505) calc(var(--logo-size) * -0.0885);
}

/* The two apps, as the app's own buttons: the blue .btn at rest, the
   yellow of .btn-active on the one that is open, yellow on hover - the
   same one-of-several switch the output mode buttons under the title
   are, rather than a second button system of its own at the top of the
   page. The JS marks the open one with .active (setAppMode in main.js),
   so that is the class that wears the yellow here. */
.mode-tabs { display: flex; gap: 8px; }

.tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.tab-btn.active { background: #fffa00; color: #1b2fea; }

/* The platform logos, kept as they are drawn in their files but painted
   in the button's own text colour through a mask - see the comment on
   .mode-tabs in index.html for why not an <img>. */
.tab-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    background: currentColor;
    -webkit-mask: var(--icon) center / contain no-repeat;
    mask: var(--icon) center / contain no-repeat;
}
.tab-icon-youtube { --icon: url("youtube.png"); }
.tab-icon-snapchat { --icon: url("snapchat.png"); }
/* The edit presets stay a column, which is worth writing down because
   the obvious move here is to lay them across. Measured, they do not
   go: "Restore only", "Natural" and "Heavy edit" are 136, 98 and 113
   pixels wide against a column of 190, so a row of them wraps to the
   same three lines it started with and only loses the left edge they
   currently share. */

/* ── Maintenance screen (maintenance.html) ─────────────────────────────
   Nothing here sets a background: the page inherits body's navy field and
   the blurred blue glow along the top edge, so it reads as the same app.

   The logo is 2x the top bar's (.brand-fox is 250px; this is 500px) and
   its -45px trim is doubled with it, because that trim exists to cancel
   the transparent margin baked into BLUEROOM.png and the margin scales
   with the picture. It is capped by max-width so a phone shrinks it
   instead of scrolling sideways. */
.maintenance { display: flex; flex-direction: column; align-items: center; }
.maintenance-logo {
    height: 500px; width: auto; max-width: 100%;
    object-fit: contain; display: block;
    margin-top: -190px; margin-bottom: -200px;
}
.maintenance-message { max-width: 1000px; width: 100%; text-align: center; margin-bottom: 28px; }
.maintenance-message h1 { font-size: clamp(14px, 2.6vw, 28px); line-height: 1.2; margin-bottom: 14px; white-space: nowrap; }
.maintenance-message .nowrap { display: block; white-space: nowrap; }
.maintenance-message p { font-size: 16px; line-height: 1.55; color: #fff; margin-bottom: 18px; }
.maintenance-message .maintenance-cta { font-weight: 800; color: #fffa00; }
/* Same blue frame the inputs wear. The height is the game's own layout at
   desktop width (masthead, screen, controls); below 920px the game stacks
   its postcard album under the screen and needs the extra rows. */
.maintenance-game {
    width: 100%; max-width: 1180px; height: 820px;
    border: 2px solid #026dff; border-radius: 8px;
    background: #0d0f22; margin-bottom: 48px;
}
@media (max-width: 920px) {
    .maintenance-logo { height: 320px; margin-top: -122px; margin-bottom: -128px; }
    .maintenance-game { height: 1250px; } /* fallback only; see the script in maintenance.html */
}
