/* Screen-reader-only: present in the DOM (and for crawlers) but visually
   hidden without removing it from the accessibility tree. */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

:root {
    /* Needle brand surfaces */
    --color-page: #F0F4EF;          /* light green page stage */
    --color-surface: #FFFFFF;       /* white working surfaces */
    --color-info: #DBEBE1;          /* callout success */

    /* Needle brand greens */
    --color-green: #99CC33;
    --color-green-dark: #74AF52;
    --color-green-light: #D7DB0A;

    /* Text */
    --color-text: #1A1A1A;
    --color-text-secondary: #4A4E4A;
    --color-text-muted: #767A76;
    --color-link: #826AED;

    /* Borders */
    --border-subtle: #D9E2D7;
    --border-strong: #C6D0C4;
    --border-focus: #826AED;

    /* Backwards-compatible aliases used across the stylesheet */
    --color-bg-0: var(--color-surface);
    --color-bg-1: var(--color-page);
    --color-bg-2: var(--color-info);
    --color-theme-1: var(--color-text);
    --color-theme-2: var(--color-green-dark);

    --font-body: "Nunito Sans", system-ui, -apple-system, sans-serif;
    --font-code: "Monaspace Neon", ui-monospace, "SF Mono", Menlo, monospace;
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-body);
    color: var(--color-text);
    min-height: 100vh;
    background-attachment: fixed;
    /* Solid light-green stage — brand: no decorative gradients */
    background-color: var(--color-page);
}

.footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    /* Dark terminal bar — solid, no blur / glass */
    background-color: #222125;
    border-top: 1px solid #40393B;
    padding: 8px 15px;
    z-index: 100;
}

.footer-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

#message-log {
    opacity: 1;
    font-size: 0.75em;
    color: rgba(255, 255, 255, 0.85);
    margin: 0;
    font-family: var(--font-code);
    max-height: 40vh;
    overflow-y: auto;
    line-height: 1.4;
    flex: 1;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.clear-log-button {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: rgba(255, 255, 255, 0.85);
    font-family: var(--font-body);
    font-size: 0.75em;
    font-weight: 600;
    height: 24px;
    padding: 0 10px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s, border-color 0.15s, opacity 0.15s;
    flex-shrink: 0;
}

.clear-log-button:hover {
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 255, 255, 0.3);
    color: #fff;
}

.clear-log-button:disabled {
    opacity: 0.4;
    cursor: default;
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.18);
    color: rgba(255, 255, 255, 0.85);
}

/* Loading spinner (footer terminal bar) */
.spinner {
    width: 13px;
    height: 13px;
    flex-shrink: 0;
    border: 2px solid rgba(255, 255, 255, 0.25);
    border-top-color: var(--color-green);
    border-radius: 50%;
    animation: spinner-rotate 0.7s linear infinite;
}

.spinner[hidden] {
    display: none;
}

/* Inline status icon inside the footer log (e.g. the "loading done" check) */
.log-icon {
    width: 13px;
    height: 13px;
    vertical-align: -2px;
    margin-right: 6px;
    color: var(--color-green);
}

/* Centered drop hint — visible while no model is loaded */
#dropzone {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    /* let drags/clicks fall through to the 3D canvas underneath */
    pointer-events: none;
    /* sits above the canvas but below the toolbar + its menu popover */
    z-index: 10;
    padding: 24px;
}

/* Hidden once a model is loaded (#container gains .have-custom-file). #container
   is now nested in #top-center, so #dropzone is no longer its sibling — match
   via :has() on the wrapper instead. */
#top-center:has(.have-custom-file) ~ #dropzone {
    display: none;
}

.dropzone-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 36px 52px;
    border: 2px dashed var(--border-strong);
    border-radius: 20px;
    background-color: rgba(255, 255, 255, 0.55);
    color: var(--color-text-muted);
    text-align: center;
    transition: border-color 0.15s, background-color 0.15s, color 0.15s;
}

.dropzone-icon {
    width: 52px;
    height: 52px;
    color: var(--color-text-muted);
}

.dropzone-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--color-text-secondary);
}

.dropzone-subtitle {
    margin: 0;
    font-size: 0.85rem;
}

