:root {
    --main-dark-sea-green: #A6C2B4;
    --main-salmon: #E8AD6B;
    --main-grey-2: #60605c;
    --main-grey-3: #60605c;

    /* Bulma primary -> #F47A36 */
    --bulma-primary-h: 21deg;
    --bulma-primary-s: 90%;
    --bulma-primary-l: 58%;
    /* white text on primary bg (Bulma auto-picks dark; override) */
    --bulma-primary-invert-l: 100%;
    --bulma-primary-invert: #fff;

    /* Translucent white behind a panel that floats over the canvas. Shared with
       the landing page's demo timeline, which mimics this one. */
    --panel-wash: rgba(255, 255, 255, 0.55);

    /* The guided tour has to clear #overlayCanvas (1101), which paints pointer chrome over
       everything below it, while staying under the error toast (9999) so errors still show. */
    --z-guide: 9000;

    /* Discord brand pair. Duplicated from theme.css, which the app page does not load;
       kept under the same names so a colour change is one grep across both files. */
    --tw-discord: #5865f2;
    --tw-discord-dark: #4b57e8;

    /* One timeline frame column. Mirrors TimeLineView.frameButtonWidth; the pinned layer
       columns and the scrubber's left offset are both sized from it. */
    --frame-col-w: 42px;
}

@-webkit-keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@-webkit-keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

/* .layer-header {
    width: 130px;
    height: 40px;
} */

.layer-text {
    width: 60px;
}

html {
    overflow-x: auto !important;
}

/* Safari-style overlay scrollbars (Firefox + Chromium) */
* {
    scrollbar-width: auto;
    scrollbar-color: rgba(0, 0, 0, 0.35) transparent;
}

*::-webkit-scrollbar {
    width: 16px;
    height: 16px;
}

*::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 10px;
}

*::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.35);
    border-radius: 10px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

*::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.55);
    background-clip: padding-box;
    border: 2px solid transparent;
}

*::-webkit-scrollbar-corner {
    background: transparent;
}

body {
    position: relative;
    touch-action: manipulation;
}

canvas {
    /*display: block;*/
    display: block;
    margin: auto;
    /* background: #d1d1d1; */
    cursor: crosshair;
    border-style: solid;
    border-width: 1px;
    border-color: #eeeeee;
    z-index: 1100;
    touch-action: manipulation;
}


/* Stacked over #paintCanvas. Keeps the 1px border width of the shared canvas rule so both
   border boxes are identical; syncOverlay() then copies paintCanvas.offsetLeft/offsetTop
   straight into left/top. That only holds while .canvas-wrapper stays unpositioned, which
   getMouseX/Y independently require — do not add position to it. */
#overlayCanvas {
    position: absolute;
    left: 0;
    top: 0;
    margin: 0;
    border-color: transparent;
    background: transparent;
    pointer-events: none;
    z-index: 1101;
}

canvas.cursor-eyedropper {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20'%3E%3Cpath d='M13 1 L19 7 L8 18 L4 18 L2 16 L2 12 Z' fill='white' stroke='black' stroke-width='1.2' stroke-linejoin='round'/%3E%3Cpath d='M2 12 L2 18 L8 18' fill='none' stroke='black' stroke-width='1.2'/%3E%3Cpath d='M13 1 L15 3' stroke='black' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E") 2 18, crosshair;
}

#nav-toggle-state {
    display: none;
}

#nav-toggle-state:checked ~ .nav-menu {
    display: block;
}

#dropdown-toggle-state {
    display: none;
}

#dropdown-toggle-state:checked ~ .dropdown-menu {
    display: block;
    -webkit-animation: fadeIn 0.5s;
    animation: fadeIn 0.5s;
}

#timeline-toggle-state {
    display: none;
}

#timeline-toggle-state:checked ~ .timeline-content {
    position: absolute;
}

.timeline-content {
    padding: 10px;
    margin-bottom: 10px;
    margin-left: 10px;
    margin-right: 10px;
    display: block;
    background: var(--panel-wash);
    /* width: fit-content; */
}

.toggle-timeline-nav{
   margin-left: 10px;
}

.check_item {
    display: none !important;
}

.label_item {
    opacity: 0.4;
}

.check_item:checked + label,
.label_item.is-toggled {
    opacity: 1;
}

/* ── Tool labels (hover tag to the right; tap-flash on touch) ─────────────── */
.tool-button {
    position: relative;
}

.tool-button[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 8px;
    padding: 3px 8px;
    white-space: nowrap;
    font-size: 12px;
    line-height: 1.4;
    color: #fff;
    background: rgba(0, 0, 0, 0.8);
    border-radius: 4px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 30;
}

