/* =========================================================================
   Design tokens
   ========================================================================= */
:root {
    --color-bg: #f6f7fb;
    --color-surface: #ffffff;
    --color-surface-alt: #f1f3f9;
    --color-border: #e2e5ec;
    --color-text: #1b1f27;
    --color-text-muted: #6b7280;
    --color-primary: #4f46e5;
    --color-primary-hover: #4338ca;
    --color-primary-soft: rgba(79, 70, 229, 0.1);
    --color-secondary: #6b7280;
    --color-secondary-hover: #4b5563;
    --color-success: #16a34a;
    --color-success-hover: #15803d;
    --color-danger: #dc2626;
    --color-danger-hover: #b91c1c;
    --color-warning: #d97706;
    --color-warning-hover: #b45309;
    --color-info: #0891b2;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
    --shadow-md: 0 4px 12px rgba(16, 24, 40, 0.08);
    --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.14);
    --font-sans: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    --nav-height: 60px;
}

/* =========================================================================
   Dark mode theme overrides (applied via .theme-dark wrapper, set per-user preference)
   ========================================================================= */
.theme-dark {
    --color-bg: #15151a;
    --color-surface: #1e1e25;
    --color-surface-alt: #26262f;
    --color-border: #34343f;
    --color-text: #f0f0f3;
    --color-text-muted: #a0a0ad;
    --color-primary: #7c6bf2;
    --color-primary-hover: #8f80f5;
    --color-primary-soft: rgba(124, 107, 242, 0.18);
    --color-secondary: #a0a0ad;
    --color-secondary-hover: #c0c0cc;
    --color-success: #4ade80;
    --color-success-hover: #22c55e;
    --color-danger: #f87171;
    --color-danger-hover: #ef4444;
    --color-warning: #fbbf24;
    --color-warning-hover: #f59e0b;
    --color-info: #22d3ee;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);

    background: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
}

/* =========================================================================
   Base / reset
   ========================================================================= */
*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-sans);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.25;
    margin: 0 0 0.5rem;
    color: var(--color-text);
}

a {
    color: var(--color-primary);
    text-decoration: none;
}

    a:hover {
        text-decoration: underline;
    }

p {
    margin: 0 0 0.75rem;
}

.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
}

.app-container:has(> .editor-shell) {
    max-width: none;
    padding: 0;
}

.app-container:has(> .catalog-page) {
    max-width: none;
    padding: 0;
}

.editor-shell {
    width: 100%;
}

h1:focus {
    outline: none;
}

/* =========================================================================
   Buttons
   ========================================================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.2;
    padding: 0.55rem 1.1rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
    text-decoration: none;
    white-space: nowrap;
}

    .btn:active {
        transform: translateY(1px);
    }

    .btn:disabled {
        opacity: 0.55;
        cursor: not-allowed;
        transform: none;
    }

.btn-sm {
    padding: 0.3rem 0.65rem;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

.btn-primary {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}

    .btn-primary:hover {
        background: var(--color-primary-hover);
        border-color: var(--color-primary-hover);
        color: #fff;
    }

.btn-secondary {
    background: var(--color-secondary);
    border-color: var(--color-secondary);
    color: #fff;
}

    .btn-secondary:hover {
        background: var(--color-secondary-hover);
        border-color: var(--color-secondary-hover);
        color: #fff;
    }

.btn-success {
    background: var(--color-success);
    border-color: var(--color-success);
    color: #fff;
}

    .btn-success:hover {
        background: var(--color-success-hover);
        border-color: var(--color-success-hover);
    }

.btn-danger {
    background: var(--color-danger);
    border-color: var(--color-danger);
    color: #fff;
}

    .btn-danger:hover {
        background: var(--color-danger-hover);
        border-color: var(--color-danger-hover);
    }

.btn-warning {
    background: var(--color-warning);
    border-color: var(--color-warning);
    color: #fff;
}

    .btn-warning:hover {
        background: var(--color-warning-hover);
        border-color: var(--color-warning-hover);
    }

.btn-outline-primary {
    background: transparent;
    border-color: var(--color-primary);
    color: var(--color-primary);
}

    .btn-outline-primary:hover {
        background: var(--color-primary-soft);
    }

.btn-outline-secondary {
    background: transparent;
    border-color: var(--color-border);
    color: var(--color-text);
}

    .btn-outline-secondary:hover {
        background: var(--color-surface-alt);
    }

.btn-outline-danger {
    background: transparent;
    border-color: var(--color-danger);
    color: var(--color-danger);
}

    .btn-outline-danger:hover {
        background: rgba(220, 38, 38, 0.08);
    }

.btn-outline-warning {
    background: transparent;
    border-color: var(--color-warning);
    color: var(--color-warning);
}

    .btn-outline-warning:hover {
        background: rgba(217, 119, 6, 0.08);
    }

.btn-outline-light {
    background: transparent;
    border-color: rgba(255, 255, 255, 0.55);
    color: #f5f5f5;
}

    .btn-outline-light:hover {
        background: rgba(255, 255, 255, 0.12);
        color: #ffffff;
    }

.btn-link {
    background: transparent;
    border: none;
    color: var(--color-primary);
    padding: 0.3rem 0.2rem;
    text-decoration: underline;
}

    .btn-link:hover {
        color: var(--color-primary-hover);
    }

/* Compact circular "x" dismiss button used inside condition/assignment rows. */
.btn-icon-remove {
    appearance: none;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.6rem;
    height: 1.6rem;
    padding: 0;
    border: 1px solid var(--color-border);
    border-radius: 50%;
    background: var(--color-surface);
    color: var(--color-text-muted);
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

    .btn-icon-remove:hover {
        background: rgba(220, 38, 38, 0.08);
        border-color: var(--color-danger);
        color: var(--color-danger);
    }

.w-100 {
    width: 100%;
}

.mx-auto {
    margin-left: auto;
    margin-right: auto;
    display: block;
}

/* =========================================================================
   Forms
   ========================================================================= */
.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
    color: var(--color-text);
}

.form-control, .form-select {
    width: 100%;
    font-family: inherit;
    font-size: 0.9rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

    .form-control:focus, .form-select:focus {
        outline: none;
        border-color: var(--color-primary);
        box-shadow: 0 0 0 3px var(--color-primary-soft);
    }

    .form-control.is-invalid, .form-select.is-invalid {
        border-color: var(--color-danger);
    }

        .form-control.is-invalid:focus, .form-select.is-invalid:focus {
            box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15);
        }

.choice-duplicate-warning {
    margin: -0.25rem 0 0.5rem;
    font-size: 0.8rem;
}

.form-text {
    display: block;
    font-size: 0.78rem;
    color: var(--color-text-muted);
    margin: 0.25rem 0 0.5rem;
}