/* highlight while a file is dragged anywhere over the window */
body.drag-active .dropzone-inner {
    border-color: var(--color-green);
    background-color: var(--color-info);
    color: var(--color-green-dark);
}

body.drag-active .dropzone-title {
    color: var(--color-green-dark);
}

/* Centered loading overlay — one row: spinner, label, filename, sep, cancel */
#loading-overlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    /* above the drop hint, still below the toolbar + its menu popover */
    z-index: 20;
    padding: 24px;
    /* backdrop is click-through; only the pill captures clicks */
    pointer-events: none;
}

#loading-overlay.visible {
    display: flex;
}

.loading-overlay-inner {
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: min(90vw, 560px);
    padding: 12px 12px 12px 18px;
    border: 1px solid var(--border-subtle);
    border-radius: 999px;
    background-color: var(--color-surface);
    box-shadow: 0 8px 28px rgba(26, 26, 26, 0.18);
    pointer-events: auto;
}

.spinner-md {
    width: 20px;
    height: 20px;
    margin-top: 0;
    border: 2.5px solid var(--border-subtle);
    border-top-color: var(--color-green);
    flex-shrink: 0;
}

.loading-overlay-word {
    color: var(--color-text-secondary);
    font-weight: 700;
    white-space: nowrap;
    flex-shrink: 0;
}

.loading-overlay-filename {
    color: var(--color-text);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 320px;
    min-width: 0;
}

.loading-overlay-sep {
    color: var(--color-text-muted);
    flex-shrink: 0;
}

.loading-cancel-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    flex-shrink: 0;
    border: 1px solid var(--border-strong);
    border-radius: 50%;
    background: transparent;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.loading-cancel-button:hover {
    background-color: var(--color-info);
    color: var(--color-text);
}

.loading-cancel-button svg {
    width: 15px;
    height: 15px;
}

@keyframes spinner-rotate {
    to { transform: rotate(360deg); }
}

#container {
    background-color: var(--color-surface);
    font-size: 0.9em;
    min-height: 44px;
    display: flex;
    align-items: center;

    padding-left: 16px;
    padding-right: 16px;
    margin-top: 5px;

    border: 1px solid var(--border-subtle);
    /* Pill: fully rounded left/right ends */
    border-radius: 999px;
    box-shadow: 0 1px 4px rgba(26, 26, 26, 0.06);
    /* stacking context above the drop hint (10) and loading overlay (20) so the
       menu popover renders on top of both */
    z-index: 30;
}

#container .buttons {
    display: flex;
    align-items: center;
    /* The pill stays a single row at every width; items condense on mobile
       (see the max-width media query) rather than wrapping to a second line. */
    flex-wrap: nowrap;
    flex-direction: row;
    white-space: nowrap;
}

.needle-logo {
    height: 26px;
    margin-right: 10px;
    /* block removes the inline baseline gap so the logo sits centered */
    display: block;
    /* brand: logo must not be recolored or faded — keep full opacity */
    opacity: 1;
}

/* Dropdown Styles */
.dropdown {
    /* Static (not relative) so the menu's containing block is the centered pill
       (#container), letting it center under the pill instead of opening off the
       right edge from the off-centre Load Sample button. */
    position: static;
    display: inline-block;
}