@media (hover: hover) {
    body.tool-labels-on .tool-button[data-tooltip]:hover::after {
        opacity: 1;
    }
}

body.tool-labels-on .tool-button.show-label::after {
    opacity: 1;
}

.color-picker-wrapper {
    margin-right: 10px;
    margin-top: 10px;
}

/* ── Brush size pill (pencil/line/eraser/weld), sits left of the colour swatch ─── */
.brush-size-wrapper {
    margin-top: 10px;
    /* clears the 4rem .sp-replacer plus both 10px gutters */
    margin-right: calc(4rem + 20px);
    width: 9rem;
    height: 2.2rem;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 0.55rem;
    /* same corner as the TweenArt/File/Edit buttons beside it */
    border-radius: var(--bulma-radius, 0.375rem);
    background: rgba(255, 255, 255, 0.65);
}

/* Fix alpha slider + input spacing */
.sp-alpha-enabled .sp-input-container {
    margin-top: 6px !important;
}

/* Palette rows as flex rows — no more overflow */
.sp-palette-row {
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
}

/* Palette swatches — bigger, touch-friendly */
.sp-palette .sp-thumb-el {
    float: none !important;
    width: 22px !important;
    height: 22px !important;
    margin: 2px !important;
    border-radius: 3px !important;
    flex-shrink: 0 !important;
}

/* Bigger trigger (replacer) button */
.sp-replacer {
    width: 4rem !important;
    height: 2.2rem !important;
    border-radius: 4px !important;
}

/* ── Spectrum custom injections ───────────────────────────────────────────── */

/* Tools row: sits inside .sp-picker-container, above choose/cancel */
.sp-custom-tools {
    border-top: 1px solid #eee;
    padding: 6px 0 2px;
    margin-top: 2px;
}

.sp-tools-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Hidden checkbox; label wraps the pips */
.sp-grad-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    user-select: none;
    flex-shrink: 0;
}
.sp-grad-toggle input[type="checkbox"] { display: none; }

