:root {
    --bg: #1c1c1c; /* ImGuiCol_WindowBg  0.11 */
    --panel: #1f1f1f; /* ImGuiCol_ChildBg   0.12 */
    --frame: #333333; /* ImGuiCol_FrameBg   0.20 */
    --frame-hover: #404040;
    --frame-active: #4d4d4d;
    --btn: #383838; /* ImGuiCol_Button    0.22 */
    --btn-hover: #474747;
    --tab: #262626; /* ImGuiCol_Tab       0.15 */
    --border: #414141; /* the 65,65,65 group outline */
    --accent: #0080e6; /* ImGuiCol_TabActive / ButtonActive */
    --accent-bright: #00b3ff; /* CheckMark / SliderGrab */
    --accent-title: #00a6ff; /* group headings */
    --text: #e8e8e8;
    --text-dim: #8c8c8c;
    --log: #33ff33;
    --warn: #ffe633;
    --brow-selected: #2A4463;
    --radius: 6px;
    --grab-radius: 12px;
    --left-w: 565px;
    --row-h: 26px;
    --font: "Roboto", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html, body {
    color-scheme: dark;
    height: 100%;
    margin: 0;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font: 400 14px/1.45 var(--font);
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

button, input, select {
    font: inherit;
    color: inherit;
}

:focus-visible {
    outline: 2px solid var(--accent-bright);
    outline-offset: 1px;
}

/* ------------------------------------------------------------------ boot */
#boot {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: grid;
    place-items: center;
    background: var(--bg);
}

.boot-inner {
    width: min(420px, 80vw);
    text-align: center;
}

.boot-title {
    margin: 0 0 22px;
    font-size: 20px;
    font-weight: 500;
    letter-spacing: .01em;
    color: var(--accent-title);
}

.boot-bar {
    height: 4px;
    border-radius: 2px;
    background: var(--frame);
    overflow: hidden;
}

    .boot-bar span {
        display: block;
        height: 100%;
        width: 35%;
        background: var(--accent-bright);
        border-radius: 2px;
        animation: boot-slide 1.15s ease-in-out infinite;
    }

@keyframes boot-slide {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(320%);
    }
}

#boot-msg {
    margin: 14px 0 0;
    color: var(--text-dim);
    font-size: 13px;
}

.boot-blurb {
    margin: 18px 0 0;
    color: var(--text);
    font-size: 13px;
    line-height: 1.5;
}

/* link back to the landing page, shown on the boot screen */
.boot-link {
    margin: 20px 0 0;
    font-size: 13px;
}

    .boot-link a {
        color: var(--text-dim);
        text-decoration: none;
        border-bottom: 1px solid transparent;
    }

        .boot-link a:hover {
            color: var(--accent-bright);
            border-bottom-color: var(--accent-bright);
        }

#boot.is-error .boot-bar {
    display: none;
}

#boot.is-error #boot-msg {
    color: var(--warn);
}

/* ------------------------------------------------------------------ shell */
#app {
    display: grid;
    grid-template-columns: var(--left-w) 6px minmax(0, 1fr);
    height: 100%;
}

    #app[hidden] {
        display: none;
    }

#left, #right {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    padding: 6px;
    gap: 6px;
}

#splitter {
    cursor: col-resize;
    background: transparent;
    border-left: 1px solid var(--border);
}

    #splitter:hover, #splitter.is-dragging {
        background: var(--accent);
    }

/* ------------------------------------------------------------------ tabs */
.tabbar {
    display: flex;
    gap: 4px;
    flex: none;
    align-items: flex-end;
    flex-wrap: wrap;   /* lets .tab-tools drop to its own row */
}

.tab {
    flex: none;
    padding: 7px 16px;
    background: var(--tab);
    border: none;
    border-radius: var(--radius) var(--radius) 0 0;
    cursor: pointer;
    color: var(--text-dim);
    white-space: nowrap;
}

    .tab:hover {
        background: #0a4a80;
        color: var(--text);
    }

    .tab.is-active {
        background: var(--accent);
        color: #fff;
    }

.tabbody {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column; /* passes height down */
    background: var(--panel);
    border-radius: 0 var(--radius) var(--radius) var(--radius);
    overflow: hidden;
}

.tabpane {
    display: none;
    overflow-y: auto;
    padding: 6px 6px;
}

    .tabpane.is-active {
        display: flex;
        flex-direction: column;
        flex: 1 1 0;
        min-height: 0;
        overflow-y: auto; /* scrolls the Configuration tab */
    }