.dropdown-button {
    background-color: transparent;
    border: none;
    color: var(--color-text-secondary);
    padding: 8px 10px;
    margin: 0 4px;
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
    transition: color 0.15s linear;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* Inline icon inside the dropdown button */
.dropdown-button .btn-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.dropdown-button:hover {
    color: var(--color-text);
}

.dropdown-content {
    display: none;
    position: absolute;
    background-color: var(--color-surface);
    width: max-content;
    max-width: min(780px, 96vw);
    /* Clear outline + lift so the popover reads as a distinct floating panel
       against the light page background. */
    box-shadow: 0 10px 28px rgba(26, 26, 26, 0.18);
    /* Above the "What's New" banner (110) and other chrome when open. */
    z-index: 200;
    border-radius: 10px;
    border: 1px solid var(--border-strong);
    /* Gap below the pill. The JS hover model keeps the menu open for a 300ms
       grace after the cursor leaves, which covers crossing this gap — so no
       transparent-border bridge is needed and the outline can wrap all sides.
       Overridden on mobile. */
    top: calc(100% + 1em);
    /* Centered under the pill (its containing block) so a wide mega-menu stays
       within the viewport regardless of where the trigger sits in the pill. */
    left: 50%;
    transform: translateX(-50%);
    /* clip the gallery flyout's square corners to the rounded panel */
    overflow: hidden;
}

/* The menu is a two-column mega-menu: link list + Sample Library flyout.
   Visibility is JS-driven via .menu-open (see index.js): pointer devices open on
   mouseenter and close 300ms after mouseleave; touch toggles it by tap. A class
   (not :hover) is used so the close can be delayed and so a tap doesn't get
   stuck in :hover on touch. */
.dropdown.menu-open .dropdown-content {
    display: flex;
    align-items: stretch;
}

.dropdown-menu {
    padding: 8px 0;
    /* grow to fit the widest row (e.g. the "USD Working Group Assets" heading) */
    min-width: 200px;
    flex-shrink: 0;
}

.dropdown-section {
    padding: 4px 0;
}

/* Items hidden unless the "?debug_menu_items" URL flag is set (e.g. dead links).
   Selectors must out-specify ".dropdown-menu a { display: block }" (0,1,1),
   so they are scoped to ".dropdown-menu a.debug-only" (0,2,1). */
.debug-only {
    display: none;
}

.dropdown-menu a.debug-only {
    display: none;
}

body.show-debug-menu .dropdown-menu a.debug-only {
    display: block;
}

.dropdown-section h4 {
    margin: 8px 12px 4px 12px;
    font-size: 0.78em;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
    font-weight: 700;
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 4px;
    white-space: nowrap;
}

.dropdown-menu a {
    color: var(--color-text-secondary);
    padding: 6px 12px;
    text-decoration: none;
    display: block;
    margin: 0;
    font-size: 0.9em;
}

.dropdown-menu a:hover {
    background-color: var(--color-info);
    color: var(--color-text);
}

/* Dialog Styles */
.dialog-overlay {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(26, 26, 26, 0.4);
}

.dialog {
    background-color: var(--color-surface);
    margin: 80px auto;
    padding: 0;
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    width: 80%;
    max-width: 500px;
    box-shadow: 0 8px 28px rgba(26, 26, 26, 0.18);
}

.dialog-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px 16px 24px;
    border-bottom: 1px solid var(--border-subtle);
}

.dialog-header h2 {
    margin: 0;
    color: var(--color-text);
    font-size: 1.4em;
    font-weight: 800;
}

.dialog-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--color-text-secondary);
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.15s;
}

.dialog-close:hover {
    background-color: var(--color-info);
    color: var(--color-text);
}

.dialog-content {
    padding: 20px 24px 24px 24px;
    color: var(--color-text-secondary);
    line-height: 1.5;
}

.dialog-content p {
    margin: 0 0 16px 0;
}

.dialog-content p:last-child {
    margin-bottom: 0;
}