.sp-grad-pip {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: 2px solid #ccc;
    cursor: pointer;
    flex-shrink: 0;
    transition: border-color 0.12s;
    background: #fff;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}
.sp-grad-pip.sp-grad-active {
    border-color: #2980b9;
    box-shadow: 0 0 0 2px rgba(41,128,185,0.2);
}

/* Red × overlay when gradient is off */
.sp-grad-pip.sp-grad-end-off::after {
    content: '✕';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #e74c3c;
    font-size: 13px;
    font-weight: bold;
    line-height: 1;
    border-radius: 2px;
    background: rgba(255,255,255,0.55);
}

.sp-grad-sep {
    font-size: 12px;
    color: #aaa;
    flex-shrink: 0;
}

/* Gradient preview bar stretches to fill remaining space */
.sp-gradient-preview {
    flex: 1;
    height: 24px;
    border-radius: 4px;
    border: 1px solid #ddd;
    background: #f4f4f4;
    min-width: 0;
}

.sp-grad-type-btn {
    width: 26px;
    height: 26px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: none;
    cursor: pointer;
    font-size: 13px;
    color: #666;
    padding: 0;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.sp-grad-type-btn.sp-grad-type-active {
    border-color: #2980b9;
    background: rgba(41,128,185,0.1);
    color: #2980b9;
}
.sp-grad-type-btn:not(.sp-grad-type-active):hover { background: #f0f0f0; }

.sp-eyedropper-btn {
    width: 28px;
    height: 28px;
    border: 1px solid #ccc;
    border-radius: 5px;
    background: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 13px;
    color: #555;
    padding: 0;
}
.sp-eyedropper-btn:hover { background: #f0f0f0; }

/* Saved palette: sits at bottom of .sp-palette-container */
.sp-saved-palette {
    border-top: 1px solid #eee;
    margin-top: 6px;
    padding-top: 6px;
    display: flex;
    align-items: flex-start;
    gap: 4px;
}

.sp-saved-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    flex: 1;
    min-height: 22px;
}

.sp-saved-swatch {
    width: 22px;
    height: 22px;
    border-radius: 3px;
    border: 1px solid #ccc;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
}
.sp-saved-swatch:hover { border-color: #888; }
.sp-saved-swatch:hover .sp-saved-swatch-del { display: block; }

.sp-saved-swatch-del {
    display: none;
    position: absolute;
    top: -5px;
    right: -5px;
    background: #555;
    color: #fff;
    font-size: 9px;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    text-align: center;
    line-height: 13px;
    cursor: pointer;
    z-index: 2;
}

.sp-save-color-btn {
    width: 26px;
    height: 26px;
    border: 1px solid #bbb;
    border-radius: 4px;
    background: none;
    font-size: 17px;
    line-height: 1;
    cursor: pointer;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 0;
}
.sp-save-color-btn:hover { background: #f0f0f0; }

.dropdown {
    margin-top: 10px;
    margin-left: 2px;
}

.dropdown-menu {
    min-width: 2px;
    margin-left: 5px;
}

.dropdown-content {
    padding: 5px;
    background: rgba(255, 255, 255, 0.85);
    /* background-color: #1c1c1c; */
}

.dropdown-item {
    margin: 2px;
    border-radius: 5px;
    /* background-color: #1c1c1c; */
}

/* Shortcut hint pinned to the right of a menu label. () marks a key the shortcut needs,
   [] a modifier that only changes what the item does. */
.dropdown-item:has(> .menu-key) {
    display: flex;
    align-items: baseline;
    gap: 2rem;
}

.menu-key {
    margin-left: auto;
    font-size: 0.8em;
    opacity: 0.55;
    white-space: nowrap;
}

.tool-button {
    margin-bottom: 2px;
}

.nav-button {
    border: none;
    box-shadow: none;
    background: rgba(255, 255, 255, 0.65);
}

/* ── Frosted glass, opt-in (General settings) ─────────────────────────────────
   Blurring the canvas behind every panel makes the compositor re-blur them on
   each repaint, which costs real battery while drawing. Default above is a flat
   translucent white; this block restores the frosted look when asked for. */
body.frosted-ui .timeline-content,
body.frosted-ui .brush-size-wrapper,
body.frosted-ui .dropdown-content,
body.frosted-ui .nav-button {
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

body.frosted-ui .timeline-content { background: rgba(255, 255, 255, 0.1); }
body.frosted-ui .dropdown-content { background: none; }

body.frosted-ui .brush-size-wrapper,
body.frosted-ui .nav-button { background: rgba(255, 255, 255, 0.3); }

#timeline-table {
    height: 28px;
}

#frame-counter {
    min-width: 5em;
}

.timeline-nav {
    position: fixed;
    bottom: 0px;
    width: 100%;
    margin-left: 50px;
    padding-right: 100px;
    pointer-events: none;
}

.timeline-nav:not(.is-locked) .toggle-timeline-nav,
.timeline-nav:not(.is-locked) .timeline-nav-buttons,
.timeline-nav:not(.is-locked) .layers-container {
    pointer-events: auto;
}

.timeline-nav.is-locked {
    opacity: 0.5;
}

.timeline-nav-buttons{
    gap: 0.25em;
}

.timeline-wrapper {
    padding: 0.5em;
    padding-bottom: 0;
}

.timeline-buttons-wrapper {
    padding-left: 0.5em;
    padding-bottom: 0.5em;
}

.fixed-top {
    position: fixed;
    top: 0px;
}

.fixed-right {
    position: fixed;
    right: 0px;
}

.canvas-wrapper {
    padding-top: 4em;
    height: 150vh;
    /* background: var(--main-grey-3); */
}

/* .field.is-grouped > .control:not(:last-child) {
    margin-right: 0.25rem;
} */

.termsWrapper {
    margin-bottom: 4px;
}

.file-label{
    overflow: inherit;
}

.fileContainer {
    overflow: hidden;
    position: relative;
}

.fileContainer [type=file] {
    cursor: inherit;
    display: block;
    font-size: 999px;
    filter: alpha(opacity=0);
    height: 1px;
    width: 1px;
    opacity: 0;
    position: absolute;
    text-align: right;
}


.layers-container {
    background-color: transparent;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* The two of these stack into one white slab: the timestep row and the scrubber on top,
   the layer rows under them, with the pinned layer columns painting opaque white down the
   left of both. So the rounding belongs to the outside of the pair, not to each of them:
   the header takes the top corners and the body the bottom ones, which is what puts the
   white inside the panel's silhouette instead of poking square corners out of it. Both
   scroll, so the radius clips what is drawn in them for free. */
#timeline-sticky-header {
    background: none;
    flex: 0 0 auto;
    border-top-left-radius: 7px;
    border-top-right-radius: 7px;
}

#timeline-layers-body {
    height: 165px;
    min-height: 50px;
    max-height: 500px;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    border-bottom-left-radius: 7px;
    border-bottom-right-radius: 7px;
}

/* ── The two pinned layer columns ────────────────────────────────────────────
   Delete and visibility are how a layer is hidden or dropped, and the layers scroll
   sideways as the animation grows: on a long timeline they used to be a hundred frames
   back the way you came. Sticky cells rather than a second table pinned beside the
   first, so the vertical scroll they share with the frames needs no syncing — they are
   still cells of the same row.

   --frame-col-w is the frame column width (TimeLineView.frameButtonWidth), which the scrubber
   row's left padding assumes for these two columns as well. One value, so the header's two
   stand-in cells, the layer rows and the scrubber cannot drift apart.

   Opaque, not the panel's own translucent wash: frame buttons pass underneath these, and at
   the wash's alpha the timestep numbers showed straight through them. The shadow on the
   second column is what says where the pinned pair ends and the scrolling frames begin. */
#timeline-layers-body table,
#timeline-sticky-header table {
    /* Sticky cells in a border-collapsed table are still unreliable outside Chrome. */
    border-collapse: separate;
    border-spacing: 0;
}

/* td-qualified: Bulma paints every cell with `.table td { background-color: ... }`, which
   outranks a bare class. Transparent like the rest of the timeline. Positional rather than
   -1/-2 modifier classes, which had to be kept in sync across a template and a JS template
   string. */
.table td.layer-control {
    position: sticky;
    z-index: 3;
    min-width: var(--frame-col-w);
    max-width: var(--frame-col-w);
    background: none;
}

.table td.layer-control:first-child { left: 0; }
.table td.layer-control + td.layer-control { left: var(--frame-col-w); }

/* ── Playing ─────────────────────────────────────────────────────────────────
   The tools do nothing while the animation runs — the first press anywhere stops it
   instead (the playback lock in event-listeners.js). This is that rule on screen. */
body.is-playing #dropdown-menu,
body.is-playing .brush-size-wrapper,
body.is-playing .color-picker-wrapper {
    opacity: 0.45;
}

.layers-resize-handle {
    height: 12px;
    cursor: ns-resize;
    /* background-color: var(--bulma-scheme-main, #ffffff); */
    background: linear-gradient(to bottom, rgba(0, 0, 0, 50) -200%, rgba(255, 255, 255, 0) 100%);
    border-top-left-radius: 7px;
    border-top-right-radius: 7px;
    flex: 0 0 auto;
    z-index: 201;
    border-top: 2px solid rgba(0, 0, 0, 0.3);
}

.layers-resize-handle:hover {
    border-top-color: #f4c560;
}

#file-dropdown-toggle {
    display: none;
}

#file-dropdown-toggle:checked ~ .dropdown-menu {
    display: block;
    -webkit-animation: fadeIn 0.5s;
    animation: fadeIn 0.5s;
}