.form-control-sm, .form-select-sm {
    padding: 0.35rem 0.6rem;
    font-size: 0.82rem;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.node-flag-row {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.node-flag-badges {
    display: flex;
    gap: 0.35rem;
}

.node-background-color-row {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}

    .node-background-color-row .form-control-color {
        flex: 0 0 auto;
        width: 2.5rem;
        padding: 0.2rem;
    }

    .node-background-color-row input[type="text"],
    .node-background-color-row .form-control:not(.form-control-color) {
        flex: 1 1 auto;
        min-width: 0;
    }

.form-check-input {
    width: 1.1rem;
    height: 1.1rem;
    accent-color: var(--color-primary);
    cursor: pointer;
}

.form-check-label {
    font-size: 0.88rem;
    cursor: pointer;
}

.form-floating {
    position: relative;
}

    .form-floating > label {
        position: absolute;
        top: 0.5rem;
        left: 0.75rem;
        font-size: 0.75rem;
        color: var(--color-text-muted);
        pointer-events: none;
        transition: all 0.1s ease;
    }

    .form-floating > .form-control {
        padding-top: 1.25rem;
    }

.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }

/* =========================================================================
   Tables
   ========================================================================= */
.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-surface);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

    .table th, .table td {
        padding: 0.75rem 1rem;
        text-align: left;
        border-bottom: 1px solid var(--color-border);
        font-size: 0.9rem;
    }

    .table th {
        background: var(--color-surface-alt);
        font-weight: 600;
        color: var(--color-text-muted);
        text-transform: uppercase;
        font-size: 0.72rem;
        letter-spacing: 0.04em;
    }

    .table tbody tr:hover {
        background: var(--color-surface-alt);
    }

    .table tbody tr:last-child td {
        border-bottom: none;
    }

/* =========================================================================
   Alerts / misc utilities
   ========================================================================= */
.alert {
    padding: 0.85rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.alert-info {
    background: #eff8ff;
    border-color: #bee3f8;
    color: #0c4a6e;
}

.alert-warning {
    background: #fffbeb;
    border-color: #fde68a;
    color: #92400e;
}

.alert-danger {
    background: #fef2f2;
    border-color: #fecaca;
    color: #991b1b;
}

.alert-success {
    background: #f0fdf4;
    border-color: #bbf7d0;
    color: #166534;
}

.text-muted {
    color: var(--color-text-muted);
}

.text-danger {
    color: var(--color-danger);
}

.text-success {
    color: var(--color-success);
}

.text-warning {
    color: var(--color-warning);
}

h1:focus {
    outline: none;
}

.auth-brand-logo {
    display: block;
    margin-bottom: 1rem;
}

.auth-page {
    display: flex;
    justify-content: center;
    padding: 2rem 1rem;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--color-surface, #fff);
    border: 1px solid var(--color-border);
    border-radius: 0.6rem;
    box-shadow: var(--shadow-md, 0 4px 12px rgba(0, 0, 0, 0.1));
    padding: 2rem;
}

    .auth-card .auth-brand-logo {
        margin: 0 auto 1rem;
    }

    .auth-card h1 {
        font-size: 1.4rem;
        text-align: center;
        margin-bottom: 1.25rem;
    }

.auth-card-links {
    margin-top: 1rem;
    text-align: center;
}

    .auth-card-links p {
        margin-bottom: 0.4rem;
        font-size: 0.9rem;
    }

.auth-divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 0.8rem;
    margin: 1.25rem 0;
}

    .auth-divider::before,
    .auth-divider::after {
        content: "";
        flex: 1;
        border-bottom: 1px solid var(--color-border);
    }

    .auth-divider span {
        padding: 0 0.75rem;
    }

.external-login-form {
    margin: 0;
}

.external-login-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.external-login-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.55rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: 0.4rem;
    background: var(--color-surface, #fff);
    color: var(--color-text);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, box-shadow 0.15s ease;
}

    .external-login-btn:hover {
        background: var(--color-surface-hover, rgba(0, 0, 0, 0.04));
        box-shadow: var(--shadow-sm);
    }

.external-login-icon {
    display: inline-flex;
    align-items: center;
}

.top-nav {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 1.25rem;
    padding: 0 1.5rem;
    height: var(--nav-height);
    background: #14141f;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 50;
}

    .top-nav .nav-link {
        color: rgba(255, 255, 255, 0.82);
        text-decoration: none;
        font-size: 0.9rem;
        font-weight: 500;
        padding: 0.4rem 0;
        border-bottom: 2px solid transparent;
        transition: color 0.15s ease, border-color 0.15s ease;
    }

    .top-nav .nav-brand {
        font-size: 1.1rem;
        font-weight: 700;
        color: #fff;
        margin-right: 0.5rem;
        display: inline-flex;
        align-items: center;
        gap: 0.4rem;
    }

        .top-nav .nav-brand-logo {
            display: block;
        }

        .top-nav .nav-link:hover {
            color: #fff;
            text-decoration: none;
            border-bottom-color: var(--color-primary);
        }

    .top-nav .nav-link-button {
        background: none;
        border: none;
        padding: 0;
        font: inherit;
        cursor: pointer;
    }

    .top-nav .nav-logout-btn {
        margin-left: 0.5rem;
    }

.quota-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    align-items: center;
    margin-bottom: 1.25rem;
    padding: 0.85rem 1.1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    font-size: 0.9rem;
}

.create-story-form {
    display: flex;
    gap: 0.5rem;
    max-width: 480px;
    margin-bottom: 1.5rem;
}

.stats-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stats-summary-card {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 140px;
    padding: 0.85rem 1.1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.stats-summary-value {
    font-size: 1.6rem;
    font-weight: 700;
}

.stats-summary-label {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.moderator-actions {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

/* =========================================================================
   Admin / Moderation pages
   ========================================================================= */
.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

    .page-header h1 {
        margin-bottom: 0.25rem;
    }

    .page-header p {
        color: var(--color-text-muted);
        margin: 0;
    }

.search-form {
    display: flex;
    gap: 0.5rem;
    max-width: 420px;
    margin-bottom: 1.5rem;
}

.empty-state {
    padding: 1.5rem;
    text-align: center;
    color: var(--color-text-muted);
    background: var(--color-surface);
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-md);
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    line-height: 1.4;
}

.badge-neutral {
    background: var(--color-surface-alt);
    color: var(--color-text-muted);
}

.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}

.badge-info {
    background: rgba(8, 145, 178, 0.12);
    color: var(--color-info);
}

.badge-success {
    background: rgba(22, 163, 74, 0.12);
    color: var(--color-success);
}

.badge-warning {
    background: rgba(217, 119, 6, 0.12);
    color: var(--color-warning);
}

.badge-danger {
    background: rgba(220, 38, 38, 0.12);
    color: var(--color-danger);
}

.badge-admin {
    background: rgba(79, 70, 229, 0.12);
    color: var(--color-primary);
}

.role-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.user-detail-panel {
    margin-bottom: 1.5rem;
}

    .user-detail-panel .user-detail-header {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        gap: 0.75rem;
        margin-bottom: 0.75rem;
    }

    .user-detail-panel h3 {
        margin: 0;
    }

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1.75rem;
    margin-bottom: 0.75rem;
}

    .section-heading h3 {
        margin: 0;
    }