#pane-palette.is-active {
    overflow: hidden;
}

/* --------------------------------------------------------------- groups */
.group {
    margin-bottom: 4px;
}

.group-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

    .group-head h3 {
        margin: 0;
        font-size: 14px;
        font-weight: 500;
        color: var(--accent-title);
    }

.reset {
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    padding: 0;
    background: none;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    opacity: .8;
}

    .reset:hover {
        background: rgba(255,255,255,.15);
        opacity: 1;
    }

    .reset:active {
        background: rgba(255,255,255,.3);
    }

    .reset img {
        width: 15px;
        height: 15px;
    }

.group-box {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px 10px 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px 8px;
}

/* ---------------------------------------------------------------- fields */
.row {
    display: flex;
    align-items: center;
    gap: 4px 8px;
    flex-wrap: wrap;
}

    .row > label {
        color: var(--text);
        white-space: nowrap;
    }

.grow {
    flex: 1 1 120px;
    min-width: 0;
}

.gap {
    flex: 0 0 10px;
}

input[type=text], input[type=number], input[type=search], select {
    height: var(--row-h);
    padding: 0 8px;
    background: var(--frame);
    border: none;
    border-radius: var(--radius);
    color: var(--text);
}

    input[type=text]:hover, input[type=number]:hover,
    input[type=search]:hover, select:hover {
        background: var(--frame-hover);
    }

input[readonly] {
    color: var(--text-dim);
}

.num {
    width: 78px;
}

.w140 {
    width: 140px;
}

.w170 {
    width: 172px;
}

select {
    appearance: none;
    padding-right: 24px;
    background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%), linear-gradient(135deg, var(--text-dim) 50%, transparent 50%);
    background-position: calc(100% - 14px) 11px, calc(100% - 9px) 11px;
    background-size: 5px 5px;
    background-repeat: no-repeat;
    cursor: pointer;
    min-width: 0;
}

.note {
    margin: 2px 0 0;
    color: var(--text-dim);
    font-size: 13px;
}

/* checkbox and radio, drawn to match the ImGui check mark */
.check, .radio {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
}

    .check input, .radio input {
        position: absolute;
        opacity: 0;
        width: 0;
        height: 0;
    }

    .check i, .radio i {
        width: 18px;
        height: 18px;
        flex: none;
        background: var(--frame);
        border-radius: 4px;
        display: grid;
        place-items: center;
    }

    .radio i {
        border-radius: 50%;
    }

    .check input:hover + i, .radio input:hover + i {
        background: var(--frame-hover);
    }

    .check input:checked + i::after {
        content: "";
        width: 10px;
        height: 6px;
        border-left: 2px solid var(--accent-bright);
        border-bottom: 2px solid var(--accent-bright);
        transform: rotate(-45deg) translate(1px, -1px);
    }

    .radio input:checked + i::after {
        content: "";
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: var(--accent-bright);
    }

    .check input:focus-visible + i, .radio input:focus-visible + i {
        outline: 2px solid var(--accent-bright);
        outline-offset: 1px;
    }

fieldset {
    border: none;
    margin: 0;
    padding: 0;
    display: contents;
}

    fieldset[disabled] {
        opacity: .45;
        pointer-events: none;
    }

#pass2-fields, #overlay-fields {
    display: flex;
    flex-direction: column;
    gap: 4px 8px;
}

    #pass2-fields[disabled], #overlay-fields[disabled] {
        opacity: .45;
        pointer-events: none;
    }

/* --------------------------------------------------------------- sliders */
.slider-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 8px;
}

.slider-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

    .slider-row > label {
        flex: 1 1 140px;
    }

    .slider-row > .slider {
        flex: 1 1 120px;
        min-width: 0;
    }

.w170 {
    width: 100%;
    max-width: 172px;
}