#edit-dropdown-toggle,
#tweenart-dropdown-toggle {
    display: none;
}

#edit-dropdown-toggle:checked ~ .dropdown-menu,
#tweenart-dropdown-toggle:checked ~ .dropdown-menu {
    display: block;
    -webkit-animation: fadeIn 0.5s;
    animation: fadeIn 0.5s;
}

/* ── Modal footers ───────────────────────────────────────────────────────────
   Bulma leaves footer buttons flush against each other. One rule for every modal
   so Save/Apply and Cancel keep the same air apart wherever they appear, rather
   than each dialog spacing its own. */
.modal-card-foot {
    gap: 12px;
}

/* The login card is the one modal that opens on top of another: a save refused for want of
   a session is reported inside the Save dialog, and the login goes over it. */
#modal-login {
    z-index: 45;
}

/* Pencil settings modal */
/* Canvas left, settings scrolling right. Stacked, the preview plus its hint and checkboxes
   ate most of the card and left the settings list a slot too short to pick anything out of.
   Side by side each column gets the full height, and the preview is the fixed column because
   its canvas has a fixed bitmap size. The card takes the height it is allowed rather than
   sizing to content, so the settings column has something to scroll inside. */
#pencil-settings-modal-card {
    width: 1180px;
    max-width: 96vw;
    height: 90vh;
}
#pencil-settings-modal-body {
    padding: 0;
    display: flex;
    flex-direction: row;
    overflow: hidden;
}
#pencil-preview-area {
    /* A fixed basis rather than auto: resizePreviewCanvas() sizes the canvas bitmap from
       this element's clientWidth, and with an auto basis that width comes from the canvas
       it is about to set. 660 canvas + 2x12 padding, box-sizing: border-box. */
    flex: 0 0 684px;
    padding: 12px;
    background: #f5f5f5;
    border-right: 1px solid #ddd;
    overflow-y: auto;
}
#pencilPreviewCanvas {
    max-width: 100%;
    height: auto;
}
#pencil-settings-area {
    flex: 1;
    min-width: 0;
    overflow-y: auto;
    padding: 12px;
}

