/* ============================================================
   Theme tokens
   Dark is the default theme. Light is opt-in via [data-theme=light]
   (set by assets/app.js from localStorage / prefers-color-scheme).
   ============================================================ */
:root {
    color-scheme: dark;

    /* Surfaces & backgrounds */
    --bg: #0b0d12;
    --surface: #141821;
    --surface-2: #1a212e;
    --panel: #141821;
    --panel-bg: #1a212e;
    --input-bg: #12161f;
    --surface-bg: #1a212e;

    /* Text */
    --text: #e8eaf0;
    --text-secondary: #f0b7b0;
    --muted: #9198a5;
    --dark-text: #0b0d12;

    /* Lines */
    --border: #2a2f3a;
    --border-strong: #3d4453;
    --panel-border: #2a2f3a;
    --border-color: #2a2f3a;

    /* Accent (muted orange — reads well on dark & light) */
    --accent: #e08a4a;
    --accent-strong: #c76b31;
    --accent-hover: #f2a968;

    /* Hover states */
    --hover-text: #0b0d12;
    --hover-bg: #e08a4a;
    --hover-border: #e08a4a;

    /* States */
    --danger: #ff8a7a;
    --danger-hover-bg: #d0453a;
    --danger-hover-border: #d0453a;
    --success: #7ee2b8;
    --warning: #e0b053;
    --warning-bg: rgba(224, 176, 83, 0.14);
    --warning-border: rgba(224, 176, 83, 0.35);

    /* Focus */
    --focus-ring: rgba(224, 138, 74, 0.18);
    --focus-border: rgba(224, 138, 74, 0.6);

    /* Shadows (flat, no glow) */
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow2: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-soft: rgba(0, 0, 0, 0.35);
    --shadow-color: var(--accent);
    --white-shadow-color: var(--text);

    /* Type */
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Menlo, Consolas, monospace;

    /* Layout */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --header-height: 56px;
}

[data-theme="light"] {
    color-scheme: light;

    --bg: #f6f8fa;
    --surface: #ffffff;
    --surface-2: #f0f2f5;
    --panel: #ffffff;
    --panel-bg: #f0f2f5;
    --input-bg: #ffffff;
    --surface-bg: #eef1f5;

    --text: #1f2328;
    --text-secondary: #a8352b;
    --muted: #65707c;
    --dark-text: #ffffff;

    --border: #d8dde4;
    --border-strong: #c3cad4;
    --panel-border: #d8dde4;
    --border-color: #d8dde4;

    --accent: #c9521f;
    --accent-strong: #a83f14;
    --accent-hover: #d9652f;

    --hover-text: #ffffff;
    --hover-bg: #c9521f;
    --hover-border: #c9521f;

    --danger: #c03d31;
    --danger-hover-bg: #b0302b;
    --danger-hover-border: #b0302b;
    --success: #1a9a6b;
    --warning: #a47a17;
    --warning-bg: rgba(164, 122, 23, 0.12);
    --warning-border: rgba(164, 122, 23, 0.3);

    --focus-ring: rgba(201, 82, 31, 0.16);
    --focus-border: rgba(201, 82, 31, 0.6);

    --shadow: 0 1px 2px rgba(31, 35, 40, 0.08);
    --shadow2: 0 1px 2px rgba(31, 35, 40, 0.08);
    --shadow-soft: rgba(31, 35, 40, 0.12);
    --shadow-color: #c9521f;
    --white-shadow-color: #1f2328;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font-sans);
    color: var(--text);
    background: var(--bg);
    transition: background-color 0.2s ease, color 0.2s ease;
}

a {
    color: inherit;
    text-decoration: none;
}

.site-background {
    display: none;
}

.site-chrome {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: var(--bg);
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 40;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.header-inner {
    display: flex;
    align-items: center;
    gap: 16px;
    height: var(--header-height);
    padding: 0 16px;
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1;
    min-width: 0;
    margin-left: auto;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: 0.02em;
    text-transform: none;
    text-decoration: none;
    white-space: nowrap;
}

.brand-mark i {
    color: var(--accent);
    font-size: 1.15rem;
}

.theme-toggle,
.nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--panel-bg);
    color: var(--text);
    font-size: 1.15rem;
    cursor: pointer;
    transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.theme-toggle:hover,