.runtime-info {
    padding: 10px 12px;
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    background: var(--color-info);
    color: var(--color-text);
    font-family: var(--font-code);
    font-size: 0.78rem;
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.dialog-content a {
    color: var(--color-link);
    text-decoration: none;
}

.dialog-content a:hover {
    text-decoration: underline;
}

.dialog-actions {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.dialog-actions a {
    color: var(--color-link);
    text-decoration: none;
    font-weight: 600;
}

.dialog-actions a:hover {
    text-decoration: underline;
    cursor: pointer;
}

/* Export dialog call-to-action: Needle Cloud primary, browser download secondary. */
.dialog-cta {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

/* Scoped under .dialog-cta to out-specify ".dialog-content a" (0,1,1), which
   would otherwise paint the label link-purple on the green button. */
.dialog-cta .cta-primary {
    display: inline-flex;
    align-items: center;
    background-color: var(--color-green-dark);
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    padding: 9px 18px;
    border-radius: 999px;
    transition: background-color 0.15s;
}

.dialog-cta .cta-primary:hover {
    background-color: var(--color-text);
    color: #fff;
    text-decoration: none;
}

.cta-secondary {
    background: none;
    border: none;
    padding: 9px 4px;
    color: var(--color-text-secondary);
    font-family: inherit;
    font-size: 1em;
    font-weight: 600;
    text-decoration: underline;
    cursor: pointer;
}

.cta-secondary:hover {
    color: var(--color-text);
}

/* Sample Library flyout — a second column of the dropdown mega-menu, revealed
   on the same hover as the link menu (no click, no separate popover). */
.gallery-flyout {
    display: flex;
    flex-direction: column;
    width: 380px;
    max-width: 60vw;
    border-left: 1px solid var(--border-subtle);
    background-color: var(--color-page);
    padding: 12px;
    /* No max-height here — the grid inside is the scroll container and caps its
       own height. Capping the flyout too would clip the grid's last rows. */
}

.gallery-panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.gallery-panel-title {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.gallery-panel-head h4 {
    margin: 0;
    font-size: 0.78em;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
    font-weight: 700;
    white-space: nowrap;
}

.gallery-panel-subtitle {
    font-size: 0.72em;
    color: var(--color-text-muted);
    font-weight: 600;
    white-space: nowrap;
}

/* Brand logo left of each converter label. */
.conv-logo {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
}

/* Segmented converter toggle (three | blender | omniverse). */
.converter-toggle {
    display: inline-flex;
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
}

.converter-toggle button {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: var(--color-surface);
    border: none;
    border-left: 1px solid var(--border-subtle);
    color: var(--color-text-secondary);
    font-family: inherit;
    font-size: 0.72em;
    padding: 4px 8px;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
}

.converter-toggle button:first-child {
    border-left: none;
}

.converter-toggle button:hover {
    background-color: var(--color-info);
    color: var(--color-text);
}

.converter-toggle button.active {
    background-color: var(--color-green-dark);
    color: #fff;
}

.gallery-status {
    font-size: 0.82em;
    color: var(--color-text-muted);
    margin: 0 0 8px 0;
}

.gallery-status.error {
    color: #b3261e;
}

.gallery-status[hidden] {
    display: none;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
    padding: 2px;
    /* Self-contained scroll container. A definite max-height here (viewport
       units, not %) makes the grid scroll on its own — it does NOT depend on a
       definite height propagating down the flex chain, which never resolves
       because the dropdown is an absolutely-positioned hover popover. */
    max-height: 60vh;
    overflow-y: auto;
    /* Size rows to content and pack from the top. Without these, the cards
       (which use overflow:hidden, giving them an auto-minimum of 0) let the grid
       stretch its rows to fill the fixed height — collapsing each thumbnail to a
       ~3px strip instead of overflowing into the scroll area. */
    grid-auto-rows: max-content;
    align-content: start;
}

/* Each card is an "a.file" so it reuses the existing URL-load handler. The
   "#container" prefix is needed to out-specify "#container a" (1,0,1), which
   would otherwise force its own padding/margin onto these <a> cards. */
#container .gallery-card {
    display: block;
    padding: 0;
    margin: 0;
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    overflow: hidden;
    text-decoration: none;
    color: var(--color-text-secondary);
    background: var(--color-surface);
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}

#container .gallery-card:hover {
    border-color: var(--color-green-dark);
    box-shadow: 0 4px 14px rgba(26, 26, 26, 0.12);
    transform: translateY(-1px);
    text-decoration: none;
}

#container .gallery-card.active {
    border-color: var(--color-green-dark);
    box-shadow: 0 0 0 2px var(--color-green-dark);
}

/* Fixed-height thumbnail. A definite pixel height never collapses — unlike
   aspect-ratio or the padding-top hack, both of which resolve to ~0 height
   inside a grid/flex item and squash the image into a thin strip. */
.gallery-thumb-wrap {
    height: 116px;
    background: var(--color-info);
    overflow: hidden;
}

.gallery-thumb {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery-card-body {
    padding: 7px 9px 9px 9px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* "#container" prefix beats "#container a span" (1,0,2) for the card labels. */
#container .gallery-name {
    font-size: 0.82em;
    font-weight: 700;
    color: var(--color-text);
    line-height: 1.2;
}

#container .gallery-meta {
    font-size: 0.7em;
    color: var(--color-text-muted);
}

/* Narrow screens: stack the gallery under the links instead of beside them. */
@media (max-width: 720px) {
    /* Anchor the menu to the viewport instead of the (centered) button, so it
       can't run off-screen. It drops down as a near-full-width panel below the
       header and scrolls as one. */
    .dropdown {
        position: static;
    }
    .dropdown-content {
        position: fixed;
        /* Just below the one-row pill (~51px). #top-center's transform makes it
           the containing block, so this is measured from its top (viewport 5px),
           i.e. the menu opens ~viewport 59px — snug under the pill. */
        top: 54px;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        flex-direction: column;
        width: 94vw;
        max-width: 94vw;
        max-height: calc(100dvh - 72px);
        overflow-y: auto;
        z-index: 1000;
    }
    .gallery-flyout {
        width: auto;
        max-width: none;
        border-left: none;
        border-top: 1px solid var(--border-subtle);
    }
    /* Stack the title above the converter toggle so the (logo-widened) toggle
       gets the full panel width instead of overflowing the right edge. */
    .gallery-panel-head {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }
    /* Let the whole panel scroll as one on mobile rather than a nested grid. */
    .gallery-grid {
        max-height: none;
    }
}

/* Phone widths: condense the pill so it stays one row. The "About USD Viewer"
   label collapses to just its icon, and spacing tightens. */
@media (max-width: 560px) {
    #container {
        padding-left: 12px;
        padding-right: 12px;
        font-size: 0.85em;
    }
    .about-text {
        display: none;
    }
    #about-link .usd-logo {
        margin-right: 0;
    }
    .needle-logo {
        height: 22px;
        margin-right: 6px;
    }
    .filename-bar {
        max-width: 96vw;
    }
}