.section-heading-plain {
    margin-top: 0;
    margin-bottom: 0.75rem;
}

.list-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 0;
    list-style: none;
    margin: 0;
    overflow: hidden;
}

    .list-card li {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.75rem;
        padding: 0.65rem 1rem;
        border-bottom: 1px solid var(--color-border);
        font-size: 0.9rem;
    }

    .list-card li:last-child {
        border-bottom: none;
    }

.account-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.25rem;
}

    .account-card h3,
    .account-card h5 {
        margin-top: 0;
    }

.store-bundle-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.25rem;
}

.store-bundle-card {
    text-align: center;
    display: flex;
    flex-direction: column;
}

.store-bundle-price {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0.5rem 0 1rem;
    white-space: nowrap;
}

    .store-bundle-price-per-slot {
        font-size: 0.8rem;
        font-weight: 400;
        margin-left: 0.35rem;
    }

    .store-bundle-card .action-buttons {
        flex-direction: column;
        align-items: stretch;
        margin-top: auto;
    }

        .store-bundle-card .action-buttons .btn {
            width: 100%;
        }

.manage-layout {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}

.manage-nav {
    flex: 0 0 220px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 0.75rem;
}

.manage-content {
    flex: 1 1 auto;
    min-width: 0;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
}

.manage-nav-list {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

    .manage-nav-list li {
        list-style: none;
    }

    .manage-nav-list .manage-nav-link {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        border-radius: var(--radius-sm);
        padding: 0.5rem 0.75rem;
        color: var(--color-text);
        font-size: 0.9rem;
        text-decoration: none;
        transition: background-color 0.15s ease, color 0.15s ease;
    }

    .manage-nav-list .manage-nav-icon {
        font-size: 1rem;
        line-height: 1;
    }

    .manage-nav-list .manage-nav-link.active {
        background: var(--color-primary-soft);
        color: var(--color-primary);
        font-weight: 600;
    }

    .manage-nav-list .manage-nav-link:hover {
        background: var(--color-surface-alt);
        text-decoration: none;
    }

.story-author {
    margin-top: -0.5rem;
    margin-bottom: 0.75rem;
    color: var(--color-muted, #6c757d);
}

.moderator-actions {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.15rem;
    align-items: center;
    padding: 0.5rem 1rem;
    background: var(--color-editor-menubar-bg, #1b1e2b);
    border-bottom: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
    position: relative;
}

.editor-story-title {
    font-weight: 600;
    font-size: 1.05rem;
    margin-right: auto;
    color: var(--color-editor-menubar-text, #f1f2f6);
}

.editor-toolbar-actions {
    display: flex;
    gap: 0.3rem;
    align-items: center;
}

    .editor-toolbar-actions .btn-outline-secondary {
        border-color: var(--color-editor-menubar-muted, rgba(241, 242, 246, 0.45));
        color: var(--color-editor-menubar-text, #f1f2f6);
    }

        .editor-toolbar-actions .btn-outline-secondary:hover {
            background: var(--color-editor-menubar-hover, rgba(255, 255, 255, 0.1));
        }

        .editor-toolbar-actions .btn-outline-secondary:disabled {
            border-color: var(--color-editor-menubar-muted, rgba(241, 242, 246, 0.25));
            color: var(--color-editor-menubar-muted, rgba(241, 242, 246, 0.45));
            background: transparent;
            opacity: 1;
        }

.editor-search-popover {
    position: absolute;
    top: 100%;
    right: 1rem;
    margin-top: 0.25rem;
    width: 320px;
    max-width: calc(100vw - 2rem);
    background: var(--color-surface, #fff);
    border: 1px solid var(--color-border);
    border-radius: 0.4rem;
    box-shadow: var(--shadow-md, 0 4px 12px rgba(0, 0, 0, 0.2));
    padding: 0.5rem;
    z-index: 50;
}

.editor-search-results {
    list-style: none;
    margin: 0.4rem 0 0;
    padding: 0;
    max-height: 260px;
    overflow-y: auto;
}

    .editor-search-results li {
        margin-bottom: 0.15rem;
    }

.editor-search-result-item {
    display: flex;
    flex-direction: column;
    width: 100%;
    text-align: left;
    padding: 0.4rem 0.5rem;
    border: none;
    border-radius: 0.3rem;
    background: transparent;
    cursor: pointer;
}

    .editor-search-result-item:hover {
        background: var(--color-surface-hover, rgba(0, 0, 0, 0.06));
    }

    .editor-search-result-item span {
        font-size: 0.8rem;
    }

.editor-file-menu {
    position: relative;
}

.editor-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.editor-modal {
    background: var(--color-surface, #fff);
    border-radius: 0.5rem;
    box-shadow: var(--shadow-md, 0 4px 12px rgba(0, 0, 0, 0.3));
    padding: 1.25rem;
    width: 420px;
    max-width: calc(100vw - 2rem);
}

.editor-modal-orphan-list {
    max-height: 200px;
    overflow-y: auto;
    margin: 0.5rem 0;
    padding-left: 1.25rem;
}

.editor-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1rem;
}

.editor-orphan-banner {
    position: absolute;
    left: 0.5rem;
    right: 0.5rem;
    bottom: 0.5rem;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 0.4rem;
    padding: 0.6rem 0.85rem;
    z-index: 10;
    box-shadow: var(--shadow-md, 0 4px 12px rgba(0, 0, 0, 0.2));
}

.editor-orphan-banner-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #664d03;
}

.editor-orphan-banner-list {
    list-style: none;
    margin: 0.4rem 0 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

    .editor-orphan-banner-list li {
        display: flex;
        align-items: center;
        gap: 0.4rem;
        background: #fff;
        border: 1px solid var(--color-border);
        border-radius: 0.3rem;
        padding: 0.25rem 0.4rem;
    }

.editor-orphan-banner-item {
    border: none;
    background: transparent;
    color: #1b1f27;
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: underline;
    cursor: pointer;
    padding: 0;
}

.editor-orphan-connect-btn {
    border: 1px solid #997404;
    background: #ffc107;
    color: #1b1f27;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 0.25rem;
    padding: 0.2rem 0.5rem;
    white-space: nowrap;
    cursor: pointer;
}

    .editor-orphan-connect-btn:disabled {
        border-color: #c7cad3;
        background: #e9ecef;
        color: #6c757d;
        cursor: not-allowed;
    }

    .editor-orphan-connect-btn:not(:disabled):hover {
        background: #e0a800;
    }

    .editor-file-menu summary {
        display: flex;
        align-items: center;
        gap: 0.35rem;
        cursor: pointer;
        list-style: none;
        padding: 0.45rem 0.85rem;
        border-radius: 0.3rem;
        font-size: 0.9rem;
        font-weight: 600;
        color: var(--color-editor-menubar-text, #f1f2f6);
        background: transparent;
        border: none;
    }

        .editor-file-menu summary::-webkit-details-marker {
            display: none;
        }

        .editor-file-menu summary::after {
            content: "";
            display: inline-block;
            width: 0;
            height: 0;
            margin-left: 0.15rem;
            border-left: 4px solid transparent;
            border-right: 4px solid transparent;
            border-top: 5px solid currentColor;
            opacity: 0.7;
        }

        .editor-file-menu summary:hover {
            background: var(--color-editor-menubar-hover, rgba(255, 255, 255, 0.1));
        }

    .editor-file-menu[open] summary {
        background: var(--color-editor-menubar-hover, rgba(255, 255, 255, 0.14));
    }

.editor-file-menu-content {
    position: absolute;
    top: calc(100% + 0.35rem);
    left: 0;
    z-index: 20;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.25rem;
    min-width: 250px;
    padding: 0.5rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 0.375rem;
    box-shadow: var(--shadow-md);
}

.editor-file-menu-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.5rem 0.6rem;
    border: none;
    background: none;
    color: var(--color-text, inherit);
    text-align: left;
    font-size: 0.9rem;
    border-radius: 0.25rem;
    cursor: pointer;
    text-decoration: none;
}

.editor-file-menu-item-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.editor-file-menu-item-title {
    font-weight: 600;
}

.editor-file-menu-item-subtitle {
    font-size: 0.75rem;
    color: var(--color-text-muted, #6c757d);
}

    .editor-file-menu-item:hover {
        background: var(--color-border);
        color: var(--color-text, inherit);
        text-decoration: none;
    }

.editor-file-menu-icon {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
}

.editor-autosave-status {
    font-size: 0.85rem;
    color: var(--color-editor-menubar-muted, rgba(241, 242, 246, 0.65));
    min-width: 6rem;
}

.modal-backdrop-custom {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-dialog-custom {
    background: var(--color-surface, #fff);
    border-radius: var(--radius-md, 8px);
    box-shadow: var(--shadow-md);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 1.25rem;
    gap: 0.75rem;
}

    .modal-dialog-custom > .asset-list {
        overflow-y: auto;
    }

.modal-dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--color-border);
}

    .modal-dialog-header h5 {
        margin: 0;
    }

    .modal-dialog-header .btn-close {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 2rem;
        height: 2rem;
        padding: 0;
        border: none;
        border-radius: 50%;
        background: transparent;
        color: var(--color-text);
        font-size: 1.1rem;
        line-height: 1;
        cursor: pointer;
        flex-shrink: 0;
    }

        .modal-dialog-header .btn-close::before {
            content: "\2715";
        }

        .modal-dialog-header .btn-close:hover {
            background: var(--color-border);
        }

.modal-dialog-body {
    padding: 1.25rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

    .modal-dialog-body .story-detail-field {
        flex: none;
        min-width: 0;
    }

    .modal-dialog-body .story-detail-row {
        gap: 1rem;
    }

.modal-dialog-footer {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--color-border);
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

.editor-body {
    display: flex;
    height: calc(100vh - 110px);
}

.node-canvas {
    position: relative;
    flex: 1;
    background: #f5f5f5;
    overflow: auto;
    transition: flex-basis 0.25s ease, width 0.25s ease;
}

    .node-canvas.panning-enabled {
        cursor: grab;
    }

    .node-canvas.panning-active {
        cursor: grabbing;
        user-select: none;
    }

.editor-sidebar {
    width: 480px;
    flex-shrink: 0;
    border-left: 1px solid #ddd;
    overflow-y: auto;
    padding: 0.5rem;
    transition: width 0.25s ease;
}

.sidebar-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--color-border);
    margin-bottom: 0.75rem;
}

.editor-panel-tabs {
    display: flex;
    gap: 0.1rem;
    margin-left: 0.25rem;
}

    .editor-panel-tabs .sidebar-tab {
        border: none;
        border-radius: 0.3rem;
        background: transparent;
        padding: 0.45rem 0.85rem;
        font-weight: 600;
        color: var(--color-editor-menubar-text, #f1f2f6);
    }

        .editor-panel-tabs .sidebar-tab:hover {
            background: var(--color-editor-menubar-hover, rgba(255, 255, 255, 0.1));
            color: var(--color-editor-menubar-text, #f1f2f6);
        }

        .editor-panel-tabs .sidebar-tab.active {
            background: var(--color-editor-menubar-hover, rgba(255, 255, 255, 0.16));
            color: var(--color-editor-menubar-text, #f1f2f6);
        }

.test-play-icon {
    display: inline-block;
    margin-left: 0.25rem;
    font-size: 0.75em;
}

.editor-panel-tabs .sidebar-tab,
.editor-panel-popover-tabs .sidebar-tab {
    white-space: nowrap;
}

.editor-panel-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.25);
    z-index: 1000;
    display: flex;
    justify-content: flex-end;
}

.editor-panel-popover {
    position: relative;
    width: 100%;
    max-width: 520px;
    height: 100%;
    overflow-y: auto;
    background: var(--color-surface);
    box-shadow: var(--shadow-md);
    padding: 1.25rem;
    padding-top: 2.5rem;
}

.editor-panel-popover-wide {
    max-width: min(1400px, 95vw);
}

.editor-panel-popover-tabs {
    margin-bottom: 1rem;
}

.editor-panel-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--color-text);
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
}

    .editor-panel-close:hover {
        background: var(--color-border);
    }

.editor-properties-panel {
    max-width: 760px;
    margin: 0;
    padding: 1rem 1.25rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

    .editor-properties-panel > h4 {
        font-size: 0.78rem;
        font-weight: 700;
        letter-spacing: 0.04em;
        text-transform: uppercase;
        color: var(--color-text-muted);
        margin-bottom: 0.9rem;
    }

.sidebar-tab {
    appearance: none;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -3px;
    padding: 0.55rem 0.9rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text-muted);
    cursor: pointer;
}

    .sidebar-tab:hover {
        color: var(--color-text);
        background: var(--color-border);
    }

    .sidebar-tab.active {
        color: var(--color-primary);
        font-weight: 700;
        background: var(--color-primary-soft);
        border-bottom-color: var(--color-primary);
    }

.sidebar-tab-content.d-none {
    display: none;
}

.sidebar-main {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-start;
}

.sidebar-properties,
.sidebar-canvas {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 0.85rem 1rem;
}

    .sidebar-properties > .sidebar-panel,
    .sidebar-canvas > .sidebar-panel {
        border-bottom: none;
        margin-bottom: 0;
        padding-bottom: 0;
    }

    .sidebar-properties > .sidebar-panel > h4,
    .sidebar-canvas > .sidebar-panel > h4 {
        margin: -0.85rem -1rem 0.75rem;
        padding: 0.6rem 1rem;
        font-size: 0.85rem;
        letter-spacing: 0.02em;
        text-transform: uppercase;
        color: var(--color-text-muted);
        background: var(--color-surface-alt);
        border-bottom: 1px solid var(--color-border);
        border-radius: var(--radius-md) var(--radius-md) 0 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

.sidebar-properties {
    flex: 1 1 260px;
    min-width: 260px;
    order: 2;
}

.sidebar-canvas {
    flex: 2 1 320px;
    min-width: 260px;
    order: 1;
}

/* When no node is selected, the user is browsing/building the tree: give it most of the space. */
.editor-body.browsing-tree .node-canvas {
    flex: 1;
}

.editor-body.browsing-tree .editor-sidebar {
    width: 340px;
}

    .editor-body.browsing-tree .editor-sidebar .sidebar-main {
        flex-direction: column;
    }

        .editor-body.browsing-tree .editor-sidebar .sidebar-main .sidebar-properties,
        .editor-body.browsing-tree .editor-sidebar .sidebar-main .sidebar-canvas {
            min-width: 0;
            width: 100%;
        }

/* When a node is selected, the user is editing its page canvas: give the sidebar (and its page canvas) more room. */
.editor-body.editing-node .node-canvas {
    flex: 0 1 320px;
    min-width: 220px;
}

.editor-body.editing-node .editor-sidebar {
    width: auto;
    flex: 1 1 auto;
}

.node-graph {
    position: relative;
}

.node-graph-lines {
    position: absolute;
    left: 0;
    top: 0;
    pointer-events: none;
}

    .node-graph-lines path {
        stroke-width: 2;
    }

    .node-graph-lines path.graph-edge-solid {
        stroke: #9094a3;
        stroke-dasharray: none;
    }

    .node-graph-lines path.graph-edge-dashed {
        stroke: #c7cad3;
        stroke-dasharray: 6 4;
    }

    .node-graph-lines polygon.graph-arrowhead-solid {
        fill: #9094a3;
    }

    .node-graph-lines polygon.graph-arrowhead-dashed {
        fill: #c7cad3;
    }

.graph-node {
    position: absolute;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 0.6rem;
    cursor: pointer;
    user-select: none;
    box-shadow: var(--shadow-sm);
    box-sizing: border-box;
    transition: box-shadow 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

    .graph-node:hover {
        box-shadow: var(--shadow-md);
        transform: translateY(-1px);
    }

    .graph-node.selected {
        border-color: var(--color-primary);
        box-shadow: 0 0 0 3px var(--color-primary-soft), var(--shadow-md);
    }

.graph-node-placeholder {
    position: absolute;
    border: 2px dashed #c7cad3;
    border-radius: var(--radius-md);
    background: rgba(79, 70, 229, 0.03);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-sizing: border-box;
    transition: border-color 0.15s ease, background 0.15s ease;
}

    .graph-node-placeholder:hover {
        border-color: var(--color-primary);
        background: var(--color-primary-soft);
    }

.graph-placeholder-plus {
    font-size: 1.5rem;
    color: #b0b3bd;
}

.story-node-header {
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
    color: var(--color-text);
}

.story-node-body {
    font-size: 0.78rem;
    color: var(--color-text-muted);
}

.story-node-badges {
    display: flex;
    gap: 0.35rem;
    margin-top: 0.35rem;
}

.story-node-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    font-size: 1rem;
    line-height: 1;
    border-radius: 50%;
}

.story-node-badge-start {
    color: var(--color-success);
}

.story-node-badge-ending {
    color: var(--color-danger);
    font-size: 0.85rem;
}

.sidebar-panel {
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 0.75rem;
    margin-bottom: 0.75rem;
}

    .sidebar-panel > h4 {
        font-size: 0.78rem;
        font-weight: 700;
        letter-spacing: 0.04em;
        text-transform: uppercase;
        color: var(--color-text-muted);
        margin-bottom: 0.9rem;
    }

.slug-editor-url-preview {
    font-size: 0.9rem;
    font-weight: 600;
    word-break: break-all;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.65rem;
    margin-bottom: 0.5rem;
}

.slug-editor-hint {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-bottom: 0.4rem;
}

.slug-editor-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.slug-editor-row {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.slug-editor-prefix {
    color: var(--color-text-muted);
    font-size: 0.85rem;
    white-space: nowrap;
}

.slug-editor-row .form-control {
    flex: 1 1 auto;
    min-width: 0;
}

.choice-row, .condition-row, .variable-row, .asset-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    align-items: center;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.6rem;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

    .choice-row:hover, .condition-row:hover, .variable-row:hover, .asset-row:hover {
        border-color: #c7cad3;
    }

    .choice-row > .form-control,
    .choice-row > .form-select,
    .condition-row > .form-control,
    .condition-row > .form-select,
    .variable-row > .form-control,
    .variable-row > .form-select {
        flex: 1 1 0;
        min-width: 0;
    }

    .choice-row > .btn, .condition-row > .btn, .variable-row > .btn, .asset-row > .btn {
        flex-shrink: 0;
    }

.assignment-row {
    flex-wrap: wrap;
}

    .assignment-row > .form-select,
    .assignment-row > .form-control {
        flex: 1 1 110px;
        min-width: 90px;
    }

    .assignment-row > .btn {
        flex-shrink: 0;
    }

.choice-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.4rem;
    height: 1.4rem;
    border-radius: 50%;
    color: #fff;
    font-size: 0.75rem;
    font-weight: bold;
    flex-shrink: 0;
}

.script-condition-builder {
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 0.65rem 0.75rem;
    margin-bottom: 0.6rem;
}

.script-condition-rows {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    margin-bottom: 0.5rem;
}

.script-condition-row {
    display: flex;
    gap: 0.4rem;
    align-items: center;
    flex-wrap: wrap;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.5rem;
}

    .script-condition-row > .form-control,
    .script-condition-row > .form-select {
        flex: 1 1 110px;
        min-width: 90px;
    }

.script-condition-join {
    max-width: 5.5rem;
    flex-shrink: 0;
    font-weight: 600;
}

.script-condition-operator {
    max-width: 4.5rem;
    flex-shrink: 0;
}

.script-condition-not {
    flex-shrink: 0;
    margin-bottom: 0;
    white-space: nowrap;
}

.script-condition-compare-toggle {
    flex-shrink: 0;
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    white-space: nowrap;
}

.script-condition-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.script-condition-new-variable {
    display: flex;
    gap: 0.4rem;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 0.4rem;
}

    .script-condition-new-variable > .form-control,
    .script-condition-new-variable > .form-select {
        flex: 1 1 110px;
        min-width: 90px;
    }

.node-assignment-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}

.node-section-divider {
    margin: 0.9rem 0;
    border: none;
    border-top: 1px solid var(--color-border);
}

.delete-confirm {
    background: var(--color-surface);
    border: 1px solid var(--color-danger, #dc3545);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.75rem;
}

    .delete-confirm .btn {
        margin-right: 0.4rem;
    }


.asset-list {
    list-style: none;
    padding: 0;
    margin-top: 0.5rem;
}

.asset-section-heading {
    margin-top: 1.5rem;
    margin-bottom: 0.25rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text-muted);
}

    .asset-section-heading:first-of-type {
        margin-top: 0.5rem;
    }

.canvas-toolbar {
    display: flex;
    gap: 0.75rem;
    align-items: stretch;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
    padding: 0.6rem;
    background: var(--color-surface-muted, #f4f5f7);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}

.toolbox-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 0.4rem 0.6rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm, 4px);
}

.toolbox-group-active {
    border-color: var(--color-primary);
    background: var(--color-primary-soft);
}

.toolbox-group-label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--color-text-muted);
}

.toolbox-group-controls {
    display: flex;
    gap: 0.4rem;
    align-items: center;
    flex-wrap: wrap;
}

.toolbox-combo {
    display: flex;
    gap: 0;
}

    .toolbox-combo .canvas-asset-picker {
        border-top-right-radius: 0;
        border-bottom-right-radius: 0;
    }

    .toolbox-combo button {
        border-top-left-radius: 0;
        border-bottom-left-radius: 0;
        border-left: none;
    }

.toolbox-divider {
    width: 1px;
    align-self: stretch;
    background: var(--color-border);
    margin: 0.25rem 0;
}

.canvas-asset-picker, .canvas-choice-picker {
    max-width: 160px;
}

.canvas-editor-area {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    flex-wrap: wrap;
}

.canvas-main {
    flex: 1 1 auto;
    min-width: 0;
}

.canvas-element-inspector {
    flex: 0 0 240px;
    min-width: 200px;
    max-width: 280px;
    padding: 0.85rem 1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

    .canvas-element-inspector h5 {
        font-size: 0.8rem;
        letter-spacing: 0.02em;
        text-transform: uppercase;
        color: var(--color-text-muted);
        margin: 0 0 0.75rem;
    }

.form-range {
    width: 100%;
    accent-color: var(--color-primary);
    cursor: pointer;
}

.form-control-color {
    width: 100%;
    height: 2.25rem;
    padding: 0.2rem;
    cursor: pointer;
}

.page-canvas {
    position: relative;
    max-width: 100%;
    background: #1b1b22;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
    user-select: none;
    box-shadow: var(--shadow-md);
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

    .page-canvas.canvas-drop-active {
        border-color: var(--color-primary);
        box-shadow: 0 0 0 3px var(--color-primary-soft), var(--shadow-md);
    }

.canvas-drop-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
}

.canvas-drop-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    z-index: 6;
    pointer-events: none;
    text-align: center;
    padding: 1rem;
}

.canvas-drop-overlay-error {
    background: rgba(140, 20, 20, 0.75);
}

.canvas-background {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
}

.canvas-element {
    position: absolute;
    border: 1px dashed transparent;
    cursor: move;
    overflow: visible;
}

    .canvas-element.selected {
        border-color: #0d6efd;
    }

    .canvas-element-image,
    .canvas-element-text,
    .canvas-element-text-input {
        overflow: hidden;
    }

.canvas-placing-hotspot .canvas-element {
    pointer-events: none;
}

.canvas-element-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

.canvas-element-text {
    width: 100%;
    height: 100%;
    pointer-events: none;
    white-space: pre-wrap;
}

.canvas-element-text-input {
    width: 100%;
    height: 100%;
    background: transparent;
    border: 1px dashed rgba(255, 255, 255, 0.5);
    resize: none;
    outline: none;
    white-space: pre-wrap;
    padding: 0;
    margin: 0;
}

.canvas-element-input-preview {
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px dashed rgba(255, 255, 255, 0.5);
    border-radius: 4px;
    resize: none;
    outline: none;
    padding: 4px 6px;
    margin: 0;
    pointer-events: none;
}

.canvas-element-input {
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    padding: 4px 6px;
    margin: 0;
    box-sizing: border-box;
}

.canvas-resize-handle {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 10px;
    height: 10px;
    background: #0d6efd;
    cursor: nwse-resize;
}

.canvas-element-remove {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 20px;
    height: 20px;
    padding: 0;
    margin: 0;
    line-height: 1;
    border: 2px solid #fff;
    border-radius: 50%;
    background: #dc3545;
    color: #fff;
    font-size: 0.85rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    z-index: 10;
}

    .canvas-element-remove:hover {
        background: #bb2d3b;
    }


.canvas-hotspot-layer {
    position: absolute;
    left: 0;
    top: 0;
    pointer-events: none;
    z-index: 50;
}

.canvas-hotspot-shape {
    pointer-events: all;
    stroke-width: 2;
    cursor: move;
}

    .canvas-hotspot-shape.selected {
        stroke-width: 3;
        stroke-dasharray: 4 2;
    }

.canvas-hotspot-badge-dot {
    pointer-events: none;
}

.canvas-hotspot-badge-text {
    pointer-events: none;
    fill: #fff;
    font-size: 11px;
    font-weight: bold;
    text-anchor: middle;
}

.canvas-hotspot-resize-handle {
    pointer-events: all;
    fill: #0d6efd;
    cursor: nwse-resize;
}

.canvas-hotspot-draft {
    pointer-events: none;
    fill: rgba(13, 110, 253, 0.1);
    stroke: #0d6efd;
    stroke-width: 2;
    stroke-dasharray: 4 2;
}

.canvas-hotspot-draft-point {
    pointer-events: none;
    fill: #0d6efd;
}

.canvas-hotspot-label-wrap {
    position: absolute;
    z-index: 51;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    background: rgba(0, 0, 0, 0.6);
    padding: 1px 4px;
    border-radius: var(--radius-sm, 4px);
}

.canvas-hotspot-label {
    font-size: 0.7rem;
    color: #fff;
    white-space: nowrap;
}

.canvas-hotspot-remove {
    padding: 0 4px;
    line-height: 1;
}

.canvas-placement-hint {
    font-size: 0.8rem;
    color: var(--text-muted, #6c757d);
    align-self: center;
}

.btn-group-shape {
    display: inline-flex;
    gap: 0.25rem;
}

.player-background-sound {
    display: none;
}

.player-page-canvas-wrapper {
    position: relative;
    width: 100%;
    margin: 0 auto 1rem;
    container-type: inline-size;
}

.player-page-canvas {
    position: relative;
    width: 100%;
    height: 100%;
    background: #1b1b22;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.player-canvas-content-layer {
    position: absolute;
    inset: 0;
    isolation: isolate;
    z-index: 0;
}

.player-hotspot {
    position: absolute;
    background: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
    z-index: 1000;
}

    .player-hotspot:hover {
        background: rgba(255, 255, 255, 0.15);
        outline: 2px solid rgba(255, 255, 255, 0.6);
    }

.player-hotspot-circle {
    border-radius: 50%;
}

    .player-hotspot-circle:hover {
        outline: none;
        box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.6);
    }

.player-hotspot-polygon:hover {
    outline: none;
}


.asset-row {
    justify-content: space-between;
}

.asset-upload-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

.asset-upload-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.asset-thumb {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm, 4px);
    object-fit: cover;
    flex-shrink: 0;
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border);
}

.asset-thumb-placeholder {
    display: inline-block;
}

.asset-thumb-audio {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: var(--color-primary);
}

.asset-row-details {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    flex: 1 1 auto;
    min-width: 0;
}

.asset-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.asset-name-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.asset-name-row .asset-name {
    flex: 0 1 auto;
}

.asset-name-row .btn {
    flex: 0 0 auto;
}

.asset-row-details audio {
    width: 100%;
    height: 28px;
}

.asset-rename-form {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.asset-rename-form input {
    flex: 1 1 auto;
    min-width: 0;
}

.story-player {
    max-width: 700px;
    margin: 0 auto;
    padding: 1.5rem;
}

.story-back-link {
    display: inline-block;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    color: var(--color-text-muted);
}

    .story-back-link:hover {
        color: var(--color-primary);
    }

.story-player-footer {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
    font-size: 0.85rem;
    color: var(--color-text-muted);
    text-align: center;
}

    .story-player-footer a {
        color: inherit;
    }

.powered-by {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.powered-by-logo {
    height: 14px;
    width: auto;
    display: inline-block;
    vertical-align: middle;
}

.player-node {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
}

.player-choices {
    list-style: none;
    padding: 0;
}

.player-choices li {
    margin-bottom: 0.5rem;
}

.age-gate {
    max-width: 600px;
    margin: 2rem auto;
    text-align: center;
}

.rating-widget, .report-dialog {
    margin-top: 1rem;
    padding: 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    box-shadow: var(--shadow-sm);
}

.story-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.story-card {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1.1rem;
    background: var(--color-surface);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.15s ease, transform 0.1s ease;
}

    .story-card:hover {
        box-shadow: var(--shadow-md);
        transform: translateY(-2px);
    }

.editor-story-details {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: flex-start;
    margin-bottom: 0.75rem;
    padding: 1rem 1.25rem;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}

.story-detail-field {
    flex: 1 1 220px;
    min-width: 200px;
}

.story-detail-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

    .story-detail-row .story-detail-field {
        flex: 1 1 200px;
        min-width: 180px;
    }

.story-detail-field-narrow {
    flex: 0 0 160px !important;
}

.story-detail-dimensions {
    flex: 1 1 220px;
    min-width: 220px;
}

.story-dimensions-inputs {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.author-header {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    margin-bottom: 1rem;
}

.author-avatar {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.author-avatar-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-primary-soft);
    color: var(--color-primary);
    font-size: 1.75rem;
    font-weight: 700;
}

.avatar-uploader {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-start;
}

.avatar-preview {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    object-fit: cover;
}

.avatar-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-primary-soft);
    color: var(--color-primary);
    font-size: 1.75rem;
    font-weight: 700;
}

    .story-dimensions-inputs input {
        min-width: 0;
        flex: 1 1 0;
    }

.story-poster-preview {
    display: block;
    max-width: 90px;
    max-height: 90px;
    object-fit: cover;
    border-radius: 0.25rem;
    margin-bottom: 0.4rem;
}

.story-image-hint {
    font-size: 0.8rem;
    margin: 0.1rem 0 0.4rem;
}

.story-hero-preview {
    display: block;
    max-width: 220px;
    max-height: 90px;
    object-fit: cover;
    border-radius: 0.25rem;
    margin-bottom: 0.4rem;
}

.story-list-poster {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 0.25rem;
}

.story-synopsis {
    font-style: italic;
}




.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid #e50000;
}