/* Too narrow for two columns (684 of preview plus a settings column that can still hold its
   labels): stack them, preview on top. The canvas is capped to a third of the viewport height
   so the settings below it keep a list worth scrolling — stacked and uncapped is exactly the
   squeeze this layout exists to fix. CSS scales it rather than the bitmap, so the preview is
   the same drawing seen smaller. */
@media (max-width: 1100px) {
    #pencil-settings-modal-body {
        flex-direction: column;
    }
    #pencil-preview-area {
        flex: 0 0 auto;
        overflow-y: visible;
        border-right: none;
        border-bottom: 1px solid #ddd;
    }
    #pencilPreviewCanvas {
        max-height: 34vh;
    }
}

.frame {
    padding: 1px !important;
    /* opacity: 0.6; */
}

.waypoint-dots {
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 0;
    pointer-events: none;
}
.waypoint-dot {
    position: absolute;
    top: 0;
    transform: translate(-50%, -50%);
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #fff;
    pointer-events: auto;
    cursor: pointer;
}
.waypoint-dot::before {
    content: '';
    position: absolute;
    top: -4px; left: -4px; right: -4px; bottom: -4px;
}

/* The camera layer's one frame: white where a tween frame is green, orange like any other
   cell while it is the selected row. Its key dots go dark so they show on the white. */
.camera-frame:not(.is-primary) {
    background-color: #fff !important;
    color: #363636 !important;
    border: 1px solid #dbdbdb !important;
}
.camera-frame {
    position: relative;
    justify-content: flex-start !important;
}
/* Step 0 gets no dot (renderCameraCell skips it), so the icon has that cell to itself. */
.camera-frame:not(.is-primary) .waypoint-dot {
    background: #363636;
}

.audio-frame {
    background-color: #e24444 !important;
    color: #fff !important;
    border: 0 !important;
    position: relative;
    overflow: hidden;
}
/* The darker shade is what an audio frame shows when it is the current frame or in a
   selection. It was written against is-warning, which nothing has applied since the
   is-warning -> is-primary rebrand, so an audio frame could not look active at all. */
.audio-frame.is-primary {
    background-color: #c03030 !important;
}
.audio-wave-wrap {
    position: absolute;
    inset: 0;
    pointer-events: none;
    display: block;
    text-align: left;
    line-height: 0;
}
.audio-wave {
    display: block;
    height: 100%;
}
.audio-layer td.frame > button.is-primary {
    background-color: #c03030 !important;
    color: #fff !important;
}

.audio-frame.visemified {
    background-color: #f5d742 !important;
    color: #333 !important;
}
.audio-frame.visemified.is-primary {
    background-color: #d4b722 !important;
}
.audio-layer td.frame > button.is-primary.visemified {
    background-color: #d4b722 !important;
    color: #333 !important;
}
.viseme-diamonds {
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 0;
    pointer-events: none;
    z-index: 2;
}
.viseme-diamond {
    position: absolute;
    top: 0;
    transform: translate(-50%, -50%) rotate(45deg);
    width: 10px;
    height: 10px;
    border: 1px solid #333;
    pointer-events: auto;
    cursor: pointer;
}
.viseme-diamond.is-empty {
    background: transparent;
}
.viseme-diamond.is-filled {
    background: #333;
}

table td {
    padding: 1px;

}

.table {
    background-color: transparent;
}

.top-of-the-page{
   position: fixed !important;
   z-index: 9999 !important;
   top:2%;
   left:50%;
   transform:translate(-50%);
}

/* Switch toggle component */
input[type="checkbox"].switch {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
input[type="checkbox"].switch + label {
    position: relative;
    display: inline-flex;
    align-items: center;
    padding-left: 3.25rem;
    cursor: pointer;
    min-height: 1.5rem;
    line-height: 1.5rem;
}
input[type="checkbox"].switch + label::before {
    content: '';
    position: absolute;
    left: 0;
    width: 3rem;
    height: 1.6rem;
    background: #b5b5b5;
    border-radius: 9999px;
    transition: background 0.15s ease-in-out;
}
input[type="checkbox"].switch + label::after {
    content: '';
    position: absolute;
    left: 0.2rem;
    width: 1.1rem;
    height: 1.1rem;
    background: #fff;
    border-radius: 9999px;
    /* margin-top: calc((1.5rem - 1.1rem) / 2); */
    transition: left 0.15s ease-in-out;
}
input[type="checkbox"].switch:checked + label::before {
    background: #02b120;
}
input[type="checkbox"].switch:checked + label::after {
    left: calc(3rem - 1.1rem - 0.2rem);
}

/* Timeline scrubber: consistent rounded-rect thumb across browsers */
#timeline-scrubber-row {
    /* Clears the two pinned layer columns, so step 0 lines up with frame 0. */
    padding-left: calc(2 * var(--frame-col-w));
    height: 20px;
    margin: 0;
    overflow: visible;
    position: relative;
}