.nav-toggle:hover {
    color: var(--hover-text);
    background: var(--hover-bg);
    border-color: var(--hover-border);
}

.nav-toggle {
    display: none;
    font-size: 1.35rem;
}

html[data-theme="dark"] .theme-toggle .bi-sun {
    display: none;
}

html[data-theme="light"] .theme-toggle .bi-moon {
    display: none;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: nowrap;
}

.nav-link,
.nav-link-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    border: 0;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    font-family: inherit;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.15s ease, background 0.15s ease;
}

.nav-link:hover,
.nav-link-button:hover {
    color: var(--text);
    background: var(--surface-2);
}

.nav-link.is-active {
    color: var(--accent);
}

.nav-logout {
    margin: 0;
    display: inline-flex;
}

.site-body {
    position: relative;
    display: flex;
    flex: 1;
    align-items: stretch;
}

.site-body > *:not(.animated-background) {
    position: relative;
    z-index: 1;
}

aside.text-sidebar {
    flex: 0 0 auto;
    width: 64px;
    align-self: center;
    margin: 0 16px 0 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 10px 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
    z-index: 30;
}

aside.text-sidebar .toggle-sidebar {
    color: var(--accent-strong);
    font-size: large;
    text-align: center;
    width: 100%;
}

.page-shell {
    flex: 1 1 auto;
    min-width: 0;
    padding: 24px;
}

/* .hero-card {
    padding: 32px;
    border: 1px solid var(--panel-border);
    border-radius: 40px;
    background: var(--panel);
    box-shadow: 0 24px 70px var(--shadow-soft);
    backdrop-filter: blur(14px);
} */

main.page-shell section.hero-card-background {
    padding: 10px;
    color: var(--text);
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    margin-top: 8px;
    margin-left: auto;
    margin-right: auto;
}

.hero-card-background--content {
    max-width: min-content;
}

.hero-card-background--wide {
    max-width: 1000px;
}

.hero-card-background--medium {
    max-width: 700px;
}

.hero-card-background--narrow {
    max-width: 400px;
}

.hero-card h1 {
    margin: 0 0 12px;
    font-size: 2rem;
    line-height: 1.3;
    color: var(--accent-strong);
}

.hero-card h2, .hero-card h3, .hero-card h4, .hero-card h5, .hero-card h6 {
    color: var(--accent-strong);
}

.hero-card p {
    margin: 0 0 16px;
    color: var(--muted);
    line-height: 1.6;
}

.hero-card-header {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin: 5px;
}

.hero-card-header h1, .hero-card-header p {
    margin: 0;
}

.hero-card-header .eyebrow {
    padding: 10px;
    margin-bottom: 0px !important;
    font-size: 1.6rem;
    width: 2.75rem;
    height: 2.75rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
}

.hero-card-header .button-primary, 
.hero-card-header .button-secondary, 
.actions .button-primary, 
.actions .button-secondary, 
.actions .button-danger {
    padding: 8px;
    font-size: 1.1rem;
    border-radius: var(--radius-md);
    /* width: 2.75rem; */
    height: 2.75rem;
    background: var(--panel-bg);
    border: 1px solid var(--border);
    box-shadow: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hero-card-header .button-primary:hover, 
.actions .button-primary:hover, 
.actions .button-danger:hover {
    box-shadow: none;
}

.hero-card-header .button-secondary:hover, 
.actions .button-secondary:hover {
    box-shadow: none;
}

.hero-card .actions, .auth-form .actions {
    justify-content: space-between;
}

.eyebrow {
    display: inline-block;
    margin-bottom: 14px !important;
    padding: 6px 10px;
    border-radius: 999px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.78rem;
    font-weight: 700;
}

.actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 24px;
}

.button-primary,
.button-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 14px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--panel-bg);
    color: var(--accent);
    font-size: 0.92rem;
    font-weight: 700;
    transition: color 0.2s ease, background 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
    cursor: pointer;
}

.button-secondary {
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
}