.slider {
    position: relative;
    height: var(--row-h);
    background: var(--frame);
    border-radius: var(--radius);
    overflow: hidden;
}

    .slider:hover {
        background: var(--frame-hover);
    }

    .slider input[type=range] {
        appearance: none;
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        margin: 0;
        background: transparent;
        cursor: ew-resize;
    }

        .slider input[type=range]::-webkit-slider-thumb {
            appearance: none;
            width: 12px;
            height: 20px;
            border: none;
            border-radius: var(--grab-radius);
            background: var(--accent-bright);
        }

        .slider input[type=range]:active::-webkit-slider-thumb {
            background: #00ccff;
        }

        .slider input[type=range]::-moz-range-thumb {
            width: 12px;
            height: 20px;
            border: none;
            border-radius: var(--grab-radius);
            background: var(--accent-bright);
        }

    .slider .sv {
        position: absolute;
        inset: 0;
        display: grid;
        place-items: center;
        pointer-events: none;
        font-size: 14px;
        text-shadow: none;
        color: var(--text);
    }

/* --------------------------------------------------------------- buttons */
button img {
    pointer-events: none;
    -webkit-user-drag: none;
    -moz-user-drag: none;
}

.btn {
    height: var(--row-h);
    padding: 0 14px;
    background: var(--btn);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    white-space: nowrap;
}

    .btn:hover {
        background: var(--btn-hover);
    }

    .btn:active {
        background: var(--accent);
        color: #fff;
    }

    .btn.sq {
        width: 30px;
        padding: 0;
    }

    .btn.full {
        width: 100%;
    }

    .btn.primary {
        flex: 1 1 0;
        height: 35px;
        letter-spacing: .04em;
    }

.actions {
    display: flex;
    gap: 8px;
    flex: none;
}

.warning {
    flex: none;
    margin: 0;
    color: var(--warn);
    font-size: 13px;
}

/* ------------------------------------------------------- block palette */
.search-row {
    flex-wrap: nowrap;
}

hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 8px 0;
}
/* lock all direct children of the palette tab so they don't stretch */
#pane-palette > * {
    flex: 0 0 auto;
}

/* the main block picker absorbs all remaining vertical space */
#pane-palette > .picker:not(.picker--overlay) {
    flex: 1 1 0;
    min-height: 0;
    align-items: stretch;
    grid-template-rows: minmax(0, 1fr); /* implicit row fills the container height */
}

    #pane-palette > .picker:not(.picker--overlay) .picker-col {
        display: flex;
        flex-direction: column;
        min-height: 0;
    }

    #pane-palette > .picker:not(.picker--overlay) .picker-tools {
        padding-top: 0;
        justify-content: center;
    }

/* ---------------------------------------------------------- base picker */
.picker {
    display: grid;
    grid-template-columns: minmax(0,1fr) 44px minmax(0,1fr);
    gap: 6px;
    align-items: start;
}

.picker-col {
    position: relative;
    min-width: 0;
}

    .picker-col h4 {
        margin: 6px 0 6px;
        font-size: 14px;
        font-weight: 400;
        color: var(--text);
        flex: none;
    }

.picker-tools {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding-top: 84px;
}

.picker--overlay {
    flex: 0 0 auto;
}

    .picker--overlay .picker-tools {
        padding-top: 34px;
    }

.tool-gap {
    height: 12px;
    flex: none;
}

.icobtn {
    width: 30px;
    height: 30px;
    padding: 0;
    display: grid;
    place-items: center;
    background: var(--btn);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    flex: none;
}

    .icobtn:hover {
        background: var(--btn-hover);
    }

    .icobtn:active {
        background: var(--accent);
    }

    .icobtn img {
        width: 26px;
        height: 26px;
        object-fit: contain;
    }

/* -------------------------------------------------------------- blocklist */
.blocklist {
    position: relative;
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 3px;
}

.blocklist--short {
    flex: 0 0 130px;
    height: 130px;
}