/* Tiniest phones: Export collapses to its icon so the pill still fits one row.
   Load Sample keeps its label as the primary action. */
@media (max-width: 430px) {
    .export-button {
        font-size: 0;
    }
    .export-button .inline-icon {
        margin-right: 0;
    }
}

/* Very small phones (~320px): drop the About entry and tighten padding so the
   one-row pill still fits. */
@media (max-width: 380px) {
    #about-link {
        display: none;
    }
    #container {
        padding-left: 10px;
        padding-right: 10px;
    }
}

#container a {
    color: var(--color-text-secondary);
    text-decoration: none;
    padding: 8px 10px;
    margin: 0 4px;
    transition: color 0.15s linear;
}

#container a:hover, .dropdown-button:hover {
    color: var(--color-text);
    text-decoration: underline;
    cursor: pointer;
}

#container a span {
    font-size: 0.8em;
    color: var(--color-text-muted);
}

/* Inline SVG icons that sit left of a text label (filename, Export glTF) */
.inline-icon {
    width: 15px;
    height: 15px;
    vertical-align: -2px;
    margin-right: 5px;
    pointer-events: none;
}

/* Loaded filename is a label, not a link — no pointer, no hover underline */
.filename {
    color: var(--color-text-secondary);
    padding: 8px 10px;
    margin: 0 4px;
    cursor: default;
}

/* The Needle logo link should not show the text-link underline on hover */
#container a.needle-logo-link,
#container a.needle-logo-link:hover {
    padding: 8px 6px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}

/* About link: USD logo sits left of the label, vertically centered */
.usd-logo {
    width: 18px;
    height: 18px;
    vertical-align: middle;
    margin-right: 6px;
    position: relative;
    top: -1px;
}

/* Visible focus ring on every interactive element — brand accessibility */
a:focus-visible,
button:focus-visible {
    outline: 2px solid var(--border-focus);
    outline-offset: 2px;
    border-radius: 4px;
}

.have-custom-file a.file.hide {
    display: none;
}

/* Hide Clear button when no file is loaded */
#container:not(.have-custom-file) .clear-button {
    display: none;
}

/* Hide Export button when no file is loaded */
#container:not(.have-custom-file) .export-button {
    display: none;
}

/* Hide filename display when no file is loaded */
/* Centered top stack: the header pill on top, the loaded-file row below it.
   Absolutely positioned and horizontally centered; the pill and file row are
   stacked so the file row always sits just under the pill, whatever its
   height. */
#top-center {
    position: absolute;
    top: 5px;
    left: 50%;
    transform: translateX(-50%);
    /* Above the "What's New" banner (110): the transform makes #top-center a
       stacking context, so the open menu inside it can only rise above the
       banner if #top-center itself does. */
    z-index: 200;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    max-width: 96vw;
}

/* The file row is a sibling of #container inside #top-center, so the "no file
   loaded" hide rule uses the sibling combinator. */