.button-danger {
    border: 1px solid rgba(255, 138, 122, 0.35);
    background: rgba(255, 138, 122, 0.1);
    color: var(--text-secondary);
    transition: color 0.2s ease, background 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}

.button-danger:hover {
    color: var(--hover-text);
    background: var(--danger-hover-bg);
    border-color: var(--danger-hover-border);
}

.button-primary:hover,
.button-secondary:hover {
    color: var(--hover-text);
    background: var(--hover-bg);
    border-color: var(--hover-border);
}

.notice {
    padding: 12px 14px;
    border-radius: var(--radius-md);
}

.notice-success {
    background: rgba(126, 226, 184, 0.12);
    border: 1px solid rgba(126, 226, 184, 0.3);
    color: var(--text);
    text-align: center;
}

.notice-info {
    background: var(--focus-ring);
    border: 1px solid var(--focus-border);
    color: var(--text);
}

.notice-error {
    background: rgba(255, 138, 122, 0.1);
    border: 1px solid rgba(255, 138, 122, 0.3);
    color: var(--text-secondary);
}

form#login-form, form#registration-form {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
}

form#text-edit-form {
    color: var(--text);
    background: var(--surface);
    padding: 10px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    margin-top: 8px;
}

form#login-form input, form#registration-form input {
    text-align: center;
}

.auth-form {
    /* display: grid; */
    gap: 12px;
    margin-top: 24px;
}

.auth-form label {
    font-weight: 700;
    color: var(--text);
}

.auth-form input,
.auth-form select,
.auth-form textarea {
    width: 100%;
    min-height: 46px;
    padding: 10px 14px;
    color: var(--text);
    background: var(--input-bg);
    font-family: var(--font-sans);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.auth-form input:focus,
.auth-form select:focus,
.auth-form textarea:focus {
    outline: none;
    border-color: var(--focus-border);
    box-shadow: 0 0 0 4px var(--focus-ring);
}

.auth-form .actions {
    margin-top: 8px;
}

.g-recaptcha {
    display: flex;
    justify-content: center;
    margin-top: 10px;
    filter: invert(1);
}

.field-note {
    margin: -4px 0 0 !important;
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.5;
}

.filter-form {
    margin-top: 20px;
}

.flash-stack {
    width: min(1120px, calc(100% - 24px));
    /* margin: 0px auto 19px auto; */
}

.content-grid {
    display: grid;
    gap: 22px;
}

.site-footer {
    border-top: 1px solid var(--border);
    background: var(--surface);
    color: var(--muted);
}

.site-footer-inner {
    width: min(1120px, calc(100% - 24px));
    margin: 0 auto;
    padding: 14px 0 18px;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    font-size: 0.8rem;
}

.site-footer a {
    color: var(--accent);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 18px;
    margin-bottom: 18px;
}

.stat-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px;
    background: var(--surface);
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.stat-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1 1 200px;
    min-width: 200px;
    max-width: 260px;
    margin-left: auto;
}

.stat-actions > form {
    display: block;
    width: 100%;
}

.stat-actions .button-primary,
.stat-actions .button-secondary {
    width: 100%;
    min-height: 36px;
    padding: 0 12px;
    font-size: 0.85rem;
}