.brow {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 1px 6px;
    border-radius: 0px;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

    .brow:hover {
        background: rgba(255,255,255,.07);
    }

    .brow.is-selected {
        background: var(--brow-selected);
        color: #fff;
    }

    .brow.is-dim {
        color: #666;
    }

        .brow.is-dim .ico {
            filter: brightness(.3);
        }

/* icons come from a single atlas canvas turned into one data URL */
.ico {
    width: 16px;
    height: 16px;
    flex: none;
    background-image: var(--block-atlas);
    background-repeat: no-repeat;
    image-rendering: pixelated;
}

.ico--ov {
    background-image: var(--overlay-atlas);
}

.popup[hidden] {
    display: none !important;
}

.popup {
    position: fixed;   /* getBoundingClientRect is viewport-relative */
    z-index: 30;
    min-width: 190px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 26px rgba(0,0,0,.55);
}

/* ------------------------------------------------------------- preview */
.preview-head {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    flex: none;
}

    .preview-head h2 {
        margin: 0;
        flex: 1 1 auto;
        font-size: 14px;
        font-weight: 500;
        color: var(--accent-title);
    }

.head-tools {
    display: flex;
    align-items: center;
    gap: 8px;
}

.bg-label {
    color: var(--text-dim);
}

.bg-picker {
    display: flex;
    gap: 4px;
}

.swatch {
    width: var(--row-h);
    height: var(--row-h);
    padding: 0;
    border: 2px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    background: #151515;
}

    .swatch:hover {
        filter: brightness(1.2);
    }

    .swatch.is-active {
        border-color: #fff;
    }

.swatch--transp {
    display: flex;
    place-items: center;
    background: #808080;
    border-radius: var(--radius);
}

    .swatch--transp--img {
        height: 100%;
        object-fit: cover;
        border-radius: 5px;
    }

#canvas-wrap {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
/* actual size is set inline by draw(); 100% is just the pre-first-frame fallback */
#canvas {
    display: block;
    touch-action: none;   /* only the canvas should capture gestures */
    width: 100%;
    height: 100%;
    cursor: grab;
    -webkit-optimize-contrast: none;
    image-rendering: crisp-edges;   /* fallback for older Firefox */
    image-rendering: pixelated;
}

    #canvas.is-panning {
        cursor: grabbing;
    }

    #canvas.is-picking {
        cursor: pointer;
    }

.canvas-msg {
    position: absolute;
    inset: 0;
    display: grid;
    align-content: center;
    justify-items: center;
    gap: 6px;
    pointer-events: none;
    color: #d1cccc;
    text-shadow: 1px 1px 0px rgb(0 0 0);
}

    .canvas-msg strong {
        font-weight: 500;
        font-size: 15px;
    }

    .canvas-msg span {
        font-size: 13px;
    }

.canvas-badge {
    position: absolute;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    padding: 5px 12px;
    background: rgba(40,40,40,.92);
    border: 1px solid #ffff00;
    border-radius: 4px;
    color: #ffff00;
    font-size: 13px;
    pointer-events: none;
}

.canvas-hint {
    position: absolute;
    bottom: 8px;
    left: 10px;
    color: #d1cccc;
    font-size: 12px;
    text-shadow: 1px 1px 0px rgb(0 0 0);
    pointer-events: none;
}

/* ------------------------------------------------------------- console */
#console {
    flex: 0 0 210px;
    display: flex;
    flex-direction: column;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

#log {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 6px 10px;
    font-size: 13px;
    line-height: 1.4;
}

.logline {
    color: var(--log);
    white-space: pre-wrap;
    word-break: break-word;
}

    .logline.cmd {
        color: #fff;
        cursor: pointer;
    }

        .logline.cmd:hover {
            text-decoration: underline;
        }

    .logline.is-copied {
        color: var(--accent-bright);
    }

#status {
    flex: none;
    padding: 6px 10px;
    border-top: 1px solid var(--border);
    color: var(--accent-bright);
    font-size: 12px;
    line-height: 1.5;
    white-space: pre-wrap;
}

/* ---------------------------------------------------------- overlays UI */
#toast {
    position: fixed;
    bottom: 18px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 55;
    padding: 8px 16px;
    background: #2a2a2a;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
}

/* ------------------------------------------------------------ responsive */
@media (max-width: 1100px) {
    /* free the body height lock so the page can actually scroll */
    html, body {
        height: auto;
        min-height: 100%;
        overflow: auto;
    }

    #app {
        display: flex; /* switch from grid to flex for simpler vertical stacking */
        flex-direction: column;
        height: auto;
        min-height: 100%;
    }

    #splitter {
        display: none;
    }

    #right {
        order: -1;
    }

    /* remove strict flex constraints from the major panels */
    #left, #right {
        display: flex;
        flex: none;
    }

    /* let the canvas and console breathe */
    #canvas-wrap {
        height: 45vh;
        flex: none;
    }

    #console {
        height: 180px;
        flex: none;
    }

    /* unlock the tabs so they expand to fit their inner content */
    .tabbody {
        display: block;
        overflow: visible;
    }

    .tabpane.is-active,
    #pane-palette.is-active {
        display: block;
        overflow: visible;
    }

    /* blocklists must use a fixed height now that their parent isn't stretching */
    #pane-palette > .picker:not(.picker--overlay) {
        flex: none;
    }

    .blocklist {
        flex: none;
        height: 35vh;
        min-height: 200px;
    }

    .slider-row {
        flex-wrap: wrap;
    }

        .slider-row > label {
            flex: 1 1 100%;
        }
}