.validation-message {
    color: #e50000;
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.darker-border-checkbox.form-check-input {
    border-color: #929292;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* =========================================================================
   Responsive layout
   ========================================================================= */
.test-play-panel {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.test-play-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.test-play-body {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.test-play-stage {
    flex: 2 1 480px;
    min-width: 320px;
    max-width: 720px;
}

.test-play-node-id {
    font-size: 0.85rem;
    color: var(--text-muted, #9aa0a6);
}

.test-play-ending {
    margin-top: 1rem;
}

.test-play-debug {
    flex: 1 1 280px;
    min-width: 260px;
}

.test-play-variables-table code,
.test-play-node-id code,
.test-play-history code {
    font-size: 0.8rem;
}

.test-play-history {
    margin: 0;
    padding-left: 1.25rem;
    max-height: 240px;
    overflow-y: auto;
}

@media (max-width: 900px) {
    .app-container {
        padding: 1rem;
    }

    .editor-body {
        flex-direction: column;
        height: auto;
    }

    .editor-body.editing-node .node-canvas,
    .editor-body.browsing-tree .node-canvas {
        flex: none;
        width: 100%;
        min-height: 320px;
    }

    .editor-body .editor-sidebar,
    .editor-body.editing-node .editor-sidebar,
    .editor-body.browsing-tree .editor-sidebar {
        width: 100%;
        border-left: none;
        border-top: 1px solid var(--color-border);
    }

    .sidebar-main {
        flex-direction: column;
    }

        .sidebar-main .sidebar-properties {
            order: 1;
            max-width: none;
        }

        .sidebar-main .sidebar-canvas {
            order: 0;
        }

    .story-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }

    .quota-summary {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}

@media (max-width: 640px) {
    .top-nav {
        height: auto;
        padding: 0.75rem 1rem;
        gap: 0.75rem;
    }

    .editor-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .editor-story-details {
        flex-direction: column;
    }

    .table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

    .create-story-form {
        flex-direction: column;
        max-width: none;
    }

    .manage-layout {
        flex-direction: column;
    }

    .manage-nav {
        flex: none;
        width: 100%;
    }
}

/* =========================================================================
   Public catalog (Home) page
   ========================================================================= */
.catalog-page {
    --catalog-bg: #15151a;
    --catalog-surface: #1e1e25;
    --catalog-surface-alt: #26262f;
    --catalog-border: #34343f;
    --catalog-text: #f0f0f3;
    --catalog-text-muted: #a0a0ad;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: var(--catalog-bg);
    color: var(--catalog-text);
    font-family: var(--font-sans);
}

    .catalog-page .btn-outline-light {
        border-color: var(--catalog-border);
        color: var(--catalog-text);
    }

        .catalog-page .btn-outline-light:hover {
            background: var(--catalog-surface-alt);
        }

.catalog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 3rem;
    position: sticky;
    top: 0;
    z-index: 10;
    background: linear-gradient(to bottom, var(--catalog-bg) 65%, transparent);
}

.catalog-brand {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--color-primary);
    letter-spacing: 0.02em;
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
}

    .catalog-brand-logo {
        display: block;
    }

.catalog-header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

    .catalog-header-actions form {
        margin: 0;
        display: flex;
    }

.catalog-body {
    flex: 1;
    padding: 0.5rem 0 2rem;
}

.catalog-loading {
    padding: 1.5rem 3rem;
}

.catalog-hero {
    position: relative;
    display: flex;
    align-items: flex-end;
    aspect-ratio: 32 / 10;
    min-height: 260px;
    max-height: 600px;
    padding: 2.5rem 3rem;
    background-size: cover;
    background-position: center top;
    background-color: var(--catalog-surface);
    background-image: linear-gradient(135deg, var(--color-primary-soft) 0%, var(--catalog-surface) 65%);
}

.catalog-hero-empty {
    aspect-ratio: auto;
    min-height: 0;
    max-height: none;
    flex-direction: column;
    align-items: flex-start;
    background: none;
    padding: 1.5rem 3rem 1rem;
}

    .catalog-hero-empty::after {
        display: none;
    }

    .catalog-hero-empty h1 {
        color: var(--catalog-text);
        font-size: 2rem;
    }

    .catalog-hero-empty p {
        color: var(--catalog-text-muted);
    }

.catalog-hero::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, var(--catalog-bg) 2%, rgba(21, 21, 26, 0.55) 45%, rgba(21, 21, 26, 0.05) 80%);
    pointer-events: none;
}

.catalog-hero-content {
    max-width: 640px;
    position: relative;
    z-index: 1;
}

    .catalog-hero-content h1 {
        color: var(--catalog-text);
        font-size: 2.5rem;
        font-weight: 700;
        margin-bottom: 0.75rem;
        text-shadow: 0 2px 12px rgba(0, 0, 0, 0.6);
    }

.catalog-hero-synopsis {
    color: var(--catalog-text);
    font-size: 1.05rem;
    margin-bottom: 0.9rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
}

.catalog-hero-meta {
    margin-bottom: 1.1rem;
}

.catalog-age-badge {
    display: inline-block;
    padding: 0.2rem 0.65rem;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: var(--radius-sm);
    color: var(--catalog-text);
    font-size: 0.8rem;
}

.rating-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    margin-right: 0.4rem;
    border: none;
    border-radius: 3px;
    font-family: inherit;
    font-weight: 800;
    font-size: 0.85rem;
    line-height: 1;
    color: #ffffff;
    vertical-align: middle;
    cursor: pointer;
    padding: 0;
    transition: filter 0.15s ease;
}

    .rating-badge:hover {
        filter: brightness(1.15);
    }