.stat-label {
    margin: 0 !important;
    color: var(--muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.stat-value {
    margin: 8px 0 0 !important;
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text);
}

.section-title {
    margin: 20px 0 10px;
    font-size: 1.1rem;
    color: var(--text);
}

.recent-list {
    margin: 0;
    padding-left: 20px;
    color: var(--muted);
}

.recent-list li {
    margin-bottom: 8px;
}

.recent-list a.recent-title {
    color: var(--text);
    font-weight: 700;
    text-decoration: none;
}

.recent-list a.recent-title:hover {
    color: var(--accent);
    text-decoration: underline;
}

.recent-list a.meta:hover {
    text-decoration: underline;
}

.meta {
    margin-left: 8px;
    font-size: 0.9rem;
    color: var(--accent);
}

.empty-state {
    color: var(--muted);
    margin-bottom: 0 !important;
}

.inline-action {
    margin-left: 10px;
    min-height: 30px;
    padding: 4px 10px;
    font-size: 0.82rem;
}

.inline-delete-form {
    display: inline-block;
    margin-left: 10px;
}

select option {
    color: var(--text);
    background: var(--surface);
}

select,
::picker(select) {
    appearance: base-select;
}

select::picker-icon {
    color: var(--accent);
    transition: color 0.2s ease, background 0.2s ease, transform 0.2s ease, border-color 0.2s ease, rotate 0.4s ease;
}

select:hover::picker-icon {
    /* color: black; */
    color: var(--accent);
}

select:open::picker-icon {
    rotate: 180deg;
}

::picker(select) {
    border: none;
}

option {
    display: flex;
    justify-content: flex-start;
    gap: 20px;
    border: 1px solid var(--panel-border);
    padding: 10px;
    transition: 0.4s;
}

option:first-of-type {
    border-radius: 8px 8px 0 0;
}

option:last-of-type {
    border-radius: 0 0 8px 8px;
}

::picker(select) {
    border-radius: 8px;
}

option:not(option:last-of-type) {
    border-bottom: none;
}

option:nth-of-type(odd) {
    background: var(--surface-2);
}

option:hover,
option:focus {
    background-color: rgba(224, 138, 74, 0.14);
    color: var(--accent);
    transition: background-color 0.15s ease-in-out;
}

selectedcontent .icon {
    display: none;
}

option:checked {
    font-weight: bold;
}

option::checkmark {
    order: 1;
    margin-left: auto;
    content: "⬤";
}

.visually-hidden {
    display: none;
}

@keyframes mymove {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

@media (max-width: 900px) {
    .nav-toggle {
        display: inline-flex;
    }

    .site-nav {
        position: absolute;
        top: var(--header-height);
        left: 0;
        right: 0;
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
        padding: 12px 16px;
        margin-left: 0;
        background: var(--surface);
        border-bottom: 1px solid var(--border);
        display: none;
    }

    .site-nav.is-open {
        display: flex;
        box-shadow: 0 12px 30px var(--shadow-soft);
    }

    .nav-links {
        flex-direction: column;
        align-items: stretch;
        gap: 2px;
    }

    .nav-link,
    .nav-link-button {
        width: 100%;
        padding: 10px 12px;
    }

    .site-body {
        flex-direction: column;
    }

    .page-shell {
        padding: 16px;
        padding-bottom: 76px;
    }

    aside.text-sidebar {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: auto;
        flex-direction: row;
        justify-content: center;
        margin: 0;
        border: 0;
        border-top: 1px solid var(--border);
        border-radius: 0;
        padding: 8px 12px;
        z-index: 30;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .site-footer-inner {
        flex-direction: column;
    }
}

.page-shell .hero-card {
    /* padding: 10px; */
    padding: 0px;
}

.text-header-container {
    display: flex;
    flex-flow: nowrap;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    padding-left: 2px;
    padding-right: 2px;
    padding-bottom: 10px;
}

.text-header-container div {
    display: flex;
    flex-flow: nowrap;
    justify-content: center;
    align-items: center;
}

.text-header-container div i {
    font-size: 2rem;
    margin-right: 5px;
}

.text-header-container .button-primary,
.text-header-container .button-secondary,
.text-header-container .button-danger {
    padding: 8px;
    font-size: 1.1rem;
    border-radius: var(--radius-md);
    width: 2.75rem;
    height: 2.75rem;
    box-shadow: none;
    background: var(--panel-bg);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
}

.text-header-container div.locked-indicator {
    color: var(--accent);
    cursor: not-allowed;
}

.text-header-container input:disabled {
    cursor: not-allowed;
}

.text-header-container select:disabled {
    cursor: not-allowed;
}

.text-header-container div.locked-indicator i {
    margin-right: 0px !important;
    font-size: medium;
}

.text-header-container .text-name div.locked-indicator {
    position: relative;
    left: -29px;
    background: var(--surface-2);
}

.text-header-container .text-tag div.locked-indicator {
    position: relative;
    left: -29px;
    background: var(--surface-2);
}

.text-header-container .text-type div.locked-indicator {
    position: relative;
    left: -29px;
    background: var(--surface-2);
}

.hero-card .auth-form {
    margin-top: 0px;
}

.locked-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 700;
    background: rgba(255, 193, 7, 0.15);
    border: 1px solid rgba(255, 193, 7, 0.3);
    color: var(--warning);
}

.locked-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    background: var(--warning-bg);
    border: 1px solid var(--warning-border);
    color: var(--warning);
    margin-bottom: 18px;
}

.title-terminal-container {
    width: 100%;
    height: 45px;
    background: var(--input-bg);
    text-align: center;
    font-family: var(--font-mono);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

#text-edit-form input, #text-edit-form select {
    background: var(--input-bg);
    color: var(--text);
    font-family: var(--font-mono);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

textarea#text_content {
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--input-bg);
    color: var(--text);
    resize: none;
    min-height: 99%;
    font-family: var(--font-mono);
    line-height: 1.5;
    field-sizing: content;
    min-width: 100%;
    width: max-content;
}

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

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