/* Last-saved status pill: sits in the empty two-frame (84px) gap before the scrubber. */
.save-status-pill {
    position: absolute;
    left: 2px;
    top: 50%;
    transform: translateY(-50%);
    width: 80px;
    height: 16px;
    border-radius: 4px;
    font-size: 0.6rem;
    line-height: 16px;
    text-align: center;
    background: transparent;
    color: #7a7a7a;
    pointer-events: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    z-index: 3;
    transition: background-color 0.2s ease;
}
.save-status-pill.is-unsaved {
    background: #fde2e2;
    color: #c0392b;
}
#timeline-scrubber {
    -webkit-appearance: none;
    appearance: none;
    width: 4200px;
    height: 20px;
    margin: 0;
    padding: 0;
    display: block;
    cursor: pointer;
    touch-action: none;
    background: none;
}
/* ── Range inputs ────────────────────────────────────────────────────────────
   One recipe — pill track, white rounded thumb — sized per control by the six
   variables below. Written once because ::-webkit-* and ::-moz-* have to be
   declared separately: copying it per slider is how the two halves drift apart
   until someone opens Firefox. */
.tw-range {
    --range-h: 20px;
    --track-a: 0.25;
    --track-r: 7px;
    --thumb-w: 38px;
    --thumb-h: 16px;
    --thumb-r: 6px;

    -webkit-appearance: none;
    appearance: none;
    height: var(--range-h);
    margin: 0;
    padding: 0;
    cursor: pointer;
    background: none;
}

.tw-range::-webkit-slider-runnable-track {
    height: var(--range-h);
    background: rgba(0, 0, 0, var(--track-a));
    border-radius: var(--track-r);
}

.tw-range::-moz-range-track {
    height: var(--range-h);
    background: rgba(0, 0, 0, var(--track-a));
    border-radius: var(--track-r);
    border: none;
}

/* margin-top centres the thumb in the taller track, the same 2px reveal on each. */
.tw-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: var(--thumb-w);
    height: var(--thumb-h);
    margin-top: calc((var(--range-h) - var(--thumb-h)) / 2);
    border-radius: var(--thumb-r);
    background: #ffffff;
    border: 1px solid #dadada;
    cursor: pointer;
}

.tw-range::-moz-range-thumb {
    appearance: none;
    width: var(--thumb-w);
    height: var(--thumb-h);
    border-radius: var(--thumb-r);
    background: #ffffff;
    border: 1px solid #dadada;
    cursor: pointer;
}

/* Vertical-pill thumb: the timeline scrubber's, stood on end. */
#brush-size-slider {
    --range-h: 24px;
    --track-r: 4px;
    --thumb-w: 8px;
    --thumb-h: 20px;
    --thumb-r: 3px;

    flex: 1;
    min-width: 0;
    touch-action: none;
}

/* Track padding keeps the thumb from touching the pill ends at either extreme. */
#brush-size-slider::-webkit-slider-runnable-track {
    padding-left: 2px;
    padding-right: 2px;
}

#brush-size-slider::-moz-range-track {
    padding-left: 2px;
    padding-right: 2px;
}

#timeline-scrubber {
    width: 4200px;
    display: block;
    touch-action: none;
}

#timeline-scrubber::-webkit-slider-thumb {
    margin-left: 2px;
}

#timeline-scrubber::-moz-range-thumb {
    margin-left: 2px;
}

.set-range {
    --range-h: 18px;
    --track-a: 0.16;
    --track-r: 6px;
    --thumb-w: 26px;
    --thumb-h: 14px;
    --thumb-r: 5px;

    width: 100%;
}

/* ── General settings modal ───────────────────────────────────────────────────
   A right-aligned label column wrapping two words deep, then a 200px gap, then a
   short input, is what made this dialog mostly empty space. One grid instead:
   fixed label column on the left, the control filling what is left, the number
   parked at a constant right edge so every row lines up down the dialog. */
#settings-modal-card {
    width: 560px;
    max-width: 96vw;
}

#settings-modal-body,
#features-modal-body {
    padding: 6px 20px 18px;
}

/* Version and last-saved are facts about the project, not settings — they read as
   a byline under the title rather than as two more rows you might try to edit. */
.set-head {
    flex-grow: 1;
    min-width: 0;
}