.rating-badge-sm {
    width: 1.15rem;
    height: 1.15rem;
    font-size: 0.65rem;
    margin-right: 0;
}

.rating-badge-everyone {
    background: #2e7d32;
}

.rating-badge-teen {
    background: #f9a825;
    color: #1b1b1f;
}

.rating-badge-mature {
    background: #c62828;
}

.rating-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 1rem;
}

.rating-modal {
    background: var(--catalog-surface);
    color: var(--catalog-text);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    max-width: 380px;
    width: 100%;
    box-shadow: var(--shadow-lg);
}

.rating-modal-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.75rem;
}

    .rating-modal-header h3 {
        margin: 0;
        color: var(--catalog-text);
    }

.rating-modal p {
    color: var(--catalog-text-muted);
    margin-bottom: 1.25rem;
}

.catalog-hero-actions {
    display: flex;
    gap: 0.75rem;
}

.catalog-row {
    padding: 0 3rem;
    margin-top: 1.75rem;
}

.catalog-row-title {
    color: var(--catalog-text);
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.catalog-row-track {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    scrollbar-width: thin;
}

    .catalog-row-track .catalog-card {
        flex: 0 0 180px;
    }

.catalog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-top: 1rem;
}

.catalog-card {
    display: block;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--catalog-surface);
    color: var(--catalog-text);
    text-decoration: none;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

    .catalog-card:hover {
        transform: scale(1.04);
        box-shadow: var(--shadow-lg);
        text-decoration: none;
    }