.flex-row-gap-6 {
    display: flex;
    gap: 6px;
}

.overflow-x-auto {
    overflow-x: auto;
}

.w-100 {
    width: 100%;
}

/* Autosave indicator styles */
.autosave-indicator {
    font-size: 0.78rem;
    padding: 4px 10px;
    border-radius: 8px;
    transition: opacity 0.3s ease;
    opacity: 0;
    white-space: nowrap;
    /* position: sticky; */
    position: absolute;
    transform: translateX(-50%);
    top: 145px;
    left: 50%;
    z-index: 1000;
    width: 200px;
    display: flow;
    margin-left: auto;
    margin-right: auto;
    text-align: center;
}

.autosave-indicator.visible {
    opacity: 1;
}

.autosave-indicator.notice-success {
    background: rgba(126, 226, 184, 0.12);
    /* border: 1px solid rgba(120, 214, 198, 0.24); */
    border: unset;
    color: var(--success);
}

.autosave-indicator.notice-info {
    background: var(--focus-ring);
    /* border: 1px solid rgba(95, 183, 255, 0.24); */
    border: unset;
    color: var(--accent);
}

.autosave-indicator.notice-error {
    background: rgba(255, 138, 122, 0.12);
    /* border: 1px solid rgba(255, 138, 122, 0.24); */
    border: unset;
    color: var(--danger);
}
/* END of Autosave indicator styles */

.flex-row-gap-6 {
    display: flex;
    gap: 6px;
}

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

.inline-block {
    display: inline-block;
}

.fw-600 {
    font-weight: 600;
}

.flex-grow-3 {
    flex-grow: 3;
}

.tag-pill {
    background: rgba(224, 138, 74, 0.2);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.9rem;
}

.tag-pill-rich {
    background: rgba(67, 154, 255, 0.18);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.9rem;
}

.tag-pill-plain {
    background: rgba(130, 255, 170, 0.15);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.9rem;
}

.tag-pill-count {
    background: rgba(95, 183, 255, 0.2);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.9rem;
}

.star-icon {
    color: var(--warning);
}