.set-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 16px;
    margin: 3px 0 0;
    font-size: 12px;
    color: #85857c;
}

.set-meta b {
    font-weight: 600;
    color: #4a4a44;
}

.set-group {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: #9a9a90;
    margin: 16px 0 4px;
    padding-bottom: 5px;
    border-bottom: 1px solid #ececE6;
}

.set-group:first-child {
    margin-top: 4px;
}

.set-row {
    display: grid;
    /* Label column sized to the longest one ("Number of Onion Skins") so no row
       wraps — a wrapped label is what threw the old dialog's rows out of line. */
    grid-template-columns: 176px 1fr 76px;
    align-items: center;
    gap: 0 12px;
    padding: 6px 0;
}

.set-label,
.feat-name {
    margin: 0;
    font-size: 13.5px;
    font-weight: 600;
    color: #363630;
}

.input.set-num {
    height: 30px;
    font-size: 13px;
    padding: 0 8px;
    text-align: right;
}

/* Anything that runs past the slider column. One rule, so a new full-width row
   type only has to say `set-wide` rather than be added to two selector lists. */
.set-wide {
    grid-column: 2 / -1;
}

/* No slider to sit beside, so the number takes the middle column at a readable
   width instead of being flung to the right edge on its own. */
.set-row--plain .input.set-num {
    justify-self: start;
    width: 132px;
    text-align: left;
}

/* Bulma's .help, placed. The type is already right; only the column is ours. */
.set-row .help {
    margin: 3px 0 0;
    font-size: 11.5px;
}

.set-pair {
    display: flex;
    align-items: center;
    gap: 8px;
}

.set-pair .input.set-num {
    width: 76px;
    text-align: left;
}

.set-by {
    color: #9a9a90;
    font-size: 13px;
}

.set-row--toggle input[type="checkbox"].switch + label {
    justify-self: start;
}

/* Phones: the label column stops paying for itself, so rows stack. */
@media screen and (max-width: 560px) {
    .set-row {
        grid-template-columns: 1fr 76px;
        row-gap: 4px;
    }

    .set-label,
    .set-wide {
        grid-column: 1 / -1;
    }
}


/* ── Feature list ─────────────────────────────────────────────────────────────
   Reference, not a form, so it reuses .set-group for the section headings and
   nothing else from the settings dialog: two columns, a name on the left with
   its keys, a sentence on the right. Taller than the settings card because it
   is read top to bottom rather than aimed at. */
#features-modal-card {
    width: 760px;
    max-width: 96vw;
    height: 86vh;
}

.feat-row {
    display: grid;
    /* Wide enough for the longest name plus its keys ("Redo shift cmd z") without
       wrapping, which is what would throw the two columns out of line. */
    grid-template-columns: 208px 1fr;
    gap: 0 16px;
    align-items: baseline;
    padding: 7px 0;
    border-bottom: 1px solid #f3f3ed;
}

.feat-row:last-child {
    border-bottom: none;
}

/* .set-label above carries the type; only the row of keys beside the name is ours. */
.feat-name {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 5px;
}

.feat-name .icon {
    color: #9a9a90;
}

/* The timeline legend: one chip per frame colour, in the colours the timeline
   actually paints, so the row is the key rather than a description of one. */
.feat-swatch {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-right: 16px;
    white-space: nowrap;
}

.feat-chip {
    display: inline-block;
    width: 15px;
    height: 15px;
    border-radius: 4px;
}