.catalog-card-poster {
    aspect-ratio: 2 / 3;
    background: var(--catalog-surface-alt);
}

    .catalog-card-poster img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        display: block;
    }

.catalog-card-poster-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 1rem;
    font-weight: 600;
    color: var(--catalog-text);
}

.catalog-card-info {
    padding: 0.75rem 0.9rem 1rem;
}

    .catalog-card-info h3 {
        color: var(--catalog-text);
        font-size: 1rem;
        margin-bottom: 0.25rem;
    }

    .catalog-card-info p {
        color: var(--catalog-text-muted);
        font-size: 0.85rem;
        margin-bottom: 0.4rem;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

.catalog-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 3rem;
    border-top: 1px solid var(--catalog-border);
    color: var(--catalog-text-muted);
    font-size: 0.9rem;
}

    .catalog-footer a {
        color: var(--catalog-text);
    }

@media (max-width: 600px) {
    .catalog-header, .catalog-footer, .catalog-row, .catalog-hero, .catalog-hero-empty, .catalog-loading {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .catalog-hero {
        aspect-ratio: 3 / 2;
        min-height: 320px;
    }

    .catalog-hero-empty {
        aspect-ratio: auto;
        min-height: 0;
    }

    .catalog-hero-content h1 {
        font-size: 1.75rem;
    }

    .catalog-row-track .catalog-card {
        flex: 0 0 130px;
    }
}

/* =========================================================================
   App footer
   ========================================================================= */
.app-footer {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    padding: 1.25rem 1rem;
    margin-top: auto;
    font-size: 0.875rem;
    color: var(--color-text-muted);
    border-top: 1px solid var(--color-border);
}

.app-footer a {
    color: var(--color-text-muted);
    text-decoration: none;
}

.app-footer a:hover {
    color: var(--color-primary);
    text-decoration: underline;
}

.app-footer-separator {
    color: var(--color-border);
}

/* =========================================================================
   Legal pages
   ========================================================================= */
.legal-content {
    max-width: 860px;
    margin: 0 auto;
    padding: 0 1rem 3rem;
    color: var(--color-text);
}

.legal-content section {
    margin-bottom: 1.75rem;
}

.legal-content h2 {
    font-size: 1.15rem;
    margin-bottom: 0.5rem;
}

.legal-content p,
.legal-content li {
    color: var(--color-text-muted);
    line-height: 1.6;
}

.legal-content ul {
    padding-left: 1.25rem;
}