.filter-form-inline {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.table-header {
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
}

.table-cell-padded {
    padding: 12px;
}

.table-cell-left {
    padding: 12px;
    text-align: left;
}

.table-cell-center {
    padding: 12px;
    text-align: center;
}

.table-row-border {
    border-bottom: 1px solid var(--border);
}

.mb-16 {
    margin-bottom: 16px;
}

.m-20-0 {
    margin: 20px 0;
}

.editor-body {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    flex-direction: column;
    overflow-x: auto;
    overflow-y: auto;
    /* height set dynamically by ResizeObserver in _form.html.twig */
}

.editor-content {
    flex: 1;
    min-width: 0;

    width: 100%;
}

.jump-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.jump-btn i.bi-caret-up-fill {
    transform: translateY(1px);
}

.jump-btn i.bi-caret-down-fill {
    transform: translateY(4px);
}

/* Table of Contents */
.toc-wrapper {
    position: relative;
}

.toc-wrapper.is-plain {
    display: none;
}

.toc-toggle {
    position: relative;
    z-index: 1;
}

.toc-dropdown {
    position: absolute;
    right: calc(100% + 10px);
    top: 20px;
    transform: translateY(-50%);
    min-width: 260px;
    max-width: calc(100vw - 12vw);
    max-height: 70vh;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 6px 0;
    box-shadow: 0 16px 48px var(--shadow-soft);
    z-index: 100;
}

.toc-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.toc-list li {
    padding: 6px 14px;
    cursor: pointer;
    color: var(--text);
    font-size: 0.85rem;
    line-height: 1.4;
    transition: background 0.15s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.toc-list li:hover {
    background: var(--surface-2);
    color: var(--accent);
}

.toc-list li.toc-empty {
    cursor: default;
    color: var(--muted);
    font-style: italic;
}

.toc-list li.toc-empty:hover {
    background: transparent;
    color: var(--muted);
}

.toc-list li.toc-h1 { padding-left: 14px; font-weight: 700; }
.toc-list li.toc-h2 { padding-left: 26px; }
.toc-list li.toc-h3 { padding-left: 38px; font-size: 0.8rem; }
.toc-list li.toc-h4 { padding-left: 50px; font-size: 0.78rem; }
.toc-list li.toc-h5 { padding-left: 62px; font-size: 0.76rem; }
.toc-list li.toc-h6 { padding-left: 74px; font-size: 0.74rem; }

.toc-select {
    display: none;
}

@media (max-width: 640px) {
    .toc-dropdown {
        display: none !important;
    }

    .toc-select {
        display: block;
        width: 100%;
        min-height: 40px;
        padding: 0 10px;
        border: 1px solid var(--border-color);
        border-radius: 8px;
        background: var(--panel-bg);
        color: var(--text);
        font-size: 0.85rem;
        cursor: pointer;
        appearance: auto;
        position: absolute;
        top: 0px;
    }
}

/* Text type switch modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.modal-overlay.is-open {
    opacity: 1;
    visibility: visible;
}

.modal-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    max-width: 440px;
    width: 90%;
    box-shadow: 0 16px 48px var(--shadow-soft);
}

.modal-icon {
    font-size: 3rem;
    color: var(--accent-strong);
    text-align: center;
    margin-bottom: 16px;
}

.modal-message {
    color: var(--text);
    font-size: 0.95rem;
    line-height: 1.6;
    text-align: center;
    margin: 0 0 24px;
    white-space: pre-line;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    /* margin: 20px 0; */
}

section.feature-grid {
    background: var(--surface-2);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    padding: 10px;
}

.feature-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 24px;
    background: var(--surface);
    transition: border-color 0.2s ease, background 0.2s ease;
}

.feature-card:hover {
    border-color: var(--border-strong);
    background: var(--surface-2);
}

.feature-icon {
    font-size: 2rem;
    color: var(--accent-strong);
    margin-bottom: 12px;
}

.feature-title {
    margin: 0 0 8px;
    font-size: 1.1rem;
    color: var(--text);
}

.feature-text {
    margin: 0;
    color: var(--muted);
    line-height: 1.6;
    font-size: 0.92rem;
}

/* Theme customization (profile) */
.theme-section {
    margin-top: 24px;
    padding: 18px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.theme-section-title {
    margin: 0 0 8px;
    font-size: 1.1rem;
    color: var(--text);
}

.theme-mode-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
    margin-top: 16px;
}

.theme-mode > label {
    font-weight: 700;
    color: var(--text);
}

.theme-mode select {
    width: 100%;
    margin: 6px 0 12px;
}

.theme-colors {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 16px;
}

.theme-colors[hidden] {
    display: none;
}

.theme-colors .form-row,
.theme-colors div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.theme-colors label {
    font-size: 0.82rem;
    color: var(--muted);
    white-space: nowrap;
}

.theme-colors input[type="color"] {
    width: 44px;
    height: 30px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--input-bg);
    cursor: pointer;
}

/* ============================================================
   Page loading screen
   ============================================================ */
.page-loader {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    background: var(--bg);
    color: var(--text);
    opacity: 1;
    visibility: visible;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.page-loader.is-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.page-loader__box {
    width: 72px;
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    animation: page-loader-pulse 1.6s ease-in-out infinite;
}

.page-loader__icon {
    font-size: 1.9rem;
    color: var(--accent);
}

.page-loader__wordmark {
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: 0.04em;
}

.page-loader__terminal {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--muted);
}