@media (max-width: 620px) {
    .head-tools {
        flex-wrap: wrap;
        justify-content: center;
    }
    .slider-grid {
        grid-template-columns: 1fr;
    }

    .picker {
        grid-template-columns: minmax(0,1fr);
    }

    .picker-tools {
        flex-direction: row;
        justify-content: center;
        flex-wrap: wrap;
        padding-top: 0;
    }

    .tool-gap {
        display: none;
    }

    .btn.primary {
        font-size: 13px;
        padding: 0 8px;
    }

    .canvas-hint {
        display: none;
    }

    /* rotates the arrows to up/down for the stacked picker layout */
    #btn-move .ic,
    #btn-all-allow .ic,
    #btn-all-disallow .ic,
    #btn-ov-move .ic,
    #btn-ov-all-allow .ic,
    #btn-ov-all-disallow .ic {
        transform: rotate(90deg);
    }

    /* touch targets. 44px is the smallest that is comfortable with a thumb */
    .icobtn {
        width: 44px;
        height: 44px;
    }

        .icobtn .ic {
            width: 24px;
            height: 24px;
        }

    .tabtool {
        width: 44px;
        height: 40px;
    }

        .tabtool .ic {
            width: 22px;
            height: 22px;
        }

    .picker-tools {
        gap: 10px;
        padding: 4px 0 8px;
    }

    /* taller rows, so a row is a target rather than a line of text */
    .brow {
        padding: 10px 8px;
        gap: 10px;
    }

    .blocklist {
        position: static;
        height: 46vh;
        flex: none;
    }

        /* a finger dragging in the left part of a list selects; the rest still
       scrolls. The divider marks where that changes */
        .blocklist::after {
            content: "";
            position: absolute;
            top: 32px;
            bottom: 0;
            right: 40%;
            width: 1px;
            background: var(--border);
            opacity: .5;
            pointer-events: none;
            z-index: 5;
        }

    /* nothing here survives a phone screen usefully, and it costs a third of
       the height */
    #console {
        display: none;
    }

    /* no file can be dragged onto a phone, so the target is dead weight */
    #import-drop {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: .01ms !important;
        transition-duration: .01ms !important;
    }
}

/* ==========================================================================
   Help markers
   ========================================================================== */

/* sits inline after a heading or label without disturbing its baseline */
.help {
    display: inline-grid;
    place-items: center;
    align-self: center;
    width: 18px;
    height: 18px;
    padding: 0;
    margin-left: 6px;
    background: none;
    border: none;
    border-radius: 50%;
    color: var(--text-dim);
    cursor: help;
}

    .help:hover, .help:focus-visible {
        color: var(--accent-bright);
    }

    .help .ic {
        width: 17px;
        height: 17px;
    }

/* keeps the help marker next to the heading, reset button on the right */
.group-head .help {
    margin-right: auto;
}

#help-pop {
    width: 320px;
    max-width: calc(100vw - 16px);
    max-height: 70vh;
    overflow-y: auto;
    cursor: default;
}

.help-body {
    margin: 0;
    color: var(--text);
    font-size: 12px;
    line-height: 1.5;
}

.help-list {
    margin: 0;
    display: grid;
    gap: 6px;
}

    .help-list dt {
        color: var(--accent-bright);
        font-size: 12px;
    }

    .help-list dd {
        margin: 2px 0 0;
        color: var(--text-dim);
        font-size: 12px;
        line-height: 1.45;
    }

/* ==========================================================================
   Config presets — tab bar tools and their menus
   ========================================================================== */

/* icons inherit the button's colour via fill, not stroke */
.ic {
    flex: none;
    width: 25px;
    height: 25px;
    fill: currentColor;
    stroke: none;
    pointer-events: none;
}

.ic--reset {
    flex: none;
    width: 22px;
    height: 22px;
    fill: currentColor;
    stroke: none;
    pointer-events: none;
}

#btn-snapshot {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

    #btn-snapshot .ic {
        width: 15px;
        height: 15px;
    }

/* pushes the tab tools to the far edge of the row */
.tab-tools {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    padding-bottom: 3px;
    min-width: 164px;   /* the four buttons plus the divider */
}

