/* Color themes and variables */

/* The Wyldcards palette. missing.css ships a warm grey scale and a navy accent,
   while this sheet, the landing page and the app icon were all drawn in slate
   and a brighter blue — so borders read blue-grey on beige-grey grounds and the
   two blues never matched. Re-tuning the scales missing.css builds every
   semantic token from brings its own rules along, and the semantic tokens
   below fix the hierarchy: muted text was nearly as dark as body text in light
   mode and nearly as bright in dark mode, and dark boxes jumped straight from
   near-black to mid-grey. gray-12 is the icon's ink. */
:root {
    --gray-0: #f8fafc;
    --gray-1: #f1f4f8;
    --gray-2: #e8edf3;
    --gray-3: #dde3ea;
    --gray-4: #cfd6df;
    --gray-5: #b3bcc8;
    --gray-6: #94a0ae;
    --gray-7: #7a8594;
    --gray-8: #5f6b7a;
    --gray-9: #4a5563;
    --gray-10: #343d4a;
    --gray-11: #1d2430;
    --gray-12: #0f1420;

    --blue-0: #eef5ff;
    --blue-1: #dce9ff;
    --blue-2: #bcd6ff;
    --blue-3: #93bcff;
    --blue-4: #6aa2fb;
    --blue-5: #4a8af2;
    --blue-6: #3474e0;
    --blue-7: #2968cf;
    --blue-8: #215bb8;
    --blue-9: #1d4f9f;
    --blue-10: #1a4586;
    --blue-11: #163a70;
    --blue-12: #112d56;

    --fg: var(--gray-12);
    --muted-fg: #56606e;
    --faded-fg: var(--gray-6);
    --bg: var(--gray-0);
    --plain-bg: var(--gray-1);
    --box-bg: var(--plain-bg);
    --interactive-bg: var(--gray-3);
    --accent: var(--blue-8);
    --muted-accent: var(--blue-5);
}

:root.-dark-theme {
    --fg: #e9eef4;
    --muted-fg: #a3aebb;
    --faded-fg: var(--gray-8);
    --bg: var(--gray-12);
    --plain-bg: #171d28;
    --box-bg: #1f2632;
    --interactive-bg: #2e3744;
    --plain-fg: var(--blue-3);
    --info-fg: var(--blue-3);
    --accent: #7cb3ff;
    --muted-accent: var(--blue-5);
}

@media (prefers-color-scheme: dark) {
    :root:not(.-no-dark-theme) {
        --fg: #e9eef4;
        --muted-fg: #a3aebb;
        --faded-fg: var(--gray-8);
        --bg: var(--gray-12);
        --plain-bg: #171d28;
        --box-bg: #1f2632;
        --interactive-bg: #2e3744;
        --plain-fg: var(--blue-3);
        --info-fg: var(--blue-3);
        --accent: #7cb3ff;
        --muted-accent: var(--blue-5);
    }
}

:root {
    --border: #cbd5e1;
    --accent-bg: rgba(0, 0, 0, 0.05);
    --text: var(--fg);
    --muted: var(--muted-fg);
    /* Screenplay text zoom (A−/A+); 1 = 12pt industry default. text-size.js writes
       the base value; --wyldcards-text-scale is what every rule actually reads, so
       page view can fold the canvas zoom into it without touching those rules. */
    --wyldcards-base-text-scale: 1;
    --wyldcards-text-scale: var(--wyldcards-base-text-scale, 1);
    /* Page canvas zoom; page-zoom.js overwrites this on <html>. */
    --wyldcards-page-zoom: 1;
    /* Tint for selected blocks; see the block-selection rules at the end. */
    --block-selection-tint: color-mix(in srgb, var(--accent, #2563eb) 16%, transparent);
    /* Block highlight tints; kept light enough for body text to stay readable. */
    --block-highlight-yellow: #fdf3d3;
    --block-highlight-green: #dff2e3;
    --block-highlight-blue: #dbe9f8;
    --block-highlight-red: #fbe0dd;
    --block-highlight-gray: #e9ecef;
    color-scheme: light;
}

/* Cross-document transitions complement HTMX's same-document swaps. Browsers
   that do not implement the API continue with ordinary navigation. */
@media (prefers-reduced-motion: no-preference) {
    @view-transition {
        navigation: auto;
    }

    ::view-transition-old(root) {
        animation: 120ms ease-out both wyldcards-page-exit;
    }

    ::view-transition-new(root) {
        animation: 180ms ease-out both wyldcards-page-enter;
    }
}

@keyframes wyldcards-page-exit {
    to { opacity: 0; }
}

@keyframes wyldcards-page-enter {
    from { opacity: 0; }
}

/* Comments live in the workbench's right panel. Closed, they are one slim line;
   the toolbar's Comments button opens them too. */
.wyldcards-card-comments {
    box-sizing: border-box;
    width: 100%;
    margin: 1rem 0 0;
}

.wyldcards-side > .wyldcards-card-comments:first-child {
    margin-top: 0;
}

.wyldcards-card-comments-details {
    position: relative;
    margin: 0;
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.65rem;
    /* --gray-0 is white in both themes; the box ground follows the theme. */
    background: var(--box-bg, #fff);
    overflow: visible;
}

/* Open, it scrolls inside a capped height rather than squeezing the card
   above it out of the fixed-height page. */
.wyldcards-card-comments-details[open] {
    max-height: min(40vh, 22rem);
    padding-bottom: 0.75rem;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.wyldcards-comment-form textarea::placeholder {
    text-align: start;
}
.wyldcards-transfer-tools input[type="search"]::placeholder {
    text-align: start;
}

/* Doubled class: missing.css's `details > summary:first-of-type` would
   otherwise make this a list item, adding its own ▶ beside ours. */
.wyldcards-card-comments-details > .wyldcards-card-comments-header {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
    margin: 0;
    padding: 0.1rem 0;
    list-style: none;
    cursor: pointer;
}

.wyldcards-card-comments-header h2 {
    font-size: 0.95rem;
    line-height: 1.4;
}

.wyldcards-card-comments-header .muted {
    font-size: 0.85rem;
    white-space: nowrap;
}

.wyldcards-card-comments-header::-webkit-details-marker {
    display: none;
}

.wyldcards-comments-close {
    display: none;
}

.wyldcards-card-comments-details[open] > .wyldcards-comments-close {
    display: inline-flex;
    position: absolute;
    top: 0.4rem;
    right: 0.75rem;
    min-height: 0;
    padding: 0.2rem 0.45rem;
    font-size: 0.8rem;
    text-align: start;
}

.wyldcards-card-comments-header::before {
    content: "▸";
    font-size: 0.8rem;
}

.wyldcards-card-comments-details[open] > .wyldcards-card-comments-header {
    margin-bottom: 0.6rem;
    padding-right: 4.5rem;
}

.wyldcards-card-comments-details[open] > .wyldcards-card-comments-header::before {
    content: "▾";
}

.wyldcards-comment > header {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
}

.wyldcards-card-comments-header h2,
.wyldcards-comment p {
    margin: 0;
}

.wyldcards-comment-list {
    display: grid;
    gap: 0.5rem;
    padding: 0;
    margin: 0.6rem 0;
    max-block-size: min(14rem, 28vh);
    overflow-y: auto;
    list-style: none;
}

.wyldcards-comment {
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.wyldcards-comment time {
    color: var(--muted);
    font-size: 0.85rem;
}

.wyldcards-comment-delete {
    margin-left: auto;
    padding: 0;
    border: 0;
    color: var(--muted);
    background: transparent;
    font-size: 0.8rem;
    text-decoration: underline;
}

.wyldcards-comment-form {
    display: grid;
    gap: 0.35rem;
}

.wyldcards-comment-form textarea {
    width: 100%;
    resize: vertical;
}

.wyldcards-comment-form button {
    justify-self: start;
}

.wyldcards-comment-notice {
    color: var(--error, #b91c1c);
}

.wyldcards-compare-page {
    max-width: none;
    padding: 1rem;
}

.wyldcards-compare-header {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 1rem;
    margin-bottom: 1rem;
}

.wyldcards-compare-header h1,
.wyldcards-compare-pane h2 {
    margin: 0;
}

.wyldcards-compare-picker {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.wyldcards-compare-picker label {
    font-weight: 600;
}

.wyldcards-compare-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(10rem, 1fr));
    gap: 0.35rem 0.75rem;
    margin: 0;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
}

.wyldcards-compare-options legend {
    padding: 0 0.25rem;
    font-weight: 600;
}

.wyldcards-compare-option {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-width: 0;
}

.wyldcards-compare-option span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wyldcards-compare-selection {
    flex-basis: 100%;
    margin: 0;
}

.wyldcards-compare-empty {
    padding: 2rem;
    text-align: center;
    border: 1px dashed var(--border);
    border-radius: 0.5rem;
}

.wyldcards-compare-panes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 30rem), 1fr));
    gap: 1rem;
}

.wyldcards-compare-pane {
    min-width: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 0.65rem;
    background: var(--gray-0, #fff);
    box-shadow: 0 0.4rem 1.25rem rgb(15 23 42 / 0.12);
}

.wyldcards-compare-titlebar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 2.5rem;
    padding: 0.4rem 0.75rem;
    border-bottom: 1px solid var(--border);
    background: var(--accent-bg);
}

.wyldcards-compare-open {
    margin-left: auto;
    font-size: 0.875rem;
}

.wyldcards-compare-window-dot {
    width: 0.7rem;
    height: 0.7rem;
    flex: 0 0 auto;
    border-radius: 50%;
    background: var(--accent, #2563eb);
}

.wyldcards-compare-frame {
    width: 100%;
    height: calc(100vh - 15rem);
    min-height: 38rem;
    border: 0;
}

@media (max-width: 800px) {
    .wyldcards-compare-header {
        align-items: start;
        flex-direction: column;
    }

    .wyldcards-compare-panes {
        grid-template-columns: 1fr;
    }

    .wyldcards-compare-options {
        grid-template-columns: 1fr;
        width: 100%;
    }

    .wyldcards-compare-frame {
        height: 42rem;
    }
}

:root.-dark-theme {
    --border: #3a4453;
    --accent-bg: rgba(255, 255, 255, 0.08);
    /* The dark accent is a pale blue: ink on it is the dark ground, not white. */
    --accent-contrast: var(--bg, #121210);
    --block-highlight-yellow: #4b3c14;
    --block-highlight-green: #1f4029;
    --block-highlight-blue: #1c3a55;
    --block-highlight-red: #4d2724;
    --block-highlight-gray: #3a4250;
    color-scheme: dark;
}

nav[aria-label="Breadcrumb"] {
    font-size: 1.05rem;
}

nav[aria-label="Breadcrumb"] ol {
    list-style: none;
    margin: 0;
    padding-left: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 0.5rem;
}

nav[aria-label="Breadcrumb"] ol > li {
    display: inline-flex;
    align-items: center;
    min-width: 0;
}

nav[aria-label="Breadcrumb"] ol > li + li::before {
    content: '›';
    margin-right: 0.5rem;
    color: var(--muted-fg, #64748b);
}

nav[aria-label="Breadcrumb"] ol > li:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (prefers-color-scheme: dark) {
    :root:not(.-no-dark-theme) {
        --border: #3a4453;
        --accent-bg: rgba(255, 255, 255, 0.08);
        --accent-contrast: var(--bg, #121210);
        --block-highlight-yellow: #4b3c14;
        --block-highlight-green: #1f4029;
        --block-highlight-blue: #1c3a55;
        --block-highlight-red: #4d2724;
        --block-highlight-gray: #3a4250;
        color-scheme: dark;
    }
}

/* Global transitions for a premium dark mode toggle feel */
body, main, header, nav, footer, table, tr, td, th, input, textarea, button, select, .help-card{
    transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease, box-shadow 0.25s ease;
}

/* Named action classes below cover the main screens. These fallback rules keep
   older and inline form actions in the same visual system rather than letting
   missing.css choose a different button treatment. */
button:not([class]),
a[role="button"]:not([class]) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    margin: 0;
    padding: 0.4rem 0.7rem;
    border: 1px solid var(--border, #cbd5e1);
    border-radius: 7px;
    background: var(--box-bg, #ffffff);
    color: var(--fg, inherit);
    font: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease, opacity 0.15s ease;
}

button:not([class]):hover,
a[role="button"]:not([class]):hover {
    border-color: var(--accent, #475569);
    background: var(--accent-bg, rgba(0, 0, 0, 0.03));
    color: var(--accent, #475569);
}

button:not([class]):focus-visible,
a[role="button"]:not([class]):focus-visible {
    border-color: var(--accent, #475569);
    outline: 2px solid color-mix(in srgb, var(--accent, #475569) 40%, transparent);
    outline-offset: 2px;
}

button:not([class]):disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

button.bad:not(.wyldcards-list-action-btn):not(.user-form-delete),
a.bad[role="button"]:not(.wyldcards-list-action-btn):not(.user-form-delete) {
    border-color: rgba(211, 47, 47, 0.35);
    background: rgba(211, 47, 47, 0.08);
    color: var(--bad-fg, #d32f2f);
    font-weight: 600;
}

button.bad:not(.wyldcards-list-action-btn):not(.user-form-delete):hover,
button.bad:not(.wyldcards-list-action-btn):not(.user-form-delete):focus-visible,
a.bad[role="button"]:not(.wyldcards-list-action-btn):not(.user-form-delete):hover,
a.bad[role="button"]:not(.wyldcards-list-action-btn):not(.user-form-delete):focus-visible {
    border-color: var(--bad-fg, #d32f2f);
    background: rgba(211, 47, 47, 0.14);
    color: var(--bad-fg, #d32f2f);
}

/* Header action buttons (help, settings, user) */
.header-actions {
    position: absolute;
    top: 0.35rem;
    right: 0.5rem;
    display: flex;
    align-items: center;
    z-index: 1001;
}

.header-actions-group {
    display: inline-flex;
    align-items: center;
    gap: 0.15rem;
    height: 2.25rem;
    padding: 0 0.2rem;
    box-sizing: border-box;
    background: var(--interactive-bg);
    border: 1px solid var(--muted-fg);
    border-radius: var(--border-radius);
}

.header-actions .help-dropdown,
.header-actions .settings-dropdown,
.header-actions .user-dropdown-container {
    position: relative;
}

/* User dropdown in header */
.user-dropdown-container {
    z-index: 1001;
}

.user-dropdown-container .user-toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    color: var(--fg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease, transform 0.2s ease, color 0.2s ease;
    width: 36px;
    height: 36px;
    font: inherit;
    text-decoration: none;
}

.user-dropdown-container .user-toggle-btn:hover,
.user-dropdown-container .user-toggle-btn:focus {
    background-color: var(--accent-bg);
    transform: scale(1.1);
    color: var(--accent);
    outline: none;
}

.user-dropdown-container .user-icon {
    flex-shrink: 0;
}

.user-dropdown-container .nav-dropdown-item.active,
.user-dropdown-container .theme-option.active,
html[data-theme-setting="light"] .user-dropdown-container .theme-option[data-theme="light"],
html[data-theme-setting="dark"] .user-dropdown-container .theme-option[data-theme="dark"],
html[data-theme-setting="system"] .user-dropdown-container .theme-option[data-theme="system"] {
    background-color: var(--accent-bg);
    color: var(--accent);
    font-weight: 600;
}

.user-menu-label {
    padding: 0.35rem 0.65rem 0.15rem;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted, #888);
    user-select: none;
}

.user-dropdown-container .theme-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
}

.user-dropdown-container .theme-option svg {
    flex-shrink: 0;
    margin-right: 0 !important;
}

.user-dropdown-container .theme-option::after {
    content: '';
    margin-left: auto;
    width: 1rem;
    text-align: center;
    flex-shrink: 0;
}

html[data-theme-setting="light"] .user-dropdown-container .theme-option[data-theme="light"]::after,
html[data-theme-setting="dark"] .user-dropdown-container .theme-option[data-theme="dark"]::after,
html[data-theme-setting="system"] .user-dropdown-container .theme-option[data-theme="system"]::after {
    content: '✓';
    color: var(--accent);
    font-weight: 700;
}

/* Help, settings, and user icon dropdowns */
.help-dropdown,
.settings-dropdown,
.user-dropdown-container {
    display: inline-flex;
    align-items: center;
}

.help-dropdown .help-toggle-btn{
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    color: var(--fg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease, transform 0.2s ease, color 0.2s ease;
    width: 36px;
    height: 36px;
    font: inherit;
    text-decoration: none;
}

.help-dropdown .help-toggle-btn:hover,
.help-dropdown .help-toggle-btn:focus{
    background-color: var(--accent-bg);
    transform: scale(1.1);
    color: var(--accent);
    outline: none;
}

.help-dropdown .help-icon{
    flex-shrink: 0;
}

.header-actions .help-toggle-label {
    display: none;
}

.help-dropdown .nav-dropdown-item.active {
    background-color: var(--accent-bg);
    color: var(--accent);
    font-weight: 600;
}

.help-dropdown .nav-dropdown-menu.help-dropdown-menu {
    min-width: 16.5rem;
    max-width: min(20rem, calc(100vw - 1.5rem));
}

.help-feature-search {
    padding: 0.2rem 0.2rem 0.15rem;
}

.help-feature-search-input {
    width: 100%;
    box-sizing: border-box;
    padding: 0.45rem 0.65rem;
    border: 1px solid var(--border, #e0e0e0);
    border-radius: 0.45rem;
    background: var(--bg, #ffffff);
    color: var(--fg, #333333);
    font: inherit;
    font-size: 0.875rem;
    line-height: 1.35;
}

.help-feature-search-input:focus {
    outline: none;
    border-color: var(--accent, #475569);
    box-shadow: 0 0 0 2px rgba(71, 85, 105, 0.15);
}

.help-feature-search-input::-webkit-search-cancel-button {
    -webkit-appearance: none;
    appearance: none;
}

.help-feature-search-results {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    max-height: 14rem;
    overflow-y: auto;
    margin-top: 0.35rem;
}

.help-feature-search-results .nav-dropdown-item {
    white-space: normal;
}

.help-feature-search-empty {
    margin: 0.45rem 0.65rem 0.15rem;
    font-size: 0.8rem;
    text-align: left;
}

.help-feature-search-no-match {
    margin-top: 0.2rem;
}

.help-feature-group-label {
    margin: 0.5rem 0.65rem 0.15rem;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted-fg, #6b7280);
}

.help-feature-search-results .help-feature-result {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.1rem;
    padding-top: 0.4rem;
    padding-bottom: 0.4rem;
}

.help-feature-result-title {
    font-weight: 600;
    font-size: 0.875rem;
    line-height: 1.3;
}

.help-feature-result-desc {
    font-size: 0.75rem;
    line-height: 1.3;
    color: var(--muted-fg, #6b7280);
}

.help-feature-result:hover .help-feature-result-desc,
.help-feature-result:focus-visible .help-feature-result-desc {
    color: inherit;
    opacity: 0.85;
}

.help-feature-match {
    padding: 0;
    background: transparent;
    color: var(--accent, inherit);
    font-weight: 700;
}

.help-feature-search-more {
    font-size: 0.8rem;
    white-space: normal;
}

.header-actions-group .help-toggle-btn,
.header-actions-group .user-toggle-btn {
    width: auto;
    height: auto;
    min-width: 2rem;
    min-height: 2rem;
    padding: 0.15em 0.35em;
    border-radius: calc(var(--border-radius) - 2px);
}

.header-actions-group .help-toggle-btn:hover,
.header-actions-group .help-toggle-btn:focus,
.header-actions-group .user-toggle-btn:hover,
.header-actions-group .user-toggle-btn:focus {
    transform: none;
    filter: brightness(1.1);
}

.header-actions-group .help-icon,
.header-actions-group .user-icon {
    width: 20px;
    height: 20px;
}


/* Spellcheck Icon States */
html[data-spellcheck="false"] .spellcheck-toggle-btn .spellcheck-slash {
    display: block;
}
html[data-spellcheck="false"] .spellcheck-toggle-btn .spellcheck-check {
    opacity: 0.3;
}
html[data-spellcheck="false"] .spellcheck-toggle-btn:not(.nav-dropdown-item) {
    opacity: 0.5;
}
html[data-spellcheck="true"] .spellcheck-toggle-btn .spellcheck-slash {
    display: none;
}
html[data-spellcheck="true"] .spellcheck-toggle-btn .spellcheck-check {
    stroke: var(--good-fg-color, #22c55e);
}

header {
    position: relative; /* Set relative positioning so absolute theme toggle aligns to it */
    border-bottom: none;
    padding: 0.4rem 1.5rem 0.4rem 0.5rem;
}

header nav {
    gap: 1.5rem;
    padding-right: 9rem; /* Leave room for header action buttons on the right */
    padding-left: 0;
}

/* The site header on every ordinary page. missing.css centres it on its ~40rem
   line length and leaves a ~45px margin under it, while `.header-actions` is
   pinned to the window edge a line higher than the brand — so the brand floated
   inward of wide pages, the account buttons sat apart from it, and each page
   put the brand somewhere different. Give the header one 1100px column (the
   home screen's), with the actions centred on the brand's line; the wider
   workspaces set --page-header-gutter to their own content edge. The card
   editor, the song/notes pages, sign-in and the landing page draw their own
   header, and the phone app shell collapses it. */
html:not(.app-shell) body:not(.has-toolbar-brand):not(.login-body):not(.landing-body):not(:has(main.text-documents-page)) > header.sidebar.menu {
    margin-bottom: 0;
    padding-inline: var(--page-header-gutter, max(1rem, calc((100% - 1100px) / 2 + 1rem)));
}
html:not(.app-shell) body:not(.has-toolbar-brand):not(.login-body):not(.landing-body):not(:has(main.text-documents-page)) > header.sidebar.menu .header-actions {
    top: calc(var(--rhythm, 1.4rem) - 0.5rem);
    right: var(--page-header-gutter, max(1rem, calc((100% - 1100px) / 2 + 1rem)));
}
body:has(main.wyldcards-storyboard-page, main.wyldcards-link-map-page) > header.sidebar.menu {
    --page-header-gutter: max(1.5rem, calc((100% - 76rem) / 2 + 1.5rem));
}
body:has(main.wyldcards-canvas-page) > header.sidebar.menu {
    --page-header-gutter: clamp(0.85rem, 2vw, 1.5rem);
}

main.home {
    text-align: center;
}

/* Landing page (signed out) */
body.landing-body {
    --landing-ink: #0c1222;
    --landing-glow: rgba(56, 120, 168, 0.22);
    background:
        radial-gradient(ellipse 70% 45% at 70% 18%, var(--landing-glow) 0%, transparent 68%),
        radial-gradient(ellipse 50% 40% at 12% 8%, rgba(15, 23, 42, 0.06) 0%, transparent 60%),
        linear-gradient(180deg, #f3f6fa 0%, var(--bg, #f8fafc) 42%, var(--bg, #f8fafc) 100%);
    overflow-x: hidden;
}

body.landing-body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    opacity: 0.35;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
    background-size: 180px 180px;
    /* missing.css sets `*, :before, :after { background-repeat: no-repeat }`, which
       left this 180px grain tile sitting alone in the top-left corner. */
    background-repeat: repeat;
    mix-blend-mode: multiply;
}

body.landing-body header,
body.landing-body main.landing-page {
    position: relative;
    z-index: 1;
}

body.landing-body header {
    background: transparent;
    border-bottom: none;
    /* The landing content follows the header and otherwise covers its menus. */
    z-index: 2;
}

body.landing-body main.landing-page {
    /* Override Missing.css main { max-inline-size: var(--eff-line-length) } */
    max-inline-size: none;
    inline-size: 100%;
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 0 0 1.5rem;
    text-align: left;
}

.landing-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
    gap: clamp(1.5rem, 4vw, 3.5rem);
    align-items: center;
    width: 100%;
    max-width: 82rem;
    margin: 0 auto;
    min-height: auto;
    padding: clamp(1rem, 2.5vh, 1.75rem) clamp(1rem, 3vw, 2.5rem) 1.5rem;
    box-sizing: border-box;
}

.landing-hero-copy {
    max-width: 34rem;
    min-width: 0;
    animation: landing-rise 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.landing-brand {
    margin: 0;
    font-family: Syne, "Avenir Next", "Segoe UI", sans-serif;
    /* Sized to fit the copy column at both ends: Syne 800 sets "Wyldcards" at
       roughly 7.7em wide, so anything larger than this is a word that cannot
       break pushing the hero off the right edge on a phone and breaking itself
       mid-word inside the 28rem column on a desktop. */
    font-size: clamp(2.1rem, 10.5vw, 3.5rem);
    font-weight: 800;
    line-height: 0.92;
    letter-spacing: -0.055em;
    color: var(--landing-ink);
}

.landing-title {
    margin: 1.15rem 0 0;
    font-family: Syne, "Avenir Next", "Segoe UI", sans-serif;
    font-size: clamp(1.15rem, 2.4vw, 1.45rem);
    font-weight: 600;
    line-height: 1.25;
    letter-spacing: -0.02em;
    color: var(--fg, #0f172a);
}

.landing-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1.1rem;
    margin-top: 1.85rem;
}

.landing-cta-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.82rem 1.4rem;
    border: 1px solid var(--landing-ink);
    border-radius: var(--border-radius);
    background: var(--landing-ink);
    color: #f8fafc;
    font-size: 0.95rem;
    font-weight: 600;
    text-decoration: none;
    transition: transform 0.15s ease, box-shadow 0.2s ease, gap 0.2s ease, background 0.2s ease;
}

.landing-cta-primary:hover,
.landing-cta-primary:focus-visible {
    background: #162033;
    box-shadow: 0 14px 32px -16px rgba(12, 18, 34, 0.65);
    gap: 0.7rem;
    color: #f8fafc;
    outline: none;
}

.landing-cta-primary:active {
    transform: translateY(1px);
}

.landing-cta-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.9rem;
    padding: 0.72rem 1.25rem;
    border: 1px solid color-mix(in srgb, var(--landing-ink) 32%, transparent);
    border-radius: var(--border-radius);
    background: color-mix(in srgb, var(--bg, #f8fafc) 65%, transparent);
    color: var(--landing-ink);
    font-size: 0.95rem;
    font-weight: 600;
    text-decoration: none;
    transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.landing-cta-secondary:hover,
.landing-cta-secondary:focus-visible {
    border-color: var(--landing-ink);
    background: color-mix(in srgb, var(--landing-ink) 7%, var(--bg, #f8fafc));
    box-shadow: 0 10px 24px -20px rgba(12, 18, 34, 0.75);
    outline: none;
}

.landing-features {
    width: min(100% - 2.5rem, 66rem);
    margin: 0 auto;
    padding: clamp(1.5rem, 4vh, 2.5rem) 0 0;
    animation: landing-rise 0.7s cubic-bezier(0.22, 1, 0.36, 1) 0.2s both;
}

.landing-features-heading {
    margin: 0;
    font-family: Syne, "Avenir Next", "Segoe UI", sans-serif;
    font-size: clamp(1.35rem, 3vw, 1.75rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--landing-ink);
}

.landing-feature-list {
    list-style: none;
    margin: 2rem 0 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0;
    border-top: 1px solid var(--border);
}

.landing-feature {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    padding: 1.35rem 1.25rem;
    border: none;
    border-right: 1px solid var(--border);
    background: transparent;
    box-shadow: none;
    transition: none;
}

.landing-feature:last-child {
    border-right: none;
    padding-right: 0;
}

.landing-feature:first-child {
    padding-left: 0;
}

.landing-feature:hover {
    border-color: var(--border);
    box-shadow: none;
}

.landing-feature-index {
    font-family: Syne, "Avenir Next", "Segoe UI", sans-serif;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: var(--muted-fg, #64748b);
}

.landing-feature-body h3 {
    margin: 0 0 0.4rem;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.015em;
    color: var(--fg, #0f172a);
}

.landing-feature-body p {
    margin: 0;
    font-size: 0.88rem;
    line-height: 1.55;
    color: var(--muted-fg, #64748b);
}

.landing-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    margin-top: auto;
    padding: 1.75rem 1.25rem 0;
    animation: landing-rise 0.7s cubic-bezier(0.22, 1, 0.36, 1) 0.28s both;
}

.landing-footer-link {
    font-size: 0.84rem;
    font-weight: 500;
    color: var(--muted-fg, #64748b);
    text-decoration: none;
    transition: color 0.2s ease;
}

.landing-footer-link:hover,
.landing-footer-link:focus-visible {
    color: var(--landing-ink);
    outline: none;
}

.landing-footer-sep {
    color: var(--border, #cbd5e1);
    user-select: none;
}

.landing-headline {
    margin: 0;
    font-family: Syne, "Avenir Next", "Segoe UI", sans-serif;
    font-size: clamp(1.75rem, 3.25vw, 2.75rem);
    font-weight: 800;
    letter-spacing: -0.055em;
    line-height: 1.06;
    color: var(--landing-ink);
}

.landing-headline > span {
    color: color-mix(in srgb, var(--landing-ink) 70%, #4689c0);
}

.landing-preview {
    position: relative;
    width: 100%;
    max-width: 32rem;
    justify-self: center;
    min-width: 0;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 1.25rem;
    background: color-mix(in srgb, var(--bg, #f8fafc) 90%, #8baac6);
    box-shadow: 0 30px 80px -35px rgba(12, 18, 34, 0.4);
    text-align: left;
}

.landing-preview-bar,
.landing-preview-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    font-size: 0.75rem;
}

.landing-preview-bar {
    padding: 0.25rem 0.25rem 1rem;
    color: var(--landing-ink);
    font-weight: 600;
}

.landing-preview-workspace {
    position: relative;
    display: grid;
    grid-template-columns: 3.9rem minmax(0, 1fr);
    overflow: hidden;
    border: 1px solid #d6e0e7;
    border-radius: 0.75rem;
    background: #edf3f7;
}

.landing-preview-rail {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    padding: 0.9rem 0.55rem;
    border-right: 1px solid #d6e0e7;
    background: #e4edf3;
}

.landing-preview-rail-label {
    margin-bottom: 0.15rem;
    color: #718195;
    font-size: 0.59rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.landing-preview-thumb,
.landing-preview-add {
    display: grid;
    place-items: center;
    width: 2.15rem;
    height: 1.7rem;
    border: 1px solid #cbd8e2;
    border-radius: 0.3rem;
    color: #718195;
    background: #f8fafc;
    font-size: 0.62rem;
    font-weight: 700;
}

.landing-preview-count {
    color: #718195;
    font-weight: 500;
}

/* The rail's cards and the demo's buttons are labels, and missing.css makes
   every label a padded block; these put them back to the shapes drawn. */
.landing-preview .landing-preview-thumb {
    display: grid;
    padding: 0;
    line-height: 1;
    margin: 0;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.landing-preview-thumb:hover {
    border-color: #729fc0;
    color: #235f88;
}

#landing-card-1:checked ~ .landing-preview-rail [for="landing-card-1"],
#landing-card-2:checked ~ .landing-preview-rail [for="landing-card-2"],
#landing-card-3:checked ~ .landing-preview-rail [for="landing-card-3"] {
    border-color: #729fc0;
    color: #235f88;
    background: #d9ebf6;
    box-shadow: 0 0 0 2px rgba(114, 159, 192, 0.18);
}

#landing-card-1:focus-visible ~ .landing-preview-rail [for="landing-card-1"],
#landing-card-2:focus-visible ~ .landing-preview-rail [for="landing-card-2"],
#landing-card-3:focus-visible ~ .landing-preview-rail [for="landing-card-3"] {
    outline: 2px solid #235f88;
    outline-offset: 2px;
}

.landing-preview-add {
    height: 1.25rem;
    border-style: dashed;
    background: transparent;
    font-size: 0.9rem;
    font-weight: 400;
}

/* Every card shares one grid cell, so the stack is as tall as its tallest
   card and switching never moves the page. */
.landing-preview-cards {
    display: grid;
    min-width: 0;
    background: #f8fafc;
}

.landing-preview-card {
    grid-area: 1 / 1;
    min-width: 0;
    padding: clamp(1.25rem, 3vw, 2rem);
    color: #1a2333;
    opacity: 0;
    visibility: hidden;
    transform: translateX(0.75rem);
    transition: opacity 0.25s ease, transform 0.3s cubic-bezier(0.22, 1, 0.36, 1), visibility 0s linear 0.3s;
}

#landing-card-1:checked ~ .landing-preview-cards .landing-preview-card--1,
#landing-card-2:checked ~ .landing-preview-cards .landing-preview-card--2,
#landing-card-3:checked ~ .landing-preview-cards .landing-preview-card--3 {
    opacity: 1;
    visibility: visible;
    transform: none;
    transition-delay: 0s;
}

.landing-preview-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.landing-preview-card-header > span {
    color: #8492a2;
    font-size: 0.65rem;
}

.landing-preview-meta {
    margin: 0;
    color: #52647a;
    line-height: 1.5;
}

.landing-preview-card h2 {
    margin: 1.75rem 0 0.65rem;
    font-family: Syne, "Avenir Next", "Segoe UI", sans-serif;
    font-size: clamp(1.4rem, 2.5vw, 2rem);
    line-height: 1.15;
    letter-spacing: -0.04em;
    color: #1a2333;
}

.landing-preview-card > p {
    margin: 0;
    color: #52647a;
    font-size: 0.85rem;
}

.landing-preview-field {
    margin: 1.5rem 0;
    padding: 1rem;
    border: 1px solid #d6e0e7;
    border-radius: 0.5rem;
    background: #fff;
}

.landing-preview-field > span {
    color: #52647a;
    font-size: 0.7rem;
    font-weight: 600;
}

.landing-preview-field p {
    margin: 0.5rem 0 0;
    font-size: 0.95rem;
    line-height: 1.7;
}

.landing-preview-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.landing-preview .landing-preview-button {
    display: inline-block;
    line-height: 1.2;
    margin: 0;
    padding: 0.4rem 0.65rem;
    border: 1px solid #cddbe5;
    border-radius: 0.3rem;
    color: #3e5c72;
    background: #f3f7fa;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.landing-preview .landing-preview-button:hover {
    border-color: #729fc0;
    background: #e6f0f7;
}

.landing-preview .landing-preview-button--primary {
    border-color: #1a2333;
    color: #f8fafc;
    background: #1a2333;
}

.landing-preview .landing-preview-button--primary:hover {
    border-color: #2b3a52;
    background: #2b3a52;
}

.landing-preview-card h2 small {
    color: #718195;
    font-size: 0.45em;
    letter-spacing: 0;
}

.landing-preview-checklist {
    margin: 1.25rem 0 1.5rem;
    padding: 0;
    list-style: none;
}

.landing-preview-checklist li {
    margin: 0;
    padding: 0;
    border-bottom: 1px solid #e2e9ef;
}

.landing-preview-checklist label {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin: 0;
    padding: 0.7rem 0.1rem;
    font-size: 0.92rem;
    font-weight: 500;
    color: #1a2333;
    cursor: pointer;
}

.landing-preview-checklist input {
    flex-shrink: 0;
    width: 1.05rem;
    height: 1.05rem;
    margin: 0;
    accent-color: #235f88;
}

.landing-preview-checklist label:has(input:checked) {
    color: #8492a2;
    text-decoration: line-through;
}

.landing-metronome {
    display: flex;
    gap: 0.6rem;
    margin: 1.25rem 0 1.5rem;
}

.landing-metronome span {
    flex: 1;
    height: 2.6rem;
    border: 1px solid #d6e0e7;
    border-radius: 0.5rem;
    background: #fff;
}

.landing-metronome span:first-child {
    border-color: #b9cddb;
}

/* 92 bpm: four beats to a 2.6s bar, each box lit for its own quarter. */
.landing-metronome-toggle:checked + .landing-metronome span {
    animation: landing-beat 2.608s steps(1) infinite;
}

.landing-metronome-toggle:checked + .landing-metronome span:nth-child(2) { animation-delay: 0.652s; }
.landing-metronome-toggle:checked + .landing-metronome span:nth-child(3) { animation-delay: 1.304s; }
.landing-metronome-toggle:checked + .landing-metronome span:nth-child(4) { animation-delay: 1.956s; }

.landing-metronome-stop,
.landing-metronome-toggle:checked ~ .landing-preview-card-actions .landing-metronome-start {
    display: none;
}

.landing-metronome-toggle:checked ~ .landing-preview-card-actions .landing-metronome-stop {
    display: inline;
}

.landing-metronome-toggle:focus-visible ~ .landing-preview-card-actions .landing-preview-button--primary {
    outline: 2px solid #235f88;
    outline-offset: 2px;
}

@keyframes landing-beat {
    0%, 24.9% {
        border-color: #235f88;
        background: #9cc6e2;
    }
    25%, 100% {
        border-color: #d6e0e7;
        background: #fff;
    }
}

.landing-preview-script {
    display: block;
    margin-top: 1rem;
    padding: 0.55rem 0.7rem;
    border-radius: 0.4rem;
    background: #1a2333;
    color: #d7e3ee;
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.74rem;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.landing-preview-script span {
    color: #8fc3e8;
}

/* Small drawings in the use-case and how-it-works tiles: they show what
   the headings name, so the page does not need paragraphs to say it. */
.landing-use-art {
    margin-top: 1.1rem;
    height: 4.5rem;
    border-radius: 0.5rem;
    overflow: hidden;
}

.landing-use-art--script {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.2rem;
    padding: 0.6rem 0.8rem;
    background: rgba(255, 255, 255, 0.72);
    color: #1a2333;
    font-family: "Courier New", Courier, monospace;
    font-size: 0.72rem;
    line-height: 1.3;
}

.landing-art-scene {
    font-weight: 700;
}

.landing-art-character,
.landing-art-line {
    align-self: center;
}

.landing-art-character {
    margin-top: 0.15rem;
    font-weight: 700;
    letter-spacing: 0.06em;
}

.landing-use-art--keys {
    position: relative;
    display: flex;
    background: #1a2333;
    padding: 0 1px 1px;
}

.landing-use-art--keys span {
    flex: 1;
    margin-right: 1px;
    border-radius: 0 0 0.2rem 0.2rem;
    background: #fbfbf8;
}

.landing-use-art--keys span:last-child {
    margin-right: 0;
}

/* Black keys sit over the gap between two white ones. */
.landing-use-art--keys span.is-black {
    flex: 0 0 auto;
    position: relative;
    z-index: 1;
    width: 5%;
    height: 60%;
    margin: 0 -2.5%;
    background: #1a2333;
}

.landing-use-art--list {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.45rem;
    padding: 0 0.8rem;
    background: rgba(255, 255, 255, 0.72);
}

.landing-use-art--list span {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.landing-use-art--list span::before {
    content: "";
    flex-shrink: 0;
    width: 0.8rem;
    height: 0.8rem;
    border: 1.5px solid #8a7462;
    border-radius: 0.2rem;
}

.landing-use-art--list span::after {
    content: "";
    height: 0.4rem;
    width: 70%;
    border-radius: 999px;
    background: #d9c8ba;
}

.landing-use-art--list span:nth-child(2)::after { width: 52%; }
.landing-use-art--list span:nth-child(3)::after { width: 62%; }

.landing-use-art--list span.is-done::before {
    border-color: #8a7462;
    background:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 6.2 5 8.5l4.5-5' fill='none' stroke='%23fff' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 100% no-repeat,
        #8a7462;
}

.landing-use-art--list span.is-done::after {
    opacity: 0.55;
}

.landing-step-art {
    margin-top: 0.9rem;
}

.landing-step-art--stack {
    position: relative;
    width: 5.5rem;
    height: 3.6rem;
}

.landing-step-art--stack span {
    position: absolute;
    inset: 0 auto auto 0;
    width: 4.6rem;
    height: 3.1rem;
    border: 1px solid var(--border, #cbd5e1);
    border-radius: 0.35rem;
    background: var(--bg, #f8fafc);
    box-shadow: 0 6px 14px -10px rgba(12, 18, 34, 0.45);
}

.landing-step-art--stack span:nth-child(1) { transform: translate(0.9rem, 0.5rem) rotate(6deg); }
.landing-step-art--stack span:nth-child(2) { transform: translate(0.45rem, 0.25rem) rotate(3deg); }

.landing-step-art--parts {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    height: 3.6rem;
}

.landing-step-field,
.landing-step-button {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--muted-fg, #64748b);
}

.landing-step-field {
    flex: 0 0 6rem;
    padding: 0.45rem 0.6rem;
    border: 1px dashed color-mix(in srgb, var(--muted-fg, #64748b) 55%, transparent);
    border-radius: 0.35rem;
}

.landing-step-button {
    padding: 0.45rem 0.7rem;
    border: 1px solid var(--border, #cbd5e1);
    border-radius: 999px;
    background: var(--bg, #f8fafc);
}

.landing-feature .landing-preview-script {
    display: inline-block;
    max-width: 100%;
    box-sizing: border-box;
}

.landing-possibilities,
.landing-invitation {
    width: min(100% - 2.5rem, 66rem);
    margin: 1.75rem auto 0;
}

.landing-possibilities {
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.landing-use-cases {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
    margin-top: 1.75rem;
}

.landing-use-cases article {
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 0.85rem;
    background: color-mix(in srgb, var(--bg, #f8fafc) 85%, #99b9cf);
}

.landing-use-cases article:nth-child(2) {
    background: color-mix(in srgb, var(--bg, #f8fafc) 85%, #b3b89b);
}

.landing-use-cases article:nth-child(3) {
    background: color-mix(in srgb, var(--bg, #f8fafc) 85%, #cfb09b);
}

.landing-use-icon {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted-fg, #64748b);
}

.landing-use-cases h3 {
    margin: 1.5rem 0 0.5rem;
    font-size: 1.15rem;
    color: var(--landing-ink);
}

.landing-use-cases p,
.landing-invitation p {
    margin: 0;
    color: var(--muted-fg, #64748b);
    font-size: 0.9rem;
    line-height: 1.65;
}

.landing-invitation {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
    padding: 1.5rem;
    border: 1px solid var(--border);
    border-radius: 1rem;
}

.landing-invitation p {
    max-width: 34rem;
    margin-top: 0.75rem;
}

.landing-invitation .landing-cta-primary {
    flex-shrink: 0;
}

.landing-page a:focus-visible {
    outline: 2px solid var(--landing-ink);
    outline-offset: 4px;
}

@media (max-width: 600px) {
    .landing-use-cases {
        grid-template-columns: minmax(0, 1fr);
    }

    .landing-use-cases h3 {
        margin-top: 0.75rem;
    }

    .landing-invitation {
        flex-direction: column;
        align-items: stretch;
        padding: 1rem;
    }
}

@keyframes landing-rise {
    from {
        opacity: 0;
        transform: translateY(18px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

:root.-dark-theme body.landing-body {
    --landing-ink: #f1f5f9;
    --landing-glow: rgba(96, 165, 250, 0.16);
    background:
        radial-gradient(ellipse 70% 45% at 72% 16%, var(--landing-glow) 0%, transparent 68%),
        radial-gradient(ellipse 45% 35% at 8% 10%, rgba(255, 255, 255, 0.04) 0%, transparent 55%),
        linear-gradient(180deg, #0b1220 0%, var(--bg, #0f172a) 48%, var(--bg, #0f172a) 100%);
}

:root.-dark-theme body.landing-body::before {
    opacity: 0.18;
    mix-blend-mode: soft-light;
}

/* The drawings are paper, like the preview's cards; a translucent white
   over the dark tiles only turns them grey. */
:root.-dark-theme .landing-use-art--script,
:root.-dark-theme .landing-use-art--list {
    background: #eef2f7;
}

:root.-dark-theme .landing-cta-primary {
    background: #e2e8f0;
    border-color: #e2e8f0;
    color: #0c1222;
}

:root.-dark-theme .landing-cta-primary:hover,
:root.-dark-theme .landing-cta-primary:focus-visible {
    background: #f8fafc;
    color: #0c1222;
    box-shadow: 0 14px 32px -16px rgba(226, 232, 240, 0.45);
}

:root.-dark-theme .landing-cta-secondary:hover,
:root.-dark-theme .landing-cta-secondary:focus-visible,
:root.-dark-theme .landing-footer-link:hover,
:root.-dark-theme .landing-footer-link:focus-visible {
    color: #e2e8f0;
}

@media (prefers-color-scheme: dark) {
    :root:not(.-no-dark-theme) body.landing-body {
        --landing-ink: #f1f5f9;
                --landing-glow: rgba(96, 165, 250, 0.16);
        background:
            radial-gradient(ellipse 70% 45% at 72% 16%, var(--landing-glow) 0%, transparent 68%),
            radial-gradient(ellipse 45% 35% at 8% 10%, rgba(255, 255, 255, 0.04) 0%, transparent 55%),
            linear-gradient(180deg, #0b1220 0%, var(--bg, #0f172a) 48%, var(--bg, #0f172a) 100%);
    }

    :root:not(.-no-dark-theme) body.landing-body::before {
        opacity: 0.18;
        mix-blend-mode: soft-light;
    }

    :root:not(.-no-dark-theme) .landing-use-art--script,
    :root:not(.-no-dark-theme) .landing-use-art--list {
        background: #eef2f7;
    }

    :root:not(.-no-dark-theme) .landing-cta-primary {
        background: #e2e8f0;
        border-color: #e2e8f0;
        color: #0c1222;
    }

    :root:not(.-no-dark-theme) .landing-cta-primary:hover,
    :root:not(.-no-dark-theme) .landing-cta-primary:focus-visible {
        background: #f8fafc;
        color: #0c1222;
        box-shadow: 0 14px 32px -16px rgba(226, 232, 240, 0.45);
    }

    :root:not(.-no-dark-theme) .landing-cta-secondary:hover,
    :root:not(.-no-dark-theme) .landing-cta-secondary:focus-visible,
    :root:not(.-no-dark-theme) .landing-footer-link:hover,
    :root:not(.-no-dark-theme) .landing-footer-link:focus-visible {
        color: #e2e8f0;
    }
}

@media (max-width: 900px) {
    .landing-hero {
        grid-template-columns: minmax(0, 1fr);
        min-height: auto;
        gap: 1.5rem;
        padding-top: 1rem;
        text-align: center;
    }

    .landing-hero-copy {
        max-width: 34rem;
        margin: 0 auto;
    }

        .landing-actions {
        justify-content: center;
    }

                        .landing-features {
        text-align: center;
    }

        .landing-feature-list {
        grid-template-columns: 1fr;
        text-align: left;
    }

    .landing-feature {
        flex-direction: row;
        align-items: flex-start;
        gap: 1rem;
        padding: 1.2rem 0;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .landing-feature:last-child {
        border-bottom: none;
    }
}

@media (max-width: 480px) {
    .landing-actions {
        flex-direction: column;
        width: 100%;
    }

    .landing-cta-primary,
    .landing-cta-secondary {
        width: 100%;
    }

        .landing-preview-workspace {
        grid-template-columns: 3.25rem minmax(0, 1fr);
    }

    .landing-preview-rail {
        padding-inline: 0.35rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .landing-hero-copy,
    .landing-features,
    .landing-footer {
        animation: none !important;
        opacity: 1 !important;
        transform: none !important;
    }

    .landing-preview-card {
        transform: none;
        transition: none;
    }

    /* A still bar with the downbeat marked, rather than a flashing one. */
    .landing-metronome-toggle:checked + .landing-metronome span {
        animation: none;
    }

    .landing-metronome-toggle:checked + .landing-metronome span:first-child {
        border-color: #235f88;
        background: #9cc6e2;
    }
}

/* Sign-in / recovery pages */
body.login-body {
    --login-ink: #0c1222;
    --login-paper: #eef2f7;
    --login-glow: rgba(56, 120, 168, 0.26);
    --login-glow-2: rgba(99, 102, 241, 0.14);
    --login-focus: var(--accent, #2563eb);
    --login-surface: rgba(255, 255, 255, 0.78);
    --login-surface-border: rgba(15, 23, 42, 0.08);
    background:
        radial-gradient(ellipse 55% 50% at 50% 32%, var(--login-glow) 0%, transparent 70%),
        radial-gradient(ellipse 45% 40% at 85% 90%, var(--login-glow-2) 0%, transparent 70%),
        radial-gradient(ellipse 40% 35% at 8% 85%, rgba(20, 184, 166, 0.08) 0%, transparent 70%),
        linear-gradient(180deg, #eef3f9 0%, var(--bg, #f8fafc) 55%, var(--bg, #f8fafc) 100%);
    overflow-x: hidden;
}

/* The illustrated stage that once filled the second column is gone, and the
   empty column left the form pinned to the left edge. Centre the one panel and
   give it a surface of its own, so the fields sit on something rather than
   straight on the grain. */
body.login-body .login-shell:not(:has(.login-stage)) {
    grid-template-columns: minmax(0, 26rem);
    justify-content: center;
}

body.login-body .login-panel {
    width: 100%;
    box-sizing: border-box;
    padding: 2rem 1.75rem 1.5rem;
    border: 1px solid var(--login-surface-border);
    border-radius: 18px;
    background: var(--login-surface);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    box-shadow:
        0 1px 2px rgba(15, 23, 42, 0.04),
        0 30px 60px -32px rgba(15, 23, 42, 0.35);
}

/* The wordmark doesn't wrap, and at the stage-less layout's full 2.75rem it ran
   past the card's padding. */
body.login-body .login-panel .login-brand {
    font-size: clamp(2rem, 8.5vw, 2.4rem);
}

/* missing.css pads and spaces every <header> and <footer>; inside the card
   that put a blank band above the wordmark, indented it off the fields' edge,
   and left one below the footer links. The padding needs !important to beat
   the phone layout's `header { padding: … !important }`, meant for the nav. */
body.login-body .login-panel .login-header {
    margin-top: 0;
    padding: 0 !important;
}

body.login-body .login-panel .login-footer {
    margin-bottom: 0;
}

@media (max-width: 480px) {
    body.login-body .login-panel {
        padding: 1.5rem 1.25rem 1.25rem;
    }
}

body.login-body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    opacity: 0.35;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
    background-size: 180px 180px;
    /* missing.css sets `*, :before, :after { background-repeat: no-repeat }`, which
       left this 180px grain tile sitting alone in the top-left corner. */
    background-repeat: repeat;
    mix-blend-mode: multiply;
}

body.login-body > header.sidebar.menu,
body.login-body main.login-page {
    position: relative;
    z-index: 1;
}

/* The nav is chrome floating over the page, not a band above it. Left in flow
   its ~7rem stacked on top of main's `min-height: 100vh` and put a scrollbar on
   a screen holding one short form; main's padding-top already reserves the
   space it needs. Scoped to the direct child: the panel has a <header> of its
   own, and it is not this one. */
body.login-body > header.sidebar.menu {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background: transparent;
    border-bottom: none;
}

body.login-body main.login-page {
    /* Override Missing.css main { max-inline-size: var(--eff-line-length) } */
    max-inline-size: none;
    inline-size: 100%;
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5.5rem clamp(1.25rem, 5vw, 4rem) 2.5rem;
    text-align: left;
}

.login-shell {
    display: grid;
    grid-template-columns: minmax(0, 24rem) minmax(0, 1fr);
    gap: clamp(2rem, 5vw, 4.5rem);
    align-items: center;
    width: min(100%, 58rem);
}

.login-panel,
.login-card {
    width: min(100%, 24rem);
    animation: login-enter 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.login-card {
    padding: 2rem 1.75rem 1.5rem;
    border: 1px solid var(--border);
    border-radius: calc(var(--border-radius) + 6px);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.55) 0%, transparent 38%),
        var(--box-bg, var(--bg, #fff));
    box-shadow:
        0 1px 2px rgba(15, 23, 42, 0.05),
        0 24px 48px -28px rgba(15, 23, 42, 0.4);
}

@keyframes login-enter {
    from {
        opacity: 0;
        transform: translateY(14px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-header {
    margin-bottom: 1.65rem;
}

.login-panel .login-header {
    text-align: left;
}

.login-card .login-header {
    text-align: center;
}

.login-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3.25rem;
    height: 3.25rem;
    margin-bottom: 0.85rem;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--accent-bg);
    color: var(--login-ink, #0c1222);
}

.login-eyebrow {
    margin: 0 0 0.35rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--login-ink, #0c1222);
}

.login-brand {
    margin: 0;
    font-family: Syne, "Avenir Next", "Segoe UI", sans-serif;
    font-size: clamp(2.25rem, 5vw, 2.75rem);
    font-weight: 800;
    line-height: 0.95;
    letter-spacing: -0.055em;
    color: var(--login-ink, #0c1222);
    /* The wordmark is one word. Left to wrap it broke as "Songb / ook", and
       missing.css's `overflow-wrap: break-word` is what let it. */
    white-space: nowrap;
    overflow-wrap: normal;
}

.login-title {
    margin: 0;
    font-size: clamp(1.55rem, 4vw, 1.85rem);
    line-height: 1.2;
    letter-spacing: -0.02em;
    color: var(--fg, #0f172a);
}

.login-panel .login-title {
    margin-top: 1rem;
    font-family: Syne, "Avenir Next", "Segoe UI", sans-serif;
    font-size: clamp(1.1rem, 2.4vw, 1.3rem);
    font-weight: 600;
    letter-spacing: -0.02em;
}

.login-subtitle {
    margin: 0.55rem 0 0;
    max-width: 20rem;
    color: var(--muted-fg, #64748b);
    font-size: 0.95rem;
    line-height: 1.55;
}

.login-card .login-subtitle {
    margin-left: auto;
    margin-right: auto;
    max-width: 18rem;
    font-size: 0.9rem;
}

.login-error {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    margin-bottom: 1.25rem;
    padding: 0.85rem 0.95rem;
    border: 1px solid rgba(220, 38, 38, 0.25);
    border-radius: var(--border-radius);
    background: rgba(220, 38, 38, 0.08);
    color: #b91c1c;
    font-size: 0.9rem;
    line-height: 1.45;
}

.login-error svg {
    flex-shrink: 0;
    margin-top: 0.1rem;
}

.login-success {
    margin-bottom: 1.25rem;
    padding: 0.85rem 0.95rem;
    border: 1px solid rgba(22, 101, 52, 0.25);
    border-radius: var(--border-radius);
    background: rgba(22, 101, 52, 0.08);
    color: #166534;
    font-size: 0.9rem;
    line-height: 1.45;
}

:root.-dark-theme .login-error {
    color: #fca5a5;
    border-color: rgba(248, 113, 113, 0.35);
    background: rgba(127, 29, 29, 0.35);
}

:root.-dark-theme .login-success {
    color: #86efac;
    border-color: rgba(134, 239, 172, 0.35);
    background: rgba(22, 101, 52, 0.35);
}

@media (prefers-color-scheme: dark) {
    :root:not(.-no-dark-theme) .login-error {
        color: #fca5a5;
        border-color: rgba(248, 113, 113, 0.35);
        background: rgba(127, 29, 29, 0.35);
    }

    :root:not(.-no-dark-theme) .login-success {
        color: #86efac;
        border-color: rgba(134, 239, 172, 0.35);
        background: rgba(22, 101, 52, 0.35);
    }
}

.login-form {
    display: grid;
    gap: 0.95rem;
}

.login-field {
    display: grid;
    gap: 0.35rem;
}

.login-label {
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--fg);
}

.login-label-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    width: 100%;
}

.login-forgot {
    font-size: 0.8rem;
    font-weight: 400;
    color: var(--muted-fg, #64748b);
    text-decoration: none;
    transition: color 0.2s ease;
}

.login-forgot:hover,
.login-forgot:focus-visible {
    color: var(--login-focus, var(--login-ink, #0c1222));
    text-decoration: underline;
}

.login-input-wrap {
    position: relative;
    display: block;
}

.login-field-icon {
    position: absolute;
    top: 50%;
    left: 1rem;
    transform: translateY(-50%);
    width: 1.25rem;
    height: 1.25rem;
    color: var(--muted-fg, #94a3b8);
    pointer-events: none;
    transition: color 0.2s ease;
}

.login-field input {
    width: 100%;
    box-sizing: border-box;
    min-height: 3.25rem;
    padding: 0.9rem 1.15rem;
    border: 1px solid var(--border, #cbd5e1);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.72);
    color: var(--fg, #0f172a);
    font: inherit;
    font-size: 1.1rem;
    line-height: 1.4;
    text-align: left;
    -webkit-appearance: none;
    appearance: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.login-input-wrap:has(.login-field-icon) input {
    padding-left: 3rem;
}

.login-card .login-field input {
    background: var(--bg, #fff);
}

.login-field input::placeholder {
    color: var(--muted-fg, #94a3b8);
    /* missing.css sets `::placeholder { text-align: end }`, which parked the hint
       against the right edge, a full field away from the icon it belongs to. */
    text-align: left;
}

.login-field input:focus,
.login-field input:focus-visible {
    outline: 2px solid var(--login-focus, var(--login-ink, #0c1222));
    outline-offset: 1px;
    border-color: var(--login-focus, var(--login-ink, #0c1222));
    background: #fff;
    box-shadow: 0 0 0 5px color-mix(in srgb, var(--login-focus, #0c1222) 14%, transparent);
}

.login-input-wrap:focus-within .login-field-icon {
    color: var(--login-focus, var(--login-ink, #0c1222));
}

.login-input-wrap:has(.login-reveal) input {
    padding-right: 3rem;
}

.login-reveal {
    position: absolute;
    top: 50%;
    right: 0.4rem;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    /* missing.css gives every button a drop shadow; here it drew a raised box
       around a mark that is meant to sit flat inside the field. */
    box-shadow: none;
    color: var(--muted-fg, #94a3b8);
    cursor: pointer;
    transition: color 0.2s ease, background-color 0.2s ease;
}

.login-reveal:hover {
    color: var(--login-ink, #0c1222);
    background: var(--accent-bg, rgba(15, 23, 42, 0.06));
}

.login-reveal:focus-visible {
    outline: 2px solid var(--login-ink, #0c1222);
    outline-offset: 1px;
    color: var(--login-ink, #0c1222);
}

/* One icon or the other, never both — the button swaps which is hidden. */
.login-reveal .login-reveal-off { display: none; }
.login-reveal[aria-pressed="true"] .login-reveal-on { display: none; }
.login-reveal[aria-pressed="true"] .login-reveal-off { display: block; }

.login-submit {
    width: 100%;
    margin-top: 0.35rem;
}

.login-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1.5rem;
    padding-top: 1.2rem;
    border-top: 1px solid rgba(15, 23, 42, 0.1);
}

.login-footer-link {
    font-size: 0.84rem;
    font-weight: 500;
    color: var(--muted-fg, #64748b);
    text-decoration: none;
    transition: color 0.2s ease;
}

.login-footer-link:hover,
.login-footer-link:focus-visible {
    color: var(--login-focus, var(--login-ink, #0c1222));
    outline: none;
}

.login-stage {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 22rem;
    animation: login-enter 0.7s cubic-bezier(0.22, 1, 0.36, 1) 0.1s both;
}

.login-stage-glow {
    position: absolute;
    inset: 8% 5% 12% 8%;
    background:
        radial-gradient(ellipse 70% 60% at 55% 45%, rgba(56, 120, 168, 0.34) 0%, transparent 68%),
        linear-gradient(105deg, transparent 0%, rgba(12, 18, 34, 0.05) 55%, rgba(12, 18, 34, 0.12) 100%);
    filter: blur(2px);
    animation: login-glow 7s ease-in-out infinite alternate;
}

.login-song-page {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    width: min(100%, 20rem);
    aspect-ratio: 8.5 / 11;
    padding: 1.75rem 1.6rem;
    border-radius: 2px;
    background: var(--login-paper);
    /* A lyric sheet is monospaced for the same reason the app's is: a chord only
       sits over the syllable it is played on if every character is one width. */
    font-family: "Courier New", Courier, monospace;
    color: #1a2333;
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.65) inset,
        0 28px 60px -28px rgba(12, 18, 34, 0.5),
        0 8px 20px -12px rgba(12, 18, 34, 0.3);
    transform: perspective(1200px) rotateY(-8deg) rotateX(3deg) rotateZ(-1deg);
}

.login-song-page::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
    background: linear-gradient(180deg, #3878a8 0%, #1f4f74 100%);
    opacity: 0.85;
}

.login-song-title,
.login-song-meta,
.login-song-section,
.login-song-chords,
.login-song-lyric {
    margin: 0;
    font-size: 0.78rem;
    line-height: 1.45;
}

.login-song-title {
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.login-song-meta {
    margin-bottom: 0.5rem;
    padding-bottom: 0.6rem;
    border-bottom: 1px solid currentColor;
    opacity: 0.55;
    font-size: 0.7rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.login-song-section {
    margin-top: 0.35rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    opacity: 0.75;
}

/* Chords ride above the lyric line, tight to it, so the pair reads as one row. */
.login-song-chords {
    color: #1f4f74;
    font-weight: 700;
    letter-spacing: 0.02em;
    white-space: pre;
}

.login-song-chords + .login-song-lyric {
    margin-top: -0.35rem;
}

.login-song-lyric {
    white-space: pre;
    opacity: 0.88;
}

.login-song-caret {
    display: inline-block;
    width: 0.5rem;
    height: 1em;
    margin-bottom: -0.15rem;
    background: #1a2333;
    animation: login-caret 1.05s steps(1) infinite;
}

@keyframes login-glow {
    from { opacity: 0.75; transform: scale(1); }
    to { opacity: 1; transform: scale(1.04); }
}

@keyframes login-caret {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0; }
}

:root.-dark-theme body.login-body {
    --login-ink: #e8eef8;
    --login-paper: #1a2333;
    --login-glow: rgba(66, 140, 210, 0.30);
    --login-glow-2: rgba(129, 140, 248, 0.16);
    --login-surface: rgba(20, 28, 44, 0.72);
    --login-surface-border: rgba(255, 255, 255, 0.09);
    background:
        radial-gradient(ellipse 55% 50% at 50% 30%, var(--login-glow) 0%, transparent 70%),
        radial-gradient(ellipse 45% 40% at 88% 92%, var(--login-glow-2) 0%, transparent 70%),
        radial-gradient(ellipse 40% 35% at 6% 88%, rgba(45, 212, 191, 0.07) 0%, transparent 70%),
        linear-gradient(180deg, #0a101c 0%, var(--bg, #0f172a) 50%, var(--bg, #0f172a) 100%);
}

:root.-dark-theme body.login-body::before {
    opacity: 0.18;
    mix-blend-mode: soft-light;
}

:root.-dark-theme .login-field input {
    background: rgba(15, 23, 42, 0.55);
}

:root.-dark-theme .login-field input:focus,
:root.-dark-theme .login-field input:focus-visible {
    background: rgba(15, 23, 42, 0.85);
}

:root.-dark-theme .login-song-page {
    color: #d7dee9;
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.06) inset,
        0 28px 60px -28px rgba(0, 0, 0, 0.7),
        0 8px 20px -12px rgba(0, 0, 0, 0.45);
}

:root.-dark-theme .login-song-caret {
    background: #d7dee9;
}

:root.-dark-theme .login-song-chords {
    color: #7fb2dc;
}

:root.-dark-theme .login-footer {
    border-top-color: rgba(255, 255, 255, 0.12);
}

@media (prefers-color-scheme: dark) {
    :root:not(.-no-dark-theme) body.login-body {
        --login-ink: #e8eef8;
        --login-paper: #1a2333;
        --login-glow: rgba(66, 140, 210, 0.30);
        --login-glow-2: rgba(129, 140, 248, 0.16);
        --login-surface: rgba(20, 28, 44, 0.72);
        --login-surface-border: rgba(255, 255, 255, 0.09);
        background:
            radial-gradient(ellipse 55% 50% at 50% 30%, var(--login-glow) 0%, transparent 70%),
            radial-gradient(ellipse 45% 40% at 88% 92%, var(--login-glow-2) 0%, transparent 70%),
            radial-gradient(ellipse 40% 35% at 6% 88%, rgba(45, 212, 191, 0.07) 0%, transparent 70%),
            linear-gradient(180deg, #0a101c 0%, var(--bg, #0f172a) 50%, var(--bg, #0f172a) 100%);
    }

    :root:not(.-no-dark-theme) body.login-body::before {
        opacity: 0.18;
        mix-blend-mode: soft-light;
    }

    :root:not(.-no-dark-theme) .login-field input {
        background: rgba(15, 23, 42, 0.55);
    }

    :root:not(.-no-dark-theme) .login-field input:focus,
    :root:not(.-no-dark-theme) .login-field input:focus-visible {
        background: rgba(15, 23, 42, 0.85);
    }

    :root:not(.-no-dark-theme) .login-song-page {
        color: #d7dee9;
        box-shadow:
            0 1px 0 rgba(255, 255, 255, 0.06) inset,
            0 28px 60px -28px rgba(0, 0, 0, 0.7),
            0 8px 20px -12px rgba(0, 0, 0, 0.45);
    }

    :root:not(.-no-dark-theme) .login-song-caret {
        background: #d7dee9;
    }

    :root:not(.-no-dark-theme) .login-song-chords {
        color: #7fb2dc;
    }

    :root:not(.-no-dark-theme) .login-footer {
        border-top-color: rgba(255, 255, 255, 0.12);
    }
}

@media (max-width: 860px) {
    .login-shell {
        grid-template-columns: 1fr;
        max-width: 24rem;
    }

    .login-stage {
        display: none;
    }
}

@media (max-width: 768px) {
    body.login-body main.login-page {
        padding: 4.75rem 1rem 2rem;
        align-items: flex-start;
    }

    .login-card {
        padding: 1.5rem 1.25rem 1.25rem;
    }

    .login-footer {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.55rem;
    }

    .login-card .login-footer {
        align-items: center;
    }
}

@media (prefers-reduced-motion: reduce) {
    .login-panel,
    .login-card,
    .login-stage,
    .login-stage-glow,
    .login-song-caret {
        animation: none !important;
    }
}

.nowrap {
    white-space: nowrap;
}

#table-actors a,
#table-characters a,
#table-wyldcards .wyldcards-list-title,
#table-scenes a,
#table-blocks a.character-name,
.table-blocks-all a.character-name {
    color: inherit;
    text-decoration: none;
}

#table-wyldcards .wyldcards-list-title {
    color: var(--fg, inherit);
}

#table-wyldcards .wyldcards-list-delete-btn {
    opacity: 1;
    flex-shrink: 0;
}

#table-actors td,
#table-characters td,
#table-wyldcards td,
#table-scenes td,
#table-blocks td,
.table-blocks-all td {
    border-top: none;
}

#table-scenes td:first-child {
    width: auto;
}

#table-blocks .block-content,
.table-blocks-all .block-content {
    width: min(var(--screenplay-action-width, 6in), 100%);
    max-width: min(var(--screenplay-action-width, 6in), 100%);
}

#table-blocks .block-content,
.table-blocks-all .block-content {
    cursor: pointer;
}

#table-blocks .block-left-controls,
.table-blocks-all .block-left-controls {
    vertical-align: middle;
    white-space: nowrap !important;
    padding-right: 0.5rem;
}

.block-left-controls-inner {
    display: inline-grid;
    grid-template-columns: var(--block-select-col-checkbox) var(--block-select-col-plus) var(--block-select-col-drag);
    align-items: center;
    gap: var(--block-select-col-gap);
    vertical-align: middle;
    width: calc(var(--block-select-col-checkbox) + var(--block-select-col-plus) + var(--block-select-col-drag) + 2 * var(--block-select-col-gap));
    max-width: 100%;
}

.wyldcards-script-select-row,
.wyldcards-script{
    --block-select-col-checkbox: 1.1rem;
    --block-select-col-plus: 1.5rem;
    --block-select-col-drag: 1.15rem;
    --block-select-col-gap: 8px;
    --block-text-line-box: calc(12pt * 1.5 * var(--wyldcards-text-scale, 1));
}

.wyldcards-toolbar-row {
    display: grid;
    grid-template-columns: 1fr min(var(--screenplay-action-width, 6in), 100%) 1fr;
    column-gap: var(--screenplay-chrome-gap, 1rem);
    width: 100%;
    max-width: 100%;
    align-items: start;
}

.wyldcards-toolbar-left.block-left-controls {
    display: block;
}

.wyldcards-toolbar-left {
    grid-column: 1;
    justify-self: end;
}

.wyldcards-toolbar-select-row {
    margin-top: 0;
}

.wyldcards-toolbar-main {
    grid-column: 2;
}

.wyldcards-toolbar-right {
    grid-column: 3;
    min-width: 0;
    display: flex;
    flex-wrap: wrap;
    row-gap: 0.25rem;
    align-items: center;
    justify-content: flex-end;
}

.wyldcards-script-stats {
    font-size: 0.8rem;
    color: var(--muted-fg, #64748b);
    white-space: nowrap;
    line-height: 1.3;
    text-align: right;
    padding: 0 0.15rem;
}

.wyldcards-script-stats-sep {
    margin: 0 0.2rem;
    opacity: 0.7;
}

.wyldcards-script-stats--top-bar {
    margin-left: auto;
    align-self: center;
}

html.wyldcards-word-count-hidden .wyldcards-script-stats {
    display: none;
}

.block-select-all-slot {
    display: block;
    width: 100%;
    min-height: 1px;
}

.block-select-all-label {
    display: contents;
    cursor: pointer;
    user-select: none;
}

.block-select-all-control {
    display: contents;
}

.block-select-menu-dropdown {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: var(--block-select-col-plus, 1.5rem);
}

button.block-select-menu-toggle.nav-dropdown-toggle {
    box-sizing: border-box;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    min-width: 1.5rem;
    min-height: 1.5rem;
    padding: 0 !important;
    margin: 0;
    font: inherit;
    font-weight: 600;
    line-height: 1;
    gap: 0;
    border-radius: 999px;
    border: 1px solid var(--border, #cbd5e1);
    background: var(--accent-bg, rgba(0, 0, 0, 0.05));
    color: var(--accent, #475569);
    opacity: 0.55;
    cursor: pointer;
    flex-shrink: 0;
    transition: opacity 0.15s ease, background-color 0.15s ease, border-color 0.15s ease, transform 0.12s ease, box-shadow 0.12s ease;
}

.block-select-menu-icon {
    display: block;
    transition: transform 0.16s cubic-bezier(0.16, 1, 0.3, 1);
}

.wyldcards-script-select-row:hover button.block-select-menu-toggle.nav-dropdown-toggle,
button.block-select-menu-toggle.nav-dropdown-toggle:hover,
button.block-select-menu-toggle.nav-dropdown-toggle:focus-visible,
.block-select-menu-dropdown.open button.block-select-menu-toggle.nav-dropdown-toggle {
    opacity: 1;
    border-color: var(--accent, #475569);
    outline: none;
}

button.block-select-menu-toggle.nav-dropdown-toggle:hover {
    background: var(--accent-bg, rgba(0, 0, 0, 0.08));
    transform: scale(1.06);
    box-shadow: none;
}

button.block-select-menu-toggle.nav-dropdown-toggle:active {
    transform: scale(0.96);
}

.block-select-menu-dropdown.open button.block-select-menu-toggle.nav-dropdown-toggle {
    background: var(--pressed-interactive-bg, var(--accent-bg));
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08) inset;
}

.block-select-menu-dropdown.open .block-select-menu-icon {
    transform: rotate(180deg);
}

.block-select-menu-dropdown .nav-dropdown-menu.block-select-menu {
    left: 0;
    right: auto;
    min-width: 13rem;
    padding: 0.45rem;
    transform-origin: top left;
    z-index: 1100;
}

.block-select-menu-heading {
    margin: 0.15rem 0.45rem 0.35rem;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted, #64748b);
}

.block-select-menu .nav-dropdown-item {
    font-size: 0.875rem;
}

.block-select-menu .nav-dropdown-divider {
    margin: 0.35rem 0.35rem;
}

.block-drag-menu-dropdown {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: var(--block-select-col-drag, 1.15rem);
}

button.block-drag-menu-toggle.nav-dropdown-toggle {
    box-sizing: border-box;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: auto;
    min-width: 1.15rem;
    min-height: 1.5rem;
    padding: 0.1em 0.25em !important;
    margin: 0;
    font: inherit;
    font-size: inherit;
    font-weight: inherit;
    line-height: 1;
    gap: 0;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--muted, #94a3b8);
    opacity: 1;
    cursor: grab;
    flex-shrink: 0;
    user-select: none;
    touch-action: none;
    transition: color 0.15s ease, background-color 0.15s ease;
}

.block-row:hover button.block-drag-menu-toggle.nav-dropdown-toggle,
tr[data-block-id]:hover button.block-drag-menu-toggle.nav-dropdown-toggle,
button.block-drag-menu-toggle.nav-dropdown-toggle:hover,
button.block-drag-menu-toggle.nav-dropdown-toggle:focus-visible,
.block-drag-menu-dropdown.open button.block-drag-menu-toggle.nav-dropdown-toggle {
    color: var(--accent, #475569);
    background-color: var(--accent-bg, rgba(0, 0, 0, 0.05));
}

button.block-drag-menu-toggle.nav-dropdown-toggle:active {
    cursor: grabbing;
}

.block-drag-menu-dropdown .nav-dropdown-menu.block-drag-menu {
    left: 0;
    right: auto;
    min-width: 11.5rem;
    max-height: none;
    overflow: visible;
    padding: 0.4rem;
    transform-origin: top left;
    z-index: 1100;
    background-color: var(--block-menu-bg, var(--box-bg, #ffffff));
    border: 1px solid var(--block-menu-border, color-mix(in srgb, var(--border, #cbd5e1) 88%, var(--fg, #0f172a) 12%));
    border-radius: 0.7rem;
    box-shadow: none;
}

.block-drag-submenu {
    position: relative;
}

.block-drag-submenu-toggle {
    justify-content: space-between;
}

.block-drag-submenu-caret {
    margin-left: 0.75rem;
    font-size: 1rem;
    line-height: 1;
    opacity: 0.7;
}

.block-drag-submenu-menu {
    top: 0;
    left: calc(100% + 0.2rem);
    right: auto;
    min-width: 11.5rem;
    max-height: min(22rem, 70vh);
    overflow-y: auto;
    padding: 0.4rem;
    transform-origin: top left;
    z-index: 1110;
    background-color: var(--block-menu-bg, var(--box-bg, #ffffff));
    border: 1px solid var(--block-menu-border, color-mix(in srgb, var(--border, #cbd5e1) 88%, var(--fg, #0f172a) 12%));
    border-radius: 0.7rem;
    box-shadow: none;
}

/* Beat .nav-dropdown.open .nav-dropdown-menu so the flyout stays closed until Elements is clicked. */
.block-drag-menu-dropdown.open .block-drag-submenu > .block-drag-submenu-menu {
    display: none;
}

.block-drag-menu-dropdown.open .block-drag-submenu.open > .block-drag-submenu-menu {
    display: block;
    animation: dropdownIn 0.16s cubic-bezier(0.16, 1, 0.3, 1);
}

.block-drag-submenu.open > .block-drag-submenu-toggle {
    background-color: var(--accent-bg, rgba(0, 0, 0, 0.05));
}

.block-drag-submenu-menu.block-drag-submenu-menu--flip-left {
    left: auto;
    right: calc(100% + 0.2rem);
    transform-origin: top right;
}

:root.-dark-theme .block-drag-menu-dropdown .nav-dropdown-menu.block-drag-menu,
:root.-dark-theme .block-drag-submenu-menu {
    --block-menu-bg: color-mix(in srgb, var(--box-bg, #1e293b) 92%, #000 8%);
    --block-menu-border: color-mix(in srgb, var(--border, #475569) 70%, #94a3b8 30%);
}

@media (prefers-color-scheme: dark) {
    :root:not(.-no-dark-theme):not([data-theme-setting="light"]) .block-drag-menu-dropdown .nav-dropdown-menu.block-drag-menu,
    :root:not(.-no-dark-theme):not([data-theme-setting="light"]) .block-drag-submenu-menu {
        --block-menu-bg: color-mix(in srgb, var(--box-bg, #1e293b) 92%, #000 8%);
        --block-menu-border: color-mix(in srgb, var(--border, #475569) 70%, #94a3b8 30%);
    }
}

.block-drag-menu .nav-dropdown-item {
    font-size: 0.84rem;
    font-weight: 500;
    text-transform: none;
    color: var(--fg, #334155);
    gap: 0.55rem;
    padding: 0.48rem 0.62rem;
}

/* Radio items (highlight swatches) in the block/line menu mark the current pick. */
.block-drag-menu .nav-dropdown-item[role="menuitemradio"][aria-checked="true"] {
    color: var(--accent, #475569);
    font-weight: 600;
}

.block-drag-menu .nav-dropdown-item[role="menuitemradio"][aria-checked="true"]::after {
    content: "✓";
    margin-left: auto;
    padding-left: 0.75rem;
    font-size: 0.8rem;
    font-weight: 700;
}

.block-drag-menu .nav-dropdown-divider {
    margin: 0.3rem 0.4rem;
    background-color: color-mix(in srgb, var(--border, #cbd5e1) 75%, transparent);
}

.block-drag-menu-bookmark {
    color: var(--block-menu-bookmark-fg, #92400e);
}

.block-drag-menu-bookmark:hover,
.block-drag-menu-bookmark:focus-visible {
    color: var(--block-menu-bookmark-fg-hover, #b45309);
    background-color: color-mix(in srgb, var(--block-menu-bookmark-fg-hover, #f59e0b) 14%, transparent);
}

.block-drag-menu-bookmark[data-bookmarked='true'] {
    color: var(--block-menu-bookmark-active-fg, #b45309);
    background-color: color-mix(in srgb, var(--block-menu-bookmark-active-fg, #f59e0b) 12%, transparent);
}

.block-drag-menu-bookmark[data-bookmarked='true']:hover,
.block-drag-menu-bookmark[data-bookmarked='true']:focus-visible {
    color: var(--block-menu-bookmark-active-fg, #b45309);
    background-color: color-mix(in srgb, var(--block-menu-bookmark-active-fg, #f59e0b) 20%, transparent);
}

.block-drag-menu-pin {
    color: var(--block-menu-pin-fg, #4338ca);
}

.block-drag-menu-pin:hover,
.block-drag-menu-pin:focus-visible {
    color: var(--block-menu-pin-fg-hover, #4f46e5);
    background-color: color-mix(in srgb, var(--block-menu-pin-fg-hover, #6366f1) 14%, transparent);
}

.block-drag-menu-pin[data-pinned='true'] {
    color: var(--block-menu-pin-active-fg, #4f46e5);
    background-color: color-mix(in srgb, var(--block-menu-pin-active-fg, #6366f1) 12%, transparent);
}

.block-drag-menu-pin[data-pinned='true']:hover,
.block-drag-menu-pin[data-pinned='true']:focus-visible {
    color: var(--block-menu-pin-active-fg, #4f46e5);
    background-color: color-mix(in srgb, var(--block-menu-pin-active-fg, #6366f1) 20%, transparent);
}

.block-drag-menu-delete {
    color: var(--block-menu-delete-fg, #dc2626);
}

.block-drag-menu-delete:hover,
.block-drag-menu-delete:focus-visible {
    color: var(--block-menu-delete-fg-hover, #b91c1c);
    background-color: color-mix(in srgb, var(--block-menu-delete-fg-hover, #ef4444) 14%, transparent);
}

:root.-dark-theme .block-drag-menu-bookmark {
    --block-menu-bookmark-fg: #fbbf24;
    --block-menu-bookmark-fg-hover: #fcd34d;
    --block-menu-bookmark-active-fg: #fde68a;
}

:root.-dark-theme .block-drag-menu-pin {
    --block-menu-pin-fg: #a5b4fc;
    --block-menu-pin-fg-hover: #c7d2fe;
    --block-menu-pin-active-fg: #e0e7ff;
}

:root.-dark-theme .block-drag-menu-delete {
    --block-menu-delete-fg: #f87171;
    --block-menu-delete-fg-hover: #fca5a5;
}

@media (prefers-color-scheme: dark) {
    :root:not(.-no-dark-theme):not([data-theme-setting="light"]) .block-drag-menu-bookmark {
        --block-menu-bookmark-fg: #fbbf24;
        --block-menu-bookmark-fg-hover: #fcd34d;
        --block-menu-bookmark-active-fg: #fde68a;
    }

    :root:not(.-no-dark-theme):not([data-theme-setting="light"]) .block-drag-menu-pin {
        --block-menu-pin-fg: #a5b4fc;
        --block-menu-pin-fg-hover: #c7d2fe;
        --block-menu-pin-active-fg: #e0e7ff;
    }

    :root:not(.-no-dark-theme):not([data-theme-setting="light"]) .block-drag-menu-delete {
        --block-menu-delete-fg: #f87171;
        --block-menu-delete-fg-hover: #fca5a5;
    }
}

.block-drag-menu-dropdown.open button.block-drag-menu-toggle.nav-dropdown-toggle {
    color: var(--accent, #475569);
    background-color: color-mix(in srgb, var(--accent-bg, rgba(0, 0, 0, 0.05)) 80%, var(--accent, #475569) 20%);
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent, #475569) 18%, transparent);
}

.controls-wrapper {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    vertical-align: middle;
}

#table-blocks .drag-handle,
.table-blocks-all .drag-handle {
    cursor: grab;
    user-select: none;
    color: #ccc;
    font-size: 1.2em;
}

#table-blocks .drag-handle:active,
.table-blocks-all .drag-handle:active {
    cursor: grabbing;
}

.create-below-menu-dropdown {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: var(--block-select-col-plus, 1.5rem);
}

#table-blocks td.block-left-controls a.create-below[role="button"],
.table-blocks-all td.block-left-controls a.create-below[role="button"],
#table-blocks .block-left-controls a.create-below[role="button"],
.table-blocks-all .block-left-controls a.create-below[role="button"],
.wyldcards-script .block-left-controls a.create-below[role="button"],
a.create-below[role="button"],
#table-blocks td.block-left-controls button.create-below.create-below-menu-toggle,
.table-blocks-all td.block-left-controls button.create-below.create-below-menu-toggle,
#table-blocks .block-left-controls button.create-below.create-below-menu-toggle,
.table-blocks-all .block-left-controls button.create-below.create-below-menu-toggle,
.wyldcards-script .block-left-controls button.create-below.create-below-menu-toggle,
button.create-below.create-below-menu-toggle {
    box-sizing: border-box;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    min-width: 1.5rem;
    padding: 0;
    margin: 0;
    font: inherit;
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1;
    border-radius: 999px;
    border: 1px solid var(--border, #cbd5e1);
    background: var(--accent-bg, rgba(0, 0, 0, 0.05));
    color: var(--accent, #475569);
    opacity: 0.55;
    text-decoration: none;
    vertical-align: middle;
    flex-shrink: 0;
    cursor: pointer;
    transition: opacity 0.15s ease, background-color 0.15s ease, border-color 0.15s ease, transform 0.12s ease, box-shadow 0.12s ease;
}

.block-row:hover a.create-below[role="button"],
tr[data-block-id]:hover a.create-below[role="button"],
a.create-below[role="button"]:focus-visible,
.block-row:hover button.create-below.create-below-menu-toggle,
tr[data-block-id]:hover button.create-below.create-below-menu-toggle,
button.create-below.create-below-menu-toggle:focus-visible,
.create-below-menu-dropdown.open button.create-below.create-below-menu-toggle {
    opacity: 1;
    border-color: var(--accent, #475569);
}

a.create-below[role="button"]:hover,
button.create-below.create-below-menu-toggle:hover {
    opacity: 1;
    background: var(--accent-bg, rgba(0, 0, 0, 0.08));
    transform: scale(1.06);
    box-shadow: none;
}

a.create-below[role="button"]:active,
button.create-below.create-below-menu-toggle:active {
    transform: scale(0.96);
}

.create-below-menu-dropdown.open button.create-below.create-below-menu-toggle {
    background: var(--pressed-interactive-bg, var(--accent-bg));
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08) inset;
}

.create-below-menu-dropdown .nav-dropdown-menu.create-below-menu {
    left: 0;
    right: auto;
    min-width: 11.5rem;
    max-height: min(22rem, 70vh);
    overflow-y: auto;
    padding: 0.4rem;
    transform-origin: top left;
    z-index: 1100;
    background-color: var(--block-menu-bg, var(--box-bg, #ffffff));
    border: 1px solid var(--block-menu-border, color-mix(in srgb, var(--border, #cbd5e1) 88%, var(--fg, #0f172a) 12%));
    border-radius: 0.7rem;
    box-shadow: none;
}

:root.-dark-theme .create-below-menu-dropdown .nav-dropdown-menu.create-below-menu {
    --block-menu-bg: color-mix(in srgb, var(--box-bg, #1e293b) 92%, #000 8%);
    --block-menu-border: color-mix(in srgb, var(--border, #475569) 70%, #94a3b8 30%);
}

@media (prefers-color-scheme: dark) {
    :root:not(.-no-dark-theme):not([data-theme-setting="light"]) .create-below-menu-dropdown .nav-dropdown-menu.create-below-menu {
        --block-menu-bg: color-mix(in srgb, var(--box-bg, #1e293b) 92%, #000 8%);
        --block-menu-border: color-mix(in srgb, var(--border, #475569) 70%, #94a3b8 30%);
    }
}

.create-below-menu .nav-dropdown-item {
    font-size: 0.84rem;
    font-weight: 500;
    text-transform: none;
    color: var(--fg, #334155);
}

.create-below-menu .nav-dropdown-divider {
    margin: 0.3rem 0.4rem;
    background-color: color-mix(in srgb, var(--border, #cbd5e1) 75%, transparent);
}

.create-below-songs-section[hidden],
.create-below-drafts-section[hidden] {
    display: none !important;
}

.create-below-songs-heading,
.create-below-drafts-heading {
    padding: 0.35rem 0.65rem 0.15rem;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: color-mix(in srgb, var(--muted, #64748b) 88%, var(--fg, #0f172a) 12%);
}

.create-below-songs-list .nav-dropdown-item,
.create-below-drafts-list .nav-dropdown-item {
    max-width: 14rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.create-below-docs-empty {
    padding: 0.25rem 0.65rem 0.35rem;
    font-size: 0.78rem;
    color: var(--muted, #64748b);
}

.create-below-docs-manage {
    margin-top: 0.15rem;
    font-size: 0.78rem;
    color: var(--muted, #64748b);
}

#table-blocks .block-left-controls .drag-handle,
.table-blocks-all .block-left-controls .drag-handle {
    display: inline-block !important;
    vertical-align: middle;
}

#table-blocks tr.dragging,
.table-blocks-all tr.dragging,
.table-blocks-all .block-row.dragging {
    opacity: 0.4;
}

#table-blocks tr[data-block-id],
.table-blocks-all .block-row[data-block-id] {
    position: relative;
}

#table-blocks tr.drop-before > td,
#table-blocks tr.drop-after > td {
    position: relative;
}

#table-blocks tr.drop-before > td.block-content::before,
#table-blocks tr.drop-after > td.block-content::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--accent, #475569);
    border-radius: 2px;
    box-shadow: 0 0 0 1px var(--box-bg, #ffffff), 0 0 0 3px color-mix(in srgb, var(--accent, #475569) 25%, transparent);
    pointer-events: none;
    z-index: 3;
}

#table-blocks tr.drop-before > td.block-content::before {
    top: -2px;
}

#table-blocks tr.drop-after > td.block-content::after {
    bottom: -2px;
}

.table-blocks-all .block-row.drop-before::before,
.table-blocks-all .block-row.drop-after::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--accent, #475569);
    border-radius: 2px;
    box-shadow: 0 0 0 1px var(--box-bg, #ffffff), 0 0 0 3px color-mix(in srgb, var(--accent, #475569) 25%, transparent);
    pointer-events: none;
    z-index: 3;
}

.table-blocks-all .block-row.drop-before::before {
    top: -2px;
}

.table-blocks-all .block-row.drop-after::after {
    bottom: -2px;
}

.wyldcards-script .block-row.drop-before::before,
.wyldcards-script .block-row.drop-after::after {
    grid-column: 1 / -1;
}

h1 > small a[role="button"],
h1 > small .wyldcards-delete-btn,
#table-scenes a[role="button"],
#table-blocks a[role="button"]:not(.create-below),
.table-blocks-all a[role="button"]:not(.create-below),
.wyldcards-script .block-actions a[role="button"] {
    opacity: 0;
    font-size: 0.5em;
}

.version-history-intro {
    color: var(--muted);
    max-width: 42rem;
    margin-bottom: 1.25rem;
}

.script-edition-dropdown {
    display: inline-block;
    position: relative;
}

.script-edition-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    max-width: 11rem;
}

.script-edition-toggle-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.85rem;
    font-weight: 600;
}

.script-edition-toggle-lock {
    display: none;
    flex-shrink: 0;
    opacity: 0.85;
}

html.wyldcards-block-edit-locked .script-edition-toggle-lock{
    display: block;
}

.script-edition-toggle-caret {
    flex-shrink: 0;
    opacity: 0.7;
}

.script-edition-dropdown.open .script-edition-toggle-caret{
    transform: rotate(180deg);
}

.script-edition-menu .nav-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.script-edition-dropdown .nav-dropdown-menu.script-edition-menu {
    display: none;
    right: 0;
    left: auto;
    min-width: 14rem;
    max-width: calc(100vw - 1rem);
    padding: 0.35rem;
    transform-origin: top right;
    z-index: 1100;
}

.script-edition-dropdown.open .nav-dropdown-menu.script-edition-menu {
    display: block;
}

.script-edition-menu-label {
    padding: 0.35rem 0.65rem 0.15rem;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted, #888);
    user-select: none;
}

.script-edition-row {
    display: flex;
    align-items: center;
    gap: 0.15rem;
    border-radius: 0.45rem;
}

.script-edition-row.is-active {
    background-color: var(--accent-bg, rgba(0, 0, 0, 0.05));
}

.script-edition-row .script-edition-switch {
    display: block;
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.script-edition-row .controls-wrapper {
    flex-shrink: 0;
}

.script-edition-row-edited {
    flex: 0 0 auto;
    margin: 0 0.15rem 0 0;
    padding: 0 0.2rem;
    font-size: 0.72rem;
    line-height: 1.2;
    color: var(--muted-fg, #64748b);
    white-space: nowrap;
    pointer-events: none;
    user-select: none;
}

.script-edition-row-edited .last-edited-time {
    font-size: inherit;
    color: inherit;
}

.script-edition-row.is-active .script-edition-switch:hover,
.script-edition-row.is-active .script-edition-switch:focus-visible {
    background: transparent;
}

.script-edition-default-form {
    display: inline-flex;
    flex-shrink: 0;
    margin: 0;
}

.script-edition-default-toggle {
    width: 1.75rem;
    height: 1.75rem;
    font-size: 1rem;
    flex-shrink: 0;
    cursor: default;
}

button.script-edition-default-toggle {
    cursor: pointer;
}

.script-edition-menu-hint {
    padding: 0.25rem 0.75rem 0.5rem;
    font-size: 0.75rem;
    line-height: 1.3;
}

.script-edition-publish-form {
    display: inline-flex;
    flex-shrink: 0;
    margin: 0;
}

.script-edition-publish-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    min-width: 1.75rem;
    padding: 0;
    margin: 0;
    flex-shrink: 0;
    border: none;
    border-radius: 0.45rem;
    background: transparent;
    color: var(--muted-fg, #64748b);
    cursor: default;
}

button.script-edition-publish-toggle {
    cursor: pointer;
}

button.script-edition-publish-toggle:hover,
button.script-edition-publish-toggle:focus-visible {
    color: var(--fg, inherit);
    background: var(--accent-bg, rgba(0, 0, 0, 0.05));
}

.script-edition-publish-toggle.is-published {
    color: var(--fg, inherit);
}

.script-edition-delete-form {
    display: inline-flex;
    flex-shrink: 0;
    margin: 0;
}

.script-edition-row .script-edition-lock-toggle,
.script-edition-row .script-edition-history-toggle,
.script-edition-row .script-edition-rename-toggle,
.script-edition-row .script-edition-delete-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    min-width: 1.75rem;
    padding: 0;
    margin: 0;
    gap: 0;
    flex-shrink: 0;
    border: none;
    background: transparent;
    border-radius: 0.45rem;
    color: var(--muted-fg, #64748b);
    text-decoration: none;
    cursor: pointer;
}

.script-edition-row .script-edition-lock-toggle:hover,
.script-edition-row .script-edition-lock-toggle:focus-visible,
.script-edition-row .script-edition-history-toggle:hover,
.script-edition-row .script-edition-history-toggle:focus-visible,
.script-edition-row .script-edition-rename-toggle:hover,
.script-edition-row .script-edition-rename-toggle:focus-visible {
    color: var(--fg, inherit);
    background: var(--accent-bg, rgba(0, 0, 0, 0.05));
}

.script-edition-row .script-edition-delete-toggle:hover,
.script-edition-row .script-edition-delete-toggle:focus-visible {
    color: var(--danger-fg, #b91c1c);
    background: var(--danger-bg, rgba(185, 28, 28, 0.08));
}

.script-edition-row .script-edition-rename-toggle svg,
.script-edition-row .script-edition-delete-toggle svg {
    width: 13px;
    height: 13px;
    display: block;
    flex-shrink: 0;
}

.script-edition-row .script-edition-lock-toggle.is-active {
    color: var(--accent, #475569);
}

.script-edition-row .script-edition-history-toggle svg {
    width: 13px;
    height: 13px;
    display: block;
    flex-shrink: 0;
}

/* Icon-only buttons can't fit the injected ⌘-hint text; the title tooltip already carries it. */
.script-edition-row .script-edition-lock-toggle .nav-dropdown-shortcut,
.script-edition-row .script-edition-history-toggle .nav-dropdown-shortcut {
    display: none;
}

.script-edition-menu .nav-dropdown-item.active {
    font-weight: 700;
}

.text-size-control .script-edition-toggle svg{
    display: block;
    flex-shrink: 0;
}

.script-edition-dialog {
    border: 1px solid var(--line, #ccc);
    border-radius: 0.5rem;
    padding: 1.25rem;
    max-width: 24rem;
    width: calc(100% - 2rem);
    background: var(--bg, #fff);
    color: inherit;
}

.script-edition-dialog::backdrop {
    background: rgba(0, 0, 0, 0.35);
}

.script-edition-create-form h2 {
    margin-top: 0;
    font-size: 1.15rem;
}

.script-edition-create-form label {
    display: block;
    margin: 1rem 0;
}

.script-edition-create-form input[type="text"] {
    width: 100%;
    margin-top: 0.35rem;
}

.script-edition-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1rem;
}

.version-changes {
    min-width: 14rem;
    max-width: 28rem;
}

.version-change-summary {
    display: block;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.version-change-details {
    margin: 0;
    padding-left: 1.1rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.version-change-details li + li {
    margin-top: 0.15rem;
}

.version-row-autosave td {
    color: var(--muted);
}

.version-badge {
    display: inline-block;
    margin-left: 0.4rem;
    padding: 0.05rem 0.4rem;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--muted);
    border: 1px solid color-mix(in srgb, var(--muted) 45%, transparent);
    border-radius: 0.25rem;
    vertical-align: middle;
}

/* --- Snapshot history page ---------------------------------------------- */
.version-history-header {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    margin: 0.35rem 0 1.5rem;
}

.version-history-mark {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.6rem;
    height: 2.6rem;
    margin-top: 0.15rem;
    border-radius: 0.85rem;
    color: var(--td-song, #0f766e);
    background: color-mix(in srgb, var(--td-song, #0f766e) 14%, transparent);
}

.version-history-header h1 {
    margin: 0 0 0.35rem;
    line-height: 1.15;
}

.version-history-header .version-history-intro {
    margin: 0;
    max-width: 42rem;
}

.version-save-form {
    margin: 0 0 1.75rem;
    display: flex;
    gap: 0.6rem;
    align-items: flex-end;
    flex-wrap: wrap;
    padding: 1rem 1.15rem;
    border: 1px solid var(--td-line, #cbd5e1);
    border-radius: calc(var(--border-radius, 0.5rem) + 2px);
    background: var(--td-surface, color-mix(in srgb, var(--box-bg, #fff) 88%, var(--accent, #475569) 12%));
}

.version-save-label {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    flex: 1 1 18rem;
    min-width: 0;
    margin: 0;
}

.version-save-label-text {
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--muted-fg, #64748b);
}

.version-save-form input[type="text"] {
    width: 100%;
    box-sizing: border-box;
    margin: 0;
}

.version-history-empty {
    margin: 0.35rem 0 0;
    padding: 1.6rem 1.25rem;
    border: 1px dashed var(--td-line, #cbd5e1);
    border-radius: calc(var(--border-radius, 0.5rem) + 2px);
    background: color-mix(in srgb, var(--box-bg, #fff) 92%, var(--accent, #475569) 8%);
    text-align: center;
}

.version-history-empty-title {
    margin: 0 0 0.35rem;
    font-weight: 600;
}

.version-history-empty .muted {
    margin: 0 auto;
    max-width: 30rem;
}

.version-history-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.version-history-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
    font-size: 0.92rem;
}

.version-history-table thead th {
    text-align: left;
    padding: 0.5rem 0.75rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted-fg, #64748b);
    border-bottom: 2px solid var(--td-line, #cbd5e1);
    white-space: nowrap;
}

.version-history-table tbody td {
    padding: 0.7rem 0.75rem;
    border-bottom: 1px solid color-mix(in srgb, var(--td-line, #cbd5e1) 60%, transparent);
    vertical-align: top;
}

.version-history-table tbody tr:hover td {
    background: color-mix(in srgb, var(--accent, #475569) 5%, transparent);
}

.version-label-cell {
    min-width: 8rem;
}

.version-label-text {
    font-weight: 600;
}

.version-row-autosave .version-label-text {
    font-weight: 500;
}

.version-actions-cell {
    text-align: right;
}

.version-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    justify-content: flex-end;
}

.version-actions form {
    display: inline;
    margin: 0;
}

h1 > small a[role="button"]:focus,
h1:hover > small a[role="button"],
h1 > small .wyldcards-delete-btn:focus,
h1:hover > small .wyldcards-delete-btn,
#table-scenes tr a[role="button"]:focus,
#table-scenes tr:hover a[role="button"],
#table-blocks tr a[role="button"]:focus,
#table-blocks tr:hover a[role="button"],
.table-blocks-all tr a[role="button"]:focus,
.table-blocks-all tr:hover a[role="button"],
.table-blocks-all .block-row a[role="button"]:focus,
.table-blocks-all .block-row:hover a[role="button"] {
    opacity: 1;
}

#table-scenes tr:last-child .move-up,
#table-blocks tr:last-child .move-up {
    margin-left: 22px;
}

.text-size-control {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
    justify-content: flex-end;
    margin-bottom: 1rem;
}

.wyldcards-tools-group {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.wyldcards-toolbar-row.wyldcards-tools-row {
    margin-bottom: 0.35rem;
}

.wyldcards-toolbar-row.wyldcards-tools-row .wyldcards-toolbar-main {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
}

/* Plain text labels rather than bordered pills, matching the song editor's
   toolbar (fragments/songFileMenu, songEditMenu), which takes the base
   .nav-dropdown-toggle look. Only the layout bits below are group-specific. */
.wyldcards-tools-group .nav-dropdown-toggle,
.wyldcards-tools-group a.nav-dropdown-toggle {
    background: none;
    border: none;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.25rem;
    /* The song editor has two menus and can afford its 1rem side padding; nine
       menus have to fit the 6in toolbar column, so only the padding is tightened. */
    padding: 0.5rem 0.3rem;
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.2;
    white-space: nowrap;
    text-decoration: none;
    color: inherit;
    min-width: 0;
    min-height: 0;
    height: auto;
    cursor: pointer;
}

.wyldcards-tools-group .nav-dropdown-toggle:hover,
.wyldcards-tools-group .nav-dropdown-toggle:focus,
.wyldcards-tools-group a.nav-dropdown-toggle:hover,
.wyldcards-tools-group a.nav-dropdown-toggle:focus {
    filter: none;
    background-color: var(--accent-bg, rgba(0, 0, 0, 0.05));
    box-shadow: none;
}

.wyldcards-tools-group .nav-dropdown-toggle[aria-expanded="true"] {
    box-shadow: none;
    background-color: var(--accent-bg, rgba(0, 0, 0, 0.05));
    color: var(--accent, inherit);
}

.wyldcards-tools-group .nav-dropdown-toggle svg,
.wyldcards-tools-group a.nav-dropdown-toggle svg {
    display: none;
}

.text-size-control-row-break {
    flex-basis: 100%;
    width: 0;
    height: 0;
    margin: 0;
    padding: 0;
    border: 0;
    overflow: hidden;
}

.text-size-control button {
    font-size: 0.85rem;
    padding: 0.15em 0.5em;
    cursor: pointer;
}

.text-size-control button.history-action-btn.is-unavailable,
.wyldcards-tools-group button.history-action-btn.is-unavailable {
    opacity: 0.55;
    cursor: not-allowed;
}

.wyldcards-tools-group .history-dropdown,
.text-size-control .history-dropdown {
    display: inline-block;
    position: relative;
    z-index: 1;
}

.wyldcards-tools-group .history-dropdown.open,
.text-size-control .history-dropdown.open {
    z-index: 1300;
}

.wyldcards-tools-group .history-dropdown .nav-dropdown-menu.history-menu,
.text-size-control .history-dropdown .nav-dropdown-menu.history-menu {
    display: none;
    left: 0;
    right: auto;
    min-width: 12.5rem;
    padding: 0.35rem;
    transform-origin: top left;
    z-index: 1300;
}

.wyldcards-tools-group .history-dropdown.open .nav-dropdown-menu.history-menu,
.text-size-control .history-dropdown.open .nav-dropdown-menu.history-menu {
    display: block;
}

.history-menu .nav-dropdown-item {
    font-size: 0.84rem;
    font-weight: 500;
    justify-content: flex-start;
    gap: 0.75rem;
}

.history-menu .nav-dropdown-item-label {
    min-width: 0;
}

.nav-dropdown-item .nav-dropdown-shortcut,
.nav-dropdown-item .element-type-shortcut {
    margin-left: auto;
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    opacity: 0.55;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    flex-shrink: 0;
}

/* When a shortcut is present, keep the checkmark after it instead of pushing left. */
.nav-dropdown-item[aria-checked="true"]:has(.nav-dropdown-shortcut:not([hidden]))::after,
.nav-dropdown-item[aria-checked="true"]:has(.element-type-shortcut:not([hidden]))::after,
.nav-dropdown-item.is-active:has(.nav-dropdown-shortcut:not([hidden]))::after,
.nav-dropdown-item.is-active:has(.element-type-shortcut:not([hidden]))::after {
    margin-left: 0;
}

.text-size-control .nav-dropdown-toggle {
    background: var(--interactive-bg);
    border: 1px solid var(--muted-fg);
    border-radius: var(--border-radius);
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    color: var(--fg);
    font-size: 0.85rem;
    padding: 0.15em 0.5em;
}

.text-size-control .nav-dropdown-toggle:hover,
.text-size-control .nav-dropdown-toggle:focus {
    filter: brightness(1.1);
    background-color: var(--interactive-bg);
    box-shadow: none;
}

.text-size-control .nav-dropdown-toggle[aria-expanded="true"] {
    box-shadow: 0 2px 4px -1px var(--fg) inset;
    background: var(--pressed-interactive-bg);
    color: var(--accent);
}

.scene-pager {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

body.htmx-settling {
    opacity: 1;
}

body.htmx-swapping {
    opacity: 0;
    transition: opacity 0.1s ease-out;
}

/* Dropdown container */
.nav-dropdown {
    position: relative;
    display: inline-block;
}

.header-actions .user-dropdown-container.nav-dropdown {
    position: relative;
}

/* Dropdown toggle button */
.nav-dropdown-toggle {
    background: none;
    border: none;
    color: inherit;
    padding: 0.5rem 1rem;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.25rem;
    transition: color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
    border-radius: 4px;
    box-shadow: none;
}

.nav-dropdown-toggle:hover,
.nav-dropdown-toggle:focus-visible {
    background-color: var(--accent-bg, rgba(0, 0, 0, 0.05));
    outline: none;
    box-shadow: none;
    filter: none;
}

.nav-dropdown.open > .nav-dropdown-toggle,
.help-dropdown.open .help-toggle-btn,
.user-dropdown-container.open .user-toggle-btn {
    background-color: var(--accent-bg, rgba(0, 0, 0, 0.05));
    color: var(--accent, inherit);
}

.header-actions-group .help-dropdown.open .help-toggle-btn,
.header-actions-group .user-dropdown-container.open .user-toggle-btn {
    background: var(--pressed-interactive-bg, var(--accent-bg));
    filter: none;
}

/* Dropdown panel */
.nav-dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 0.35rem);
    right: 0;
    min-width: 11rem;
    padding: 0.35rem;
    margin: 0;
    background-color: var(--box-bg, #ffffff);
    border: 1px solid var(--border, #e0e0e0);
    border-radius: 0.65rem;
    box-shadow: none !important;
    filter: none;
    z-index: 1000;
    transform-origin: top right;
}

.header-actions .nav-dropdown-menu {
    min-width: 10.5rem;
}

.nav-dropdown.open .nav-dropdown-menu {
    display: block;
    animation: dropdownIn 0.16s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Dropdown items */
.nav-dropdown-item {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.5rem;
    width: 100%;
    padding: 0.45rem 0.65rem;
    clear: both;
    font-weight: 400;
    color: var(--fg, #333333);
    text-align: left;
    white-space: nowrap;
    background: none;
    border: none;
    border-radius: 0.45rem;
    font-size: 0.9rem;
    line-height: 1.35;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.12s ease, color 0.12s ease;
    box-sizing: border-box;
    box-shadow: none;
    filter: none;
}

.nav-dropdown-item:hover,
.nav-dropdown-item:focus-visible {
    background-color: var(--accent-bg, rgba(0, 0, 0, 0.05));
    color: var(--accent, inherit);
    outline: none;
    box-shadow: none;
    filter: none;
}

.nav-dropdown-item.active {
    background-color: var(--accent-bg, rgba(0, 0, 0, 0.05));
    color: var(--accent, inherit);
    font-weight: 600;
    box-shadow: none;
}

.nav-dropdown-item:active {
    transform: scale(0.985);
    box-shadow: none;
}

/* Dropdown divider */
.nav-dropdown-divider {
    height: 1px;
    margin: 0.3rem 0.45rem;
    overflow: hidden;
    background-color: var(--border, #e0e0e0);
    border: none;
}

@keyframes dropdownIn {
    from {
        opacity: 0;
        transform: translateY(-6px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
#create-scene-row input[type="text"],
#create-scene-below-form input[type="text"],
form[action*="/scene/"] input[type="text"],
form[hx-post*="/scene/"] input[type="text"] {
    width: 100%;
    max-width: 600px;
    box-sizing: border-box;
}

form[action*="/block/"] textarea,
form[hx-post*="/block/"] textarea,
.block-input-textarea {
    width: 100%;
    max-width: 800px;
    box-sizing: border-box;
    resize: none;
    overflow: hidden;
    display: block;
    min-height: 0;
    line-height: inherit;
    letter-spacing: inherit;
    word-spacing: inherit;
    /* Keep padding 0 so view (<p>) and edit (textarea) heights match on focus/blur */
    padding: 0;
    margin: 0;
    font: inherit;
    color: inherit;
    background: transparent;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    outline-offset: 0;
    -webkit-appearance: none;
    appearance: none;
    white-space: pre-wrap;
}

.block-content textarea:focus,
.block-content textarea:focus-visible,
.block-input-textarea:focus,
.block-input-textarea:focus-visible,
form[action*="/block/"] textarea:focus,
form[action*="/block/"] textarea:focus-visible,
form[hx-post*="/block/"] textarea:focus,
form[hx-post*="/block/"] textarea:focus-visible {
    outline: none !important;
    box-shadow: none !important;
    border: none !important;
    outline-offset: 0;
}

.block-content:focus-within,
.block-content:has(.block-inline-edit-form),
.block-content:has(form[hx-post*="/block/editInline"]) {
    outline: none;
    box-shadow: none;
}

/* Active writing row — no tint while editing */
.wyldcards-script .block-content {
    position: relative;
    border-radius: 0;
    background-color: transparent;
    box-shadow: none;
}

.wyldcards-script .block-row:hover > .block-content:not(:focus-within):not(:has(.block-inline-edit-form)):not(:has(form[hx-post*="/block/editInline"])),
.wyldcards-script .block-content:focus-within,
.wyldcards-script .block-content:has(.block-inline-edit-form:focus-within),
.wyldcards-script .block-content:has(form[hx-post*="/block/editInline"]:focus-within) {
    background-color: transparent;
    box-shadow: none;
}

.block-content textarea,
.block-content .block-input-textarea {
    width: 100%;
    max-width: 100%;
}

.block-content form .block-input-textarea.script-block-text {
    margin: 0;
}

.block-content form .block-input-textarea.script-block-text:last-child {
    margin-bottom: 0;
}

.block-content form {
    margin: 0;
    padding: 0;
}

/* Stack reader-visible mirror + edit form so Safari can extract the mirror
   while the form (sidebar/menu) stays out of Reader. */
.block-content:has(> .reader-visible-text):has(> .block-inline-edit-form),
.block-content:has(> .reader-visible-text):has(> form[hx-post*="/block/editInline"]) {
    display: grid;
    grid-template-columns: minmax(0, 100%);
}

.block-content > .reader-visible-text,
.block-content > form[hx-post*="/block/editInline"],
.block-content > form[hx-post*="/block/editInline"] .block-input-textarea.script-block-text {
    grid-area: 1 / 1;
    width: 100%;
    margin: 0;
    padding: 0;
}

/* Keep spell overlay + textarea in one cell so the block doesn't grow on focus */
.block-content form[hx-post*="/block/editInline"] {
    display: grid;
    grid-template-columns: minmax(0, 100%);
    align-content: start;
    position: relative;
}
.block-content form[hx-post*="/block/editInline"] > .wyldcards-spell-overlay,
.block-content form[hx-post*="/block/editInline"] > .block-input-textarea.script-block-text {
    grid-area: 1 / 1;
    width: 100%;
    margin: 0;
    padding: 0;
}

.block-content:has(.block-inline-edit-form) > .reader-visible-text,
.block-content:has(form[hx-post*="/block/editInline"]) > .reader-visible-text {
    display: block;
    white-space: pre-wrap;
    user-select: text;
}

.block-content:has(.block-inline-edit-form:focus-within) > .reader-visible-text,
.block-content:has(form[hx-post*="/block/editInline"]:focus-within) > .reader-visible-text {
    visibility: hidden;
    pointer-events: none;
}

.block-content:has(.block-inline-edit-form:not(:focus-within)) .block-input-textarea,
.block-content:has(form[hx-post*="/block/editInline"]:not(:focus-within)) .block-input-textarea {
    opacity: 0;
    pointer-events: none;
}

.block-content:has(.block-input-textarea),
.block-content:has(form textarea) {
    cursor: text;
}

.block-content > span {
    white-space: pre-wrap;
}

.block-select-checkbox {
    display: block !important;
    width: var(--block-select-col-checkbox, 1.1rem);
    height: var(--block-select-col-checkbox, 1.1rem);
    margin: 0;
    justify-self: center;
    cursor: pointer;
}

.wyldcards-script .block-select-checkbox {
    -webkit-appearance: none;
    appearance: none;
    box-sizing: border-box;
    border: 1.5px solid #374151;
    border-radius: 0.2rem;
    background-color: var(--box-bg, #ffffff);
    background-repeat: no-repeat;
    background-position: center;
    background-size: 100% 100%;
}

.wyldcards-script .block-select-checkbox:checked {
    background-color: var(--accent, #145591);
    border-color: var(--accent, #145591);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='white'%3E%3Cpath d='M12.207 4.793a1 1 0 0 1 0 1.414l-5 5a1 1 0 0 1-1.414 0l-2.5-2.5a1 1 0 0 1 1.414-1.414L6.5 9.086l4.293-4.293a1 1 0 0 1 1.414 0z'/%3E%3C/svg%3E");
}

.wyldcards-script .block-select-checkbox:focus-visible {
    outline: 2px solid color-mix(in srgb, var(--accent, #145591) 35%, transparent);
    outline-offset: 1px;
}

tr.filtered-out,
.block-row.filtered-out,
.song-block-row.filtered-out {
    display: none !important;
}

/* Default Wyldcards Row Highlight in List */
.wyldcards-list-card.default-wyldcards-row {
    background-color: rgba(245, 158, 11, 0.05);
    border-left-color: #f59e0b;
}

.wyldcards-list-card.default-wyldcards-row:hover {
    background-color: rgba(245, 158, 11, 0.09);
}

/* Star Icon Style Toggle */
.default-wyldcards-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    margin: 0;
    background: none !important;
    border: none !important;
    border-radius: 6px;
    box-shadow: none !important;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    padding: 0;
    color: var(--muted-fg, #94a3b8);
    transition: transform 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}

.default-wyldcards-toggle:hover {
    color: #f59e0b;
    background: rgba(245, 158, 11, 0.08) !important;
    transform: scale(1.08);
}

.default-wyldcards-toggle:focus-visible {
    outline: 2px solid rgba(245, 158, 11, 0.45);
    outline-offset: 1px;
}

.default-wyldcards-toggle .icon-filled {
    display: none;
}

.default-wyldcards-toggle.is-default {
    color: #f59e0b;
}

.default-wyldcards-toggle.is-default .icon-outline {
    display: none;
}

.default-wyldcards-toggle.is-default .icon-filled {
    display: inline;
}

/* Badge Style Toggle (for Detail Page) */
.default-wyldcards-badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.5em;
    font-weight: 600;
    padding: 0.2em 0.6em;
    border-radius: 9999px;
    border: 1px solid var(--border, #cbd5e1);
    background-color: var(--box-bg, #ffffff);
    color: var(--muted, #64748b);
    cursor: pointer;
    vertical-align: middle;
    margin-left: 0.5rem;
    transition: all 0.2s ease;
}

.default-wyldcards-badge::before {
    content: "☆ ";
    margin-right: 0.25em;
}

.default-wyldcards-badge:hover {
    background-color: var(--accent-bg, #f1f5f9);
    color: var(--accent, #1e293b);
    border-color: var(--accent, #64748b);
}

.default-wyldcards-badge.is-default {
    background-color: #f59e0b; /* Golden yellow */
    color: #ffffff;
    border-color: #d97706;
}

.default-wyldcards-badge.is-default::before {
    content: "★ ";
}

/* Wyldcards List Page */
/* missing.css gives every <header> margin-block: calc(2*var(--gap)), which leaves
   a ~45px void between the nav and the Wyldcards heading. Scoped to this page only. */
body:has(main.wyldcards-list-page) > header.sidebar.menu {
    margin-bottom: 0;
}

.wyldcards-list-page {
    --pl-line: var(--border, #cbd5e1);
    --pl-mark: var(--accent, #475569);
    max-width: 920px;
    margin: 0 auto;
    padding: 0 1.25rem 2.5rem;
}

.wyldcards-list-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin: 0.75rem 0 1.1rem;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid var(--pl-line);
    flex-wrap: wrap;
}

.wyldcards-list-header-intro {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    min-width: 0;
}

.wyldcards-list-header-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.15rem;
    height: 2.15rem;
    flex-shrink: 0;
    margin-top: 0.1rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--pl-mark) 14%, transparent);
    color: var(--pl-mark);
}

.wyldcards-list-header h1 {
    margin: 0 0 0.3rem;
    font-size: 1.65rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.wyldcards-list-header-text p,
.wyldcards-list-header-text .muted {
    margin: 0;
    font-size: 0.92rem;
}

.wyldcards-list-header-actions {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.4rem;
    flex-shrink: 0;
}

.wyldcards-list-header-buttons {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 0.6rem;
    flex-shrink: 1;
    min-width: 0;
    max-width: 100%;
}

/* Header controls mix links, buttons, and form-backed actions. Give each the
   same box metrics so no action looks taller or wider by implementation type. */
.wyldcards-list-header-buttons > form {
    display: inline-flex;
    margin: 0;
}

.wyldcards-list-header-buttons .wyldcards-list-action-btn,
.wyldcards-list-header-buttons .user-list-create-btn {
    min-height: 2.25rem;
    padding-inline: 0.7rem;
    box-sizing: border-box;
    /* missing.css gives real <button>s a drop shadow the link buttons lack. */
    box-shadow: none;
    white-space: nowrap;
}

.wyldcards-list-import-hint {
    max-width: 22rem;
    text-align: right;
    font-size: 0.8rem !important;
    line-height: 1.35;
}

.wyldcards-list-import-hint code {
    font-size: 0.9em;
    padding: 0.05rem 0.3rem;
    border-radius: 4px;
    background: var(--muted-bg, rgba(100, 116, 139, 0.12));
}

/* Count of recoverable wyldcards, shown on the Deleted Wyldcards link. */
.wyldcards-list-trash-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.15rem;
    height: 1.15rem;
    margin-left: 0.4rem;
    padding: 0 0.35rem;
    border-radius: 999px;
    background: rgba(100, 116, 139, 0.18);
    color: inherit;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1;
    vertical-align: middle;
}

.wyldcards-list-import-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    margin: 0;
    padding: 0.6rem 1.1rem;
    border-radius: 8px;
    border: 1px solid var(--border, #cbd5e1);
    background: transparent;
    color: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.wyldcards-list-import-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.wyldcards-list-import-btn:hover,
.wyldcards-list-import-btn:focus-visible {
    border-color: var(--accent, #475569);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

.wyldcards-list-import-btn:disabled {
    opacity: 0.6;
    cursor: default;
    transform: none;
}

.wyldcards-list-create-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    margin: 0;
    padding: 0.6rem 1.1rem;
    border-radius: 8px;
    border: 1px solid var(--accent, #475569);
    background: var(--accent, #475569);
    color: #fff !important;
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none !important;
    white-space: nowrap;
    flex-shrink: 0;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
    transition: filter 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.wyldcards-list-create-btn:hover,
.wyldcards-list-create-btn:focus-visible {
    filter: brightness(0.92);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    text-decoration: none !important;
    color: #fff !important;
    transform: translateY(-1px);
}

.wyldcards-list-create-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.1rem;
    height: 1.1rem;
    font-size: 1.15rem;
    line-height: 1;
    font-weight: 700;
}

.wyldcards-list-toolbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.85rem;
    flex-wrap: wrap;
}

.wyldcards-list-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
    margin-left: auto;
}

/* Folders: the tiles you click into, the path back out of the one that is open,
   and the picker that says where a card is filed. Deliberately the same quiet
   shapes the songs and notes lists use for the same job — a writer should
   recognise folders, not learn them twice. */
.wyldcards-list-folders {
    display: block;
    margin: 0 0 0.85rem;
}

/* The tiles. A grid rather than a row of chips: these are things to go into,
   and they take the width the list itself takes so a folder reads as a place
   over the cards rather than a filter above them. */
.wyldcards-list-folder-grid {
    list-style: none;
    margin: 0 0 0.6rem;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
    gap: 0.5rem;
}

.wyldcards-list-folder-tile {
    font: inherit;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.55rem;
    text-align: left;
    color: inherit;
    background: color-mix(in srgb, currentColor 4%, transparent);
    border: 1px solid color-mix(in srgb, currentColor 14%, transparent);
    border-radius: 0.6rem;
    padding: 0.6rem 0.75rem;
    cursor: pointer;
}

.wyldcards-list-folder-tile:hover {
    background: color-mix(in srgb, currentColor 8%, transparent);
    border-color: color-mix(in srgb, currentColor 28%, transparent);
}

.wyldcards-list-folder-tile-mark {
    font-size: 1.05rem;
    line-height: 1;
}

.wyldcards-list-folder-tile-name {
    font-weight: 600;
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wyldcards-list-folder-tile-count,
.wyldcards-list-folder-tile-chevron {
    color: var(--muted-fg, #64748b);
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
}

/* The path out. Sits where the tiles were, so going in and coming back out
   move nothing else on the page. */
.wyldcards-list-folder-path {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin: 0 0 0.6rem;
}

.wyldcards-list-folder-back {
    font: inherit;
    font-size: 0.9rem;
    color: var(--link-fg, #2563eb);
    background: transparent;
    border: 0;
    padding: 0.2rem 0;
    cursor: pointer;
}

.wyldcards-list-folder-back:hover {
    text-decoration: underline;
}

.wyldcards-list-folder-here {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
    flex: 1 1 auto;
}

.wyldcards-list-folder-here-mark {
    font-size: 1rem;
}

.wyldcards-list-folder-new {
    display: flex;
}

.wyldcards-list-folder-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.wyldcards-list-folder-badge {
    display: inline-block;
    font-size: 0.7rem;
    color: var(--muted-fg, #64748b);
    border: 1px solid color-mix(in srgb, var(--muted-fg, #64748b) 25%, transparent);
    border-radius: 999px;
    padding: 0.12rem 0.5rem;
}

/* The per-card and per-selection folder pickers, sized down so neither becomes
   the widest thing in its row. */
.wyldcards-list-folder-select,
#wyldcards-list-folder-selected {
    font-size: 0.85rem;
    max-width: 10rem;
}

.wyldcards-list-folder-bulk {
    display: inline-flex;
    align-items: center;
    margin: 0;
}

/* The card's own picker sits on a line of its own under the actions, out of
   the title container so an inline rename cannot swap it away. Right-aligned
   so it reads as a property of the card rather than as another button. */
.wyldcards-list-folder-row {
    display: flex;
    justify-content: flex-end;
    margin: 0.35rem 0 0;
}

.wyldcards-list-bulkbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.6rem;
    flex-wrap: wrap;
}

.wyldcards-list-select-all {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    vertical-align: middle;
    margin: 0;
    font-size: 0.85rem;
    color: var(--muted-fg, #64748b);
    cursor: pointer;
    user-select: none;
}

.wyldcards-list-select-all input[type="checkbox"] {
    margin: 0;
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--accent, #475569);
}

.wyldcards-list-download-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    margin: 0;
    padding: 0.45rem 0.95rem;
    border-radius: 8px;
    border: 1px solid var(--border, #cbd5e1);
    background: transparent;
    color: inherit !important;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none !important;
    white-space: nowrap;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.wyldcards-list-download-btn:hover,
.wyldcards-list-download-btn:focus-visible {
    border-color: var(--accent, #475569);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
    text-decoration: none !important;
}

.wyldcards-list-download-btn.is-disabled {
    opacity: 0.5;
    pointer-events: none;
    transform: none;
    box-shadow: none;
}

.wyldcards-list-sort-label {
    margin: 0;
}

.wyldcards-list-sort {
    margin: 0;
    padding: 0.5rem 2rem 0.5rem 0.8rem;
    border-radius: 8px;
    border: 1px solid var(--border, #cbd5e1);
    background-color: var(--box-bg, #ffffff);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.7rem center;
    background-size: 0.75rem;
    font-size: 0.875rem;
    color: var(--fg, inherit);
    cursor: pointer;
    appearance: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.wyldcards-list-sort:focus {
    outline: none;
    border-color: var(--accent, #475569);
    box-shadow: 0 0 0 3px rgba(71, 85, 105, 0.12);
}

.wyldcards-list-search-wrap {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1 1 280px;
    max-width: 420px;
    border-radius: 8px;
    border: 1px solid var(--border, #cbd5e1);
    background: var(--box-bg, #ffffff);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.wyldcards-list-search-wrap:focus-within {
    border-color: var(--accent, #475569);
    box-shadow: 0 0 0 3px rgba(71, 85, 105, 0.12);
}

.wyldcards-list-search-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-left: 0.85rem;
    color: var(--muted-fg, #64748b);
    pointer-events: none;
}

input.wyldcards-list-search {
    flex: 1;
    min-width: 0;
    width: auto;
    margin: 0;
    padding: 0.55rem 0.5rem 0.55rem 0.5rem;
    border: none;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    font-size: 0.9rem;
}

input.wyldcards-list-search::placeholder,
input.wyldcards-list-search-input::placeholder {
    color: var(--muted-fg, #94a3b8);
    /* missing.css right-aligns placeholders; keep ours next to the search icon */
    text-align: left;
}

input.wyldcards-list-search:focus,
input.wyldcards-list-search:focus-visible {
    outline: none;
    border: none;
    box-shadow: none;
}

input.wyldcards-list-search::-webkit-search-decoration,
input.wyldcards-list-search::-webkit-search-cancel-button,
input.wyldcards-list-search::-webkit-search-results-button,
input.wyldcards-list-search::-webkit-search-results-decoration {
    -webkit-appearance: none;
    appearance: none;
}

.wyldcards-list-search-clear {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.65rem;
    height: 1.65rem;
    margin-right: 0.4rem;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--muted-fg, #64748b);
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
}

.wyldcards-list-search-clear:hover,
.wyldcards-list-search-clear:focus-visible {
    background: var(--accent-bg, rgba(0, 0, 0, 0.05));
    color: var(--fg, inherit);
}

.wyldcards-list-search-clear[hidden] {
    display: none;
}

.wyldcards-search-dropdown {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    position: relative;
    flex: 0 0 auto;
    min-width: 0;
    margin-left: auto;
}

.wyldcards-search-dropdown .wyldcards-search-wrap {
    display: none;
    flex: 1 1 auto;
    min-width: 0;
    max-width: 18rem;
}

.wyldcards-search-dropdown.is-open {
    flex: 1 1 14rem;
    max-width: min(22rem, calc(100% - 12rem));
}

.wyldcards-search-dropdown.is-open .wyldcards-search-wrap {
    display: flex;
}

.wyldcards-search-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin: 0;
    padding: 0;
    min-width: 2.25rem;
    min-height: 2.25rem;
    width: 2.25rem;
    height: 2.25rem;
    box-sizing: border-box;
    color: var(--fg, inherit);
    background: var(--interactive-bg, transparent);
    border: 1px solid var(--muted-fg, #64748b);
    border-radius: var(--border-radius, 4px);
    cursor: pointer;
}

.wyldcards-search-toggle:hover,
.wyldcards-search-toggle:focus-visible {
    filter: brightness(1.1);
    outline: none;
}

.wyldcards-search-dropdown.is-open .wyldcards-search-toggle,
.wyldcards-search-toggle[aria-expanded="true"] {
    box-shadow: 0 2px 4px -1px var(--fg) inset;
    background: var(--pressed-interactive-bg, var(--interactive-bg));
}

.wyldcards-search-toggle svg {
    display: block;
    width: 20px;
    height: 20px;
}

.wyldcards-search-icon {
    display: none;
}

.wyldcards-share-dropdown {
    display: inline-block;
    position: relative;
}

.wyldcards-share-dropdown .nav-dropdown-menu {
    display: none;
    right: 0;
    left: auto;
    min-width: min(22rem, calc(100vw - 2rem));
    max-width: min(24rem, calc(100vw - 2rem));
    padding: 0.75rem;
    z-index: 1300;
}

.wyldcards-share-dropdown.open .nav-dropdown-menu {
    display: block;
}

.wyldcards-view-dropdown {
    display: inline-block;
    position: relative;
}

.wyldcards-view-dropdown .nav-dropdown-menu {
    display: none;
    right: 0;
    left: auto;
    min-width: min(22rem, calc(100vw - 2rem));
    max-width: min(30rem, calc(100vw - 2rem));
    padding: 0.35rem;
    z-index: 1300;
}

.wyldcards-view-dropdown.open .nav-dropdown-menu {
    display: block;
}

/* More: the card toolbar's less frequent commands, in labelled-by-rule sections. */
.wyldcards-more-dropdown .nav-dropdown-menu {
    min-width: 13rem;
}
.wyldcards-view-dropdown .nav-dropdown-separator {
    margin: 0.3rem 0.45rem;
}
.wyldcards-view-dropdown .wyldcards-menu-form {
    display: block;
    margin: 0;
}
.wyldcards-view-dropdown button.nav-dropdown-item {
    font-family: inherit;
    min-height: 0;
}
.wyldcards-view-dropdown .nav-dropdown-item[role="menuitemcheckbox"]::after {
    content: "";
    margin-left: auto;
}
.wyldcards-view-dropdown .nav-dropdown-item[aria-checked="true"]::after {
    content: "\2713";
    color: var(--accent, #2563eb);
    font-weight: 700;
}
.wyldcards-view-dropdown .nav-dropdown-item.bad {
    color: var(--bad-fg, #b91c1c);
}

.file-dropdown {
    display: inline-block;
    position: relative;
}

.file-dropdown .nav-dropdown-menu.file-menu {
    display: none;
    min-width: 10.5rem;
    padding: 0.35rem;
}

.file-menu .nav-dropdown-item {
    font-size: 0.84rem;
    font-weight: 500;
}

.file-menu-label {
    padding: 0.35rem 0.65rem 0.15rem;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted, #888);
    user-select: none;
}

/* The song editor's menus now live inside .wyldcards-tools-group (see
   wyldcards/documents/edit.html), so the screenplay's open-state and
   left-alignment rules below reach them and the song-specific overrides that
   used to sit here are no longer needed.

   The group wraps on the screenplay because nine menus have to fit the 6in
   toolbar column. The song row holds four and spans the page, so it stays on
   one line — otherwise opening Edit > Search, which expands inline, pushes
   Tools onto a second row. */
.text-document-toolbar-row .wyldcards-tools-group {
    flex-wrap: nowrap;
}

/* The song editor's word-count readout rides the toolbar meta bar and is hidden
   unless the Tools > Word count toggle is on, mirroring the screenplay's
   .wyldcards-script-stats (word-count-toggle.js owns the html class). */
.song-word-count {
    white-space: nowrap;
}

html.wyldcards-word-count-hidden .song-word-count {
    display: none;
}

.wyldcards-tools-group .file-dropdown,
.wyldcards-tools-group .tools-dropdown,
.wyldcards-tools-group .element-type-dropdown,
.wyldcards-tools-group .script-edition-dropdown,
.wyldcards-tools-group .help-dropdown {
    display: inline-block;
    position: relative;
    z-index: 1;
}

.wyldcards-tools-group .file-dropdown.open,
.wyldcards-tools-group .tools-dropdown.open,
.wyldcards-tools-group .element-type-dropdown.open,
.wyldcards-tools-group .script-edition-dropdown.open,
.wyldcards-tools-group .help-dropdown.open {
    z-index: 1300;
}

.wyldcards-tools-group .file-dropdown .nav-dropdown-menu.file-menu,
.wyldcards-tools-group .tools-dropdown .nav-dropdown-menu.tools-menu,
.wyldcards-tools-group .element-type-dropdown .nav-dropdown-menu.element-type-menu,
.wyldcards-tools-group .script-edition-dropdown .nav-dropdown-menu.script-edition-menu,
.wyldcards-tools-group .help-dropdown .nav-dropdown-menu.help-dropdown-menu {
    display: none;
    left: 0;
    right: auto;
    min-width: 10.5rem;
    padding: 0.35rem;
    transform-origin: top left;
    z-index: 1300;
}

.wyldcards-tools-group .file-dropdown.open .nav-dropdown-menu.file-menu,
.wyldcards-tools-group .tools-dropdown.open .nav-dropdown-menu.tools-menu,
.wyldcards-tools-group .element-type-dropdown.open .nav-dropdown-menu.element-type-menu,
.wyldcards-tools-group .script-edition-dropdown.open .nav-dropdown-menu.script-edition-menu,
.wyldcards-tools-group .help-dropdown.open .nav-dropdown-menu.help-dropdown-menu {
    display: block;
}

.wyldcards-tools-group .help-dropdown .help-icon {
    display: none;
}

.wyldcards-tools-group .help-dropdown .help-toggle-btn {
    width: auto;
    height: auto;
    border-radius: var(--border-radius, 0.35rem);
    transform: none;
}

.wyldcards-tools-group .help-dropdown .help-toggle-btn:hover,
.wyldcards-tools-group .help-dropdown .help-toggle-btn:focus {
    transform: none;
}

.wyldcards-tools-group .help-dropdown .nav-dropdown-menu.help-dropdown-menu {
    min-width: 16.5rem;
    max-width: min(20rem, calc(100vw - 1.5rem));
}

.wyldcards-tools-group .script-edition-dropdown .nav-dropdown-menu.script-edition-menu {
    min-width: 14rem;
}

.wyldcards-tools-group .script-edition-toggle {
    max-width: 11rem;
}

.wyldcards-tools-group .script-edition-toggle-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    /* The standalone toggle sets its own smaller, bolder label; on the toolbar it
       has to read as a plain menu label like File and Edit beside it. */
    font-size: inherit;
    font-weight: inherit;
}

html.wyldcards-block-edit-locked .wyldcards-tools-group .script-edition-toggle .script-edition-toggle-lock{
    display: block;
}

.wyldcards-tools-group .wyldcards-search-dropdown {
    display: none;
    align-items: center;
    gap: 0.35rem;
    margin-left: 0;
    flex: 0 0 auto;
    max-width: none;
    z-index: 1;
}

.wyldcards-tools-group .wyldcards-search-dropdown.is-open,
.wyldcards-tools-group .wyldcards-search-dropdown.has-value {
    display: inline-flex;
}

.wyldcards-tools-group .wyldcards-search-dropdown.is-open {
    flex: 1 1 12rem;
    max-width: min(18rem, 100%);
    z-index: 1300;
}
.element-type-menu .nav-dropdown-item {
    font-size: 0.84rem;
    font-weight: 500;
}

.wyldcards-tools-group .view-dropdown,
.text-size-control .view-dropdown {
    display: inline-block;
    position: relative;
    z-index: 1;
}

.wyldcards-tools-group .view-dropdown.open,
.text-size-control .view-dropdown.open {
    z-index: 1300;
}
.tools-menu .nav-dropdown-item {
    font-size: 0.84rem;
    font-weight: 500;
    gap: 0.55rem;
}
.tools-menu .nav-dropdown-item svg {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
}
.tools-menu .nav-dropdown-item.is-active {
    color: inherit;
    font-weight: 500;
    background: none;
}
.tools-menu .nav-dropdown-item[aria-checked="true"] {
    color: var(--accent, #475569);
    font-weight: 600;
}
.tools-menu .nav-dropdown-item[aria-checked="true"]::after {
    content: "✓";
    margin-left: auto;
    font-size: 0.8rem;
    font-weight: 700;
}

.tools-menu-text-size {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.35rem 0.55rem;
    font-size: 0.84rem;
    font-weight: 500;
}

.tools-menu-text-size-label {
    color: var(--fg);
}
.tools-menu .text-size-buttons {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}
.tools-menu .text-size-btn {
    background: var(--interactive-bg);
    border: 1px solid var(--muted-fg);
    border-radius: var(--border-radius);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--fg);
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1;
    min-width: 2rem;
    min-height: 1.85rem;
    padding: 0 0.35rem;
    box-sizing: border-box;
    cursor: pointer;
}
.tools-menu .text-size-btn:hover,
.tools-menu .text-size-btn:focus {
    filter: brightness(1.1);
}
.tools-menu .text-size-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    filter: none;
}

.wyldcards-tools-group .view-toolbar-btn.is-active,
.text-size-control .view-toolbar-btn.is-active {
    color: var(--fg);
    border-color: var(--fg);
}

.wyldcards-share-intro {
    margin: 0 0 0.65rem;
    font-size: 0.85rem;
    line-height: 1.4;
}

.wyldcards-share-link-row {
    display: flex;
    align-items: stretch;
    gap: 0.35rem;
    margin-bottom: 0.85rem;
}

.wyldcards-share-link-input {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    padding: 0.35rem 0.55rem;
    font-size: 0.82rem;
    border: 1px solid var(--border, #cbd5e1);
    border-radius: 8px;
    background: var(--box-bg, #ffffff);
    color: var(--fg, inherit);
}

.wyldcards-share-copy-btn {
    flex: 0 0 auto;
    margin: 0;
    padding: 0.35rem 0.65rem;
    font-size: 0.82rem;
    border-radius: 8px;
    white-space: nowrap;
}

.wyldcards-share-access-title {
    margin: 0 0 0.35rem;
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.wyldcards-share-access-note,
.wyldcards-share-access-empty {
    margin: 0 0 0.5rem;
    font-size: 0.78rem;
    line-height: 1.35;
}

.wyldcards-share-user-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 12rem;
    overflow-y: auto;
    border: 1px solid var(--border, #cbd5e1);
    border-radius: 8px;
    background: var(--box-bg, #ffffff);
}

.wyldcards-share-user {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.45rem 0.6rem;
    font-size: 0.82rem;
    border-bottom: 1px solid var(--border, #e2e8f0);
}

.wyldcards-share-user:last-child {
    border-bottom: none;
}

.wyldcards-share-user-main {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
}

.wyldcards-share-user-name {
    font-weight: 500;
}

.wyldcards-share-user-access {
    font-size: 0.75rem;
}

.wyldcards-share-invite-form {
    margin-top: 0.75rem;
}

.wyldcards-share-invite-form > label {
    display: block;
    margin-bottom: 0.3rem;
    font-size: 0.82rem;
    font-weight: 600;
}

.wyldcards-share-invite-row {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.wyldcards-share-invite-row input {
    flex: 1 1 9rem;
    min-width: 0;
}

.wyldcards-share-invite-row select,
.wyldcards-share-invite-row button,
.wyldcards-share-invite-row input {
    margin: 0;
    padding: 0.35rem 0.5rem;
    font-size: 0.8rem;
}

.wyldcards-share-invite-form p {
    margin: 0.35rem 0 0;
    font-size: 0.75rem;
    line-height: 1.35;
}

.access-permission-chip {
    flex-shrink: 0;
    display: inline-block;
    padding: 0.12rem 0.45rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    line-height: 1.3;
    white-space: nowrap;
}

.access-permission-chip--edit {
    color: #166534;
    background: #dcfce7;
}

.access-permission-chip--view {
    color: #475569;
    background: #e2e8f0;
}

.wyldcards-share-manage-link {
    display: inline-block;
    margin-top: 0.65rem;
    font-size: 0.82rem;
}

.wyldcards-share-flash {
    margin: 0 0 0.45rem;
    font-size: 0.78rem;
    line-height: 1.35;
}

.wyldcards-share-flash-success {
    color: #166534;
}

.wyldcards-share-flash-error {
    color: #b91c1c;
}

.invite-email-note {
    margin: 0 0 0.75rem;
    font-size: 0.9rem;
}

.field-error {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.78rem;
    color: #b91c1c;
}

.wyldcards-search-wrap {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 2.25rem;
    border-radius: 8px;
    border: 1px solid var(--border, #cbd5e1);
    background: var(--box-bg, #ffffff);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.wyldcards-search-wrap:focus-within {
    border-color: var(--accent, #475569);
    box-shadow: 0 0 0 3px rgba(71, 85, 105, 0.12);
}

.wyldcards-search-input {
    flex: 1;
    min-width: 0;
    width: 100%;
    margin: 0;
    padding: 0.5rem 0.55rem 0.5rem 0.75rem;
    border: none;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    font-size: 0.9rem;
    line-height: 1.2;
}

.wyldcards-search-input::placeholder {
    color: var(--muted-fg, #94a3b8);
}

.wyldcards-search-input:focus,
.wyldcards-search-input:focus-visible {
    outline: none;
    border: none;
    box-shadow: none;
}

.wyldcards-search-input::-webkit-search-decoration,
.wyldcards-search-input::-webkit-search-cancel-button,
.wyldcards-search-input::-webkit-search-results-button,
.wyldcards-search-input::-webkit-search-results-decoration {
    -webkit-appearance: none;
    appearance: none;
}

.wyldcards-search-clear {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 1.75rem;
    height: 1.75rem;
    margin-right: 0.4rem;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--muted-fg, #64748b);
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
}

.wyldcards-search-clear:hover,
.wyldcards-search-clear:focus-visible {
    background: var(--accent-bg, rgba(0, 0, 0, 0.05));
    color: var(--fg, inherit);
}

.wyldcards-search-clear[hidden] {
    display: none;
}

/* --- Find & replace ---------------------------------------------------- */

/* Replace mode stacks find / replace / options, so the strip becomes a column. */
.wyldcards-search-dropdown[data-mode="replace"].is-open {
    flex-direction: column;
    align-items: stretch;
    gap: 0.35rem;
    flex: 1 1 20rem;
    max-width: min(26rem, calc(100% - 8rem));
}

.wyldcards-search-dropdown[data-mode="replace"] .wyldcards-search-wrap {
    max-width: none;
}

.wyldcards-search-count {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    padding: 0 0.4rem;
    color: var(--muted-fg, #64748b);
    font-size: 0.75rem;
    white-space: nowrap;
}

.wyldcards-search-count[hidden],
.wyldcards-search-nav[hidden],
.wyldcards-replace-wrap[hidden],
.wyldcards-replace-options[hidden] {
    display: none;
}

.wyldcards-search-nav {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
    vertical-align: middle;
}

.wyldcards-search-nav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--muted-fg, #64748b);
    font-size: 0.8rem;
    line-height: 1;
    cursor: pointer;
}

.wyldcards-search-nav-btn:hover,
.wyldcards-search-nav-btn:focus-visible {
    background: var(--accent-bg, rgba(0, 0, 0, 0.05));
    color: var(--fg, inherit);
}

.wyldcards-replace-wrap {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    width: 100%;
    min-height: 2.25rem;
    border-radius: 8px;
    border: 1px solid var(--border, #cbd5e1);
    background: var(--box-bg, #ffffff);
}

.wyldcards-replace-wrap:focus-within {
    border-color: var(--accent, #475569);
    box-shadow: 0 0 0 3px rgba(71, 85, 105, 0.12);
}

.wyldcards-replace-input {
    flex: 1;
    min-width: 0;
    margin: 0;
    padding: 0.5rem 0.55rem 0.5rem 0.75rem;
    border: none;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    font-size: 0.9rem;
    line-height: 1.2;
}

.wyldcards-replace-input:focus,
.wyldcards-replace-input:focus-visible {
    outline: none;
    border: none;
    box-shadow: none;
}

.wyldcards-replace-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    flex-shrink: 0;
    margin-right: 0.35rem;
    vertical-align: middle;
}

.wyldcards-replace-btn {
    padding: 0.25rem 0.6rem;
    border: 1px solid var(--border, #cbd5e1);
    border-radius: 6px;
    background: transparent;
    color: var(--fg, inherit);
    font-size: 0.78rem;
    line-height: 1.4;
    white-space: nowrap;
    cursor: pointer;
}

.wyldcards-replace-btn:hover,
.wyldcards-replace-btn:focus-visible {
    background: var(--accent-bg, rgba(0, 0, 0, 0.05));
    border-color: var(--accent, #475569);
}

.wyldcards-replace-options {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.15rem 0.75rem;
    padding: 0 0.2rem;
}

.wyldcards-replace-option {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    margin: 0;
    color: var(--muted-fg, #64748b);
    font-size: 0.75rem;
    line-height: 1.4;
    white-space: nowrap;
    cursor: pointer;
    vertical-align: middle;
}

.wyldcards-replace-option input[type="checkbox"] {
    width: 0.85rem;
    height: 0.85rem;
    margin: 0;
    flex-shrink: 0;
}

mark.wyldcards-search-hit {
    padding: 0 1px;
    border-radius: 2px;
    background: var(--search-hit-bg, #fde68a);
    /* Fixed dark ink: the highlight stays amber in both themes, so inheriting a
       light foreground would make the hit unreadable in dark mode. */
    color: #1f2937;
}

html.wyldcards-hide-block-bookmarks .block-action-bookmark {
    display: none !important;
}

html.wyldcards-hide-block-pins .block-action-pin {
    display: none !important;
}

html.wyldcards-hide-block-select .block-select-checkbox,
html.wyldcards-hide-block-select a.create-below[role="button"],
html.wyldcards-hide-block-select .create-below-menu-dropdown,
html.wyldcards-hide-block-select button.create-below.create-below-menu-toggle,
html.wyldcards-hide-block-select .drag-handle,
html.wyldcards-hide-block-select .block-drag-menu-dropdown,
html.wyldcards-hide-block-select .block-actions-controls,
html.wyldcards-hide-block-select .block-left-controls-inner > .block-select-all-slot{
    visibility: hidden;
    pointer-events: none;
}

html.wyldcards-hide-block-select .wyldcards-script-select-row {
    display: none;
}

html.wyldcards-hide-block-select .wyldcards-script aside.block-left-controls,
html.wyldcards-hide-block-select #table-blocks aside.block-left-controls,
html.wyldcards-hide-block-select .table-blocks-all aside.block-left-controls,
html.wyldcards-hide-block-select .wyldcards-script aside.block-actions,
html.wyldcards-hide-block-select #table-blocks aside.block-actions,
html.wyldcards-hide-block-select .table-blocks-all aside.block-actions {
    visibility: hidden;
    pointer-events: none;
}

/* Hover reveals only when no block has the text cursor — otherwise the
   focused/cursor block wins (important after Enter creates a new row while
   the pointer is still over the previous one). */
html.wyldcards-hide-block-select:not(:has(.block-row:focus-within, tr[data-block-id]:focus-within, tr:focus-within)) .block-row:hover:not(.wyldcards-script-select-row) .block-select-checkbox,
html.wyldcards-hide-block-select:not(:has(.block-row:focus-within, tr[data-block-id]:focus-within, tr:focus-within)) .block-row:hover:not(.wyldcards-script-select-row) a.create-below[role="button"],
html.wyldcards-hide-block-select:not(:has(.block-row:focus-within, tr[data-block-id]:focus-within, tr:focus-within)) .block-row:hover:not(.wyldcards-script-select-row) .create-below-menu-dropdown,
html.wyldcards-hide-block-select:not(:has(.block-row:focus-within, tr[data-block-id]:focus-within, tr:focus-within)) .block-row:hover:not(.wyldcards-script-select-row) button.create-below.create-below-menu-toggle,
html.wyldcards-hide-block-select:not(:has(.block-row:focus-within, tr[data-block-id]:focus-within, tr:focus-within)) .block-row:hover:not(.wyldcards-script-select-row) .drag-handle,
html.wyldcards-hide-block-select:not(:has(.block-row:focus-within, tr[data-block-id]:focus-within, tr:focus-within)) .block-row:hover:not(.wyldcards-script-select-row) .block-drag-menu-dropdown,
html.wyldcards-hide-block-select:not(:has(.block-row:focus-within, tr[data-block-id]:focus-within, tr:focus-within)) tr:hover .block-select-checkbox,
html.wyldcards-hide-block-select:not(:has(.block-row:focus-within, tr[data-block-id]:focus-within, tr:focus-within)) tr:hover a.create-below[role="button"],
html.wyldcards-hide-block-select:not(:has(.block-row:focus-within, tr[data-block-id]:focus-within, tr:focus-within)) tr:hover .create-below-menu-dropdown,
html.wyldcards-hide-block-select:not(:has(.block-row:focus-within, tr[data-block-id]:focus-within, tr:focus-within)) tr:hover button.create-below.create-below-menu-toggle,
html.wyldcards-hide-block-select:not(:has(.block-row:focus-within, tr[data-block-id]:focus-within, tr:focus-within)) tr:hover .drag-handle,
html.wyldcards-hide-block-select:not(:has(.block-row:focus-within, tr[data-block-id]:focus-within, tr:focus-within)) tr:hover .block-drag-menu-dropdown,
html.wyldcards-hide-block-select .block-row:focus-within:not(.wyldcards-script-select-row) .block-select-checkbox,
html.wyldcards-hide-block-select .block-row:focus-within:not(.wyldcards-script-select-row) a.create-below[role="button"],
html.wyldcards-hide-block-select .block-row:focus-within:not(.wyldcards-script-select-row) .create-below-menu-dropdown,
html.wyldcards-hide-block-select .block-row:focus-within:not(.wyldcards-script-select-row) button.create-below.create-below-menu-toggle,
html.wyldcards-hide-block-select .block-row:focus-within:not(.wyldcards-script-select-row) .drag-handle,
html.wyldcards-hide-block-select .block-row:focus-within:not(.wyldcards-script-select-row) .block-drag-menu-dropdown,
html.wyldcards-hide-block-select .block-row.block-controls-revealed .block-select-checkbox,
html.wyldcards-hide-block-select .block-row.block-controls-revealed a.create-below[role="button"],
html.wyldcards-hide-block-select .block-row.block-controls-revealed .create-below-menu-dropdown,
html.wyldcards-hide-block-select .block-row.block-controls-revealed button.create-below.create-below-menu-toggle,
html.wyldcards-hide-block-select .block-row.block-controls-revealed .drag-handle,
html.wyldcards-hide-block-select .block-row.block-controls-revealed .block-drag-menu-dropdown,
html.wyldcards-hide-block-select tr:focus-within .block-select-checkbox,
html.wyldcards-hide-block-select tr:focus-within a.create-below[role="button"],
html.wyldcards-hide-block-select tr:focus-within .create-below-menu-dropdown,
html.wyldcards-hide-block-select tr:focus-within button.create-below.create-below-menu-toggle,
html.wyldcards-hide-block-select tr:focus-within .drag-handle,
html.wyldcards-hide-block-select tr:focus-within .block-drag-menu-dropdown,
html.wyldcards-hide-block-select tr.block-controls-revealed .block-select-checkbox,
html.wyldcards-hide-block-select tr.block-controls-revealed a.create-below[role="button"],
html.wyldcards-hide-block-select tr.block-controls-revealed .create-below-menu-dropdown,
html.wyldcards-hide-block-select tr.block-controls-revealed button.create-below.create-below-menu-toggle,
html.wyldcards-hide-block-select tr.block-controls-revealed .drag-handle,
html.wyldcards-hide-block-select tr.block-controls-revealed .block-drag-menu-dropdown {
    visibility: visible;
    pointer-events: auto;
}

html.wyldcards-hide-block-select:not(:has(.block-row:focus-within, tr[data-block-id]:focus-within, tr:focus-within)) .block-row:hover:not(.wyldcards-script-select-row) aside.block-left-controls,
html.wyldcards-hide-block-select:not(:has(.block-row:focus-within, tr[data-block-id]:focus-within, tr:focus-within)) tr:hover td.block-left-controls,
html.wyldcards-hide-block-select .block-row:focus-within:not(.wyldcards-script-select-row) aside.block-left-controls,
html.wyldcards-hide-block-select .block-row.block-controls-revealed aside.block-left-controls,
html.wyldcards-hide-block-select tr:focus-within td.block-left-controls,
html.wyldcards-hide-block-select tr.block-controls-revealed td.block-left-controls {
    visibility: visible;
    pointer-events: auto;
}

/* An open menu keeps its own controls revealed. :hover drops the moment the
   pointer moves onto the menu, and :focus-within cannot cover for it — WebKit
   does not focus a <button> on click, so the handle never takes focus there.
   Without this the dropdown stays .open but goes visibility: hidden.
   Mirrors .song-block-row:has(.song-block-menu-dropdown.open). */
html.wyldcards-hide-block-select .block-row:has(.block-drag-menu-dropdown.open, .create-below-menu-dropdown.open):not(.wyldcards-script-select-row) aside.block-left-controls,
html.wyldcards-hide-block-select tr:has(.block-drag-menu-dropdown.open, .create-below-menu-dropdown.open) td.block-left-controls,
html.wyldcards-hide-block-select .block-drag-menu-dropdown.open,
html.wyldcards-hide-block-select .block-drag-menu-dropdown.open .drag-handle,
html.wyldcards-hide-block-select .create-below-menu-dropdown.open,
html.wyldcards-hide-block-select .create-below-menu-dropdown.open a.create-below[role="button"],
html.wyldcards-hide-block-select .create-below-menu-dropdown.open button.create-below.create-below-menu-toggle {
    visibility: visible;
    pointer-events: auto;
}

html.wyldcards-hide-block-select .create-below-menu-dropdown.open a.create-below[role="button"],
html.wyldcards-hide-block-select .create-below-menu-dropdown.open button.create-below.create-below-menu-toggle {
    opacity: 1;
}

html.wyldcards-hide-block-select:not(:has(.block-row:focus-within, tr[data-block-id]:focus-within, tr:focus-within)) .block-row:hover:not(.wyldcards-script-select-row) a.create-below[role="button"],
html.wyldcards-hide-block-select:not(:has(.block-row:focus-within, tr[data-block-id]:focus-within, tr:focus-within)) tr:hover a.create-below[role="button"],
html.wyldcards-hide-block-select:not(:has(.block-row:focus-within, tr[data-block-id]:focus-within, tr:focus-within)) .block-row:hover:not(.wyldcards-script-select-row) button.create-below.create-below-menu-toggle,
html.wyldcards-hide-block-select:not(:has(.block-row:focus-within, tr[data-block-id]:focus-within, tr:focus-within)) tr:hover button.create-below.create-below-menu-toggle,
html.wyldcards-hide-block-select .block-row:focus-within:not(.wyldcards-script-select-row) a.create-below[role="button"],
html.wyldcards-hide-block-select .block-row.block-controls-revealed a.create-below[role="button"],
html.wyldcards-hide-block-select tr:focus-within a.create-below[role="button"],
html.wyldcards-hide-block-select tr.block-controls-revealed a.create-below[role="button"],
html.wyldcards-hide-block-select .block-row:focus-within:not(.wyldcards-script-select-row) button.create-below.create-below-menu-toggle,
html.wyldcards-hide-block-select .block-row.block-controls-revealed button.create-below.create-below-menu-toggle,
html.wyldcards-hide-block-select tr:focus-within button.create-below.create-below-menu-toggle,
html.wyldcards-hide-block-select tr.block-controls-revealed button.create-below.create-below-menu-toggle {
    opacity: 1;
}

html.wyldcards-hide-block-select:not(:has(.block-row:focus-within, tr[data-block-id]:focus-within, tr:focus-within)) .block-row:hover:not(.wyldcards-script-select-row) button.block-drag-menu-toggle.nav-dropdown-toggle,
html.wyldcards-hide-block-select:not(:has(.block-row:focus-within, tr[data-block-id]:focus-within, tr:focus-within)) tr:hover button.block-drag-menu-toggle.nav-dropdown-toggle,
html.wyldcards-hide-block-select .block-row:focus-within:not(.wyldcards-script-select-row) button.block-drag-menu-toggle.nav-dropdown-toggle,
html.wyldcards-hide-block-select .block-row.block-controls-revealed button.block-drag-menu-toggle.nav-dropdown-toggle,
html.wyldcards-hide-block-select tr:focus-within button.block-drag-menu-toggle.nav-dropdown-toggle,
html.wyldcards-hide-block-select tr.block-controls-revealed button.block-drag-menu-toggle.nav-dropdown-toggle {
    color: var(--accent, #475569);
    background-color: var(--accent-bg, rgba(0, 0, 0, 0.05));
}

@keyframes block-caret-preview-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

html.wyldcards-hide-block-element-labels .block-element-label {
    display: none !important;
}

/* Show/hide comments: Note blocks act as screenplay comments/annotations. */
html.wyldcards-hide-block-notes .block-row[data-block-type="NOTE"] {
    display: none !important;
}

.wyldcards-script .block-element-label {
    grid-column: 1;
    grid-row: 1;
    justify-self: start;
    align-self: start;
    width: auto;
    max-width: 4.5rem;
    margin-left: 0;
    padding: 0.05rem 0.35rem;
    font-size: 0.58rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    line-height: 1.3;
    text-align: left;
    text-transform: uppercase;
    color: var(--muted-fg, #64748b);
    background: color-mix(in srgb, var(--accent-bg, #f1f5f9) 80%, transparent);
    border: 1px solid color-mix(in srgb, var(--border, #cbd5e1) 70%, transparent);
    border-radius: 999px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
    user-select: none;
    transform: translateX(calc(-100% - 0.45rem));
}

tr:not([data-block-id]) .block-select-checkbox {
    pointer-events: none;
    cursor: default;
}

html.wyldcards-block-edit-locked .wyldcards-script .block-content {
    cursor: default;
}

html.wyldcards-block-edit-locked .wyldcards-script .block-content form[hx-post*="/block/editInline"] textarea {
    pointer-events: none;
}

.text-size-control .spellcheck-toggle-btn {
    font-size: 1rem;
    line-height: 1;
}

.wyldcards-list-no-results {
    margin: 0;
    padding: 2.25rem 1.5rem;
    text-align: center;
    color: var(--muted-fg, #64748b);
    font-size: 0.95rem;
}

.wyldcards-list-no-results strong {
    color: var(--fg, inherit);
    font-weight: 600;
}

.wyldcards-list-panel {
    margin: 0;
}

/* Card list — mirrors the Songs/Notes document list (.text-documents-list /
   .text-document-card) so Wyldcards reads as the same component family. */
.wyldcards-list-cards {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.wyldcards-list-card {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 1.05rem 1.15rem;
    border: 1px solid var(--pl-line, var(--border, #cbd5e1));
    border-left: 3px solid color-mix(in srgb, var(--pl-mark, var(--accent, #475569)) 55%, var(--pl-line, var(--border, #cbd5e1)));
    border-radius: calc(var(--border-radius, 0.5rem) + 2px);
    background: var(--box-bg, var(--bg, #fff));
    box-shadow: 0 1px 0 color-mix(in srgb, var(--fg, #000) 4%, transparent);
    transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
    animation: text-documents-rise 0.4s ease both;
    animation-delay: calc(0.04s * var(--card-i, 0));
}

.wyldcards-list-card:hover {
    border-color: color-mix(in srgb, var(--accent, #475569) 45%, var(--pl-line, var(--border, #cbd5e1)));
    box-shadow: 0 8px 22px -16px color-mix(in srgb, var(--fg, #000) 45%, transparent);
    transform: translateY(-1px);
}

@media (prefers-reduced-motion: reduce) {
    .wyldcards-list-card {
        animation: none !important;
    }
}

/* Selection checkbox sits at the head of each card row (see the bulk-download
   bar). Table-cell wrappers from the original table layout are dropped — the
   card is a flex row, so the checkbox aligns itself. */
.wyldcards-list-select-checkbox {
    margin: 0;
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--accent, #475569);
    flex: 0 0 auto;
    align-self: center;
}

.wyldcards-list-star {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    align-self: flex-start;
    padding-top: 0.1rem;
}

.wyldcards-list-star-form {
    margin: 0;
    display: inline-flex;
}

/* The archive button posts a form, so the form itself must not take part in
   the actions row's layout. */
.wyldcards-list-archive-form {
    margin: 0;
    display: inline-flex;
}

.wyldcards-title-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    width: 100%;
    min-width: 0;
    flex: 1;
}

.wyldcards-list-title-wrap {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.3rem;
    min-width: 0;
    flex: 1;
}

.wyldcards-list-title-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    flex-wrap: wrap;
}

.wyldcards-list-meta {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    min-width: 0;
    flex-wrap: wrap;
}

.wyldcards-list-meta-sep {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--muted-fg, #94a3b8);
    opacity: 0.7;
    flex-shrink: 0;
}

.wyldcards-list-last-edited {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.78rem;
    color: var(--muted-fg, #64748b);
    white-space: nowrap;
}

.wyldcards-list-last-edited svg {
    opacity: 0.75;
    flex-shrink: 0;
}

.wyldcards-last-edited {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    line-height: 1.2;
    color: var(--muted-fg, #64748b);
}

.wyldcards-last-edited svg {
    opacity: 0.7;
    flex-shrink: 0;
    width: 12px;
    height: 12px;
}

.wyldcards-last-edited-line {
    margin: 0;
    font-size: 0.8rem;
    line-height: 1.2;
}

.wyldcards-header-row {
    display: inline-flex;
    align-items: baseline;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.65rem;
    max-width: 100%;
}

.wyldcards-header-row .wyldcards-last-edited-line {
    font-weight: normal;
    white-space: nowrap;
}

.breadcrumb-name-meta {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.65rem;
    min-width: 0;
    max-width: 100%;
}

.breadcrumb-name-meta .wyldcards-breadcrumb-name-wrap {
    min-width: 0;
    max-width: 100%;
}

.breadcrumb-name-meta .wyldcards-last-edited-line {
    white-space: nowrap;
    flex-shrink: 0;
}

.top-bar-start {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
    flex: 1 1 auto;
}

.top-bar-start nav[aria-label="Breadcrumb"] {
    margin: 0 !important;
}

.top-bar-start .wyldcards-last-edited-line {
    margin: 0;
}

.wyldcards-list-title {
    font-size: 1.08rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--fg, inherit);
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: color 0.15s ease;
}

.wyldcards-list-title:hover {
    color: var(--accent, #475569);
    text-decoration: none;
}

.wyldcards-list-default-label {
    flex-shrink: 0;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 0.12rem 0.4rem;
    border-radius: 4px;
    background: rgba(245, 158, 11, 0.15);
    color: #b45309;
}

:root.-dark-theme .wyldcards-list-default-label {
    color: #fbbf24;
}

@media (prefers-color-scheme: dark) {
    :root:not(.-no-dark-theme) .wyldcards-list-default-label {
        color: #fbbf24;
    }
}

.wyldcards-list-actions {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    flex-shrink: 0;
    flex-wrap: nowrap;
}

.wyldcards-list-actions .wyldcards-list-action-btn--icon {
    opacity: 0.55;
    transition: opacity 0.15s ease, border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.wyldcards-list-row:hover .wyldcards-list-actions .wyldcards-list-action-btn--icon,
.wyldcards-list-row:focus-within .wyldcards-list-actions .wyldcards-list-action-btn--icon {
    opacity: 1;
}

.wyldcards-list-action-btn,
.user-list-create-btn,
.user-form-cancel,
.user-form-submit,
.login-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    margin: 0;
    padding: 0.4rem 0.7rem;
    border-radius: 7px;
    border: 1px solid var(--border, #cbd5e1);
    background: var(--box-bg, #ffffff);
    color: var(--fg, inherit);
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    text-decoration: none !important;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease, opacity 0.15s ease;
}

.wyldcards-list-action-btn svg,
.user-form-cancel svg,
.user-form-submit svg,
.login-submit svg {
    flex-shrink: 0;
    opacity: 0.9;
}

.wyldcards-list-action-btn--primary,
.user-list-create-btn,
.user-form-submit,
.login-submit {
    background: var(--accent, #475569);
    border-color: var(--accent, #475569);
    color: #fff !important;
    box-shadow: none;
}

.wyldcards-list-action-btn--primary:hover,
.wyldcards-list-action-btn--primary:focus-visible,
.user-list-create-btn:hover,
.user-list-create-btn:focus-visible {
    filter: brightness(0.92);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
    color: #fff !important;
    text-decoration: none !important;
}

.user-form-submit:hover,
.user-form-submit:focus-visible,
.login-submit:hover,
.login-submit:focus-visible {
    filter: brightness(0.92);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
    color: #fff !important;
}

/* The dark theme's accent is a pale blue, and white text on it was close to
   unreadable. Use the page ground as the ink instead. */
:root.-dark-theme :is(.wyldcards-list-action-btn--primary, .user-list-create-btn, .user-form-submit, .login-submit),
:root.-dark-theme :is(.wyldcards-list-action-btn--primary, .user-list-create-btn, .user-form-submit, .login-submit):is(:hover, :focus-visible) {
    color: var(--bg, #121210) !important;
}
@media (prefers-color-scheme: dark) {
    :root:not(.-no-dark-theme) :is(.wyldcards-list-action-btn--primary, .user-list-create-btn, .user-form-submit, .login-submit),
    :root:not(.-no-dark-theme) :is(.wyldcards-list-action-btn--primary, .user-list-create-btn, .user-form-submit, .login-submit):is(:hover, :focus-visible) {
        color: var(--bg, #121210) !important;
    }
}

.user-form-cancel:hover,
.user-form-cancel:focus-visible,
.wyldcards-list-action-btn:not(.wyldcards-list-action-btn--primary):not(.bad):hover,
.wyldcards-list-action-btn:not(.wyldcards-list-action-btn--primary):not(.bad):focus-visible {
    border-color: var(--accent, #475569);
    background: var(--accent-bg, rgba(0, 0, 0, 0.03));
    color: var(--accent, #475569);
}

/* Every destructive action uses the same restrained red treatment. */
.wyldcards-list-action-btn.bad,
.user-form-actions .bad,
.user-form-card .bad {
    border-color: rgba(211, 47, 47, 0.35);
    background: rgba(211, 47, 47, 0.08);
    color: var(--bad-fg, #d32f2f);
    font-weight: 600;
}

.wyldcards-list-action-btn.bad:hover,
.wyldcards-list-action-btn.bad:focus-visible,
.user-form-actions .bad:hover,
.user-form-actions .bad:focus-visible,
.user-form-card .bad:hover,
.user-form-card .bad:focus-visible {
    border-color: var(--bad-fg, #d32f2f);
    background: rgba(211, 47, 47, 0.14);
    color: var(--bad-fg, #d32f2f);
}

.wyldcards-list-action-btn--secondary {
    background: transparent;
    border-color: var(--border, #cbd5e1);
    color: var(--fg, inherit);
    font-weight: 500;
}

.wyldcards-list-action-btn--secondary:hover,
.wyldcards-list-action-btn--secondary:focus-visible {
    border-color: var(--accent, #475569);
    color: var(--accent, #475569) !important;
    background: var(--accent-bg, rgba(0, 0, 0, 0.03));
}

.wyldcards-list-action-btn--ghost {
    border-color: transparent;
    background: transparent;
    color: var(--muted-fg, #64748b);
    font-weight: 500;
}

.wyldcards-list-action-btn--ghost:hover,
.wyldcards-list-action-btn--ghost:focus-visible {
    border-color: var(--border, #cbd5e1);
    background: var(--accent-bg, rgba(0, 0, 0, 0.03));
    color: var(--fg, inherit);
}

/* The selection buttons — Archive, Delete, Unarchive — start disabled and stay
   that way until rows are ticked, and until now a disabled one was pixel for
   pixel an enabled one: full opacity, pointing cursor, primary blue. The only
   way to learn it did nothing was to press it. Nothing here is per-variant, so
   the primary form stops shouting for a press it will not accept. */
.wyldcards-list-action-btn:disabled,
.wyldcards-list-action-btn[disabled] {
    opacity: 0.45;
    cursor: default;
    box-shadow: none;
}

.wyldcards-list-action-btn:disabled:hover,
.wyldcards-list-action-btn[disabled]:hover {
    border-color: inherit;
    background: inherit;
}

.wyldcards-list-action-btn--icon {
    width: 2rem;
    height: 2rem;
    padding: 0;
    border-color: transparent;
    background: transparent;
    color: var(--muted-fg, #64748b);
    font-weight: 500;
}

.wyldcards-list-action-btn--icon:hover,
.wyldcards-list-action-btn--icon:focus-visible {
    border-color: var(--border, #cbd5e1);
    background: var(--accent-bg, rgba(0, 0, 0, 0.04));
    color: var(--fg, inherit);
}

.wyldcards-list-actions-divider {
    width: 1px;
    height: 1.25rem;
    background: var(--border, #cbd5e1);
    margin: 0 0.1rem;
    flex-shrink: 0;
}

.wyldcards-list-delete-btn {
    border-color: transparent;
    background: transparent;
    color: var(--muted-fg, #64748b);
    font-weight: 500;
    opacity: 1;
}

.wyldcards-list-delete-btn:hover,
.wyldcards-list-delete-btn:focus-visible {
    border-color: rgba(211, 47, 47, 0.3);
    background: rgba(211, 47, 47, 0.08);
    color: var(--bad-fg, #d32f2f) !important;
}

.wyldcards-list-rename-form {
    width: 100%;
    margin: 0;
}

.wyldcards-list-rename-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
}

.wyldcards-list-rename-input {
    flex: 1;
    min-width: 0;
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.wyldcards-list-rename-error {
    display: block;
    margin-top: 0.35rem;
    color: var(--bad-fg, #d32f2f);
    font-size: 0.85rem;
}

.wyldcards-script header {
    text-align: center;
}

.wyldcards-header-title {
    margin: 0;
    font-size: inherit;
    font-weight: inherit;
    line-height: inherit;
    letter-spacing: normal;
    text-transform: none;
    text-align: center;
}

.wyldcards-script .wyldcards-header-title {
    margin-bottom: 0;
}

.wyldcards-script-header {
    margin-bottom: 1.25rem;
    width: 100%;
    text-align: center;
}

/* Visible h1 — Safari Reader drops clipped/sr-only titles */
.wyldcards-script-header .wyldcards-header-title {
    margin: 0 0 0.35rem;
    font-family: 'Courier New', Courier, monospace;
    font-size: calc(14pt * var(--wyldcards-text-scale, 1));
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: 0.02em;
    text-transform: none;
    text-align: center;
}

.wyldcards-header-name-wrap {
    display: inline-block;
    max-width: 100%;
    min-width: 4rem;
}

.wyldcards-header-name-display {
    cursor: pointer;
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    border-radius: 2px;
    transition: color 0.15s ease, background-color 0.15s ease;
}

.wyldcards-header-name-display:hover,
.wyldcards-header-name-display:focus-visible {
    color: var(--accent, #475569);
    outline: none;
}

.wyldcards-header-name-edit-form {
    display: inline-block;
    max-width: 100%;
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
}

/* Beat missing.css input[type=text] { font-size: 1rem } so edit mode
   keeps the same size as the display title (14pt × text scale). */
.wyldcards-header-name-wrap input[name="title"],
.wyldcards-header-name-wrap input[type="text"],
.wyldcards-header-name-input {
    font: inherit;
    font-family: inherit;
    font-size: inherit;
    font-weight: inherit;
    line-height: inherit;
    letter-spacing: inherit;
    text-align: center;
    color: inherit;
    width: min(100%, 28rem);
    min-width: 8em;
    max-width: 100%;
    margin: 0;
    padding: 0;
    border: none !important;
    border-bottom: 1px solid var(--accent, #475569) !important;
    border-radius: 0;
    background: transparent;
    outline: none !important;
    box-shadow: none !important;
}

.wyldcards-header-name-wrap input[name="title"]:focus,
.wyldcards-header-name-wrap input[name="title"]:focus-visible,
.wyldcards-header-name-wrap input[type="text"]:focus,
.wyldcards-header-name-wrap input[type="text"]:focus-visible,
.wyldcards-header-name-input:focus,
.wyldcards-header-name-input:focus-visible {
    outline: none !important;
    box-shadow: none !important;
}

.wyldcards-header-name-error {
    display: block;
    margin-top: 0.25rem;
    color: var(--bad-fg, #d32f2f);
    font-size: 0.85rem;
    font-family: inherit;
    font-weight: 400;
    text-align: center;
}

.wyldcards-name-placeholder {
    color: #ccc;
    font-style: italic;
}

.wyldcards-breadcrumb-name-wrap {
    display: inline-block;
    min-width: 0;
    max-width: 100%;
}

.wyldcards-breadcrumb-name-display {
    cursor: pointer;
    display: inline-block;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: color 0.15s ease;
}

.wyldcards-breadcrumb-name-display:hover,
.wyldcards-breadcrumb-name-display:focus-visible {
    color: var(--accent, #475569);
}

.wyldcards-breadcrumb-name-wrap input[name="title"],
.wyldcards-breadcrumb-name-input {
    font: inherit;
    font-size: inherit;
    min-width: 8em;
    max-width: min(100%, 24rem);
    width: 100%;
    margin: 0;
    padding: 0;
    border: none !important;
    border-radius: 0;
    background: transparent;
    outline: none !important;
    box-shadow: none !important;
    outline-offset: 0;
}

.wyldcards-breadcrumb-name-wrap input[name="title"]:focus,
.wyldcards-breadcrumb-name-wrap input[name="title"]:focus-visible,
.wyldcards-breadcrumb-name-input:focus,
.wyldcards-breadcrumb-name-input:focus-visible {
    outline: none !important;
    box-shadow: none !important;
    border: none !important;
}

.wyldcards-breadcrumb-name-error {
    display: block;
    margin-top: 0.25rem;
    color: var(--bad-fg, #d32f2f);
    font-size: 0.85rem;
}

.wyldcards-list-no-results {
    margin: 0;
    padding: 1.25rem;
    text-align: center;
}

.wyldcards-list-no-results[hidden] {
    display: none;
}

.wyldcards-list-empty {
    text-align: center;
    padding: 3.5rem 1.5rem;
    border: 1px dashed var(--border, #cbd5e1);
    border-radius: 10px;
    background: var(--accent-bg, rgba(0, 0, 0, 0.015));
}

.wyldcards-list-empty-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3.25rem;
    height: 3.25rem;
    margin: 0 auto 1rem;
    border-radius: 10px;
    background: var(--accent-bg, rgba(0, 0, 0, 0.04));
    color: var(--muted-fg, #64748b);
}

.wyldcards-list-empty-title {
    margin: 0 0 0.35rem;
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.wyldcards-list-empty p {
    margin: 0 0 1.15rem;
}

.text-documents-page {
    --td-song: #0f766e;
    --td-draft: #475569;
    --td-surface: color-mix(in srgb, var(--box-bg, #fff) 88%, var(--accent, #475569) 12%);
    --td-line: var(--border, #cbd5e1);
    max-width: 860px;
    margin: 0 auto;
    padding: 0 1.25rem 3rem;
    line-height: 1.5;
}

/* Tighten chrome above Songs/Notes editors and lists */
body:has(main.text-documents-page) > header.sidebar.menu {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 0;
    margin: 0 !important;
    padding: 0 !important;
    min-height: 0 !important;
    border: none;
    overflow: visible;
    z-index: 1500;
}

body:has(main.text-documents-page) > header.sidebar.menu > nav {
    display: none;
}

body:has(main.text-documents-page) > header.sidebar.menu .header-actions {
    top: 0.35rem;
    right: 0.5rem;
}

body:has(main.text-documents-page) > main.text-documents-page {
    padding-top: 0.65rem !important;
}

.text-documents-page .top-bar {
    margin-top: 0;
    margin-bottom: 0.35rem;
    padding: 0.35rem 3.5rem 0.35rem 0;
    min-height: 2.25rem;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    gap: 0.5rem 0.75rem;
}

.text-documents-page .top-bar nav[aria-label="Breadcrumb"] {
    flex: 1 1 auto;
    min-width: 0;
}

.text-documents-page .top-bar nav[aria-label="Breadcrumb"] > ol {
    padding: 0.15rem 0;
    margin: 0;
    align-items: center;
}

.text-document-edit-page .text-document-editor-shell {
    margin-top: 0.25rem;
}

.text-documents-kicker {
    margin: 0 0 0.35rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted-fg, #64748b);
}

.text-document-top-bar-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    vertical-align: middle;
    flex: 0 0 auto;
}

/* The song editor's menu row, sitting under the breadcrumb. Left-aligned, so it
   does not inherit the right-shove the breadcrumb's flex: 1 gives the actions
   while they share the bar above. */
.text-documents-page .text-document-toolbar-row {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.75rem;
    margin-bottom: 0.35rem;
    min-height: 2.25rem;
}

/* Notes formatting controls. Explicit inline-flex so the buttons align as a
   group regardless of missing.css inline-block defaults. */
.note-format-toolbar {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    vertical-align: middle;
}

.note-format-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    height: 1.85rem;
    padding: 0 0.5rem;
    border: 1px solid var(--border, #cbd5e1);
    border-radius: 6px;
    background: transparent;
    color: var(--fg, inherit);
    font-size: 0.78rem;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
}

/* Arrow glyphs need more size than the text labels to stay legible. */
.note-format-btn--icon {
    font-size: 1.05rem;
    padding: 0 0.4rem;
}

.note-format-btn:hover,
.note-format-btn:focus-visible {
    background: var(--accent-bg, rgba(0, 0, 0, 0.05));
    border-color: var(--accent, #475569);
}

.note-format-divider {
    width: 1px;
    height: 1.1rem;
    margin: 0 0.2rem;
    background: var(--border, #cbd5e1);
}

/* "Last edited" / save status riding the toolbar row rather than sitting under
   the editor: pushed to the far end, and without the block margin and
   space-between the standalone bar uses. */
.text-documents-page .text-document-meta-bar--toolbar {
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 0;
    margin-left: auto;
    min-width: 0;
}

/* The song editor's menus stay on a row of their own, under the breadcrumb bar.

   Wide screens used to lift this row up onto that bar with a negative top margin
   to save the second row, on the reading that the bar's right-hand side was
   empty. It is not: .text-document-top-bar-actions — Read song, History and the
   info popover — is right-aligned in the same bar, and the lifted row landed on
   top of it, one unreadable over the other.

   Nor is there room to lay the bar out as three real columns instead. The page
   is capped at 860px at every viewport, which leaves the bar 764px of content,
   and the crumbs, the menus with "Last edited", and the actions want roughly 900
   between them. Whatever the width, something has to give — so the menus keep
   their own row, as the note toolbar in the same slot always has. */

.text-documents-heading-row {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    vertical-align: middle;
}

.text-documents-heading-row h2 {
    margin: 0;
}

.text-document-about {
    position: relative;
    top: auto;
    right: auto;
    z-index: 2;
    flex: 0 0 auto;
    margin: 0;
    padding: 0;
    max-width: min(22rem, calc(100vw - 4rem));
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    background: transparent;
    border: none;
    box-shadow: none;
}

.text-document-about-toggle {
    cursor: pointer;
    list-style: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: calc(var(--border-radius, 0.5rem) - 2px);
    color: var(--accent, #475569);
    background: transparent;
    box-shadow: none;
    user-select: none;
}

.text-document-about-toggle::-webkit-details-marker {
    display: none;
}

.text-document-about-toggle:hover,
.text-document-about-toggle:focus-visible {
    color: var(--fg, #0f172a);
    background: transparent;
    outline: none;
}

.text-document-about[open] .text-document-about-toggle {
    background: transparent;
}

.text-document-about-icon {
    display: block;
    flex: 0 0 auto;
}

.text-document-about-text {
    margin: 0.4rem 0 0;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--td-line, var(--border, #cbd5e1));
    border-radius: var(--border-radius, 0.5rem);
    background: var(--box-bg, #fff);
    color: var(--muted-fg, #64748b);
    box-shadow: 0 8px 24px -12px rgba(15, 23, 42, 0.35);
    max-width: none;
}

.text-documents-page .top-bar {
    align-items: center;
    gap: 0.5rem 0.75rem;
}

.text-document-breadcrumb-title {
    min-width: 0;
    max-width: min(100%, 28rem);
}

.text-document-breadcrumb-title-label {
    display: inline-flex;
    align-items: center;
    margin: 0;
    min-width: 0;
    max-width: 100%;
}

.text-document-breadcrumb-title-input {
    font: inherit;
    font-size: inherit;
    font-weight: 600;
    line-height: inherit;
    color: inherit;
    min-width: 6rem;
    max-width: min(100%, 28rem);
    width: auto;
    margin: 0;
    padding: 0.1rem 0.15rem;
    border: none !important;
    border-radius: 0;
    background: transparent;
    outline: none !important;
    box-shadow: none !important;
    box-sizing: border-box;
}

.text-document-breadcrumb-title-input:hover,
.text-document-breadcrumb-title-input:focus,
.text-document-breadcrumb-title-input:focus-visible {
    border-bottom: 1px solid var(--accent, #475569) !important;
    background: transparent;
    outline: none !important;
    box-shadow: none !important;
}

.text-documents-top-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    align-items: center;
    justify-content: flex-end;
    margin-left: auto;
}

.text-documents-header--song {
    background:
        linear-gradient(135deg,
            color-mix(in srgb, var(--td-song) 12%, transparent) 0%,
            transparent 55%),
        var(--box-bg, var(--bg, #fff));
}

.text-documents-header--draft {
    background:
        linear-gradient(135deg,
            color-mix(in srgb, var(--td-draft) 12%, transparent) 0%,
            transparent 55%),
        var(--box-bg, var(--bg, #fff));
}

.text-documents-header-text h1 {
    margin: 0 0 0.4rem;
    letter-spacing: -0.02em;
}

.text-documents-header-text > .muted,
.text-documents-header-text > p:not(.text-documents-kicker) {
    margin: 0;
    max-width: 38rem;
}

.text-documents-secondary-btn {
    margin: 0;
}

.text-documents-empty {
    margin: 0.75rem 0 0;
}

/* The archived folders, above the archived documents on the same page. A
   heading and a gap is the whole of it: the rows themselves are ordinary
   `.text-document-card`s, which is deliberate — a folder in the archive is one
   more thing waiting there, not a different kind of screen furniture. */
.text-documents-folder-archive {
    margin: 0.35rem 0 1.25rem;
}

.text-documents-subheading {
    margin: 0 0 0.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--muted-fg, #64748b);
    text-transform: none;
}

.text-documents-empty-state {
    margin: 0.35rem 0 0;
    padding: 1.35rem 1.25rem;
    border: 1px dashed var(--td-line);
    border-radius: calc(var(--border-radius, 0.5rem) + 2px);
    background: color-mix(in srgb, var(--box-bg, #fff) 92%, var(--accent, #475569) 8%);
    text-align: center;
}

.text-documents-empty-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    margin: 0 auto 0.85rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--td-song) 14%, transparent);
    color: var(--td-song);
    font-size: 1.35rem;
    line-height: 1;
}

.text-documents-empty-mark--draft {
    background: color-mix(in srgb, var(--td-draft) 14%, transparent);
    color: var(--td-draft);
}

.text-documents-empty-title {
    margin: 0 0 0.35rem;
    font-weight: 600;
}

.text-documents-empty-state .muted {
    margin: 0 auto 1rem;
    max-width: 28rem;
}

.text-documents-empty-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
}

.text-documents-section {
    margin: 0 0 2.35rem;
    animation: text-documents-rise 0.45s ease both;
}

.text-documents-section--drafts {
    animation-delay: 0.06s;
}

@keyframes text-documents-rise {
    from {
        opacity: 0;
        transform: translateY(0.45rem);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .text-documents-section,
    .text-document-card {
        animation: none !important;
    }
}

.text-documents-section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.95rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--td-line);
}

.text-documents-section-intro {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    min-width: 0;
}

.text-documents-section-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    flex-shrink: 0;
    margin-top: 0.1rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--td-song) 14%, transparent);
    color: var(--td-song);
    font-size: 0.95rem;
    line-height: 1;
}

.text-documents-section-mark--draft {
    background: color-mix(in srgb, var(--td-draft) 14%, transparent);
    color: var(--td-draft);
}

.text-documents-section-header h2 {
    margin: 0 0 0.25rem;
    font-size: 1.2rem;
    letter-spacing: -0.015em;
}

.text-documents-section-header p {
    margin: 0;
    max-width: 30rem;
}

.text-documents-section-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

/* The toolbar while rows are ticked: it drops to the bottom of the window,
   where the app's own selection bar lives. The writer who has just ticked the
   tenth row of forty is exactly the writer about to want Delete, and the walk
   back up the page should not be the price of it. Only off the phone shell —
   that shell keeps these controls in its own sheet. The section keeps room
   below the last rows so the bar never sits on the one being ticked.

   `is-selecting` is the ticked rows' mode and `is-selecting-folders` the
   ticked tiles' — two classes rather than one so the two scripts never toggle
   each other's mode off. The bar itself is the same bar either way. */
html:not(.app-shell) .text-documents-section.is-selecting,
html:not(.app-shell) .text-documents-section.is-selecting-folders {
    padding-bottom: 4.5rem;
    /* The section rises in on an animation whose `both` fill leaves an
       identity transform behind forever after — and any transform makes this
       section the containing block for the fixed bar below, pinning "bottom
       of the window" to the bottom of the section instead. The rise is long
       over by the time a row is ticked; let the transform go with it. */
    animation: none;
}

html:not(.app-shell) .text-documents-section.is-selecting .text-documents-section-actions,
html:not(.app-shell) .text-documents-section.is-selecting-folders .text-documents-section-actions {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
    padding: 0.6rem 1.25rem;
    background: var(--box-bg, var(--bg, #fff));
    border-top: 1px solid var(--td-line, var(--border, #cbd5e1));
    box-shadow: 0 -6px 16px rgba(0, 0, 0, 0.08);
}

/* A menu opening downward out of a bar on the floor of the window would open
   into nothing; from down here the Export formats unfold upward. */
html:not(.app-shell) .text-documents-section.is-selecting .song-export-menu,
html:not(.app-shell) .text-documents-section.is-selecting-folders .song-export-menu {
    top: auto;
    bottom: calc(100% + 0.35rem);
    transform-origin: bottom right;
}

/* While the bar is a selection bar it carries selection actions and nothing
   else: Import and the three places to go — Archive, Trash, New — are the
   list's chrome, not the selection's, and the app hides its own chrome the
   same way the moment a row is ticked. */
html:not(.app-shell) .text-documents-section.is-selecting .text-documents-section-actions > a,
html:not(.app-shell) .text-documents-section.is-selecting #import-doc-btn,
html:not(.app-shell) .text-documents-section.is-selecting-folders .text-documents-section-actions > a,
html:not(.app-shell) .text-documents-section.is-selecting-folders #import-doc-btn {
    display: none;
}

/* "3 songs selected — 1 out of view", and the Clear that ends it. An explicit
   inline-flex wrapper, as every run of row controls here must be: missing.css
   gives inline blocks a baseline of their own to wander on. */
.text-documents-selection-note {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    vertical-align: middle;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent, #475569);
    white-space: nowrap;
}

.text-documents-toolbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin: 0 0 1rem;
}

.text-documents-search-wrap {
    max-width: 22rem;
    width: 100%;
}

.text-documents-no-results {
    margin: 0.5rem 0 0;
    padding: 0.85rem 1rem;
    border: 1px dashed var(--td-line, var(--border, #cbd5e1));
    border-radius: var(--border-radius, 0.5rem);
    color: var(--muted-fg, #64748b);
    font-size: 0.9rem;
}

.text-document-import-banner {
    margin: 0 0 1.25rem;
    padding: 0.7rem 1rem;
    background: color-mix(in srgb, var(--accent, #1e293b) 8%, transparent);
    border: 1px solid var(--td-line);
    border-radius: var(--border-radius, 0.5rem);
    font-size: 0.92rem;
}

/* Says an open document is in the archive rather than the list, and carries the
   way back. Reads like the import banner above — same padding, same border —
   but lays its parts out in a row, because unlike that one it ends in a button.
   The iPad client wears the same strip in the same place. */
.text-document-archived-banner {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin: 0 0 1rem;
    padding: 0.55rem 1rem;
    background: color-mix(in srgb, var(--td-draft, #b45309) 10%, transparent);
    border: 1px solid var(--td-line);
    border-radius: var(--border-radius, 0.5rem);
    font-size: 0.9rem;
}

.text-document-archived-mark {
    font-size: 1rem;
    line-height: 1;
}

/* Takes the room so the button sits at the trailing edge, where the archive
   page keeps its own Unarchive. */
.text-document-archived-text {
    flex: 1 1 auto;
    min-width: 0;
}

.text-document-archived-banner form {
    margin: 0;
    flex: 0 0 auto;
}

/* Standing on its own above an archive's rows rather than sharing a toolbar
   with a search and a sort, as it does on the list — those pages have neither,
   so it needs its own gap. */
.text-documents-list + .text-documents-select-all,
.text-documents-section > .text-documents-select-all {
    margin-bottom: 0.75rem;
}

.text-documents-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.text-document-title-full {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin: 0 0 1rem;
}

.text-document-card {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 1.05rem 1.15rem;
    border: 1px solid var(--td-line);
    border-radius: calc(var(--border-radius, 0.5rem) + 2px);
    background: var(--box-bg, var(--bg, #fff));
    box-shadow: 0 1px 0 color-mix(in srgb, var(--fg, #000) 4%, transparent);
    transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
    animation: text-documents-rise 0.4s ease both;
    animation-delay: calc(0.04s * var(--card-i, 0));
}

.text-document-card:hover {
    border-color: color-mix(in srgb, var(--accent, #475569) 45%, var(--td-line));
    box-shadow: 0 8px 22px -16px color-mix(in srgb, var(--fg, #000) 45%, transparent);
    transform: translateY(-1px);
}

.text-document-card--song {
    border-left: 3px solid color-mix(in srgb, var(--td-song) 70%, var(--td-line));
}

.text-document-card--draft {
    border-left: 3px solid color-mix(in srgb, var(--td-draft) 65%, var(--td-line));
}

/* Drag handle + export checkbox share one explicit inline-flex row: missing.css
   will not line up bare inline-blocks against the card title on its own. */
.text-document-card-lead {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    vertical-align: middle;
    flex: 0 0 auto;
    padding-top: 0.15rem;
}

/* Deliberately NOT the shared .drag-handle class: html.wyldcards-hide-block-select
   hides that, and every rule that reveals it again is scoped to .block-row / tr,
   so a song card would lose its handle for good. */
.text-document-drag-handle {
    user-select: none;
    -webkit-user-select: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 26px;
    padding: 0;
    border: 0;
    border-radius: 4px;
    background: none;
    color: color-mix(in srgb, var(--fg, #000) 40%, transparent);
    font-size: 0.95rem;
    line-height: 1;
    letter-spacing: -2px;
    cursor: grab;
    opacity: 0.55;
    transition: opacity 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.text-document-card:hover .text-document-drag-handle,
.text-document-drag-handle:focus-visible {
    opacity: 1;
    color: var(--fg, #000);
    background: color-mix(in srgb, var(--fg, #000) 7%, transparent);
}

.text-document-drag-handle:active {
    cursor: grabbing;
}

.text-document-card.dragging {
    opacity: 0.4;
}

/* Drop indicator, matching the song-block and screenplay-block drags. */
.text-document-card.drop-before::before,
.text-document-card.drop-after::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--accent, #475569);
    border-radius: 2px;
    box-shadow: 0 0 0 1px var(--box-bg, #ffffff), 0 0 0 3px color-mix(in srgb, var(--accent, #475569) 25%, transparent);
    pointer-events: none;
    z-index: 3;
}

.text-document-card.drop-before::before {
    top: -3px;
}

.text-document-card.drop-after::after {
    bottom: -3px;
}

.text-documents-list--saving .text-document-drag-handle {
    cursor: progress;
    opacity: 0.35;
}

/* Export selection checkbox. Explicit inline-flex so the box lines up with the
   card title rather than sitting on the text baseline. */
.text-document-select {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    vertical-align: middle;
    flex: 0 0 auto;
    padding-top: 0.15rem;
}

/* Inside the lead row the wrapper already handles alignment; the standalone
   padding would push the checkbox off the handle's centre line. */
.text-document-card-lead .text-document-select {
    padding-top: 0;
}

.text-document-select-checkbox {
    margin: 0;
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--accent, #475569);
}

.text-documents-select-all {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    vertical-align: middle;
    margin: 0;
    font-size: 0.8rem;
    color: var(--muted-fg, #64748b);
    cursor: pointer;
    user-select: none;
}

.text-documents-select-all input {
    margin: 0;
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--accent, #475569);
}

/* Tells the reader what the format links below will actually export. */
.song-export-scope {
    padding: 0.35rem 0.65rem 0.15rem;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted, #888);
    user-select: none;
}

.text-document-card-main {
    flex: 1 1 16rem;
    min-width: 0;
}

.text-document-card-title {
    display: inline-block;
    font-weight: 600;
    font-size: 1.05rem;
    letter-spacing: -0.01em;
    text-decoration: none !important;
    color: inherit;
    margin-bottom: 0.4rem;
}

.text-document-card-title:hover,
.text-document-card-title:focus-visible {
    color: var(--accent, #475569);
}

.text-document-card-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.55rem;
    margin-bottom: 0.5rem;
    font-size: 0.82rem;
}

.text-document-type-badge {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--td-draft);
    background: color-mix(in srgb, var(--td-draft) 10%, transparent);
    border: 1px solid color-mix(in srgb, var(--td-draft) 22%, transparent);
    border-radius: 999px;
    padding: 0.15rem 0.55rem;
}

.text-document-type-badge--song {
    color: var(--td-song);
    background: color-mix(in srgb, var(--td-song) 10%, transparent);
    border-color: color-mix(in srgb, var(--td-song) 24%, transparent);
}

/* Folders: the tiles you open, the path back out of the one that is open, and
   the badge that says where a card is filed. The badge is quieter than the type
   badge on purpose — where a song lives is worth knowing at a glance and never
   the first thing on the card. */
.text-document-folders {
    display: block;
    margin: 0 0 1rem;
}

/* The tiles. A grid rather than a row of chips: these are things to go into,
   and they take the width the list itself takes so a folder reads as a shelf
   over the cards rather than a filter above them. */
.text-document-folder-grid {
    list-style: none;
    margin: 0 0 0.6rem;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
    gap: 0.5rem;
}

/* A tick beside each tile, for picking several folders at once. An explicit
   flex row, per the rule every run of controls here follows — missing.css
   gives inline blocks a baseline of their own to wander on — with the guard
   `[hidden]` needs the moment a display is set by hand. */
.text-document-folder-tile-item {
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.text-document-folder-tile-item[hidden] {
    display: none;
}

.text-document-folder-select {
    display: inline-flex;
    align-items: center;
}

.text-document-folder-tile {
    font: inherit;
    width: 100%;
    /* Beside the tick it is a flex item; without these it would refuse to
       shrink past its name and shoulder the tick off the shelf. */
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 0.55rem;
    text-align: left;
    color: inherit;
    background: color-mix(in srgb, currentColor 4%, transparent);
    border: 1px solid color-mix(in srgb, currentColor 14%, transparent);
    border-radius: 0.6rem;
    padding: 0.6rem 0.75rem;
    cursor: pointer;
}

.text-document-folder-tile:hover {
    background: color-mix(in srgb, currentColor 8%, transparent);
    border-color: color-mix(in srgb, currentColor 28%, transparent);
}

.text-document-folder-tile-mark {
    font-size: 1.05rem;
    line-height: 1;
}

.text-document-folder-tile-name {
    font-weight: 600;
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.text-document-folder-tile-count,
.text-document-folder-tile-chevron {
    color: var(--muted-fg, #64748b);
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
}

/* The path out. Sits where the tiles were, so going in and coming back out
   move nothing else on the page. */
.text-document-folder-path {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin: 0 0 0.6rem;
}

.text-document-folder-back {
    font: inherit;
    font-size: 0.9rem;
    color: var(--link-fg, #2563eb);
    background: transparent;
    border: 0;
    padding: 0.2rem 0;
    cursor: pointer;
}

.text-document-folder-back:hover {
    text-decoration: underline;
}

/* The folders above this one, each a way back to it. Ahead of the folder's own
   name in the path and styled like the way out rather than like the name,
   because that is what they are: steps, not where you are. */
.text-document-folder-crumbs {
    display: flex;
    align-items: baseline;
    gap: 0.3rem;
    flex-wrap: wrap;
    min-width: 0;
}

.text-document-folder-crumb {
    font: inherit;
    font-size: 0.9rem;
    color: var(--link-fg, #2563eb);
    background: transparent;
    border: 0;
    padding: 0.2rem 0;
    cursor: pointer;
    max-width: 12rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.text-document-folder-crumb:hover {
    text-decoration: underline;
}

.text-document-folder-crumb-sep {
    color: var(--muted-fg, #64748b);
    font-size: 0.8rem;
}

.text-document-folder-here {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
    flex: 1 1 auto;
}

/* Where a folder found by a search actually sits. Only ever on screen when the
   search reached past the folders in view, so it is never a second copy of the
   path already above. */
.text-document-folder-tile-where {
    font-size: 0.75rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 10rem;
}

.text-document-folder-here-mark {
    font-size: 1rem;
}

.text-document-folder-new {
    display: flex;
}

/* Inside a folder every card is filed under the name in the path above, so the
   badge on each of them would be that one word repeated down the page. */
.text-documents-list.is-inside-folder .text-document-folder-badge {
    display: none;
}

.text-document-folder-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.text-document-folder-badge {
    display: inline-block;
    font-size: 0.7rem;
    color: var(--muted-fg, #64748b);
    border: 1px solid color-mix(in srgb, var(--muted-fg, #64748b) 25%, transparent);
    border-radius: 999px;
    padding: 0.12rem 0.5rem;
}

/* The per-card and per-selection folder pickers. Sized down to sit in a row of
   buttons without becoming the widest thing in it. */
.text-document-folder-select,
#songs-folder-selected,
.text-document-wyldcards-select,
#songs-wyldcards-selected {
    font-size: 0.85rem;
    max-width: 10rem;
}

.text-document-preview {
    margin: 0;
    font-size: 0.92rem;
    line-height: 1.45;
    color: var(--muted-fg, #64748b);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    white-space: pre-wrap;
}

.text-document-preview--empty {
    font-style: italic;
    opacity: 0.8;
}

.text-document-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
}

.text-document-card-actions form,
.text-document-insert-form,
.text-document-delete-form {
    margin: 0;
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.text-document-delete-btn:hover,
.text-document-delete-btn:focus-visible {
    color: #b91c1c !important;
    border-color: color-mix(in srgb, #b91c1c 35%, var(--td-line)) !important;
    background: color-mix(in srgb, #b91c1c 8%, transparent) !important;
}

.text-document-form {
    margin-bottom: 1.5rem;
}

.text-document-editor-shell {
    position: relative;
    padding: 0;
    margin: 0.25rem 0 1rem;
    border: none;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

.text-document-editor-shell .text-document-title-label {
    width: 100%;
}

.text-document-edit-page--song .text-document-editor-shell,
.text-document-edit-page--draft .text-document-editor-shell {
    border-top: none;
}

.text-document-form-row {
    display: grid;
    grid-template-columns: 1fr minmax(8rem, 10rem);
    gap: 0.85rem;
    margin-bottom: 1rem;
}

@media (max-width: 640px) {
    .text-document-form-row {
        grid-template-columns: 1fr;
    }

    .text-documents-search-wrap {
        max-width: none;
    }

    .text-document-card-actions {
        width: 100%;
    }

    .text-document-card-actions .wyldcards-list-action-btn {
        flex: 1 1 auto;
    }
}

.text-document-form label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin: 0;
}

.text-document-title-full input[type="text"] {
    width: 100%;
    box-sizing: border-box;
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    padding: 0.65rem 0.8rem;
}

.text-document-content-label {
    margin-bottom: 0;
}

.text-document-content-heading {
    display: flex;
    justify-content: flex-end;
    align-items: baseline;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.text-document-content-hint {
    font-size: 0.78rem;
    font-weight: 500;
}

.text-document-content {
    width: 100%;
    min-height: 24rem;
    font-family: "Courier Prime", "Courier New", Courier, monospace;
    font-size: 1rem;
    line-height: 1.6;
    padding: 0.25rem 0;
    resize: vertical;
    white-space: pre-wrap;
    border: none !important;
    border-radius: 0;
    outline: none !important;
    box-shadow: none !important;
    background: transparent;
}

.text-document-content:focus,
.text-document-content:focus-visible {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

:root.-dark-theme .text-document-content,
:root[data-theme-setting="dark"] .text-document-content {
    background: transparent;
}

@media (prefers-color-scheme: dark) {
    :root:not(.-no-dark-theme):not([data-theme-setting="light"]) .text-document-content {
        background: transparent;
    }
}

.text-document-save-status {
    margin: 0.35rem 0 0;
    font-size: 0.85rem;
    font-weight: 500;
    min-height: 1.2em;
}

.text-document-save-status[data-state="saving"] {
    color: var(--muted, #64748b);
}

.text-document-save-status[data-state="saved"] {
    color: color-mix(in srgb, #15803d 85%, var(--fg, #0f172a));
}

.text-document-save-status[data-state="error"] {
    color: color-mix(in srgb, #b91c1c 85%, var(--fg, #0f172a));
}

.text-document-meta-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.35rem;
    min-height: 1.2em;
}

.text-document-last-edited {
    font-size: 0.85rem;
    color: var(--muted-fg, #64748b);
}

.text-document-meta-bar .text-document-save-status {
    margin: 0;
}

/* --- Songs workspace (every song in a wyldcards on one page) --------------- */
.song-workspace-intro {
    margin: 0 0 1rem;
    max-width: 60ch;
}

.song-workspace-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.song-workspace-search-wrap {
    flex: 1 1 16rem;
    min-width: 12rem;
}

/* Guardrail: explicit flex container so the buttons line up regardless of
   missing.css's inline-block defaults. */
.song-workspace-toolbar-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    vertical-align: middle;
}

.song-workspace-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

/* missing.css gives sibling <section>s a large block margin, which fights the
   list's own gap and strands the collapsed rows far apart. */
.song-workspace-item {
    margin-block: 0;
    border: 1px solid var(--td-line, #cbd5e1);
    border-radius: calc(var(--border-radius, 0.5rem) + 2px);
    background: var(--box-bg, var(--bg, #fff));
    box-shadow: 0 1px 0 color-mix(in srgb, var(--fg, #000) 4%, transparent);
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.song-workspace-item--open {
    border-color: color-mix(in srgb, var(--accent, #6366f1) 45%, var(--td-line, #cbd5e1));
    box-shadow: 0 2px 10px color-mix(in srgb, var(--fg, #000) 7%, transparent);
}

.song-workspace-item-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    padding: 0.7rem 0.9rem;
}

.song-workspace-status:empty {
    display: none;
}

.song-workspace-status {
    margin: 0.75rem 0 0;
    color: var(--error-fg, #b91c1c);
}

.song-workspace-drag-handle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 1.4rem;
    height: 1.75rem;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--muted-fg, #64748b);
    font-size: 0.85rem;
    line-height: 1;
    cursor: grab;
}

.song-workspace-drag-handle:hover,
.song-workspace-drag-handle:focus-visible {
    background: color-mix(in srgb, var(--fg, #000) 6%, transparent);
    color: inherit;
}

.song-workspace-item--dragging {
    opacity: 0.5;
}

/* A 2px rail marks where the dragged song will land, matching the lyric-line
   drop indicator. */
.song-workspace-drop-before {
    box-shadow: 0 -2px 0 0 var(--accent, #6366f1);
}

.song-workspace-drop-after {
    box-shadow: 0 2px 0 0 var(--accent, #6366f1);
}

.song-workspace-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 1.75rem;
    height: 1.75rem;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: inherit;
    cursor: pointer;
}

.song-workspace-toggle:hover,
.song-workspace-toggle:focus-visible {
    border-color: var(--td-line, #cbd5e1);
    background: color-mix(in srgb, var(--fg, #000) 5%, transparent);
}

.song-workspace-chevron {
    display: inline-block;
    font-size: 0.8rem;
    line-height: 1;
    transition: transform 0.18s ease;
}

.song-workspace-item--open .song-workspace-chevron {
    transform: rotate(90deg);
}

.song-workspace-title-label {
    flex: 1 1 12rem;
    min-width: 0;
    margin: 0;
}

/* missing.css gives inputs their own fill and text colour; the workspace title
   reads as part of the header, so it stays flat until hovered or focused. */
.song-workspace-title {
    width: 100%;
    padding: 0.25rem 0.4rem;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent !important;
    font-size: 1.05rem;
    font-weight: 600;
    color: inherit !important;
}

.song-workspace-title:hover:not([readonly]) {
    border-color: var(--td-line, #cbd5e1);
}

.song-workspace-title:focus {
    border-color: var(--accent, #6366f1);
    background: var(--bg, #fff);
    outline: none;
}

.song-workspace-title[readonly] {
    cursor: default;
}

.song-workspace-item-meta {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    flex: 0 0 auto;
    vertical-align: middle;
    font-size: 0.85rem;
}

.song-workspace-body {
    padding: 0 0.9rem 0.9rem;
    border-top: 1px solid var(--td-line, #cbd5e1);
}

/* The single-song editor needs breathing room under its toolbar; stacked in
   the workspace that gap just pushes every song apart. */
.song-workspace-body .song-blocks {
    padding-top: 0.6rem;
}

/* The single-song editor wraps its blocks in a <form>, which is where the lyric
   textareas pick up their text colour. The workspace has no form, so without
   this they fall back to the UA default and vanish in dark mode. */
.song-workspace-body .song-block-textarea {
    color: inherit;
}

@media (max-width: 40rem) {
    .song-workspace-item-meta {
        width: 100%;
        justify-content: flex-end;
    }
}

/* --- Song block editor (add/edit/delete/reorder lyric lines) ------------- */
.song-blocks-editor {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    width: 100%;
}

.song-blocks {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    padding-top: 1.5rem;
    /* Number the lyric lines. A pure-CSS counter renumbers itself when the
       list is swapped by HTMX or reordered by drag, with no server or JS help. */
    counter-reset: song-line;
}

.song-block-row {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
    border-radius: 6px;
    /* 2px left rail marks the active line on :focus-within; transparent by
       default. Trim the left padding by the same 2px so the lyric text does
       not shift when the rail appears. */
    border-left: 2px solid transparent;
    padding: 0.1rem 0.25rem 0.1rem calc(0.25rem - 2px);
    counter-increment: song-line;
    transition: background-color 0.12s ease-in-out, border-left-color 0.12s ease-in-out;
}

/* Faint hover wash so pointing at a line reads as interactive. Skipped for
   highlighted, selected, or actively-edited rows so it never fights their own
   background or the "no tint while typing" rule below. */
.song-block-row:not([class*="song-block-highlight-"]):not(.block-selected):not(:focus-within):hover {
    background-color: color-mix(in srgb, var(--fg, #0f172a) 4%, transparent);
}

/* Accent rail on the line that holds the caret. */
.song-block-row:focus-within {
    border-left-color: var(--accent, #475569);
}

/* Line number sitting in the gutter that otherwise only holds the hover
   controls. Right-aligned toward the lyric text; fades out on hover/focus so
   the "+" / "⋮⋮" controls can take the same space. */
.song-block-row::before {
    content: counter(song-line);
    position: absolute;
    left: 0;
    top: 0;
    width: 2.7rem;
    padding-top: 0.3rem;
    padding-right: 0.2rem;
    text-align: right;
    font-family: "Courier Prime", "Courier New", Courier, monospace;
    font-size: 0.8rem;
    line-height: 1.6;
    color: var(--muted-fg, #64748b);
    opacity: 0.5;
    pointer-events: none;
    -webkit-user-select: none;
    user-select: none;
    transition: opacity 0.12s ease-in-out;
}

.song-block-row:hover::before,
.song-block-row:focus-within::before,
.song-block-row:has(.song-block-menu-dropdown.open)::before {
    opacity: 0;
}

/* Drag-to-reorder feedback, matching the screenplay block rows. */
.song-block-row.dragging {
    opacity: 0.4;
}

.song-block-row.drop-before::before,
.song-block-row.drop-after::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--accent, #475569);
    border-radius: 2px;
    box-shadow: 0 0 0 1px var(--box-bg, #ffffff), 0 0 0 3px color-mix(in srgb, var(--accent, #475569) 25%, transparent);
    pointer-events: none;
    z-index: 3;
}

.song-block-row.drop-before::before {
    top: -2px;
}

.song-block-row.drop-after::after {
    bottom: -2px;
}

/* Song line controls mirror the screenplay block controls: a round "+" to add a
   line below and a "⋮⋮" menu (move up/down, delete). Reuses the screenplay
   .create-below / .block-drag-menu button styling for a consistent look. */
.song-block-controls {
    flex: 0 0 auto;
    display: flex;
    align-items: flex-start;
    /* missing.css styles <aside> with a block margin, block padding, and a
       border-block rule that draws a line above and below the controls. Zero
       all three so the controls line up with the first line of lyric text and
       carry no rules of their own. */
    margin: 0;
    border-block: 0;
    padding-block: 0.2rem 0;
    opacity: 0;
    transition: opacity 0.12s ease-in-out;
}

.song-block-row:hover .song-block-controls,
.song-block-row:focus-within .song-block-controls,
.song-block-row:has(.song-block-menu-dropdown.open) .song-block-controls {
    opacity: 1;
}

.song-block-controls-inner {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    vertical-align: middle;
}

/* The song "+" adds a line directly (no type menu). */
.song-block-add.create-below.create-below-menu-toggle {
    font-size: 1.05rem;
    font-weight: 600;
}

/* The "⋮⋮" handle both drags to reorder and clicks open the line menu. */
button.song-block-menu-toggle.block-drag-menu-toggle.nav-dropdown-toggle {
    cursor: grab;
    min-width: 1.5rem;
}

button.song-block-menu-toggle.block-drag-menu-toggle.nav-dropdown-toggle:active {
    cursor: grabbing;
}

.song-block-row:hover button.song-block-menu-toggle.block-drag-menu-toggle.nav-dropdown-toggle,
.song-block-menu-dropdown.open button.song-block-menu-toggle.block-drag-menu-toggle.nav-dropdown-toggle {
    color: var(--accent, #475569);
    background-color: var(--accent-bg, rgba(0, 0, 0, 0.05));
}

.song-block-menu-dropdown .nav-dropdown-menu.song-block-menu {
    min-width: 10rem;
}

.song-block-textarea {
    flex: 1 1 auto;
    width: 100%;
    min-height: 1.6em;
    font-family: "Courier Prime", "Courier New", Courier, monospace;
    font-size: calc(1rem * var(--wyldcards-text-scale, 1));
    line-height: 1.6;
    padding: 0.15rem 0.35rem;
    margin: 0;
    resize: none;
    overflow: hidden;
    white-space: pre-wrap;
    word-break: break-word;
    border: none !important;
    border-radius: 4px;
    outline: none !important;
    box-shadow: none !important;
    background: transparent;
}

.song-block-textarea::placeholder {
    color: var(--muted-fg, #64748b);
    opacity: 0.7;
    font-style: italic;
    /* missing.css sets `::placeholder { text-align: end }`; !important is needed
       to keep the lyric hint at the left, where typed lyrics actually appear. */
    text-align: left !important;
}

/* No focus tint: a block is highlighted only when it is selected (see the block
   selection rules at the end of this file), never while it is being typed in. */
.song-block-textarea:focus,
.song-block-textarea:focus-visible {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    background: transparent;
}

.text-document-insert-panel {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 0.25rem;
    padding: 1.15rem 1.2rem;
    border: 1px solid var(--td-line);
    border-radius: calc(var(--border-radius, 0.5rem) + 2px);
    background:
        linear-gradient(135deg,
            color-mix(in srgb, var(--accent, #475569) 7%, transparent),
            transparent 55%),
        var(--box-bg, var(--bg, #fff));
}

.text-document-insert-panel h2 {
    margin: 0 0 0.35rem;
    font-size: 1.1rem;
}

.text-document-insert-panel-text > .muted {
    margin: 0;
    max-width: 28rem;
}

.text-document-insert-type-label {
    display: inline-flex;
    flex-direction: column;
    gap: 0.3rem;
    margin: 0;
    font-size: 0.9rem;
}

.text-document-insert-banner {
    max-width: 52rem;
    margin: 0.75rem auto 0;
    padding: 0.65rem 1rem;
    background: color-mix(in srgb, var(--accent, #1e293b) 8%, transparent);
    border: 1px solid var(--td-line);
    border-radius: var(--border-radius, 0.5rem);
    font-size: 0.92rem;
}

:root.-dark-theme .text-documents-page {
    --td-song: #2dd4bf;
    --td-draft: #94a3b8;
}

@media (prefers-color-scheme: dark) {
    :root:not(.-no-dark-theme):not([data-theme-setting="light"]) .text-documents-page {
        --td-song: #2dd4bf;
        --td-draft: #94a3b8;
    }
}

@media (max-width: 768px) {
}

/* Users List Page */
.user-list-page {
    max-width: 920px;
    margin: 0 auto;
    padding: 0 1.25rem 2.5rem;
    line-height: 1.5;
}

.user-list-flash {
    margin: 0.75rem 0 0;
    padding: 0.65rem 0.85rem;
    border-radius: 8px;
    font-size: 0.9rem;
    line-height: 1.4;
}

/* A one-time confirmation on the card page (after an import): fades out on its own. */
.wyldcards-card-notice {
    position: fixed;
    left: 50%;
    bottom: 1.25rem;
    z-index: 60;
    transform: translateX(-50%);
    max-width: calc(100vw - 2rem);
    background: var(--bg, #fff);
    border: 1px solid var(--graphical-fg, rgba(0, 0, 0, 0.2));
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    pointer-events: none;
    animation: wyldcards-card-notice-fade 5s ease-in forwards;
}

@keyframes wyldcards-card-notice-fade {
    0%, 80% { opacity: 1; }
    100% { opacity: 0; visibility: hidden; }
}

.stack-import-open {
    border: 0;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.stack-import-open legend {
    padding: 0;
    margin-bottom: 0.25rem;
    font-weight: 600;
}

.stack-import-open label {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.5rem;
    width: auto;
    font-weight: normal;
    text-align: left;
}

.stack-import-open input[type="radio"] {
    width: auto;
    flex: 0 0 auto;
    margin: 0;
}

.user-list-flash-error {
    color: #991b1b;
    background: rgba(185, 28, 28, 0.08);
    border: 1px solid rgba(185, 28, 28, 0.25);
}

.user-list-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
    margin: 0.75rem 0 1.25rem;
}

.user-list-header-text h1 {
    margin: 0 0 0.35rem;
}

.user-list-header-text .muted {
    margin: 0;
}

.user-list-create-btn {
    flex-shrink: 0;
    margin: 0;
    padding-inline: 0.9rem;
}

.user-list-toolbar {
    margin-bottom: 1rem;
}

.user-list-table {
    width: 100%;
    margin: 0;
    border-collapse: collapse;
}

.user-list-main-cell {
    padding: 1rem 1.15rem;
    vertical-align: middle;
}

.user-list-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    width: 100%;
}

.stack-list-bulkbar {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    margin: 0 0 1rem;
}

.stack-list-select-all,
.stack-list-select {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    flex: 0 0 auto;
}

.stack-list-tile-select {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.55rem 0.55rem 0;
}

/* Stack selection is a deliberate mode: keep row and tile checkboxes out of
   the way until Select stacks is pressed, regardless of the current layout. */
body:not(.app-selecting) .stack-list-select,
body:not(.app-selecting) .stack-list-tile-select {
    display: none;
}

.user-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: rgba(71, 85, 105, 0.12);
    color: var(--muted-fg, #64748b);
    font-weight: 700;
    text-transform: uppercase;
    border: 1px solid var(--border, #cbd5e1);
}

.user-avatar--list {
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 999px;
    font-size: 0.95rem;
}

.user-avatar--profile {
    width: 4.5rem;
    height: 4.5rem;
    border-radius: 12px;
    font-size: 1.5rem;
}

.user-list-info {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    min-width: 0;
    flex: 1;
}

.user-list-name-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    row-gap: 0.35rem;
    flex-wrap: wrap;
}

.user-list-name {
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.35;
}

/* A stack's emoji or glyph, beside its name in lists, headings and the toolbar. */
.stack-icon {
    display: inline-block;
    flex-shrink: 0;
    min-width: 1.4em;
    margin-right: 0.35em;
    text-align: center;
    font-size: 1.15em;
    line-height: 1;
    vertical-align: -0.1em;
}
.user-list-name-row .stack-icon {
    margin-right: 0;
}
.stack-icon-input {
    max-width: 10rem;
    font-size: 1.25rem;
}

.user-list-status {
    flex-shrink: 0;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    border: 1px solid var(--border, #cbd5e1);
}

.user-list-status--enabled {
    color: #166534;
    background: rgba(22, 101, 52, 0.08);
    border-color: rgba(22, 101, 52, 0.2);
}

.user-list-status--disabled {
    color: var(--muted-fg, #64748b);
    background: var(--accent-bg, rgba(0, 0, 0, 0.03));
}

.user-list-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem 0.5rem;
    font-size: 0.875rem;
    color: var(--muted-fg, #64748b);
    line-height: 1.4;
}

.user-list-meta-sep::before {
    content: "·";
}

.user-list-roles {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.user-list-access {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-top: 0.15rem;
}

.user-list-access-perms {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
}

.user-list-access-casting {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.12rem 0.45rem;
    border-radius: 999px;
    border: 1px solid rgba(37, 99, 235, 0.25);
    background: rgba(37, 99, 235, 0.08);
    color: #1d4ed8;
    line-height: 1.35;
}

.user-list-access-wyldcards {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.3rem;
}

.user-list-access-wyldcards-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-right: 0.1rem;
}

.user-list-wyldcards-chip {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.12rem 0.45rem;
    border-radius: 6px;
    border: 1px solid var(--border, #cbd5e1);
    background: var(--accent-bg, rgba(0, 0, 0, 0.03));
    color: var(--fg, inherit);
    line-height: 1.35;
    max-width: 14rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-list-wyldcards-chip--all {
    font-weight: 600;
    border-color: rgba(22, 101, 52, 0.25);
    background: rgba(22, 101, 52, 0.08);
    color: #166534;
}

.user-list-access-empty {
    font-size: 0.78rem;
}

.user-role-chip {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    border: 1px solid var(--border, #cbd5e1);
    background: var(--box-bg, #ffffff);
    color: var(--fg, inherit);
    line-height: 1.35;
}

.user-role-chip--muted {
    color: var(--muted-fg, #64748b);
    background: var(--accent-bg, rgba(0, 0, 0, 0.03));
}

.user-list-actions {
    flex-shrink: 0;
}

/* User Profile Page */
.user-profile-page {
    max-width: 760px;
    margin: 0 auto;
    padding: 0 1.25rem 2.5rem;
    line-height: 1.5;
}

.user-profile-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.75rem;
}

.user-profile-header-main {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 0;
}

.user-profile-header-text h1 {
    margin: 0 0 0.2rem;
    line-height: 1.25;
}

.user-profile-username {
    margin: 0;
    font-size: 0.95rem;
}

.user-profile-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.user-profile-grid {
    display: grid;
    gap: 1rem;
}

.user-profile-card {
    border: 1px solid var(--border, #cbd5e1);
    border-radius: 12px;
    background: var(--box-bg, #ffffff);
    padding: 1.15rem 1.25rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
}

.user-profile-card h2 {
    margin: 0 0 0.85rem;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted-fg, #64748b);
}

.user-profile-details {
    margin: 0;
    display: grid;
    gap: 0.75rem;
}

.user-profile-details div {
    display: grid;
    grid-template-columns: 5.5rem 1fr;
    gap: 0.85rem 1rem;
    align-items: baseline;
}

.user-profile-details dt {
    margin: 0;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--muted-fg, #64748b);
    line-height: 1.35;
}

.user-profile-details dd {
    margin: 0;
    line-height: 1.5;
}

.user-profile-empty {
    margin: 0;
}

.user-profile-access-note {
    margin: 0.85rem 0 0;
    font-size: 0.85rem;
}

.user-profile-access-subtitle {
    margin: 1rem 0 0.55rem;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--muted-fg, #64748b);
}

.user-profile-access-list {
    list-style: none;
    margin: 0;
    padding: 0;
    border: 1px solid var(--border, #cbd5e1);
    border-radius: 8px;
    overflow: hidden;
}

.user-profile-access-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.55rem 0.7rem;
    border-bottom: 1px solid var(--border, #e2e8f0);
}

.user-profile-access-item:last-child {
    border-bottom: none;
}

.user-profile-access-item-main {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
}

.user-profile-access-reason {
    font-size: 0.75rem;
}

@media (min-width: 640px) {
    .user-profile-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .user-profile-card--roles,
    .user-profile-card--access {
        grid-column: 1 / -1;
    }
}

@media (max-width: 768px) {
    .user-list-item {
        flex-wrap: wrap;
    }

    .user-list-actions {
        width: 100%;
        margin-left: 3.75rem;
    }
}

@media (max-width: 640px) {
    .user-list-header {
        flex-direction: column;
        align-items: stretch;
    }

    .user-list-create-btn {
        width: 100%;
        text-align: center;
    }

    .user-list-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .user-list-actions {
        margin-left: 0;
        width: 100%;
    }

    .user-profile-header {
        flex-direction: column;
        align-items: stretch;
    }

    .user-profile-actions {
        width: 100%;
    }

    .user-profile-actions a {
        flex: 1;
        text-align: center;
    }

    .user-profile-details div {
        grid-template-columns: 1fr;
        gap: 0.2rem;
    }
}

/* Actor Create / Edit Form */
.user-form-page {
    max-width: 560px;
    margin: 0 auto;
    padding: 0 1.25rem 2.5rem;
    line-height: 1.5;
}
.user-form-header {
    margin-bottom: 1.5rem;
}
/* Stack settings: an index of its sections. A wrapping row of links under the
   heading; on a screen wide enough, a column pinned beside the form. */
.settings-index {
    margin: -0.5rem 0 1.5rem;
}
.settings-index ol {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin: 0;
    padding: 0;
    list-style: none;
}
.settings-index li {
    margin: 0;
    padding: 0;
}
.settings-index a {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--muted-fg);
    font-size: 0.82rem;
    text-decoration: none;
    white-space: nowrap;
}
.settings-index a:hover,
.settings-index a:focus-visible {
    border-color: var(--accent);
    color: var(--fg);
}
.settings-index a[aria-current="true"] {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 12%, transparent);
    color: var(--fg);
}
.user-form-page .user-form-card[id] {
    scroll-margin-top: 1.5rem;
}
@media (min-width: 1120px) {
    .settings-index {
        position: fixed;
        top: 7rem;
        /* The form is a 560px column centred on the page; sit just left of it. */
        left: calc(50% - 280px - 13.5rem);
        width: 12rem;
        max-height: calc(100vh - 9rem);
        overflow-y: auto;
        margin: 0;
    }
    .settings-index ol {
        flex-direction: column;
        gap: 0.1rem;
    }
    .settings-index a {
        display: block;
        padding: 0.3rem 0.7rem;
        border-color: transparent;
        border-radius: 0.45rem;
        font-size: 0.875rem;
    }
}

.user-form-header h1 {
    margin: 0 0 0.35rem;
    line-height: 1.25;
}
.user-form-header-text p {
    margin: 0;
}
.user-form-header-text p + p {
    margin-top: 0.6rem;
}
.user-form {
    display: grid;
    gap: 1rem;
}
.user-form-card {
    border: 1px solid var(--border, #cbd5e1);
    border-radius: 12px;
    background: var(--box-bg, #ffffff);
    padding: 1.15rem 1.25rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
}
.user-form-card h2 {
    margin: 0 0 1rem;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted-fg, #64748b);
}
.user-form-fields {
    display: grid;
    gap: 1rem;
}
.user-form-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.user-form-profile-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.user-form-profile-grid .user-form-field:last-child {
    grid-column: 1 / -1;
}
.card-size-presets {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.55rem;
    margin: 0 0 1rem;
}
.card-size-preset {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
    margin: 0;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--border, #cbd5e1);
    border-radius: 8px;
    background: var(--bg, #fff);
    color: inherit;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.card-size-preset small {
    color: var(--muted-fg, #64748b);
    font-size: 0.78rem;
    font-weight: 500;
    white-space: nowrap;
}
.card-size-preset:hover,
.card-size-preset:focus-visible,
.card-size-preset.is-selected {
    border-color: var(--accent, #475569);
    background: rgba(71, 85, 105, 0.08);
}
.user-form-field {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    min-width: 0;
}
.stack-import-drop-zone {
    align-items: center;
    border: 2px dashed rgba(71, 85, 105, 0.35);
    border-radius: 12px;
    padding: 1.75rem 1rem;
    text-align: center;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}
.stack-import-drop-zone input[type="file"] {
    max-width: 22rem;
}
.stack-import-drop-zone.is-dragging {
    border-color: var(--accent, #475569);
    border-style: solid;
    background: rgba(71, 85, 105, 0.08);
}
[data-stack-import][aria-busy="true"] .stack-import-drop-zone {
    opacity: 0.6;
}
.stack-import-drop-icon {
    font-size: 2rem;
    line-height: 1;
    opacity: 0.7;
}
.stack-import-drop-title {
    font-size: 1.05rem;
}
@media (hover: none) and (pointer: coarse) {
    .stack-import-drop-title {
        display: none;
    }
}
.stack-import-page-drop {
    display: contents;
}
.stack-import-overlay {
    display: none;
}
.stack-import-overlay.is-dragging {
    align-items: center;
    background: rgba(15, 23, 42, 0.35);
    border: 0;
    color: inherit;
    display: flex;
    height: auto;
    inset: 0;
    justify-content: center;
    margin: 0;
    padding: 1rem;
    pointer-events: none;
    position: fixed;
    width: auto;
    z-index: 1000;
}
.stack-import-overlay-panel {
    align-items: center;
    background: var(--bg, #fff);
    border: 3px dashed var(--accent, #475569);
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(15, 23, 42, 0.25);
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    max-width: 26rem;
    padding: 2rem 1.5rem;
    text-align: center;
}
.stack-import-overlay-panel strong {
    font-size: 1.25rem;
}
.stack-import-toasts {
    align-items: center;
    background: transparent;
    border: 0;
    bottom: 1rem;
    color: inherit;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    inset: auto 1rem 1rem;
    margin: 0 auto;
    overflow: visible;
    padding: 0;
    pointer-events: none;
    position: fixed;
    z-index: 1001;
}
.stack-import-toasts[popover]:not(:popover-open) {
    display: none;
}
.stack-import-toast {
    background: var(--bg, #fff);
    border: 1px solid rgba(71, 85, 105, 0.3);
    border-radius: 10px;
    box-shadow: 0 6px 24px rgba(15, 23, 42, 0.2);
    margin: 0;
    max-width: 100%;
    padding: 0.6rem 1rem;
    pointer-events: auto;
}
.stack-import-toast:empty {
    display: none;
}
.stack-import-toast--error {
    border-color: rgba(185, 28, 28, 0.5);
    color: #b91c1c;
    cursor: pointer;
}
.user-form-field label {
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.35;
}
.user-form-field input,
.user-form-field select {
    width: 100%;
    padding: 0.65rem 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--border, #cbd5e1);
    background: var(--bg, #fff);
    color: var(--fg, inherit);
    font-size: 1rem;
    font-family: inherit;
    line-height: 1.35;
    box-sizing: border-box;
}
.user-form-field input::placeholder {
    color: var(--muted-fg, #94a3b8);
}
.user-form-field input:focus-visible,
.user-form-field select:focus-visible {
    outline: 2px solid var(--accent, #475569);
    outline-offset: 1px;
}
/* Some fields are one <label> wrapping its words and its input. The words took
   the body size instead of the small bold label, and missing.css's
   `label :is(input, select)` zeroed the input's padding, leaving it a 24px
   sliver beside its full-height neighbours. */
label.user-form-field {
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.35;
}
label.user-form-field .muted {
    font-weight: 400;
}
.user-form-page label.user-form-field > :is(input, select) {
    padding-block: 0.65rem;
    font-weight: 400;
}
.user-form-hint {
    font-size: 0.8125rem;
    color: var(--muted-fg, #64748b);
    line-height: 1.45;
}

.user-form-role-fieldset + .user-form-hint {
    display: block;
    margin-top: 0.75rem;
}
.user-form-hint a {
    color: inherit;
}
.user-form-error {
    color: #dc2626;
    font-size: 0.8125rem;
    line-height: 1.4;
}
.user-form-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.65rem;
    flex-wrap: wrap;
    padding-top: 0.25rem;
}
.user-form-cancel,
.user-form-submit {
    min-width: 7.5rem;
    text-align: center;
    padding: 0.65rem 1.1rem !important;
    font-size: 0.9375rem !important;
    border-radius: 8px !important;
}
.user-form-submit {
    font-weight: 600;
}
.user-form-danger {
    margin-top: 0.5rem;
    border-color: rgba(220, 38, 38, 0.25);
    background: rgba(220, 38, 38, 0.03);
}
.user-form-danger h2 {
    color: #b91c1c;
}
.user-form-danger-text {
    margin: 0 0 1rem;
    font-size: 0.875rem;
    color: var(--muted-fg, #64748b);
    line-height: 1.5;
}
.user-form-delete {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.55rem 1rem !important;
    font-size: 0.875rem !important;
    border-radius: 8px !important;
}
.user-delete-form {
    display: contents;
    margin: 0;
}
.user-form-role-fieldset {
    margin: 0;
    padding: 0;
    border: 0;
}
.user-form-role-list {
    display: grid;
    gap: 0.55rem;
}

.user-form-role-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}
.user-form-role-option {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin: 0;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--border, #cbd5e1);
    border-radius: 8px;
    background: var(--bg, #fff);
    font-weight: 500;
    cursor: pointer;
}
.user-form-role-option:has(input:checked) {
    border-color: var(--accent, #475569);
    background: rgba(71, 85, 105, 0.08);
}
.user-form-role-option input {
    margin: 0;
    flex-shrink: 0;
}
/* An option with a title and a description: centred, the radio sat beside the
   description. Keep it on the title's line and set the description under it. */
.user-form-role-option:has(small) {
    align-items: flex-start;
    padding-block: 0.65rem;
}
.user-form-role-option:has(small) > input {
    margin-top: 0.35rem;
}
.user-form-role-option > span {
    font-weight: 600;
    line-height: 1.5;
}
.user-form-role-option > span > br {
    display: none;
}
.user-form-role-option > span > small {
    display: block;
    margin-top: 0.1rem;
    font-size: 0.8rem;
    font-weight: 400;
    line-height: 1.35;
}
/* missing.css draws a box around every fieldset and puts a double gap between
   sibling sections; inside a form card both are a frame too many. */
.user-form-fieldset {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
}
.user-form-fieldset > .user-form-hint {
    margin: 0 0 0.75rem;
}
.user-form > .user-form-card {
    margin: 0;
}
.user-form-card > .user-form-hint {
    display: block;
    margin-top: 0.75rem;
}
/* missing.css right-aligns placeholders; a hint belongs where typing starts. */
.user-form-field input::placeholder,
.user-form-field textarea::placeholder {
    text-align: start;
}

/* Textareas belong to the same field family as inputs and selects. Keeping the
   shared treatment here prevents native controls from breaking form rhythm. */
.user-form-field textarea {
    width: 100%;
    min-height: 5.5rem;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--border, #cbd5e1);
    border-radius: 8px;
    box-sizing: border-box;
    resize: vertical;
    background: var(--bg, #fff);
    color: var(--fg, inherit);
    font: inherit;
    font-size: 1rem;
    line-height: 1.35;
}

.user-form-field textarea::placeholder {
    color: var(--muted-fg, #94a3b8);
}

.user-form-field textarea:focus-visible {
    outline: 2px solid var(--accent, #475569);
    outline-offset: 1px;
}
.collaboration-roles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
    gap: 0.55rem;
    margin: 1rem 0;
}
.collaboration-roles div,
.collaborator-row {
    border: 1px solid var(--border, #cbd5e1);
    border-radius: 8px;
    background: var(--bg, #fff);
}
.collaboration-roles div {
    display: grid;
    gap: 0.2rem;
    padding: 0.65rem 0.75rem;
}
.collaboration-roles span,
.collaborator-row span {
    color: var(--muted-fg, #64748b);
    font-size: 0.8125rem;
}
/* The Roles page: one fieldset for backgrounds, one for fields. */
.role-rules {
    display: grid;
    gap: 0.4rem;
    margin: 0;
    padding: 0.75rem;
    border: 1px solid var(--border, #cbd5e1);
    border-radius: 8px;
}
.role-rules legend {
    padding: 0 0.3rem;
    font-weight: 600;
}
.role-rules .user-form-hint {
    margin: 0 0 0.25rem;
}
.role-field-table {
    overflow-x: auto;
}
.role-field-table table {
    width: 100%;
    margin: 0;
}
.role-field-table td {
    vertical-align: middle;
}
.role-field-table select {
    margin: 0;
}
.collaboration-safety {
    margin: 0 0 1rem;
    padding: 0.65rem 0.75rem;
    border-left: 3px solid var(--accent, #475569);
    background: rgba(71, 85, 105, 0.08);
    font-size: 0.875rem;
}
.collaborator-list {
    display: grid;
    gap: 0.55rem;
    margin-top: 1.25rem;
}
.collaborator-list h3 {
    margin: 0;
    font-size: 0.875rem;
}
.collaborator-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.65rem 0.75rem;
}
.collaborator-row > div {
    display: grid;
    gap: 0.15rem;
    min-width: 0;
    margin-right: auto;
}
.collaborator-access-form {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}
.collaborator-access-form select,
.collaborator-access-form button,
.collaborator-row .bad {
    margin: 0;
}
@media (max-width: 640px) {
    .collaboration-roles {
        grid-template-columns: 1fr;
    }
    .collaborator-row {
        flex-wrap: wrap;
    }
    .collaborator-access-form {
        width: 100%;
    }
    .collaborator-access-form select {
        flex: 1;
    }
}

@media (max-width: 640px) {
    .user-form-row,
    .user-form-profile-grid,
    .user-form-role-list {
        grid-template-columns: 1fr;
    }
    .card-size-presets {
        grid-template-columns: 1fr;
    }
    .user-form-actions {
        flex-direction: column-reverse;
        align-items: stretch;
    }
    .user-form-cancel,
    .user-form-submit {
        width: 100%;
        min-width: 0;
    }
}

.confirm-modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 1rem;
}

.confirm-modal[hidden] {
    display: none;
}

.confirm-modal-panel {
    background: var(--box-bg, #ffffff);
    border: 1px solid var(--border, #cbd5e1);
    border-radius: 12px;
    padding: 1.5rem;
    max-width: 420px;
    width: 100%;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.18);
}

.confirm-modal-panel h2 {
    margin: 0 0 0.75rem;
    font-size: 1.2rem;
}

.confirm-modal-panel p {
    margin: 0;
    line-height: 1.5;
}

.confirm-modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1.25rem;
}

.confirm-modal-actions button {
    margin: 0;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Help Page Specific Styling */
.help-container {
    max-width: 1000px;
    margin: 2rem auto;
    padding: 0 1.5rem;
}

.help-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.help-search-wrapper {
    position: relative;
    max-width: 500px;
    margin: 1.5rem auto 0 auto;
}

.help-search-input {
    width: 100%;
    padding: 0.75rem 1.25rem;
    border-radius: 50px;
    border: 1px solid var(--border, #cbd5e1);
    background-color: var(--box-bg, #ffffff);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    font-size: 1rem;
    transition: all 0.2s ease;
}

.help-search-input:focus {
    outline: none;
    border-color: var(--accent, #475569);
    box-shadow: 0 0 0 3px rgba(71, 85, 105, 0.15);
}

.help-search-clear {
    position: absolute;
    top: 50%;
    right: 0.75rem;
    width: 2rem;
    height: 2rem;
    margin: 0;
    padding: 0;
    transform: translateY(-50%);
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--muted-fg, #64748b);
    font-size: 1.5rem;
    line-height: 1;
}

.help-search-clear:hover,
.help-search-clear:focus-visible {
    background: var(--accent-bg, rgba(0, 0, 0, 0.05));
    color: var(--accent, #475569);
}

.help-search-input:not(:placeholder-shown) {
    padding-right: 3.25rem;
}

.help-search-hint {
    margin: 0.65rem 0 0;
    color: var(--muted-fg, #64748b);
    font-size: 0.85rem;
}

.help-start-here {
    margin: 0 auto 2.5rem;
    max-width: 850px;
}

.help-start-here h2 {
    margin: 0 0 0.85rem;
    font-size: 1.1rem;
    text-align: center;
}

.help-start-here-links {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.help-start-here-links a {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 1rem;
    border: 1px solid var(--border, #cbd5e1);
    border-radius: 8px;
    background: var(--box-bg, #ffffff);
    color: inherit;
    text-decoration: none;
}

.help-start-here-links a:hover,
.help-start-here-links a:focus-visible {
    border-color: var(--accent, #475569);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.08);
}

.help-start-here-links span {
    color: var(--muted-fg, #64748b);
    font-size: 0.9rem;
}

.help-tabs {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--border, #cbd5e1);
    padding-bottom: 1rem;
}

#help-category-panels {
    min-height: 16rem;
}

.help-tab-btn {
    background: none;
    border: none;
    padding: 0.6rem 1.2rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--muted-fg, #64748b);
    cursor: pointer;
    border-radius: 20px;
    transition: all 0.2s ease;
}

.help-tab-btn:hover {
    background-color: var(--accent-bg, rgba(0, 0, 0, 0.05));
    color: var(--accent, inherit);
}

/* missing.css paints the selected tab with [role="tab"][role="tab"][aria-selected="true"],
   which outranks a two-class selector and left bg-coloured text on a pale box. */
.help-tab-btn.active,
.help-tab-btn[role="tab"][aria-selected="true"] {
    background-color: var(--accent, #475569);
    color: var(--accent-contrast, var(--bg, #ffffff));
}

.help-content-section {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

.help-content-section.active {
    display: block;
}

.help-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

/* Template cards: descriptions differ in length, so pin the count and the
   Clone button to the foot of each card to keep a row's buttons level. */
.stack-template-card {
    display: flex;
    flex-direction: column;
}
.stack-template-card h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0;
}
.stack-template-card > p:not(.muted) {
    margin-bottom: 0.75rem;
}
.stack-template-card > p.muted {
    margin: auto 0 0.6rem;
    font-size: 0.85rem;
}
.stack-template-card > form,
.stack-template-actions form {
    margin: 0;
}
.stack-template-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

/* A template previewed without signing in: what it is, and how to get one. */
.template-preview-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    margin: 0 0 0.75rem;
    padding: 0.6rem 0.9rem;
    border: 1px solid var(--border, #cbd5e1);
    border-radius: 8px;
    background: var(--box-bg, #ffffff);
}
.template-preview-banner p {
    margin: 0;
}

.help-card {
    background-color: var(--box-bg, #ffffff);
    border: 1px solid var(--border, #cbd5e1);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.help-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.06);
    border-color: var(--accent, #475569);
}

.help-card h2,
.help-card h3 {
    margin-top: 0;
    color: var(--accent, #1e293b);
    border-bottom: 1px dashed var(--border, #cbd5e1);
    padding-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.help-card p, .help-card ul {
    margin-bottom: 0;
}

.help-search-result {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
}

.help-search-result-area {
    margin: -0.55rem 0 0 !important;
    color: var(--muted-fg, #64748b);
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.help-card:focus {
    outline: 3px solid rgba(71, 85, 105, 0.3);
    outline-offset: 4px;
}

.help-search-result-link {
    font-weight: 700;
}

.help-search-result-link:focus-visible {
    outline: 3px solid rgba(71, 85, 105, 0.3);
    outline-offset: 3px;
}

.help-search-result mark {
    background: color-mix(in srgb, var(--accent, #475569) 18%, transparent);
    border-radius: 2px;
    color: inherit;
    padding: 0 0.1em;
}

kbd {
    background-color: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    box-shadow: 0 1px 1px rgba(0,0,0,0.1);
    color: #334155;
    display: inline-block;
    font-size: 0.85em;
    font-weight: 700;
    line-height: 1;
    padding: 2px 5px;
    white-space: nowrap;
}

.help-shortcut-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border, #e2e8f0);
}

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

.shortcuts-context {
    font-size: 0.9rem;
    margin: 0 0 0.75rem 0;
}

.shortcuts-list {
    margin-top: 0.25rem;
}

.shortcut-keys {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.25rem;
    justify-content: flex-end;
    text-align: right;
}

.shortcut-or {
    font-size: 0.8rem;
    color: var(--muted, #64748b);
    margin: 0 0.15rem;
}

.help-tip-box {
    background: linear-gradient(135deg, rgba(71, 85, 105, 0.05), rgba(71, 85, 105, 0.01));
    border-left: 4px solid var(--accent, #475569);
    border-radius: 4px;
    padding: 1rem;
    margin: 1.5rem 0;
}

.help-tip-box h4 {
    margin: 0 0 0.5rem 0;
    color: var(--accent, #475569);
    font-size: 1rem;
}

/* Mobile Responsive Adjustments */
@media (max-width: 768px) {
    /* 1. Global layout structure stack */
    .f-row {
        flex-direction: column !important;
        gap: 1.5rem !important;
    }
    .f-row > * {
        width: 100% !important;
        flex: none !important;
    }

    /* 2. Mobile Navigation Header Design */
    header {
        padding: 1rem 1rem 1rem 0.5rem !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.75rem !important;
        position: relative !important;
    }
    header nav {
        display: flex !important;
        flex-wrap: wrap !important;
        justify-content: flex-start !important;
        gap: 0.75rem 1.25rem !important;
        padding-right: 0 !important;
        width: 100% !important;
    }
    .header-actions {
        position: absolute !important;
        top: 0.35rem !important;
        right: 0.5rem !important;
        margin: 0 !important;
    }

    .has-toolbar-brand .header-actions {
        top: var(--toolbar-brand-top-space, 0.5rem) !important;
        right: var(--toolbar-brand-side-space, 0.5rem) !important;
        height: 2.25rem;
    }

    .has-toolbar-brand > header {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        height: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
        min-height: 0 !important;
        border-bottom: none !important;
        overflow: visible !important;
        display: block !important;
        flex-direction: unset !important;
        align-items: unset !important;
        gap: 0 !important;
    }

    .has-toolbar-brand > header nav {
        display: none !important;
    }

    /* Wyldcards editor toolbar: full-width row so File and other menus are not clipped */
    .wyldcards-script-toolbar > .wyldcards-toolbar-row.wyldcards-tools-row {
        grid-template-columns: minmax(0, 1fr);
        column-gap: 0;
    }

    .wyldcards-script-toolbar > .wyldcards-toolbar-row.wyldcards-tools-row .wyldcards-toolbar-main,
    .wyldcards-script-toolbar > .wyldcards-toolbar-row.wyldcards-tools-row .wyldcards-toolbar-right {
        grid-column: 1;
        width: 100%;
        min-width: 0;
    }

    .wyldcards-script-toolbar > .wyldcards-toolbar-row.wyldcards-tools-row .wyldcards-toolbar-right {
        justify-self: stretch;
        justify-content: flex-start;
        margin-top: 0.25rem;
    }

    .wyldcards-script-toolbar,
    .wyldcards-tools-group,
    .wyldcards-toolbar-row.wyldcards-tools-row .wyldcards-toolbar-main {
        overflow: visible;
    }

    .wyldcards-tools-group .file-dropdown .nav-dropdown-menu.file-menu {
        max-width: min(12rem, calc(100vw - 1.5rem));
    }

    /* Keep breadcrumbs wrapping nicely and readable */
    nav[aria-label="Breadcrumb"] ol {
        gap: 0.25rem 0.5rem;
    }

    /* Help center specific mobile styling */
    .help-container {
        margin: 1rem auto !important;
        padding: 0 1rem !important;
    }
    .help-tabs {
        gap: 0.35rem !important;
        border-bottom: none !important;
        padding-bottom: 0 !important;
    }
    .help-start-here-links {
        grid-template-columns: 1fr;
    }
    .help-tab-btn {
        font-size: 0.85rem !important;
        padding: 0.4rem 0.8rem !important;
    }
    .help-card-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)) !important;
        gap: 1rem !important;
    }

    /* Force interactive elements/buttons that only show on hover to be permanently visible on touch devices */
    h1 > small a[role="button"],
    #table-scenes a[role="button"],
    #table-blocks a[role="button"],
    .table-blocks-all a[role="button"]{
        opacity: 1 !important;
        font-size: 0.8em !important;
        display: inline-flex !important;
        align-items: center;
        background-color: var(--accent-bg);
        padding: 0.15rem 0.4rem !important;
        border-radius: 4px;
        border: 1px solid var(--border);
        margin: 0.25rem 0.25rem 0 0 !important;
        vertical-align: middle;
        text-decoration: none;
    }

    /* Generic tables horizontal scroll (exclude flex-layout list tables) */
    table:not(.table-blocks-all):not(#table-blocks):not(#table-wyldcards):not(.wyldcards-list-table):not(.casting-list-table) {
        display: block !important;
        width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
    }
    
    table:not(.table-blocks-all):not(#table-blocks):not(#table-wyldcards):not(.wyldcards-list-table):not(.casting-list-table) th,
    table:not(.table-blocks-all):not(#table-blocks):not(#table-wyldcards):not(.wyldcards-list-table):not(.casting-list-table) td {
        white-space: nowrap;
    }

    /* Wyldcards / casting list — stack toolbar and row actions on narrow viewports */
    .wyldcards-list-header {
        flex-direction: column;
        align-items: stretch;
    }

    .wyldcards-list-create-btn {
        width: 100%;
        text-align: center;
    }

    .wyldcards-list-header-actions {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }

    .wyldcards-list-header-buttons {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }

    .wyldcards-list-import-btn {
        width: 100%;
    }

    .wyldcards-list-toolbar-actions {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        margin-left: 0;
    }

    .wyldcards-list-sort {
        width: 100%;
    }

    .wyldcards-list-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .wyldcards-list-search-wrap {
        flex-basis: auto;
        max-width: none;
        width: 100%;
    }

    .wyldcards-title-container {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .wyldcards-list-actions {
        align-self: stretch;
        gap: 0.4rem;
        flex-wrap: wrap;
    }

    .wyldcards-list-actions .wyldcards-list-action-btn--icon {
        opacity: 1;
    }

    .wyldcards-list-action-btn--primary,
    .wyldcards-list-action-btn--secondary {
        flex: 1 1 auto;
        min-width: 0;
    }

    .wyldcards-list-actions-divider {
        display: none;
    }

    .wyldcards-list-rename-controls {
        flex-wrap: wrap;
    }

    /* Version history creation form stack */
    form[action*="/version/create"] {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.75rem !important;
    }
    form[action*="/version/create"] label {
        width: 100%;
        /* Reset the row-layout flex-basis (18rem) so it is not applied as a
           288px height once the form stacks into a column. */
        flex: 0 0 auto !important;
    }
    form[action*="/version/create"] input {
        min-width: 0 !important;
        width: 100% !important;
    }
    form[action*="/version/create"] button {
        width: 100%;
        margin: 0 !important;
    }
}

/* Card-based Block List for Small Mobiles */
@media (max-width: 600px) {
    .table-blocks-all, #table-blocks,
    .table-blocks-all tbody, #table-blocks tbody,
    .table-blocks-all tr, #table-blocks tr,
    .table-blocks-all td, #table-blocks td {
        display: block !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .table-blocks-all tr, #table-blocks tr {
        background-color: var(--box-bg, #ffffff) !important;
        border: 1px solid var(--border, #cbd5e1) !important;
        border-radius: 8px !important;
        margin-bottom: 1rem !important;
        padding: 0.75rem !important;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.03) !important;
        position: relative !important;
    }

    .table-blocks-all tr.dragging, #table-blocks tr.dragging {
        opacity: 0.5 !important;
    }

    /* Left controls cell styled as card header */
    .table-blocks-all td.block-left-controls, #table-blocks td.block-left-controls {
        padding: 0 0 0.5rem 0 !important;
        border-bottom: none !important;
        margin-bottom: 0.5rem !important;
    }

    #table-blocks tr .block-left-controls-inner,
    .table-blocks-all tr .block-left-controls-inner {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        width: 100% !important;
        gap: 12px !important;
    }

    /* Touch-friendly Drag Handle */
    .table-blocks-all .drag-handle, #table-blocks .drag-handle {
        font-size: 1.5em !important;
        padding: 0.25rem 0.75rem !important;
        background-color: var(--accent-bg);
        border-radius: 4px;
        border: 1px solid var(--border);
        color: var(--muted);
    }

    /* Checkbox layout alignment */
    #table-blocks tr .block-select-checkbox,
    .table-blocks-all tr .block-select-checkbox {
        width: 1.35rem !important;
        height: 1.35rem !important;
        margin: 0 !important;
    }

    /* Touch-friendly + Create Below Button */
    #table-blocks tr a.create-below[role="button"],
    .table-blocks-all tr a.create-below[role="button"],
    #table-blocks tr button.create-below.create-below-menu-toggle,
    .table-blocks-all tr button.create-below.create-below-menu-toggle {
        width: 2rem !important;
        height: 2rem !important;
        min-width: 2rem !important;
        font-size: 1.25rem !important;
        opacity: 0.7 !important;
    }

    .block-row:hover a.create-below[role="button"],
    tr[data-block-id]:hover a.create-below[role="button"],
    .block-row:hover button.create-below.create-below-menu-toggle,
    tr[data-block-id]:hover button.create-below.create-below-menu-toggle {
        opacity: 1 !important;
    }

    /* Content Area inside Card */
    .table-blocks-all td.block-content, #table-blocks td.block-content {
        padding: 0.5rem 0 !important;
        font-size: 1.05rem !important;
        line-height: 1.5 !important;
    }

    .table-blocks-all td.block-content p, #table-blocks td.block-content p {
        margin-top: 0 !important;
        margin-bottom: 0 !important;
    }

    /* Right controls styled as card footer toolbar */
    .table-blocks-all td:last-child, #table-blocks td:last-child {
        padding: 0.5rem 0 0 0 !important;
        border-top: none !important;
        margin-top: 0.5rem !important;
        display: flex !important;
        justify-content: flex-end !important;
        align-items: center !important;
    }

    .table-blocks-all td:last-child .block-actions-controls,
    #table-blocks td:last-child .block-actions-controls,
    .table-blocks-all td:last-child .nowrap,
    #table-blocks td:last-child .nowrap {
        display: inline-flex !important;
        align-items: center !important;
        gap: 12px !important;
        width: 100% !important;
        justify-content: flex-end !important;
        flex-wrap: wrap !important;
    }

    /* Make star, bookmark, pin, edit/delete links look premium and touch-friendly */
    .table-blocks-all td:last-child a, #table-blocks td:last-child a {
        text-decoration: none !important;
        font-size: 1rem !important;
        padding: 0.35rem 0.6rem !important;
        background-color: var(--accent-bg);
        border: 1px solid var(--border);
        border-radius: 4px;
        color: var(--text);
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        min-height: 36px;
    }

    .table-blocks-all td:last-child a[role="button"], #table-blocks td:last-child a[role="button"] {
        opacity: 1 !important;
        font-size: 0.85rem !important;
        font-weight: 500 !important;
    }

    .table-blocks-all td:last-child a.move-up, #table-blocks td:last-child a.move-up{
        opacity: 1 !important;
        width: 36px !important;
        height: 36px !important;
        padding: 0 !important;
    }

    .table-blocks-all tr:last-child .move-up, #table-blocks tr:last-child .move-up {
        margin-left: 0 !important;
    }

    /* Inline search in the wyldcards tools row — icon/label; field expands when open */
    .wyldcards-search-dropdown {
        flex: 0 0 auto !important;
        max-width: none !important;
        min-width: 0 !important;
        margin-left: 0 !important;
    }

    .wyldcards-search-dropdown.is-open {
        flex: 1 1 auto !important;
        max-width: min(18rem, 100%) !important;
    }

    .wyldcards-share-dropdown .nav-dropdown-menu {
        min-width: calc(100vw - 2rem) !important;
        max-width: calc(100vw - 2rem) !important;
        right: 0 !important;
        left: auto !important;
    }

    .wyldcards-search-input {
        font-size: 1rem !important;
    }

    /* Ensure text inputs, textareas on all forms do not cause horizontal layout breaks */
    input[type="text"], input[type="password"], textarea, select {
        max-width: 100% !important;
        width: 100% !important;
    }
}

/* Compact top layout rules */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}
.wyldcards-script-toolbar,
.wyldcards-script-select-toolbar,
aside.block-left-controls,
aside.block-actions {
    border: none;
    border-block: none;
    padding-block: 0;
    margin-block: 0;
    font-size: inherit;
    line-height: inherit;
}

.top-bar nav[aria-label="Breadcrumb"] {
    margin: 0 !important;
}

.has-toolbar-brand > header nav {
    display: none;
}

.has-toolbar-brand > header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 0;
    padding: 0;
    margin: 0;
    min-height: 0;
    border-bottom: none;
    overflow: visible;
    /* Above tools-row dropdowns (1300) and open Share top-bar (1400). */
    z-index: 1500;
}

.has-toolbar-brand .header-actions {
    top: var(--toolbar-brand-top-space, 0.5rem);
    right: var(--toolbar-brand-side-space, 0.5rem);
    height: 2.25rem;
    z-index: 1500;
}

.has-toolbar-brand .header-actions .nav-dropdown-menu {
    z-index: 1501;
}

/* On a card the actions sat on the page's top padding, a line above the card
   toolbar they share a row with; drop them onto its controls' centre line
   (the card page's 0.75rem top padding plus the toolbar's 0.5rem). */
@media (min-width: 769px) {
    html:not(.app-shell) body.has-toolbar-brand:has(> main.wyldcards-card-page) .header-actions {
        top: calc(var(--toolbar-brand-top-space, 1rem) + 1.25rem);
    }
}

body.has-toolbar-brand {
    --toolbar-brand-top-space: 1rem;
    --toolbar-brand-bottom-space: 0.75rem;
    --toolbar-brand-side-space: 1.25rem;
    --toolbar-brand-header-actions-space: 3.5rem;
    --wyldcards-chrome-inset: 0.25rem;
    padding-top: var(--toolbar-brand-top-space);
    padding-left: var(--toolbar-brand-side-space);
    padding-right: var(--toolbar-brand-side-space);
}

.has-toolbar-brand .wyldcards-script-toolbar {
    margin: 0 0 var(--toolbar-brand-bottom-space, 0.5rem);
    padding: 0 var(--wyldcards-chrome-inset, 0);
}

/* Wide screens: lift the tools row up onto the breadcrumb row so the editor
   chrome uses one row instead of two. The toolbar overlays the top bar, so it
   must not steal clicks from the breadcrumb/Share (pointer-events) while its
   own controls stay clickable. */
@media (min-width: 1280px) {
    .has-toolbar-brand .wyldcards-script-toolbar {
        position: relative;
        /* Above .wyldcards-top-bar (z 20); menus that open (z 1300+) still win. */
        z-index: 30;
        /* Breadcrumb row min-height (2.25rem) + top bar bottom margin (0.25rem). */
        margin-top: -2.5rem;
        pointer-events: none;
    }

    .has-toolbar-brand .wyldcards-script-toolbar .wyldcards-toolbar-main,
    .has-toolbar-brand .wyldcards-script-toolbar .wyldcards-toolbar-left,
    .has-toolbar-brand .wyldcards-script-toolbar .wyldcards-toolbar-right {
        pointer-events: auto;
    }

    .has-toolbar-brand .wyldcards-script-toolbar > .wyldcards-toolbar-row.wyldcards-tools-row {
        min-height: 2.25rem;
        align-content: center;
        margin-bottom: 0;
    }

    /* Keep the word-count stats clear of Share and the account menu. */
    .has-toolbar-brand .wyldcards-script-toolbar > .wyldcards-tools-row .wyldcards-toolbar-right {
        margin-right: 10rem;
        pointer-events: none;
    }

    .has-toolbar-brand .wyldcards-script-toolbar > .wyldcards-tools-row .wyldcards-toolbar-right > * {
        pointer-events: auto;
    }
}

.has-toolbar-brand .wyldcards-script-select-toolbar {
    margin: 0;
    padding: 0;
    width: 100%;
    max-width: 100%;
}

.wyldcards-script-toolbar > .wyldcards-toolbar-row.wyldcards-tools-row,
.wyldcards-script-toolbar > .wyldcards-toolbar-row:not(.wyldcards-tools-row) {
    display: grid;
}

.wyldcards-script-toolbar > .wyldcards-toolbar-row:not(.wyldcards-tools-row):has(.tags-bulk-action:not([hidden])) {
    display: grid;
}

.has-toolbar-brand main {
    padding-top: 0.75rem !important;
}

.top-bar .toolbar-brand-link {
    text-decoration: none;
    color: inherit;
}

.top-bar .toolbar-brand-link strong {
    font-weight: 700;
}

.top-bar .text-size-control {
    margin: 0 !important;
    flex: 0 1 auto;
    justify-content: flex-end;
}

main {
    padding-top: 0.4rem !important;
}

main h1 {
    margin-top: 0.4rem !important;
    margin-bottom: 0.4rem !important;
}

/* :not(.script-block-text) — screenplay headings are laid out by the block rules */
main h2:not(.script-block-text) {
    margin-top: 0.4rem !important;
    margin-bottom: 0.4rem !important;
}

main h3:not(.script-block-text) {
    margin-top: 0.4rem !important;
    margin-bottom: 0.4rem !important;
}

/* Title Page Feature Styles */
.title-page-editor-container {
    display: flex;
    gap: 2rem;
    align-items: stretch;
    margin-top: 1.5rem;
}

.title-page-form-panel {
    flex: 1;
    min-width: 300px;
}

.title-page-form-panel form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.title-page-form-panel label {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-weight: 600;
}

.title-page-form-panel input[type="text"],
.title-page-form-panel textarea {
    padding: 0.75rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    background-color: var(--bg);
    color: var(--fg);
    font-size: 1rem;
    font-family: inherit;
}

.title-page-form-panel textarea {
    resize: vertical;
}

.title-page-form-panel .field-error {
    color: #ef4444;
    font-size: 0.85rem;
    font-weight: normal;
}

.title-page-form-panel .form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.title-page-form-panel .form-actions a,
.title-page-form-panel .form-actions button {
    flex: 1;
    text-align: center;
    padding: 0.75rem;
    font-size: 1rem;
    border-radius: 6px;
    cursor: pointer;
}

.title-page-preview-panel {
    flex: 1;
    min-width: 300px;
    display: flex;
    flex-direction: column;
}

.title-page-preview-panel .preview-header {
    text-align: center;
    margin-bottom: 1rem !important;
}

.screenplay-paper-wrapper {
    background-color: var(--accent-bg);
    padding: 2rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    flex-grow: 1;
}

.screenplay-paper {
    background-color: #ffffff;
    color: #111111;
    border: 1px solid #cbd5e1;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    aspect-ratio: 8.5 / 11;
    width: 100%;
    max-width: 420px;
    padding: 3rem 2.5rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-sizing: border-box;
    border-radius: 4px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.95rem;
    line-height: 1.4;
}

:root.-dark-theme .screenplay-paper {
    background-color: #1e1e1e;
    color: #e2e8f0;
    border-color: #475569;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

@media (prefers-color-scheme: dark) {
    :root:not(.-no-dark-theme) .screenplay-paper {
        background-color: #1e1e1e;
        color: #e2e8f0;
        border-color: #475569;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    }
}

.screenplay-title-wrap {
    margin-top: 35%;
    text-align: center;
}

.screenplay-preview-title {
    font-weight: bold;
    text-transform: uppercase;
    font-size: 1.35rem;
    margin-bottom: 1.5rem;
    letter-spacing: 0.5px;
    word-break: break-word;
}

.screenplay-preview-by {
    margin-bottom: 1.5rem;
    font-style: italic;
}

.screenplay-preview-writers {
    font-size: 1.1rem;
    word-break: break-word;
}

.screenplay-preview-version {
    margin-top: 1.25rem;
    font-size: 0.95rem;
    word-break: break-word;
}

.screenplay-preview-contact {
    margin-top: auto;
    font-size: 0.85rem;
    text-align: left;
    max-width: 75%;
    white-space: pre-wrap;
    line-height: 1.4;
    word-break: break-word;
}

/* Responsive wrap */
@media (max-width: 768px) {
    .title-page-editor-container {
        flex-direction: column;
    }
    .screenplay-paper {
        max-width: 100%;
    }
}

/* Safari Reader / read view */
.script-read-view .script-scene {
    margin-bottom: 2rem;
}

/* Screenplay block spacing (read views) */
.script-block {
    margin-top: 1em;
}

.script-block:first-child {
    margin-top: 0;
}

/* Continuous flow on wyldcards page — no extra block/scene gaps */
.wyldcards-script .table-blocks-all .block-row {
    margin-top: 0;
}

.wyldcards-script .script-scene + .script-scene {
    margin-top: 0;
}

#wyldcards-script-body {
    display: contents;
}

.wyldcards-script{
    --screenplay-action-width: 6in;
    --screenplay-dialogue-width: 3.5in;
    /* Left indents as % of the 6in action column: 2.2in / 1in / 1.5in —
       matches page-view and print (industry-standard screenplay positions). */
    --screenplay-character-indent: 36.667%;
    --screenplay-dialogue-indent: 16.667%;
    --screenplay-parenthetical-indent: 25%;
    --screenplay-chrome-gap: 1rem;
    --screenplay-paper: var(--box-bg, #fff);
    --screenplay-desk: transparent;
    width: 100%;
    max-width: 100%;
}

/* Continuous edit: no tinted desk — script sits on the page background */
html:not(.wyldcards-page-view-mode) .wyldcards-script {
    padding: 1.25rem 0.75rem 2.5rem;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

/* Escape Missing.css main { max-inline-size: var(--eff-line-length) } (~40rem).
   The screenplay grid is 6in of action text plus the left control gutter and
   right actions gutter (~52rem total). At the ~40rem cap it overflowed to the
   right, so the centered body column no longer lined up under the centered
   header title. Widen main just enough to hold the grid, so its symmetric
   gutters center the action column on the same axis as the title. Page-view
   and full-width modes escape the cap with their own rules above/below. */
html:not(.wyldcards-page-view-mode):not(.wyldcards-screenplay-full-width) main:has(.wyldcards-script) {
    max-inline-size: min(100%, 52rem);
}

:root.-dark-theme:not(.wyldcards-page-view-mode) .wyldcards-script {
    --screenplay-paper: color-mix(in srgb, var(--box-bg, #1e293b) 88%, #0f172a);
    --screenplay-desk: color-mix(in srgb, var(--bg, #0f172a) 85%, #1e293b);
}

@media (prefers-color-scheme: dark) {
    :root:not(.-no-dark-theme):not(.wyldcards-page-view-mode) .wyldcards-script {
        --screenplay-paper: color-mix(in srgb, var(--box-bg, #1e293b) 88%, #0f172a);
        --screenplay-desk: color-mix(in srgb, var(--bg, #0f172a) 85%, #1e293b);
    }
}

.wyldcards-script .script-scene {
    display: grid;
    grid-template-columns: 1fr min(var(--screenplay-action-width), 100%) 1fr;
    column-gap: var(--screenplay-chrome-gap);
    width: 100%;
    max-width: 100%;
}

.wyldcards-script .block-content,
#table-blocks .block-content,
.table-blocks-all .block-content{
    font-family: 'Courier New', Courier, monospace;
    font-size: calc(12pt * var(--wyldcards-text-scale, 1));
    line-height: 1.5;
    width: min(var(--screenplay-action-width, 6in), 100%);
    max-width: min(var(--screenplay-action-width, 6in), 100%);
}

.script-read-view .script-character-name,
#table-blocks .block-content .script-character-name,
.table-blocks-all .block-content .script-character-name,
.wyldcards-script .block-content .script-character-name {
    position: relative;
    margin: 0 0 0.15em;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
}

#table-blocks .block-content .character-name,
.table-blocks-all .block-content .character-name {
    margin-bottom: 0;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
}

.script-block--dialogue .script-block-text,
.script-block--dialogue .reader-visible-text,
.wyldcards-script .block-row:has(.script-character-name) .script-block-text,
.wyldcards-script .block-row:has(.script-character-name) .reader-visible-text,
.wyldcards-script .block-content:has(.script-character-name) .block-input-textarea,
#table-blocks tr[data-block-id]:has(.script-character-name) .script-block-text,
#table-blocks tr[data-block-id]:has(.script-character-name) .reader-visible-text,
#table-blocks tr[data-block-id]:has(.script-character-name) .block-input-textarea,
.table-blocks-all .block-row:has(.script-character-name) .script-block-text,
.table-blocks-all .block-row:has(.script-character-name) .reader-visible-text,
.table-blocks-all .block-row:has(.script-character-name) .block-input-textarea {
    max-width: min(var(--screenplay-dialogue-width, 3.5in), 100%);
    margin-left: auto;
    margin-right: auto;
    display: block;
}

.script-read-view .script-block-text,
#table-blocks .block-content .script-block-text,
.table-blocks-all .block-content .script-block-text,
.wyldcards-script .block-content .script-block-text {
    white-space: pre-wrap;
    margin: 0;
    min-height: 1.5em;
}

.wyldcards-script .block-content .script-block-text:not(textarea),
.table-blocks-all .block-content .script-block-text:not(textarea),
#table-blocks .block-content .script-block-text:not(textarea),
.wyldcards-script .block-content .reader-visible-text,
.table-blocks-all .block-content .reader-visible-text,
#table-blocks .block-content .reader-visible-text,
.wyldcards-script .block-content .character-name,
.table-blocks-all .block-content .character-name,
#table-blocks .block-content .character-name,
.wyldcards-script .block-content .reader-visible-character-name,
.table-blocks-all .block-content .reader-visible-character-name,
#table-blocks .block-content .reader-visible-character-name {
    user-select: text;
}

.wyldcards-script .block-content .script-block-text[contenteditable]:not(textarea),
.table-blocks-all .block-content .script-block-text[contenteditable]:not(textarea),
#table-blocks .block-content .script-block-text[contenteditable]:not(textarea),
.wyldcards-script .block-content .reader-visible-text[contenteditable],
.table-blocks-all .block-content .reader-visible-text[contenteditable],
#table-blocks .block-content .reader-visible-text[contenteditable] {
    outline: none;
    cursor: text;
    caret-color: auto;
}

.block-selection-menu {
    position: fixed;
    z-index: 1200;
    display: inline-flex;
    align-items: stretch;
    gap: 0.1rem;
    padding: 0.28rem;
    border: 1px solid var(--border, #cbd5e1);
    border-radius: calc(var(--border-radius, 6px) + 4px);
    background: var(--box-bg, #fff);
    box-shadow: none;
    user-select: none;
    -webkit-user-select: none;
    animation: blockSelectionMenuIn 0.14s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes blockSelectionMenuIn {
    from {
        opacity: 0;
        transform: translateY(4px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.block-selection-menu-divider {
    width: 1px;
    align-self: stretch;
    margin: 0.12rem 0.08rem;
    background: var(--border, #cbd5e1);
    flex-shrink: 0;
}

.block-selection-menu-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.38rem;
    border: none;
    background: transparent;
    color: var(--fg, #0f172a);
    font: inherit;
    font-size: 0.82rem;
    line-height: 1.2;
    padding: 0.34rem 0.58rem;
    border-radius: calc(var(--border-radius, 6px) + 1px);
    cursor: pointer;
    white-space: nowrap;
}

.block-selection-menu-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    opacity: 0.78;
}

.block-selection-menu-btn:hover,
.block-selection-menu-btn:focus-visible {
    background: var(--accent-bg, rgba(0, 0, 0, 0.05));
    outline: none;
}

.block-selection-menu-btn:focus-visible {
    box-shadow: 0 0 0 2px var(--accent-bg, rgba(0, 0, 0, 0.08)), 0 0 0 3px var(--accent, #475569);
}

.block-selection-menu-btn[data-action="delete"]:hover,
.block-selection-menu-btn[data-action="delete"]:focus-visible {
    color: #b91c1c;
    background: rgba(185, 28, 28, 0.08);
}

:root.-dark-theme .block-selection-menu-btn[data-action="delete"]:hover,
:root.-dark-theme .block-selection-menu-btn[data-action="delete"]:focus-visible {
    color: #fca5a5;
    background: rgba(248, 113, 113, 0.12);
}

.wyldcards-script aside.block-left-controls,
.wyldcards-script aside.block-actions,
#table-blocks td.block-left-controls,
#table-blocks td.block-actions-cell,
.table-blocks-all td.block-left-controls,
.table-blocks-all td.block-actions-cell,
.block-left-controls-inner,
.block-actions-controls,
.block-element-label,
.block-select-checkbox,
.block-select-all-checkbox,
a.create-below[role="button"],
.create-below-menu-dropdown,
button.create-below.create-below-menu-toggle,
.drag-handle,
.block-drag-menu-dropdown,
button.block-drag-menu-toggle,
.block-action-bookmark,
.block-action-pin,
.block-action-source,
.block-action-move {
    user-select: none;
    -webkit-user-select: none;
}

html.wyldcards-block-text-selecting .wyldcards-script aside.block-left-controls,
html.wyldcards-block-text-selecting .wyldcards-script aside.block-actions,
html.wyldcards-block-text-selecting #table-blocks td.block-left-controls,
html.wyldcards-block-text-selecting #table-blocks td.block-actions-cell,
html.wyldcards-block-text-selecting .table-blocks-all td.block-left-controls,
html.wyldcards-block-text-selecting .table-blocks-all td.block-actions-cell,
html.wyldcards-block-text-selecting .block-element-label,
html.wyldcards-block-text-selecting .block-left-controls-inner,
html.wyldcards-block-text-selecting .block-actions-controls {
    pointer-events: none;
}

.script-block-text:empty::before {
    content: '\00a0';
}

#table-blocks tr[data-block-id] td.block-content {
    padding-top: 1em;
}

#table-blocks tr[data-block-id]:first-of-type td.block-content {
    padding-top: 0;
}

.wyldcards-script-toolbar {
    margin-bottom: 0.35rem;
    width: 100%;
    max-width: 100%;
}

/* Keep the bold slug weight while the SCENE block is being edited (the edit
   textarea/mirror carry .script-block-text, not .scene-header) so it doesn't
   flip to normal weight on focus. Alignment is already flush-left by default. */
.wyldcards-script .block-content.block-type-scene .script-block-text,
.wyldcards-script .block-content.block-type-scene .reader-visible-text,
.wyldcards-script .block-content.block-type-scene .block-input-textarea {
    font-weight: 700;
}

.wyldcards-script h3.script-block-text {
    margin: 0;
    font-size: inherit;
    font-weight: inherit;
    font-family: inherit;
    line-height: inherit;
}

/* Character name: plain text for Reader; edit link for the editor */
html:not(.safari-reader-view) .block-content .reader-visible-character-name {
    /* Keep in flow for Safari extraction — visually match the edit link overlay */
    display: block;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
    margin: 0 0 0.15em;
}

/* Transparent click overlay — no link text (avoids Reader link-density drops) */
html:not(.safari-reader-view):not(.wyldcards-page-view-mode) .block-content .character-name.hide-in-reader-view {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    margin: 0;
    padding: 0;
    border: 0;
    text-align: center;
    z-index: 1;
    background: transparent;
    color: transparent;
    font-size: 0;
    line-height: 0;
    text-decoration: none;
    cursor: pointer;
}

html.safari-reader-view .hide-in-reader-view {
    display: none !important;
}

html.safari-reader-view .block-row[data-block-type="SYNOPSIS"],
html.safari-reader-view .block-row[data-block-type="NOTE"] {
    display: none !important;
}

html.safari-reader-view body > header,
html.safari-reader-view .wyldcards-script-toolbar {
    display: none !important;
}

html.safari-reader-view main {
    max-width: 40rem;
    margin: 0 auto;
    padding: 2rem 1.25rem 3rem;
    font-family: Georgia, "Times New Roman", serif;
    line-height: 1.65;
}

html.safari-reader-view .wyldcards-script .script-scene,
html.safari-reader-view .wyldcards-script .block-row {
    display: block;
}

html.safari-reader-view .wyldcards-script .block-content {
    width: auto;
    max-width: none;
    font-family: inherit;
    font-size: inherit;
}

html.safari-reader-view .wyldcards-script .script-block-text {
    margin: 0 0 1rem;
}

html.safari-reader-view .wyldcards-script .script-block {
    margin-top: 0;
}

html.safari-reader-view .wyldcards-header-title .reader-visible-wyldcards-title {
    font-size: 1.75rem;
    line-height: 1.25;
    margin-bottom: 1rem;
}

html.safari-reader-view .wyldcards-script .reader-visible-scene-name {
    display: inline;
}
html.safari-reader-view .block-content form[hx-post*="/block/editInline"] {
    display: none !important;
}

html.safari-reader-view .block-content > .reader-visible-text,
html.safari-reader-view .block-content .reader-visible-text {
    display: block !important;
    visibility: visible !important;
    position: static !important;
    width: auto !important;
    height: auto !important;
    margin: 0 0 1rem !important;
    overflow: visible !important;
    clip: auto !important;
    white-space: pre-wrap !important;
    border: 0 !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* Print styles consolidated at end of file */

/* Minimal pages for Safari Reader (/scene/all, /scene/read) */
.script-reader-page main {
    max-width: 40rem;
    margin: 0 auto;
    padding: 2rem 1.25rem 3rem;
}

.script-reader-page {
    margin: 0;
    line-height: 1.65;
    font-family: Georgia, "Times New Roman", serif;
    color: var(--fg, #111);
    background: var(--bg, #fff);
}

.script-reader-page article h1 {
    font-size: 1.75rem;
    margin: 0 0 1.5rem;
    line-height: 1.25;
}

.script-reader-page article h2 {
    font-size: 1.1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 2rem 0 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border, #ddd);
}

.script-reader-page article h2:first-of-type {
    border-top: none;
    padding-top: 0;
    margin-top: 0;
}

.script-reader-page .script-block p {
    margin: 0;
}

.script-reader-page article p {
    margin: 0 0 1rem;
    white-space: pre-wrap;
}

.script-reader-page .script-character-name {
    text-align: center;
    margin-bottom: 0.25rem;
}

.script-reader-page .script-character-name strong {
    font-weight: 700;
    letter-spacing: 0.06em;
}

.script-reader-page .script-reader-byline {
    color: var(--muted-fg, #666);
    font-style: italic;
    margin: -1rem 0 1.5rem;
}

.script-reader-footer {
    max-width: 40rem;
    margin: 0 auto;
    padding: 0 1.25rem 2rem;
    font-family: system-ui, sans-serif;
    font-size: 0.9rem;
}

.script-reader-footer a {
    color: var(--accent, #475569);
}

.script-reader-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg, #fff);
    border-bottom: 1px solid var(--graphical-fg, #e5e7eb);
    /* Aligns the link with the 40rem text column (which carries 1.25rem of side padding). */
    padding: 0.75rem max(1.25rem, calc((100% - 42.5rem) / 2 + 1.25rem));
    font-family: system-ui, sans-serif;
    font-size: 0.9rem;
}

.script-reader-header .script-reader-back {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--accent, #475569);
    text-decoration: none;
}

.script-reader-header .script-reader-back:hover {
    text-decoration: underline;
}

.script-reader-page main {
    padding-top: 1.5rem;
}

@media print {
    .script-reader-header {
        display: none;
    }
}

/* ---------- Quick capture ---------- */
.wyldcards-capture-page {
    width: min(100% - 2rem, 42rem);
    margin: 3.5rem auto;
}
.wyldcards-capture-breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    color: var(--muted-fg, #64748b);
    font-size: 0.9rem;
}
.wyldcards-capture-breadcrumb span::before {
    content: "/";
    margin-right: 0.5rem;
}
.wyldcards-capture-page header {
    margin-bottom: 1.75rem;
}
.wyldcards-capture-eyebrow {
    margin: 0 0 0.45rem;
    color: var(--accent, #2563eb);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.wyldcards-capture-page h1 {
    margin: 0;
    font-size: clamp(1.7rem, 5vw, 2.45rem);
    line-height: 1.08;
}
.wyldcards-capture-page header > p:last-child {
    margin: 0.8rem 0 0;
    color: var(--muted-fg, #64748b);
}
.wyldcards-capture-form {
    display: grid;
    gap: 1.15rem;
    padding: clamp(1rem, 4vw, 1.75rem);
    border: 1px solid var(--border, #d8dee9);
    border-radius: 14px;
    background: var(--plain-bg, #fff);
    box-shadow: 0 16px 40px color-mix(in srgb, #172033 10%, transparent);
}
.wyldcards-capture-form label {
    display: grid;
    gap: 0.45rem;
    font-weight: 650;
}
.wyldcards-capture-form input,
.wyldcards-capture-form textarea {
    width: 100%;
    box-sizing: border-box;
    margin: 0;
    font: inherit;
    font-weight: 400;
}
.wyldcards-capture-form textarea {
    min-height: 12rem;
    resize: vertical;
}
.wyldcards-capture-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.8rem;
    margin-top: 0.3rem;
}
.wyldcards-capture-actions button,
.wyldcards-capture-cancel {
    min-height: 2.75rem;
    margin: 0;
}
.wyldcards-capture-cancel {
    display: inline-flex;
    align-items: center;
    padding: 0.4rem 0.75rem;
    color: inherit;
    text-decoration: none;
}
@media (max-width: 720px) {
    .wyldcards-capture-page {
        width: auto;
        margin: 0;
        padding: 1.25rem 1rem 2rem;
    }
    .wyldcards-capture-breadcrumb {
        display: none;
    }
    .wyldcards-capture-page header {
        margin-bottom: 1.35rem;
    }
    .wyldcards-capture-form {
        margin-inline: -0.15rem;
    }
    .wyldcards-capture-form textarea {
        min-height: 15rem;
    }
    .wyldcards-capture-actions {
        justify-content: stretch;
    }
    .wyldcards-capture-actions button,
    .wyldcards-capture-cancel {
        flex: 1;
        justify-content: center;
        text-align: center;
    }
}

/* Product analytics: restrained summary cards for the administrator dashboard. */
.analytics-page {
    max-width: 1050px;
    margin: 2.5rem auto;
    padding: 0 1.25rem;
}

.analytics-header {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.analytics-header h1 {
    margin: 0;
}

.analytics-header .muted {
    margin: 0.35rem 0 0;
}

.analytics-eyebrow,
.analytics-label {
    margin: 0;
    color: var(--muted, #64748b);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.analytics-users-link {
    white-space: nowrap;
}

.analytics-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
}

.analytics-card {
    min-height: 11rem;
    padding: 1.25rem;
    border: 1px solid var(--border, #cbd5e1);
    border-radius: 14px;
    background: var(--card-bg, #fff);
    display: flex;
    flex-direction: column;
}

.analytics-card--accent {
    border-color: rgba(37, 99, 235, 0.35);
    background: rgba(37, 99, 235, 0.06);
}

.analytics-value {
    margin: auto 0 0.2rem;
    color: var(--fg, #172033);
    font-size: clamp(2.3rem, 5vw, 3.5rem);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.05em;
    line-height: 1;
}

.analytics-detail {
    margin: 0;
    color: var(--muted, #64748b);
    font-size: 0.88rem;
}

.analytics-note {
    margin-top: 1.25rem;
    padding: 1rem 1.25rem;
    border-left: 3px solid var(--accent, #2563eb);
    background: var(--accent-bg, rgba(37, 99, 235, 0.08));
}

.analytics-note p {
    margin: 0.35rem 0 0;
}

@media (max-width: 760px) {
    .analytics-page {
        margin: 1.5rem auto;
    }

    .analytics-header {
        align-items: start;
        flex-direction: column;
    }

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

    .analytics-card {
        min-height: 9rem;
    }
}

@media (max-width: 420px) {
    .analytics-grid {
        grid-template-columns: 1fr;
    }
}

.wyldcards-script-actions,
.wyldcards-script-toolbar{
    font-size: 0.95rem;
}

.wyldcards-script-actions {
    margin: 0;
}

.block-actions-controls {
    display: inline-grid;
    /* Still four lanes. The mark on a line inserted from a song is the fifth
       control and wraps onto a second row beneath the bookmark rather than
       taking a lane of its own: the margin this sits in is a `1fr` column that
       collapses to the controls' own width on a narrow window, so another
       1.25rem across pushes the whole script sideways on a phone — and it
       would do it on every row, for a mark almost none of them carry. Down
       costs nothing; the margin has the room. */
    grid-template-columns: repeat(4, 1.15rem);
    align-items: center;
    justify-items: center;
    gap: 0.1rem;
    line-height: 1;
}

.block-actions-controls .block-action-bookmark,
.block-actions-controls .block-action-pin,
.block-actions-controls .block-action-move,
.block-actions-controls .block-action-source,
.block-actions-controls .block-action-slot {
    width: 1.15rem;
    margin: 0 !important;
    text-align: center;
}

.block-action-source {
    /* Under the bookmark, at the head of its own row — see the grid above. */
    grid-column: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--muted-fg, #64748b);
    text-decoration: none;
}

.block-action-source:hover,
.block-action-source:focus-visible {
    color: var(--accent-fg, #2563eb);
}

.block-actions-controls .block-action-slot {
    display: inline-block;
    height: 1em;
}

.block-actions-controls .block-action-bookmark,
.block-actions-controls .block-action-pin {
    text-decoration: none;
}

.block-action-bookmark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.block-action-pin {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}
.text-size-control .spellcheck-toggle-btn svg,
.text-size-control .drafts-toolbar-btn svg,
.text-size-control .file-toolbar-btn svg,
.text-size-control .view-toolbar-btn svg,
.text-size-control .history-toolbar-btn svg {
    display: block;
}

.script-edition-row .script-edition-lock-toggle .lock-icon {
    width: 13px;
    height: 13px;
}
.text-size-control #page-view-mode-toggle[aria-pressed="true"] {
    box-shadow: 0 2px 4px -1px var(--fg) inset;
    background: var(--pressed-interactive-bg);
    color: var(--accent);
}

@keyframes screenplay-page-settle {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.988);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Continuous edit/read mode: industry-standard left-indented screenplay
   positions within the centered action column — character 2.2in, dialogue
   1in (3.5in wide), parenthetical 1.5in — instead of the older centered
   layout. Scoped to desktop/tablet and non-page-view; page-view and print
   keep their own (matching) rules, and the mobile block below keeps its
   centered narrow column. */
@media screen and (min-width: 641px) {
    html:not(.wyldcards-page-view-mode) .wyldcards-script .block-content .script-character-name,
    html:not(.wyldcards-page-view-mode) .wyldcards-script .block-content.block-type-character .script-block-text,
    html:not(.wyldcards-page-view-mode) .wyldcards-script .block-content.block-type-character .reader-visible-text,
    html:not(.wyldcards-page-view-mode) .wyldcards-script .block-content.block-type-character .block-input-textarea,
    html:not(.wyldcards-page-view-mode) .wyldcards-script .block-content.block-type-character textarea,
    html:not(.wyldcards-page-view-mode) .wyldcards-script .block-content.block-type-dual_dialogue .script-block-text,
    html:not(.wyldcards-page-view-mode) .wyldcards-script .block-content.block-type-dual_dialogue .reader-visible-text,
    html:not(.wyldcards-page-view-mode) .wyldcards-script .block-content.block-type-dual_dialogue .block-input-textarea,
    html:not(.wyldcards-page-view-mode) .wyldcards-script .block-content.block-type-dual_dialogue textarea {
        display: block;
        text-align: left;
        margin-left: var(--screenplay-character-indent, 36.667%);
        margin-right: 0;
        width: auto;
        max-width: none;
    }

    html:not(.wyldcards-page-view-mode) .wyldcards-script .block-content.block-type-dialogue {
        padding-left: 0;
        padding-right: 0;
    }

    html:not(.wyldcards-page-view-mode) .wyldcards-script .block-content.block-type-dialogue .script-block-text,
    html:not(.wyldcards-page-view-mode) .wyldcards-script .block-content.block-type-dialogue .reader-visible-text,
    html:not(.wyldcards-page-view-mode) .wyldcards-script .block-content.block-type-dialogue .block-input-textarea,
    html:not(.wyldcards-page-view-mode) .wyldcards-script .block-content.block-type-dialogue textarea,
    html:not(.wyldcards-page-view-mode) .wyldcards-script .script-block--dialogue .script-block-text,
    html:not(.wyldcards-page-view-mode) .wyldcards-script .script-block--dialogue .reader-visible-text,
    html:not(.wyldcards-page-view-mode) .wyldcards-script .script-block--dialogue .block-input-textarea,
    html:not(.wyldcards-page-view-mode) .wyldcards-script .block-row:has(.script-character-name) .script-block-text,
    html:not(.wyldcards-page-view-mode) .wyldcards-script .block-row:has(.script-character-name) .reader-visible-text,
    html:not(.wyldcards-page-view-mode) .wyldcards-script .block-content:has(.script-character-name) .block-input-textarea {
        display: block;
        width: var(--screenplay-dialogue-width, 3.5in);
        max-width: var(--screenplay-dialogue-width, 3.5in);
        margin-left: var(--screenplay-dialogue-indent, 16.667%);
        margin-right: 0;
        text-align: left;
    }

    html:not(.wyldcards-page-view-mode) .wyldcards-script .block-content.block-type-parenthetical {
        padding-left: 0;
        padding-right: 0;
    }

    html:not(.wyldcards-page-view-mode) .wyldcards-script .block-content.block-type-parenthetical .script-block-text,
    html:not(.wyldcards-page-view-mode) .wyldcards-script .block-content.block-type-parenthetical .reader-visible-text,
    html:not(.wyldcards-page-view-mode) .wyldcards-script .block-content.block-type-parenthetical .block-input-textarea,
    html:not(.wyldcards-page-view-mode) .wyldcards-script .block-content.block-type-parenthetical textarea {
        display: block;
        margin-left: var(--screenplay-parenthetical-indent, 25%);
        margin-right: 0;
        max-width: 33.333%;
        width: auto;
        text-align: left;
    }
}

.text-size-control a.nav-dropdown-toggle {
    text-decoration: none;
    color: var(--fg);
}

#table-blocks tr[data-block-id] > td,
.table-blocks-all .block-row {
    vertical-align: top;
}

#table-blocks td.block-actions-cell,
.wyldcards-script aside.block-actions {
    vertical-align: top;
}

/* Vertical rhythm between screenplay elements (continuous edit/read mode).
   One blank line before action, character cues, sections, transitions, and
   speeches that carry their own character name; ~1.5 blank lines before a new
   scene. A character cue -> parenthetical -> (unnamed) dialogue belong to one
   speech and stay tight, so only speech-starting rows get a gap.

   The margin lives on the stable .block-row wrapper, keyed off the
   data-block-type attribute — that attribute does not change when a block is
   clicked into for editing (only the inner content swaps), so the layout never
   jumps between display and edit states. The adjacent-sibling combinator means
   the first row of a scene never gets a leading gap. Gaps scale with the
   reader's text-size control, and page-view/print keep their own page-accurate
   spacing. */
html:not(.wyldcards-page-view-mode) .wyldcards-script {
    --screenplay-element-gap: calc(18pt * var(--wyldcards-text-scale, 1));
    --screenplay-scene-gap: calc(27pt * var(--wyldcards-text-scale, 1));
}
html:not(.wyldcards-page-view-mode) .wyldcards-script .script-scene + .script-scene {
    margin-top: var(--screenplay-scene-gap);
}


.wyldcards-script aside.block-left-controls,
.wyldcards-script aside.block-actions {
    align-self: start;
}

.wyldcards-script aside.block-left-controls {
    grid-column: 1;
    grid-row: 1;
    justify-self: end;
    min-width: calc(var(--block-select-col-checkbox) + var(--block-select-col-plus) + var(--block-select-col-drag) + 2 * var(--block-select-col-gap));
}

.wyldcards-script .block-content {
    grid-column: 2;
    grid-row: 1;
    cursor: pointer;
    min-width: 0;
}

.wyldcards-script aside.block-actions {
    grid-column: 3;
    grid-row: 1;
    justify-self: start;
    min-width: calc(4 * 1.15rem + 3 * 0.1rem);
}

.wyldcards-script aside.block-left-controls,
.wyldcards-script aside.block-actions {
    font-size: inherit;
    line-height: inherit;
    border: none;
    padding: 0;
    margin: 0;
    background: transparent;
    overflow: visible;
    white-space: nowrap;
}

/* Breathing room between the drag handle and the text caret */
.wyldcards-script aside.block-left-controls {
    padding-right: 0.5rem;
}

.wyldcards-script aside.block-left-controls .block-left-controls-inner {
    display: inline-grid !important;
    grid-template-columns: var(--block-select-col-checkbox) var(--block-select-col-plus) var(--block-select-col-drag);
    align-items: center;
    gap: var(--block-select-col-gap);
    min-height: var(--block-text-line-box);
}

.wyldcards-script .block-left-controls-inner > .block-select-checkbox,
.wyldcards-script .block-left-controls-inner > .block-select-all-label {
    grid-column: 1;
    grid-row: 1;
    position: relative;
    z-index: 2;
}

.wyldcards-script .block-left-controls-inner > .block-select-menu-dropdown,
.wyldcards-script .block-left-controls-inner > a.create-below,
.wyldcards-script .block-left-controls-inner > .create-below-menu-dropdown,
.wyldcards-script .block-left-controls-inner > button.create-below.create-below-menu-toggle {
    grid-column: 2;
    grid-row: 1;
    position: relative;
    z-index: 1;
    justify-self: center;
}

.wyldcards-script .block-left-controls-inner > .drag-handle,
.wyldcards-script .block-left-controls-inner > .block-drag-menu-dropdown,
.wyldcards-script .block-left-controls-inner > .block-select-all-slot {
    grid-column: 3;
    grid-row: 1;
    position: relative;
    z-index: 1;
    justify-self: center;
}

.wyldcards-script-select-row {
    margin-block: 0;
}

.wyldcards-script-select-row .block-left-controls-inner {
    grid-template-columns: var(--block-select-col-checkbox) var(--block-select-col-plus) var(--block-select-col-drag);
}

.wyldcards-script-select-row .wyldcards-script-select-spacer {
    grid-column: 2;
    grid-row: 1;
    min-height: var(--block-text-line-box);
    pointer-events: none;
}

.wyldcards-script .block-row:hover a[role="button"]:not(.create-below),
.wyldcards-script .block-row a[role="button"]:focus:not(.create-below) {
    opacity: 1;
}

html.wyldcards-hide-block-select:not(.wyldcards-block-edit-locked) .wyldcards-script .block-content,
html.wyldcards-hide-block-select:not(.wyldcards-block-edit-locked) #table-blocks .block-content,
html.wyldcards-hide-block-select:not(.wyldcards-block-edit-locked) .table-blocks-all .block-content {
    cursor: text;
}

.wyldcards-script .block-content.script-block {
    min-height: 1.5em;
    margin-top: 0;
}

.wyldcards-script .block-row:not([data-block-id]):not(.wyldcards-script-select-row) .block-content form,
.wyldcards-script .block-row:not([data-block-id]):not(.wyldcards-script-select-row) .block-content textarea[name="content"] {
    min-height: 1.5em;
}

.wyldcards-script .block-row.dragging {
    opacity: 0.4;
}

.wyldcards-script .drag-handle,
#table-blocks .drag-handle,
.table-blocks-all .drag-handle {
    cursor: grab;
    padding: 0.1em 0.25em;
    border-radius: 4px;
    color: var(--muted, #94a3b8);
    line-height: 1;
    user-select: none;
    touch-action: none;
    min-width: 1.15rem;
    min-height: 1.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.wyldcards-script .block-row:hover .drag-handle,
#table-blocks tr:hover .drag-handle,
.table-blocks-all tr:hover .drag-handle {
    color: var(--accent, #475569);
    background-color: var(--accent-bg, rgba(0, 0, 0, 0.05));
}

.wyldcards-script .drag-handle:active,
#table-blocks .drag-handle:active,
.table-blocks-all .drag-handle:active {
    cursor: grabbing;
}

.wyldcards-toolbar-main .element-type-actions {
    margin-top: 0;
}

.element-type-menu.element-type-actions {
    display: none;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 0.15rem;
    align-items: stretch;
    margin-top: 0;
    min-width: 11rem;
}

.wyldcards-tools-group .element-type-dropdown.open .element-type-menu.element-type-actions {
    display: flex;
}

.wyldcards-toolbar-row.wyldcards-bulk-row:not(:has(.tags-bulk-action:not([hidden]))) {
    display: none;
}

/* Fountain element type formatting */
.block-content.block-type-scene .script-block-text {
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.block-content.block-type-character .script-block-text,
.block-content.block-type-dual_dialogue .script-block-text {
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
}

.block-content.block-type-character .reader-visible-text,
.block-content.block-type-character .block-input-textarea,
.block-content.block-type-character textarea,
.block-content.block-type-dual_dialogue .reader-visible-text,
.block-content.block-type-dual_dialogue .block-input-textarea,
.block-content.block-type-dual_dialogue textarea {
    text-align: center;
}

.block-content.block-type-dual_dialogue .script-block-text:not(textarea)::after,
.block-content.block-type-dual_dialogue .reader-visible-text::after {
    content: " ^";
    opacity: 0.55;
    font-weight: 400;
    letter-spacing: 0;
}

.block-content.block-type-dialogue {
    padding-left: 15%;
    padding-right: 15%;
}

.block-content.block-type-parenthetical {
    padding-left: 22%;
    padding-right: 22%;
    font-style: italic;
}

/* Parentheticals are stored bare and get their "(" / ")" here. Blocks whose
   content already carries literal parens are tagged data-has-parens="true" by
   parenthetical-parens.js and skipped, so the screen matches what the PDF and
   other exports emit instead of doubling up. */
.block-content.block-type-parenthetical:not([data-has-parens="true"]) .script-block-text:not(textarea)::before,
.block-content.block-type-parenthetical:not([data-has-parens="true"]) .reader-visible-text::before {
    content: "(";
}

.block-content.block-type-parenthetical:not([data-has-parens="true"]) .script-block-text:not(textarea)::after,
.block-content.block-type-parenthetical:not([data-has-parens="true"]) .reader-visible-text::after {
    content: ")";
}

.block-content.block-type-transition {
    text-align: right;
    text-transform: uppercase;
}

.block-content.block-type-shot .script-block-text {
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.block-content.block-type-lyrics {
    font-style: italic;
}

.block-content.block-type-centered {
    text-align: center;
}

.block-content.block-type-section {
    font-weight: bold;
    font-size: 1.1em;
    color: var(--accent, #475569);
}

.block-content.block-type-section .script-block-text:not(textarea)::before,
.block-content.block-type-section .reader-visible-text::before {
    content: "# ";
}

.block-content.block-type-synopsis {
    font-style: italic;
    color: var(--muted-fg, #64748b);
}

.block-content.block-type-synopsis .script-block-text:not(textarea)::before,
.block-content.block-type-synopsis .reader-visible-text::before {
    content: "= ";
}

.block-content.block-type-note {
    background: color-mix(in srgb, #eab308 16%, transparent);
    border-radius: 3px;
    padding-inline: 0.2em;
    font-style: italic;
}

:root.-dark-theme .block-content.block-type-note {
    background: color-mix(in srgb, #eab308 22%, transparent);
}

@media (prefers-color-scheme: dark) {
    :root:not(.-no-dark-theme) .block-content.block-type-note {
        background: color-mix(in srgb, #eab308 22%, transparent);
    }
}

.block-content.block-type-note .script-block-text:not(textarea)::before,
.block-content.block-type-note .reader-visible-text::before {
    content: "[[ ";
    opacity: 0.5;
}

.block-content.block-type-note .script-block-text:not(textarea)::after,
.block-content.block-type-note .reader-visible-text::after {
    content: " ]]";
    opacity: 0.5;
}

.block-content.block-type-page_break {
    text-align: center;
    color: var(--muted-fg, #64748b);
    text-transform: uppercase;
    letter-spacing: 0.25em;
    font-size: 0.8em;
    border-top: 2px dashed color-mix(in srgb, var(--muted-fg, #64748b) 55%, transparent);
}

.block-content.block-type-centered .reader-visible-text,
.block-content.block-type-centered .block-input-textarea,
.block-content.block-type-centered textarea,
.block-content.block-type-page_break .reader-visible-text,
.block-content.block-type-page_break .block-input-textarea,
.block-content.block-type-page_break textarea {
    text-align: center;
}

.block-content.block-type-transition .reader-visible-text,
.block-content.block-type-transition .block-input-textarea,
.block-content.block-type-transition textarea {
    text-align: right;
}

.block-content.block-type-dialogue .reader-visible-text,
.block-content.block-type-dialogue .block-input-textarea,
.block-content.block-type-dialogue textarea {
    max-width: min(var(--screenplay-dialogue-width, 3.5in), 100%);
    margin-left: auto;
    margin-right: auto;
    display: block;
}

.block-content.block-text-align-left .script-block-text,
.block-content.block-text-align-left .reader-visible-text,
.block-content.block-text-align-left .block-input-textarea,
.block-content.block-text-align-left textarea {
    text-align: left !important;
}

.block-content.block-text-align-center .script-block-text,
.block-content.block-text-align-center .reader-visible-text,
.block-content.block-text-align-center .block-input-textarea,
.block-content.block-text-align-center textarea {
    text-align: center !important;
}

.block-content.block-text-align-right .script-block-text,
.block-content.block-text-align-right .reader-visible-text,
.block-content.block-text-align-right .block-input-textarea,
.block-content.block-text-align-right textarea {
    text-align: right !important;
}

.block-content.block-text-bold .script-block-text,
.block-content.block-text-bold .reader-visible-text,
.block-content.block-text-bold .block-input-textarea,
.block-content.block-text-bold textarea {
    font-weight: bold;
}

.block-content.block-text-italic .script-block-text,
.block-content.block-text-italic .reader-visible-text,
.block-content.block-text-italic .block-input-textarea,
.block-content.block-text-italic textarea {
    font-style: italic;
}

.block-content.block-text-underline .script-block-text,
.block-content.block-text-underline .reader-visible-text,
.block-content.block-text-underline .block-input-textarea,
.block-content.block-text-underline textarea {
    text-decoration: underline;
}

/* Notion-style block highlights: a tinted panel behind a block's text. The tint
   sits on the block/row container rather than the text, so it stays put while
   the block is being edited (the textarea is swapped in inside it).
   !important because the "no tint while editing" rules above clear
   .block-content's background on hover, :focus-within, and in page-view mode —
   a chosen highlight should outlast all three, the way align/font overrides do. */
.block-content.block-highlight-yellow,
.block-content.block-highlight-green,
.block-content.block-highlight-blue,
.block-content.block-highlight-red,
.block-content.block-highlight-gray,
.song-block-row.song-block-highlight-yellow,
.song-block-row.song-block-highlight-green,
.song-block-row.song-block-highlight-blue,
.song-block-row.song-block-highlight-red,
.song-block-row.song-block-highlight-gray {
    background-color: var(--block-highlight-tint) !important;
    border-radius: 4px !important;
    box-shadow: 0 0 0 2px var(--block-highlight-tint) !important;
}

.block-content.block-highlight-yellow,
.song-block-row.song-block-highlight-yellow {
    --block-highlight-tint: var(--block-highlight-yellow);
}

.block-content.block-highlight-green,
.song-block-row.song-block-highlight-green {
    --block-highlight-tint: var(--block-highlight-green);
}

.block-content.block-highlight-blue,
.song-block-row.song-block-highlight-blue {
    --block-highlight-tint: var(--block-highlight-blue);
}

.block-content.block-highlight-red,
.song-block-row.song-block-highlight-red {
    --block-highlight-tint: var(--block-highlight-red);
}

.block-content.block-highlight-gray,
.song-block-row.song-block-highlight-gray {
    --block-highlight-tint: var(--block-highlight-gray);
}

/* Let the tint show through the editing textarea, which is otherwise opaque. */
.block-content[class*="block-highlight-"] .block-input-textarea,
.block-content[class*="block-highlight-"] textarea,
.song-block-row[class*="song-block-highlight-"] .song-block-textarea {
    background-color: transparent;
}

/* Color chips in the Format menu / line menu. */
.block-highlight-swatch {
    display: inline-block;
    width: 0.85rem;
    height: 0.85rem;
    border-radius: 3px;
    border: 1px solid var(--border);
    background-color: var(--block-highlight-tint, transparent);
    flex: none;
}

.block-highlight-swatch.block-highlight-yellow {
    --block-highlight-tint: var(--block-highlight-yellow);
}

.block-highlight-swatch.block-highlight-green {
    --block-highlight-tint: var(--block-highlight-green);
}

.block-highlight-swatch.block-highlight-blue {
    --block-highlight-tint: var(--block-highlight-blue);
}

.block-highlight-swatch.block-highlight-red {
    --block-highlight-tint: var(--block-highlight-red);
}

.block-highlight-swatch.block-highlight-gray {
    --block-highlight-tint: var(--block-highlight-gray);
}

/* "None" reads as an empty chip with a strike through it. */
.block-highlight-swatch--none {
    background-image: linear-gradient(
        to top right,
        transparent calc(50% - 1px),
        var(--muted-fg, currentColor) calc(50% - 1px),
        var(--muted-fg, currentColor) calc(50% + 1px),
        transparent calc(50% + 1px)
    );
}

.wyldcards-offline-banner {
    --wyldcards-offline-banner-height: 2.75rem;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10000;
    box-sizing: border-box;
    min-height: var(--wyldcards-offline-banner-height);
    padding: 0.55rem 1rem;
    background: #5c3d00;
    color: #fff4d6;
    font-size: 0.875rem;
    text-align: center;
    border-bottom: 1px solid #8a5a00;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    pointer-events: none;
}

.wyldcards-offline-banner button {
    pointer-events: auto;
}

/* Keep Offline (offline-keep.js): the dialog behind a card's More menu. */
.wyldcards-keep-offline-dialog h2 {
    margin: 0 0 0.75rem;
    font-size: 1.15rem;
}
.wyldcards-keep-offline-dialog .wyldcards-dialog-message {
    font-size: 0.95rem;
    white-space: normal;
}
.wyldcards-keep-offline-progress {
    display: block;
    width: 100%;
    margin: 0 0 0.5rem;
}
.wyldcards-keep-offline-status {
    min-height: 1.4em;
    margin: 0 0 1rem;
    font-size: 0.9rem;
    color: var(--muted-fg, inherit);
}
.wyldcards-keep-offline-dialog .wyldcards-dialog-actions {
    flex-wrap: wrap;
}
#wyldcards-draft-review section a {
    margin-left: 0.75rem;
}
.nav-dropdown-item[data-keep-offline][aria-checked="true"]::after {
    content: " ✓";
}

.wyldcards-offline-banner--error {
    background: #5c1a00;
    border-bottom-color: #8a2200;
    color: #ffe8e0;
}

.wyldcards-offline-banner--syncing {
    background: #003d5c;
    border-bottom-color: #005a8a;
    color: #d6f0ff;
}

.wyldcards-offline-banner--saved {
    background: #1f4d2a;
    border-bottom-color: #2d6a3e;
    color: #d9ffe3;
}

.wyldcards-sync-status {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    min-height: 1.85rem;
    padding: 0 0.55rem;
    color: #1f6a36;
    background: color-mix(in srgb, #2d8a4a 12%, var(--bg, #fff));
    border: 1px solid color-mix(in srgb, #2d8a4a 35%, transparent);
    border-radius: 999px;
    box-shadow: none;
    font: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
}

.wyldcards-sync-status-icon {
    width: 1rem;
    height: 1rem;
    flex: 0 0 auto;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.wyldcards-sync-status-icon path:not(.wyldcards-sync-icon-save) {
    display: none;
}

.wyldcards-sync-status[data-sync-state="offline"] .wyldcards-sync-icon-save,
.wyldcards-sync-status[data-sync-state="offline"] .wyldcards-sync-icon-pending,
.wyldcards-sync-status[data-sync-state="pending"] .wyldcards-sync-icon-save,
.wyldcards-sync-status[data-sync-state="pending"] .wyldcards-sync-icon-pending,
.wyldcards-sync-status[data-sync-state="syncing"] .wyldcards-sync-icon-save,
.wyldcards-sync-status[data-sync-state="syncing"] .wyldcards-sync-icon-syncing,
.wyldcards-sync-status[data-sync-state="error"] .wyldcards-sync-icon-save,
.wyldcards-sync-status[data-sync-state="error"] .wyldcards-sync-icon-error {
    display: none;
}

.wyldcards-sync-status[data-sync-state="offline"] .wyldcards-sync-icon-pending,
.wyldcards-sync-status[data-sync-state="pending"] .wyldcards-sync-icon-pending,
.wyldcards-sync-status[data-sync-state="syncing"] .wyldcards-sync-icon-syncing,
.wyldcards-sync-status[data-sync-state="error"] .wyldcards-sync-icon-error {
    display: block;
}

.wyldcards-sync-status[data-sync-state="offline"],
.wyldcards-sync-status[data-sync-state="pending"] {
    color: #936000;
    background: color-mix(in srgb, #d69300 13%, var(--bg, #fff));
    border-color: color-mix(in srgb, #d69300 38%, transparent);
}

.wyldcards-sync-status[data-sync-state="syncing"] {
    color: #006b9b;
    background: color-mix(in srgb, #0098d4 12%, var(--bg, #fff));
    border-color: color-mix(in srgb, #0098d4 34%, transparent);
}

.wyldcards-sync-status[data-sync-state="syncing"] .wyldcards-sync-status-icon {
    animation: wyldcards-sync-spin 1.1s linear infinite;
}

.wyldcards-sync-status[data-sync-state="error"] {
    color: #a52f16;
    background: color-mix(in srgb, #d95028 11%, var(--bg, #fff));
    border-color: color-mix(in srgb, #d95028 38%, transparent);
}

.wyldcards-sync-status:hover,
.wyldcards-sync-status:focus-visible {
    filter: brightness(0.96);
    outline: 2px solid var(--accent, #2563eb);
    outline-offset: 2px;
}

@keyframes wyldcards-sync-spin {
    to { transform: rotate(360deg); }
}

@media (max-width: 640px) {
    .wyldcards-sync-status {
        position: absolute;
        width: 1.85rem;
        padding: 0;
        justify-content: center;
    }

    .wyldcards-sync-status #wyldcards-sync-status-text {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
    }
}

.wyldcards-pwa-install-banner {
    position: fixed;
    left: 50%;
    bottom: 1.25rem;
    z-index: 10002;
    transform: translateX(-50%);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 1rem;
    width: min(34rem, calc(100vw - 1.5rem));
    padding: 0.85rem 1rem;
    border-radius: 10px;
    background: #1a1f24;
    color: #f3f5f7;
    border: 1px solid #334155;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.35);
}

.wyldcards-pwa-install-banner[hidden] {
    display: none !important;
}

.wyldcards-pwa-install-banner-copy {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
    flex: 1 1 12rem;
    font-size: 0.875rem;
    line-height: 1.35;
}

.wyldcards-pwa-install-banner-copy strong {
    font-size: 0.95rem;
}

.wyldcards-pwa-install-banner-copy span {
    color: #cbd5e1;
}

.wyldcards-pwa-install-banner-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    flex: 0 0 auto;
}

.wyldcards-pwa-install-banner-install,
.wyldcards-pwa-install-guide-close {
    appearance: none;
    border: none;
    border-radius: 6px;
    padding: 0.4rem 0.8rem;
    background: #e8eef5;
    color: #111827;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

.wyldcards-pwa-install-banner-install:hover,
.wyldcards-pwa-install-guide-close:hover {
    background: #ffffff;
}

.wyldcards-pwa-install-banner-dismiss {
    appearance: none;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 0.4rem 0.65rem;
    background: transparent;
    color: #cbd5e1;
    font-size: 0.85rem;
    cursor: pointer;
}

.wyldcards-pwa-install-banner-dismiss:hover {
    color: #ffffff;
    border-color: #475569;
}

.wyldcards-pwa-install-guide {
    position: fixed;
    inset: 0;
    z-index: 10003;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(15, 23, 42, 0.55);
}

.wyldcards-pwa-install-guide[hidden] {
    display: none !important;
}

.wyldcards-pwa-install-guide-card {
    width: min(26rem, 100%);
    padding: 1.25rem 1.35rem 1.15rem;
    border-radius: 12px;
    background: var(--bg, #fff);
    color: var(--fg, #111);
    border: 1px solid var(--border, #cbd5e1);
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.28);
}

.wyldcards-pwa-install-guide-card h2 {
    margin: 0 0 0.4rem;
    font-size: 1.2rem;
}

.wyldcards-pwa-install-guide-lead {
    margin: 0 0 0.85rem;
    color: var(--muted-fg, #64748b);
    font-size: 0.95rem;
    line-height: 1.45;
}

.wyldcards-pwa-install-guide-steps {
    margin: 0 0 0.85rem;
    padding-left: 1.25rem;
    font-size: 0.95rem;
    line-height: 1.5;
}

.wyldcards-pwa-install-guide-steps li + li {
    margin-top: 0.35rem;
}

.wyldcards-pwa-install-guide-note {
    margin: 0 0 1rem;
    font-size: 0.875rem;
    line-height: 1.45;
}

.wyldcards-pwa-install-guide-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.wyldcards-pwa-install-guide-help {
    color: var(--muted-fg, #64748b);
    font-size: 0.875rem;
}

html.wyldcards-pwa-standalone [data-wyldcards-install-app] {
    display: none !important;
}

.wyldcards-offline-sync-retry {
    background: rgba(255, 255, 255, 0.14);
    color: inherit;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 4px;
    padding: 0.2rem 0.65rem;
    font-size: 0.8rem;
    cursor: pointer;
}

.wyldcards-offline-sync-retry:hover {
    background: rgba(255, 255, 255, 0.24);
}

.block-row[data-offline-pending="create"] .block-content::after {
    background: #4da3ff;
    box-shadow: 0 0 0 2px rgba(77, 163, 255, 0.25);
}

/* Keep chrome/buttons clear of the fixed offline notice */
body:has(.wyldcards-offline-banner:not([hidden])) {
    --wyldcards-offline-banner-offset: 2.75rem;
    padding-top: calc(var(--wyldcards-offline-banner-offset) + 0.4rem);
}

body.has-toolbar-brand:has(.wyldcards-offline-banner:not([hidden])) {
    padding-top: calc(var(--wyldcards-offline-banner-offset) + var(--toolbar-brand-top-space, 0.65rem));
}

/* Absolute header-actions sit at top:0 on wyldcards pages; shift them below the banner */
body.has-toolbar-brand:has(.wyldcards-offline-banner:not([hidden])) .header-actions {
    top: calc(var(--wyldcards-offline-banner-offset) + var(--toolbar-brand-top-space, 0.5rem));
}

@media (max-width: 768px) {
    body.has-toolbar-brand:has(.wyldcards-offline-banner:not([hidden])) .header-actions {
        top: calc(var(--wyldcards-offline-banner-offset) + var(--toolbar-brand-top-space, 0.5rem)) !important;
    }
}

.wyldcards-offline [hx-post],
.wyldcards-offline [hx-put],
.wyldcards-offline [hx-delete],
.wyldcards-offline [hx-patch],
.wyldcards-offline .block-drag-handle,
.wyldcards-offline .wyldcards-toolbar-bulk-actions,
.wyldcards-offline .hide-in-reader-view.sidebar.menu [hx-get] {
    pointer-events: none;
    opacity: 0.55;
}

.wyldcards-offline .wyldcards-script .block-content[hx-get] {
    pointer-events: auto;
    cursor: text;
}

.wyldcards-offline .wyldcards-script .block-content:not(.block-content-readonly) {
    cursor: text;
}

.wyldcards-offline .wyldcards-script .block-content:not(.block-content-readonly) .block-input-textarea {
    pointer-events: auto;
}

/* Custom spellcheck overlay + suggestion popup */
.block-content form .wyldcards-spell-overlay {
    grid-area: 1 / 1;
    width: 100%;
    margin: 0;
    padding: 0;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    pointer-events: none;
    visibility: hidden;
    z-index: 0;
    color: inherit;
    font: inherit;
    line-height: inherit;
    letter-spacing: inherit;
    box-sizing: border-box;
}

.block-content form.wyldcards-spell-active .wyldcards-spell-overlay {
    visibility: hidden;
}

/* While editing: keep real ink + native caret. Overlay marks show on blur via the mirror. */
.block-content form.wyldcards-spell-active:focus-within .wyldcards-spell-overlay {
    visibility: hidden;
}

.block-content form.wyldcards-spell-active:focus-within .block-input-textarea.script-block-text {
    position: relative;
    z-index: 1;
    color: inherit;
    caret-color: auto;
    -webkit-text-fill-color: unset;
}

.wyldcards-spell-error {
    /* Underline without border-bottom so line boxes (and block height) stay stable */
    text-decoration-line: underline;
    text-decoration-style: wavy;
    text-decoration-thickness: 1.5px;
    text-decoration-color: color-mix(in srgb, var(--bad-fg-color, #e11d48) 85%, transparent);
    text-underline-offset: 2px;
    background: color-mix(in srgb, var(--bad-fg-color, #e11d48) 8%, transparent);
}

.wyldcards-spell-suggestions {
    position: absolute;
    z-index: 1300;
    margin: 0;
    padding: 0.3rem;
    list-style: none;
    min-width: 11rem;
    background: var(--box-bg, var(--bg, #fff));
    color: var(--fg, #111);
    border: 1px solid color-mix(in srgb, var(--fg, #111) 12%, transparent);
    border-radius: calc(var(--border-radius, 0.2rem) + 0.35rem);
    box-shadow: 0 14px 32px -16px rgba(12, 18, 34, 0.55),
                0 2px 6px -3px rgba(12, 18, 34, 0.3);
    max-width: min(20rem, calc(100vw - 1rem));
    max-height: 16rem;
    overflow-x: hidden;
    overflow-y: auto;
    font-size: 0.85rem;
    line-height: 1.35;
    letter-spacing: normal;
    text-transform: none;
    -webkit-overflow-scrolling: touch;
    animation: wyldcards-spell-pop 120ms ease-out;
}

@keyframes wyldcards-spell-pop {
    from { opacity: 0; transform: translateY(-4px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
    .wyldcards-spell-suggestions { animation: none; }
}

.wyldcards-spell-suggestions li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.55rem;
    border-radius: var(--border-radius, 0.2rem);
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
}

/* Long words / labels ellipsize rather than force a horizontal scrollbar */
.wyldcards-spell-suggestions .wyldcards-spell-word,
.wyldcards-spell-suggestions .wyldcards-spell-action-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Header — the flagged word, echoing the wavy error mark */
.wyldcards-spell-suggestions li.wyldcards-spell-header {
    padding: 0.15rem 0.55rem 0.4rem;
    margin-bottom: 0.25rem;
    border-bottom: 1px solid color-mix(in srgb, var(--fg, #111) 8%, transparent);
    border-radius: 0;
    cursor: default;
}

.wyldcards-spell-suggestions .wyldcards-spell-header-word {
    font-weight: 600;
    max-width: 16rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-decoration: underline wavy
        color-mix(in srgb, var(--bad-fg-color, #e11d48) 80%, transparent);
    text-decoration-thickness: 1.5px;
    text-underline-offset: 3px;
}

.wyldcards-spell-suggestions li.wyldcards-spell-suggestion .wyldcards-spell-word {
    font-weight: 500;
}

.wyldcards-spell-suggestions li.is-active,
.wyldcards-spell-suggestions li[data-suggestion]:hover,
.wyldcards-spell-suggestions li[data-action]:hover {
    background: color-mix(in srgb, var(--accent, #145591) 15%, transparent);
    color: var(--accent, #145591);
}

.wyldcards-spell-suggestions li.wyldcards-spell-empty {
    color: var(--muted-fg, #64748b);
    font-style: italic;
    cursor: default;
    padding-top: 0.15rem;
    padding-bottom: 0.35rem;
}

/* Divider between suggestions and the action rows */
.wyldcards-spell-suggestions li.wyldcards-spell-sep {
    height: 1px;
    min-height: 1px;
    padding: 0;
    margin: 0.3rem 0.25rem;
    background: color-mix(in srgb, var(--fg, #111) 10%, transparent);
    border-radius: 0;
    cursor: default;
    pointer-events: none;
}

.wyldcards-spell-suggestions li.wyldcards-spell-action {
    font-size: 0.82rem;
    color: color-mix(in srgb, var(--fg, #111) 78%, transparent);
}

.wyldcards-spell-suggestions li.wyldcards-spell-action .wyldcards-spell-ico {
    flex: 0 0 auto;
    opacity: 0.7;
}

.wyldcards-spell-suggestions li.wyldcards-spell-action:hover .wyldcards-spell-ico,
.wyldcards-spell-suggestions li.wyldcards-spell-action.is-active .wyldcards-spell-ico {
    opacity: 1;
}

/* Cut/Copy/Paste menu on right-click over highlighted text. Shares the
   spellcheck popup chrome; only the disabled state is specific to it. */
.wyldcards-selection-menu {
    min-width: 9rem;
}

.wyldcards-selection-menu li.is-disabled {
    opacity: 0.45;
    cursor: default;
}

.wyldcards-selection-menu li.is-disabled:hover {
    background: none;
    color: inherit;
}

/* Text Case: a caption naming the group, then the four transforms under it.
   The rows carry no icon of their own — each label is written in the case it
   produces, which says more than a glyph would — so they are indented by hand
   to the column the labelled rows above them use: the list's own left padding,
   plus the 14px icon, plus the flex gap between icon and label. */
.wyldcards-selection-menu li.wyldcards-selection-group {
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted-fg, #64748b);
    padding-top: 0.15rem;
    padding-bottom: 0.15rem;
    cursor: default;
    pointer-events: none;
}

.wyldcards-selection-menu li.wyldcards-selection-case {
    padding-left: calc(0.55rem + 14px + 0.5rem);
}

/* Delete is destructive — tint its hover/active red */
.wyldcards-spell-suggestions li.wyldcards-spell-delete:hover,
.wyldcards-spell-suggestions li.wyldcards-spell-delete.is-active {
    background: color-mix(in srgb, var(--bad-fg-color, #e11d48) 14%, transparent);
    color: var(--bad-fg-color, #e11d48);
}

@media (prefers-color-scheme: dark) {
    :root:not(.-no-dark-theme):not([data-theme-setting="light"]) .wyldcards-spell-suggestions {
        box-shadow: 0 16px 38px -18px rgba(0, 0, 0, 0.8),
                    0 0 0 1px color-mix(in srgb, var(--fg, #e5e7eb) 8%, transparent);
    }
}

/* Fountain power-user: character autocomplete */
.fountain-char-autocomplete {
    position: absolute;
    z-index: 1200;
    margin: 0;
    padding: 0.25rem 0;
    list-style: none;
    background: var(--bg, #fff);
    color: var(--fg, #111);
    border: 1px solid color-mix(in srgb, var(--fg, #111) 18%, transparent);
    box-shadow: none;
    max-height: 12rem;
    overflow-y: auto;
    font-size: 0.85rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.fountain-char-autocomplete li {
    padding: 0.35rem 0.75rem;
    cursor: pointer;
}

.fountain-char-autocomplete li.is-active,
.fountain-char-autocomplete li:hover {
    background: color-mix(in srgb, var(--accent, #145591) 16%, transparent);
    color: var(--accent, #145591);
}

@keyframes fountain-outline-flash {
    0%, 100% { background-color: transparent; }
    25%, 60% { background-color: color-mix(in srgb, var(--accent, #145591) 14%, transparent); }
}

/* Screenplay print: US Letter, Courier, industry-style element layout */
@page {
    size: letter;
    margin: 1in 1in 1in 1.5in;
}

@media print {
    html,
    body {
        background: #fff !important;
        color: #000 !important;
        font-size: 12pt !important;
        line-height: 1 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    body > header,
    .wyldcards-script-toolbar,
    .text-size-control,
    .fountain-char-autocomplete,
    .hide-in-reader-view,
    .wyldcards-script-header,
    .wyldcards-script-select-row,
    .block-row:not([data-block-id]),
    .block-row[data-block-type="SECTION"],
    .block-row[data-block-type="SYNOPSIS"],
    .block-row[data-block-type="NOTE"],
    .block-element-label,
    .block-left-controls,
    .block-actions {
        display: none !important;
    }

    main,
    .has-toolbar-brand main {
        display: block !important;
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .wyldcards-script{
        --screenplay-action-width: 6in;
        --screenplay-dialogue-width: 3.5in;
        --screenplay-character-indent: 2.2in;
        --screenplay-dialogue-indent: 1in;
        --screenplay-parenthetical-indent: 1.5in;
        display: block !important;
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
        padding: 0 !important;
        color: #000 !important;
        background: transparent !important;
    }

    #wyldcards-script-body,
    .wyldcards-script .script-scene{
        display: block !important;
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
        padding: 0 !important;
        grid-template-columns: none !important;
        column-gap: 0 !important;
        gap: 0 !important;
    }
    .wyldcards-script .block-content,
    #table-blocks .block-content,
    .table-blocks-all .block-content{
        display: block !important;
        width: var(--screenplay-action-width) !important;
        max-width: var(--screenplay-action-width) !important;
        /* Rhythm is carried by margin-top below, matching page view and the
           PDF export: one blank line between elements. */
        margin: 1em 0 0 !important;
        padding: 0 !important;
        font-family: "Courier New", Courier, monospace !important;
        font-size: 12pt !important;
        line-height: 1 !important;
        color: #000 !important;
        background: transparent !important;
        border: 0 !important;
        box-shadow: none !important;
        cursor: default !important;
        min-height: 0 !important;
        overflow: visible !important;
        page-break-inside: avoid;
        break-inside: avoid;
    }

    .block-content .script-block-text:not(textarea) {
        display: block !important;
    }

    .block-content .reader-visible-text {
        display: block !important;
        position: static !important;
        width: auto !important;
        height: auto !important;
        margin: 0 !important;
        overflow: visible !important;
        clip: auto !important;
        white-space: pre-wrap !important;
        border: 0 !important;
        opacity: 1 !important;
        pointer-events: auto !important;
    }
    .block-content form[hx-post*="/block/editInline"],
    .block-content textarea {
        display: none !important;
    }

    .wyldcards-script .block-content .script-block-text,
    .wyldcards-script .block-content .reader-visible-text,
    .table-blocks-all .block-content .script-block-text,
    .table-blocks-all .block-content .reader-visible-text,
    #table-blocks .block-content .script-block-text,
    #table-blocks .block-content .reader-visible-text {
        margin: 0 !important;
        padding: 0 !important;
        white-space: pre-wrap !important;
        font: inherit !important;
        color: inherit !important;
        background: transparent !important;
        border: 0 !important;
        min-height: 0 !important;
    }

    .block-content.block-type-scene .script-block-text,
    .block-content.block-type-scene .reader-visible-text,
    .block-content.block-type-shot .script-block-text,
    .block-content.block-type-shot .reader-visible-text {
        text-transform: uppercase !important;
        letter-spacing: 0.03em !important;
        font-weight: 700 !important;
    }

    .block-content.block-type-character,
    .block-content.block-type-dual_dialogue {
        text-align: left !important;
    }

    .block-content .script-character-name,
    .block-content .reader-visible-character-name {
        display: block !important;
        position: static !important;
        width: auto !important;
        height: auto !important;
        margin: 0 0 0 0 !important;
        overflow: visible !important;
        clip: auto !important;
        white-space: normal !important;
        border: 0 !important;
        opacity: 1 !important;
        pointer-events: none !important;
        text-align: left !important;
        text-transform: uppercase !important;
        letter-spacing: 0.06em !important;
        font-weight: 700 !important;
        margin-left: var(--screenplay-character-indent) !important;
    }

    .block-content.block-type-character .script-block-text,
    .block-content.block-type-character .reader-visible-text,
    .block-content.block-type-dual_dialogue .script-block-text,
    .block-content.block-type-dual_dialogue .reader-visible-text {
        text-align: left !important;
        text-transform: uppercase !important;
        letter-spacing: 0.06em !important;
        font-weight: 700 !important;
        margin-left: var(--screenplay-character-indent) !important;
        margin-right: 0 !important;
        max-width: none !important;
        width: auto !important;
    }

    .block-content.block-type-dual_dialogue .script-block-text:not(textarea)::after,
    .block-content.block-type-dual_dialogue .reader-visible-text::after {
        content: none !important;
    }

    /* Vertical rhythm, mirroring page view: dialogue and parentheticals hug the
       character cue above them, and scene headings get a fuller break. */
    .block-content.block-type-dialogue,
    .block-content.block-type-parenthetical {
        margin-top: 0 !important;
    }

    .block-content.block-type-scene {
        margin-top: 2em !important;
    }

    .block-content.block-type-dialogue {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    .block-content.block-type-dialogue .script-block-text,
    .block-content.block-type-dialogue .reader-visible-text,
    .script-block--dialogue .script-block-text,
    .script-block--dialogue .reader-visible-text {
        display: block !important;
        width: var(--screenplay-dialogue-width) !important;
        max-width: var(--screenplay-dialogue-width) !important;
        margin-left: var(--screenplay-dialogue-indent) !important;
        margin-right: 0 !important;
        text-align: left !important;
    }

    .block-content.block-type-parenthetical {
        padding-left: 0 !important;
        padding-right: 0 !important;
        font-style: italic !important;
    }

    .block-content.block-type-parenthetical .script-block-text,
    .block-content.block-type-parenthetical .reader-visible-text {
        display: block !important;
        margin-left: var(--screenplay-parenthetical-indent) !important;
        margin-right: 0 !important;
        max-width: 2in !important;
        width: auto !important;
        text-align: left !important;
    }

    .block-content.block-type-transition {
        text-align: right !important;
        text-transform: uppercase !important;
    }

    .block-content.block-type-transition .script-block-text,
    .block-content.block-type-transition .reader-visible-text {
        text-align: right !important;
    }

    .block-content.block-type-centered,
    .block-content.block-type-centered .script-block-text,
    .block-content.block-type-centered .reader-visible-text {
        text-align: center !important;
    }

    .block-content.block-type-lyrics {
        font-style: italic !important;
    }

    .block-content.block-type-page_break {
        display: block !important;
        height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        border: 0 !important;
        color: transparent !important;
        font-size: 0 !important;
        line-height: 0 !important;
        page-break-after: always;
        break-after: page;
    }

    .block-content.block-type-page_break .script-block-text,
    .block-content.block-type-page_break .reader-visible-text {
        display: none !important;
    }

    a {
        color: inherit !important;
        text-decoration: none !important;
    }
}
/* --- Passkeys: login button + management page (styles live here, not in the
   page <head>, because HTMX-boosted swaps replace only <body>) --- */
.login-passkey { margin-top: 1rem; }
.login-passkey-divider {
    display: flex; align-items: center; gap: 0.75rem;
    margin-bottom: 1rem; color: var(--muted-fg, #888); font-size: 0.85rem;
}
.login-passkey-divider::before, .login-passkey-divider::after {
    content: ""; flex: 1; border-top: 1px solid currentColor; opacity: 0.35;
}
.login-passkey-button { width: 100%; }

/* The passkey button borrows .login-submit for its shape but not its weight:
   two identically solid buttons stacked read as two primary actions, and only
   one of them is. Specificity here matches the dark-theme .login-submit rules
   further up, which is what these have to out-rank rather than merely follow. */
.login-passkey .login-passkey-button,
:root.-dark-theme .login-passkey .login-passkey-button {
    background: transparent;
    border-color: var(--border, #cbd5e1);
    /* !important because .login-submit's white (dark theme: page-ground) ink is,
       and without it this label was drawn in the button's own transparent
       ground — invisible in both themes. */
    color: var(--fg, #0f172a) !important;
    box-shadow: none;
}

.login-passkey .login-passkey-button:hover,
:root.-dark-theme .login-passkey .login-passkey-button:hover {
    background: var(--accent-bg, rgba(15, 23, 42, 0.05));
    border-color: var(--login-focus, var(--login-ink, #0c1222));
    color: var(--login-focus, var(--login-ink, #0c1222)) !important;
    box-shadow: none;
}

:root.-dark-theme .login-passkey .login-passkey-button {
    border-color: rgba(255, 255, 255, 0.22);
    color: var(--login-ink, #e8eef8) !important;
}

:root.-dark-theme .login-passkey .login-passkey-button:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.45);
    color: #fff !important;
}

@media (prefers-color-scheme: dark) {
    :root:not(.-no-dark-theme) .login-passkey .login-passkey-button {
        background: transparent;
        border-color: rgba(255, 255, 255, 0.22);
        color: var(--login-ink, #e8eef8) !important;
        box-shadow: none;
    }

    :root:not(.-no-dark-theme) .login-passkey .login-passkey-button:hover {
        background: rgba(255, 255, 255, 0.08);
        border-color: rgba(255, 255, 255, 0.45);
        color: #fff !important;
        box-shadow: none;
    }
}
.passkey-table { width: 100%; border-collapse: collapse; margin-bottom: 1rem; }
.passkey-table th, .passkey-table td { text-align: left; padding: 0.4rem 0.6rem; }
.passkey-row-controls { display: inline-flex; align-items: center; gap: 8px; vertical-align: middle; }
.passkey-hidden { display: none; }

/* ---- Mobile overrides: keep these last so they win the cascade ---- */

@media (max-width: 640px) {
    /* Keep dialogue as a narrow column — industry shape, not full-bleed prose */
    .script-block--dialogue .script-block-text,
    .wyldcards-script .block-row:has(.script-character-name) .script-block-text,
    .wyldcards-script .block-content:has(.script-character-name) .block-input-textarea,
    #table-blocks tr[data-block-id]:has(.script-character-name) .script-block-text,
    .table-blocks-all .block-row:has(.script-character-name) .script-block-text,
    .block-content.block-type-dialogue .script-block-text,
    .block-content.block-type-dialogue .reader-visible-text,
    .block-content.block-type-dialogue .block-input-textarea {
        max-width: min(78%, 3.5in);
        margin-left: auto;
        margin-right: auto;
    }

    .block-content.block-type-dialogue {
        padding-left: 0;
        padding-right: 0;
    }

    /* Parenthetical: centered under the character cue, no fixed print indent */
    .block-content.block-type-parenthetical {
        padding-left: 0;
        padding-right: 0;
    }

    .block-content.block-type-parenthetical .script-block-text,
    .block-content.block-type-parenthetical .reader-visible-text,
    .block-content.block-type-parenthetical .block-input-textarea {
        display: block;
        max-width: min(55%, 2.5in);
        margin-left: auto;
        margin-right: auto;
    }

    html:not(.wyldcards-page-view-mode) .wyldcards-script {
        padding: 0.85rem 0.35rem 1.75rem;
    }
}

/*
 * Mobile continuous editor: the desktop layout reserves left/right gutter
 * columns for hover-revealed controls. On a phone those gutters crush the
 * text column (dialogue ended up ~55px wide), so collapse the grid to a
 * linear flow and float the controls over the row instead.
 */
@media (max-width: 640px) {
    .wyldcards-script .script-scene{
        display: block;
    }

    .wyldcards-script .block-content {
        width: 100%;
        max-width: 100%;
    }

    .wyldcards-toolbar-row {
        grid-template-columns: auto minmax(0, 1fr) auto;
        column-gap: 0.35rem;
    }

    /* Right-gutter actions (bookmark/pin/move) float over the row's top-right
       corner; they only paint when their visibility toggles reveal them. */
    .wyldcards-script aside.block-actions {
        position: absolute;
        top: 0;
        right: 0;
        transform: translateY(-100%);
        min-width: 0;
        z-index: 30;
    }

    .wyldcards-script aside.block-actions .block-actions-controls {
        display: inline-flex;
        align-items: center;
        gap: 2px;
        background: var(--box-bg, #fff);
        border: 1px solid var(--border, #cbd5e1);
        border-radius: 8px;
        padding: 0.1rem 0.3rem;
    }

    /* Hidden-controls mode (default): reveal-on-focus controls become a
       floating chip above the focused block instead of a reserved gutter. */
    html.wyldcards-hide-block-select .wyldcards-script aside.block-left-controls {
        position: absolute;
        top: -0.3rem;
        right: 0;
        transform: translateY(-100%);
        min-width: 0;
        padding: 0;
        z-index: 40;
    }

    /* Select mode: checkboxes must stay in reach on every row, so keep the
       controls in flow as a compact strip above each block. */
    html:not(.wyldcards-hide-block-select) .wyldcards-script aside.block-left-controls {
        display: block;
        min-width: 0;
        padding: 0 0 0.15rem;
        text-align: left;
        /* Chrome applies justify-self to block-level boxes; the desktop
           gutter rule sets `end`, which would right-align the strip. */
        justify-self: start;
    }

    html:not(.wyldcards-hide-block-select) .wyldcards-script aside.block-left-controls .block-left-controls-inner {
        min-height: 0;
    }

    /* Slightly larger tap targets for the toolbar menus */
    .wyldcards-tools-group .nav-dropdown-toggle,
    .wyldcards-tools-group a.nav-dropdown-toggle {
        padding: 0.35em 0.6em;
    }
}

/* --- Block selection (Notion-style) -------------------------------------
   Whole-block highlight for dragging across blocks, Cmd/Ctrl+A, and Escape.
   See block-selection.js. A block is tinted only while selected — hovering or
   typing in one leaves it untinted, so this tint always means "selected". */
.block-row.block-selected,
.song-block-row.block-selected {
    background: var(--block-selection-tint);
    border-radius: 6px;
}

/* A selected block shows the selection, not its own highlight. The highlight is
   !important (it has to outlast the "no tint while editing" rules), so without
   this it would paint over the selection on screenplay rows and, on song rows —
   where both tints land on the same element — hide it outright. */
.song-block-row.block-selected[class*="song-block-highlight-"] {
    background: var(--block-selection-tint) !important;
    box-shadow: none !important;
}

.block-row.block-selected > .block-content[class*="block-highlight-"] {
    background-color: transparent !important;
    box-shadow: none !important;
}

/* While blocks are selected the block highlight is the selection, so the
   browser's text highlight would only double up on it. */
html.wyldcards-block-selecting .block-row,
html.wyldcards-block-selecting .song-block-row {
    user-select: none;
}

html.wyldcards-block-selecting .block-row ::selection,
html.wyldcards-block-selecting .song-block-row ::selection {
    background: transparent;
}

/* ---------------------------------------------------------------------------
   Auto-capitalization opt-out (per-user, see UserPreferenceRestController).

   Uppercasing is presentational everywhere in the editor, so opting out is a
   matter of undoing text-transform rather than touching stored text. These live
   at the end of the file and use !important deliberately: they have to beat the
   print block's !important rules, the page-view-mode rules, and the inline
   style on the character-name input.
   --------------------------------------------------------------------------- */
html.wyldcards-no-caps-scene .block-content.block-type-scene,
html.wyldcards-no-caps-scene .block-content.block-type-scene .script-block-text,
html.wyldcards-no-caps-scene .block-content.block-type-scene .reader-visible-text,
html.wyldcards-no-caps-scene .block-content.block-type-scene .block-input-textarea,
html.wyldcards-no-caps-scene .block-content.block-type-scene textarea {
    text-transform: none !important;
}

html.wyldcards-no-caps-character .block-content.block-type-character,
html.wyldcards-no-caps-character .block-content.block-type-character .script-block-text,
html.wyldcards-no-caps-character .block-content.block-type-character .reader-visible-text,
html.wyldcards-no-caps-character .block-content.block-type-character .block-input-textarea,
html.wyldcards-no-caps-character .block-content.block-type-character textarea,
html.wyldcards-no-caps-character .block-content.block-type-dual_dialogue,
html.wyldcards-no-caps-character .block-content.block-type-dual_dialogue .script-block-text,
html.wyldcards-no-caps-character .block-content.block-type-dual_dialogue .reader-visible-text,
html.wyldcards-no-caps-character .block-content.block-type-dual_dialogue .block-input-textarea,
html.wyldcards-no-caps-character .block-content.block-type-dual_dialogue textarea,
html.wyldcards-no-caps-character .script-character-name,
html.wyldcards-no-caps-character .reader-visible-character-name,
html.wyldcards-no-caps-character .character-name-input {
    text-transform: none !important;
}

html.wyldcards-no-caps-transition .block-content.block-type-transition,
html.wyldcards-no-caps-transition .block-content.block-type-transition .script-block-text,
html.wyldcards-no-caps-transition .block-content.block-type-transition .reader-visible-text,
html.wyldcards-no-caps-transition .block-content.block-type-transition .block-input-textarea,
html.wyldcards-no-caps-transition .block-content.block-type-transition textarea {
    text-transform: none !important;
}

html.wyldcards-no-caps-shot .block-content.block-type-shot,
html.wyldcards-no-caps-shot .block-content.block-type-shot .script-block-text,
html.wyldcards-no-caps-shot .block-content.block-type-shot .reader-visible-text,
html.wyldcards-no-caps-shot .block-content.block-type-shot .block-input-textarea,
html.wyldcards-no-caps-shot .block-content.block-type-shot textarea {
    text-transform: none !important;
}

/* ---------------------------------------------------------------------------
   Recordings kept with a song.

   Sits under the lyric lines in the song editor, folded away until asked for:
   a writer who came to write should meet words, not a rack of players. Open, it
   is a plain list — a name, how long it plays, how big it is, and the browser's
   own audio control, which already knows how to scrub, change speed and keep
   playing while the tab is in the background.
   --------------------------------------------------------------------------- */
.song-audio {
    width: 100%;
    margin-top: 1.5rem;
    border-top: 1px solid var(--graphical-fg, #e2e8f0);
    padding-top: 0.75rem;
}

.song-audio-summary {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
    cursor: pointer;
    font-weight: 600;
    list-style: none;
    padding: 0.25rem 0;
}

/* The disclosure triangle drawn by hand, so it reads the same in both engines
   and turns with the panel. */
.song-audio-summary::-webkit-details-marker {
    display: none;
}

.song-audio-summary::before {
    content: "▸";
    display: inline-block;
    color: var(--muted-fg, #64748b);
    transition: transform 0.12s ease-in-out;
}

.song-audio-details[open] > .song-audio-summary::before {
    transform: rotate(90deg);
}

.song-audio-count {
    font-weight: 400;
    font-size: 0.9rem;
}

.song-audio-list {
    list-style: none;
    margin: 0.5rem 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.song-audio-item {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 0.6rem 0.7rem;
    border: 1px solid var(--graphical-fg, #e2e8f0);
    border-radius: 8px;
}

.song-audio-item-head {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.song-audio-title {
    font-weight: 600;
    overflow-wrap: anywhere;
}

.song-audio-meta {
    font-size: 0.85rem;
}

.song-audio-player {
    width: 100%;
    max-width: 30rem;
}

/* The controls line up in a row of their own, in an inline-flex wrapper for
   the reason every other control group here has one: missing.css does not make
   a button, a link and a label agree on a baseline by themselves. */
.song-audio-item-actions,
.song-audio-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    vertical-align: middle;
}

.song-audio-actions {
    margin-top: 0.75rem;
}

.song-audio-btn,
.song-audio-add-label {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.25rem 0.6rem;
    border: 1px solid var(--graphical-fg, #cbd5e1);
    border-radius: 6px;
    background: transparent;
    color: inherit;
    font-size: 0.85rem;
    line-height: 1.6;
    text-decoration: none;
    cursor: pointer;
}

.song-audio-btn:hover,
.song-audio-add:hover .song-audio-add-label,
.song-audio-add:focus-within .song-audio-add-label {
    background-color: color-mix(in srgb, var(--fg, #0f172a) 6%, transparent);
}

.song-audio-btn--danger {
    color: var(--danger-fg, #b91c1c);
    border-color: color-mix(in srgb, var(--danger-fg, #b91c1c) 40%, transparent);
}

.song-audio-add {
    display: inline-flex;
    cursor: pointer;
}

.song-audio-empty,
.song-audio-progress {
    font-size: 0.9rem;
    margin: 0.5rem 0 0;
}

.song-audio-error {
    margin: 0.5rem 0 0;
    color: var(--danger-fg, #b91c1c);
    font-size: 0.9rem;
}

/* ---------------------------------------------------------------------------
   Read aloud

   The transport bar read-aloud.js builds and appends to <body>, so it is
   positioned against the viewport and stays put as the script scrolls — the
   same footing as the page control bar, and the same glass surface, so the two
   read as one family. When page view has its bar out, this one sits above it
   rather than on top of it.

   The highlight is a tint on the element being read, not a border: a border
   would move the text a pixel on every line and the whole page would twitch its
   way through a scene.
   --------------------------------------------------------------------------- */
.read-aloud-bar {
    position: fixed;
    left: 50%;
    bottom: 1.25rem;
    transform: translateX(-50%);
    z-index: 41;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 0.4rem 0.6rem;
    border-radius: 1.1rem;
    border: 1px solid color-mix(in srgb, var(--muted-fg, #64748b) 45%, transparent);
    background: color-mix(in srgb, var(--bg, #fff) 88%, transparent);
    -webkit-backdrop-filter: blur(12px) saturate(1.4);
    backdrop-filter: blur(12px) saturate(1.4);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.5) inset,
        0 4px 12px rgba(0, 0, 0, 0.1),
        0 12px 32px rgba(0, 0, 0, 0.16);
    font-family: system-ui, sans-serif;
    font-size: 0.84rem;
    max-width: calc(100vw - 1.5rem);
}

.read-aloud-bar[hidden] {
    display: none;
}

body:has(.screenplay-page-bar:not([hidden])) .read-aloud-bar {
    bottom: 4.6rem;
}

.read-aloud-main {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.read-aloud-transport,
.read-aloud-settings {
    display: inline-flex;
    align-items: center;
    gap: 0.15rem;
    vertical-align: middle;
}

.read-aloud-settings {
    gap: 0.5rem;
}

.read-aloud-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.95rem;
    min-height: 1.95rem;
    padding: 0;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: var(--fg, #0f172a);
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    transition: background-color 120ms ease, color 120ms ease;
}

/* The transport is drawn in glyphs rather than icons, and at the label's size a
   stop square reads as a speck. */
.read-aloud-transport .read-aloud-btn {
    font-size: 1rem;
}

.read-aloud-btn--wide {
    min-width: 2.4rem;
    padding: 0 0.5rem;
}

.read-aloud-btn--play {
    background: color-mix(in srgb, var(--fg, #0f172a) 8%, transparent);
}

.read-aloud-btn:hover:not(:disabled) {
    background: color-mix(in srgb, var(--fg, #0f172a) 14%, transparent);
}

.read-aloud-btn:focus-visible {
    outline: 2px solid var(--accent, #475569);
    outline-offset: 1px;
}

.read-aloud-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* What is being read: the document above, the line or the speaker below. Fixed
   width so a long line does not make the bar grow and shrink under the writer's
   hand. */
.read-aloud-reading {
    display: flex;
    flex-direction: column;
    margin: 0;
    min-width: 9rem;
    max-width: 18rem;
    line-height: 1.3;
}

.read-aloud-title,
.read-aloud-now {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.read-aloud-title {
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--muted-fg, #64748b);
}

.read-aloud-title[hidden] {
    display: none;
}

.read-aloud-now {
    color: var(--muted-fg, #64748b);
}

.read-aloud-field {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    vertical-align: middle;
    color: var(--muted-fg, #64748b);
}

.read-aloud-select {
    padding: 0.1rem 0.25rem;
    border: 1px solid color-mix(in srgb, var(--muted-fg, #64748b) 45%, transparent);
    border-radius: 6px;
    background: transparent;
    color: var(--fg, #0f172a);
    font: inherit;
    max-width: 11rem;
}

.read-aloud-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.15rem 0.9rem;
    padding-top: 0.3rem;
    border-top: 1px solid color-mix(in srgb, var(--muted-fg, #64748b) 30%, transparent);
}

.read-aloud-options[hidden] {
    display: none;
}

.read-aloud-options label {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    vertical-align: middle;
    color: var(--muted-fg, #64748b);
}

/* The voice picker is the first thing to go when the window is narrow: the
   speed and the transport are what a reading is steered with. */
@media (max-width: 34rem) {
    .read-aloud-field--voice {
        display: none;
    }

    .read-aloud-reading {
        min-width: 6rem;
        max-width: 10rem;
    }
}

.block-row.is-reading-aloud .block-content,
.song-block-row.is-reading-aloud,
.script-reader-page .is-reading-aloud {
    background-color: color-mix(in srgb, var(--accent, #2563eb) 14%, transparent);
    border-radius: 4px;
}

@media (prefers-reduced-motion: no-preference) {
    .block-row.is-reading-aloud .block-content,
    .song-block-row.is-reading-aloud,
    .script-reader-page .is-reading-aloud {
        transition: background-color 150ms ease;
    }
}

/* Nothing to offer without a voice on the device. */
.wyldcards-no-read-aloud [data-read-aloud-entry] {
    display: none !important;
}

/* ---------------------------------------------------------------------------
   The song/note editing lock

   A locked document keeps its words and loses its handles: the line controls,
   the drag handle and the formatting buttons go, and the fields themselves are
   made read-only by document-lock.js (read-only rather than disabled, so a
   locked lyric can still be read out and selected).

   The strip over a locked editor is the only thing here that is not a
   subtraction — a locked lyric looks exactly like an unlocked one, so without
   it a click that does nothing has nothing to say for itself.
   --------------------------------------------------------------------------- */
.document-lock-banner {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    width: 100%;
    margin: 0 0 0.6rem;
    padding: 0.4rem 0.8rem;
    border: 1px solid color-mix(in srgb, var(--muted-fg, #64748b) 35%, transparent);
    border-radius: 8px;
    background: color-mix(in srgb, var(--muted-fg, #64748b) 12%, transparent);
    color: var(--fg, #0f172a);
    font-family: system-ui, sans-serif;
    font-size: 0.9rem;
    text-align: left;
    cursor: pointer;
}

.document-lock-banner:hover {
    background: color-mix(in srgb, var(--muted-fg, #64748b) 18%, transparent);
}

.document-lock-banner .muted {
    font-weight: 400;
}

/* Hidden rather than removed: a locked card sitting beside an unlocked one
   should not jump half an inch sideways, and the line the writer was looking at
   should stay where they left it. */
.is-edit-locked .song-block-controls,
.is-edit-locked .song-workspace-drag-handle {
    visibility: hidden;
}

/* An editor page holds one document, and its controls are spread across the
   page rather than gathered inside it, so the page carries the state — the same
   footing as the screenplay's .wyldcards-block-edit-locked. */
.wyldcards-document-edit-locked .note-format-toolbar [data-note-format],
.wyldcards-document-edit-locked .note-format-btn--icon {
    display: none;
}

/* Locked fields keep the page's colours rather than the browser's grey-out:
   this is a document being read, not a form that has gone away. */
.is-edit-locked .song-block-textarea,
.is-edit-locked .text-document-content {
    background: transparent;
    cursor: default;
}

.text-document-locked-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    vertical-align: middle;
    padding: 0.05rem 0.4rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--muted-fg, #64748b) 15%, transparent);
    color: var(--muted-fg, #64748b);
    font-size: 0.78rem;
}

.text-document-locked-badge[hidden] {
    display: none;
}

/* A pressed lock reads as on, the way the screenplay's does. */
.document-lock-toggle[aria-pressed="true"] {
    background: color-mix(in srgb, var(--accent, #2563eb) 14%, transparent);
}

.document-lock-toggle .lock-icon {
    display: none;
}

.document-lock-toggle .lock-icon--unlocked {
    display: inline-block;
}

.document-lock-toggle[aria-pressed="true"] .lock-icon--unlocked {
    display: none;
}

.document-lock-toggle[aria-pressed="true"] .lock-icon--locked {
    display: inline-block;
}

/* ---------------------------------------------------------------------------
   A song or a note, open to be read

   Same column, same serif, same measure as the screenplay's reading page — the
   three readings are one family, and a writer who learns the shape of one
   should recognise the others. What differs is only what each kind is made of.

   Scoped to .document-reader-page throughout, because the reader page's own
   rules (.script-reader-page article p, and the screenplay's shouted h2) are
   more specific than a bare class and would otherwise win. These pages also
   load this stylesheet without missing.css underneath, so every borrowed
   variable carries a fallback.
   --------------------------------------------------------------------------- */
.document-reader-header-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    vertical-align: middle;
}

.document-reader-page .document-reader-empty {
    color: #666;
    font-style: italic;
}

/* A lyric is set as it is written: one line per line, and the blank line
   between two verses left standing, because that gap is the writer's. */
.document-reader-page .document-reader-line {
    margin: 0 0 0.15rem;
    white-space: pre-wrap;
}

.document-reader-page .document-reader-line--break {
    margin-bottom: 0.9rem;
}

.document-reader-lyric .block-highlight-yellow,
.document-reader-lyric .block-highlight-green,
.document-reader-lyric .block-highlight-blue,
.document-reader-lyric .block-highlight-red,
.document-reader-lyric .block-highlight-gray {
    padding: 0 0.2rem;
    border-radius: 3px;
}

/* A note is prose with its markers set rather than shown. Paragraphs are spaced
   instead of separated by empty rows, which is what the blank lines meant, and
   the lines inside one sit together — a writer who broke a line meant to. */
.document-reader-page .document-reader-paragraph {
    margin: 0 0 1.15rem;
}

/* A note's headings are the writer's own words, not a screenplay's slug line:
   the reader page shouts an h2 in letterspaced capitals, and "# act one" is
   neither shouted nor a scene. */
.document-reader-page .document-reader-heading {
    margin: 0 0 0.4rem;
    padding-top: 0;
    border-top: none;
    line-height: 1.25;
    text-transform: none;
    letter-spacing: normal;
}

.document-reader-page h2.document-reader-heading {
    font-size: 1.35rem;
}

.document-reader-page h3.document-reader-heading {
    font-size: 1.15rem;
}

.document-reader-page h4.document-reader-heading {
    font-size: 1rem;
}

.document-reader-page .document-reader-prose,
.document-reader-page .document-reader-item {
    margin: 0 0 0.15rem;
    white-space: pre-wrap;
}

/* The marker is drawn beside the words rather than left in them. A numbered
   item shows the writer's own number — the editor maintains that numbering, and
   a reading that counted for itself would quietly disagree with the note. */
.document-reader-page .document-reader-item {
    padding-left: 1.9rem;
    text-indent: -1.9rem;
}

.document-reader-marker {
    display: inline-block;
    width: 1.9rem;
    text-indent: 0;
}

@media print {
    .document-reader-header-actions {
        display: none;
    }
}

/* Edit screenplay is greyed while the plain writing column is already up — the
   same way the history buttons say there is nothing to take back. */
.nav-dropdown-item#nav-edit-screenplay.is-unavailable {
    opacity: 0.55;
    cursor: not-allowed;
}

#todos-trash-empty-btn {
    margin-top: 0.75rem;
}

/* ------------------------------------------------------------------------
   Change history — what changed in one piece of work, and what it said before.

   One panel, opened over the screenplay, a song, a note or the to-do list, so
   the four never drift apart. Built entirely by js/change-history.js; nothing
   here is rendered by a template.

   The two sides of a change are labelled as well as tinted: colour alone is
   not a signal, and a lyric that reads the same in both columns except for one
   word has to be legible to someone who cannot see the tint at all.
   ------------------------------------------------------------------------ */

.change-history-dialog {
    width: min(46rem, 92vw);
    max-height: 82vh;
    overflow-y: auto;
    border: 1px solid var(--border, #cbd5e1);
    border-radius: var(--border-radius, 8px);
    background: var(--bg, #ffffff);
    color: var(--fg);
    padding: 1.25rem;
}

.change-history-dialog::backdrop {
    background: rgba(0, 0, 0, 0.45);
}

.change-history-dialog-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
}

.change-history-dialog-head h2 {
    margin: 0;
}

.change-history-blurb {
    margin: 0.35rem 0 0.75rem;
}

.change-history-status {
    color: #b3261e;
    margin: 0 0 0.75rem;
}

.change-history-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.change-history-entry {
    border-top: 1px solid var(--border, #e2e8f0);
    padding: 0.85rem 0;
}

.change-history-entry-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
}

.change-history-who {
    font-weight: 600;
}

.change-history-when {
    font-size: 0.85em;
}

.change-history-sides {
    display: grid;
    /* Side by side where there is room, stacked where there is not — a phone
       reading a lyric two words wide in each column helps nobody. */
    grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
    gap: 0.6rem;
    margin: 0.5rem 0;
}

.change-history-side {
    border-left: 3px solid var(--border, #cbd5e1);
    padding-left: 0.6rem;
}

.change-history-side--before {
    border-left-color: #b3261e;
}

.change-history-side--after {
    border-left-color: #1b7a3d;
}

.change-history-side-label {
    display: block;
    font-size: 0.75em;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted-fg, #64748b);
}

.change-history-text {
    margin: 0.15rem 0 0;
    /* A screenplay element and a lyric line both keep their own line breaks,
       and a long note has to wrap rather than push the dialog sideways. */
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.change-history-text--empty {
    color: var(--muted-fg, #64748b);
    font-style: italic;
}

.change-history-revert {
    margin-top: 0.25rem;
}

.change-history-empty {
    margin: 0.5rem 0 0;
}

/* Search across wyldcards (/search). The results are a list of *places*, so each
   row leads with what kind of thing it is and ends with the words in context —
   the two facts that decide whether it is worth following. */
.search-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 1rem;
}

.search-form-label {
    font-size: 0.9rem;
    opacity: 0.75;
}

/* Grows to fill the row but never below a phone's width, so the field and its
   button stay on one line on a laptop and stack on a handset. */
.search-form-input {
    flex: 1 1 16rem;
    min-width: 0;
    padding: 0.45rem 0.6rem;
    font: inherit;
}

.search-capped {
    margin: 0 0 0.75rem;
    font-size: 0.9rem;
}

.search-group {
    margin: 0 0 1.5rem;
}

.search-group-title {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.5rem;
    margin: 0 0 0.5rem;
    font-size: 1.05rem;
}

.search-group-count {
    font-size: 0.85rem;
    font-weight: normal;
}

.search-hits {
    margin: 0;
}

.search-hit-link {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
    width: 100%;
    padding: 0.4rem 0;
    color: inherit;
    text-decoration: none;
}

.search-hit-link:hover .search-hit-title,
.search-hit-link:focus-visible .search-hit-title {
    text-decoration: underline;
}

/* Fixed width so the titles line up down the column: the badge is a label for
   the row, not a word in it. */
.search-hit-kind {
    flex: 0 0 5.5rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    opacity: 0.7;
}

.search-hit-main {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.4rem;
    min-width: 0;
}

.search-hit-title {
    font-weight: 600;
}

.search-hit-field {
    font-size: 0.8rem;
}

/* The snippet takes the whole second line rather than trailing the title: a
   line of dialogue is long, and elided mid-word it says nothing. */
.search-hit-snippet {
    flex: 1 1 100%;
    font-size: 0.9rem;
    opacity: 0.85;
    overflow-wrap: anywhere;
}

/* Consent screen: the one place a writer is asked to approve an assistant. */

.consent-scopes {
    margin: 0.25rem 0 0;
    padding: 0;
    border: none;
}

.consent-scope {
    display: flex;
    gap: 0.7rem;
    align-items: flex-start;
    padding: 0.7rem 0;
    border-top: 1px solid var(--login-rule, #e2e8f0);
    cursor: pointer;
}

.consent-scope:first-of-type {
    border-top: none;
}

.consent-scope input[type="checkbox"] {
    margin-top: 0.25rem;
    flex: none;
}

.consent-scope-text {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.consent-scope-label {
    font-weight: 600;
}

.consent-scope-description {
    font-size: 0.88rem;
    color: var(--login-muted, #64748b);
}

.consent-note {
    margin: 0.9rem 0 0;
    font-size: 0.88rem;
    line-height: 1.5;
    /* Two fallbacks deep: --login-muted is declared on body.login-body, and
       page-chrome.js keeps that class on /login alone. Everywhere else this
       note is read — the consent screen, Connected assistants — the theme's own
       muted colour is the one that follows the theme. */
    color: var(--login-muted, var(--muted-fg, #64748b));
}

.consent-actions {
    margin-top: 1.1rem;
}

.consent-cancel-form {
    margin-top: 0.2rem;
}

.consent-cancel {
    width: 100%;
    padding: 0.7rem 1.15rem;
    border: 1px solid var(--login-rule, #e2e8f0);
    border-radius: var(--border-radius);
    background: transparent;
    color: var(--login-muted, #64748b);
    font: inherit;
    cursor: pointer;
}

.consent-cancel:hover {
    color: var(--login-ink, #0c1222);
}

/* Connect an assistant: the address a writer carries out of this page, and the
   four steps it is used in.

   Deliberately built on --fg/--muted-fg/--box-bg rather than the --login-*
   palette the rest of this card reaches for. Those are declared on
   body.login-body, and page-chrome.js strips that class from every page but
   /login, so on this one they resolve to their light-mode fallbacks and stay
   there whatever the theme. The variables used here are the app's own and
   follow the theme. */

.connect-assistant {
    margin-top: 1.4rem;
    padding-top: 1.1rem;
    border-top: 1px solid var(--graphical-fg, #cbd5e1);
}

.connect-heading {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--fg, #0c1222);
}

.connect-lead {
    margin: 0.4rem 0 0.75rem;
    font-size: 0.88rem;
    line-height: 1.5;
    color: var(--muted-fg, #64748b);
}

/* Its own line, always. The card is a fixed narrow column, so an address beside
   a button would be an address squeezed — and a truncated one is the single
   thing this section must never show. */
.connect-address {
    display: block;
    padding: 0.62rem 0.75rem;
    border: 1px solid var(--graphical-fg, #cbd5e1);
    border-radius: var(--border-radius);
    background: var(--box-bg, rgba(148, 163, 184, 0.12));
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.86rem;
    line-height: 1.4;
    color: var(--fg, #0c1222);
    /* Wraps rather than scrolling the card sideways. */
    overflow-wrap: anywhere;
    /* One click takes all of it, for anyone who would rather not trust the
       button. */
    user-select: all;
}

.connect-copy {
    /* Full width, like the card's other buttons — .login-submit's own default,
       restated because the padding below is not. */
    width: 100%;
    margin-top: 0.55rem;
    padding: 0.62rem 1rem;
    font-size: 0.88rem;
}

.connect-steps {
    margin: 1.1rem 0 0;
    padding-left: 1.35rem;
    font-size: 0.9rem;
    line-height: 1.55;
}

.connect-steps li + li {
    margin-top: 0.45rem;
}

/* ---------------------------------------------------------------------------
   The Writing menu: a sprint, a streak, and something to write to
   ------------------------------------------------------------------------ */

/* Three groups in one panel, each with a quiet label over it — the menu holds
   two lists and a read-out, and without the labels a row of minute-lengths sits
   straight under a row of weather. */
.writing-menu {
    min-width: 15rem;
}

.writing-menu-section {
    padding: 0.15rem 0;
}

.writing-menu-label {
    padding: 0.15rem 0.5rem 0.25rem;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted-fg, #64748b);
}

/* The sprint length that is remembered, and the bed that is playing, are the
   ones wearing the tick. */
.writing-sprint-length.is-active::after,
.background-noise-sound.is-active::after {
    content: "✓";
    margin-left: auto;
    padding-left: 0.75rem;
    color: var(--accent, #2563eb);
}

.writing-sprint-length,
.background-noise-sound {
    display: flex;
    align-items: center;
    width: 100%;
}

.writing-sprint-stop-item[hidden] {
    display: none;
}

.writing-streak-panel {
    padding-bottom: 0.35rem;
}

.writing-streak-current {
    padding: 0 0.5rem;
    font-size: 1.05rem;
    font-weight: 600;
}

.writing-streak-today,
.writing-streak-longest {
    padding: 0 0.5rem;
    font-size: 0.82rem;
}

.writing-streak-longest:empty {
    display: none;
}

/* Five steps rather than a slider, for the reason the app has five: a menu
   holds no dials, and a named step is a thing a writer can ask for again. */
.background-noise-volumes {
    display: flex;
    gap: 0.25rem;
    padding: 0.35rem 0.5rem 0.15rem;
}

.background-noise-volume {
    flex: 1 1 0;
    padding: 0.25rem 0.15rem;
    font-size: 0.72rem;
    line-height: 1.2;
    color: var(--muted-fg, #64748b);
    background: var(--interactive-bg, transparent);
    border: 1px solid var(--border, #cbd5e1);
    border-radius: 0.4rem;
    box-shadow: none;
}

.background-noise-volume.is-active {
    color: #fff;
    background: var(--accent, #2563eb);
    border-color: var(--accent, #2563eb);
}

/* ---------------------------------------------------------------------------
   The sprint's clock
   ------------------------------------------------------------------------ */

/* Off to one side and out of the way of the writing, which is the point of it:
   a sprint is a deadline a writer agreed to and then wants to stop thinking
   about. Fixed, because it outlives the page it was started on. */
.writing-sprint-strip {
    position: fixed;
    right: calc(1rem + env(safe-area-inset-right, 0px));
    bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    z-index: 1550;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.4rem 0.6rem 0.4rem 0.85rem;
    font-variant-numeric: tabular-nums;
    background: var(--box-bg, var(--bg, #fff));
    border: 1px solid var(--border, #cbd5e1);
    border-radius: 999px;
    box-shadow: 0 10px 30px -18px color-mix(in srgb, var(--fg, #000) 70%, transparent);
}

.writing-sprint-strip[hidden] {
    display: none;
}

.writing-sprint-clock {
    font-size: 1.05rem;
    font-weight: 600;
}

.writing-sprint-words:empty {
    display: none;
}

.writing-sprint-words {
    font-size: 0.82rem;
}

.writing-sprint-stop {
    padding: 0.15rem 0.6rem;
    font-size: 0.8rem;
    border-radius: 999px;
    box-shadow: none;
}

/* What the sprint came to, said once. Placed where the strip was, so the eye
   that was watching the clock finds the answer in the same corner. */
.writing-sprint-done {
    position: fixed;
    right: calc(1rem + env(safe-area-inset-right, 0px));
    bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    z-index: 1550;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    max-width: min(22rem, calc(100vw - 2rem));
    padding: 0.7rem 0.75rem 0.7rem 1rem;
    background: var(--box-bg, var(--bg, #fff));
    border: 1px solid var(--border, #cbd5e1);
    border-radius: 0.75rem;
    box-shadow: 0 14px 40px -20px color-mix(in srgb, var(--fg, #000) 70%, transparent);
}

.writing-sprint-done-close {
    margin-left: auto;
    padding: 0 0.35rem;
    font-size: 1.1rem;
    line-height: 1;
    color: var(--muted-fg, #64748b);
    background: none;
    border: 0;
    box-shadow: none;
}

/* On a phone the strip clears the tab bar rather than sitting on it — and in
   the editor, which has no tab bar, it sits where the tab bar would have been. */
html.app-shell .writing-sprint-strip,
html.app-shell .writing-sprint-done {
    right: calc(0.75rem + var(--app-safe-right));
    bottom: calc(var(--app-tab-height) + var(--app-safe-bottom) + 0.75rem);
}

html.app-shell body.app-shell-no-tabs .writing-sprint-strip,
html.app-shell body.app-shell-no-tabs .writing-sprint-done {
    bottom: calc(var(--app-safe-bottom) + 0.75rem);
}

/* =====================================================================
   Wyldcards — stacks, cards and parts
   ===================================================================== */

.stack-list-page {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.5rem 1rem 3rem;
}
@media (min-width: 769px) {
    .stack-list-page .user-list-header {
        align-items: center;
    }
    .stack-list-page .wyldcards-list-search-input {
        width: 15rem;
        max-width: 100%;
    }
    /* When the row is tight the search box gives up width first, so New stack
       does not drop onto a line of its own. */
    .stack-list-page .wyldcards-list-search {
        flex: 1 1 9rem;
        max-width: 15rem;
    }
    .stack-list-page .wyldcards-list-search .wyldcards-list-search-input {
        width: 100%;
    }
}
.stack-list-page .user-list-header-text .muted {
    font-variant-numeric: tabular-nums;
}

/* ---- Stack data tools: one card per tool, labels over their inputs --------- */
.stack-data-page {
    max-width: 960px;
}
.stack-data-page .user-list-header h1 {
    margin: 0 0 0.2rem;
}
.stack-data-sections {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}
.stack-data-section {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.85rem;
    margin: 0;
    padding: 1.1rem 1.25rem 1.25rem;
    border: 1px solid var(--border, #cbd5e1);
    border-radius: 12px;
    background: var(--box-bg, #ffffff);
}
.stack-data-section--half {
    grid-column: auto;
}
.stack-data-section--half > [role="button"] {
    margin-top: auto;
}
.stack-data-section h2 {
    margin: 0;
    font-size: 1.05rem;
}
.stack-data-section h2 + p.muted {
    margin: -0.55rem 0 0;
    max-width: 78ch;
    font-size: 0.88rem;
    line-height: 1.45;
}
.stack-data-section h3 {
    margin: 0 0 0.5rem;
    font-size: 0.8rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted-fg, #64748b);
}
.stack-data-form {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.6rem 0.75rem;
    margin: 0;
    width: 100%;
}
.stack-data-form > label {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    margin: 0;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--muted-fg, #64748b);
}
.stack-data-form > label > :is(input:not([type="file"]), select) {
    box-sizing: border-box;
    min-height: 2.35rem;
    padding: 0.35rem 0.6rem;
    border-radius: 7px;
}
.stack-data-form > label > :is(input, select) {
    min-width: 13rem;
    margin: 0;
    font-size: 0.95rem;
    font-weight: 400;
    color: var(--fg, inherit);
}
.stack-data-form > .wyldcards-list-action-btn {
    min-height: 2.35rem;
}
.stack-data-form + .stack-data-form {
    padding-top: 0.85rem;
    border-top: 1px solid var(--border, #cbd5e1);
}
.stack-data-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 1rem;
    flex: 1 1 100%;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
}
.stack-data-fields legend {
    width: 100%;
    margin-bottom: 0.3rem;
    padding: 0;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--muted-fg, #64748b);
}
.stack-data-fields label {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0;
    font-size: 0.9rem;
}
.stack-data-fields input[type="checkbox"] {
    margin: 0;
}
.stack-data-results {
    width: 100%;
}
.stack-data-results p.muted {
    margin: 0 0 0.35rem;
    font-size: 0.85rem;
}
.stack-data-results ul {
    margin: 0;
    padding-left: 1.1rem;
}
.stack-data-saved {
    width: 100%;
    padding-top: 0.85rem;
    border-top: 1px solid var(--border, #cbd5e1);
}
.stack-data-saved-row + .stack-data-saved-row {
    margin-top: 0.4rem;
}
.stack-data-saved-row form {
    margin: 0;
}
@media (max-width: 40rem) {
    .stack-data-sections {
        grid-template-columns: minmax(0, 1fr);
    }
    .stack-data-form > label,
    .stack-data-form > label > :is(input, select) {
        min-width: 0;
        width: 100%;
    }
}
/* The shortcut chip made Commands a few pixels taller than its neighbours;
   match their corner radius and weight too so the row reads as one set. */
.stack-list-page .command-palette-toggle {
    min-height: 0;
    padding-block: 0.4rem;
    border-radius: 7px;
    font-size: 0.8rem;
    font-weight: 600;
}
.stack-list-page .command-palette-toggle kbd {
    padding-block: 0;
    line-height: 1.2;
}
.stack-list-section {
    margin-top: 1.5rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.5rem 1rem;
}
.stack-list-section summary {
    cursor: pointer;
    font-weight: 600;
}
.stack-list-plain {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0 0;
}
.stack-list-plain li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.4rem 0;
    border-top: 1px solid var(--border);
}
.stack-list-inline-form {
    display: inline-flex;
    margin: 0;
}
/* Archive, trash and archived-card rows: name and details on the left, the
   actions together on the right, instead of buttons butting the name. */
.user-list-panel:has(> .stack-list-plain) {
    padding: 0.2rem 0.75rem;
    border: 1px solid var(--border, #cbd5e1);
    border-radius: 10px;
    background: var(--box-bg, #ffffff);
}
.user-list-panel > .stack-list-plain {
    margin: 0;
}
.stack-list-plain li:first-child {
    border-top: 0;
}
.stack-list-plain li {
    padding: 0.65rem 0.35rem;
}
.stack-list-plain-main {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex: 1 1 auto;
    min-width: 0;
}
.stack-list-plain-main .stack-icon {
    margin-right: 0;
}
.stack-list-plain-text {
    display: grid;
    gap: 0.1rem;
    min-width: 0;
}
.stack-list-plain-text > :first-child {
    overflow: hidden;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.stack-list-plain-meta {
    color: var(--muted-fg, #64748b);
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
}
.stack-list-plain-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
}
.stack-list-empty {
    margin-top: 0.5rem;
}
.stack-list-empty .wyldcards-list-empty-title + p {
    max-width: 34rem;
    margin-inline: auto;
}
@media (max-width: 40rem) {
    .stack-list-plain li {
        flex-wrap: wrap;
    }
    .stack-list-plain-actions {
        width: 100%;
        justify-content: flex-end;
    }
}

/* ---- The home screen: dock, list or grid, and the customize page ---------- */
/* Hidden bulk bars and drop zones sit between groups, so an adjacent-sibling
   rule left the stacks grid touching the dock. */
.stack-list-group ~ .stack-list-group {
    margin-top: 1.5rem;
}
.stack-list-group-heading {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted-fg, #64748b);
    margin: 0 0 0.5rem 0.15rem;
}
.stack-dock {
    padding: 0.85rem;
    border: 1px solid color-mix(in srgb, var(--accent, #475569) 32%, var(--border, #cbd5e1));
    border-radius: 18px;
    background: color-mix(in srgb, var(--box-bg, #ffffff) 90%, var(--accent-bg, rgba(71, 85, 105, 0.2)));
}
.stack-dock-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin: 0.1rem 0.15rem 0.75rem;
}
.stack-dock-title {
    margin: 0;
    font-size: 0.8rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}
.stack-dock-description {
    margin: 0.18rem 0 0;
    color: var(--muted-fg, #64748b);
    font-size: 0.85rem;
}
.stack-dock-drop-hint {
    flex: 0 0 auto;
    padding: 0.3rem 0.55rem;
    border: 1px dashed color-mix(in srgb, var(--accent, #475569) 45%, var(--border, #cbd5e1));
    border-radius: 999px;
    color: var(--muted-fg, #64748b);
    font-size: 0.75rem;
    font-weight: 700;
}
/* An empty dock already says "Drag stacks here" under the targets. */
.stack-dock:has(.stack-dock-empty-hint) .stack-dock-drop-hint {
    display: none;
}
.stack-dock.is-drop-target {
    border-color: var(--accent, #475569);
    background: color-mix(in srgb, var(--box-bg, #ffffff) 78%, var(--accent-bg, rgba(71, 85, 105, 0.2)));
    box-shadow: 0 0 0 4px var(--accent-bg, rgba(71, 85, 105, 0.2));
}
/* Doubled class: .stack-grid's auto-fill template comes later in the file and
   would otherwise replace the dock's single scrolling row of columns. */
.stack-grid.stack-dock-grid {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: minmax(11.5rem, 12.5rem);
    overflow-x: auto;
    padding: 0.15rem;
    scroll-snap-type: x proximity;
    scrollbar-width: thin;
}
.stack-dock-grid.is-drag-active {
    scrollbar-width: none;
}
.stack-dock-grid.is-drag-active::-webkit-scrollbar {
    display: none;
}
.stack-dock-grid .stack-tile {
    scroll-snap-align: start;
}
.stack-dock-empty-hint {
    margin: 0.7rem 0 0;
    color: var(--muted-fg, #64748b);
    font-size: 0.9rem;
}
.stack-dock-target {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    box-sizing: border-box;
    width: auto;
    min-height: 8.25rem;
    padding: 0.7rem;
    border: 2px dashed;
    border-radius: 18px;
    font-weight: 700;
    pointer-events: none;
}
.stack-dock-target-icon {
    box-sizing: border-box;
    width: 2.75rem;
    height: 2.75rem;
    padding: 0.5rem;
    border: 1px solid currentColor;
    border-radius: 0.8rem;
    background: color-mix(in srgb, currentColor 8%, transparent);
    transition: transform 160ms ease, background-color 160ms ease;
}
.stack-dock-target-label {
    font-size: 0.85rem;
    line-height: 1.2;
}
/* Stack the icon over its label, as the trash target does; laid out in a row
   the label ran into the icon. */
.stack-dock-target-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    align-self: stretch;
    width: 100%;
    color: inherit;
    text-decoration: none;
}
.stack-dock-target-link:hover .stack-dock-target-icon,
.stack-dock-target-link:focus-visible .stack-dock-target-icon {
    transform: translateY(-2px);
    background: color-mix(in srgb, currentColor 16%, transparent);
}
.stack-dock-target-link:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 3px;
    border-radius: 14px;
}
.stack-dock-archive-target {
    border-color: #2563eb;
    color: #1d4ed8;
    background: color-mix(in srgb, var(--box-bg, #ffffff) 88%, #dbeafe);
    pointer-events: auto;
}
.stack-dock-trash-target {
    border-color: #b91c1c;
    color: #991b1b;
    background: color-mix(in srgb, var(--box-bg, #ffffff) 88%, #fee2e2);
}
.stack-dock-archive-target.is-drop-target,
.stack-dock-trash-target.is-drop-target {
    color: #ffffff;
    border-style: solid;
    transform: scale(1.04);
}
.stack-dock-archive-target.is-drop-target {
    background: #2563eb;
}
.stack-dock-trash-target.is-drop-target {
    background: #b91c1c;
}
.stack-dock-target.is-drop-target .stack-dock-target-icon {
    background: rgba(255, 255, 255, 0.16);
    transform: scale(1.08);
}
/* The light-theme blue and red read as barely-there on a dark dock. */
:root.-dark-theme .stack-dock-archive-target:not(.is-drop-target) {
    border-color: #60a5fa;
    color: #93c5fd;
    background: color-mix(in srgb, var(--box-bg, #1e293b) 85%, #2563eb);
}
:root.-dark-theme .stack-dock-trash-target:not(.is-drop-target) {
    border-color: #f87171;
    color: #fca5a5;
    background: color-mix(in srgb, var(--box-bg, #1e293b) 85%, #b91c1c);
}
@media (prefers-color-scheme: dark) {
    :root:not(.-no-dark-theme) .stack-dock-archive-target:not(.is-drop-target) {
        border-color: #60a5fa;
        color: #93c5fd;
        background: color-mix(in srgb, var(--box-bg, #1e293b) 85%, #2563eb);
    }
    :root:not(.-no-dark-theme) .stack-dock-trash-target:not(.is-drop-target) {
        border-color: #f87171;
        color: #fca5a5;
        background: color-mix(in srgb, var(--box-bg, #1e293b) 85%, #b91c1c);
    }
}
@media (max-width: 40rem) {
    .stack-dock {
        padding: 0.7rem;
        border-radius: 14px;
    }
    .stack-dock-header {
        margin-bottom: 0.6rem;
    }
    .stack-dock-description {
        font-size: 0.8rem;
    }
    .stack-dock-drop-hint {
        display: none;
    }
    /* Two tiles to a screen, so the Archive and Trash targets fit without
       scrolling; docked stacks before them scroll sideways. */
    .stack-grid.stack-dock-grid {
        grid-auto-columns: calc((100% - 0.6rem) / 2);
        gap: 0.6rem;
    }
    .stack-dock-target {
        min-height: 7.5rem;
        border-radius: 14px;
    }
}
.stack-pin-btn.is-pinned {
    color: var(--accent, #475569);
    border-color: var(--accent, #475569);
    background: rgba(71, 85, 105, 0.08);
}
.stack-pin-btn.is-pinned svg {
    fill: currentColor;
    opacity: 1;
}
.stack-start-chip {
    color: var(--accent, #475569);
    border-color: var(--accent, #475569);
}

/* The grid: a tile per stack, its icon large, its name under, the actions in
   a footer. .wyldcards-list-row on the tile is for the phone chrome, which folds
   .wyldcards-list-actions into one "..." whatever shape the row is. */
.stack-grid {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(11.5rem, 1fr));
    gap: 0.85rem;
}
.stack-columns {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: minmax(14rem, 18rem);
    align-items: stretch;
    overflow-x: auto;
    padding: 0.15rem;
    scroll-snap-type: x proximity;
    scrollbar-width: thin;
}
.stack-columns .stack-tile {
    min-height: 18rem;
    scroll-snap-align: start;
}
.stack-grid--reorderable .stack-tile {
    cursor: grab;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-drag: none;
}
.stack-grid--reorderable .stack-tile.is-dragging {
    cursor: grabbing;
    opacity: 0.3;
    border-color: var(--accent, #475569);
    border-style: dashed;
    box-shadow: 0 0 0 3px var(--accent-bg, rgba(71, 85, 105, 0.2));
}
/* iOS can omit a fixed drag preview during a touch gesture; leave its source
   tile visible so the stack never appears to vanish. */
.stack-grid--reorderable .stack-tile.is-dragging.is-touch-dragging {
    opacity: 0.72;
}
/* The dock must retain its tile while a transfer waits for its page reload. */
.stack-dock-grid.stack-grid--reorderable .stack-tile.is-dragging {
    opacity: 1;
}
.stack-tile.stack-tile-drag-preview {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 10000;
    box-sizing: border-box;
    margin: 0;
    pointer-events: none;
    user-select: none;
    opacity: 0.94;
    border-color: var(--accent, #475569);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
    transition: none;
    will-change: transform;
}
.stack-grid--reorderable .stack-tile-face {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
}
.stack-grid--reorderable .stack-tile.is-drop-target {
    border-color: var(--accent, #475569);
    background: color-mix(in srgb, var(--box-bg, #ffffff) 86%, var(--accent-bg, rgba(71, 85, 105, 0.2)));
    box-shadow: 0 0 0 3px var(--accent-bg, rgba(71, 85, 105, 0.2));
    transform: translateY(-2px) scale(1.012);
}
.stack-grid--reorderable .stack-tile.is-group-target {
    border-style: dashed;
    box-shadow: 0 0 0 4px var(--accent-bg, rgba(71, 85, 105, 0.2)), inset 0 0 0 2px var(--accent, #475569);
}
.stack-drop-zone {
    position: fixed;
    right: calc(1rem + env(safe-area-inset-right, 0px));
    bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    z-index: 9999;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.8rem 1rem;
    border: 2px dashed #b91c1c;
    border-radius: 999px;
    color: #991b1b;
    background: color-mix(in srgb, var(--box-bg, #ffffff) 88%, #fee2e2);
    box-shadow: 0 8px 22px rgba(127, 29, 29, 0.2);
    font-weight: 700;
    pointer-events: none;
}
.stack-drop-zone[hidden] {
    display: none !important;
}
.stack-archive-drop-zone {
    left: calc(1rem + env(safe-area-inset-left, 0px));
    right: auto;
    border-color: #2563eb;
    color: #1d4ed8;
    background: color-mix(in srgb, var(--box-bg, #ffffff) 88%, #dbeafe);
    box-shadow: 0 8px 22px rgba(30, 64, 175, 0.2);
}
.stack-dock-drop-zone {
    position: static;
    width: fit-content;
    margin: 1rem 0;
    right: auto;
    bottom: auto;
    z-index: auto;
    border-color: var(--accent, #475569);
    color: var(--accent, #475569);
    background: color-mix(in srgb, var(--box-bg, #ffffff) 88%, var(--accent-bg, rgba(71, 85, 105, 0.2)));
}
.stack-trash-drop-zone.is-drop-target {
    color: #ffffff;
    background: #b91c1c;
    border-style: solid;
    transform: scale(1.06);
}
.stack-archive-drop-zone.is-drop-target {
    color: #ffffff;
    background: #2563eb;
    border-style: solid;
    transform: scale(1.06);
}
.stack-dock-drop-zone.is-drop-target {
    color: var(--box-bg, #ffffff);
    background: var(--accent, #475569);
    border-style: solid;
    transform: scale(1.06);
}
/* Keep drag destinations above the mobile tab bar throughout a long drag. */
html.app-shell .stack-drop-zone {
    bottom: calc(var(--app-tab-height) + var(--app-safe-bottom) + 1rem);
}
html.app-shell body.app-shell-no-tabs .stack-drop-zone {
    bottom: calc(var(--app-safe-bottom) + 1rem);
}
.stack-tile {
    display: flex;
    flex-direction: column;
    min-width: 0;
    border: 1px solid color-mix(in srgb, var(--border, #cbd5e1) 82%, var(--fg, #0f172a));
    border-radius: 14px;
    background: var(--box-bg, #ffffff);
    overflow: visible;
    box-shadow: inset 0 1px rgba(255, 255, 255, 0.35);
    transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease, transform 0.15s ease;
}
.stack-tile:hover,
.stack-tile:focus-within {
    border-color: color-mix(in srgb, var(--accent, #475569) 52%, var(--border, #cbd5e1));
    box-shadow: inset 0 1px rgba(255, 255, 255, 0.45);
    transform: translateY(-1px);
}
.stack-tile--pinned {
    border-color: color-mix(in srgb, var(--accent, #475569) 68%, var(--border, #cbd5e1));
    box-shadow: inset 3px 0 var(--accent, #475569), inset 0 1px rgba(255, 255, 255, 0.35);
}
.stack-tile-face {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.4rem;
    padding: 1.25rem 0.9rem 0.9rem;
    color: inherit;
    text-decoration: none !important;
    flex: 1 1 auto;
    min-width: 0;
}
.stack-tile-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3.75rem;
    height: 3.75rem;
    border-radius: 18px;
    background: var(--accent-bg, rgba(0, 0, 0, 0.04));
    border: 1px solid var(--border, #cbd5e1);
    font-size: 1.9rem;
    font-weight: 700;
    line-height: 1;
}
.stack-tile-name {
    font-weight: 600;
    line-height: 1.3;
    max-width: 100%;
    overflow-wrap: anywhere;
}
.stack-tile-group-icons {
    display: flex;
    justify-content: center;
    max-width: 100%;
    margin-top: -0.1rem;
}
.stack-tile-group-icons > span {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.55rem;
    height: 1.55rem;
    margin-left: -0.35rem;
    overflow: hidden;
    border: 2px solid var(--box-bg, #ffffff);
    border-radius: 50%;
    background: var(--accent-bg, rgba(0, 0, 0, 0.04));
    font-size: 0.85rem;
    line-height: 1;
}
.stack-tile-group-icons > span:first-child {
    margin-left: 0;
}
.stack-tile-meta {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    color: var(--muted-fg, #64748b);
    font-variant-numeric: tabular-nums;
}
.stack-tile-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.55rem 0.7rem;
    border-top: 1px solid color-mix(in srgb, var(--border, #cbd5e1) 82%, var(--fg, #0f172a));
    position: relative;
}
.stack-tile-actions .wyldcards-list-archive-form {
    display: inline-flex;
    margin: 0;
}
/* Customize page: the pin-and-arrange list. */
.home-sort-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}
.home-arrange {
    margin-top: 1.25rem;
}
.home-arrange-list {
    list-style: none;
    margin: 0.5rem 0 0;
    padding: 0;
    counter-reset: home-arrange;
}
.home-arrange-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.5rem 0.25rem;
    border-top: 1px solid var(--border, #cbd5e1);
    counter-increment: home-arrange;
}
.home-arrange-row::before {
    content: counter(home-arrange);
    flex: 0 0 1.5rem;
    color: var(--muted-fg, #64748b);
    font-variant-numeric: tabular-nums;
    font-size: 0.85rem;
}
.home-arrange-row.is-pinned {
    background: rgba(71, 85, 105, 0.05);
}
.home-arrange-name {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1 1 auto;
    min-width: 0;
    font-weight: 600;
}
.home-arrange-controls {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    vertical-align: middle;
    flex-shrink: 0;
}
.home-arrange-controls form {
    display: inline-flex;
    margin: 0;
}
.home-arrange-controls button[disabled] {
    opacity: 0.35;
    cursor: default;
}
.home-reset-form {
    display: none;
}
@media (max-width: 640px) {
    .home-sort-list {
        grid-template-columns: 1fr;
    }
    .stack-columns {
        grid-auto-columns: minmax(78vw, 18rem);
    }
}

/* ---- The card page fills the viewport below the nav ---------------- */
main.wyldcards-card-page {
    max-width: none;
    width: 100%;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 56px);
    height: calc(100dvh - 56px);
}
/* Only the workbench gives up height. Left to shrink, a wrapped toolbar kept
   its 3rem box while its second row spilled out beneath it — and, sticky,
   drew that row straight over the edit bar as the page scrolled. */
main.wyldcards-card-page > :not(.wyldcards-workbench) {
    flex-shrink: 0;
}
.wyldcards-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    /* Room on the right for the fixed header actions (install, help, account). */
    padding: 0.5rem 11.5rem 0.5rem 1rem;
    min-height: 3rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    position: sticky;
    top: 0;
    z-index: 5;
}
.wyldcards-toolbar-group {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    vertical-align: middle;
    min-width: 0;
}
.wyldcards-toolbar-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 30vw;
}
.wyldcards-toolbar-back {
    text-decoration: none;
    color: var(--muted-fg);
    white-space: nowrap;
}
.wyldcards-stack-only .sidebar {
    display: none;
}
.wyldcards-stack-only main.wyldcards-card-page {
    min-height: 100vh;
    height: auto;
}
.wyldcards-stack-only .wyldcards-toolbar {
    justify-content: flex-start;
    padding-right: 1rem;
}
.wyldcards-stack-view-title {
    max-width: min(36vw, 28rem);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.wyldcards-stack-view-count {
    margin-left: auto;
    color: var(--muted-fg);
    font-size: 0.85rem;
    white-space: nowrap;
}
.wyldcards-stack-scroll {
    display: flex;
    align-items: flex-start;
    gap: 2rem;
    padding: 1.5rem;
    overflow-x: auto;
    overflow-y: hidden;
    background-color: color-mix(in srgb, var(--fg) 3%, var(--bg));
    background-image: radial-gradient(color-mix(in srgb, var(--fg) 14%, transparent) 0.75px, transparent 0.75px);
    background-size: 16px 16px;
}
.wyldcards-stack-scroll-card {
    flex: 0 0 auto;
    width: fit-content;
    max-width: 100%;
}
.wyldcards-stack-scroll-caption {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.4rem;
    color: var(--muted-fg);
    font-size: 0.85rem;
}
.wyldcards-stack-scroll-caption-title {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    min-width: 0;
}
.wyldcards-stack-scroll-caption a {
    color: inherit;
}
.wyldcards-stack-scroll-grip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0.25rem 0.35rem;
    border: none;
    border-radius: 6px;
    background: none;
    box-shadow: none;
    color: var(--muted-fg);
    font-size: 1rem;
    line-height: 1;
    cursor: grab;
    touch-action: none;
    user-select: none;
}
.wyldcards-stack-scroll-grip:hover,
.wyldcards-stack-scroll-grip:focus-visible {
    color: var(--fg);
    background: var(--accent-bg, rgba(0, 0, 0, 0.06));
}
.wyldcards-stack-scroll-grip:active,
.wyldcards-stack-scroll-card.is-dragging .wyldcards-stack-scroll-grip {
    cursor: grabbing;
}
.wyldcards-stack-scroll-card.is-dragging {
    position: relative;
    z-index: 2;
    background: var(--bg);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
    opacity: 0.96;
}
.wyldcards-reorder-active .wyldcards-stack-scroll-card:not(.is-dragging) {
    transition: transform 120ms ease;
}
.wyldcards-reorder-active .wyldcards-stack-scroll-card:not(.is-dragging) * {
    pointer-events: none;
}
.wyldcards-stack-scroll-reorder-status {
    margin: 0.75rem auto;
    color: var(--muted-fg);
    font-size: 0.85rem;
}
.wyldcards-stack-scroll .wyldcards-card-viewport {
    display: inline-block;
}
.wyldcards-stack-view-navigation {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-left: auto;
}
.wyldcards-present-mode {
    background: #101217;
}
.wyldcards-present-mode main.wyldcards-card-page {
    min-height: 100dvh;
    height: 100dvh;
    display: grid;
    grid-template-columns: minmax(9rem, 12rem) minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
}
.wyldcards-present-mode .wyldcards-toolbar {
    grid-column: 1 / -1;
    padding: 0.5rem 1rem;
    color: #e8eaf0;
    border-color: #30343d;
    background: #181b22;
}
.wyldcards-present-mode .wyldcards-present-toolbar {
    width: 100%;
}
.wyldcards-present-mode .wyldcards-toolbar-back,
.wyldcards-present-mode .wyldcards-toolbar-cardname,
.wyldcards-present-mode .wyldcards-present-set {
    color: #b8bfce;
}
.wyldcards-present-mode .wyldcards-present-set {
    margin-left: auto;
    font-size: 0.85rem;
}
.wyldcards-present-navigator {
    display: flex;
    align-items: stretch;
    gap: 0.55rem;
    min-height: 5.9rem;
    padding: 0.7rem max(1rem, calc((100% - 72rem) / 2));
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    scrollbar-color: var(--muted-fg) var(--bg);
}
.wyldcards-present-mode .wyldcards-present-navigator {
    grid-column: 1;
    grid-row: 2;
    flex-direction: column;
    align-items: stretch;
    gap: 0.45rem;
    min-height: 0;
    padding: 0.7rem;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-block: contain;
    border-right: 1px solid var(--border);
    border-bottom: 0;
}
.wyldcards-browser-navigator,
.wyldcards-outline-sidebar {
    position: absolute;
    z-index: 4;
    top: 3.1rem;
    bottom: 0;
    left: 0;
    width: 14rem;
    margin: 0;
    color: var(--fg);
    background: var(--plain-bg);
    border-right: 1px solid var(--border);
}
.wyldcards-browser-navigator {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem 0.6rem 0;
}
.wyldcards-browser-navigator[hidden] {
    display: none;
}
.wyldcards-browser-navigator-header {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin: 0;
    padding: 0 0.15rem;
}
.wyldcards-browser-navigator-label {
    color: var(--muted-fg);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}
.wyldcards-browser-navigator-label small {
    margin-left: 0.25rem;
    font-weight: 600;
    letter-spacing: 0;
    font-variant-numeric: tabular-nums;
}
.wyldcards-browser-navigator-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0.4rem;
    color: var(--muted-fg);
    background: transparent;
    font-size: 1.25rem;
    line-height: 1;
}
.wyldcards-browser-navigator-close:hover,
.wyldcards-browser-navigator-close:focus-visible {
    color: var(--fg);
    background: var(--interactive-bg);
}
.wyldcards-browser-navigator-filter {
    width: 100%;
    min-height: 2rem;
    margin: 0;
    padding: 0.3rem 0.55rem;
    border: 1px solid var(--border);
    border-radius: 0.45rem;
    color: var(--fg);
    background: var(--bg);
    font-size: 0.85rem;
}
.wyldcards-browser-navigator-tools {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}
.wyldcards-browser-navigator-tools .wyldcards-browser-navigator-filter {
    flex: 1 1 auto;
    min-width: 0;
}
.wyldcards-browser-navigator-marked {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    flex: 0 0 auto;
    min-height: 2rem;
    margin: 0;
    padding: 0 0.5rem;
    border: 1px solid var(--border);
    border-radius: 0.45rem;
    color: var(--muted-fg);
    background: transparent;
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1;
}
.wyldcards-browser-navigator-marked::before {
    content: "";
    width: 0.45rem;
    height: 0.45rem;
    border-radius: 50%;
    background: var(--accent);
}
.wyldcards-browser-navigator-marked:hover,
.wyldcards-browser-navigator-marked:focus-visible {
    color: var(--fg);
    background: var(--interactive-bg);
}
.wyldcards-browser-navigator-marked[aria-pressed="true"] {
    border-color: var(--accent);
    color: var(--accent);
    background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.wyldcards-browser-navigator-filter::placeholder {
    color: var(--muted-fg);
    text-align: left !important;
}
.wyldcards-browser-navigator .wyldcards-present-navigator {
    flex: 1 1 auto;
    min-height: 0;
    padding: 0.15rem 0.1rem 0.9rem;
    flex-direction: column;
    align-items: stretch;
    gap: 0.2rem;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-block: contain;
    background: transparent;
    border: 0;
}
.wyldcards-browser-navigator .wyldcards-present-navigator-card {
    flex: 0 0 auto;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 0.55rem;
    min-height: 2.25rem;
    padding: 0.3rem 0.5rem;
    border: 1px solid transparent;
    border-radius: 0.45rem;
    color: var(--fg);
    background: transparent;
    box-shadow: none;
    scroll-margin-block: 0.5rem;
}
.wyldcards-browser-navigator .wyldcards-present-navigator-card[hidden] {
    display: none;
}
.wyldcards-browser-navigator .wyldcards-present-navigator-card:hover {
    color: var(--fg);
    background: var(--interactive-bg);
}
.wyldcards-browser-navigator .wyldcards-present-navigator-card:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}
.wyldcards-browser-navigator .wyldcards-present-navigator-card--current,
.wyldcards-browser-navigator .wyldcards-present-navigator-card--current:hover {
    border-color: color-mix(in srgb, var(--accent) 55%, transparent);
    color: var(--fg);
    background: color-mix(in srgb, var(--accent) 16%, transparent);
}
.wyldcards-browser-navigator .wyldcards-present-navigator-card span {
    flex: 0 0 auto;
    min-width: 1.6rem;
    color: var(--muted-fg);
    font-size: 0.75rem;
    font-weight: 700;
    text-align: right;
    opacity: 1;
}
.wyldcards-browser-navigator .wyldcards-present-navigator-card--current span {
    color: var(--accent);
}
.wyldcards-browser-navigator .wyldcards-present-navigator-card small {
    display: block;
    min-width: 0;
    font-size: 0.85rem;
    font-weight: 600;
}
.wyldcards-browser-navigator .wyldcards-present-navigator-card {
    flex-wrap: wrap;
}
.wyldcards-browser-navigator .wyldcards-present-navigator-card small {
    flex: 1 1 0;
    overflow-wrap: anywhere;
}
.wyldcards-browser-navigator-mark {
    flex: 0 0 auto;
    width: 0.45rem;
    height: 0.45rem;
    border-radius: 50%;
    background: var(--accent);
}
.wyldcards-browser-navigator-snippet {
    flex: 1 0 100%;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    margin: -0.15rem 0 0.1rem calc(1.6rem + 0.55rem);
    color: var(--muted-fg);
    font-size: 0.75rem;
    font-style: normal;
    line-height: 1.3;
    overflow-wrap: anywhere;
}
.wyldcards-browser-navigator-snippet[hidden] {
    display: none;
}
.wyldcards-browser-navigator-snippet mark {
    padding: 0 0.05em;
    border-radius: 0.15em;
    color: inherit;
    background: color-mix(in srgb, var(--accent) 28%, transparent);
}
.wyldcards-browser-navigator [data-card-navigator-reorder] .wyldcards-present-navigator-card {
    touch-action: pan-y;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}
.wyldcards-browser-navigator [data-card-navigator-reorder].is-reordering {
    cursor: grabbing;
}
.wyldcards-browser-navigator [data-card-navigator-reorder][aria-busy="true"] {
    opacity: 0.7;
}
.wyldcards-browser-navigator .wyldcards-present-navigator-card.is-dragging {
    border-style: dashed;
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 8%, transparent);
}
.wyldcards-browser-navigator .wyldcards-present-navigator-card.is-dragging > * {
    visibility: hidden;
}
.wyldcards-browser-navigator .wyldcards-present-navigator-card.is-selected,
.wyldcards-browser-navigator .wyldcards-present-navigator-card.is-selected:hover {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 30%, transparent);
    box-shadow: inset 0 0 0 1px var(--accent);
}
.wyldcards-browser-navigator .wyldcards-present-navigator-card.is-cut {
    border-style: dashed;
    border-color: color-mix(in srgb, var(--muted-fg) 60%, transparent);
    opacity: 0.55;
}
/* The card navigator's right-click menu. It is moved to <body> while open. */
.wyldcards-card-navigator-menu {
    position: fixed;
    z-index: 1100;
    min-width: 12rem;
    max-width: calc(100vw - 16px);
    max-height: calc(100vh - 16px);
    overflow-y: auto;
    padding: 0.35rem;
    background-color: var(--box-bg, #ffffff);
    border: 1px solid var(--border, #e0e0e0);
    border-radius: 0.65rem;
    box-shadow: 0 12px 32px -12px rgba(0, 0, 0, 0.45);
}
.wyldcards-card-navigator-menu[hidden] {
    display: none;
}
.wyldcards-card-navigator-menu .nav-dropdown-item {
    margin: 0;
    padding: 0.4rem 0.65rem;
    font-size: 0.875rem;
}
.wyldcards-card-navigator-menu .nav-dropdown-item:disabled {
    opacity: 0.45;
    cursor: default;
    background: none;
    color: var(--fg, #333333);
}
.wyldcards-card-navigator-menu .wyldcards-card-navigator-menu-danger:not(:disabled):hover,
.wyldcards-card-navigator-menu .wyldcards-card-navigator-menu-danger:not(:disabled):focus-visible {
    color: var(--danger-fg, #b91c1c);
    background-color: var(--danger-bg, rgba(185, 28, 28, 0.08));
}
.wyldcards-browser-navigator .wyldcards-card-navigator-drag-preview {
    position: fixed;
    top: 0;
    z-index: 1000;
    margin: 0;
    pointer-events: none;
    border-color: var(--accent);
    background: var(--bg);
    box-shadow: 0 12px 28px -14px rgba(0, 0, 0, 0.6);
}
.wyldcards-browser-navigator-empty {
    margin: 0.5rem 0.4rem;
    color: var(--muted-fg);
    font-size: 0.85rem;
}
.wyldcards-browser-navigator-add {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    min-height: 2.25rem;
    margin: 0.35rem 0 0;
    padding: 0 0.5rem;
    border: 1px dashed var(--border);
    border-radius: 0.45rem;
    color: var(--muted-fg);
    background: transparent;
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1;
}
.wyldcards-browser-navigator-add:hover,
.wyldcards-browser-navigator-add:focus-visible {
    border-color: var(--accent);
    color: var(--accent);
    background: color-mix(in srgb, var(--accent) 10%, transparent);
}
main.wyldcards-card-page:has(.wyldcards-browser-navigator:not([hidden])) .wyldcards-editbar,
main.wyldcards-card-page:has(.wyldcards-browser-navigator:not([hidden])) .wyldcards-part-picker,
main.wyldcards-card-page:has(.wyldcards-browser-navigator:not([hidden])) .wyldcards-workbench {
    margin-left: 14rem;
}
.wyldcards-outline-sidebar {
    width: min(22rem, 38vw);
    padding: 0.85rem;
    overflow-y: auto;
    background: var(--bg);
    border-right: 1px solid var(--border);
}
.wyldcards-outline-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}
.wyldcards-outline-sidebar-header button {
    margin: 0;
    padding: 0.2rem 0.45rem;
    color: var(--muted-fg);
    font-size: 0.75rem;
}
.wyldcards-outline-sidebar-list {
    display: grid;
    gap: 0.35rem;
    margin: 0;
    padding: 0;
    list-style: none;
}
.wyldcards-outline-sidebar-card {
    padding: 0.55rem 0.6rem;
    border-left: 2px solid transparent;
}
.wyldcards-outline-sidebar-card--current {
    border-left-color: var(--accent, #2563eb);
    background: color-mix(in srgb, var(--accent, #2563eb) 9%, var(--bg));
}
.wyldcards-outline-sidebar-card > a {
    display: flex;
    align-items: baseline;
    gap: 0.45rem;
    color: inherit;
    text-decoration: none;
}
.wyldcards-outline-sidebar-card > a > span {
    flex: none;
    min-width: 1.25rem;
    color: var(--muted-fg);
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
    text-align: right;
}
.wyldcards-outline-sidebar-card > a:hover strong,
.wyldcards-outline-sidebar-card > a:focus-visible strong { color: var(--accent, #2563eb); }
.wyldcards-outline-sidebar-card > p {
    display: -webkit-box;
    margin: 0.3rem 0 0 1.7rem;
    overflow: hidden;
    color: var(--muted-fg);
    font-size: 0.82rem;
    line-height: 1.35;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    white-space: pre-line;
}
main.wyldcards-card-page:has(.wyldcards-outline-sidebar:not([hidden])) .wyldcards-workbench {
    margin-left: min(22rem, 38vw);
}
.wyldcards-present-navigator-card {
    display: flex;
    flex: 0 0 7.5rem;
    flex-direction: column;
    justify-content: space-between;
    min-height: 4.5rem;
    padding: 0.45rem 0.55rem;
    border: 1px solid #3c424e;
    border-radius: 0.35rem;
    color: #c5cad5;
    background: linear-gradient(145deg, #292e38, #20242c);
    text-decoration: none;
    box-shadow: inset 0 0 0 1px rgb(255 255 255 / 3%);
}
.wyldcards-present-navigator-card:hover {
    border-color: #7e8797;
    color: #fff;
}
.wyldcards-present-navigator-card--current {
    border-color: #65a3ff;
    color: #fff;
    background: linear-gradient(145deg, #2b5c99, #234570);
    box-shadow: 0 0 0 2px rgb(101 163 255 / 30%);
}
.wyldcards-present-navigator-card span {
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
    opacity: 0.75;
}
.wyldcards-present-navigator-card small {
    overflow: hidden;
    color: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.wyldcards-present-mode .wyldcards-workbench {
    grid-column: 2;
    grid-row: 2;
    display: block;
    flex: 1;
    min-height: 0;
}
.wyldcards-present-mode .wyldcards-stage {
    height: 100%;
    padding: clamp(1rem, 4vw, 4rem);
    cursor: pointer;
    background: #101217;
}
.wyldcards-present-mode .wyldcards-card-viewport {
    max-width: 100%;
    max-height: 100%;
}
.wyldcards-present-mode .wyldcards-card {
    box-shadow: 0 1.5rem 4rem rgb(0 0 0 / 35%);
}
.wyldcards-presenter-notes {
    position: fixed;
    z-index: 10;
    right: 1rem;
    bottom: 1rem;
    width: min(28rem, calc(100vw - 2rem));
    max-height: min(45dvh, 28rem);
    overflow: auto;
    padding: 1rem;
    border: 1px solid #4c5360;
    border-radius: 0.5rem;
    color: #e8eaf0;
    background: #20242c;
    box-shadow: 0 1rem 3rem rgb(0 0 0 / 45%);
}
.wyldcards-presenter-notes header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
.wyldcards-presenter-notes header button {
    padding: 0.2rem 0.5rem;
}
.wyldcards-presenter-notes p {
    margin: 0.8rem 0 0;
    white-space: pre-wrap;
}
@media (max-width: 640px) {
    .wyldcards-present-mode .wyldcards-toolbar {
        gap: 0.4rem;
    }
    .wyldcards-present-mode .wyldcards-stack-view-title,
    .wyldcards-present-mode .wyldcards-toolbar-cardname {
        display: none;
    }
    .wyldcards-present-navigator {
        min-height: 4.65rem;
        padding: 0.45rem 0.7rem;
    }
    .wyldcards-present-navigator-card {
        flex-basis: 5.5rem;
        min-height: 3.5rem;
    }
}
.wyldcards-toolbar-arrow {
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.25rem;
    margin: 0;
    font: inherit;
    padding: 0.25rem 0.7rem;
    line-height: 1.4;
    text-decoration: none;
}
.wyldcards-jump-history-control:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}
.wyldcards-toolbar-position {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}
.wyldcards-toolbar-cardname {
    color: var(--muted-fg);
    font-style: italic;
}
.wyldcards-toolbar-mode {
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.25rem;
    margin: 0;
    font: inherit;
    padding: 0.3rem 0.9rem;
    text-decoration: none;
}
.wyldcards-toolbar-mode--done {
    background: var(--accent, #2563eb);
    color: var(--accent-contrast, #fff);
    border-color: var(--accent, #2563eb);
}
.wyldcards-practice {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 1rem;
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--accent, #2563eb) 8%, var(--bg));
}
.wyldcards-practice-setup,
.wyldcards-practice-session,
.wyldcards-practice-complete {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.55rem;
}
.wyldcards-practice label {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin: 0;
}
.wyldcards-practice select,
.wyldcards-practice button {
    margin: 0;
    min-height: 2rem;
}
.wyldcards-practice-start,
.wyldcards-practice-next {
    background: var(--accent, #2563eb);
    border-color: var(--accent, #2563eb);
    color: #fff;
}
.wyldcards-practice-end,
.wyldcards-practice-close {
    color: var(--muted-fg);
}
@media (max-width: 640px) {
    .wyldcards-practice,
    .wyldcards-practice-setup,
    .wyldcards-practice-session,
    .wyldcards-practice-complete {
        align-items: stretch;
        flex-direction: column;
    }
    .wyldcards-practice label {
        justify-content: space-between;
    }
}

.wyldcards-backlinks {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin: 0.6rem auto;
    max-width: 76rem;
    padding: 0.45rem 0.75rem;
    color: var(--muted-fg);
    font-size: 0.875rem;
}
.wyldcards-backlinks a {
    display: inline-flex;
    gap: 0.3rem;
    align-items: baseline;
    padding: 0.15rem 0.45rem;
    border: 1px solid var(--border, #cbd5e1);
    border-radius: 999px;
    color: inherit;
    text-decoration: none;
}
.wyldcards-backlinks a:hover {
    border-color: var(--accent, #2563eb);
    color: var(--accent, #2563eb);
}
.wyldcards-backlinks a span:first-child {
    font-variant-numeric: tabular-nums;
}

.wyldcards-editbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 0.7rem;
    padding: 0.45rem 1rem;
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--bg) 88%, var(--accent-bg));
    font-size: 0.9rem;
}
.wyldcards-editbar-group {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.3rem;
    padding-right: 0.7rem;
    border-right: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
    vertical-align: middle;
}
.wyldcards-editbar-group:nth-last-child(2),
.wyldcards-editbar-group--end {
    border-right: 0;
}
.wyldcards-editbar-group--end {
    margin-left: auto;
    padding-right: 0;
}
.wyldcards-save-status {
    min-width: 7.5rem;
    color: var(--muted-fg);
    font-size: 0.8rem;
    text-align: right;
}
.wyldcards-save-status[data-state="saving"],
.wyldcards-save-status[data-state="pending"] {
    color: var(--muted-fg);
}
.wyldcards-save-status[data-state="saved"] {
    color: #15803d;
}
.wyldcards-save-status[data-state="error"] {
    color: #b91c1c;
}
.wyldcards-editbar-label {
    color: var(--muted-fg);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-right: 0.25rem;
}
/* label. to outrank missing.css's `label[for]` padding, which made this row
   taller than its neighbours. */
label.wyldcards-card-name-label {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    margin: 0;
    padding: 0;
}
.wyldcards-card-name {
    width: min(10rem, 24vw);
    min-height: 1.9rem;
    margin: 0;
    padding: 0.2rem 0.5rem;
    font-size: 0.875rem;
}
/* The same button whether it is a <button>, a <summary> or an <a>: only
   <button> gets a border from missing.css, so Data and Archived cards read as
   bare links and the menu triggers as labels. */
.wyldcards-editbar-btn {
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    min-height: 1.9rem;
    margin: 0;
    padding: 0.2rem 0.6rem;
    border: 1px solid color-mix(in srgb, var(--border) 92%, var(--fg));
    border-radius: var(--border-radius, 0.25rem);
    background: var(--bg);
    color: var(--fg);
    font-size: 0.85rem;
    line-height: 1.4;
    text-decoration: none;
    white-space: nowrap;
}
.wyldcards-editbar-btn:hover,
.wyldcards-editbar-btn:focus-visible {
    border-color: var(--accent, #2563eb);
    background: color-mix(in srgb, var(--accent, #2563eb) 9%, var(--bg));
    outline: none;
}
.wyldcards-editbar-btn--danger {
    color: #b91c1c;
}
.wyldcards-toolbar-new-card {
    border-color: var(--accent, #2563eb);
    background: var(--accent, #2563eb);
    color: var(--accent-contrast, #fff);
    font-weight: 700;
}
.wyldcards-toolbar-new-card:hover,
.wyldcards-toolbar-new-card:focus-visible {
    border-color: var(--accent, #2563eb);
    background: color-mix(in srgb, var(--accent, #2563eb) 86%, #000);
    color: var(--accent-contrast, #fff);
}
.wyldcards-add-btn {
    border-color: color-mix(in srgb, var(--accent, #2563eb) 55%, var(--border));
    font-weight: 650;
}
.wyldcards-new-card-trigger {
    border-color: var(--accent, #2563eb);
    background: var(--accent, #2563eb);
    color: var(--accent-contrast, #fff);
    font-weight: 700;
    box-shadow: 0 1px 2px color-mix(in srgb, var(--fg) 18%, transparent);
}
.wyldcards-new-card-trigger:hover,
.wyldcards-new-card-trigger:focus-visible {
    border-color: var(--accent, #2563eb);
    background: color-mix(in srgb, var(--accent, #2563eb) 86%, #000);
    color: var(--accent-contrast, #fff);
}
.wyldcards-new-card-menu > summary.wyldcards-new-card-trigger::after {
    color: currentColor;
}
/* missing.css boxes every <details> — padding, border, background and
   overflow: clip. On these menus that drew a panel around each trigger and
   clipped the open option list to nothing, so Field type, Widget type, Layout,
   Templates and New card opened invisibly. */
.wyldcards-new-card-menu {
    position: relative;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: none;
    overflow: visible;
}
.wyldcards-new-card-menu > summary {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    cursor: pointer;
    list-style: none;
}
.wyldcards-new-card-menu > summary.wyldcards-editbar-btn {
    font-weight: 600;
    user-select: none;
}
.wyldcards-new-card-menu > summary::-webkit-details-marker {
    display: none;
}
.wyldcards-new-card-menu > summary::after {
    content: "▾";
    color: var(--muted-fg);
    font-size: 0.75em;
}
.wyldcards-new-card-options {
    position: absolute;
    z-index: 12;
    top: calc(100% + 0.35rem);
    left: 0;
    width: max-content;
    min-width: 14rem;
    max-height: min(70vh, 34rem);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0.3rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--bg);
    box-shadow: 0 0.6rem 1.5rem color-mix(in srgb, var(--fg) 18%, transparent);
}
.wyldcards-new-card-options button {
    display: grid;
    width: 100%;
    gap: 0.1rem;
    margin: 0;
    padding: 0.5rem 0.6rem;
    border: 0;
    border-radius: 0.3rem;
    background: transparent;
    box-shadow: none;
    color: inherit;
    text-align: left;
    /* missing.css centres button content; menu rows read left to right. */
    justify-content: stretch;
    justify-items: start;
}
.wyldcards-new-card-options button:hover,
.wyldcards-new-card-options button:focus-visible {
    background: color-mix(in srgb, var(--accent, #2563eb) 10%, var(--bg));
    outline: none;
}
.wyldcards-new-card-options span {
    color: var(--muted-fg);
    font-size: 0.8rem;
}
.wyldcards-layout-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin: 0;
    padding: 0.65rem;
    border: 1px solid var(--border);
    border-radius: 0.4rem;
}
.wyldcards-layout-presets legend {
    padding: 0 0.25rem;
    color: var(--muted-fg);
    font-size: 0.85rem;
}
.wyldcards-layout-presets button {
    margin: 0;
    padding: 0.3rem 0.5rem;
    border-color: color-mix(in srgb, var(--border) 88%, var(--fg));
    background: var(--bg);
    font-size: 0.8rem;
}
.wyldcards-layout-presets button:hover,
.wyldcards-layout-presets button:focus-visible {
    border-color: var(--accent, #2563eb);
    background: color-mix(in srgb, var(--accent, #2563eb) 9%, var(--bg));
    outline: none;
}
.wyldcards-editbar-form {
    display: inline-flex;
    margin: 0;
}
.wyldcards-editbar-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    min-height: 2rem;
    margin-left: 0.35rem;
    padding: 0 0.35rem;
    border-radius: 4px;
    color: var(--muted-fg);
    cursor: pointer;
}
.wyldcards-editbar-toggle:has(input:checked) {
    background: color-mix(in srgb, var(--accent, #2563eb) 12%, transparent);
    color: var(--fg);
}

.wyldcards-part-picker {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-block: 12px;
}

.wyldcards-part-picker select {
    width: auto;
    max-width: 100%;
    min-width: 0;
}

.wyldcards-workbench {
    display: grid;
    grid-template-columns: minmax(0, 1fr) clamp(19rem, 27vw, 25rem);
    flex: 1;
    /* missing.css spaces `section + section` 2.8rem apart; after the Links here
       or Linked from strip that took ~90px of height from the card. */
    margin-block: 0;
    /* A floor, so on a short window with the edit bar wrapped and comments
       open the page scrolls rather than squeezing the card to nothing. */
    min-height: min(20rem, 50vh);
    overflow: hidden;
}
/* Browsing renders no inspector; without this its empty column still took a
   quarter of the width beside the card — and on narrow screens, where the
   inspector stacks underneath, an empty row took the bottom of the page. */
.wyldcards-workbench:not(:has(> .wyldcards-side)) {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
}
/* Browsing a card nobody has commented on, the side panel held only a closed
   "Comments · 0 comments" line, yet took a quarter of the width from the card.
   Give that width back; More → Comments opens the panel again. */
.wyldcards-mode-browse .wyldcards-workbench:has(> .wyldcards-side > .wyldcards-card-comments[data-comment-count="0"]:only-child > .wyldcards-card-comments-details:not([open])) {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
}
.wyldcards-mode-browse .wyldcards-side:has(> .wyldcards-card-comments[data-comment-count="0"]:only-child > .wyldcards-card-comments-details:not([open])) {
    display: none;
}
.wyldcards-stage {
    min-height: 0;
    min-width: 0;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 1.5rem;
    overflow: auto;
    background-color: color-mix(in srgb, var(--fg) 3%, var(--bg));
    background-image: radial-gradient(color-mix(in srgb, var(--fg) 14%, transparent) 0.75px, transparent 0.75px);
    background-size: 16px 16px;
    background-repeat: repeat;
}
@media screen {
.device-reflow .wyldcards-card-viewport {
    width: min(100%, var(--device-width)) !important;
    height: auto !important;
}
.device-reflow .wyldcards-card-flip-scene,
.device-reflow .wyldcards-card-flip-inner {
    width: 100% !important;
    height: auto !important;
}
.device-reflow .wyldcards-card {
    position: relative !important;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px;
    box-sizing: border-box;
    width: 100% !important;
    height: auto !important;
    min-height: 240px;
    transform: none !important;
}
.device-reflow .wyldcards-card > .part {
    position: relative !important;
    inset: auto !important;
    width: 100% !important;
    max-width: 100%;
    flex: none;
    order: var(--mobile-order);
    min-height: 44px;
}
.device-preview .part-resize-handle { display: none; }
.device-preview .wyldcards-card { outline: 2px dashed var(--border); }
}
/* Public cards remain script-free, including the adaptive layout. */
@media screen and (max-width: 600px) {
    .public-mobile-layout .wyldcards-card-viewport { width: 100%; height: auto; }
    .public-mobile-layout .wyldcards-card {
        display: flex; flex-direction: column; gap: 12px; padding: 12px;
        box-sizing: border-box; width: 100% !important; height: auto !important; min-height: 240px;
    }
    .public-mobile-layout .wyldcards-card > .part {
        position: relative !important; inset: auto !important; width: 100% !important;
        max-width: 100%; flex: none; order: var(--mobile-order); min-height: 44px;
    }
}
.wyldcards-action-row,
.wyldcards-action-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.wyldcards-action-row { border: 1px solid var(--border); padding: 8px; margin-block: 8px; }
.wyldcards-action-row label { flex: 1 1 100%; }
.wyldcards-action-row input, .wyldcards-action-row select { max-width: 100%; width: 100%; }
.wyldcards-conflict-comparison { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.wyldcards-conflict-comparison pre { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 220px; overflow: auto; }
.wyldcards-card-viewport {
    position: relative;
    flex: none;
    padding: 0.15rem;
}
.wyldcards-stack,
.wyldcards-background {
    display: contents;
}
.wyldcards-card {
    position: relative;
    background: var(--plain-bg, #fff);
    color: var(--fg);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 12px 32px -18px rgba(0, 0, 0, 0.45);
    overflow: hidden;
    flex: none;
    transform-origin: top left;
}
.wyldcards-card-flip-scene {
    position: relative;
    flex: none;
    perspective: 1200px;
}
.wyldcards-card-flip-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.45s ease;
}
.wyldcards-card-flip-scene.is-flipped .wyldcards-card-flip-inner {
    transform: rotateY(180deg);
}
.wyldcards-card-flip-scene[data-card-flip] .wyldcards-card,
.wyldcards-card-back {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}
.wyldcards-card-back {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    padding: 2rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--fg);
    background: color-mix(in srgb, var(--plain-bg, #fff) 92%, var(--accent, #2563eb));
    text-align: center;
    transform: rotateY(180deg);
}
.wyldcards-card-back-label {
    color: var(--muted-fg);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}
body.wyldcards-mode-edit .wyldcards-card-flip-scene,
body.wyldcards-mode-edit .wyldcards-card-flip-inner {
    display: contents;
}
body.wyldcards-mode-edit .wyldcards-card-back {
    display: none;
}
@media (prefers-reduced-motion: reduce) {
    .wyldcards-card-flip-inner { transition: none; }
}
.card-design-presets {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
    gap: 0.75rem;
    margin: 1rem 0;
}
.card-design-preset {
    display: flex;
    align-items: center;
    min-height: 5.25rem;
    padding: 0.8rem;
    border: 1px solid var(--border);
    border-radius: 0.6rem;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}
.card-design-preset:has(input:checked) {
    border-color: var(--accent, #2563eb);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent, #2563eb) 20%, transparent);
}
.card-design-preset:hover { transform: translateY(-2px); }
.card-design-preset input { flex: none; margin: 0 0.65rem 0 0; }
.card-design-preset span { display: grid; gap: 0.2rem; }
.card-design-preset small { color: var(--muted-fg); }
.card-design-preset--paper { background: #fffdf5; color: #473719; border-color: #d6c7a1; border-radius: 2px; }
.card-design-preset--midnight { background: #172033; color: #e2e8f0; border-color: #43516b; border-radius: 0.8rem; }
.card-design-preset--midnight small { color: #bac7dc; }
.card-design-preset--postcard { background: linear-gradient(135deg, #fff8e7, #f4ebd5); color: #692e1d; border: 2px solid #d16b4a; }
.card-design-css { margin-top: 1rem; }
:root.-dark-theme .wyldcards-card {
    background: #1a2333;
}

/* ---- Storyboard ----------------------------------------------------- */
.wyldcards-storyboard-page {
    max-width: 76rem;
    padding: 1.5rem;
}
.wyldcards-storyboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.wyldcards-storyboard-header h1,
.wyldcards-storyboard-header p {
    margin: 0;
}
.wyldcards-storyboard-header p {
    margin-top: 0.25rem;
}
.wyldcards-storyboard-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}
.wyldcards-storyboard-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
    margin-bottom: 1.25rem;
}
.wyldcards-storyboard-search {
    flex: 1 1 14rem;
    max-width: 22rem;
    margin: 0;
}
/* missing.css right-aligns placeholders; the hint belongs where typing starts. */
input.wyldcards-storyboard-search::placeholder {
    text-align: left;
}
.wyldcards-storyboard-show {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    font-size: 0.9rem;
}
.wyldcards-storyboard-show select {
    margin: 0;
    max-width: 14rem;
}
.wyldcards-storyboard-size {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--bg);
}
.wyldcards-storyboard-size button {
    min-width: 2rem;
    margin: 0;
    padding: 0.25rem 0.5rem;
    border: 0;
    border-radius: 0.35rem;
    background: transparent;
    color: var(--muted-fg, inherit);
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.2;
}
.wyldcards-storyboard-size button[aria-pressed="true"] {
    background: var(--accent-bg, rgba(37, 99, 235, 0.15));
    color: var(--fg, inherit);
}
.wyldcards-storyboard-grid {
    --storyboard-zoom: 1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, calc(220px * var(--storyboard-zoom))), 1fr));
    gap: 1.25rem;
}
.wyldcards-storyboard-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    min-width: 0;
    padding: 0.85rem;
    border: 1px solid var(--border);
    border-radius: 0.65rem;
    background: color-mix(in srgb, var(--bg) 92%, var(--accent-bg));
    color: inherit;
    text-decoration: none;
}
.wyldcards-storyboard-card:hover,
.wyldcards-storyboard-card:focus-visible,
.wyldcards-storyboard-card:has(> a.wyldcards-storyboard-caption:focus-visible) {
    border-color: var(--accent, #2563eb);
    box-shadow: 0 10px 24px -18px rgba(0, 0, 0, 0.55);
    outline: none;
}
.wyldcards-storyboard-thumbnail {
    position: relative;
    overflow: hidden;
    max-width: 100%;
    border-radius: 4px;
    pointer-events: none;
}
.wyldcards-storyboard-grid .wyldcards-storyboard-thumbnail {
    width: min(100%, calc(var(--storyboard-thumb-width, 280px) * var(--storyboard-zoom)));
}
.wyldcards-storyboard-card[hidden] {
    display: none;
}
.wyldcards-storyboard-card.is-current {
    border-color: var(--accent, #2563eb);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent, #2563eb) 35%, transparent);
}
/* Straddle the tile's top edge so the labels never cover the card itself. */
.wyldcards-storyboard-badges {
    position: absolute;
    top: -0.6rem;
    right: 0.6rem;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    pointer-events: none;
}
.wyldcards-storyboard-badges:empty {
    display: none;
}
.wyldcards-storyboard-badge {
    padding: 0.05rem 0.45rem;
    border-radius: 999px;
    border: 1px solid color-mix(in srgb, var(--bg) 40%, #f59e0b);
    background: color-mix(in srgb, var(--bg) 70%, #f59e0b);
    color: var(--fg, inherit);
    font-size: 0.7rem;
    font-weight: 600;
    line-height: 1.5;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}
.wyldcards-storyboard-badge--current {
    border-color: var(--accent, #2563eb);
    background: var(--accent, #2563eb);
    color: var(--bg, #fff);
}
.wyldcards-storyboard-empty {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin: 1rem 0 0;
    color: var(--muted-fg, inherit);
}
.wyldcards-storyboard-editing .wyldcards-storyboard-thumbnail {
    pointer-events: auto;
}
.wyldcards-storyboard-canvas {
    position: absolute;
    top: 0;
    left: 0;
    max-width: none;
    transform: scale(var(--storyboard-scale));
    transform-origin: top left;
}
.wyldcards-storyboard-canvas .part-name-tag,
.wyldcards-storyboard-canvas .part-handle {
    display: none;
}
.wyldcards-storyboard-caption {
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.9rem;
}
a.wyldcards-storyboard-caption {
    color: inherit;
    text-decoration: none;
    outline: none;
}
/* The caption link covers the whole card so the thumbnail opens it too. */
a.wyldcards-storyboard-caption::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
}
.wyldcards-storyboard-card--edit {
    text-decoration: none;
}
.wyldcards-storyboard-card[data-storyboard-card] {
    touch-action: pan-y;
    cursor: grab;
}
.wyldcards-storyboard-card[data-storyboard-card]:active {
    cursor: grabbing;
}
.wyldcards-storyboard-card--edit.is-dragging {
    opacity: 0.35;
}
.wyldcards-storyboard-card--edit.is-drop-target {
    border-color: var(--accent, #2563eb);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent, #2563eb) 22%, transparent);
}
.wyldcards-storyboard-card-drag-preview {
    position: fixed;
    z-index: 1000;
    margin: 0;
    pointer-events: none;
    transform: translate3d(0, 0, 0);
    box-shadow: 0 18px 38px -18px rgba(0, 0, 0, 0.65);
}
.wyldcards-storyboard-name {
    width: calc(100% - 2rem);
    min-width: 0;
    border: 0;
    border-bottom: 1px solid transparent;
    border-radius: 0;
    padding: 0;
    background: transparent;
    color: inherit;
    font: inherit;
}
.wyldcards-storyboard-name:focus {
    border-bottom-color: var(--accent, #2563eb);
    outline: none;
}
.wyldcards-storyboard-open {
    align-self: flex-start;
    font-size: 0.8rem;
}
.wyldcards-storyboard-reorder-hint,
.wyldcards-storyboard-reorder-status {
    margin: 1rem 0 0;
}
.wyldcards-storyboard-reorder-status {
    min-height: 1.5em;
}
/* ---- Canvas --------------------------------------------------------- */
.wyldcards-canvas-page { max-width: none; padding: clamp(0.85rem, 2vw, 1.5rem); }
.wyldcards-canvas-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.wyldcards-canvas-header h1, .wyldcards-canvas-header p { margin: 0; }
.wyldcards-canvas-header p { margin-top: 0.25rem; }
.wyldcards-canvas-actions, .wyldcards-canvas-zoom { display: inline-flex; align-items: center; gap: 0.5rem; }
.wyldcards-canvas-zoom { padding: 0.2rem; border: 1px solid var(--border); border-radius: 0.5rem; background: var(--bg); }
.wyldcards-canvas-zoom .wyldcards-list-action-btn { min-width: 2rem; padding: 0.3rem 0.55rem; font-size: 1.1rem; line-height: 1; }
.wyldcards-canvas-zoom output { min-width: 3.25rem; color: var(--muted-fg); font-size: 0.8rem; font-variant-numeric: tabular-nums; text-align: center; }
.wyldcards-canvas-viewport { position: relative; height: min(72vh, 52rem); min-height: 26rem; overflow: hidden; border: 1px solid var(--border); border-radius: 0.9rem; background-color: color-mix(in srgb, var(--bg) 94%, var(--accent-bg)); background-image: radial-gradient(color-mix(in srgb, var(--border) 65%, transparent) 1px, transparent 1px); background-size: 20px 20px; touch-action: none; cursor: grab; }
.wyldcards-canvas-viewport:active { cursor: grabbing; }
.wyldcards-canvas-viewport:focus-visible { outline: 2px solid var(--accent, #2563eb); outline-offset: 2px; }
.wyldcards-canvas-board { position: absolute; inset: 0; min-width: 100%; min-height: 100%; transform-origin: 0 0; will-change: transform; }
.wyldcards-canvas-card { position: absolute; display: flex; flex-direction: column; gap: 0.45rem; width: 280px; padding: 0.65rem; border: 1px solid var(--border); border-radius: 0.6rem; background: var(--bg); color: inherit; text-decoration: none; box-shadow: 0 10px 24px -18px rgba(0, 0, 0, 0.85); touch-action: none; transition: border-color 120ms ease, box-shadow 120ms ease; }
.wyldcards-canvas-card:hover, .wyldcards-canvas-card:has(:focus-visible) { border-color: var(--accent, #2563eb); outline: none; box-shadow: 0 16px 30px -20px rgba(0, 0, 0, 0.9); }
.wyldcards-canvas-viewport[data-card-canvas='editable'] .wyldcards-canvas-card { cursor: grab; }
.wyldcards-canvas-card--dragging { border-color: var(--accent, #2563eb); box-shadow: 0 24px 40px -22px rgba(0, 0, 0, 0.9); }
.wyldcards-canvas-viewport .wyldcards-canvas-card--dragging .wyldcards-canvas-caption { cursor: grabbing; }
.wyldcards-canvas-thumbnail { position: relative; overflow: hidden; width: 100%; max-width: 100%; border-radius: 4px; pointer-events: none; }
.wyldcards-canvas-find { width: 12rem; max-width: 100%; margin: 0; }
/* missing.css right-aligns placeholders; the hint belongs where typing starts. */
input.wyldcards-canvas-find::placeholder { text-align: left; }
.wyldcards-canvas-card--current { border-color: var(--accent, #2563eb); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent, #2563eb) 35%, transparent), 0 10px 24px -18px rgba(0, 0, 0, 0.85); }
.wyldcards-canvas-card--dimmed { opacity: 0.3; }
.wyldcards-canvas-card--found { border-color: var(--accent, #2563eb); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent, #2563eb) 45%, transparent), 0 16px 30px -20px rgba(0, 0, 0, 0.9); }
.wyldcards-canvas-card { transition: border-color 120ms ease, box-shadow 120ms ease, opacity 160ms ease; }
.wyldcards-canvas-viewport--flying .wyldcards-canvas-board { transition: transform 320ms ease; }
.wyldcards-canvas-viewport--flying { transition: background-size 320ms ease, background-position 320ms ease; }
.wyldcards-canvas-viewport--flying .wyldcards-canvas-card { transition: left 320ms ease, top 320ms ease, opacity 160ms ease; }
@media (prefers-reduced-motion: reduce) {
    .wyldcards-canvas-viewport--flying, .wyldcards-canvas-viewport--flying .wyldcards-canvas-board, .wyldcards-canvas-viewport--flying .wyldcards-canvas-card { transition: none; }
}
.wyldcards-canvas-caption { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.9rem; color: inherit; text-decoration: none; outline: none; }
/* The caption link covers the whole card so the thumbnail opens it too. */
.wyldcards-canvas-caption::after { content: ''; position: absolute; inset: 0; border-radius: inherit; }
.wyldcards-canvas-viewport[data-card-canvas='editable'] .wyldcards-canvas-caption { cursor: grab; }
.wyldcards-canvas-status { min-height: 1.5em; margin: 0.75rem 0 0; }
.wyldcards-canvas-status--error { color: var(--error, #b91c1c); }
@media (max-width: 42rem) {
    .wyldcards-canvas-header { align-items: flex-start; flex-direction: column; }
    .wyldcards-canvas-actions { width: 100%; flex-wrap: wrap; }
    .wyldcards-canvas-viewport { height: 66vh; min-height: 22rem; }
    .wyldcards-canvas-find { flex: 1 1 100%; width: auto; }
}
/* These page headings are <header> elements, and missing.css gives every
   header a ~45px top margin: a band of empty space above the title that the
   other pages, whose headings are divs, do not have. */
.wyldcards-outline-header,
.wyldcards-storyboard-header,
.wyldcards-link-map-header,
.wyldcards-canvas-header {
    margin-top: 0;
}

/* ---- Outline -------------------------------------------------------- */
.wyldcards-outline-page {
    max-width: 62rem;
    padding: 1.5rem;
}
.wyldcards-outline-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.wyldcards-outline-header h1,
.wyldcards-outline-header p {
    margin: 0;
}
.wyldcards-outline-header p { margin-top: 0.25rem; }
/* The heading keeps a literal space between icon and name (the phone app bar
   reads it as the title), so the icon's own min-width and margin only widened
   the gap. */
.wyldcards-outline-header h1 .stack-icon {
    min-width: 0;
    margin-right: 0;
}
.wyldcards-outline-actions {
    display: inline-flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: 0.5rem;
}
.wyldcards-outline-list {
    display: grid;
    gap: 0.75rem;
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: outline-card;
}
.wyldcards-outline-card {
    counter-increment: outline-card;
    padding: 0.9rem 1rem 1rem;
    border-left: 2px solid color-mix(in srgb, var(--accent, #2563eb) 40%, var(--border));
    background: color-mix(in srgb, var(--bg) 94%, var(--accent-bg));
}
.wyldcards-outline-title {
    display: flex;
    align-items: baseline;
    gap: 0.65rem;
    color: inherit;
    font-weight: 700;
    text-decoration: none;
}
.wyldcards-outline-title:hover,
.wyldcards-outline-title:focus-visible { color: var(--accent, #2563eb); }
.wyldcards-outline-title--edit {
    align-items: center;
}
.wyldcards-outline-number {
    flex: none;
    min-width: 1.65rem;
    color: var(--muted);
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
    text-align: right;
}
.wyldcards-outline-name,
.wyldcards-outline-field {
    width: 100%;
    min-width: 0;
    margin: 0;
    border: 1px solid var(--border);
    border-radius: 0.3rem;
    background: var(--bg);
    color: inherit;
    font: inherit;
}
.wyldcards-outline-name {
    padding: 0.25rem 0.4rem;
    font-weight: 700;
}
.wyldcards-outline-open {
    flex: none;
    color: var(--muted-fg, var(--muted));
    font-size: 0.8rem;
    font-weight: 400;
}
.wyldcards-outline-fields {
    display: grid;
    gap: 0.35rem;
    margin: 0.6rem 0 0 2.3rem;
    padding-left: 1.1rem;
    color: var(--muted-fg, var(--muted));
}
/* Line breaks belong to the field's text only. Set on the list, pre-line also
   kept the template's own indentation and newlines between tags, so every
   field opened with an empty bullet line and its text sat on the lines below. */
.wyldcards-outline-fields > li > span {
    white-space: pre-line;
}
.wyldcards-outline-checklist {
    color: var(--fg);
    line-height: 1.55;
}
.wyldcards-outline-fields > li::marker {
    color: color-mix(in srgb, var(--muted-fg, #64748b) 60%, transparent);
}
.wyldcards-outline-editing .wyldcards-outline-fields {
    padding-left: 0;
    list-style: none;
}
.wyldcards-outline-editing .wyldcards-outline-fields li + li {
    margin-top: 0.35rem;
}
.wyldcards-outline-field {
    display: block;
    min-height: 2.25rem;
    padding: 0.35rem 0.45rem;
    overflow: hidden;
    resize: none;
    line-height: 1.45;
}
.wyldcards-outline-field-label {
    display: block;
    margin: 0 0 0.15rem;
    color: var(--muted-fg, var(--muted));
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}
.wyldcards-outline-card--current {
    border-left-color: var(--accent, #2563eb);
    box-shadow: inset 3px 0 0 var(--accent, #2563eb);
    background: color-mix(in srgb, var(--bg) 86%, var(--accent-bg));
}
.wyldcards-outline-list--titles {
    gap: 0.35rem;
}
.wyldcards-outline-list--titles .wyldcards-outline-card {
    padding-block: 0.45rem;
}
.wyldcards-outline-list--titles .wyldcards-outline-fields {
    display: none;
}
.wyldcards-outline-grip {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    min-height: 1.9rem;
    margin: 0;
    padding: 0 0.2rem;
    border: 0;
    border-radius: 0.3rem;
    background: transparent;
    color: var(--muted);
    cursor: grab;
    touch-action: none;
}
.wyldcards-outline-grip::before {
    content: '⋮⋮';
    margin-right: 0.2rem;
    font-size: 0.7rem;
    letter-spacing: -0.15em;
    opacity: 0.55;
}
.wyldcards-outline-grip:hover,
.wyldcards-outline-grip:focus-visible {
    background: color-mix(in srgb, var(--accent, #2563eb) 12%, transparent);
    color: var(--fg, inherit);
}
.wyldcards-outline-card--dragging {
    opacity: 0.85;
    box-shadow: 0 12px 28px -18px rgba(0, 0, 0, 0.6), inset 3px 0 0 var(--accent, #2563eb);
}
.wyldcards-outline-card--dragging .wyldcards-outline-grip {
    cursor: grabbing;
}
.wyldcards-outline-status {
    min-height: 1.4em;
    margin: -0.9rem 0 0.5rem;
    color: var(--muted-fg, var(--muted));
    font-size: 0.85rem;
}
.wyldcards-outline-status--error {
    color: var(--error, #b91c1c);
}
.wyldcards-outline-hint {
    margin: 1rem 0 0;
    font-size: 0.85rem;
}
.wyldcards-link-map-page {
    max-width: 76rem;
    padding: 1.5rem;
}
.wyldcards-link-map-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.wyldcards-link-map-header h1,
.wyldcards-link-map-header p {
    margin: 0;
}
.wyldcards-link-map-header p {
    margin-top: 0.25rem;
}
.wyldcards-link-map-connections,
.wyldcards-link-map-unconnected {
    margin-top: 1.5rem;
}
.wyldcards-link-map-list {
    display: grid;
    gap: 0.55rem;
    padding-left: 1.5rem;
}
.wyldcards-link-map-list li {
    padding: 0.7rem;
    border: 1px solid var(--border);
    border-radius: 0.45rem;
    background: color-mix(in srgb, var(--bg) 92%, var(--accent-bg));
}
.wyldcards-link-map-arrow {
    margin: 0 0.35rem;
}
.wyldcards-link-map-detail {
    display: block;
    margin-top: 0.3rem;
    color: var(--muted);
    font-size: 0.9rem;
}
/* Connection kinds share one colour everywhere: filters, list swatches, lines and arrowheads. */
.wyldcards-link-map-page {
    --map-button: #2563eb;
    --map-route: #c2410c;
    --map-field: #0f766e;
    --map-related: #7c3aed;
}
@media (prefers-color-scheme: dark) {
    :root:not(.-no-dark-theme) .wyldcards-link-map-page {
        --map-button: #60a5fa;
        --map-route: #fb923c;
        --map-field: #2dd4bf;
        --map-related: #c4b5fd;
    }
}
.wyldcards-link-map-kind--button { --map-kind: var(--map-button); }
.wyldcards-link-map-kind--route { --map-kind: var(--map-route); }
.wyldcards-link-map-kind--field { --map-kind: var(--map-field); }
.wyldcards-link-map-kind--related { --map-kind: var(--map-related); }
.wyldcards-link-map-count {
    display: inline-block;
    min-width: 1.6em;
    margin-left: 0.35rem;
    padding: 0 0.4rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--fg, #111) 8%, transparent);
    color: var(--muted-fg, var(--muted));
    font-size: 0.75em;
    font-weight: 600;
    text-align: center;
    vertical-align: middle;
}
.wyldcards-link-map-broken {
    margin-top: 1.5rem;
    padding: 0.9rem 1rem;
    border: 1px solid color-mix(in srgb, #d97706 55%, var(--border));
    border-radius: 0.6rem;
    background: color-mix(in srgb, var(--bg) 88%, #f59e0b);
}
.wyldcards-link-map-broken h2 { margin-top: 0; }
.wyldcards-link-map-broken .wyldcards-link-map-list { padding-left: 0; list-style: none; }
.wyldcards-link-map-broken .wyldcards-link-map-list li { background: var(--bg); }
.wyldcards-link-map-diagram { margin-top: 1.5rem; }
.wyldcards-link-map-diagram-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
}
.wyldcards-link-map-diagram-header h2 { margin: 0; }
.wyldcards-link-map-kinds {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.9rem;
    margin: 0;
    padding: 0;
    border: 0;
}
.wyldcards-link-map-kinds legend {
    float: left;
    margin-right: 0.25rem;
    padding: 0;
    color: var(--muted-fg, var(--muted));
    font-size: 0.85rem;
}
.wyldcards-link-map-kind {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin: 0;
    font-size: 0.85rem;
    cursor: pointer;
}
.wyldcards-link-map-kind input { margin: 0; }
.wyldcards-link-map-swatch {
    display: inline-block;
    width: 0.9rem;
    height: 0.2rem;
    margin-right: 0.35rem;
    border-radius: 2px;
    background: var(--map-kind, var(--muted));
    vertical-align: middle;
}
.wyldcards-link-map-kind--related .wyldcards-link-map-swatch,
.wyldcards-link-map-swatch.wyldcards-link-map-kind--related {
    background: repeating-linear-gradient(90deg, var(--map-related) 0 3px, transparent 3px 5px);
}
.wyldcards-link-map-summary { margin: 0.75rem 0 0; }
.wyldcards-link-map-tip { margin: 0.35rem 0 0.6rem; font-size: 0.85rem; }
.wyldcards-link-map-scroll {
    overflow: auto;
    max-height: 70vh;
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    background-color: color-mix(in srgb, var(--bg) 95%, var(--accent-bg));
    background-image: radial-gradient(color-mix(in srgb, var(--border) 60%, transparent) 1px, transparent 1px);
    background-size: 20px 20px;
}
.wyldcards-link-map-svg { display: block; max-width: none; }
.wyldcards-link-map-edge {
    fill: none;
    stroke: var(--map-button);
    stroke-width: 2;
    opacity: 0.7;
    transition: opacity 120ms ease, stroke-width 120ms ease;
}
.wyldcards-link-map-edge--route { stroke: var(--map-route); stroke-dasharray: 7 4; }
.wyldcards-link-map-edge--field { stroke: var(--map-field); }
.wyldcards-link-map-edge--related { stroke: var(--map-related); stroke-dasharray: 2 4; stroke-linecap: round; }
.wyldcards-link-map-arrowhead--button { fill: var(--map-button); }
.wyldcards-link-map-arrowhead--route { fill: var(--map-route); }
.wyldcards-link-map-arrowhead--field { fill: var(--map-field); }
.wyldcards-link-map-edge.is-filtered { display: none; }
.wyldcards-link-map-svg.is-highlighting .wyldcards-link-map-edge { opacity: 0.12; }
.wyldcards-link-map-svg.is-highlighting .wyldcards-link-map-edge.is-active { opacity: 1; stroke-width: 3; }
.wyldcards-link-map-node,
.wyldcards-link-map-node:hover,
.wyldcards-link-map-node:focus { cursor: pointer; outline: none; text-decoration: none; }
.wyldcards-link-map-node rect {
    fill: var(--bg, #fff);
    stroke: var(--border, #cbd5e1);
    stroke-width: 1.5;
    transition: stroke 120ms ease, opacity 120ms ease;
}
.wyldcards-link-map-node text { fill: var(--fg, #111); font-size: 13px; text-decoration: none; pointer-events: none; }
.wyldcards-link-map-node .wyldcards-link-map-node-number { fill: var(--muted-fg, #64748b); font-size: 12px; font-variant-numeric: tabular-nums; }
.wyldcards-link-map-node .wyldcards-link-map-node-name { font-weight: 600; }
.wyldcards-link-map-node .wyldcards-link-map-node-counts { fill: var(--muted-fg, #64748b); font-size: 11px; }
.wyldcards-link-map-node--current rect { stroke: var(--accent, #2563eb); stroke-width: 3; }
.wyldcards-link-map-node:hover rect,
.wyldcards-link-map-node:focus-visible rect,
.wyldcards-link-map-node.is-active rect { stroke: var(--accent, #2563eb); stroke-width: 3; }
.wyldcards-link-map-node:focus-visible rect { stroke-dasharray: 5 3; }
.wyldcards-link-map-svg.is-highlighting .wyldcards-link-map-node:not(.is-active):not(.is-related) { opacity: 0.4; }
.wyldcards-link-map-groups {
    display: grid;
    gap: 0.9rem;
    padding-left: 0;
    list-style: none;
}
.wyldcards-link-map-group > a { color: inherit; text-decoration: none; }
.wyldcards-link-map-group > a:hover strong,
.wyldcards-link-map-group > a:focus-visible strong { color: var(--accent, #2563eb); }
.wyldcards-link-map-group .wyldcards-link-map-list {
    gap: 0;
    margin: 0.35rem 0 0;
    padding-left: 0;
    list-style: none;
    border: 1px solid var(--border);
    border-radius: 0.45rem;
    background: color-mix(in srgb, var(--bg) 92%, var(--accent-bg));
}
.wyldcards-link-map-group .wyldcards-link-map-list li {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.15rem 0.75rem;
    padding: 0.45rem 0.7rem;
    border: 0;
    border-radius: 0;
    background: transparent;
}
.wyldcards-link-map-group .wyldcards-link-map-list li + li { border-top: 1px solid var(--border); }
.wyldcards-link-map-group .wyldcards-link-map-arrow { margin: 0; }
.wyldcards-link-map-group .wyldcards-link-map-detail { margin: 0 0 0 auto; }
.wyldcards-link-map-group--current > a strong { color: var(--accent, #2563eb); }
.wyldcards-link-map-group--current .wyldcards-link-map-list { border-color: color-mix(in srgb, var(--accent, #2563eb) 55%, var(--border)); }
@media (prefers-reduced-motion: reduce) {
    .wyldcards-link-map-edge, .wyldcards-link-map-node rect { transition: none; }
}
@media (max-width: 640px) {
    .wyldcards-link-map-page { padding: 1rem; }
    .wyldcards-link-map-header { align-items: flex-start; }
    .wyldcards-link-map-scroll { max-height: 60vh; }
}
.wyldcards-storyboard-card--edit .part-handle {
    display: block;
}
@media (max-width: 640px) {
    .wyldcards-storyboard-page {
        padding: 1rem;
    }
    .wyldcards-canvas-page { padding: 1rem; }
    .wyldcards-canvas-header { align-items: flex-start; }
    .wyldcards-canvas-viewport { height: 65vh; }
    .wyldcards-storyboard-header {
        align-items: flex-start;
    }
    .wyldcards-storyboard-grid {
        grid-template-columns: repeat(auto-fill, minmax(min(100%, calc(150px * var(--storyboard-zoom))), 1fr));
        gap: 0.75rem;
    }
    .wyldcards-storyboard-card {
        padding: 0.6rem;
    }
    .wyldcards-storyboard-search {
        max-width: none;
    }
    .wyldcards-outline-page { padding: 1rem; }
    .wyldcards-outline-header { align-items: flex-start; flex-direction: column; }
    .wyldcards-outline-actions { justify-content: flex-start; }
    .wyldcards-outline-fields { margin-left: 0.5rem; }
}

/* ---- Parts ---------------------------------------------------------- */
.part {
    position: absolute;
    box-sizing: border-box;
    display: flex;
    align-items: stretch;
    min-width: 8px;
    min-height: 8px;
}
.part[hidden] {
    display: none;
}
.part-control {
    flex: 1;
    min-width: 0;
    min-height: 0;
    box-sizing: border-box;
    font: inherit;
    color: inherit;
}
.part-field .part-input {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0.3rem 0.5rem;
    border: var(--part-field-border, 1px solid var(--border));
    border-radius: 4px;
    background: color-mix(in srgb, var(--plain-bg, #fff) 70%, transparent);
    resize: none;
    font-size: inherit;
    text-align: inherit;
}
.part-field textarea.part-input,
.part-static-text-multiline {
    line-height: 1.4;
}
/* A locked text field in Browse: text, laid out as its input or textarea would be. */
.part-static-text {
    overflow: hidden;
    overflow-wrap: anywhere;
}
.part-static-text-plain {
    display: grid;
    align-content: center;
    white-space: pre;
}
.part-static-text-multiline {
    white-space: pre-wrap;
    overflow-y: auto;
}
.part-field-multiline:has(textarea[data-auto-expand]) {
    overflow: visible;
}
.part-field-multiline textarea[data-auto-expand] {
    flex: none;
    min-height: 100%;
    overflow-y: hidden;
}
.part-rich-text {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: var(--part-field-border, 1px solid var(--border));
    border-radius: 4px;
    background: color-mix(in srgb, var(--plain-bg, #fff) 70%, transparent);
}
.part-rich-text-toolbar {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.2rem;
    padding: 0.2rem;
    border-bottom: 1px solid var(--border);
}
.part-rich-text-toolbar button {
    min-width: 2rem;
    margin: 0;
    padding: 0.1rem 0.3rem;
    font-size: 0.8em;
}
.part-rich-text-toolbar select {
    width: auto;
    min-width: 6.75rem;
    margin: 0;
    padding: 0.1rem 0.25rem;
    font-size: 0.8em;
}
.part-rich-text-alignment {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    padding-inline: 0.2rem;
    border-inline: 1px solid var(--border);
}
.part-rich-text-toolbar input[type="color"] {
    width: 2rem;
    min-width: 2rem;
    height: 1.65rem;
    margin: 0;
    padding: 0.1rem;
    cursor: pointer;
}
.part-rich-text-editor {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 0.3rem 0.5rem;
    outline: none;
    white-space: pre-wrap;
}
.part-rich-text-editor > :first-child { margin-top: 0; }
.part-rich-text-editor > :last-child { margin-bottom: 0; }
.part-locked .part-rich-text { border-style: dotted; background: transparent; }
.part-locked .part-input {
    border-style: dotted;
    background: transparent;
}
.part-hyperlink {
    display: block;
    width: 100%;
    height: 100%;
    padding: 0.3rem 0.5rem;
    overflow-wrap: anywhere;
    color: var(--accent, #2563eb);
    text-decoration: underline;
}
.part-hyperlink-invalid {
    color: var(--muted-fg, #64748b);
    text-decoration: none;
}
.part-checkbox {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0 0.25rem;
    cursor: pointer;
    user-select: none;
}
.part-checkbox input {
    width: 1.1em;
    height: 1.1em;
    margin: 0;
}
/* A list field: the items scroll inside the part's rect; the add row, when
   the field is not locked, stays pinned at the foot. */
.part-list {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    min-height: 0;
    padding: 0;
    border: var(--part-field-border, 1px solid var(--border));
    border-radius: 4px;
    background: color-mix(in srgb, var(--plain-bg, #fff) 70%, transparent);
    text-align: inherit;
    overflow: hidden;
    position: relative;
}
.part-list:focus-visible {
    outline: 2px solid var(--accent, #2563eb);
    outline-offset: 1px;
}
.part-locked .part-list {
    border-style: dotted;
    background: transparent;
}
.part-list .part-list-items {
    /* Size to the rows so the add field follows the last item; shrink to
       scroll when the list fills the available height. */
    flex: 0 1 auto;
    min-height: 0;
    margin: 0;
    padding: 0.2rem 0;
    list-style: none;
    overflow: auto;
    width: 100%;
}
/* missing.css styles [role="listbox"] [role="option"] with negative inline
   margins; the container-scoped selectors here outrank it. */
.part-list .part-list-item {
    display: flex;
    width: 100%;
    min-width: 0;
    align-items: baseline;
    gap: 0.4rem;
    margin: 0;
    padding: 0.2rem 0.5rem;
    border-radius: 0;
    line-height: 1.4;
    cursor: pointer;
    user-select: none;
}
.part-list .part-list-item:hover {
    background: color-mix(in srgb, var(--fg) 7%, transparent);
}
.part-list .part-list-item.is-dragging {
    opacity: 0.5;
    background: color-mix(in srgb, var(--accent, #2563eb) 12%, transparent);
}
/* The drag handle. touch-action belongs here and not on the row, or the list
   stops scrolling under a finger. */
.part-list .part-list-grip {
    flex: none;
    width: 1em;
    text-align: center;
    align-self: center;
    opacity: 0;
    line-height: 1;
    cursor: grab;
    touch-action: none;
    user-select: none;
    color: var(--muted-fg);
}
.part-list .part-list-item:hover .part-list-grip,
.part-list .part-list-item:focus-within .part-list-grip,
.part-list .part-list-item.is-dragging .part-list-grip {
    opacity: 0.6;
}
/* A picked line paints itself with the accent; the grip has to read on it. */
.part-list .part-list-item[aria-selected="true"] .part-list-grip {
    color: inherit;
}
.part-list .part-list-grip:active {
    cursor: grabbing;
}
/* The page background as text: white on the light theme's blue, near-black
   on the dark theme's pale one. */
.part-list .part-list-item[aria-selected="true"] {
    background: var(--accent, #2563eb);
    color: var(--bg, #fff);
}
.part-list-text {
    flex: 1;
    min-width: 0;
    overflow-wrap: anywhere;
}
/* HyperCard's dontWrap: one visual line per item, the rest clipped. */
.part-list-nowrap .part-list-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.part-list-remove,
.part-checklist .part-checklist-remove {
    flex: none;
    width: 1.4em;
    height: 1.4em;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 3px;
    background: transparent;
    color: inherit;
    font: inherit;
    line-height: 1;
    opacity: 0;
    cursor: pointer;
}
.part-list .part-list-item:hover .part-list-remove,
.part-list .part-list-item:focus-within .part-list-remove,
.part-checklist .part-checklist-item:hover .part-checklist-remove,
.part-checklist .part-checklist-item:focus-within .part-checklist-remove,
.part-list-remove:focus-visible,
.part-checklist .part-checklist-remove:focus-visible {
    opacity: 0.7;
}
.part-list-remove:hover,
.part-checklist .part-checklist-remove:hover {
    opacity: 1;
    background: color-mix(in srgb, currentColor 15%, transparent);
}
/* An item's text, open for editing. It stays the same span in the same slot —
   only the frame around it says so — so the line does not jump as it opens.
   The item and the checklist's label both set user-select: none for their
   click behaviour; text being edited has to be selectable again, and a list
   field's dontWrap has to let go so the whole line can be read while it is
   typed. A picked list item paints itself in the accent colour, so the box
   restates the page's own colours rather than inheriting them. */
.part-list-text.is-editing,
.part-checklist .part-checklist-text.is-editing {
    user-select: text;
    -webkit-user-select: text;
    cursor: text;
    overflow: visible;
    text-overflow: clip;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    margin: -2px -4px;
    padding: 2px 4px;
    border-radius: 3px;
    background: var(--plain-bg, #fff);
    color: var(--fg);
    outline: 2px solid var(--accent, #2563eb);
    outline-offset: 0;
}
/* Struck-through text is hard to read and pointless while it is being typed. */
.part-checklist .part-checklist-check:checked ~ .part-checklist-text.is-editing {
    text-decoration: none;
    opacity: 1;
}
.part-list .part-list-add-form,
.part-checklist .part-list-add-form {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex: none;
    margin: 0;
    padding: 0.2rem 0.5rem;
    border: 0;
    line-height: 1.4;
    transition: background-color 120ms ease;
}
.part-checklist .part-list-add-form {
    /* Skip the grip column; the plus occupies the checkbox column. */
    padding-left: calc(0.5rem + 1em + 0.4rem);
}
.part-list-add-icon {
    flex: 0 0 1em;
    text-align: center;
    color: var(--muted-fg);
    line-height: 1;
    pointer-events: none;
}
.part-checklist .part-list-add-icon {
    flex-basis: 1.1em;
}
.part-list input.part-list-add,
.part-checklist input.part-list-add {
    display: block;
    flex: 1;
    width: 0;
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    font: inherit;
    line-height: inherit;
    text-align: left;
    color: inherit;
    box-shadow: none;
}
/* missing.css sets `::placeholder { text-align: end }` through an :is() list
   of input types, which parks the hint at the right-hand edge. An add row
   reads as the next line of the list, so the prompt belongs at the left; the
   element-plus-class selector matches that rule's specificity and wins on
   order, the same way .wyldcards-list-search does above. */
input.part-list-add::placeholder {
    text-align: left;
    color: var(--muted-fg);
    opacity: 1;
}
.part-list input.part-list-add:focus,
.part-checklist input.part-list-add:focus {
    outline: none;
}
.part-list .part-list-add-form:hover,
.part-checklist .part-list-add-form:hover {
    background: color-mix(in srgb, var(--fg) 4%, transparent);
}
.part-list .part-list-add-form:focus-within,
.part-checklist .part-list-add-form:focus-within {
    background: color-mix(in srgb, var(--accent, #2563eb) 8%, transparent);
    box-shadow: inset 2px 0 var(--accent, #2563eb);
}
.part-list-add-form:focus-within .part-list-add-icon {
    color: var(--accent, #2563eb);
}
.part-list-empty {
    position: absolute;
    inset: 0.3rem 0.5rem auto;
    color: var(--muted-fg);
    pointer-events: none;
}
.part-saved .part-list,
.part-saved .part-checklist {
    box-shadow: 0 0 0 2px color-mix(in srgb, #16a34a 50%, transparent);
    transition: box-shadow 0.3s;
}
/* A checklist field: the list field's frame, with a real checkbox on every
   item. Every item-level rule is scoped under .part-checklist — missing.css
   styles bare ul, li, label and input[type=checkbox] with its own margins and
   display, and an unscoped rule here loses to it. */
.part-checklist {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    min-height: 0;
    padding: 0;
    border: var(--part-field-border, 1px solid var(--border));
    border-radius: 4px;
    background: color-mix(in srgb, var(--plain-bg, #fff) 70%, transparent);
    text-align: inherit;
    overflow: hidden;
    position: relative;
}
/* focus-within, not :focus-visible: the container is not a tab stop — the
   item checkboxes are. */
.part-checklist:focus-within {
    outline: 2px solid var(--accent, #2563eb);
    outline-offset: 1px;
}
.part-locked .part-checklist {
    border-style: dotted;
    background: transparent;
}
.part-checklist .part-checklist-items {
    flex: 0 1 auto;
    min-height: 0;
    margin: 0;
    padding: 0.2rem 0;
    list-style: none;
    overflow: auto;
    width: 100%;
}
.part-checklist .part-checklist-item {
    display: flex;
    width: 100%;
    min-width: 0;
    align-items: baseline;
    gap: 0.4rem;
    margin: 0;
    padding: 0.2rem 0.5rem;
    border-radius: 0;
    line-height: 1.4;
}
.part-checklist .part-checklist-item:hover {
    background: color-mix(in srgb, var(--fg) 7%, transparent);
}
.part-checklist .part-checklist-item.is-dragging {
    opacity: 0.5;
    background: color-mix(in srgb, var(--accent, #2563eb) 12%, transparent);
}
.part-checklist .part-checklist-label {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
    margin: 0;
    padding: 0;
    cursor: pointer;
    user-select: none;
}
.part-checklist .part-checklist-check {
    flex: none;
    font: inherit;
    width: 1.1em;
    height: 1.1em;
    margin: 0;
    align-self: center;
}
.part-checklist .part-checklist-text {
    flex: 1;
    min-width: 0;
    overflow-wrap: anywhere;
}
/* Done items are struck through and stay where they are — a list that moved
   or swallowed what was finished would keep asking whether it had been. The
   sibling selector means nothing in JS has to keep a class in step, and the
   server-rendered `checked` gets it right on the first paint. */
.part-checklist .part-checklist-check:checked ~ .part-checklist-text {
    text-decoration: line-through;
    opacity: 0.6;
}
/* HyperCard's dontWrap: one visual line per item, the rest clipped. */
.part-checklist-nowrap .part-checklist-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* The drag handle. touch-action belongs here and not on the row, or the list
   stops scrolling under a finger. */
.part-checklist .part-checklist-grip {
    flex: none;
    width: 1em;
    text-align: center;
    align-self: center;
    opacity: 0;
    line-height: 1;
    cursor: grab;
    touch-action: none;
    user-select: none;
    color: var(--muted-fg);
}
.part-checklist .part-checklist-item:hover .part-checklist-grip,
.part-checklist .part-checklist-item:focus-within .part-checklist-grip,
.part-checklist .part-checklist-item.is-dragging .part-checklist-grip {
    opacity: 0.6;
}
.part-checklist .part-checklist-grip:active {
    cursor: grabbing;
}
/* A count and never a bar. data-done / data-total stay current on this
   element, so a bar could be added later without reworking anything. */
.part-checklist .part-checklist-count {
    flex: none;
    margin: 0;
    padding: 0.2rem 0.5rem;
    border-top: 1px solid var(--border);
    font-size: 0.85em;
    color: var(--muted-fg);
}
.part-button-btn {
    width: 100%;
    height: 100%;
    margin: 0;
    /* Buttons keep the size their author drew, so side padding comes out of the
       label: keep it slim or short labels like "Bookmarks" get an ellipsis. */
    padding: 0.25rem 0.4rem;
    border: 1px solid color-mix(in srgb, var(--border) 82%, var(--fg));
    border-radius: 7px;
    background: linear-gradient(180deg, color-mix(in srgb, var(--bg, #fff) 88%, #fff), var(--accent-bg));
    box-shadow: 0 1px 1px color-mix(in srgb, var(--fg) 12%, transparent);
    color: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    cursor: pointer;
    overflow: hidden;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.part-button-btn:hover {
    border-color: var(--accent, #2563eb);
    background: color-mix(in srgb, var(--accent, #2563eb) 12%, var(--bg, #fff));
    box-shadow: 0 4px 10px color-mix(in srgb, var(--fg) 16%, transparent);
    color: inherit;
    transform: translateY(-1px);
}
.part-button-btn:focus-visible {
    outline: 2px solid var(--accent, #2563eb);
    outline-offset: 2px;
}
.part-button-icon {
    flex: none;
    line-height: 1;
}
.part-button-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.part-button-btn:active {
    box-shadow: inset 0 1px 2px color-mix(in srgb, var(--fg) 22%, transparent);
    transform: translateY(0);
}
.part-widget-body {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    color: var(--fg, #1e293b);
}
.wyldcards-drawing {
    position: relative;
    flex: 1;
    min-height: 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg, #fff);
    overflow: hidden;
}
.wyldcards-drawing-canvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
}
.wyldcards-drawing-tools {
    position: absolute;
    top: 6px;
    right: 6px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 3px;
    border: 1px solid color-mix(in srgb, var(--fg) 18%, transparent);
    border-radius: 5px;
    background: color-mix(in srgb, var(--bg, #fff) 90%, transparent);
}
.wyldcards-drawing-tool {
    min-width: 1.6rem;
    min-height: 1.6rem;
    padding: 0.15rem 0.3rem;
    border: 1px solid transparent;
    border-radius: 3px;
    font-size: 0.7rem;
}
.wyldcards-drawing-tool[data-drawing-color] { background: var(--drawing-color); }
.wyldcards-drawing-tool.is-active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.wyldcards-drawing-status { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.home-widget-tray {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
    gap: 0.75rem;
    margin: 1rem 0;
}
.home-widget {
    position: relative;
    min-height: 8rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg);
    box-shadow: 0 1px 2px color-mix(in srgb, var(--fg) 8%, transparent);
}
.home-widget-options {
    gap: 0.5rem;
}
.home-widget-option {
    cursor: grab;
}
.home-widget-option.is-dragging {
    cursor: grabbing;
    opacity: 0.55;
}
.home-widget-option-controls {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    margin-left: auto;
}
.home-widget-option-controls button {
    margin: 0;
    min-width: auto;
    padding: 0.2rem 0.4rem;
    font-size: 0.75rem;
}
.home-widget-arrange-controls {
    position: absolute;
    z-index: 1;
    top: 0.4rem;
    right: 0.4rem;
    display: inline-flex;
    gap: 0.25rem;
}
.home-widget-arrange-controls button {
    margin: 0;
    min-width: auto;
    padding: 0.2rem 0.4rem;
    font-size: 0.75rem;
}
.home-widget.is-dragging {
    cursor: grabbing;
    opacity: 0.55;
}
.home-widget-trash-target {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: 4rem;
    border: 1px dashed color-mix(in srgb, var(--bad, #b91c1c) 65%, var(--border));
    border-radius: 8px;
    color: var(--bad, #b91c1c);
    background: color-mix(in srgb, var(--bad, #b91c1c) 8%, var(--bg));
}
.home-widget-trash-target.is-drop-target {
    border-style: solid;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad, #b91c1c) 22%, transparent);
}
.home-quick-capture {
    display: grid;
    gap: 0.65rem;
    padding: 1rem;
}
.home-quick-capture-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
}
.home-quick-capture-heading h2 {
    margin: 0;
    font-size: 1rem;
}
.home-quick-capture-heading span {
    color: var(--muted-fg);
    font-size: 0.8rem;
}
.home-quick-capture label {
    display: grid;
    gap: 0.25rem;
    font-size: 0.85rem;
    font-weight: 600;
}
.home-quick-capture input,
.home-quick-capture select,
.home-quick-capture textarea {
    width: 100%;
    box-sizing: border-box;
    margin: 0;
    font: inherit;
}
.home-quick-capture textarea {
    resize: vertical;
}
.home-quick-capture button {
    justify-self: end;
}
.home-quick-capture-empty p {
    margin: 0;
    color: var(--muted-fg);
}
.home-quick-capture-empty a {
    justify-self: start;
}
@media (max-width: 32rem) {
    .home-quick-capture-heading {
        align-items: flex-start;
        flex-direction: column;
    }
    .home-quick-capture button {
        justify-self: stretch;
    }
    .home-quick-capture-empty a {
        justify-self: stretch;
    }
}
.part-card-preview {
    width: 100%;
    height: 100%;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: color-mix(in srgb, var(--fg) 3%, var(--bg));
}
.part-card-preview-canvas {
    position: relative;
    overflow: hidden;
    pointer-events: none;
}
.part-card-shortcut {
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: color-mix(in srgb, var(--accent, #2563eb) 9%, var(--bg));
    color: inherit;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    font-weight: 600;
    text-decoration: none;
}
.part-card-shortcut:hover {
    border-color: var(--accent, #2563eb);
    color: inherit;
}
.part-card-shortcut:focus-visible {
    outline: 2px solid var(--accent, #2563eb);
    outline-offset: 2px;
}
.part-card-shortcut-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.part-stack-view {
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(7rem, 1fr));
    align-content: start;
    gap: 0.35rem;
    overflow: auto;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: color-mix(in srgb, var(--fg) 3%, var(--bg));
}
.part-stack-view-title {
    grid-column: 1 / -1;
    font-size: 0.85rem;
}
.part-stack-view-card {
    min-width: 0;
    display: flex;
    gap: 0.35rem;
    padding: 0.35rem 0.45rem;
    border-radius: 4px;
    color: inherit;
    text-decoration: none;
}
.part-stack-view-card:hover,
.part-stack-view-card:focus-visible,
.part-stack-view-card[aria-current="page"] {
    background: color-mix(in srgb, var(--accent, #2563eb) 15%, var(--bg));
    color: inherit;
}
.part-stack-view-card span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.wyldcards-image {
    width: 100%;
    height: 100%;
    display: block;
}
.part-saved .part-input,
.part-saved .part-checkbox {
    box-shadow: 0 0 0 2px color-mix(in srgb, #16a34a 50%, transparent);
    transition: box-shadow 0.3s;
}
.wyldcards-widget-unknown {
    color: var(--muted-fg);
    font-size: 0.85rem;
    padding: 0.5rem;
}

/* ---- Edit mode ------------------------------------------------------ */
.wyldcards-mode-edit .part {
    cursor: move;
    outline: 1px dashed color-mix(in srgb, var(--fg) 35%, transparent);
    outline-offset: 1px;
}
.wyldcards-mode-edit .part .part-control,
.wyldcards-mode-edit .part .part-control * {
    pointer-events: none;
}
.wyldcards-mode-edit .part-on-background {
    outline-style: dotted;
}
body.wyldcards-editing-background .part-on-card {
    opacity: 0.35;
}
body.wyldcards-editing-background .wyldcards-card {
    box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--accent, #2563eb) 60%, transparent);
}
.part-selected {
    outline: 2px solid var(--accent, #2563eb) !important;
    outline-offset: 1px;
    z-index: 3;
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent, #2563eb) 16%, transparent);
}
.part-selected.part-snapped {
    outline-color: #16a34a !important;
    box-shadow: 0 0 0 4px color-mix(in srgb, #16a34a 22%, transparent);
}
.part-handle {
    position: absolute;
    right: -6px;
    bottom: -6px;
    width: 12px;
    height: 12px;
    border-radius: 3px;
    background: var(--accent, #2563eb);
    border: 2px solid var(--plain-bg, #fff);
    cursor: nwse-resize;
    opacity: 0;
    pointer-events: auto;
}
.part-selected .part-handle,
.part:hover .part-handle {
    opacity: 1;
}
.part-name-tag {
    position: absolute;
    left: 0;
    top: -1.25rem;
    font-size: 0.65rem;
    line-height: 1;
    padding: 0.15rem 0.35rem;
    border-radius: 3px;
    background: color-mix(in srgb, var(--fg) 75%, transparent);
    color: var(--bg);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
}
.part-selected .part-name-tag,
.part:hover .part-name-tag {
    opacity: 1;
}
/* Alignment guides and the position readout, drawn only while dragging. */
.part-guide {
    position: absolute;
    z-index: 20;
    pointer-events: none;
    background: #db2777;
}
.part-guide--vertical {
    top: 0;
    bottom: 0;
    width: 1px;
    margin-left: -0.5px;
}
.part-guide--horizontal {
    left: 0;
    right: 0;
    height: 1px;
    margin-top: -0.5px;
}
.part-readout {
    position: absolute;
    z-index: 21;
    pointer-events: none;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    background: color-mix(in srgb, var(--fg) 85%, transparent);
    color: var(--bg);
    font: 0.7rem/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
    white-space: nowrap;
}
.wyldcards-arrange {
    display: grid;
    gap: 0.25rem;
    padding: 0.15rem 0.2rem;
}
.wyldcards-arrange-hint {
    margin: 0 0.4rem 0.15rem;
    color: var(--muted-fg);
    font-size: 0.75rem;
    max-width: 17rem;
}
.wyldcards-arrange-row {
    display: flex;
    gap: 0.25rem;
}
.wyldcards-new-card-options .wyldcards-arrange-row button {
    flex: 1 1 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.35rem 0.4rem;
    border: 1px solid var(--border);
    font-size: 0.8rem;
    white-space: nowrap;
}

/* ---- Side panel: inspector, cards, scripts -------------------------- */
.wyldcards-side {
    min-width: 0;
    border-inline-start: 1px solid var(--border);
    background: color-mix(in srgb, var(--bg) 96%, var(--accent-bg));
    overflow: auto;
    overscroll-behavior: contain;
    padding: 1.1rem;
    font-size: 0.9rem;
}
.wyldcards-side-hint {
    padding: 0.85rem;
    border: 1px dashed color-mix(in srgb, var(--border) 88%, var(--fg));
    border-radius: 0.5rem;
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    line-height: 1.5;
}
.wyldcards-side-hint p {
    margin: 0 0 0.75rem;
}
.wyldcards-side-hint p:last-child {
    margin-bottom: 0;
}
.wyldcards-side-hint ol {
    display: grid;
    gap: 0.45rem;
    margin: 0.75rem 0;
    padding-left: 1.35rem;
}
.wyldcards-inspector-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}
.wyldcards-inspector-close {
    flex: 0 0 auto;
    min-height: 2rem;
    margin: 0;
    padding: 0.25rem 0.55rem;
    border-color: var(--border);
    background: var(--bg);
    color: var(--muted-fg);
    font-size: 0.8rem;
}
.wyldcards-inspector-title {
    font-size: 1.05rem;
    margin: 0 0 0.15rem;
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
}
.wyldcards-inspector-kind {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted-fg);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 0.05rem 0.3rem;
}
.wyldcards-inspector-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin: 0 0 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}
.wyldcards-inspector-field {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}
.wyldcards-inspector-field > span:first-child {
    font-size: 0.8rem;
    color: var(--muted-fg);
}
.wyldcards-inspector-field input,
.wyldcards-inspector-field select,
.wyldcards-inspector-field textarea {
    width: 100%;
    box-sizing: border-box;
    margin: 0;
    font-size: 0.9rem;
    background: var(--bg);
}
.wyldcards-inspector-rect {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.45rem;
    padding: 0.65rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: color-mix(in srgb, var(--bg) 82%, var(--accent-bg));
}
.wyldcards-inspector-rect label {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    font-size: 0.75rem;
    color: var(--muted-fg);
}
.wyldcards-inspector-rect input {
    width: 100%;
    box-sizing: border-box;
    margin: 0;
    padding: 0.25rem 0.35rem;
    font-size: 0.85rem;
}
.wyldcards-inspector-check {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    cursor: pointer;
}
.wyldcards-inspector-check input {
    margin: 0;
}
.wyldcards-inspector-lock {
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
}
.wyldcards-inspector-lock-control {
    gap: 0.5rem;
    min-height: 28px;
}
.wyldcards-inspector-lock-control input {
    flex: none;
}
.wyldcards-inspector-lock-heading {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
    flex: 1;
    font-weight: 600;
}
.wyldcards-inspector-lock-icon {
    flex: none;
}
.wyldcards-inspector-lock-state {
    margin-left: auto;
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--muted-fg);
}
.wyldcards-inspector-lock-control .wyldcards-lock-closed,
.wyldcards-inspector-lock-control input:checked ~ .wyldcards-inspector-lock-heading .wyldcards-lock-open {
    display: none;
}
.wyldcards-inspector-lock-control input:checked ~ .wyldcards-inspector-lock-heading .wyldcards-lock-closed {
    display: inline;
}
.wyldcards-inspector-lock p {
    margin: 0.4rem 0 0;
    font-size: 0.78rem;
    line-height: 1.45;
    color: var(--muted-fg);
}
.wyldcards-inspector-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
}
.wyldcards-inspector-actions button {
    margin: 0;
    min-height: 2rem;
    padding: 0.3rem 0.7rem;
    font-size: 0.85rem;
}
.wyldcards-inspector-actions button[type="submit"] {
    border-color: var(--accent, #2563eb);
    background: var(--accent, #2563eb);
    color: #fff;
}
.wyldcards-inspector-actions button[type="submit"]:hover,
.wyldcards-inspector-actions button[type="submit"]:focus-visible {
    filter: brightness(1.08);
    outline: 2px solid color-mix(in srgb, var(--accent, #2563eb) 45%, transparent);
    outline-offset: 1px;
}
.wyldcards-inspector-help {
    margin-left: auto;
    font-size: 0.8rem;
}
.wyldcards-inspector-notice {
    margin: 0 0 0.75rem;
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    background: color-mix(in srgb, #16a34a 14%, transparent);
    font-size: 0.85rem;
}
.wyldcards-inspector-error,
.wyldcards-inspector-fielderror {
    margin: 0 0 0.5rem;
    color: #b91c1c;
    font-size: 0.85rem;
}
.wyldcards-script-textarea {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.85rem;
    line-height: 1.45;
    tab-size: 2;
}

.wyldcards-cards-list {
    list-style: none;
    padding: 0;
    margin: 0 0 1rem;
}
/* The transfer workspace needs room for two card lists, so the side panel
   widens while it is open; below that width the lists stack. */
@media (min-width: 801px) {
    .wyldcards-workbench:has(> .wyldcards-side .wyldcards-transfer) {
        grid-template-columns: minmax(0, 1fr) clamp(22rem, 48vw, 48rem);
    }
}
.wyldcards-transfer {
    container-type: inline-size;
}
.wyldcards-transfer-picker {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.5rem;
    margin: 0;
}
.wyldcards-transfer-picker label {
    display: flex;
    flex: 1 1 10rem;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
    margin: 0;
}
.wyldcards-transfer-picker select {
    width: 100%;
    margin: 0;
}
.wyldcards-transfer-swap {
    flex: none;
    margin: 0;
    padding: 0.3rem 0.55rem;
}
.wyldcards-transfer-status {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.6rem;
    margin: 0.75rem 0 0;
    padding: 0.45rem 0.65rem;
    border-radius: 0.4rem;
    background: color-mix(in srgb, var(--accent) 12%, var(--bg));
}
.wyldcards-transfer-stacks {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
    gap: 0.75rem;
    margin-top: 1rem;
}
@container (max-width: 30rem) {
    .wyldcards-transfer-stacks {
        grid-template-columns: minmax(0, 1fr);
    }
}
.wyldcards-transfer-stack {
    display: flex;
    flex-direction: column;
    min-width: 0;
    margin: 0;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: color-mix(in srgb, var(--bg) 88%, var(--accent-bg));
}
.wyldcards-transfer-stack.is-card-transfer-target {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}
.wyldcards-transfer-stack > header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    padding: 0.45rem 0.65rem;
    border-bottom: 1px solid var(--border);
}
.wyldcards-transfer-stack h3 {
    flex: 1;
    min-width: 0;
    margin: 0;
    overflow: hidden;
    font-size: 0.9rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.wyldcards-transfer-stack input[type="checkbox"] {
    flex: none;
    margin: 0;
}
.wyldcards-transfer-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    padding: 0.45rem 0.5rem;
    border-bottom: 1px solid var(--border);
}
.wyldcards-transfer-tools input[type="search"] {
    flex: 1 1 7rem;
    min-width: 0;
    margin: 0;
    padding: 0.2rem 0.45rem;
    font-size: 0.8rem;
}
.wyldcards-transfer-stack ol {
    flex: 1;
    max-height: min(60vh, 34rem);
    margin: 0;
    padding: 0;
    overflow: auto;
    overscroll-behavior: contain;
    list-style: none;
}
.wyldcards-transfer-stack ol.is-card-transfer-drop-end {
    box-shadow: inset 0 -3px 0 var(--accent);
}
.wyldcards-transfer-stack li {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.5rem;
    border-bottom: 1px solid var(--border);
}
.wyldcards-transfer-stack li[hidden] {
    display: none;
}
.wyldcards-transfer-stack li:last-child {
    border-bottom: 0;
}
.wyldcards-transfer-stack li.is-card-transfer-selected {
    background: color-mix(in srgb, var(--accent) 10%, transparent);
}
.wyldcards-transfer-stack li.is-card-transfer-current {
    box-shadow: inset 3px 0 0 var(--accent);
}
.wyldcards-transfer-stack li.is-card-transfer-arrived {
    animation: wyldcards-transfer-arrived 1.6s ease-out;
}
@keyframes wyldcards-transfer-arrived {
    from { background: color-mix(in srgb, var(--accent) 30%, transparent); }
}
.wyldcards-transfer-stack li.is-card-transfer-drop-before {
    box-shadow: inset 0 3px 0 var(--accent);
}
.wyldcards-transfer-stack li.is-card-transfer-dragging {
    opacity: 0.45;
}
.is-card-transfer-copying .wyldcards-transfer-stack.is-card-transfer-target {
    cursor: copy;
}
.wyldcards-transfer-stack form {
    display: inline-flex;
    align-items: center;
    flex: none;
    gap: 0.25rem;
    margin: 0;
}
.wyldcards-transfer-stack button {
    margin: 0;
    padding: 0.2rem 0.4rem;
    font-size: 0.75rem;
}
.wyldcards-transfer-card-grip {
    cursor: grab;
    flex: none;
    touch-action: none;
}
.wyldcards-transfer-card-grip:active {
    cursor: grabbing;
}
.wyldcards-transfer-card-name {
    display: flex;
    flex: 1;
    align-items: baseline;
    gap: 0.35rem;
    min-width: 0;
}
.wyldcards-transfer-card-name > span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.wyldcards-transfer-here {
    flex: none;
    padding: 0 0.3rem;
    border-radius: 0.25rem;
    background: var(--accent);
    color: var(--bg);
    font-size: 0.65rem;
}
.wyldcards-transfer-hint {
    margin-top: 0.75rem;
    font-size: 0.8rem;
}
@media (prefers-reduced-motion: reduce) {
    .wyldcards-transfer-stack li.is-card-transfer-arrived {
        animation: none;
        background: color-mix(in srgb, var(--accent) 15%, transparent);
    }
}
.wyldcards-cards-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0;
    border-bottom: 1px solid var(--border);
}
.wyldcards-cards-row--current {
    background: var(--accent-bg);
}
.wyldcards-cards-row--marked,
.wyldcards-card-list-row--marked {
    box-shadow: inset 3px 0 0 #d97706;
}
.wyldcards-cards-number {
    min-width: 2rem;
    text-align: center;
    font-variant-numeric: tabular-nums;
    text-decoration: none;
    font-weight: 600;
}
.wyldcards-cards-name {
    flex: 1;
    min-width: 0;
    margin: 0;
    padding: 0.2rem 0.4rem;
    font-size: 0.85rem;
}
.wyldcards-cards-parts {
    font-size: 0.75rem;
    white-space: nowrap;
}
.wyldcards-card-mark {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    flex: 0 0 auto;
    padding: 0.15rem 0.45rem;
    border: 1px solid var(--border, #cbd5e1);
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: 0.01em;
    white-space: nowrap;
}
.wyldcards-card-mark::before {
    width: 0.45rem;
    height: 0.45rem;
    border-radius: 50%;
    background: currentColor;
    content: '';
}
.wyldcards-card-mark--marked {
    border-color: color-mix(in srgb, #d97706 38%, var(--border, #cbd5e1));
    background: color-mix(in srgb, #f59e0b 14%, transparent);
    color: #92400e;
}
.wyldcards-card-mark--unmarked {
    color: var(--muted-fg, #64748b);
}
.wyldcards-card-mark--unmarked::before {
    background: transparent;
    box-shadow: inset 0 0 0 1.5px currentColor;
}
.wyldcards-card-list-mark-cell {
    width: 1%;
    padding-left: 0;
    white-space: nowrap;
    /* Beside a two-line row it hung from the top edge, above the row's chevron. */
    vertical-align: middle;
}
.wyldcards-card-list-mark-form {
    display: inline-flex;
    align-items: center;
    margin: 0;
    vertical-align: middle;
}
.wyldcards-card-list-mark-form .wyldcards-card-mark {
    margin: 0;
    cursor: pointer;
}
.wyldcards-card-list-mark-form .wyldcards-card-mark:hover,
.wyldcards-card-list-mark-form .wyldcards-card-mark:focus-visible {
    border-color: var(--accent);
    outline: none;
}
.wyldcards-card-email-form {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin: 0 0 1rem;
}
.wyldcards-card-email-form input[type="email"] {
    margin: 0;
    min-width: min(100%, 18rem);
}
.wyldcards-card-email-select-all {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    white-space: nowrap;
}
.wyldcards-card-email-cell {
    width: 1%;
    text-align: center;
}
@media (max-width: 40rem) {
    .wyldcards-card-email-form input[type="email"] {
        width: 100%;
    }
}
.wyldcards-cards-mark {
    margin-left: auto;
}

/* The panel's grip. Narrower than the full-page list's — the sidebar has a
   sequence of controls across every row and no width to spare — but the same
   gesture, and the same explicit inline-flex box so missing.css's button
   metrics cannot knock it out of line with the number beside it. */
.wyldcards-cards-grip-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    vertical-align: middle;
}
.wyldcards-cards-grip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0.2rem 0.15rem;
    border: none;
    background: none;
    box-shadow: none;
    color: var(--muted-fg);
    font-size: 0.85rem;
    line-height: 1;
    cursor: grab;
    touch-action: none;
    user-select: none;
    opacity: 0.55;
}
.wyldcards-cards-row:hover .wyldcards-cards-grip,
.wyldcards-cards-grip:focus-visible {
    opacity: 1;
    color: var(--fg);
}
.wyldcards-cards-grip:active {
    cursor: grabbing;
}
.wyldcards-cards-row.is-dragging {
    background: var(--bg);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
    opacity: 0.96;
}
/* Mid-drag the row is carried by a transform and must not also be typed into
   or navigated from; the grip stays live because it is what is being held. */
.wyldcards-reorder-active .wyldcards-cards-number,
.wyldcards-reorder-active .wyldcards-cards-name {
    pointer-events: none;
}

/* ---- Full-page card list (/stack/{uid}/cards/list) -------------------- */
/* Same footprint as .wyldcards-toolbar-mode, but a separate class: wyldcards-editor.js
   binds ⌘E to the first .wyldcards-toolbar-mode in main, and this link sits before it. */
.wyldcards-toolbar-link {
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.25rem;
    margin: 0;
    font: inherit;
    line-height: 1.4;
    padding: 0.3rem 0.9rem;
    text-decoration: none;
    white-space: nowrap;
}
/* One quiet treatment for every toolbar item. Left alone, the <button>s (Find,
   Comments, Practice, Flip, Mark, Bookmark...) took missing.css's grey raised
   button while the <a>s beside them were bare blue links. The primary New card
   and a marked toggle keep their own colours. */
/* Jump arrows only take room once there is a jump to retrace. */
.wyldcards-jump-history-control[disabled] { display: none; }
.wyldcards-toolbar-link:not(.wyldcards-toolbar-new-card, .wyldcards-mark-toggle--marked) {
    border: 1px solid transparent;
    border-radius: 7px;
    background: transparent;
    box-shadow: none;
    color: var(--fg, inherit);
}
.wyldcards-toolbar-link:not(.wyldcards-toolbar-new-card, .wyldcards-mark-toggle--marked):is(:hover, :focus-visible, [aria-expanded="true"]) {
    border-color: var(--border, #cbd5e1);
    background: var(--accent-bg, rgba(0, 0, 0, 0.05));
    color: var(--accent, inherit);
}
.wyldcards-card-list-link {
    color: inherit;
    text-decoration: none;
}
/* Narrow screens turn .user-list-item into a column and the phone shell makes
   the <tr> a flex row; a card row stays one line, number - name - chevron. */
.wyldcards-card-list-row .user-list-main-cell {
    flex: 1 1 auto;
    min-width: 0;
}
.wyldcards-card-list-row .user-list-item {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
}
.wyldcards-card-list-row:hover {
    background: var(--accent-bg, rgba(0, 0, 0, 0.03));
}
.wyldcards-card-list-row--current {
    background: var(--accent-bg);
}
.wyldcards-card-list-number {
    min-width: 2.25rem;
    flex-shrink: 0;
    text-align: center;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--muted-fg);
}
.wyldcards-card-list-unnamed {
    color: var(--muted-fg);
    font-style: italic;
    font-weight: 400;
}
.wyldcards-card-list-chevron {
    margin-left: auto;
    flex-shrink: 0;
    color: var(--muted-fg);
}
.wyldcards-mark-toggle--marked {
    border-color: color-mix(in srgb, #d97706 44%, var(--border, #cbd5e1));
    background: color-mix(in srgb, #f59e0b 16%, transparent);
    color: #92400e;
    font-weight: 700;
}
.wyldcards-mark-toggle--marked::before {
    margin-right: 0.35rem;
    content: '●';
    color: #d97706;
    font-size: 0.7em;
    vertical-align: 0.08em;
}

/* ---- Rearranging the card list --------------------------------------- */
/* The grip is the only part of a row that starts a drag; the rest of it stays
   a link to the card. missing.css gives buttons their own inline metrics, so
   the cell is an explicit inline-flex box rather than trusting inline-block to
   centre a glyph against the row beside it. touch-action: none is what lets a
   finger drag the row instead of scrolling the page under it. */
.wyldcards-card-list-grip-cell {
    /* A shrink-to-fit cell in the desktop table, and a fixed-size flex item once
       the phone shell turns the row itself into a flex row. */
    width: 1px;
    flex: 0 0 auto;
    padding: 0 0 0 0.5rem;
    text-align: center;
    vertical-align: middle;
}
.wyldcards-card-list-grip-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
}
.wyldcards-card-list-grip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0.35rem 0.4rem;
    border: none;
    background: none;
    /* missing.css gives every button a raised edge; a grip is not a raised thing. */
    box-shadow: none;
    color: var(--muted-fg);
    font-size: 1rem;
    line-height: 1;
    cursor: grab;
    touch-action: none;
    user-select: none;
    border-radius: 6px;
}
.wyldcards-card-list-grip:hover,
.wyldcards-card-list-grip:focus-visible {
    color: var(--fg);
    background: var(--accent-bg, rgba(0, 0, 0, 0.06));
}
.wyldcards-card-list-grip:active {
    cursor: grabbing;
}

/* The row under the hand: lifted off the list, and carried by a transform the
   script sets each frame, so no transition may smooth it or it will lag behind
   the finger. Everything else in the list slides into place around it. */
.wyldcards-card-list-row.is-dragging {
    position: relative;
    z-index: 2;
    background: var(--bg);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
    opacity: 0.96;
    cursor: grabbing;
}
.wyldcards-card-list-row.is-dragging .wyldcards-card-list-grip {
    cursor: grabbing;
}
.wyldcards-reorder-active .wyldcards-card-list-row:not(.is-dragging) {
    transition: transform 120ms ease;
}
/* A drag in progress must not also be read as a click on the row's link. */
.wyldcards-reorder-active .wyldcards-card-list-link {
    pointer-events: none;
}
.wyldcards-reorder-saving {
    cursor: progress;
}

.wyldcards-card-list-hint {
    margin: 0.75rem 0 0;
    font-size: 0.8rem;
}
.wyldcards-card-list-status {
    margin: 0.25rem 0 0;
    min-height: 1.2em;
    font-size: 0.8rem;
    color: var(--muted-fg);
}
.wyldcards-card-list-status--error {
    color: var(--danger-fg, #b91c1c);
    font-weight: 600;
}

@media (prefers-reduced-motion: reduce) {
    .wyldcards-reorder-active .wyldcards-card-list-row:not(.is-dragging) {
        transition: none;
    }
}

/* ---- Dialogs the runtime raises -------------------------------------- */
.wyldcards-dialog {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    background: var(--bg);
    color: var(--fg);
    max-width: min(420px, 90vw);
    box-shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.5);
}
.wyldcards-dialog::backdrop {
    background: rgba(0, 0, 0, 0.35);
}
.wyldcards-dialog-message {
    margin: 0 0 1rem;
    font-size: 1.05rem;
    white-space: pre-wrap;
}
.wyldcards-dialog-input {
    width: 100%;
    box-sizing: border-box;
    margin: 0 0 1rem;
}
.wyldcards-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}
.wyldcards-dialog-actions button {
    margin: 0;
}
.wyldcards-dialog-primary {
    background: var(--accent, #2563eb);
    color: #fff;
    border-color: var(--accent, #2563eb);
}

/* ---- Widgets --------------------------------------------------------- */
.wyldcards-key-picker {
    position: relative;
    display: block;
    overflow: visible;
}
.wyldcards-key-picker-trigger {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0.35rem 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
}
.wyldcards-key-picker-popover {
    position: absolute;
    z-index: 20;
    top: calc(100% + 0.35rem);
    right: 0;
    width: 248px;
    padding: 0.75rem;
    border: 1px solid var(--border, #cbd5e1);
    border-radius: 8px;
    background: var(--card-bg, #fff);
    box-shadow: 0 8px 20px rgb(15 23 42 / 18%);
}
.wyldcards-key-picker-label {
    display: block;
    margin: 0 0 0.3rem;
    color: var(--muted-fg, #64748b);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
}
.wyldcards-key-picker-tonics,
.wyldcards-key-picker-quality,
.wyldcards-key-picker-transpose {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.25rem;
    margin-bottom: 0.7rem;
}
.wyldcards-key-picker-quality {
    grid-template-columns: repeat(2, 1fr);
}
.wyldcards-key-picker-transpose {
    grid-template-columns: repeat(4, 1fr);
}
.wyldcards-key-picker-option,
.wyldcards-key-picker-transpose-action,
.wyldcards-key-picker-done {
    margin: 0;
    min-height: 2rem;
    padding: 0.2rem;
    font-size: 0.78rem;
}
.wyldcards-key-picker-option--selected,
.wyldcards-key-picker-done {
    background: var(--accent, #2563eb);
    border-color: var(--accent, #2563eb);
    color: #fff;
}
.wyldcards-key-picker-done {
    display: block;
    width: 100%;
}
/* The song template's data fields are saved by the picker, not displayed. */
.wyldcards-card:has(.part-widget-body[data-widget-type="key_picker"]) .part[data-part-name="tonic"],
.wyldcards-card:has(.part-widget-body[data-widget-type="key_picker"]) .part[data-part-name="quality"] {
    display: none;
}
.wyldcards-piano {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    min-height: 0;
    padding: 0.55rem;
    border: 1px solid color-mix(in srgb, var(--border, #cbd5e1) 80%, var(--accent, #2563eb));
    border-radius: 0.8rem;
    background: linear-gradient(145deg, color-mix(in srgb, var(--bg, #fff) 92%, var(--accent-bg, #eff6ff)), var(--bg, #fff));
    box-shadow: inset 0 1px 0 color-mix(in srgb, #fff 80%, transparent), 0 0.25rem 0.75rem color-mix(in srgb, #0f172a 9%, transparent);
}
.wyldcards-piano-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
    min-width: 0;
}
.wyldcards-piano-title {
    color: var(--fg, #0f172a);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}
.wyldcards-piano-range {
    color: var(--muted-fg, #64748b);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.68rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.wyldcards-piano-keys {
    position: relative;
    flex: 1;
    min-height: 7rem;
    overflow: hidden;
    border: 1px solid #0f172a;
    border-radius: 0.5rem;
    background: #111827;
    box-shadow: inset 0 1px 4px rgba(15, 23, 42, 0.55), 0 1px 1px rgba(15, 23, 42, 0.15);
}
.wyldcards-piano-key {
    position: absolute;
    top: 0;
    margin: 0;
    padding: 0;
    border: 1px solid #334155;
    border-radius: 0 0 0.3rem 0.3rem;
    cursor: pointer;
    font-size: clamp(0.55rem, 1.4vw, 0.7rem);
    font-weight: 600;
    line-height: 1;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 3px;
    box-sizing: border-box;
    user-select: none;
    touch-action: none;
    transition: background-color 0.1s ease, box-shadow 0.1s ease, transform 0.1s ease, filter 0.1s ease;
}
.wyldcards-piano-key--white {
    height: 100%;
    background: linear-gradient(90deg, #f8fafc, #fff 45%, #e2e8f0);
    color: #475569;
    z-index: 1;
    box-shadow: inset 0 -0.28rem 0 #cbd5e1, inset 1px 0 rgba(255, 255, 255, 0.8);
}
.wyldcards-piano-key--black {
    height: 60%;
    border-color: #0f172a;
    background: linear-gradient(90deg, #0f172a, #334155 55%, #020617);
    color: #fff;
    z-index: 2;
    box-shadow: inset 0 -0.2rem 0 #020617, 0 0.12rem 0.18rem rgba(15, 23, 42, 0.45);
}
.wyldcards-piano-key--white:hover {
    background: linear-gradient(90deg, #eff6ff, #fff 45%, #dbeafe);
}
.wyldcards-piano-key--black:hover {
    background: linear-gradient(90deg, #1e293b, #475569 55%, #0f172a);
}
.wyldcards-piano-key:active,
.wyldcards-piano-key--down {
    transform: translateY(0.12rem);
}
.wyldcards-piano-key--down.wyldcards-piano-key--white {
    background: linear-gradient(90deg, #bfdbfe, #dbeafe 55%, #93c5fd);
    box-shadow: inset 0 -0.1rem 0 #60a5fa;
}
.wyldcards-piano-key--down.wyldcards-piano-key--black {
    background: linear-gradient(90deg, #1d4ed8, #3b82f6, #1e40af);
    box-shadow: inset 0 -0.08rem 0 #1e3a8a, 0 0.1rem 0.16rem rgba(15, 23, 42, 0.35);
}
.wyldcards-piano-key:focus-visible {
    z-index: 3;
    outline: 2px solid var(--accent, #2563eb);
    outline-offset: -3px;
}
.wyldcards-piano-status {
    min-height: 1.1em;
    color: var(--muted-fg, #64748b);
    font-size: 0.72rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    text-align: center;
}
.wyldcards-piano--full {
    overflow-x: auto;
}
.wyldcards-piano--full .wyldcards-piano-keys {
    flex: none;
    min-width: 44rem;
}

.wyldcards-metronome {
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 8px;
}
.wyldcards-metronome-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
}
.wyldcards-metronome-bpm {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.wyldcards-metronome-beats {
    display: flex;
    gap: 0.35rem;
}
.wyldcards-metronome-beat {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1px solid var(--border);
}
.wyldcards-metronome-beat--on {
    background: var(--accent, #2563eb);
    border-color: var(--accent, #2563eb);
}
.wyldcards-metronome-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
}
.wyldcards-metronome-btn {
    margin: 0;
    min-width: 3rem;
    padding: 0.25rem 0.45rem;
    font-size: 0.85rem;
}
.wyldcards-metronome-tempo {
    width: 4.25rem;
    min-height: 2.1rem;
    margin: 0;
    padding: 0.2rem 0.35rem;
    text-align: center;
    font: inherit;
    font-variant-numeric: tabular-nums;
}
.wyldcards-live-audio {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    padding: 0.7rem;
    border: 1px solid color-mix(in srgb, var(--accent, #2563eb) 55%, var(--border, #cbd5e1));
    border-radius: 0.7rem;
    background: linear-gradient(135deg, color-mix(in srgb, var(--accent, #2563eb) 15%, var(--bg, #fff)), var(--bg, #fff));
}
.wyldcards-live-audio-header, .wyldcards-live-audio-controls, .wyldcards-live-audio-pulse {
    display: flex;
    align-items: center;
    gap: 0.45rem;
}
.wyldcards-live-audio-header { justify-content: space-between; }
.wyldcards-live-audio-status, .wyldcards-live-audio-bpm, .wyldcards-live-audio-quantize { color: var(--muted-fg, #64748b); font-size: 0.75rem; }
.wyldcards-live-audio-pulse { justify-content: center; }
.wyldcards-live-audio-beat { width: 0.7rem; height: 0.7rem; border: 1px solid var(--border, #cbd5e1); border-radius: 50%; }
.wyldcards-live-audio-beat.is-playing { background: var(--accent, #2563eb); border-color: var(--accent, #2563eb); box-shadow: 0 0 0 0.25rem color-mix(in srgb, var(--accent, #2563eb) 25%, transparent); }
.wyldcards-live-audio-play { margin: 0; padding: 0.25rem 0.65rem; font-size: 0.8rem; }
.wyldcards-live-audio-tempo { width: 4.1rem; min-height: 1.9rem; margin: 0; padding: 0.15rem 0.3rem; font: inherit; font-size: 0.8rem; text-align: center; }
.wyldcards-live-audio-volume { width: min(7rem, 24vw); margin: 0; }
.wyldcards-live-audio-quantize { display: inline-flex; align-items: center; gap: 0.25rem; white-space: nowrap; }
/* Solfège sequencer: movable-do steps, played in the card's key. */
.wyldcards-sequencer {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-height: 0;
    height: 100%;
    padding: 0.65rem;
    border: 1px solid color-mix(in srgb, var(--accent, #2563eb) 40%, var(--border, #cbd5e1));
    border-radius: 0.7rem;
    background: linear-gradient(135deg, color-mix(in srgb, var(--accent, #2563eb) 8%, var(--bg, #fff)), var(--bg, #fff));
    box-sizing: border-box;
}
.wyldcards-sequencer-header,
.wyldcards-sequencer-controls,
.wyldcards-sequencer-palette {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
}
.wyldcards-sequencer-header { justify-content: space-between; }
.wyldcards-sequencer-status { font-size: 0.8rem; color: var(--muted-fg, #64748b); }
.wyldcards-sequencer-status.is-error { color: var(--danger, #b91c1c); }
.wyldcards-sequencer-toggle { display: inline-flex; align-items: center; gap: 0.2rem; font-size: 0.85rem; }
.wyldcards-sequencer-grid {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 0.3rem;
    flex: 1 1 auto;
    min-height: 3rem;
    overflow-y: auto;
    align-content: start;
    padding: 0.15rem;
    border-radius: 0.4rem;
}
.wyldcards-sequencer-grid:focus-visible { outline: 2px solid var(--accent, #2563eb); outline-offset: 2px; }
.wyldcards-sequencer-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 2.6rem;
    padding: 0.2rem 0.1rem;
    border: 1px solid var(--border, #cbd5e1);
    border-radius: 0.45rem;
    background: var(--bg, #fff);
    color: inherit;
    font: inherit;
    cursor: pointer;
    overflow: hidden;
}
.wyldcards-sequencer-step.is-rest { opacity: 0.55; }
.wyldcards-sequencer-step.is-hold { border-style: dotted; background: color-mix(in srgb, var(--accent, #2563eb) 6%, var(--bg, #fff)); }
.wyldcards-sequencer-step.is-hold .wyldcards-sequencer-syllable { color: var(--muted-fg, #64748b); }
.wyldcards-sequencer-step.is-selected { border-color: var(--accent, #2563eb); box-shadow: inset 0 0 0 1px var(--accent, #2563eb); }
.wyldcards-sequencer-step.is-playing { background: var(--accent, #2563eb); border-color: var(--accent, #2563eb); color: var(--accent-fg, #fff); }
.wyldcards-sequencer-syllable { font-size: 0.95rem; line-height: 1.1; }
.wyldcards-sequencer-lyric { font-size: 0.7rem; line-height: 1.1; max-width: 100%; text-overflow: ellipsis; white-space: nowrap; overflow: hidden; }
.wyldcards-sequencer-empty { grid-column: 1 / -1; font-size: 0.85rem; color: var(--muted-fg, #64748b); }
.wyldcards-sequencer-note,
.wyldcards-sequencer-action { min-width: 2.4rem; padding: 0.2rem 0.45rem; font-size: 0.85rem; }
.wyldcards-sequencer-note.is-chromatic { font-size: 0.75rem; opacity: 0.85; }
/* Sing back, karaoke and the hand signs. */
.wyldcards-sequencer [hidden] { display: none !important; }
.wyldcards-sequencer-files { display: inline-flex; gap: 0.3rem; margin-left: auto; }
.wyldcards-sequencer-file { margin: 0; padding: 0.15rem 0.5rem; font-size: 0.8rem; }
.wyldcards-sequencer-mic { margin: 0; padding: 0.2rem 0.55rem; font-size: 0.85rem; }
.wyldcards-sequencer-mic[aria-pressed="true"] { border-color: var(--danger, #b91c1c); color: var(--danger, #b91c1c); }
.wyldcards-sequencer-header,
.wyldcards-sequencer-controls,
.wyldcards-sequencer-palette,
.wyldcards-sequencer-coach { flex: 0 0 auto; }
.wyldcards-sequencer-coach { display: flex; align-items: center; gap: 0.6rem; }
.wyldcards-sequencer-hand { display: flex; flex-direction: column; align-items: center; gap: 0.1rem; margin: 0; padding: 0; border: 0; background: none; flex: 0 0 auto; }
.wyldcards-sequencer-hand img { width: 5.5rem; height: 3.7rem; object-fit: contain; padding: 0.15rem; border-radius: 0.4rem; background: #fff; }
.wyldcards-sequencer-hand figcaption { font-size: 0.75rem; font-weight: 600; }
.wyldcards-sequencer-readout { display: flex; flex-direction: column; gap: 0.3rem; flex: 1 1 auto; min-width: 0; font-size: 0.9rem; }
.wyldcards-sequencer-hold { height: 0.45rem; border-radius: 1rem; background: color-mix(in srgb, var(--border, #cbd5e1) 60%, transparent); overflow: hidden; }
.wyldcards-sequencer-hold span { display: block; width: 0; height: 100%; background: #16a34a; }
.wyldcards-sequencer-hold.is-close span { background: #d97706; }
.wyldcards-sequencer-hold.is-off span { background: var(--danger, #b91c1c); }
.wyldcards-sequencer-step.is-cursor { border-color: var(--accent, #2563eb); border-style: dashed; border-width: 2px; }
.wyldcards-sequencer-step.is-correct { background: color-mix(in srgb, #16a34a 22%, var(--bg, #fff)); }
.wyldcards-sequencer-step.is-close { background: color-mix(in srgb, #d97706 22%, var(--bg, #fff)); }
.wyldcards-sequencer-step.is-wrong { background: color-mix(in srgb, var(--danger, #b91c1c) 20%, var(--bg, #fff)); }
.wyldcards-sequencer-step.is-missed { opacity: 0.6; text-decoration: line-through; }
.wyldcards-sequencer-step.is-playing.is-correct,
.wyldcards-sequencer-step.is-playing.is-close,
.wyldcards-sequencer-step.is-playing.is-wrong { background: var(--accent, #2563eb); }
@media (prefers-reduced-motion: no-preference) {
    .wyldcards-sequencer-step { transition: background-color 80ms linear, color 80ms linear; }
}
/* Ear trainer: the Solfege app's drills, answered from four names. */
.wyldcards-ear {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    min-height: 0;
    height: 100%;
    padding: 0.65rem;
    border: 1px solid color-mix(in srgb, var(--accent, #2563eb) 40%, var(--border, #cbd5e1));
    border-radius: 0.7rem;
    background: linear-gradient(135deg, color-mix(in srgb, var(--accent, #2563eb) 8%, var(--bg, #fff)), var(--bg, #fff));
    box-sizing: border-box;
    overflow-y: auto;
}
.wyldcards-ear-header,
.wyldcards-ear-controls,
.wyldcards-ear-dictation {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
}
.wyldcards-ear-header select { margin: 0; width: auto; min-height: 2rem; padding: 0.15rem 0.4rem; font-size: 0.9rem; }
.wyldcards-ear-progress-toggle, .wyldcards-ear-progress-reset { margin: 0; padding: 0.2rem 0.55rem; font-size: 0.85rem; }
.wyldcards-ear [hidden] { display: none !important; }
.wyldcards-ear-progress { display: flex; flex-direction: column; gap: 0.35rem; padding: 0.5rem; border: 1px solid var(--border, #cbd5e1); border-radius: 0.5rem; font-size: 0.85rem; }
.wyldcards-ear-progress p { margin: 0; }
.wyldcards-ear-progress-row { display: flex; flex-wrap: wrap; gap: 0.15rem 0.6rem; align-items: baseline; }
.wyldcards-ear-progress-rate { font-variant-numeric: tabular-nums; }
.wyldcards-ear-progress-weak { flex-basis: 100%; color: var(--muted-fg, #64748b); }
.wyldcards-ear-progress-reset { align-self: flex-start; }
.wyldcards-ear-score { margin-left: auto; font-size: 0.8rem; color: var(--muted-fg, #64748b); font-variant-numeric: tabular-nums; }
.wyldcards-ear-controls button,
.wyldcards-ear-dictation button { margin: 0; padding: 0.3rem 0.7rem; font-size: 0.9rem; }
.wyldcards-ear-prompt { font-size: 0.95rem; font-weight: 600; }
.wyldcards-ear-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.4rem; }
.wyldcards-ear-choice { margin: 0; min-height: 2.6rem; padding: 0.3rem 0.5rem; font-size: 1rem; }
.wyldcards-ear-choice.is-answer { background: color-mix(in srgb, #16a34a 18%, var(--bg, #fff)); border-color: #16a34a; color: inherit; opacity: 1; }
.wyldcards-ear-choice.is-wrong { background: color-mix(in srgb, var(--danger, #b91c1c) 14%, var(--bg, #fff)); border-color: var(--danger, #b91c1c); color: inherit; opacity: 1; }
.wyldcards-ear-written { flex: 1 1 10rem; margin: 0; min-height: 2rem; font-family: var(--mono-font, ui-monospace, monospace); }
.wyldcards-ear-feedback { font-size: 0.88rem; }
.wyldcards-ear-feedback p { margin: 0 0 0.15rem; }
.wyldcards-ear-feedback.is-right p:first-child { color: #15803d; font-weight: 600; }
.wyldcards-ear-feedback.is-wrong p:first-child { color: var(--danger, #b91c1c); font-weight: 600; }

.wyldcards-beat-builder {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    min-height: 0;
    padding: 0.65rem;
    border: 1px solid color-mix(in srgb, var(--accent, #2563eb) 40%, var(--border, #cbd5e1));
    border-radius: 0.7rem;
    background: linear-gradient(135deg, color-mix(in srgb, var(--accent, #2563eb) 10%, var(--bg, #fff)), var(--bg, #fff));
}
.wyldcards-beat-builder-header,
.wyldcards-beat-builder-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}
.wyldcards-beat-builder-title { font-size: 0.85rem; }
.wyldcards-beat-builder-status,
.wyldcards-beat-builder-tempo-label { color: var(--muted-fg, #64748b); font-size: 0.72rem; }
.wyldcards-beat-builder-grid { display: grid; gap: 0.28rem; }
.wyldcards-beat-builder-row {
    display: grid;
    grid-template-columns: minmax(2.4rem, 0.8fr) repeat(16, minmax(0, 1fr));
    gap: 0.2rem;
    align-items: center;
}
.wyldcards-beat-builder-track { color: var(--muted-fg, #64748b); font-size: 0.68rem; font-weight: 700; }
.wyldcards-beat-builder-step {
    min-width: 0;
    aspect-ratio: 1;
    min-height: 1rem;
    margin: 0;
    padding: 0;
    border: 1px solid var(--border, #cbd5e1);
    border-radius: 0.2rem;
    background: color-mix(in srgb, var(--bg, #fff) 88%, #94a3b8);
}
.wyldcards-beat-builder-step:nth-child(4n + 2) { border-left-color: var(--accent, #2563eb); }
.wyldcards-beat-builder-step.is-active { border-color: var(--accent, #2563eb); background: var(--accent, #2563eb); }
.wyldcards-beat-builder-step.is-playing { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent, #2563eb) 50%, transparent); }
.wyldcards-beat-builder-play { margin: 0; padding: 0.25rem 0.65rem; font-size: 0.8rem; }
.wyldcards-beat-builder-tempo {
    width: 4.2rem;
    min-height: 1.9rem;
    margin: 0 0 0 auto;
    padding: 0.15rem 0.3rem;
    font: inherit;
    font-size: 0.8rem;
    text-align: center;
}
.wyldcards-solfege-grid {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-height: 0;
    padding: 0.6rem;
    overflow: auto;
    border: 1px solid color-mix(in srgb, var(--accent, #2563eb) 40%, var(--border, #cbd5e1));
    border-radius: 0.7rem;
    background: linear-gradient(135deg, color-mix(in srgb, var(--accent, #2563eb) 10%, var(--bg, #fff)), var(--bg, #fff));
}
.wyldcards-solfege-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}
.wyldcards-solfege-key {
    margin: 0;
    padding: 0.2rem 0.6rem;
    border: 1px solid var(--border, #cbd5e1);
    border-radius: 0.4rem;
    background: var(--bg, #fff);
    font-size: 0.78rem;
    font-weight: 700;
    white-space: nowrap;
}
.wyldcards-solfege-status { color: var(--muted-fg, #64748b); font-size: 0.72rem; }
.wyldcards-solfege-steps {
    display: flex;
    flex-wrap: wrap;
    gap: 0.22rem;
    align-content: flex-start;
    min-height: 2.2rem;
}
.wyldcards-solfege-step {
    min-width: 2.6rem;
    min-height: 1.9rem;
    margin: 0;
    padding: 0.1rem 0.3rem;
    border: 1px solid var(--border, #cbd5e1);
    border-radius: 0.25rem;
    background: color-mix(in srgb, var(--bg, #fff) 88%, #94a3b8);
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1;
}
.wyldcards-solfege-step--rest { color: var(--muted-fg, #64748b); font-weight: 400; }
.wyldcards-solfege-step--caret {
    min-width: 1.7rem;
    border-style: dashed;
    background: transparent;
    color: var(--muted-fg, #64748b);
}
.wyldcards-solfege-step.is-selected {
    border-color: var(--accent, #2563eb);
    box-shadow: inset 0 0 0 1px var(--accent, #2563eb);
}
.wyldcards-solfege-step.is-playing {
    border-color: var(--accent, #2563eb);
    background: var(--accent, #2563eb);
    color: var(--accent-fg, #fff);
}
.wyldcards-solfege-empty { color: var(--muted-fg, #64748b); font-size: 0.75rem; }
.wyldcards-solfege-pads {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.22rem;
}
.wyldcards-solfege-pad {
    min-width: 0;
    min-height: 2rem;
    margin: 0;
    padding: 0.15rem 0.25rem;
    border: 1px solid color-mix(in srgb, var(--accent, #2563eb) 30%, var(--border, #cbd5e1));
    border-radius: 0.3rem;
    background: var(--bg, #fff);
    font-size: 0.76rem;
    font-weight: 700;
    line-height: 1;
}
.wyldcards-solfege-pad--tonic { background: color-mix(in srgb, var(--accent, #2563eb) 16%, var(--bg, #fff)); }
.wyldcards-solfege-pad--rest { color: var(--muted-fg, #64748b); font-weight: 400; }
.wyldcards-solfege-controls { display: flex; align-items: center; gap: 0.35rem; }
.wyldcards-solfege-play,
.wyldcards-solfege-loop,
.wyldcards-solfege-erase { margin: 0; padding: 0.25rem 0.6rem; font-size: 0.78rem; }
.wyldcards-solfege-loop.is-active {
    border-color: var(--accent, #2563eb);
    background: var(--accent, #2563eb);
    color: var(--accent-fg, #fff);
}
.wyldcards-solfege-tempo {
    width: 4.2rem;
    min-height: 1.9rem;
    margin: 0 0 0 auto;
    padding: 0.15rem 0.3rem;
    font: inherit;
    font-size: 0.78rem;
    text-align: center;
}
.wyldcards-solfege-tempo-label { color: var(--muted-fg, #64748b); font-size: 0.72rem; }
.wyldcards-drone {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--border, #cbd5e1);
    border-radius: 0.6rem;
}
.wyldcards-drone--on { border-color: var(--accent, #2563eb); background: color-mix(in srgb, var(--accent, #2563eb) 10%, var(--bg, #fff)); }
.wyldcards-drone-readout { display: flex; flex-direction: column; min-width: 0; }
.wyldcards-drone-note { font-size: 0.95rem; line-height: 1.1; }
.wyldcards-drone-detail { color: var(--muted-fg, #64748b); font-size: 0.7rem; }
.wyldcards-drone-toggle { margin: 0 0 0 auto; padding: 0.25rem 0.65rem; font-size: 0.78rem; white-space: nowrap; }
.wyldcards-drone-volume { width: min(6rem, 22vw); margin: 0; }
.wyldcards-countdown {
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 8px;
}
.wyldcards-countdown-label {
    color: var(--muted-fg, #64748b);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.wyldcards-countdown-readout {
    font-size: clamp(1.5rem, 8vw, 2.5rem);
    line-height: 1;
    font-variant-numeric: tabular-nums;
}
.wyldcards-countdown-duration {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--muted-fg, #64748b);
    font-size: 0.8rem;
}
.wyldcards-countdown-duration-input {
    width: 5.5rem;
    min-height: 2.1rem;
    margin: 0;
    padding: 0.2rem 0.35rem;
    font: inherit;
    font-variant-numeric: tabular-nums;
}
.wyldcards-countdown-controls {
    display: flex;
    gap: 0.35rem;
}
.wyldcards-countdown-toggle,
.wyldcards-countdown-reset {
    margin: 0;
    padding: 0.25rem 0.65rem;
    font-size: 0.85rem;
}
.wyldcards-countdown--running {
    border-color: var(--accent, #2563eb);
}
.wyldcards-countdown--complete {
    border-color: #dc2626;
    color: #b91c1c;
}
.wyldcards-quicktips {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.5rem;
    min-height: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent, #2563eb);
    border-radius: 8px;
    background: color-mix(in srgb, var(--accent, #2563eb) 7%, transparent);
}
.wyldcards-quicktips-title {
    color: var(--muted-fg, #64748b);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.wyldcards-quicktips-tip {
    margin: 0;
    line-height: 1.4;
}
.wyldcards-quicktips-controls {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}
.wyldcards-quicktips-button {
    margin: 0;
    padding: 0.25rem 0.55rem;
    font-size: 0.8rem;
}
.wyldcards-audio-levels {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.55rem;
    min-height: 100%;
    padding: 0.65rem;
    border: 1px solid var(--border);
    border-radius: 8px;
}
.wyldcards-audio-levels-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
}
.wyldcards-audio-levels-label { font-size: 0.85rem; }
.wyldcards-audio-levels-readout {
    color: var(--muted-fg, #64748b);
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
}
.wyldcards-audio-levels-meter {
    position: relative;
    height: 1rem;
    overflow: hidden;
    border: 1px solid var(--border, #cbd5e1);
    border-radius: 999px;
    background: color-mix(in srgb, var(--bg, #fff) 88%, #94a3b8);
}
.wyldcards-audio-levels-fill {
    display: block;
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, #22c55e 0%, #eab308 72%, #ef4444 100%);
    transition: width 50ms linear;
}
.wyldcards-audio-levels-peak {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 2px;
    background: var(--fg, #0f172a);
}
.wyldcards-audio-levels-toggle {
    align-self: flex-start;
    margin: 0;
    padding: 0.3rem 0.65rem;
    font-size: 0.8rem;
}
.wyldcards-audio-levels--monitoring { border-color: var(--accent, #2563eb); }
.wyldcards-microphone-feed {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.55rem;
    min-height: 100%;
    padding: 0.65rem;
    border: 1px solid var(--border);
    border-radius: 8px;
}
.wyldcards-microphone-feed-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
}
.wyldcards-microphone-feed-label { font-size: 0.85rem; }
.wyldcards-microphone-feed-status {
    color: var(--muted-fg, #64748b);
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
}
.wyldcards-microphone-feed-waveform {
    width: 100%;
    height: 4rem;
    border: 1px solid var(--border, #cbd5e1);
    border-radius: 5px;
    background: color-mix(in srgb, var(--bg, #fff) 88%, #94a3b8);
}
.wyldcards-microphone-feed-toggle {
    align-self: flex-start;
    margin: 0;
    padding: 0.3rem 0.65rem;
    font-size: 0.8rem;
}
.wyldcards-microphone-feed--live { border-color: var(--accent, #2563eb); }
.wyldcards-three-d {
    display: flex;
    flex-direction: column;
    min-height: 100%;
    padding: 0.55rem;
    border: 1px solid var(--border, #cbd5e1);
    border-radius: 8px;
    background: radial-gradient(circle at 50% 35%, color-mix(in srgb, var(--accent, #2563eb) 15%, transparent), transparent 65%);
}
.wyldcards-three-d-canvas {
    flex: 1 1 auto;
    min-height: 5rem;
    width: 100%;
    touch-action: none;
    cursor: grab;
}
.wyldcards-three-d-canvas:active { cursor: grabbing; }
.wyldcards-three-d-controls {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}
.wyldcards-three-d-button {
    margin: 0;
    padding: 0.25rem 0.55rem;
    font-size: 0.75rem;
}
.wyldcards-three-d-status {
    margin-top: 0.3rem;
    color: var(--muted-fg, #64748b);
    font-size: 0.75rem;
}
.wyldcards-sing {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 8px;
}
.wyldcards-sing-readout {
    display: flex;
    flex-direction: column;
    min-width: 9rem;
    text-align: center;
}
.wyldcards-sing-note {
    font-size: 1.35rem;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}
.wyldcards-sing-solfege {
    color: var(--muted-fg, #64748b);
    font-size: 0.75rem;
}
.wyldcards-sing-toggle {
    margin: 0;
    padding: 0.35rem 0.75rem;
}
.wyldcards-sing--listening {
    border-color: var(--accent, #2563eb);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent, #2563eb) 18%, transparent);
}
.wyldcards-midi {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    min-height: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 8px;
}
.wyldcards-midi-status {
    min-width: 0;
    overflow: hidden;
    color: var(--muted-fg, #64748b);
    font-size: 0.75rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.wyldcards-midi-toggle { margin: 0; padding: 0.35rem 0.75rem; }
.wyldcards-camera {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.5rem;
    min-height: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 8px;
}
.wyldcards-camera-preview {
    display: grid;
    min-height: 5rem;
    overflow: hidden;
    border-radius: 5px;
    background: #111827;
}
.wyldcards-camera-video,
.wyldcards-camera-photo {
    grid-area: 1 / 1;
    width: 100%;
    max-height: 100%;
    object-fit: contain;
}
.wyldcards-camera-controls {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}
.wyldcards-camera-start,
.wyldcards-camera-capture,
.wyldcards-camera-retake {
    margin: 0;
    padding: 0.25rem 0.55rem;
    font-size: 0.8rem;
}
.wyldcards-camera-status {
    color: var(--muted-fg, #64748b);
    font-size: 0.75rem;
}
.wyldcards-webcam-feed {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.5rem;
    min-height: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 8px;
}
.wyldcards-webcam-feed-preview {
    display: grid;
    flex: 1 1 auto;
    min-height: 0;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border-radius: 5px;
    background: #111827;
}
.wyldcards-webcam-feed-video {
    grid-area: 1 / 1;
    flex: 1 1 auto;
    width: 100%;
    min-height: 0;
    height: 100%;
    object-fit: cover;
}
.wyldcards-webcam-feed-empty {
    grid-area: 1 / 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    padding: 1rem;
    color: #cbd5e1;
    text-align: center;
}
.wyldcards-webcam-feed-empty strong {
    color: #f8fafc;
    font-size: 0.9rem;
}
.wyldcards-webcam-feed-empty span {
    font-size: 0.75rem;
}
.wyldcards-webcam-feed-controls {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}
.wyldcards-webcam-feed-toggle {
    margin: 0;
    padding: 0.25rem 0.55rem;
    font-size: 0.8rem;
}
.wyldcards-webcam-feed-flip {
    margin: 0;
    padding: 0.25rem 0.55rem;
    font-size: 0.8rem;
}
.wyldcards-webcam-feed-status {
    color: var(--muted-fg, #64748b);
    font-size: 0.75rem;
}
@media (prefers-reduced-motion: reduce) {
    .wyldcards-piano-key {
        transition: none;
    }
}

/* ---- Small screens ---------------------------------------------------- */
@media (max-width: 800px) {
    .wyldcards-browser-navigator {
        top: 3.1rem;
        width: min(14rem, 80vw);
    }
    .wyldcards-outline-sidebar {
        top: 3.1rem;
        width: min(22rem, 80vw);
    }
    main.wyldcards-card-page:has(.wyldcards-browser-navigator:not([hidden])) .wyldcards-editbar,
    main.wyldcards-card-page:has(.wyldcards-browser-navigator:not([hidden])) .wyldcards-part-picker,
    main.wyldcards-card-page:has(.wyldcards-browser-navigator:not([hidden])) .wyldcards-workbench {
        margin-left: min(14rem, 80vw);
    }
    main.wyldcards-card-page:has(.wyldcards-outline-sidebar:not([hidden])) .wyldcards-workbench {
        margin-left: min(22rem, 80vw);
    }
    .wyldcards-present-mode main.wyldcards-card-page {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto auto minmax(0, 1fr);
    }
    .wyldcards-present-mode .wyldcards-present-navigator {
        grid-column: 1;
        grid-row: 2;
        flex-direction: row;
        align-items: stretch;
        min-height: 5.9rem;
        padding: 0.7rem 1rem;
        overflow-x: auto;
        overflow-y: hidden;
        border-right: 0;
        border-bottom: 1px solid #30343d;
    }
    .wyldcards-present-mode .wyldcards-workbench {
        grid-column: 1;
        grid-row: 3;
    }
    .wyldcards-workbench {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: minmax(20rem, 1fr) minmax(15rem, 50vh);
        overflow: auto;
    }
    .wyldcards-side {
        border-inline-start: 0;
        border-top: 1px solid var(--border);
        min-height: 0;
    }
    .wyldcards-editbar {
        gap: 0.5rem;
        padding: 0.5rem 0.75rem;
    }
    .wyldcards-editbar-group {
        padding-right: 0.5rem;
    }
    .wyldcards-stage {
        padding: 0.75rem;
        min-height: 0;
    }
    .wyldcards-toolbar-title {
        display: none;
    }
    .wyldcards-toolbar {
        padding-right: 1rem;
        padding-top: 3rem;
    }
    .wyldcards-stack-only .wyldcards-toolbar {
        padding-top: 0.5rem;
    }
    .wyldcards-stack-view-title {
        max-width: 42vw;
    }
    .wyldcards-stack-scroll {
        align-items: flex-start;
        padding: 0.75rem;
        overflow-x: auto;
    }
}
@media (max-width: 520px) {
    .wyldcards-editbar-group {
        width: 100%;
        padding: 0 0 0.5rem;
        border-right: 0;
        border-bottom: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
    }
    .wyldcards-editbar-group--end {
        padding-bottom: 0;
        border-bottom: 0;
    }
    .wyldcards-editbar-btn {
        flex: 1 0 auto;
        text-align: center;
    }
    .wyldcards-card-name-label {
        flex: 1 1 100%;
    }
    .wyldcards-card-name {
        flex: 1 1 auto;
        width: auto;
    }
    .wyldcards-editbar-toggle {
        margin-left: 0;
    }
    .wyldcards-inspector-rect {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* On a phone, controls inside a part are for editing, not a small target that
   accidentally drags the part away. The label becomes the deliberate move
   handle and the corner grows to a thumb-sized resize handle. */
@media (pointer: coarse) and (max-width: 800px) {
    .wyldcards-mode-edit .part-name-tag {
        display: inline-flex;
        align-items: center;
        min-height: 2rem;
        padding: 0.35rem 0.55rem;
        font-size: 0.75rem;
        opacity: 1;
        pointer-events: auto;
        cursor: grab;
        touch-action: none;
    }
    .wyldcards-mode-edit .part-name-tag:active {
        cursor: grabbing;
    }
    .wyldcards-mode-edit .part-handle {
        right: -12px;
        bottom: -12px;
        width: 24px;
        height: 24px;
        opacity: 1;
        touch-action: none;
    }
}

/* Keep card tools reachable without making the canvas wait behind a stack of
   full-width button rows. Each group remains intact and can be swiped across. */
@media (max-width: 640px) {
    .wyldcards-mode-edit .wyldcards-editbar {
        flex-wrap: nowrap;
        align-items: stretch;
        gap: 0.5rem;
        overflow-x: auto;
        overscroll-behavior-x: contain;
        padding: 0.5rem max(0.75rem, env(safe-area-inset-left)) 0.6rem;
        scrollbar-width: thin;
    }
    /* The horizontal scroller otherwise clips the Field and Layout menus. */
    .wyldcards-mode-edit .wyldcards-editbar:has(.wyldcards-new-card-menu[open]) {
        overflow: visible;
    }
    .wyldcards-mode-edit .wyldcards-editbar-group,
    .wyldcards-mode-edit .wyldcards-editbar-group--end {
        width: auto;
        flex: 0 0 auto;
        flex-wrap: nowrap;
        padding: 0 0.5rem 0 0;
        margin: 0;
        border: 0;
        border-right: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
    }
    .wyldcards-mode-edit .wyldcards-editbar-group--end {
        border-right: 0;
    }
    .wyldcards-mode-edit .wyldcards-editbar-btn {
        flex: 0 0 auto;
        min-height: 2.5rem;
        padding-inline: 0.7rem;
    }
    .wyldcards-new-card-options {
        position: fixed;
        left: max(0.75rem, env(safe-area-inset-left));
        right: max(0.75rem, env(safe-area-inset-right));
        top: auto;
        bottom: max(0.75rem, env(safe-area-inset-bottom));
        width: auto;
    }
    .wyldcards-new-card-options button {
        min-height: 2.75rem;
    }
    .wyldcards-mode-edit .wyldcards-editbar-toggle {
        flex: 0 0 auto;
        min-height: 2.5rem;
        white-space: nowrap;
    }
    .wyldcards-mode-edit .wyldcards-editbar-label {
        display: none;
    }
    .wyldcards-mode-edit .wyldcards-part-picker {
        margin: 0;
        padding: 0.6rem 0.75rem;
        border-bottom: 1px solid var(--border);
    }
    .wyldcards-mode-edit .wyldcards-part-picker label,
    .wyldcards-mode-edit .wyldcards-part-picker .muted {
        display: none;
    }
    .wyldcards-mode-edit .wyldcards-part-picker select {
        width: 100%;
        min-height: 2.5rem;
    }
}

/* The editor is a workspace, not a document. Keep its tools and canvas inside
   the visible app window so editing a part never scrolls the page chrome away. */
html.app-shell body.app-shell-editor main.wyldcards-card-page {
    min-height: calc(100dvh - var(--app-bar-height) - var(--app-safe-top));
    height: calc(100dvh - var(--app-bar-height) - var(--app-safe-top));
}

html.app-shell body.app-shell-editor .wyldcards-toolbar {
    top: calc(var(--app-bar-height) + var(--app-safe-top));
}

@media (max-width: 800px) {
    .wyldcards-workbench {
        /* The stage and inspector each own their scrolling; the parent should
           not create a third scroll surface between them. */
        overflow: hidden;
        grid-template-rows: minmax(18rem, 1fr) minmax(14rem, 42vh);
    }

    .wyldcards-side {
        padding: 0.9rem max(0.9rem, env(safe-area-inset-right)) 1.1rem max(0.9rem, env(safe-area-inset-left));
        -webkit-overflow-scrolling: touch;
    }

    .wyldcards-side-hint {
        padding: 0.7rem 0.8rem;
    }
}

@media (pointer: coarse) and (max-width: 640px) {
    .wyldcards-mode-edit .wyldcards-editbar {
        scroll-snap-type: x proximity;
        -webkit-overflow-scrolling: touch;
    }

    .wyldcards-mode-edit .wyldcards-editbar-group {
        scroll-snap-align: start;
    }

    .wyldcards-inspector-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .wyldcards-inspector-actions button,
    .wyldcards-inspector-actions .wyldcards-inspector-help {
        min-height: 2.75rem;
        margin: 0;
    }

    .wyldcards-inspector-actions button[type="submit"] {
        grid-column: 1 / -1;
    }

    .wyldcards-inspector-help {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 0.3rem 0.7rem;
        border: 1px solid var(--border);
        border-radius: var(--border-radius, 4px);
        text-decoration: none;
    }
}

/* ---------- Recordings kept with a card ---------- */
/* The display rules below would otherwise beat the hidden attribute the
   script toggles the controls with. */
.card-audio [hidden] {
    display: none !important;
}
.card-audio {
    width: 100%;
    height: 100%;
    overflow: auto;
    border: 1px solid color-mix(in srgb, var(--border) 80%, var(--accent, #6d5dfc));
    border-radius: 10px;
    background: linear-gradient(135deg, color-mix(in srgb, var(--accent-bg, #f1f5f9) 86%, transparent), color-mix(in srgb, var(--plain-bg, #fff) 75%, transparent));
    padding: 0.75rem;
    font-size: 0.9rem;
}
.card-audio-summary {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}
.card-audio-summary::before {
    content: "♪";
    display: inline-block;
    color: var(--accent, #6d5dfc);
    font-size: 1.25rem;
    line-height: 1;
}
.card-audio-count {
    font-weight: 400;
    font-size: 0.85rem;
}
.card-jukebox {
    margin-top: 0.7rem;
    padding: 0.8rem;
    border: 1px solid color-mix(in srgb, var(--border) 75%, transparent);
    border-radius: 8px;
    background: color-mix(in srgb, var(--plain-bg, #fff) 88%, var(--accent-bg, #f1f5f9));
}
.card-jukebox-now-playing { display: flex; flex-direction: column; gap: 0.15rem; margin-bottom: 0.7rem; }
.card-jukebox-kicker { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.card-jukebox-now-playing strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 1.05rem; }
.card-jukebox-controls, .card-jukebox-progress, .card-jukebox-volume, .card-jukebox-transport, .card-jukebox-options { display: flex; align-items: center; gap: 0.4rem; }
.card-jukebox-controls { justify-content: space-between; flex-wrap: wrap; gap: 0.55rem; }
.card-jukebox-transport { flex: 1 1 auto; }
.card-jukebox-options { flex: 0 1 auto; flex-wrap: wrap; }
.card-jukebox-progress { margin-top: 0.7rem; font-variant-numeric: tabular-nums; font-size: 0.8rem; color: var(--muted-fg, #64748b); }
.card-jukebox-progress input { flex: 1; min-width: 4rem; accent-color: var(--accent, #6d5dfc); }
.card-jukebox-volume { margin-top: 0.55rem; font-size: 0.8rem; color: var(--muted-fg, #64748b); }
.card-jukebox-volume input { width: clamp(4rem, 24vw, 7rem); accent-color: var(--accent, #6d5dfc); }
.card-audio-list {
    list-style: none;
    margin: 0.5rem 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}
.card-audio-item {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 0.5rem 0.6rem;
    border: 1px solid color-mix(in srgb, var(--border) 75%, transparent);
    border-radius: 8px;
    background: var(--accent-bg, transparent);
    transition: border-color 150ms ease, box-shadow 150ms ease, background-color 150ms ease;
}
.card-audio-item--active {
    border-color: color-mix(in srgb, var(--accent, #6d5dfc) 62%, var(--border));
    background: color-mix(in srgb, var(--accent-bg, #f1f5f9) 78%, var(--plain-bg, #fff));
    box-shadow: inset 3px 0 0 var(--accent, #6d5dfc);
}
.card-audio-item-head {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.card-audio-title {
    font-weight: 600;
    overflow-wrap: anywhere;
}
.card-audio-meta {
    font-size: 0.85rem;
}
.card-audio-player {
    width: 100%;
    max-width: 30rem;
}
/* Control groups sit in an inline-flex wrapper: missing.css does not line up
   inline blocks by itself. */
.card-audio-item-actions,
.card-audio-actions,
.card-audio-recording {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    vertical-align: middle;
}
.card-audio-actions {
    margin-top: 0.75rem;
}
.card-audio-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.25rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: inherit;
    font: inherit;
    font-size: 0.85rem;
    line-height: 1.4;
    cursor: pointer;
    text-decoration: none;
}
.card-audio-btn--primary {
    min-width: 4.7rem;
    justify-content: center;
    border-color: var(--accent, #6d5dfc);
    background: var(--accent, #6d5dfc);
    color: var(--accent-contrast, #fff);
    font-weight: 700;
}
.card-audio-btn--primary:hover { background: color-mix(in srgb, var(--accent, #6d5dfc) 86%, #000); }
.card-audio-btn--icon { min-width: 2.4rem; justify-content: center; }
.card-audio-btn[aria-pressed="true"] {
    border-color: color-mix(in srgb, var(--accent, #6d5dfc) 55%, var(--border));
    background: color-mix(in srgb, var(--accent, #6d5dfc) 14%, transparent);
    color: var(--fg, inherit);
}
.card-audio-btn:hover,
.card-audio-add:hover .card-audio-add-label,
.card-audio-add:focus-within .card-audio-add-label {
    background-color: color-mix(in srgb, var(--fg, #0f172a) 6%, transparent);
}
.card-audio-btn--danger {
    color: #b91c1c;
    border-color: color-mix(in srgb, #b91c1c 40%, transparent);
}
.card-audio-btn--quiet {
    color: var(--muted-fg, #64748b);
}
.card-audio-add {
    display: inline-flex;
    cursor: pointer;
}
.card-audio-record-dot,
.card-audio-recording-dot {
    display: inline-block;
    width: 0.6rem;
    height: 0.6rem;
    border-radius: 50%;
    background: #dc2626;
}
.card-audio-recording-dot {
    animation: card-audio-pulse 1s ease-in-out infinite;
}
.card-audio-recording-time {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    min-width: 3ch;
}
@keyframes card-audio-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.25; }
}
@media (prefers-reduced-motion: reduce) {
    .card-audio-recording-dot { animation: none; }
    .card-audio-item { transition: none; }
}
.card-audio-empty,
.card-audio-progress {
    font-size: 0.85rem;
    margin: 0.5rem 0 0;
}
.card-audio-error {
    margin: 0.5rem 0 0;
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    font-size: 0.85rem;
    color: #b91c1c;
    background: color-mix(in srgb, #b91c1c 8%, transparent);
}
@media (max-width: 480px) {
    .card-audio { padding: 0.6rem; }
    .card-jukebox-controls { align-items: stretch; flex-direction: column; }
    .card-jukebox-transport, .card-jukebox-options { width: 100%; }
    .card-jukebox-options .card-audio-btn { flex: 1 1 0; justify-content: center; }
    .card-jukebox-volume { flex-wrap: wrap; }
    .card-jukebox-volume input { flex: 1 1 6rem; }
}

/* Find
   The bar over a card (⌘F) and the results page. Both lean on the list styles
   already here — .user-list-panel, .user-list-table, .user-role-chip — so a hit
   row reads like a card row, which is what it leads to. */
.wyldcards-findbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
    background: var(--accent-bg);
}
.wyldcards-findbar[hidden] { display: none; }
.wyldcards-findbar-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted);
}
.wyldcards-findbar-input {
    flex: 1 1 12rem;
    min-width: 8rem;
    padding: 0.3rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--text);
}
.wyldcards-findbar-count {
    font-size: 0.8rem;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
    min-width: 6ch;
}
.wyldcards-findbar-btn {
    padding: 0.2rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--text);
    cursor: pointer;
    line-height: 1.4;
}
.wyldcards-findbar-btn:disabled { opacity: 0.4; cursor: default; }
.wyldcards-findbar-btn--close { margin-left: auto; }
/* The hit list is its own scroller: a hundred matches must not push the card
   itself off the screen. */
.wyldcards-find-results {
    flex: 1 0 100%;
    max-height: 40vh;
    overflow-y: auto;
}
.wyldcards-find-list {
    list-style: none;
    margin: 0.25rem 0 0;
    padding: 0;
}
.wyldcards-find-hit + .wyldcards-find-hit { border-top: 1px solid var(--border); }
.wyldcards-find-hit-link {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
    padding: 0.35rem 0.25rem;
    text-decoration: none;
    color: inherit;
}
.wyldcards-find-hit-link:hover,
.wyldcards-find-hit-link:focus-visible { background: var(--accent-bg); }
.wyldcards-find-hit-n {
    font-variant-numeric: tabular-nums;
    font-size: 0.8rem;
    color: var(--muted);
    min-width: 2ch;
    text-align: right;
}
.wyldcards-find-hit-body {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.4rem;
    min-width: 0;
}
.wyldcards-find-hit-title { font-weight: 600; }

/* Spreadsheet-oriented stack data, deliberately separate from the card editor. */
.data-workspace {
    min-height: calc(100vh - 4rem);
    background: var(--bg);
    color: var(--text);
}
.data-workspace-header,
.data-workspace-viewbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem clamp(1rem, 3vw, 2.25rem);
    border-bottom: 1px solid var(--border);
}
.data-workspace-header { justify-content: space-between; }
.data-workspace-header h1 { display: inline; margin: 0 0 0 0.65rem; font-size: 1.1rem; }
.data-workspace-back { color: var(--muted); font-size: 0.86rem; text-decoration: none; }
.data-workspace-back:hover { color: var(--text); text-decoration: underline; }
.data-workspace-add { margin: 0; background: var(--accent); color: var(--accent-contrast, #fff); }
.data-workspace-viewbar { min-height: 3.25rem; background: color-mix(in srgb, var(--accent-bg) 55%, var(--bg)); }
.data-workspace-count { color: var(--muted); font-size: 0.82rem; }
.data-workspace-options { position: relative; }
.data-workspace-options summary { cursor: pointer; color: var(--muted); font-size: 0.88rem; }
.data-workspace-options form {
    position: absolute;
    z-index: 2;
    top: 1.7rem;
    left: 0;
    display: grid;
    gap: 0.6rem;
    min-width: 16rem;
    padding: 0.85rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--bg);
    box-shadow: 0 0.7rem 1.5rem rgb(0 0 0 / 15%);
}
.data-workspace-options label { display: grid; gap: 0.2rem; font-size: 0.82rem; }
.data-workspace-options label:has(input[type="checkbox"]) { display: flex; align-items: center; gap: 0.45rem; }
.data-workspace-grid { overflow: hidden; }
.data-workspace-keyboard-help { margin: 0; padding: 0.35rem 0.75rem; border-bottom: 1px solid var(--border); color: var(--muted); font-size: 0.78rem; }
.data-workspace-grid .table-scroll { margin: 0; max-height: calc(100vh - 10.5rem); }
.data-workspace-table { width: 100%; min-width: 42rem; border-collapse: separate; border-spacing: 0; }
.data-workspace-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 0.65rem 0.75rem;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 600;
    text-align: left;
    white-space: nowrap;
}
.data-workspace-table td { min-width: 10rem; padding: 0; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.data-workspace-table input { width: 100%; min-width: 0; margin: 0; padding: 0.55rem 0.7rem; border: 0; border-radius: 0; background: transparent; color: var(--text); box-shadow: none; }
.data-workspace-table input:focus { outline: 2px solid var(--accent); outline-offset: -2px; background: var(--accent-bg); }
.data-workspace-row-number { width: 3.25rem; min-width: 3.25rem !important; color: var(--muted); font-size: 0.78rem; text-align: center !important; }
.data-workspace-table td.data-workspace-row-number { padding: 0.55rem; }
.data-workspace-primary { display: flex; align-items: center; min-width: 15rem !important; font-weight: 600; }
.data-workspace-primary a { padding: 0.35rem 0.6rem; color: var(--muted); text-decoration: none; }
.data-workspace-primary a:hover { color: var(--accent); }
.data-workspace-field-type { display: inline-block; margin-right: 0.35rem; color: var(--accent); font-size: 0.7rem; font-weight: 700; }
.data-workspace-new-row td { padding: 0.35rem 0.65rem; background: color-mix(in srgb, var(--accent-bg) 45%, var(--bg)); }
.data-workspace-new-row button { margin: 0; padding: 0.25rem 0; border: 0; background: transparent; color: var(--muted); font-size: 0.85rem; }
.data-workspace-new-row button:hover { color: var(--accent); }
@media (max-width: 640px) {
    .data-workspace-header, .data-workspace-viewbar { padding-inline: 0.85rem; }
    .data-workspace-viewbar { align-items: flex-start; flex-wrap: wrap; }
    .data-workspace-grid .table-scroll { max-height: calc(100vh - 13rem); }
}
/* One line, clipped: a snippet that wrapped would set the row height by how the
   text it came from happened to be broken. */
.wyldcards-find-hit-mark {
    padding: 0 0.1em;
    border-radius: 0.2em;
    color: inherit;
    background: color-mix(in srgb, var(--accent, #2563eb) 28%, transparent);
    font-weight: 600;
}
.wyldcards-find-hit-snippet {
    color: var(--muted);
    font-size: 0.85rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}
.wyldcards-find-empty,
.wyldcards-find-capped {
    margin: 0.35rem 0 0;
    font-size: 0.85rem;
    color: var(--muted);
}
.wyldcards-search-form {
    display: flex;
    gap: 0.5rem;
    margin: 0;
}
.wyldcards-search-hint { margin: 0.45rem 0 1rem; font-size: 0.85rem; }
.wyldcards-search-input {
    flex: 1 1 auto;
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
}
.wyldcards-list-search { display: inline-flex; }
.wyldcards-list-search-input {
    padding: 0.3rem 0.55rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    max-width: 11rem;
}
.wyldcards-search-group {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.5rem;
    margin: 0;
    padding: 0.5rem 0.75rem;
    font-size: 1rem;
    border-bottom: 1px solid var(--border);
}
.wyldcards-search-group-count { font-size: 0.8rem; }
/* Where Cmd-G is standing. The counter says "7 of 40"; this says which row. */
.wyldcards-find-hit--current { background: var(--block-selection-tint); }
.wyldcards-find-hit--current .wyldcards-find-hit-title { font-weight: 700; }

/* Card list columns — a card's first few field texts, shown where the part
   count used to be. They sit straight in .user-list-meta, which is already a
   flex row with the list's own "·" separator, so all that is left to say is
   that a long one is cut rather than allowed to push the row wide. */
.wyldcards-card-list-field {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ------------------------------------------------------------------------
   The stack on paper — /stack/{uid}/print.

   Each card is a sheet, each sheet its own page. On screen the sheets stack
   down the window so you can see what you are about to spend paper on; in
   print they break one to a page and the chrome around them goes away.

   A printed part keeps the rect it has on the card, so a chart laid out in
   columns prints in columns. The one departure: nothing clips. On screen a
   card hides what overruns it and a textarea scrolls; on paper there is no
   scrolling, so overflow stays visible and a field taller than its box runs
   past the bottom of it. A line over the edge is worse-looking than the layout
   the author drew, and better than a fourth verse nobody printed.
   ------------------------------------------------------------------------ */
.wyldcards-print-sheets {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    padding: 1rem 0 2rem;
}
.wyldcards-print-filter {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
}
.wyldcards-print-filter label {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    margin: 0;
    white-space: nowrap;
}
.wyldcards-print-filter input {
    width: 4.75rem;
    margin: 0;
}
.wyldcards-print-filter select {
    width: auto;
    margin: 0;
}
.wyldcards-print-empty {
    margin: 2rem auto;
    text-align: center;
}
.wyldcards-print-sheet {
    max-width: 100%;
}
.wyldcards-print-layout-2 .wyldcards-print-sheet,
.wyldcards-print-layout-4 .wyldcards-print-sheet {
    display: grid;
    justify-content: center;
    align-items: start;
    gap: 1rem;
}
.wyldcards-print-layout-2 .wyldcards-print-sheet {
    grid-template-columns: repeat(2, max-content);
}
.wyldcards-print-layout-4 .wyldcards-print-sheet {
    grid-template-columns: repeat(2, max-content);
}
.wyldcards-print-layout-2 .wyldcards-print-tile {
    zoom: 0.48;
}
.wyldcards-print-layout-4 .wyldcards-print-tile {
    zoom: 0.24;
}
.wyldcards-print-card {
    position: relative;
    /* print-cards.js may raise this past the card's drawn height so an
       overrunning field is inside the page rather than over its edge. */
    box-sizing: content-box;
    background: #fff;
    color: #000;
    border: 1px solid var(--border);
    border-radius: 6px;
    max-width: 100%;
    /* No `overflow: hidden` — that is the whole difference from the card on
       screen. The card keeps the height it was drawn at, and a field with more
       text than its box spills past it rather than being cropped. */
    overflow: visible;
}
.wyldcards-print-caption {
    margin: 0.4rem 0 0;
    font-size: 0.8rem;
    color: var(--muted-fg, #666);
    text-align: center;
}
.print-part {
    position: absolute;
    box-sizing: border-box;
    /* The inline rect still sets `height`, and visible overflow turns it into
       a floor: the box is where the author drew it, and a fourth verse runs
       past the bottom of it instead of disappearing. */
    overflow: visible;
    color: inherit;
}
.print-text {
    display: block;
    /* Newlines are the text: a multiline field's verses are its line breaks. */
    white-space: pre-wrap;
    overflow-wrap: break-word;
}
.print-list {
    margin: 0;
    padding-left: 1.1em;
    list-style: disc;
}
.print-checklist {
    padding-left: 0;
    list-style: none;
}
.print-checklist .print-done {
    text-decoration: line-through;
}
.print-mark {
    margin-right: 0.35em;
}
.print-count {
    margin-top: 0.25em;
    font-size: 0.85em;
    opacity: 0.7;
}
.print-part-checkbox .print-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 0.35em;
}

@media print {
    /* The page is the sheet. Everything that is a control rather than the
       stack — the nav, the header with the Print button — has no business on
       paper. `body > header` is already hidden by the print rules above. */
    .wyldcards-print-page .hide-when-printing,
    .wyldcards-print-page .user-list-header,
    .wyldcards-print-empty {
        display: none !important;
    }
    .wyldcards-print-sheets {
        display: block;
        padding: 0;
        gap: 0;
    }
    .wyldcards-print-sheet {
        break-after: page;
        page-break-after: always;
        max-width: none;
    }
    .wyldcards-print-layout-2 .wyldcards-print-sheet,
    .wyldcards-print-layout-4 .wyldcards-print-sheet {
        display: grid;
        grid-template-columns: repeat(2, max-content);
        justify-content: center;
        align-items: start;
        gap: 0.15in;
    }
    /* Nothing after the last card: a trailing blank page is a wasted sheet. */
    .wyldcards-print-sheet:last-child {
        break-after: auto;
        page-break-after: auto;
    }
    .wyldcards-print-card {
        border: none;
        border-radius: 0;
        box-shadow: none;
        background: #fff;
        color: #000;
    }
    .wyldcards-print-caption {
        color: #666;
    }
}

/* Keep keyboard focus apparent even where component styling suppresses outlines. */
body :focus-visible {
    outline: 3px solid var(--accent, #2563eb) !important;
    outline-offset: 3px;
}

.wyldcards-skip-link {
    position: fixed;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 2000;
    padding: 0.65rem 0.9rem;
    border-radius: 0.4rem;
    background: var(--bg, #ffffff);
    color: var(--fg, #0f172a);
    box-shadow: 0 0 0 1px var(--border, #cbd5e1), 0 0.5rem 1.25rem rgb(15 23 42 / 0.2);
    /* Clear of the top edge by more than its offset and shadow; -150% left
       the shadow showing as a smudge in the corner of every page. */
    transform: translateY(calc(-100% - 3rem));
    transition: transform 0.15s ease;
}

.wyldcards-skip-link:focus {
    transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
    .wyldcards-skip-link {
        transition: none;
    }
}

/* ==========================================================================
   HyperCard visual effects
   The runtime puts the effect's name on <html> (data-effect) just before a
   boosted navigation; htmx starts the view transition; these keyframes are
   what it animates. Speeds map to durations; reduced motion skips the lot
   because the whole block sits inside the no-preference media query above
   the ordinary cross-fade — see view-transitions.js.
   ========================================================================== */
@property --wc-slat { syntax: '<percentage>'; inherits: false; initial-value: 0%; }
@property --wc-check { syntax: '<percentage>'; inherits: false; initial-value: 0%; }

@media (prefers-reduced-motion: no-preference) {
    html[data-effect] { --wc-effect-duration: 450ms; }
    html[data-effect-speed="very-slow"] { --wc-effect-duration: 1400ms; }
    html[data-effect-speed="slow"] { --wc-effect-duration: 850ms; }
    html[data-effect-speed="fast"] { --wc-effect-duration: 240ms; }
    html[data-effect-speed="very-fast"] { --wc-effect-duration: 120ms; }

    html[data-effect]::view-transition-old(root),
    html[data-effect]::view-transition-new(root) {
        animation-duration: var(--wc-effect-duration);
        animation-timing-function: ease-in-out;
        animation-fill-mode: both;
        mix-blend-mode: normal;
    }
    html[data-effect="plain"]::view-transition-old(root),
    html[data-effect="plain"]::view-transition-new(root) { animation: none; }

    html[data-effect="dissolve"]::view-transition-old(root) { animation-name: wc-fade-out; mix-blend-mode: plus-lighter; }
    html[data-effect="dissolve"]::view-transition-new(root) { animation-name: wc-fade-in; mix-blend-mode: plus-lighter; }

    /* Wipes: the old card stays put; the new one is uncovered by a moving edge. */
    html[data-effect^="wipe-"]::view-transition-old(root) { animation-name: wc-stay; }
    html[data-effect="wipe-left"]::view-transition-new(root) { animation-name: wc-wipe-left; }
    html[data-effect="wipe-right"]::view-transition-new(root) { animation-name: wc-wipe-right; }
    html[data-effect="wipe-up"]::view-transition-new(root) { animation-name: wc-wipe-up; }
    html[data-effect="wipe-down"]::view-transition-new(root) { animation-name: wc-wipe-down; }

    /* Scrolls: both cards move, the new one pushing the old out. */
    html[data-effect="scroll-left"]::view-transition-old(root) { animation-name: wc-slide-out-left; }
    html[data-effect="scroll-left"]::view-transition-new(root) { animation-name: wc-slide-in-right; }
    html[data-effect="scroll-right"]::view-transition-old(root) { animation-name: wc-slide-out-right; }
    html[data-effect="scroll-right"]::view-transition-new(root) { animation-name: wc-slide-in-left; }
    html[data-effect="scroll-up"]::view-transition-old(root) { animation-name: wc-slide-out-up; }
    html[data-effect="scroll-up"]::view-transition-new(root) { animation-name: wc-slide-in-down; }
    html[data-effect="scroll-down"]::view-transition-old(root) { animation-name: wc-slide-out-down; }
    html[data-effect="scroll-down"]::view-transition-new(root) { animation-name: wc-slide-in-up; }

    /* Opens reveal the new card; closes hide the old one on top of it. */
    html[data-effect$="-open"]::view-transition-old(root),
    html[data-effect="venetian-blinds"]::view-transition-old(root),
    html[data-effect="checkerboard"]::view-transition-old(root) { animation-name: wc-stay; }
    html[data-effect$="-close"]::view-transition-old(root) { z-index: 1; }
    html[data-effect$="-close"]::view-transition-new(root) { animation-name: wc-stay; }

    html[data-effect="iris-open"]::view-transition-new(root) { animation-name: wc-iris-open; }
    html[data-effect="iris-close"]::view-transition-old(root) { animation-name: wc-iris-close; }
    html[data-effect="zoom-open"]::view-transition-new(root) { animation-name: wc-zoom-open; }
    html[data-effect="zoom-close"]::view-transition-old(root) { animation-name: wc-zoom-close; }
    html[data-effect="barn-door-open"]::view-transition-new(root) { animation-name: wc-barn-open; }
    html[data-effect="barn-door-close"]::view-transition-old(root) { animation-name: wc-barn-close; }
    html[data-effect="venetian-blinds"]::view-transition-new(root) {
        animation-name: wc-blinds;
        mask-image: repeating-linear-gradient(to bottom, #000 0, #000 var(--wc-slat), transparent var(--wc-slat), transparent 8%);
        -webkit-mask-image: repeating-linear-gradient(to bottom, #000 0, #000 var(--wc-slat), transparent var(--wc-slat), transparent 8%);
    }
    html[data-effect="checkerboard"]::view-transition-new(root) {
        animation-name: wc-checker;
        mask-image: conic-gradient(#000 var(--wc-check), transparent 0 50%, #000 0 calc(50% + var(--wc-check)), transparent 0);
        -webkit-mask-image: conic-gradient(#000 var(--wc-check), transparent 0 50%, #000 0 calc(50% + var(--wc-check)), transparent 0);
        mask-size: 96px 96px;
        -webkit-mask-size: 96px 96px;
    }

    /* To black / to white: the old card fades into a colour, the new fades out of it. */
    html[data-effect="to-black"]::view-transition-image-pair(root) { background: #000; }
    html[data-effect="to-white"]::view-transition-image-pair(root) { background: #fff; }
    html[data-effect^="to-"]::view-transition-old(root) { animation-name: wc-fade-out; animation-duration: calc(var(--wc-effect-duration) / 2); }
    html[data-effect^="to-"]::view-transition-new(root) { animation-name: wc-fade-in; animation-duration: calc(var(--wc-effect-duration) / 2); animation-delay: calc(var(--wc-effect-duration) / 2); }
}

@keyframes wc-stay { from { opacity: 1; } to { opacity: 1; } }
@keyframes wc-fade-out { to { opacity: 0; } }
@keyframes wc-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes wc-wipe-left { from { clip-path: inset(0 0 0 100%); } to { clip-path: inset(0 0 0 0); } }
@keyframes wc-wipe-right { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes wc-wipe-up { from { clip-path: inset(100% 0 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes wc-wipe-down { from { clip-path: inset(0 0 100% 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes wc-slide-out-left { to { transform: translateX(-100%); } }
@keyframes wc-slide-out-right { to { transform: translateX(100%); } }
@keyframes wc-slide-out-up { to { transform: translateY(-100%); } }
@keyframes wc-slide-out-down { to { transform: translateY(100%); } }
@keyframes wc-slide-in-right { from { transform: translateX(100%); } to { transform: translateX(0); } }
@keyframes wc-slide-in-left { from { transform: translateX(-100%); } to { transform: translateX(0); } }
@keyframes wc-slide-in-down { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes wc-slide-in-up { from { transform: translateY(-100%); } to { transform: translateY(0); } }
@keyframes wc-iris-open { from { clip-path: circle(0% at 50% 50%); } to { clip-path: circle(75% at 50% 50%); } }
@keyframes wc-iris-close { from { clip-path: circle(75% at 50% 50%); } to { clip-path: circle(0% at 50% 50%); } }
@keyframes wc-zoom-open { from { transform: scale(0.15); opacity: 0.2; } to { transform: scale(1); opacity: 1; } }
@keyframes wc-zoom-close { from { transform: scale(1); opacity: 1; } to { transform: scale(0.15); opacity: 0; } }
@keyframes wc-barn-open { from { clip-path: inset(0 50% 0 50%); } to { clip-path: inset(0 0 0 0); } }
@keyframes wc-barn-close { from { clip-path: inset(0 0 0 0); } to { clip-path: inset(0 50% 0 50%); } }
@keyframes wc-blinds { from { --wc-slat: 0%; } to { --wc-slat: 8%; } }
@keyframes wc-checker { from { --wc-check: 0%; } to { --wc-check: 50%; } }

/* lock screen: a frozen copy of the card over the live one. */
.wyldcards-screen-lock {
    position: absolute;
    inset: 0;
    z-index: 40;
    pointer-events: none;
    overflow: hidden;
}
.wyldcards-screen-lock > .wyldcards-card {
    position: absolute;
    inset: 0;
    margin: 0;
}
/* flash: HyperCard inverted the whole screen; the card is enough. */
.wyldcards-card--flash { filter: invert(1) hue-rotate(180deg); }

/* hilite / disable, set by script on a button */
.part-button-btn--hilite,
.part-button-btn--hilite:hover,
.part-button-btn--auto-hilite,
.part-button-btn--auto-hilite:hover {
    background: var(--fg, #1e293b);
    color: var(--bg, #fff);
    border-color: var(--fg, #1e293b);
}
.part--disabled { opacity: 0.45; }
.part--disabled .part-button-btn,
.part--disabled .part-input { pointer-events: none; }

/* ==========================================================================
   Field looks: ruled lines (HyperCard's Show Lines) and a scrolling field
   ========================================================================== */
.part-lines textarea.part-input,
.part-lines .part-static-text-multiline {
    --wc-rule: 1.4em;
    line-height: var(--wc-rule);
    padding-top: 0.3rem;
    background-image: repeating-linear-gradient(to bottom,
        transparent 0, transparent calc(var(--wc-rule) - 1px),
        color-mix(in srgb, var(--fg, #1e293b) 22%, transparent) calc(var(--wc-rule) - 1px),
        color-mix(in srgb, var(--fg, #1e293b) 22%, transparent) var(--wc-rule));
    background-origin: content-box;
    background-attachment: local;
}
.part-scroll textarea.part-input,
.part-scroll .part-static-text-multiline,
.part-scroll .part-rich-text-editor {
    overflow-y: auto !important;
    scrollbar-gutter: stable;
}
.part-scroll textarea[data-auto-expand] {
    min-height: 0;
    flex: 1;
}
.part-field-multiline.part-scroll:has(textarea[data-auto-expand]) { overflow: hidden; }

/* ==========================================================================
   Message Box (⌘M) and Message Watcher — the same shape as the find bar
   ========================================================================== */
.wyldcards-message-box {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
    background: var(--accent-bg);
}
.wyldcards-message-box[hidden] { display: none; }
.wyldcards-message-box-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}
.wyldcards-message-box-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted);
}
.wyldcards-message-box-input {
    flex: 1 1 14rem;
    min-width: 8rem;
    padding: 0.3rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--text);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.95rem;
}
.wyldcards-message-box-btn {
    padding: 0.2rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--text);
    cursor: pointer;
    line-height: 1.4;
}
.wyldcards-message-box-btn[aria-pressed="true"] {
    background: var(--fg, #1e293b);
    color: var(--bg, #fff);
    border-color: var(--fg, #1e293b);
}
.wyldcards-message-box-btn--close { margin-left: auto; }
.wyldcards-message-box-result {
    display: block;
    min-height: 1.2em;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.85rem;
    color: var(--muted);
    white-space: pre-wrap;
    word-break: break-word;
}
.wyldcards-message-box-result:empty { display: none; }
.wyldcards-message-box-result--error { color: var(--danger, #b91c1c); }
.wyldcards-message-watcher {
    margin: 0;
    padding: 0.25rem 0.5rem;
    max-height: 9rem;
    overflow-y: auto;
    list-style: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    font-size: 0.8rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.wyldcards-message-watcher[hidden] { display: none; }
.wyldcards-message-watcher li { padding: 0.1rem 0; border-top: 1px dotted var(--border); }
.wyldcards-message-watcher li:first-child { border-top: 0; }
.wyldcards-message-watcher li[data-kind="message"] code { font-weight: 700; }
.wyldcards-message-watcher li[data-kind="note"] { color: var(--muted); }
.wyldcards-message-watcher small { color: var(--muted); }

/* ==========================================================================
   HyperCard button styles, hidden parts, field margins — the persisted looks
   ========================================================================== */
.part-button-style-transparent .part-button-btn {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
    padding-inline: 0.15rem;
}
.part-button-style-opaque .part-button-btn {
    background: var(--plain-bg, #fff);
    border-color: transparent;
    box-shadow: none;
    padding-inline: 0.15rem;
}
.part-button-style-rectangle .part-button-btn {
    border-radius: 0;
    background: var(--plain-bg, #fff);
    box-shadow: none;
}
.part-button-style-round-rect .part-button-btn {
    border-radius: 999px;
}
.part-button-style-shadow .part-button-btn {
    border-radius: 0;
    background: var(--plain-bg, #fff);
    box-shadow: 3px 3px 0 var(--fg, #1e293b);
}
.part-button-style-default .part-button-btn {
    outline: 3px double var(--fg, #1e293b);
    outline-offset: 2px;
    border-radius: 999px;
}
/* Check box and radio: a label around a real input, drawn like HyperCard's — no button chrome. */
.part-button-toggle {
    justify-content: flex-start;
    gap: 0.45rem;
    background: transparent;
    border-color: transparent;
    box-shadow: none;
    font-weight: 500;
    justify-content: flex-start;
    cursor: pointer;
}
.part-button-toggle:hover { transform: none; box-shadow: none; background: var(--accent-bg); }
.part-button-toggle.part-button-btn--hilite,
.part-button-toggle.part-button-btn--hilite:hover {
    background: transparent;
    color: inherit;
    border-color: transparent;
    font-weight: 700;
}
.part-button-toggle-input {
    width: 1.1em;
    height: 1.1em;
    margin: 0;
    accent-color: var(--fg, #1e293b);
    flex: none;
}
/* Popup: HyperCard's menu button. */
.part-button-popup {
    appearance: auto;
    padding-inline-end: 1.5rem;
    font-weight: 600;
    cursor: pointer;
}
/* Dropdown field: a native menu filling the field's rect. */
.part-field select.part-dropdown {
    appearance: auto;
    padding-inline-end: 1.5rem;
    cursor: pointer;
    color: inherit;
    font-family: inherit;
}
.part-field select.part-dropdown:disabled { cursor: default; opacity: 1; }
/* A hidden part in Edit mode shows as a ghost so it can still be selected. */
.wyldcards-mode-edit .part-hidden { opacity: 0.45; outline: 1px dashed var(--muted); outline-offset: 2px; }
.wyldcards-mode-edit .part-hidden .part-name-tag::after { content: ' (hidden)'; }
/* wideMargins / fixedLineHeight */
.part-wide-margins .part-input,
.part-wide-margins .part-rich-text-editor { padding-inline: 1rem; padding-block: 0.6rem; }
.part-fixed-line-height textarea.part-input,
.part-fixed-line-height .part-static-text-multiline,
.part-fixed-line-height .part-rich-text-editor { line-height: 1.5rem !important; }
.part-fixed-line-height.part-lines textarea.part-input,
.part-fixed-line-height.part-lines .part-static-text-multiline { --wc-rule: 1.5rem; }

/* Card Info toggles in the edit bar */
.wyldcards-editbar-check {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.85rem;
    cursor: pointer;
}
.wyldcards-editbar-check input { margin: 0; }

/* Edit bar menus (Card, Part, Scripts, Stack): links, checkboxes and separators
   sit in the same rows as the menu's buttons. */
.wyldcards-editbar-menu .wyldcards-new-card-options a {
    display: grid;
    gap: 0.1rem;
    padding: 0.5rem 0.6rem;
    border-radius: 0.3rem;
    color: inherit;
    text-decoration: none;
}
.wyldcards-editbar-menu .wyldcards-new-card-options a:is(:hover, :focus-visible) {
    background: color-mix(in srgb, var(--accent, #2563eb) 10%, var(--bg));
    outline: none;
}
.wyldcards-editbar-menu .wyldcards-new-card-options form { margin: 0; }
.wyldcards-editbar-menu .wyldcards-new-card-options label:not(.wyldcards-editbar-check) { display: grid; gap: 0.2rem; padding: 0.4rem 0.6rem; font-size: 0.85rem; }
.wyldcards-editbar-menu .wyldcards-editbar-check { display: flex; padding: 0.4rem 0.6rem; }
.wyldcards-editbar-menu .wyldcards-editbar-check span { color: inherit; font-size: inherit; }
.wyldcards-editbar-menu .nav-dropdown-separator { margin: 0.25rem 0.3rem; border: 0; border-top: 1px solid var(--border); }
.wyldcards-editbar-menu .wyldcards-editbar-menu-danger strong { color: var(--bad-fg, #b91c1c); }

/* ==========================================================================
   Recent cards (⌘R)
   ========================================================================== */
.wyldcards-recent {
    width: min(64rem, calc(100vw - 2rem));
    max-height: min(80vh, 44rem);
    padding: 0.75rem 1rem 1rem;
}
.wyldcards-recent-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}
.wyldcards-recent-title { margin: 0; font-size: 1.05rem; }
.wyldcards-recent-body { overflow-y: auto; max-height: calc(min(80vh, 44rem) - 4rem); }
.wyldcards-recent-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}
.wyldcards-recent-card {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.25rem;
    text-decoration: none;
    color: inherit;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.35rem;
    background: var(--bg);
}
.wyldcards-recent-card:hover,
.wyldcards-recent-card:focus-visible,
.wyldcards-recent-card:has(> a:focus-visible) { border-color: var(--accent, #2563eb); background: var(--accent-bg); }
.wyldcards-recent-card .wyldcards-storyboard-caption { font-size: 0.75rem; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wyldcards-recent-open { font-size: 0.95em; }

/* ==========================================================================
   Paint layers and Paint mode (HyperCard's paint tools)
   ========================================================================== */
.wyldcards-paint-layer {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    user-select: none;
    image-rendering: auto;
}
.print-part ~ .wyldcards-paint-layer,
.wyldcards-print-card .wyldcards-paint-layer { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
.wyldcards-paint-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    touch-action: none;
    cursor: crosshair;
    z-index: 30;
}
.wyldcards-mode-paint .part { pointer-events: none; opacity: 0.55; }
.wyldcards-mode-paint .wyldcards-card-flip-scene { perspective: none; }
.wyldcards-mode-paint .wyldcards-card-viewport { overflow: auto; max-width: 100%; }
.wyldcards-mode-paint.wyldcards-paint-fatbits .wyldcards-card-flip-scene { zoom: 3; image-rendering: pixelated; }
.wyldcards-mode-paint.wyldcards-paint-fatbits .wyldcards-paint-layer,
.wyldcards-mode-paint.wyldcards-paint-fatbits .wyldcards-paint-canvas { image-rendering: pixelated; }
.wyldcards-paint-palette {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem 1rem;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
    background: var(--accent-bg);
    font-size: 0.85rem;
}
.wyldcards-paint-group { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; }
.wyldcards-paint-layer-pick { display: inline-flex; align-items: center; gap: 0.25rem; font-weight: 600; }
.wyldcards-paint-tool {
    min-width: 2rem;
    height: 2rem;
    padding: 0 0.4rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--text);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
}
.wyldcards-paint-tool[aria-pressed="true"] { background: var(--fg, #1e293b); color: var(--bg, #fff); border-color: var(--fg, #1e293b); }
.wyldcards-paint-option { display: inline-flex; align-items: center; gap: 0.3rem; }
.wyldcards-paint-option input[type="range"] { width: 6rem; }
.wyldcards-paint-save { font-weight: 700; }
.wyldcards-paint-status { color: var(--muted); font-variant-numeric: tabular-nums; }
.wyldcards-paint-status--error { color: var(--danger, #b91c1c); }

/* Button icon pictures (HyperCard's icons) */
.part-button-icon-image { width: 1.5em; height: 1.5em; flex: none; object-fit: contain; image-rendering: pixelated; }
.part-button-toggle .part-button-icon-image { width: 1.2em; height: 1.2em; }

/* Icon editor */
.wyldcards-icon-editor { width: min(30rem, calc(100vw - 2rem)); }
.wyldcards-icon-editor-canvas {
    display: block;
    width: 256px;
    height: 256px;
    margin: 0.5rem auto;
    border: 1px solid var(--border);
    background:
        linear-gradient(45deg, var(--accent-bg) 25%, transparent 25%, transparent 75%, var(--accent-bg) 75%),
        linear-gradient(45deg, var(--accent-bg) 25%, transparent 25%, transparent 75%, var(--accent-bg) 75%);
    background-size: 16px 16px;
    background-position: 0 0, 8px 8px;
    image-rendering: pixelated;
    touch-action: none;
    cursor: crosshair;
}
.wyldcards-icon-editor-tools { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; justify-content: center; }
.wyldcards-icon-swatch { width: 1.6rem; height: 1.6rem; border: 2px solid var(--border); border-radius: 4px; cursor: pointer; padding: 0; }
.wyldcards-icon-swatch[aria-pressed="true"] { border-color: var(--fg, #1e293b); outline: 2px solid var(--fg, #1e293b); }

/* Scripted menus */
.nav-dropdown-separator { border: 0; border-top: 1px solid var(--border); margin: 0.25rem 0; }
.wyldcards-script-menu .nav-dropdown-item { width: 100%; text-align: left; background: none; border: 0; font: inherit; color: inherit; cursor: pointer; }
.wyldcards-script-menu .nav-dropdown-item:disabled { opacity: 0.45; cursor: default; }

/* Report layouts (columns / labels) */
.wyldcards-report-page .wyldcards-report-toolbar { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; margin-bottom: 1rem; }
.wyldcards-report-layout-form { display: flex; flex-wrap: wrap; gap: 0.75rem 1.25rem; align-items: flex-start; margin: 1rem 0; padding: 0.75rem; border: 1px solid var(--border); border-radius: 8px; }
.wyldcards-report-layout-form fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.wyldcards-report-layout-form legend { font-weight: 600; margin-bottom: 0.25rem; }
.wyldcards-report-layout-form label { display: block; }
.wyldcards-report-columns { width: 100%; border-collapse: collapse; }
.wyldcards-report-columns th, .wyldcards-report-columns td { text-align: left; padding: 0.3rem 0.5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.wyldcards-report-labels { display: grid; gap: 0; }
.wyldcards-report-labels--2 { grid-template-columns: repeat(2, 1fr); }
.wyldcards-report-labels--3 { grid-template-columns: repeat(3, 1fr); }
.wyldcards-report-label { min-height: 1in; padding: 0.15in 0.2in; box-sizing: border-box; border: 1px dashed var(--border); break-inside: avoid; overflow: hidden; }
.wyldcards-report-label p { margin: 0; line-height: 1.25; }
.wyldcards-report-label .wyldcards-report-label-title { font-weight: 700; }
.wyldcards-report-footer { margin-top: 1rem; color: var(--muted); font-size: 0.85rem; }
@media print {
    .wyldcards-report-page .hide-when-printing, .wyldcards-report-page .user-list-header, .wyldcards-report-page nav { display: none !important; }
    .wyldcards-report-label { border-color: transparent; }
    .wyldcards-report-columns tr { break-inside: avoid; }
    .wyldcards-report-page h1 { string-set: report-title content(); }
}
@page report {
    margin: 0.6in 0.5in;
    @top-center { content: string(report-title); font-size: 9pt; color: #555; }
    @bottom-center { content: "Page " counter(page) " of " counter(pages); font-size: 9pt; color: #555; }
}
.wyldcards-report-layout-page { page: report; }

/* The Home stack's stack_list widget */
/* The Home stack's All stacks card: the arranging page, scrolled inside its part. */
.part-all-stacks.stack-list-page {
    width: 100%;
    height: 100%;
    max-width: none;
    margin: 0;
    padding: 0.35rem 0.5rem 0.75rem;
    overflow: auto;
    box-sizing: border-box;
    text-align: left;
}
.part-all-stacks .user-list-header {
    flex-wrap: wrap;
    gap: 0.5rem;
}
.part-all-stacks .wyldcards-list-header-buttons {
    flex: 1 1 100%;
    min-width: 0;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 0.4rem;
}
.part-all-stacks .wyldcards-list-header-buttons .wyldcards-list-action-btn,
.part-all-stacks .wyldcards-list-header-buttons .user-list-create-btn {
    min-height: 2rem;
    padding-inline: 0.55rem;
    font-size: 0.85rem;
}
.part-all-stacks .wyldcards-list-search {
    flex: 1 1 100%;
}
.part-all-stacks .wyldcards-list-search-input {
    width: 100%;
}
.wyldcards-mode-edit .part-all-stacks {
    pointer-events: none;
}
.part-stack-list {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.5rem;
    align-content: start;
    padding: 0.35rem;
    box-sizing: border-box;
}
.part-stack-list-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    padding: 0.6rem 0.4rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: color-mix(in srgb, var(--plain-bg, #fff) 70%, transparent);
    color: inherit;
    text-decoration: none;
    text-align: center;
}
.part-stack-list-item:hover, .part-stack-list-item:focus-visible { border-color: var(--accent, #2563eb); background: var(--accent-bg); }
.part-stack-list-icon { font-size: 1.8rem; line-height: 1; }
.part-stack-list-name { font-weight: 600; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.part-stack-list-count { font-size: 0.75rem; }
.part-stack-list-empty { grid-column: 1 / -1; margin: 0.5rem; }
.wyldcards-mode-edit .part-stack-list-item { pointer-events: none; }

/* Scripts on a shared stack: the collaborator's "Run scripts" choice and the
   owner's "waiting for approval" note, in a strip above the card. */
.wyldcards-script-trust-banner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin: 0 auto 0.75rem;
    max-width: 60rem;
    padding: 0.55rem 1rem;
    background: color-mix(in srgb, var(--accent, #2563eb) 9%, transparent);
    border: 1px solid var(--border);
    border-radius: var(--border-radius, 0.5rem);
    font-size: 0.9rem;
}
.wyldcards-script-trust-text { flex: 1 1 18rem; min-width: 0; margin: 0; }
.wyldcards-script-trust-banner form { margin: 0; flex: 0 0 auto; }

.script-review-list { list-style: none; padding: 0; margin: 1rem 0 0; display: grid; gap: 1rem; }
.script-review-item { border: 1px solid var(--border); border-radius: var(--border-radius, 0.5rem); padding: 0.75rem 1rem; }
.script-review-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; }
.script-review-locations { margin: 0; padding-left: 1.1rem; }
.script-review-code { margin: 0.6rem 0 0; max-height: 24rem; overflow: auto; white-space: pre-wrap; word-break: break-word; }

/* Styled paragraphs field: each paragraph's look comes from the field's own
   scoped <style> (margins in ch, so indents line up in a monospace font). */
.part-paragraphs {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: var(--part-field-border, 1px solid var(--border));
    border-radius: 4px;
    background: color-mix(in srgb, var(--plain-bg, #fff) 70%, transparent);
}
.part-paragraphs-bar {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.3rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.8em;
}
.part-paragraphs-bar select { width: auto; min-width: 8rem; margin: 0; padding: 0.1rem 0.25rem; font-size: 1em; }
.part-paragraphs-bar select[data-paragraph-case-picker] { min-width: 0; }
.part-paragraphs-bar .muted { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.part-paragraphs-body {
    position: relative;
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 0.4rem 0.6rem;
    outline: none;
}
.part-paragraph { min-height: 1.2em; white-space: pre-wrap; overflow-wrap: anywhere; }
.part-paragraphs-body > .part-paragraph:first-child { margin-top: 0 !important; }
.part-locked .part-paragraphs { border-style: dotted; background: transparent; }
.part-paragraphs-suggest {
    position: absolute;
    z-index: 20;
    min-width: 12rem;
    max-width: 90%;
    margin: 0;
    padding: 0.2rem 0;
    list-style: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--plain-bg, #fff);
    box-shadow: 0 4px 14px rgb(0 0 0 / 0.14);
    font-size: 0.9em;
}
.part-paragraphs-suggest li { padding: 0.15rem 0.6rem; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.part-paragraphs-suggest li[aria-selected="true"] { background: var(--accent-bg, #e0e7ff); }
.wyldcards-inspector-code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.8rem; white-space: pre; }

/* Page view: a styled paragraphs field as printable pages. Sheets are real
   size (inches), always paper-white, set in 12-point lines; the field's own
   style rules are scoped to .page-view-sheets with blank lines at 1em. */
.page-view-body { background: var(--page-view-desk, #e5e7eb); }
.page-view-toolbar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 0.9rem;
    padding: 0.5rem 1rem;
    background: var(--plain-bg, #fff);
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}
.page-view-toolbar label { display: inline-flex; align-items: center; gap: 0.35rem; margin: 0; }
.page-view-toolbar select { width: auto; margin: 0; padding: 0.15rem 0.3rem; font-size: 0.85rem; }
.page-view-toolbar button { margin: 0; padding: 0.25rem 0.6rem; font-size: 0.85rem; }
.page-view-toolbar form { margin: 0; }
.page-view-back { font-weight: 600; text-decoration: none; }
.page-view { padding: 1.25rem 1rem 3rem; overflow-x: auto; }
.page-view-empty { max-width: 40rem; margin: 2rem auto; text-align: center; }
.page-view-sheets {
    zoom: var(--page-view-zoom, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5in;
    font-size: 12pt;
    line-height: 12pt;
}
.page-view-sheet {
    position: relative;
    flex: 0 0 auto;
    background: #fff;
    color: #111;
    box-shadow: 0 2px 10px rgb(0 0 0 / 0.18);
}
.page-view-content { position: absolute; overflow: hidden; }
.page-view-content > .part-paragraph { white-space: pre-wrap; overflow-wrap: anywhere; min-height: 12pt; }
.page-view-content > .part-paragraph:first-child,
.page-view-sheets .page-view-more,
.page-view-sheets .page-view-contd { margin-top: 0 !important; }
.page-view-number { position: absolute; top: 0.5in; line-height: 12pt; }
/* The title page: rows of 12-point lines, the same rows the PDF sets. */
.page-view-title-line { margin: 0; min-height: 12pt; line-height: 12pt; white-space: pre-wrap; overflow-wrap: anywhere; }
.page-view-title-main { text-align: center; }
.page-view-title-contact,
.page-view-title-draft { position: absolute; bottom: 0; max-width: 50%; }
.page-view-title-contact { left: 0; text-align: left; }
.page-view-title-draft { right: 0; text-align: right; }
/* A long form hanging from the sticky toolbar: it scrolls inside itself, or its foot would be out of reach. */
.page-view-import form.page-view-title-form {
    gap: 0.3rem;
    width: min(24rem, 90vw);
    max-height: calc(100vh - 7rem);
    overflow-y: auto;
}
.page-view-import .page-view-title-form label { display: block; font-size: 0.8125rem; }
/* A song inserted into a paragraphs field: its lines as they read now, set off and locked. */
.part-paragraph-insert {
    margin: 0.4em 0;
    padding: 0.1em 0 0.3em 0.6em;
    border-left: 3px solid var(--accent, #475569);
    background: rgba(71, 85, 105, 0.06);
    cursor: default;
    user-select: text;
}
.part-paragraph-insert.is-marked-for-removal { outline: 2px solid #b91c1c; background: rgba(185, 28, 28, 0.08); }
.part-paragraph-insert-label {
    margin: 0 0 0.2em;
    font: 0.75rem/1.3 system-ui, -apple-system, "Segoe UI", sans-serif;
    color: var(--muted-fg, #64748b);
}
.part-paragraph-insert-label a { color: inherit; }
.part-paragraph-insert-picker {
    display: grid;
    gap: 0.35rem;
    margin: 0.3rem 0;
    padding: 0.5rem;
    border: 1px solid var(--border, #cbd5e1);
    border-radius: 6px;
    background: var(--plain-bg, #fff);
    font: 0.8125rem/1.35 system-ui, -apple-system, "Segoe UI", sans-serif;
}
.part-paragraph-insert-picker input[type=search] { margin: 0; width: 100%; }
.part-paragraph-insert-results { display: grid; gap: 0.2rem; max-height: 12rem; margin: 0; padding: 0; overflow-y: auto; list-style: none; }
.part-paragraph-insert-results button { margin: 0; padding: 0.15rem 0.4rem; text-align: left; }
.version-uses { display: grid; gap: 0.35rem; margin: 0; padding-left: 1.1rem; }
/* Spelling that knows the script: marks drawn over the text, and the popup a click on one opens. */
::highlight(wyldcards-spelling) {
    text-decoration: underline wavy #dc2626;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}
.part-paragraphs-spelling { display: inline-flex; align-items: center; gap: 0.25rem; margin: 0; font-size: 0.8125rem; white-space: nowrap; }
.part-paragraphs-spelling input { margin: 0; }
.part-spelling-popup {
    position: absolute;
    z-index: 60;
    display: grid;
    gap: 0.2rem;
    min-width: 11rem;
    max-width: min(20rem, 90vw);
    padding: 0.35rem;
    border: 1px solid var(--border, #cbd5e1);
    border-radius: 6px;
    background: var(--plain-bg, #fff);
    box-shadow: 0 6px 20px rgb(0 0 0 / 0.18);
    font: 0.8125rem/1.3 system-ui, -apple-system, "Segoe UI", sans-serif;
}
.part-spelling-popup button { justify-content: flex-start; margin: 0; padding: 0.25rem 0.5rem; text-align: left; font-weight: 400; }
.part-spelling-popup hr { margin: 0.15rem 0; }
.part-spelling-popup p { margin: 0.2rem 0.5rem; }
/* Your own folders on the stacks page, and a folder's own page. */
.stack-folders { margin-bottom: 0.5rem; }
.stack-folder-tile .stack-tile-face { background: color-mix(in srgb, var(--accent, #475569) 7%, var(--bg, #fff)); }
.stack-folder-icon { font-size: 1.6rem; }
.stack-folder-tile.is-drop-target { outline: 3px solid var(--accent, #475569); outline-offset: 2px; }
.stack-new-folder { position: relative; margin: 0; padding: 0; border: 0; background: none; overflow: visible; }
.stack-new-folder summary { list-style: none; cursor: pointer; }
.stack-new-folder summary::-webkit-details-marker { display: none; }
.stack-new-folder-form {
    position: absolute;
    right: 0;
    z-index: 20;
    display: grid;
    gap: 0.35rem;
    width: min(18rem, 86vw);
    margin-top: 0.35rem;
    padding: 0.65rem;
    border: 1px solid var(--border, #cbd5e1);
    border-radius: 8px;
    background: var(--bg, #fff);
    box-shadow: 0 8px 22px rgb(0 0 0 / 0.14);
}
.stack-new-folder-form input { margin: 0; }
.stack-list-bulk-folder { display: inline-flex; align-items: center; gap: 0.35rem; }
.stack-list-bulk-folder select { width: auto; max-width: 14rem; margin: 0; }
.stack-folder-path ol { display: flex; flex-wrap: wrap; gap: 0.25rem 0.5rem; margin: 0 0 0.5rem; padding: 0; list-style: none; font-size: 0.875rem; }
.stack-folder-path li + li::before { content: "›"; margin-right: 0.5rem; color: var(--muted-fg, #64748b); }
.stack-folder-move { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 0.3rem; }
.stack-folder-move select { width: auto; max-width: 11rem; margin: 0; }
.stack-folder-tools { margin-top: 1.5rem; }
.stack-folder-row { margin-bottom: 0.75rem; }

/* The read view: one quiet column of the whole script, sized for any screen. */
.read-view-body {
    --read-ground: #fdfcf9;
    --read-ink: #1f2328;
    --read-muted: #6b7078;
    --read-rule: #e4e1da;
    --read-accent: #365f91;
    --read-size-step: 0;
    margin: 0;
    background: var(--read-ground);
    color: var(--read-ink);
}
.read-view-body[data-read-theme="sepia"] { --read-ground: #f4ecd8; --read-ink: #3b2f1e; --read-muted: #7a6a52; --read-rule: #e0d3b6; --read-accent: #8a5a1c; }
.read-view-body[data-read-theme="dark"] { --read-ground: #15171b; --read-ink: #dfe3e8; --read-muted: #9aa1ab; --read-rule: #2a2e35; --read-accent: #8db4e6; }
.read-view-toolbar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 0.9rem;
    padding: 0.5rem max(1rem, calc((100% - 46rem) / 2));
    border-bottom: 1px solid var(--read-rule);
    background: var(--read-ground);
    font: 0.875rem/1.3 system-ui, -apple-system, "Segoe UI", sans-serif;
}
.read-view-toolbar a { color: var(--read-accent); }
.read-view-back { margin-right: auto; text-decoration: none; }
.read-view-controls { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; }
.read-view-controls button,
.read-view-controls select {
    width: auto;
    margin: 0;
    padding: 0.2rem 0.5rem;
    border: 1px solid var(--read-rule);
    border-radius: 5px;
    background: transparent;
    color: var(--read-ink);
    font: inherit;
}
.read-view-contents { position: relative; }
.read-view-contents summary { cursor: pointer; color: var(--read-accent); }
.read-view-contents ol {
    position: absolute;
    right: 0;
    z-index: 6;
    width: min(24rem, 86vw);
    max-height: 60vh;
    margin: 0.4rem 0 0;
    padding: 0.5rem 0.75rem 0.5rem 2rem;
    overflow-y: auto;
    border: 1px solid var(--read-rule);
    border-radius: 6px;
    background: var(--read-ground);
    box-shadow: 0 8px 24px rgb(0 0 0 / 0.14);
}
.read-view-contents li { margin: 0.15rem 0; }
.read-view {
    max-width: none;
    margin: 0;
    padding: 2rem max(1rem, calc((100% - 46rem) / 2)) 6rem;
    background: var(--read-ground);
    color: var(--read-ink);
}
.read-view-empty { color: var(--read-muted); }
.read-script {
    --read-indent: 1;
    font-family: var(--read-face-script, 'Courier Prime', 'Courier New', Courier, monospace);
    font-size: calc(1rem + var(--read-size-step) * 0.125rem);
    line-height: 1.35;
}
.read-view-body[data-read-face="book"] .read-script { font-family: Charter, "Iowan Old Style", Georgia, "Times New Roman", serif; line-height: 1.5; }
.read-script .part-paragraph { white-space: pre-wrap; overflow-wrap: anywhere; }
.read-script h2.part-paragraph { font-size: 1em; font-weight: 400; scroll-margin-top: 6rem; }
.read-script-title { display: block; margin: 2rem 0 3rem; text-align: center; }
.read-script-title h1 { margin: 0 0 1.2em; font-size: 1.35em; text-transform: uppercase; letter-spacing: 0.04em; }
.read-script-title p { margin: 0.35em 0; white-space: pre-line; }
.read-script-authors { font-weight: 600; }
.read-script-source,
.read-script-draft { color: var(--read-muted); }
.read-script-card + .read-script-card { margin-top: 1.2em; }
@media (max-width: 40rem) {
    .read-script { --read-indent: 0.45; }
    .read-view { padding-top: 1rem; }
}
@media print {
    .read-view-toolbar { display: none; }
    .read-view-body { background: #fff; color: #000; }
    .read-view { padding: 0; }
    .read-script { --read-indent: 1; font-size: 12pt; }
}

/* Focus mode: the page steps back and one styled paragraphs field fills the window. */
html.wyldcards-focus { overflow: hidden; }
html.wyldcards-focus body { overflow: hidden; }
html.wyldcards-focus body * { visibility: hidden; }
html.wyldcards-focus body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 900;
    background: var(--focus-ground, #fbfaf7);
}
.wyldcards-focus-stage {
    position: fixed;
    inset: 0 0 3.25rem;
    z-index: 950;
}
html.wyldcards-focus .wyldcards-focus-stage,
html.wyldcards-focus .wyldcards-focus-stage *,
html.wyldcards-focus .wyldcards-focus-bar,
html.wyldcards-focus .wyldcards-focus-bar *,
html.wyldcards-focus .part-spelling-popup,
html.wyldcards-focus .part-spelling-popup * { visibility: visible; }
html.wyldcards-focus .part-spelling-popup { z-index: 970; }
html.wyldcards-focus .is-focus-target {
    position: static !important;
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    transform: none !important;
}
html.wyldcards-focus .is-focus-target .part-paragraphs {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: transparent;
}
html.wyldcards-focus .is-focus-target .part-paragraphs-bar {
    width: min(46rem, calc(100% - 2rem));
    margin: 0.75rem auto 0;
    opacity: 0.35;
    transition: opacity 0.2s;
}
html.wyldcards-focus .is-focus-target .part-paragraphs-bar:hover,
html.wyldcards-focus .is-focus-target .part-paragraphs-bar:focus-within { opacity: 1; }
html.wyldcards-focus .is-focus-target .part-paragraphs-body {
    flex: 1;
    overflow-y: auto;
    padding: 30vh max(1rem, calc((100% - 44rem) / 2)) 45vh;
    font-size: 1.1rem;
    line-height: 1.45;
    border: 0;
    outline: none;
    background: transparent;
}
html.wyldcards-focus .is-focus-target .part-paragraphs-body > .part-paragraph,
html.wyldcards-focus .is-focus-target .part-paragraphs-body > .part-paragraph-insert { opacity: 0.38; transition: opacity 0.25s; }
html.wyldcards-focus .is-focus-target .part-paragraphs-body > .part-paragraph.is-focus-current { opacity: 1; }
.wyldcards-focus-bar {
    position: fixed;
    inset: auto 0 0;
    z-index: 960;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.4rem 1rem;
    min-height: 3.25rem;
    padding: 0.35rem 1rem;
    background: var(--focus-ground, #fbfaf7);
    font: 0.8125rem/1.3 system-ui, -apple-system, "Segoe UI", sans-serif;
    color: #334155;
}
.wyldcards-focus-bar button { margin: 0; padding: 0.2rem 0.7rem; }
@media (prefers-color-scheme: dark) {
    html.wyldcards-focus { --focus-ground: #14161a; }
    html.wyldcards-focus .is-focus-target .part-paragraphs-body { color: #e5e7eb; }
    .wyldcards-focus-bar { color: #cbd5e1; }
}
@media (max-width: 40rem) {
    .wyldcards-focus-hint { display: none; }
    html.wyldcards-focus .is-focus-target .part-paragraphs-body { padding-top: 12vh; font-size: 1rem; }
}

/* Writing tools: Stats and Find and replace. */
.writing-stats-glance {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
    gap: 0.5rem;
    margin: 0 0 0.75rem;
}
.writing-stats-glance div { padding: 0.55rem 0.7rem; border: 1px solid var(--border, #cbd5e1); border-radius: 8px; background: var(--bg, #fff); }
.writing-stats-glance dt { margin: 0; color: var(--muted-fg, #64748b); font-size: 0.75rem; letter-spacing: 0.04em; text-transform: uppercase; }
.writing-stats-glance dd { margin: 0.15rem 0 0; font-size: 1.35rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.writing-stats-table { overflow-x: auto; }
.writing-stats-table table { width: 100%; margin: 0; font-variant-numeric: tabular-nums; }
.writing-stats-table th[scope="row"] { font-weight: 500; text-align: left; }
.writing-stats-bar {
    display: inline-block;
    width: 5rem;
    height: 0.5rem;
    vertical-align: middle;
    border-radius: 999px;
    background: linear-gradient(to right, var(--accent, #475569) var(--share, 0%), rgba(71, 85, 105, 0.15) var(--share, 0%));
}
.replace-results { display: grid; gap: 0.6rem; margin: 0; padding-left: 1.2rem; }
.replace-results ul { display: grid; gap: 0.2rem; margin: 0.25rem 0 0; padding-left: 1rem; font-size: 0.875rem; }
.replace-results mark { padding: 0 0.1em; border-radius: 2px; }
.replace-apply { margin-top: 0.75rem; }
.page-view-download-list {
    position: absolute;
    right: 0;
    z-index: 6;
    display: grid;
    gap: 0.35rem;
    width: max-content;
    max-width: min(22rem, 90vw);
    margin: 0.4rem 0 0;
    padding: 0.6rem 0.75rem;
    list-style: none;
    background: var(--plain-bg, #fff);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 6px 20px rgb(0 0 0 / 0.16);
}
.page-view-download-list li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.4rem; margin: 0; }
.page-view-download-list .muted { font-size: 0.8125rem; }
.page-view-import-kinds { margin: 0; font-size: 0.8125rem; }
.page-view-title-form input,
.page-view-title-form textarea { margin: 0; width: 100%; }
.page-view-number--top-right { text-align: right; }
.page-view-number--top-center { text-align: center; }
.page-view-number--bottom-center { top: auto; bottom: 0.5in; text-align: center; }
.page-view-number--none { display: none; }
@media print {
    .page-view-body { background: #fff; }
    .page-view-toolbar { display: none; }
    .page-view { padding: 0; overflow: visible; }
    .page-view-sheets { zoom: 1; gap: 0; }
    .page-view-sheet { box-shadow: none; break-after: page; }
    .page-view-sheet:last-child { break-after: auto; }
}
/* missing.css boxes and clips <details>; this one is a toolbar menu whose panel hangs below it. */
.page-view-import { position: relative; overflow: visible; margin: 0; padding: 0; border: 0; background: none; }
.page-view-import summary { cursor: pointer; }
.page-view-import form {
    position: absolute;
    right: 0;
    z-index: 6;
    display: grid;
    gap: 0.5rem;
    width: min(22rem, 90vw);
    margin-top: 0.4rem;
    padding: 0.75rem;
    background: var(--plain-bg, #fff);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 6px 20px rgb(0 0 0 / 0.16);
}
.page-view-import label { display: flex; flex-direction: column; align-items: stretch; gap: 0.2rem; }
.page-view-import fieldset { display: grid; gap: 0.25rem; margin: 0; padding: 0; border: 0; }
.page-view-import fieldset label { flex-direction: row; align-items: center; gap: 0.4rem; }
.page-view-notice { max-width: 40rem; margin: 0 auto 1rem; }
.page-view-notice--error { color: var(--bad-fg, #b91c1c); }

/* Linked cards field: a chip per linked card and a search box to link one more. */
.part-linked-cards {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    padding: 0.3rem 0.4rem;
    overflow: auto;
    border: var(--part-field-border, 1px solid var(--border));
    border-radius: 4px;
    background: color-mix(in srgb, var(--plain-bg, #fff) 70%, transparent);
}
.part-linked-cards-items { display: flex; flex-wrap: wrap; gap: 0.3rem; margin: 0; padding: 0; list-style: none; }
.part-linked-card {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    max-width: 100%;
    padding: 0.1rem 0.25rem 0.1rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 0.9em;
}
.part-linked-card a { display: inline-flex; gap: 0.35rem; align-items: baseline; min-width: 0; color: inherit; text-decoration: none; }
.part-linked-card a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.part-linked-card a small { color: var(--muted-fg); white-space: nowrap; }
.part-linked-card a:hover span { text-decoration: underline; }
.part-linked-card-hidden { color: var(--muted-fg); }
.part-linked-card-remove { margin: 0; padding: 0 0.3rem; min-width: 0; border: 0; background: none; color: var(--muted-fg); line-height: 1; }
.part-linked-card-remove:hover { color: var(--bad-fg, #b91c1c); }
.part-linked-cards-add { position: relative; }
.part-linked-cards-add input { width: 100%; margin: 0; padding: 0.15rem 0.4rem; font-size: 0.9em; }
.part-linked-cards-menu {
    position: absolute;
    left: 0;
    right: 0;
    z-index: 20;
    max-height: 14rem;
    overflow: auto;
    margin: 0.15rem 0 0;
    padding: 0.2rem 0;
    list-style: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--plain-bg, #fff);
    box-shadow: 0 4px 14px rgb(0 0 0 / 0.14);
}
.part-linked-cards-menu li { display: flex; justify-content: space-between; gap: 0.6rem; padding: 0.2rem 0.6rem; cursor: pointer; font-size: 0.9em; }
.part-linked-cards-menu li small { color: var(--muted-fg); white-space: nowrap; }
.part-linked-cards-menu li[aria-selected="true"] { background: var(--accent-bg, #e0e7ff); }
.wyldcards-linked-from-group { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 0.3rem; }
.wyldcards-linked-from-label { font-style: italic; }

.team-list { margin: 0; padding-left: 1.1rem; display: grid; gap: 0.3rem; }

/* Someone else changed this card: notices stack at the foot of the screen, clear of the card. */
.wyldcards-live-notices {
    position: fixed;
    left: 50%;
    bottom: 1rem;
    z-index: 60;
    display: grid;
    gap: 0.5rem;
    width: min(34rem, calc(100vw - 2rem));
    transform: translateX(-50%);
    pointer-events: none;
}
.wyldcards-live-notice {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--plain-bg, #fff);
    box-shadow: 0 6px 22px rgb(0 0 0 / 0.18);
    font-size: 0.9rem;
    pointer-events: auto;
}
.wyldcards-live-notice p { flex: 1 1 16rem; margin: 0; }
.wyldcards-live-notice button { margin: 0; padding: 0.25rem 0.7rem; font-size: 0.85rem; }
.wyldcards-live-notice--conflict { border-color: var(--bad-fg, #b91c1c); }

/* Edition menu beside the stack name. missing.css boxes and clips <details>; this one is a menu. */
.wyldcards-editions { position: relative; overflow: visible; margin: 0; padding: 0; border: 0; background: none; }
.wyldcards-editions summary {
    display: inline-flex;
    align-items: baseline;
    gap: 0.35rem;
    padding: 0.15rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.85rem;
    white-space: nowrap;
}
.wyldcards-editions-menu {
    position: absolute;
    right: 0;
    max-width: calc(100vw - 2rem);
    z-index: 30;
    display: grid;
    min-width: 14rem;
    margin-top: 0.3rem;
    padding: 0.3rem 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--plain-bg, #fff);
    box-shadow: 0 6px 20px rgb(0 0 0 / 0.16);
}
.wyldcards-editions-menu a { display: flex; align-items: baseline; gap: 0.5rem; padding: 0.3rem 0.8rem; color: inherit; text-decoration: none; font-size: 0.9rem; }
.wyldcards-editions-menu a:hover, .wyldcards-editions-menu a:focus-visible { background: var(--accent-bg, #e0e7ff); }
.wyldcards-editions-current span { font-weight: 700; }
.wyldcards-editions-published { color: var(--accent, #2563eb); }
.wyldcards-editions-manage { border-top: 1px solid var(--border); margin-top: 0.2rem; }
.edition-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
.edition-actions form { margin: 0; }
.edition-actions input { width: 10rem; }

/* Changes: a change per row, its words kept, taken out and put in. */
.changes-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.changes-actions form { margin: 0; }
.changes-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.6rem; }
.change-row { padding: 0.7rem 0.9rem; border: 1px solid var(--border); border-radius: 6px; display: grid; gap: 0.35rem; }
.change-row--undone { opacity: 0.7; }
.change-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.3rem 1rem; }
.change-when { display: inline-flex; gap: 0.8rem; font-size: 0.85rem; white-space: nowrap; }
.change-diff { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.92rem; max-height: 16rem; overflow: auto; }
.change-diff del { background: color-mix(in srgb, var(--bad-fg, #b91c1c) 16%, transparent); text-decoration: line-through; }
.change-diff ins { background: color-mix(in srgb, #15803d 18%, transparent); text-decoration: none; }
.change-row-actions { display: flex; gap: 0.4rem; }
.change-row-actions form { margin: 0; }
.change-row-actions button { margin: 0; padding: 0.2rem 0.6rem; font-size: 0.85rem; }

.part-stack-list-item { position: relative; }
.part-stack-list-item--docked { border-color: color-mix(in srgb, var(--accent, #2563eb) 45%, var(--border)); }
.part-stack-list-badge { position: absolute; top: 0.25rem; right: 0.35rem; font-size: 0.75rem; line-height: 1; }
.part-stack-list-shared {
    font-size: 0.65rem;
    padding: 0 0.35rem;
    border-radius: 999px;
    background: var(--accent-bg);
    color: var(--muted-fg);
}
.part-stack-list-all { border-style: dashed; background: transparent; }
.part-stack-list-filter { grid-column: 1 / -1; }
.part-stack-list-filter-input { width: 100%; box-sizing: border-box; margin: 0; }
.part-stack-list-filter-input::placeholder { text-align: start; }
.part-stack-list-item[hidden] { display: none; }
/* At phone width stack-list-phone.js moves the stack list and All stacks out of the
   scaled card into this panel, at full size, and leaves a note in the part. */
.wyldcards-phone-widget {
    width: 100%;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
    padding: 0.5rem max(0.75rem, env(safe-area-inset-right)) 1rem max(0.75rem, env(safe-area-inset-left));
}
/* The card keeps a short row, the list takes the rest and scrolls, comments stay a strip. */
.wyldcards-workbench:has(> .wyldcards-phone-widget) {
    grid-template-rows: auto minmax(0, 1fr) auto;
}
.wyldcards-workbench:has(> .wyldcards-phone-widget) > .wyldcards-side {
    max-height: 30vh;
}
.wyldcards-phone-widget .part-stack-list {
    height: auto;
    overflow: visible;
    grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr));
    padding: 0;
}
.wyldcards-phone-widget .part-stack-list-item { padding: 0.75rem 0.5rem; }
.wyldcards-phone-widget .part-stack-list-filter-input { font-size: 1rem; text-align: start; }
.wyldcards-phone-widget .stack-grid:not(.stack-dock-grid) {
    grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr));
    gap: 0.6rem;
}
.wyldcards-phone-widget .part-all-stacks.stack-list-page {
    height: auto;
    overflow: visible;
    padding: 0;
}
.part-phone-moved {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: center;
    height: 100%;
    margin: 0;
    font-size: 1.5rem;
    text-align: center;
}
/* Home's Recent window shows cards from every stack, so each names its stack. */
.wyldcards-recent-stack { font-size: 0.7rem; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* The widgets chosen for home, under the Home card */
.wyldcards-home-tray {
    /* The card page can scroll sideways under a wide card; the widgets keep to the screen. */
    width: min(100%, 100vw);
    max-width: 76rem;
    margin: 0.75rem auto;
    padding: 0 0.75rem;
    box-sizing: border-box;
}

/* ---- Stack windows: card strips for moving cards between windows ---- */
.wyldcards-compare-hint {
    margin: -0.25rem 0 0.85rem;
}

.wyldcards-compare-count {
    flex: none;
    font-size: 0.8rem;
}

.wyldcards-compare-pane {
    grid-template-rows: auto auto minmax(0, 1fr);
}

.wyldcards-compare-pane.is-card-drop-target {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent), 0 0.4rem 1.25rem rgb(15 23 42 / 0.12);
}

.wyldcards-window-shelf {
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--bg) 92%, var(--accent-bg));
}

.wyldcards-window-cards {
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 0.45rem;
    max-height: 9.25rem;
    margin: 0;
    padding: 0.55rem 0.65rem;
    overflow-y: auto;
    list-style: none;
}

.wyldcards-window-card {
    position: relative;
    flex: none;
    width: 6.25rem;
    margin: 0;
    padding: 0;
}

.wyldcards-window-card button.wyldcards-window-card-face {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.15rem;
    width: 100%;
    height: 3.9rem;
    margin: 0;
    padding: 0.3rem 0.4rem;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 0.3rem;
    background: var(--gray-0, #fff);
    color: inherit;
    font: inherit;
    font-size: 0.72rem;
    line-height: 1.2;
    text-align: left;
    box-shadow: 0 1px 0 var(--border), 0 2px 0 -1px var(--gray-0, #fff), 0 3px 0 -1px var(--border);
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.wyldcards-window-card button.wyldcards-window-card-face:hover {
    border-color: var(--accent);
}

.wyldcards-window-card button.wyldcards-window-card-face:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.wyldcards-compare-pane[data-stack-window-editable="false"] button.wyldcards-window-card-face {
    cursor: pointer;
}

.wyldcards-window-card.is-current button.wyldcards-window-card-face {
    border-color: var(--accent);
    background: var(--accent-bg);
    box-shadow: inset 0 0 0 1px var(--accent);
}

.wyldcards-window-card-number {
    color: var(--muted-fg, #64748b);
    font-size: 0.65rem;
    font-variant-numeric: tabular-nums;
}

.wyldcards-window-card-name {
    display: -webkit-box;
    overflow: hidden;
    font-weight: 600;
    overflow-wrap: anywhere;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.wyldcards-window-card button.wyldcards-window-card-menu {
    position: absolute;
    box-shadow: none;
    min-width: 0;
    min-height: 0;
    top: 0.1rem;
    right: 0.1rem;
    margin: 0;
    padding: 0 0.3rem;
    border: 0;
    border-radius: 0.25rem;
    background: transparent;
    color: var(--muted-fg, #64748b);
    font-size: 0.8rem;
    line-height: 1.2;
    opacity: 0;
}

.wyldcards-window-card:hover button.wyldcards-window-card-menu,
.wyldcards-window-card:focus-within button.wyldcards-window-card-menu,
.wyldcards-window-card button.wyldcards-window-card-menu[aria-expanded="true"] {
    opacity: 1;
}

@media (hover: none) {
    .wyldcards-window-card button.wyldcards-window-card-menu {
        opacity: 1;
    }
}

.wyldcards-window-card button.wyldcards-window-card-menu:hover,
.wyldcards-window-card button.wyldcards-window-card-menu:focus-visible {
    background: var(--accent-bg);
    color: inherit;
}

.wyldcards-window-card.is-dragging {
    opacity: 0.35;
}

.wyldcards-window-card.is-saving {
    opacity: 0.5;
    pointer-events: none;
}

.wyldcards-window-card.is-arrived .wyldcards-window-card-face {
    animation: wyldcards-window-card-arrive 1.2s ease-out;
}

@keyframes wyldcards-window-card-arrive {
    0% { transform: scale(1.08); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 45%, transparent); }
    100% { transform: none; box-shadow: 0 0 0 0 transparent; }
}

.wyldcards-window-card-drop {
    flex: none;
    width: 3px;
    height: 3.9rem;
    margin: 0 -0.1rem;
    border-radius: 2px;
    background: var(--accent);
    list-style: none;
}

.wyldcards-window-card-ghost {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 10000;
    display: grid;
    gap: 0.25rem;
    max-width: 13rem;
    pointer-events: none;
}

.wyldcards-window-card-ghost-face {
    width: 6.25rem;
    padding: 0.3rem 0.4rem;
    overflow: hidden;
    border: 1px solid var(--accent);
    border-radius: 0.3rem;
    background: var(--gray-0, #fff);
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
    box-shadow: 0 0.5rem 1.2rem rgb(15 23 42 / 0.25);
    transform: rotate(-3deg);
}

.wyldcards-window-card-ghost-action {
    justify-self: start;
    padding: 0.15rem 0.45rem;
    border-radius: 999px;
    background: var(--accent);
    color: var(--accent-contrast, #fff);
    font-size: 0.72rem;
    white-space: nowrap;
}

.wyldcards-window-card-ghost.is-copy .wyldcards-window-card-ghost-action::before {
    content: "+ ";
    font-weight: 700;
}

/* Frames would swallow the pointer mid-drag; the page tracks it instead. */
.is-dragging-window-card .wyldcards-compare-frame {
    pointer-events: none;
}

.is-dragging-window-card,
.is-dragging-window-card * {
    cursor: grabbing !important;
}

.wyldcards-window-card-popup {
    position: absolute;
    z-index: 10000;
    display: grid;
    min-width: 12rem;
    max-width: min(20rem, calc(100vw - 1rem));
    padding: 0.3rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--bg, #fff);
    box-shadow: 0 0.5rem 1.5rem rgb(15 23 42 / 0.2);
}

.wyldcards-window-card-popup button[role="menuitem"] {
    margin: 0;
    padding: 0.35rem 0.55rem;
    border: 0;
    border-radius: 0.3rem;
    background: transparent;
    box-shadow: none;
    font-weight: 500;
    justify-content: flex-start;
    color: inherit;
    font-size: 0.85rem;
    text-align: left;
}

.wyldcards-window-card-popup button[role="menuitem"]:hover,
.wyldcards-window-card-popup button[role="menuitem"]:focus-visible {
    background: var(--accent-bg);
}

.wyldcards-window-card-popup p {
    margin: 0.3rem 0.55rem;
    font-size: 0.8rem;
}

:root.-dark-theme .wyldcards-window-card-face,
:root.-dark-theme .wyldcards-window-card-ghost-face {
    background: var(--bg, #121210);
}

@media (prefers-reduced-motion: reduce) {
    .wyldcards-window-card.is-arrived .wyldcards-window-card-face {
        animation: none;
        box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 45%, transparent);
    }
}