.page-loader__prompt {
    color: var(--accent);
}

.page-loader__cursor {
    color: var(--accent);
    animation: page-loader-blink 1s steps(2, start) infinite;
}

.page-loader__bar {
    width: 180px;
    height: 2px;
    background: var(--surface-2);
    border-radius: 2px;
    overflow: hidden;
}

.page-loader__bar span {
    display: block;
    height: 100%;
    width: 40%;
    background: var(--accent);
    animation: page-loader-sweep 1.1s ease-in-out infinite;
}

@keyframes page-loader-pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.06);
        opacity: 0.85;
    }
}

@keyframes page-loader-blink {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0;
    }
}

@keyframes page-loader-sweep {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(350%);
    }
}

@media (prefers-reduced-motion: reduce) {
    .page-loader__box,
    .page-loader__cursor,
    .page-loader__bar span {
        animation: none;
    }
}

turbo-progress-bar {
    visibility: hidden;
}

/* ============================================================
   Animated background (per-user, parallax layers behind content)
   ============================================================ */
.animated-background {
    position: absolute;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

.animated-bg__mode {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

.animated-bg__mode--dark {
    display: block;
}

.animated-bg__mode--light {
    display: none;
}

[data-theme="light"] .animated-bg__mode--dark {
    display: none;
}

[data-theme="light"] .animated-bg__mode--light {
    display: block;
}

/* Profile live preview: force-show the previewed mode */
.animated-background[data-animated-bg-preview="light"] .animated-bg__mode--dark {
    display: none;
}

.animated-background[data-animated-bg-preview="light"] .animated-bg__mode--light {
    display: block;
}

.animated-background[data-animated-bg-preview="dark"] .animated-bg__mode--dark {
    display: block;
}

.animated-background[data-animated-bg-preview="dark"] .animated-bg__mode--light {
    display: none;
}

.animated-bg__layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    will-change: transform;
}

.animated-bg__layer--slide-x {
    width: 200%;
    animation: animated-bg-slide-x var(--dur, 60s) linear infinite;
}

.animated-bg__layer--slide-y {
    height: 200%;
    animation: animated-bg-slide-y var(--dur, 60s) linear infinite;
}

.animated-bg__item {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--size, 24px);
    height: var(--size, 24px);
    top: var(--y, 0%);
    left: var(--x, 0%);
    color: var(--color, var(--muted));
    opacity: var(--opacity, 0.8);
    white-space: nowrap;
}

.animated-bg__item svg {
    display: block;
    width: 100%;
    height: 100%;
}

.animated-bg__item .animated-bg__emoji {
    font-size: calc(var(--size, 24px) * 0.8);
    line-height: 1;
}

.animated-bg__item .animated-bg__char {
    font-family: var(--font-mono);
    font-size: calc(var(--size, 24px) * 0.9);
    line-height: 1;
}

.animated-bg__layer--glow .animated-bg__char {
    text-shadow: 0 0 6px currentColor;
}

.animated-bg__shape {
    display: block;
}

.animated-bg__shape--circle {
    width: 100%;
    height: 100%;
    background: currentColor;
    border-radius: 50%;
}

.animated-bg__shape--streak {
    width: 2px;
    height: 100%;
    background: currentColor;
    border-radius: 2px;
}

.animated-bg__shape--triangle {
    width: 100%;
    height: 100%;
    background: currentColor;
    clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

.animated-bg__shape--ring {
    width: 100%;
    height: 100%;
    border: 2px solid currentColor;
    border-radius: 50%;
    box-sizing: border-box;
}

.animated-bg__item .animated-bg__shape {
    width: 100%;
    height: 100%;
}

@keyframes animated-bg-slide-x {
    from {
        transform: translateX(-50%);
    }
    to {
        transform: translateX(0);
    }
}

@keyframes animated-bg-slide-y {
    from {
        transform: translateY(-50%);
    }
    to {
        transform: translateY(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .animated-bg__layer--slide-x,
    .animated-bg__layer--slide-y {
        animation: none;
    }
}