/* auto margin parks the version picker on the left of the otherwise
   right-aligned .tab-tools */
.tabtool-select {
    flex: none;
    height: 28px;
    background-color: var(--btn);
    background-position: calc(100% - 14px) 12px, calc(100% - 9px) 12px;
    font-size: 13px;
}

    .tabtool-select:hover {
        background-color: var(--btn-hover);
    }

.tab-tools-sep {
    width: 1px;
    height: 18px;
    background: var(--border);
    flex: none;
}

.tabtool {
    width: 32px;
    height: 28px;
    padding: 0;
    flex: none;
    display: grid;
    place-items: center;
    background: var(--btn);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
}

    .tabtool:hover {
        background: var(--btn-hover);
    }

    .tabtool:active {
        background: var(--accent);
    }

    .tabtool .ic {
        width: 19px;
        height: 19px;
    }

.cfg-menu {
    position: fixed;
    z-index: 40;
    width: 264px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 10px 30px rgba(0,0,0,.6);
}

    .cfg-menu[hidden] {
        display: none;
    }

    .cfg-menu input[type=text] {
        width: 100%;
    }

.cfg-menu-title {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--accent-title);
    font-size: 13px;
}

    .cfg-menu-title .ic {
        width: 15px;
        height: 15px;
    }

.cfg-hint {
    color: var(--text-dim);
    font-size: 12px;
}

.cfg-warn {
    color: var(--warn);
    font-size: 12px;
}

.cfg-empty {
    color: var(--text-dim);
    font-size: 12px;
    padding: 10px 2px;
}

.cfg-list[hidden] {
    display: none;
}

.cfg-list {
    max-height: 190px;
    overflow-y: auto;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 3px;
}

.cfg-row {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 5px 6px;
    background: none;
    border: none;
    border-radius: 3px;
    color: var(--text);
    font-size: 12px;
    text-align: left;
    cursor: pointer;
}

    .cfg-row:hover {
        background: rgba(255,255,255,.07);
    }

.cfg-row--tall {
    padding: 0;
    gap: 0;
}

    .cfg-row--tall:hover {
        background: none;
    }

.cfg-row-name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cfg-row-meta {
    flex: none;
    color: var(--text-dim);
}

.cfg-row-main {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 6px;
    background: none;
    border: none;
    border-radius: 3px;
    color: var(--text);
    font-size: 12px;
    text-align: left;
    cursor: pointer;
}

    .cfg-row-main:hover {
        background: rgba(255,255,255,.07);
    }

.cfg-row-sub {
    color: var(--text-dim);
    font-size: 11px;
}

.cfg-row-del {
    flex: none;
    width: 24px;
    height: 24px;
    margin-right: 4px;
    background: none;
    border: none;
    border-radius: 3px;
    color: var(--text-dim);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
}

    .cfg-row-del:hover {
        background: rgba(255,80,80,.2);
        color: #ff8080;
    }

.cfg-what {
    color: var(--text-dim);
    font-size: 12px;
    line-height: 1.8;
}

    .cfg-what div::before {
        content: "\2713";
        color: var(--log);
        margin-right: 6px;
    }

.cfg-drop {
    padding: 20px 10px;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    color: var(--text-dim);
    font-size: 12px;
    text-align: center;
}

    .cfg-drop.is-over {
        border-color: var(--accent-bright);
        color: var(--text);
    }

.cfg-primary {
    width: 100%;
    height: var(--row-h);
    background: var(--accent);
    border: none;
    border-radius: var(--radius);
    color: #fff;
    font-size: 12px;
    cursor: pointer;
}

    .cfg-primary:hover {
        background: #0093ff;
    }

/* ==========================================================================
   Preview snapshots — filmstrip and the frozen-view chrome
   ========================================================================== */

/* sits inside #canvas-wrap rather than beside it, so no markup had to move.
   draw() subtracts its width from the canvas instead */
#filmstrip {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 74px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 5px;
    background: var(--panel);
    border-left: 1px solid var(--border);
    z-index: 3;
}

#strip-items {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

#filmstrip[hidden] {
    display: none;
}

.strip-head {
    color: var(--text-dim);
    font-size: 11px;
    text-align: center;
    flex: none;
}