.feat-chip--current { background: var(--bulma-primary); }
.feat-chip--drawn   { background: var(--bulma-link); }
.feat-chip--empty   { background: var(--bulma-light); box-shadow: inset 0 0 0 1px #dcdcd4; }
.feat-chip--tween   { background: var(--bulma-success); }
.feat-chip--camera  { background: #fff; box-shadow: inset 0 0 0 1px #dbdbdb; }

@media screen and (max-width: 560px) {
    .feat-row {
        grid-template-columns: 1fr;
        row-gap: 3px;
    }
}


/* ── Guided tour ──────────────────────────────────────────────────────────────
   Deliberately not a Bulma .modal — see the note in js/guide.js. The layer itself
   is inert; .guide-catcher is the sheet that eats every click, and the box and the
   ring sit above it. No backdrop-filter here: frosted glass is opt-in and scoped to
   body.frosted-ui, and this repaints over a live canvas. */
.guide-layer {
    position: fixed;
    inset: 0;
    z-index: var(--z-guide);
    pointer-events: none;
}

/* Transparent on purpose: it blocks the app without dimming the thing being explained. */
.guide-catcher {
    position: absolute;
    inset: 0;
    pointer-events: auto;
    background: transparent;
    cursor: default;
}

.guide-ring {
    position: fixed;
    border: 2px solid var(--main-salmon);
    border-radius: 8px;
    pointer-events: none;
}

/* The halo pulses on a pseudo-element via transform/opacity, which the compositor owns.
   Animating box-shadow on .guide-ring instead costs a style recalc and a main-thread
   repaint every frame, and the tiles it dirties hold the timeline and toolbar sitting
   underneath it — the same trade rejected for frosted glass (js/app.js). */
.guide-ring::after {
    content: "";
    position: absolute;
    inset: -3px;
    border-radius: 11px;
    box-shadow: 0 0 0 3px var(--main-salmon);
    opacity: 0.28;
    will-change: transform, opacity;
    animation: guide-pulse 1.8s ease-in-out infinite;
}

@keyframes guide-pulse {
    0%, 100% { transform: scale(1);    opacity: 0.28; }
    50%      { transform: scale(1.06); opacity: 0.10; }
}

.guide-box {
    position: fixed;
    width: 344px;
    max-width: calc(100vw - 20px);
    pointer-events: auto;
    background: #fff;
    border: 1px solid #e4e4dc;
    border-radius: 10px;
    box-shadow: 0 12px 34px -12px rgba(0, 0, 0, 0.35);
    padding: 12px 14px 10px;
    animation: fadeIn 0.18s ease;
}

/* The pointer. One triangle, rotated onto whichever side the box ended up on. */
.guide-box::after {
    content: "";
    position: absolute;
    width: 10px;
    height: 10px;
    background: #fff;
    border-left: 1px solid #e4e4dc;
    border-top: 1px solid #e4e4dc;
}

.guide-box[data-placement="top"]::after    { bottom: -6px; left: 50%; margin-left: -5px; transform: rotate(225deg); }
.guide-box[data-placement="bottom"]::after { top: -6px;    left: 50%; margin-left: -5px; transform: rotate(45deg); }
.guide-box[data-placement="left"]::after   { right: -6px;  top: 50%;  margin-top: -5px;  transform: rotate(135deg); }
.guide-box[data-placement="right"]::after  { left: -6px;   top: 50%;  margin-top: -5px;  transform: rotate(-45deg); }
.guide-box[data-placement="center"]::after { display: none; }

.guide-canvas {
    display: block;
    width: 320px;
    max-width: 100%;
    height: auto;
    margin: 0 auto 10px;
    background: #fbfbf8;
    border: 1px solid #ececE6;
    border-radius: 6px;
}

.guide-title {
    font-size: 14px;
    font-weight: 700;
    color: #4a4a44;
    margin: 0 0 5px;
}

.guide-text,
.feat-desc {
    font-size: 12.5px;
    line-height: 1.45;
    color: var(--main-grey-2);
    margin: 0 0 10px;
}

/* Same type, no trailing gap: a feature row's own padding is the space between rows. */
.feat-desc {
    margin: 0;
}

.guide-text kbd,
.feat-row kbd {
    display: inline-block;
    padding: 0 4px;
    border: 1px solid #d8d8d0;
    border-bottom-width: 2px;
    border-radius: 4px;
    background: #f6f6f1;
    font-family: inherit;
    font-size: 11.5px;
    font-weight: 600;
    color: #4a4a44;
}

.guide-foot {
    display: flex;
    align-items: center;
    gap: 10px;
    border-top: 1px solid #ececE6;
    padding-top: 8px;
}

.guide-progress {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #9a9a90;
}

.guide-optout {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11.5px;
    color: #85857c;
    cursor: pointer;
}

/* Pushes the buttons to the right edge whether or not the opt-out is showing. */
.guide-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

/* The tour's Discord button, and the one an error offers when the way out of it is the
   same place. Both wear the brand colour rather than their surroundings, so "join" never
   reads as "dismiss". */
#guide-discord,
#error-link {
    background: var(--tw-discord);
    border-color: transparent;
    color: #fff;
    font-weight: 600;
}

#guide-discord:hover,
#error-link:hover {
    background: var(--tw-discord-dark);
    color: #fff;
}

/* Inline-block, so it rides in the centred text flow of the message and wraps with it. The
   right margin is for the message's own close button, which follows it. */
#error-link {
    display: inline-block;
    margin: 4px 10px 0 6px;
    vertical-align: middle;
}

/* Narrow screens: the ring still points, but the box stops chasing it sideways. */
@media screen and (max-width: 460px) {
    .guide-box {
        width: calc(100vw - 20px);
    }

    .guide-box::after {
        display: none;
    }
}