#container:not(.have-custom-file) ~ .filename-bar {
    display: none;
}

/* Loaded-file row: filename label, separator, Clear — centered under the pill.
   No background; it floats as plain text over the canvas. Only the Clear action
   is interactive so the label never blocks canvas interaction. */
.filename-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 96vw;
    pointer-events: none;
}

.filename-bar .filename {
    display: inline-flex;
    align-items: center;
    min-width: 0;
    padding: 0;
    margin: 0;
    font-size: 0.9em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.filename-bar .filename-text {
    overflow: hidden;
    text-overflow: ellipsis;
}

.filename-sep {
    color: var(--color-text-muted);
    user-select: none;
}

.filename-bar .clear-button {
    pointer-events: auto;
    display: inline-flex;
    align-items: center;
    color: var(--color-text-secondary);
    text-decoration: none;
    font-size: 0.9em;
    white-space: nowrap;
    cursor: pointer;
}

.filename-bar .clear-button:hover {
    color: var(--color-text);
    text-decoration: underline;
}

/* "What's New" banner — small, subtle, bottom-right announcement card that
   rotates through items from the Needle marketer feed. Sits above the footer
   terminal bar (z-index 100) but is small enough not to crowd the canvas. */
.whats-new {
    position: fixed;
    right: 14px;
    /* clear the footer terminal bar (single-line height + breathing room) */
    bottom: 58px;
    z-index: 110;
    width: 300px;
    max-width: calc(100vw - 28px);
    border-radius: 12px;
    box-shadow: 0 8px 28px rgba(26, 26, 26, 0.18);
    overflow: hidden;
    /* hidden state: nudged down + faded; .is-visible animates it in */
    opacity: 0;
    transform: translateY(12px);
    /* transition every animatable property change (fade/slide in + out) */
    transition: all 0.25s ease;
    pointer-events: none;
}

.whats-new.is-visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.whats-new-link {
    display: block;
    /* banner.css from the feed sets the background + readable text colour;
       these are the layout defaults it themes on top of */
    background-color: var(--color-surface);
    color: var(--color-text);
    text-decoration: none;
    padding: 14px 38px 14px 16px;
    font-family: var(--font-body);
    line-height: 1.35;
    /* ease the themed background/text change between rotated items
       (solid backgrounds + text colour tween; CSS can't tween gradients,
       which the card's opacity fade covers instead) */
    transition: all 0.25s ease;
}

.whats-new-kicker {
    display: block;
    font-size: 0.62rem;
    font-weight: 800;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    opacity: 0.7;
    margin-bottom: 3px;
}

.whats-new-title {
    display: block;
    font-size: 0.95rem;
    font-weight: 800;
}

.whats-new-subtitle {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    opacity: 0.9;
    margin-top: 2px;
}

.whats-new-cta {
    display: inline-block;
    margin-top: 8px;
    font-size: 0.78rem;
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* Dismiss (×) — small, lives in the top-right corner of the card */
.whats-new-dismiss {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 24px;
    height: 24px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 6px;
    /* inherit the banner's text colour, kept subtle until hover */
    color: currentColor;
    background: transparent;
    opacity: 0.55;
    cursor: pointer;
    transition: opacity 0.15s, background-color 0.15s;
}

.whats-new-dismiss:hover {
    opacity: 1;
    background: rgba(127, 127, 127, 0.18);
}

.whats-new-dismiss svg {
    width: 14px;
    height: 14px;
}

/* Rotation indicator dots */
.whats-new-dots {
    position: absolute;
    bottom: 8px;
    right: 10px;
    display: flex;
    gap: 5px;
    pointer-events: none;
}

.whats-new-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.3;
    transition: opacity 0.2s;
}

.whats-new-dot.is-active {
    opacity: 0.85;
}

@media (max-width: 520px) {
    .whats-new {
        right: 10px;
        left: 10px;
        width: auto;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
    /* No spin — show a calm, evenly-coloured ring instead of a frozen arc */
    .spinner {
        border-color: var(--color-green);
        opacity: 0.7;
    }
}

@media (prefers-contrast: more) {
    #container,
    .dropdown-content,
    .dialog {
        border-color: var(--border-strong);
        box-shadow: none;
    }
}