.strip-item {
    position: relative;
    flex: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    /* pan-y keeps the strip scrollable while stopping double-tap zoom; the
       other two stop iOS turning a long press into a callout and a selection */
    touch-action: pan-y;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

    /* held open by a tap on touch, rather than by the cursor resting on it */
    .strip-item.is-pinned {
        border-color: #ffb020;
        box-shadow: inset 0 0 0 1px #ffb020;
    }

    /* mid long-press: shows the hold registered before it completes */
    .strip-item.is-holding {
        border-color: #ffb020;
        opacity: .7;
    }

    .strip-item:hover, .strip-item:focus-visible {
        border-color: #ffb020;
        outline: none;
    }

    .strip-item img {
        display: block;
        width: 100%;
        height: 44px;
        object-fit: contain;
        background: var(--bg);
    }

.strip-cap {
    color: var(--text-dim);
    font-size: 11px;
    text-align: center;
    padding: 2px;
}

.strip-del {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 16px;
    height: 16px;
    padding: 0;
    display: none;
    place-items: center;
    background: rgba(0,0,0,.65);
    border: none;
    border-radius: 3px;
    color: #fff;
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
}

.strip-item:hover .strip-del, .strip-item:focus-within .strip-del {
    display: grid;
}

.strip-del:hover {
    background: #a32d2d;
}

/* amber, not the app's blue, to mark a frozen snapshot view */
#snap-ring {
    position: absolute;
    inset: 0;
    border: 2px solid #ffb020;
    border-radius: var(--radius);
    pointer-events: none;
    z-index: 4;
}

#snap-badge {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    padding: 4px 12px;
    max-width: calc(100% - 100px);
    background: #ffb020;
    border-radius: 4px;
    color: #412402;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
}

    #snap-ring[hidden], #snap-badge[hidden] {
        display: none;
    }

@media (max-width: 620px) {
    .tab {
        padding: 7px 12px;
        font-size: 13px;
    }

    .tab-tools {
        padding: 6px 0 0;
        justify-content: flex-start;
    }

    #filmstrip {
        width: 62px;
    }

    #snap-badge {
        font-size: 11px;
        max-width: calc(100% - 76px);
    }
}

/* ------------------------------------------------------------- scroll FAB */
.fab {
    position: fixed;
    bottom: 80px;
    /* positions it in the bottom-right of the left configuration panel on desktop */
    left: calc(var(--left-w) - 64px);
    z-index: 50;
    width: 44px;
    height: 44px;
    padding: 0;
    display: grid;
    place-items: center;
    background: var(--frame-active);
    color: #fff;
    border: none;
    border-radius: 50%;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transform: translateY(15px);
    transition: opacity 0.2s ease, transform 0.2s ease, background 0.2s ease;
}

    .fab .ic {
        transform: rotate(90deg);
        width: 24px;
        height: 24px;
    }

    .fab:active {
        transform: translateY(0) scale(0.95);
    }

    /* toggled by JS when scrolling past the threshold */
    .fab.is-visible {
        opacity: 1;
        pointer-events: auto;
        transform: translateY(0);
    }

/* on mobile, move it to the standard bottom-right of the screen */
@media (max-width: 1100px) {
    .fab {
        left: auto;
        right: 40px;
    }
}

/* ==========================================================================
   SEO and accessibility scaffolding
   ========================================================================== */

/* visually hidden but readable by screen readers and crawlers */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

/* link out to the guide, under the export buttons */
.panel-foot {
    flex: none;
    margin: 6px 0 0;
    text-align: center;
    font-size: 12px;
}

    .panel-foot a {
        color: var(--text-dim);
        text-decoration: none;
        border-bottom: 1px solid transparent;
    }

        .panel-foot a:hover {
            color: var(--accent-bright);
            border-bottom-color: rgba(0,179,255,.4);
        }

@media (max-width: 620px) {
    .panel-foot {
        margin-bottom: 2vh;
    }
}

/* shown when JavaScript is disabled */
.noscript-note {
    max-width: 620px;
    margin: 60px auto;
    padding: 0 20px;
    line-height: 1.6;
}

    .noscript-note h2 {
        margin: 0 0 14px;
        font-size: 22px;
        font-weight: 500;
        color: var(--accent-title);
    }

    .noscript-note p {
        margin: 0 0 12px;
        color: var(--text);
    }

    .noscript-note a {
        color: var(--accent-bright);
    }

    .noscript-note code {
        padding: 1px 5px;
        background: var(--frame);
        border-radius: 3px;
        font-size: .9em;
    }
