@import url("../vendor/noto-sans-kr/index.css"); /* R85_LOCAL_HANGUL_WEBFONT */

:root {
    color-scheme: dark;
    --bg: #09090d;
    --surface: #111118;
    --surface-2: #181820;
    --surface-3: #22222c;
    --border: rgba(255, 255, 255, 0.09);
    --text: #f6f4fb;
    --muted: #a8a4b3;
    --accent: #9b5cff;
    --accent-strong: #7c3aed;
    --accent-soft: rgba(155, 92, 255, 0.16);
    --success: #39d98a;
    --danger: #ff6b7a;
    --shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
    --sidebar-width: 272px;
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 11px;
}

/* =========================================================
   STORYRAUM 3.0: PRIVATE STORY-WORLD MANAGEMENT
========================================================= */
.worlds-heading {
    align-items: flex-end;
}

.worlds-heading .primary-button {
    flex: 0 0 auto;
}

.worlds-eyebrow-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.worlds-eyebrow-row .eyebrow {
    margin: 0;
}

.worlds-beta-badge {
    display: inline-flex;
    min-height: 24px;
    align-items: center;
    padding: 3px 9px;
    border: 1px solid rgba(192, 132, 252, 0.25);
    border-radius: 999px;
    background: rgba(126, 34, 206, 0.16);
    color: #d8b4fe;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.world-foundation-note {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin: 24px 0 20px;
    padding: 17px 19px;
    border: 1px solid rgba(192, 132, 252, 0.14);
    border-radius: 17px;
    background: linear-gradient(120deg, rgba(126, 34, 206, 0.1), rgba(255, 255, 255, 0.018));
}

.world-foundation-icon {
    display: grid;
    width: 40px;
    height: 40px;
    flex: 0 0 auto;
    place-items: center;
    border-radius: 13px;
    background: rgba(168, 85, 247, 0.14);
    color: #d8b4fe;
    font-size: 1.25rem;
}

.world-foundation-note strong,
.world-foundation-note p {
    display: block;
    margin: 0;
}

.world-foundation-note p {
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.86rem;
    line-height: 1.55;
}

.world-page-message {
    min-height: 20px;
    margin-bottom: 8px;
}

.world-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr));
    gap: 18px;
}

.world-card {
    display: flex;
    min-width: 0;
    min-height: 410px;
    flex-direction: column;
    padding: 21px;
    border: 1px solid rgba(255, 255, 255, 0.075);
    border-radius: 21px;
    background:
        radial-gradient(circle at 100% 0, rgba(168, 85, 247, 0.12), transparent 13rem),
        #101014;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.16);
    transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.world-card:hover {
    border-color: rgba(192, 132, 252, 0.27);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.25);
    transform: translateY(-2px);
}

.world-card-heading {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 13px;
}

.world-card-mark {
    display: grid;
    width: 50px;
    height: 50px;
    flex: 0 0 auto;
    place-items: center;
    border: 1px solid rgba(216, 180, 254, 0.2);
    border-radius: 16px;
    background: linear-gradient(145deg, rgba(168, 85, 247, 0.34), rgba(76, 29, 149, 0.38));
    color: #f3e8ff;
    font-size: 1.22rem;
    font-weight: 850;
    box-shadow: 0 12px 30px rgba(76, 29, 149, 0.2);
}

.world-card-title {
    min-width: 0;
}

.world-card-title h3,
.world-card-title p {
    margin: 0;
}

.world-card-title h3 {
    overflow: hidden;
    font-size: 1.16rem;
    letter-spacing: -0.025em;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.world-card-title p {
    margin-top: 4px;
    color: #9f93ad;
    font-size: 0.76rem;
}

.world-card-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 17px;
}

.world-badge {
    display: inline-flex;
    min-height: 25px;
    align-items: center;
    padding: 3px 9px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.035);
    color: #cfc8d8;
    font-size: 0.69rem;
    font-weight: 750;
}

.world-badge.mode-romance {
    border-color: rgba(244, 114, 182, 0.22);
    background: rgba(190, 24, 93, 0.12);
    color: #f9a8d4;
}

.world-badge.mode-adult {
    border-color: rgba(248, 113, 113, 0.22);
    background: rgba(185, 28, 28, 0.13);
    color: #fca5a5;
}

.world-director-badge {
    border-color: rgba(96, 165, 250, 0.18);
    background: rgba(30, 64, 175, 0.1);
    color: #bfdbfe;
}

.world-card-description {
    display: -webkit-box;
    min-height: 4.65em;
    margin: 18px 0;
    overflow: hidden;
    color: #aaa2b4;
    font-size: 0.86rem;
    line-height: 1.55;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
}

.world-count-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-top: auto;
}

.world-count-item {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 8px;
    padding: 9px;
    border: 1px solid rgba(255, 255, 255, 0.055);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.022);
}

.world-count-icon {
    flex: 0 0 auto;
    color: #b993ef;
    font-size: 0.85rem;
}

.world-count-copy {
    min-width: 0;
}

.world-count-copy strong,
.world-count-copy small {
    display: block;
}

.world-count-copy strong {
    color: #f5f1fa;
    font-size: 0.8rem;
}

.world-count-copy small {
    overflow: hidden;
    color: #89818f;
    font-size: 0.61rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.world-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.055);
}

.world-updated {
    min-height: 1em;
    color: #7f7886;
    font-size: 0.68rem;
}

.world-card-actions {
    display: flex;
    flex: 0 0 auto;
    gap: 7px;
}

.world-empty-state {
    min-height: 360px;
}

.world-editor-card {
    width: min(760px, calc(100vw - 28px));
    max-height: min(90vh, 900px);
    max-height: min(90dvh, 900px);
    overflow-y: auto;
}

.world-editor-form {
    display: grid;
    gap: 18px;
    padding: 22px;
}

.world-name-field input {
    font-size: 1.03rem;
    font-weight: 700;
}

.world-editor-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(130px, 0.6fr);
    gap: 14px;
}

.world-director-help {
    min-height: 2.7em;
    color: var(--muted);
    line-height: 1.45;
}

.world-editor-private-note {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 15px;
    border: 1px solid rgba(74, 222, 128, 0.14);
    border-radius: 14px;
    background: rgba(22, 101, 52, 0.08);
}

.world-editor-private-note > span {
    color: #86efac;
    font-size: 1.15rem;
}

.world-editor-private-note strong,
.world-editor-private-note p {
    display: block;
    margin: 0;
}

.world-editor-private-note p {
    margin-top: 3px;
    color: #9eaaa1;
    font-size: 0.78rem;
    line-height: 1.45;
}

.world-editor-actions {
    margin-top: 0;
}

@media (max-width: 820px) {
    body[data-registered="1"] .mobile-bottom-nav {
        grid-template-columns: repeat(8, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    .worlds-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .worlds-heading .primary-button {
        width: 100%;
    }

    .world-foundation-note {
        padding: 15px;
    }

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

    .world-card {
        min-height: 0;
        padding: 18px;
    }

    .world-count-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .world-card-footer {
        align-items: stretch;
        flex-direction: column;
    }

    .world-card-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .world-card-actions button {
        width: 100%;
    }

    .world-editor-card {
        width: min(100% - 16px, 760px);
        max-height: calc(100dvh - 16px);
    }

    .world-editor-form {
        gap: 15px;
        padding: 17px;
    }

    .world-editor-grid {
        grid-template-columns: 1fr;
    }
}

@media (prefers-reduced-motion: reduce) {
    .world-card {
        transition: none;
    }

    .world-card:hover {
        transform: none;
    }
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--bg);
}

body {
    margin: 0;
    min-width: 320px;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    background:
        radial-gradient(circle at 80% 0%, rgba(124, 58, 237, 0.16), transparent 34rem),
        radial-gradient(circle at 30% 100%, rgba(93, 64, 160, 0.1), transparent 28rem),
        var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans KR Variable", sans-serif;
    -webkit-font-smoothing: antialiased;
}

button,
select,
a {
    font: inherit;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

button {
    color: inherit;
}

button:focus-visible,
a:focus-visible,
select:focus-visible {
    outline: 3px solid rgba(155, 92, 255, 0.45);
    outline-offset: 2px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: fixed;
    z-index: 3000;
    top: max(10px, env(safe-area-inset-top));
    left: max(10px, env(safe-area-inset-left));
    padding: 10px 14px;
    transform: translateY(-160%);
    border: 1px solid rgba(192, 132, 252, .45);
    border-radius: 12px;
    background: #17121f;
    box-shadow: 0 12px 36px rgba(0, 0, 0, .42);
    color: #fff;
    text-decoration: none;
    transition: transform 140ms ease;
}

.skip-link:focus { transform: translateY(0); }

.app-shell {
    min-height: 100vh;
    min-height: 100dvh;
}

.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    display: flex;
    width: var(--sidebar-width);
    flex-direction: column;
    padding: 22px 16px;
    background: rgba(15, 15, 21, 0.9);
    border-right: 1px solid var(--border);
    backdrop-filter: blur(24px);
}

.brand-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 6px 24px;
}

.brand {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 12px;
    color: var(--text);
    text-decoration: none;
}

.brand-logo {
    display: block;
    width: min(184px, 100%);
    height: auto;
}

body[data-environment="sandbox"] .brand-logo {
    width: min(148px, 100%);
}

.environment-badge {
    flex: 0 0 auto;
    padding: 4px 7px;
    border: 1px solid rgba(250, 204, 21, 0.34);
    border-radius: 999px;
    background: rgba(113, 63, 18, 0.2);
    color: #fde68a;
    font-size: 0.62rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.brand-mark {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    border-radius: 14px;
    background: linear-gradient(135deg, #b47bff, #6f2ee8);
    box-shadow: 0 12px 28px rgba(124, 58, 237, 0.34);
    font-size: 1.35rem;
}

.brand strong,
.brand small {
    display: block;
}

.brand strong {
    font-size: 0.98rem;
    letter-spacing: -0.01em;
}

.brand small {
    margin-top: 2px;
    color: var(--muted);
    font-size: 0.72rem;
}

.icon-button {
    display: inline-grid;
    width: 42px;
    height: 42px;
    place-items: center;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 13px;
    background: var(--surface-2);
    cursor: pointer;
}

.sidebar-close,
.mobile-menu-button {
    display: none;
}

@media (max-width: 860px) {
    .environment-badge { display: none; }
}

.primary-nav {
    display: grid;
    gap: 7px;
}

.nav-item,
.v1-link {
    display: flex;
    width: 100%;
    align-items: center;
    gap: 12px;
    min-height: 48px;
    padding: 0 14px;
    border: 1px solid transparent;
    border-radius: 14px;
    background: transparent;
    color: var(--muted);
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    transition: 160ms ease;
}

.nav-item:hover,
.v1-link:hover {
    background: rgba(255, 255, 255, 0.045);
    color: var(--text);
}

.nav-item.is-active {
    background: var(--accent-soft);
    border-color: rgba(155, 92, 255, 0.22);
    color: #e9dcff;
}

.nav-icon {
    display: grid;
    width: 24px;
    place-items: center;
    font-size: 1.15rem;
}

.sidebar-spacer {
    flex: 1;
    min-height: 24px;
}

.v1-link {
    margin-bottom: 12px;
    border-color: var(--border);
    background: rgba(255, 255, 255, 0.025);
}

.account-card {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.035);
}

.account-card-login {
    color: inherit;
    text-decoration: none;
    cursor: pointer;
    transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.account-card-login:hover {
    border-color: rgba(168, 85, 247, 0.55);
    background: rgba(139, 92, 246, 0.12);
    transform: translateY(-1px);
}

.account-card-login:focus-visible {
    outline: 2px solid #a855f7;
    outline-offset: 3px;
}

.account-card-login .account-copy strong {
    line-height: 1.25;
    white-space: normal;
}

.account-login-arrow {
    flex: 0 0 auto;
    color: #c9adff;
    font-size: 1.35rem;
    line-height: 1;
}

.account-logout-button {
    display: grid;
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    place-items: center;
    margin-left: auto;
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--muted);
    text-decoration: none;
    background: rgba(255,255,255,.03);
}
.account-logout-button:hover { color: #fff; border-color: rgba(248,113,113,.45); background: rgba(127,29,29,.18); }
.account-profile-logout { display: inline-flex; width: max-content; margin-top: 8px; text-decoration: none; }
.wallet-summary { margin-top: 14px; padding: 14px; border: 1px solid var(--border); border-radius: 14px; background: rgba(139,92,246,.08); }
.wallet-summary div { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.wallet-summary strong { color:#dec8ff; font-size:1.05rem; }
.wallet-summary small { display:block; margin-top:6px; color:var(--muted); line-height:1.45; }
.account-topup-card { margin-top: 18px; }
.topup-package-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(180px,1fr)); gap:12px; }
.topup-package { padding:16px; border:1px solid var(--border); border-radius:15px; background:var(--surface-2); }
.topup-package strong,.topup-package span { display:block; }
.topup-package strong { margin:6px 0 2px; font-size:1.15rem; }
.topup-package small { color:var(--muted); }
.topup-package button { width:100%; margin-top:12px; }
.account-billing-catalogue,.account-topup-card,.account-payment-methods{margin-bottom:18px}.billing-plan-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:14px;margin-top:18px}.billing-plan-card{display:flex;flex-direction:column;gap:14px;min-width:0;padding:18px;border:1px solid var(--border);border-radius:18px;background:var(--surface-2)}.billing-plan-card.is-current{border-color:rgba(139,92,246,.65);box-shadow:inset 0 0 0 1px rgba(139,92,246,.18);background:linear-gradient(145deg,rgba(91,33,182,.13),var(--surface-2))}.billing-plan-heading{display:flex;justify-content:space-between;gap:12px;align-items:flex-start}.billing-plan-heading h3{margin:4px 0 0}.billing-plan-description{margin:0;color:var(--muted);min-height:2.8em}.billing-plan-price{font-size:1.35rem}.billing-benefit-list{display:grid;gap:8px;margin:0 0 4px;padding:0;list-style:none;color:var(--muted)}.billing-benefit-list li:before{content:"✓";color:#a78bfa;font-weight:800;margin-right:8px}.billing-plan-card>.secondary-button{margin-top:auto;text-align:center}.wallet-breakdown{display:grid!important;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;margin-top:14px}.wallet-breakdown>span{display:grid;gap:3px;padding:10px;border:1px solid var(--border);border-radius:12px;background:rgba(255,255,255,.025)}.wallet-breakdown small{color:var(--muted)}.payment-method-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));gap:12px;margin-top:16px}.payment-method-item{display:grid;gap:5px;padding:15px;border:1px solid var(--border);border-radius:14px;background:var(--surface-2)}.payment-method-item span,.payment-method-item small{color:var(--muted)}.payment-method-status{color:#a78bfa!important;font-weight:700}
.account-billing-history{margin-bottom:18px}.billing-history-list{display:grid;margin-top:14px;border:1px solid var(--border);border-radius:14px;overflow:hidden}.billing-history-row{display:flex;justify-content:space-between;gap:18px;padding:14px 16px;border-bottom:1px solid var(--border);background:var(--surface-2)}.billing-history-row:last-child{border-bottom:0}.billing-history-row>div{display:grid;gap:3px}.billing-history-row>div:last-child{text-align:right}.billing-history-row small,.billing-history-empty{color:var(--muted)}.billing-history-empty{padding:16px}.billing-status{font-weight:700}.billing-status.is-completed{color:#34d399}.billing-status.is-failed,.billing-status.is-refunded{color:#f87171}

.account-avatar {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    border-radius: 12px;
    object-fit: cover;
}

.account-avatar-fallback {
    display: grid;
    place-items: center;
    background: var(--accent-soft);
    color: #d8c1ff;
    font-weight: 800;
}

.account-copy {
    min-width: 0;
    flex: 1;
}

.account-copy small,
.account-copy strong {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.account-copy small {
    color: var(--muted);
    font-size: 0.7rem;
}

.account-copy strong {
    margin-top: 2px;
    font-size: 0.83rem;
}

.account-state {
    width: 8px;
    height: 8px;
    flex: 0 0 8px;
    border-radius: 999px;
    background: var(--success);
    box-shadow: 0 0 0 4px rgba(57, 217, 138, 0.1);
}

.app-main {
    min-height: 100vh;
    min-height: 100dvh;
    margin-left: var(--sidebar-width);
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    min-height: 86px;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 14px clamp(20px, 4vw, 56px);
    background: rgba(9, 9, 13, 0.78);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(22px);
}

.topbar-left,
.topbar-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}

.eyebrow {
    margin: 0 0 3px;
    color: #b996f8;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.topbar h1 {
    margin: 0;
    font-size: clamp(1.25rem, 2vw, 1.65rem);
    letter-spacing: -0.035em;
}

.language-control select {
    width: auto;
    min-height: 42px;
    padding: 0 36px 0 13px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-2);
    color: var(--text);
    cursor: pointer;
}

.health-badge {
    display: inline-flex;
    min-height: 32px;
    align-items: center;
    gap: 7px;
    padding: 0 11px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 700;
}

.health-badge::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #e7b94c;
}

.health-badge.is-online::before {
    background: var(--success);
}

.health-badge.is-offline::before {
    background: var(--danger);
}

.page-area {
    width: min(1420px, 100%);
    margin: 0 auto;
    padding: clamp(22px, 4vw, 56px);
}

.page-view {
    display: none;
    animation: page-in 220ms ease both;
}

.page-view.is-active {
    display: block;
}

@keyframes page-in {
    from { opacity: 0; transform: translateY(7px); }
    to { opacity: 1; transform: translateY(0); }
}

.hero-panel {
    position: relative;
    display: grid;
    min-height: 360px;
    grid-template-columns: minmax(0, 1.25fr) minmax(270px, 0.75fr);
    align-items: center;
    gap: 32px;
    overflow: hidden;
    padding: clamp(30px, 5vw, 66px);
    border: 1px solid rgba(178, 128, 255, 0.19);
    border-radius: var(--radius-lg);
    background:
        linear-gradient(125deg, rgba(155, 92, 255, 0.15), transparent 48%),
        rgba(17, 17, 24, 0.82);
    box-shadow: var(--shadow);
}

.hero-panel::after {
    content: "";
    position: absolute;
    width: 440px;
    height: 440px;
    right: -180px;
    bottom: -250px;
    border-radius: 50%;
    background: rgba(124, 58, 237, 0.2);
    filter: blur(30px);
}

.pill {
    display: inline-flex;
    width: fit-content;
    min-height: 30px;
    align-items: center;
    padding: 0 11px;
    border: 1px solid rgba(155, 92, 255, 0.25);
    border-radius: 999px;
    background: var(--accent-soft);
    color: #d9c3ff;
    font-size: 0.76rem;
    font-weight: 800;
}

.hero-copy {
    position: relative;
    z-index: 2;
}

.hero-copy h2 {
    max-width: 760px;
    margin: 19px 0 14px;
    font-size: clamp(2.15rem, 5vw, 4.7rem);
    line-height: 0.98;
    letter-spacing: -0.065em;
}

.hero-copy p {
    max-width: 670px;
    margin: 0;
    color: var(--muted);
    font-size: clamp(0.98rem, 1.4vw, 1.15rem);
    line-height: 1.65;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 11px;
    margin-top: 28px;
}

.primary-button,
.secondary-button,
.danger-button {
    display: inline-flex;
    min-height: 46px;
    align-items: center;
    justify-content: center;
    padding: 0 18px;
    border-radius: 13px;
    text-decoration: none;
    cursor: pointer;
    transition: transform 150ms ease, filter 150ms ease;
}

.primary-button:hover,
.secondary-button:hover,
.danger-button:hover {
    transform: translateY(-1px);
    filter: brightness(1.08);
}

.primary-button {
    border: 0;
    background: linear-gradient(135deg, #a66cff, #7133df);
    color: white;
    font-weight: 800;
    box-shadow: 0 15px 32px rgba(124, 58, 237, 0.28);
}

.secondary-button {
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
}

.danger-button {
    border: 1px solid rgba(255, 107, 122, 0.28);
    background: rgba(255, 78, 99, 0.1);
    color: #ff9aa7;
    font-weight: 750;
}

.danger-button:hover {
    background: rgba(255, 78, 99, 0.17);
}

.danger-button:disabled {
    cursor: wait;
    opacity: 0.58;
}

.hero-orbit {
    position: relative;
    z-index: 2;
    min-height: 240px;
}

.orbit-card {
    position: absolute;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.13);
    background: rgba(30, 29, 40, 0.74);
    box-shadow: 0 24px 50px rgba(0, 0, 0, 0.32);
    backdrop-filter: blur(18px);
    font-weight: 900;
    letter-spacing: -0.04em;
}

.orbit-card-one {
    inset: 9% auto auto 5%;
    width: 130px;
    height: 170px;
    border-radius: 28px;
    transform: rotate(-10deg);
    color: #cbaaff;
    font-size: 2.2rem;
}

.orbit-card-two {
    inset: 24% 4% auto auto;
    width: 150px;
    height: 190px;
    border-radius: 30px;
    transform: rotate(9deg);
    color: #fff;
    font-size: 2.5rem;
}

.orbit-card-three {
    inset: auto auto 0 36%;
    width: 104px;
    height: 104px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(168, 109, 255, 0.85), rgba(91, 42, 190, 0.78));
    color: white;
    font-size: 1.35rem;
}

.section-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    margin: 48px 4px 18px;
}

.section-heading h2 {
    margin: 0;
    font-size: clamp(1.4rem, 2.3vw, 2rem);
    letter-spacing: -0.04em;
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.feature-card,
.empty-panel {
    border: 1px solid var(--border);
    background: rgba(17, 17, 24, 0.78);
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.16);
}

.feature-card {
    min-height: 210px;
    padding: 24px;
    border-radius: var(--radius-md);
}

.feature-icon {
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    border-radius: 13px;
    background: var(--accent-soft);
    color: #d2b5ff;
    font-size: 1.3rem;
}

.feature-card h3 {
    margin: 20px 0 8px;
    font-size: 1.05rem;
}

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

.empty-panel {
    display: grid;
    min-height: 420px;
    place-items: center;
    align-content: center;
    gap: 11px;
    padding: 44px;
    border-radius: var(--radius-lg);
    text-align: center;
}

.empty-symbol {
    display: grid;
    width: 64px;
    height: 64px;
    place-items: center;
    border-radius: 20px;
    background: var(--accent-soft);
    color: #d1b1ff;
    font-size: 1.8rem;
}

.empty-panel h2 {
    margin: 7px 0 0;
    font-size: clamp(1.7rem, 3vw, 2.5rem);
    letter-spacing: -0.045em;
}

.empty-panel p {
    max-width: 560px;
    margin: 0 0 7px;
    color: var(--muted);
    line-height: 1.65;
}

.sidebar-backdrop,
.mobile-bottom-nav {
    display: none;
}

@media (max-width: 1024px) {
    .hero-panel {
        grid-template-columns: 1fr;
    }

    .hero-orbit {
        display: none;
    }

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

@media (max-width: 820px) {
    body.sidebar-open {
        overflow: hidden;
    }

    .app-sidebar {
        width: min(88vw, 310px);
        transform: translateX(-104%);
        box-shadow: 24px 0 80px rgba(0, 0, 0, 0.55);
        transition: transform 220ms ease;
    }

    .app-sidebar.is-open {
        transform: translateX(0);
    }

    .sidebar-close,
    .mobile-menu-button {
        display: inline-grid;
    }

    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        z-index: 45;
        display: block;
        background: rgba(0, 0, 0, 0.62);
        backdrop-filter: blur(4px);
    }

    .sidebar-backdrop[hidden] {
        display: none;
    }

    .app-main {
        margin-left: 0;
        padding-bottom: 76px;
    }

    .topbar {
        min-height: 74px;
        padding: 10px 14px;
    }

    .health-badge {
        display: none;
    }

    .page-area {
        padding: 16px 13px 26px;
    }

    .hero-panel {
        min-height: auto;
        padding: 28px 22px 32px;
        border-radius: 20px;
    }

    .hero-copy h2 {
        font-size: clamp(2.15rem, 12vw, 3.6rem);
    }

    .section-heading {
        margin-top: 34px;
    }

    .mobile-bottom-nav {
        position: fixed;
        inset: auto 0 0;
        z-index: 35;
        display: grid;
        grid-template-columns: repeat(7, minmax(0, 1fr));
        padding: 7px max(8px, env(safe-area-inset-right)) calc(7px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
        border-top: 1px solid var(--border);
        background: rgba(13, 13, 19, 0.92);
        backdrop-filter: blur(22px);
    }

    .bottom-nav-item {
        display: grid;
        min-height: 52px;
        place-items: center;
        align-content: center;
        gap: 2px;
        padding: 3px;
        border: 0;
        border-radius: 11px;
        background: transparent;
        color: var(--muted);
        text-decoration: none;
        cursor: pointer;
    }

    .bottom-nav-login {
        color: #d9c4ff;
        background: rgba(139, 92, 246, 0.12);
    }

    .bottom-nav-item.is-active {
        color: #d9c4ff;
        background: var(--accent-soft);
    }

    .bottom-nav-item span {
        font-size: 1.05rem;
    }

    .bottom-nav-item small {
        width: 100%;
        overflow: hidden;
        font-size: clamp(.53rem, 1.8vw, .68rem);
        line-height: 1.15;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .bottom-nav-item small {
        max-width: 76px;
        overflow: hidden;
        font-size: 0.62rem;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

@media (max-width: 520px) {
    .topbar-left {
        gap: 9px;
    }

    .topbar .eyebrow {
        display: none;
    }

    .language-control select {
        max-width: 112px;
        padding-right: 28px;
    }

    .hero-actions {
        display: grid;
    }

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

    .empty-panel {
        min-height: 360px;
        padding: 30px 20px;
    }
}

/* =========================================================
   PHASE 2: ACCOUNT PROFILE, AGE POLICY & LANGUAGE
========================================================= */

.profile-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.75fr);
    gap: 22px;
    align-items: start;
}

.settings-card,
.policy-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: rgba(17, 17, 24, 0.82);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.settings-card {
    padding: clamp(22px, 4vw, 34px);
}

.settings-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
}

.settings-card h2,
.policy-card h2 {
    margin: 4px 0 0;
    font-size: clamp(1.45rem, 2.4vw, 2rem);
    letter-spacing: -0.035em;
}

.settings-intro {
    max-width: 720px;
    margin: 16px 0 26px;
    color: var(--muted);
    line-height: 1.7;
}

.profile-status-badge {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 0 11px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.04);
    font-size: 0.76rem;
    font-weight: 750;
    white-space: nowrap;
}

.profile-status-badge.is-ready {
    border-color: rgba(57, 217, 138, 0.25);
    background: rgba(57, 217, 138, 0.1);
    color: #9ff3c8;
}

.profile-status-badge.is-restricted {
    border-color: rgba(255, 184, 77, 0.25);
    background: rgba(255, 184, 77, 0.1);
    color: #ffd28c;
}

.profile-status-badge.is-error {
    border-color: rgba(255, 107, 122, 0.3);
    background: rgba(255, 107, 122, 0.1);
    color: #ffadb7;
}

.notice-card {
    margin-bottom: 24px;
    padding: 17px;
    border: 1px solid rgba(255, 184, 77, 0.22);
    border-radius: var(--radius-md);
    background: rgba(255, 184, 77, 0.07);
}

.notice-card[hidden] {
    display: none;
}

.notice-card strong {
    display: block;
    margin-bottom: 5px;
}

.notice-card p {
    margin: 0 0 14px;
    color: var(--muted);
    line-height: 1.55;
}

.compact-button {
    min-height: 38px;
    padding: 0 14px;
    font-size: 0.86rem;
}

.settings-form {
    display: grid;
    gap: 20px;
}

.field-group {
    display: grid;
    gap: 8px;
}

.field-group > span {
    font-size: 0.9rem;
    font-weight: 760;
}

.field-group input,
.field-group select {
    width: 100%;
    min-height: 50px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
}

.field-group input:disabled,
.field-group select:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.field-group small {
    color: var(--muted);
    line-height: 1.5;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    padding-top: 4px;
}

.primary-button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
    transform: none;
}

.form-message {
    min-height: 1.2em;
    color: var(--muted);
    font-size: 0.9rem;
}

.form-message.is-success {
    color: var(--success);
}

.form-message.is-error {
    color: var(--danger);
}

.policy-card {
    position: sticky;
    top: 98px;
    padding: 26px;
}

.age-display {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin: 16px 0 6px;
}

.age-display strong {
    font-size: clamp(3rem, 7vw, 5rem);
    line-height: 0.95;
    letter-spacing: -0.07em;
}

.age-display span {
    color: var(--muted);
    font-weight: 700;
}

.policy-summary {
    min-height: 3em;
    margin: 8px 0 24px;
    color: var(--muted);
    line-height: 1.55;
}

.policy-list {
    display: grid;
    gap: 10px;
}

.policy-list > div {
    display: grid;
    gap: 5px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.025);
}

.policy-list span {
    color: var(--muted);
    font-size: 0.78rem;
}

.policy-list strong {
    font-size: 0.92rem;
}

.separation-note {
    margin-top: 20px;
    padding: 15px;
    border-radius: 14px;
    background: var(--accent-soft);
    border: 1px solid rgba(155, 92, 255, 0.18);
}

.separation-note strong {
    display: block;
    margin-bottom: 5px;
    color: #eadfff;
}

.separation-note p {
    margin: 0;
    color: #c8badf;
    font-size: 0.86rem;
    line-height: 1.55;
}

@media (max-width: 920px) {
    .profile-layout {
        grid-template-columns: 1fr;
    }

    .policy-card {
        position: static;
    }
}

@media (max-width: 640px) {
    .settings-card-header {
        align-items: flex-start;
    }

    .settings-card,
    .policy-card {
        border-radius: 20px;
    }

    .form-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .form-actions .primary-button {
        width: 100%;
    }
}

/* =========================================================
   PHASE 3: AGE-FILTERED CHARACTER CATALOGUE
========================================================= */

.catalogue-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 18px;
}

.catalogue-heading h2 {
    margin: 3px 0 7px;
    font-size: clamp(1.9rem, 4vw, 3.2rem);
    letter-spacing: -0.055em;
}

.catalogue-heading > div > p:last-child {
    max-width: 720px;
    margin: 0;
    color: var(--muted);
    line-height: 1.65;
}

.catalogue-access-note {
    margin-bottom: 16px;
    padding: 13px 16px;
    border: 1px solid rgba(155, 92, 255, 0.2);
    border-radius: 14px;
    background: var(--accent-soft);
    color: #d8c7f4;
    font-size: 0.88rem;
    line-height: 1.5;
}

.catalogue-toolbar {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(180px, 240px) auto;
    gap: 10px;
    margin-bottom: 24px;
}

.catalogue-search,
.catalogue-filter {
    display: flex;
    min-height: 48px;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(24, 24, 32, 0.88);
}

.catalogue-search {
    gap: 10px;
    padding: 0 14px;
}

.catalogue-search > span:not(.sr-only) {
    color: var(--muted);
    font-size: 1.2rem;
}

.catalogue-search input,
.catalogue-filter select {
    width: 100%;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text);
    font: inherit;
}

.catalogue-search input {
    height: 46px;
}

.catalogue-search input::placeholder {
    color: #777382;
}

.catalogue-filter select {
    height: 46px;
    padding: 0 34px 0 13px;
    cursor: pointer;
}

.catalogue-search:focus-within,
.catalogue-filter:focus-within {
    border-color: rgba(155, 92, 255, 0.5);
    box-shadow: 0 0 0 3px rgba(155, 92, 255, 0.1);
}

.catalogue-state {
    display: grid;
    min-height: 330px;
    place-items: center;
    align-content: center;
    gap: 12px;
    padding: 30px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: rgba(17, 17, 24, 0.7);
    color: var(--muted);
    text-align: center;
}

.catalogue-state[hidden],
.character-groups[hidden] {
    display: none;
}

.catalogue-state h3,
.catalogue-state p {
    margin: 0;
}

.catalogue-state.is-error {
    border-color: rgba(255, 107, 122, 0.22);
}

.loading-spinner {
    width: 38px;
    height: 38px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: catalogue-spin 700ms linear infinite;
}

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

.character-groups {
    display: grid;
    gap: 34px;
}

.character-group {
    min-width: 0;
}

.character-group-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin: 0 3px 13px;
}

.character-group-heading h3 {
    margin: 0;
    font-size: 1.12rem;
    letter-spacing: -0.025em;
}

.character-count {
    color: var(--muted);
    font-size: 0.76rem;
}

.character-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 16px;
}

.character-card {
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: rgba(17, 17, 24, 0.84);
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.18);
    transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.character-card:hover {
    transform: translateY(-3px);
    border-color: rgba(155, 92, 255, 0.3);
    box-shadow: 0 24px 55px rgba(0, 0, 0, 0.27);
}

.character-card-media {
    position: relative;
    aspect-ratio: 4 / 5;
    overflow: hidden;
    background:
        radial-gradient(circle at 70% 20%, rgba(155, 92, 255, 0.24), transparent 45%),
        var(--surface-2);
}

.character-card-media img,
.character-image-fallback {
    width: 100%;
    height: 100%;
}

.character-card-media img {
    display: block;
    object-fit: cover;
    transition: transform 300ms ease;
}

.character-card:hover .character-card-media img {
    transform: scale(1.025);
}

.character-image-fallback {
    display: grid;
    place-items: center;
    color: #d8c2ff;
    font-size: 4rem;
    font-weight: 900;
}

.character-card-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    padding: 12px;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.3), transparent 42%, rgba(0, 0, 0, 0.48));
    pointer-events: none;
}

.character-badges {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
}

.character-badge,
.roleplay-age,
.character-meta span {
    display: inline-flex;
    min-height: 25px;
    align-items: center;
    padding: 0 9px;
    border: 1px solid rgba(255, 255, 255, 0.13);
    border-radius: 999px;
    background: rgba(11, 11, 16, 0.7);
    color: #eee8f8;
    backdrop-filter: blur(12px);
    font-size: 0.68rem;
    font-weight: 780;
}

.character-badge.mode-romance {
    color: #ffd2e7;
    background: rgba(139, 45, 90, 0.68);
}

.character-badge.mode-adult {
    color: #ffd8dc;
    background: rgba(132, 38, 52, 0.72);
}

.character-badge.is-favorite {
    color: #ffd974;
}

.character-card-body {
    display: grid;
    gap: 12px;
    padding: 16px;
}

.character-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.character-title-row h3 {
    min-width: 0;
    margin: 0;
    overflow: hidden;
    font-size: 1.06rem;
    letter-spacing: -0.025em;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.roleplay-age {
    flex: 0 0 auto;
    background: rgba(255, 255, 255, 0.035);
    color: var(--muted);
}

.character-description {
    display: -webkit-box;
    min-height: 4.65em;
    margin: 0;
    overflow: hidden;
    color: var(--muted);
    font-size: 0.85rem;
    line-height: 1.55;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
}

.character-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.character-meta span {
    min-height: 24px;
    background: rgba(255, 255, 255, 0.03);
    color: #bdb7c8;
}

.character-chat-button {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
    color: #86818f;
    font: inherit;
    font-size: 0.82rem;
    font-weight: 760;
}

.character-chat-button:disabled {
    cursor: not-allowed;
}

@media (max-width: 760px) {
    .catalogue-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .catalogue-heading .secondary-button {
        width: fit-content;
    }

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

    .catalogue-search {
        grid-column: 1 / -1;
    }

    .character-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 11px;
    }

    .character-card {
        border-radius: 16px;
    }

    .character-card-body {
        gap: 9px;
        padding: 12px;
    }

    .character-title-row {
        align-items: flex-start;
        flex-direction: column;
        gap: 6px;
    }

    .character-title-row h3 {
        width: 100%;
    }

    .character-description {
        min-height: 4.35em;
        font-size: 0.78rem;
        -webkit-line-clamp: 3;
    }

    .character-meta {
        display: none;
    }

    .character-chat-button {
        min-height: 38px;
        padding: 5px 8px;
        font-size: 0.72rem;
    }
}

/* =========================================================
   CHARACTER DISCOVERY EXPERIENCE
========================================================= */
.character-spotlight[hidden],
.dashboard-hero-feature[hidden],
#dashboardHeroOrbit[hidden] {
    display: none !important;
}

.discovery-hero.has-featured-character {
    isolation: isolate;
    overflow: hidden;
}

.discovery-hero.has-featured-character::after {
    content: "";
    position: absolute;
    z-index: 0;
    top: 0;
    right: 0;
    bottom: 0;
    height: auto;
    width: min(54%, 650px);
    border-radius: 0;
    pointer-events: none;
    background-image: var(--dashboard-hero-art);
    background-position: center 22%;
    background-size: cover;
    background-repeat: no-repeat;
    opacity: 0.88;
    filter: none;
    -webkit-mask-image: linear-gradient(90deg, transparent 0%, rgba(0,0,0,.5) 24%, #000 58%);
    mask-image: linear-gradient(90deg, transparent 0%, rgba(0,0,0,.5) 24%, #000 58%);
}

.discovery-hero.has-featured-character::before {
    z-index: 1;
    background: linear-gradient(90deg, rgba(7, 7, 10, .96) 0%, rgba(7, 7, 10, .83) 43%, rgba(7, 7, 10, .08) 78%);
}

.discovery-hero .hero-copy {
    position: relative;
    z-index: 2;
}

.discovery-hero.has-featured-character .hero-copy {
    max-width: min(720px, 67%);
}

.dashboard-hero-feature {
    position: absolute;
    z-index: 3;
    right: 24px;
    bottom: 22px;
    display: grid;
    min-width: 190px;
    max-width: 270px;
    gap: 2px;
    padding: 11px 14px;
    border: 1px solid rgba(255, 255, 255, .14);
    border-radius: 15px;
    background: rgba(10, 8, 14, .68);
    box-shadow: 0 12px 34px rgba(0, 0, 0, .34);
    backdrop-filter: blur(14px);
    color: #fff;
    cursor: pointer;
    text-align: left;
}

.dashboard-hero-feature:hover {
    border-color: rgba(216, 180, 254, .38);
    background: rgba(26, 16, 38, .82);
}

.dashboard-hero-feature-label {
    color: #d8b4fe;
    font-size: .61rem;
    font-weight: 850;
    letter-spacing: .09em;
    text-transform: uppercase;
}

.dashboard-hero-feature strong { margin-top: 2px; font-size: .96rem; }
.dashboard-hero-feature small { color: #aaa3b2; font-size: .68rem; }

.characters-page .catalogue-heading {
    margin-bottom: 10px;
}

.character-spotlight {
    position: relative;
    display: grid;
    min-height: 300px;
    grid-template-columns: minmax(250px, .78fr) minmax(0, 1.22fr);
    overflow: hidden;
    margin: 18px 0 20px;
    border: 1px solid rgba(192, 132, 252, .16);
    border-radius: 25px;
    background:
        radial-gradient(circle at 75% 15%, rgba(126, 34, 206, .15), transparent 27rem),
        #0e0d12;
    box-shadow: 0 24px 72px rgba(0, 0, 0, .3);
}

.character-spotlight-media {
    position: relative;
    min-height: 300px;
    overflow: hidden;
}

.character-spotlight-media::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent 54%, #0e0d12 100%);
    pointer-events: none;
}

.character-spotlight-media img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    object-position: center 22%;
}

.character-spotlight-copy {
    display: flex;
    min-width: 0;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    padding: clamp(24px, 4vw, 48px);
}

.character-spotlight-eyebrow {
    color: #c084fc;
    font-size: .68rem;
    font-weight: 900;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.character-spotlight-copy h3 {
    margin: 6px 0 10px;
    font-size: clamp(2rem, 4vw, 3.65rem);
    line-height: .98;
    letter-spacing: -.055em;
}

.character-spotlight-copy > p {
    display: -webkit-box;
    max-width: 650px;
    margin: 0;
    overflow: hidden;
    color: #b7b0bd;
    font-size: .9rem;
    line-height: 1.6;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
}

.character-spotlight-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 15px;
}

.character-spotlight-meta span {
    padding: 5px 9px;
    border: 1px solid rgba(255,255,255,.09);
    border-radius: 999px;
    background: rgba(255,255,255,.035);
    color: #aaa3b2;
    font-size: .68rem;
    font-weight: 750;
}

.character-spotlight-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    margin-top: 20px;
}

.character-discovery-tabs {
    display: flex;
    gap: 7px;
    margin: 4px 0 14px;
    overflow-x: auto;
    padding: 2px 1px 4px;
    scrollbar-width: none;
}

.character-discovery-tabs::-webkit-scrollbar,
.character-category-chips::-webkit-scrollbar { display: none; }

.character-discovery-tab,
.character-category-chip {
    flex: 0 0 auto;
    border: 1px solid rgba(255,255,255,.075);
    border-radius: 999px;
    background: rgba(255,255,255,.025);
    color: #96909e;
    cursor: pointer;
    font: inherit;
    font-size: .76rem;
    font-weight: 760;
    transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
}

.character-discovery-tab { min-height: 38px; padding: 0 14px; }
.character-category-chip { min-height: 32px; padding: 0 11px; font-size: .7rem; }

.character-discovery-tab:hover,
.character-category-chip:hover { color: #e8dff0; border-color: rgba(192,132,252,.23); }

.character-discovery-tab.is-active,
.character-category-chip.is-active {
    border-color: rgba(192, 132, 252, .32);
    background: linear-gradient(135deg, rgba(126,34,206,.32), rgba(76,29,149,.18));
    color: #f1e8ff;
}

.characters-page .catalogue-toolbar {
    grid-template-columns: minmax(260px, 1fr) auto auto;
    margin-bottom: 10px;
}

.character-category-chips {
    display: flex;
    gap: 6px;
    margin: 0 0 10px;
    overflow-x: auto;
    padding: 0 1px 3px;
    scrollbar-width: none;
}

.character-discovery-summary-row {
    display: flex;
    min-height: 32px;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}

.character-discovery-summary {
    color: #8f8998;
    font-size: .72rem;
    font-weight: 720;
}

.character-clear-filters {
    min-height: 32px;
    padding: 5px 10px;
    border: 1px solid rgba(192, 132, 252, .18);
    border-radius: 999px;
    background: rgba(126, 34, 206, .1);
    color: #cbb5e8;
    cursor: pointer;
    font: inherit;
    font-size: .68rem;
    font-weight: 760;
}

.character-clear-filters:hover { border-color: rgba(192, 132, 252, .34); color: #fff; }

.characters-page .character-groups { gap: 38px; }
.characters-page .character-group-heading { margin-bottom: 12px; }
.characters-page .character-grid { grid-template-columns: repeat(auto-fill, minmax(205px, 1fr)); gap: 14px; }

.characters-page .character-card {
    position: relative;
    aspect-ratio: 3 / 4.15;
    min-height: 330px;
    overflow: hidden;
    border-radius: 20px;
    background: #111016;
}

.characters-page .character-card-media {
    position: absolute;
    inset: 0;
    aspect-ratio: auto;
}

.characters-page .character-card-media img {
    transform: scale(1.002);
    transition: transform 420ms cubic-bezier(.2,.7,.2,1), filter 220ms ease;
}

.characters-page .character-card:hover .character-card-media img { transform: scale(1.055); }

.characters-page .character-card-overlay {
    z-index: 2;
    background: linear-gradient(180deg, rgba(0,0,0,.28), transparent 34%, rgba(7,6,10,.2) 55%, rgba(7,6,10,.98) 100%);
}

.characters-page .character-card-body {
    position: absolute;
    z-index: 3;
    right: 0;
    bottom: 0;
    left: 0;
    gap: 8px;
    padding: 78px 14px 14px;
    background: linear-gradient(180deg, transparent, rgba(8,7,11,.9) 58%, rgba(8,7,11,.98));
}

.characters-page .character-title-row h3 {
    color: #fff;
    font-size: 1.08rem;
    text-shadow: 0 2px 12px rgba(0,0,0,.6);
}

.characters-page .roleplay-age { background: rgba(9,8,12,.62); color: #c6bfca; }
.characters-page .character-description { min-height: 2.7em; color: #aaa4af; font-size: .76rem; line-height: 1.45; -webkit-line-clamp: 2; }
.characters-page .character-meta { display: none; }

.characters-page .character-chat-button {
    min-height: 42px;
    border-color: rgba(192,132,252,.2);
    background: linear-gradient(135deg, rgba(147,51,234,.88), rgba(91,33,182,.94));
    color: #fff;
}

.characters-page .character-chat-button:hover { filter: brightness(1.1); }

@media (max-width: 760px) {
    .discovery-hero.has-featured-character::after { width: 78%; opacity: .5; }
    .discovery-hero.has-featured-character::before { background: linear-gradient(90deg, rgba(7,7,10,.94), rgba(7,7,10,.72) 58%, rgba(7,7,10,.22)); }
    .discovery-hero.has-featured-character .hero-copy { max-width: 100%; }
    .dashboard-hero-feature { display: none; }

    .character-spotlight { grid-template-columns: 1fr; min-height: 0; }
    .character-spotlight-media { min-height: 250px; max-height: 42vh; }
    .character-spotlight-media::after { background: linear-gradient(180deg, transparent 60%, #0e0d12 100%); }
    .character-spotlight-copy { padding: 20px; }
    .character-spotlight-copy h3 { font-size: clamp(2rem, 10vw, 3rem); }
    .character-spotlight-copy > p { -webkit-line-clamp: 2; }
    .character-spotlight-actions { width: 100%; }
    .character-spotlight-actions > * { flex: 1; }

    .characters-page .catalogue-toolbar { grid-template-columns: minmax(0, 1fr) auto; }
    .characters-page .catalogue-search { grid-column: 1 / -1; }
    .characters-page .character-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .characters-page .character-card { min-height: 280px; border-radius: 16px; }
    .characters-page .character-grid .character-card-body { min-height: 142px; padding: 54px 11px 11px; }
    .characters-page .character-description { font-size: .7rem; }
    .characters-page .character-grid .character-title-row { min-height: 2.7em; flex-direction: row; align-items: center; }
    .characters-page .character-chat-button { min-height: 42px; font-size: .7rem; }
}

@media (max-width: 390px) {
    .characters-page .character-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .characters-page .character-card { min-height: 250px; }
    .characters-page .roleplay-age { display: none; }
}

@media (max-width: 390px) {
    .character-grid {
        grid-template-columns: 1fr;
    }

    .character-card-media {
        aspect-ratio: 16 / 11;
    }
}

/* =========================================================
   PHASE 4: STORIES, START MODAL & CHAT
========================================================= */

.story-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 18px;
}

.story-card {
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--border, rgba(255, 255, 255, 0.09));
    border-radius: 22px;
    background: linear-gradient(180deg, rgba(26, 26, 36, 0.96), rgba(14, 14, 21, 0.98));
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.22);
}

.story-card-media {
    position: relative;
    height: 170px;
    overflow: hidden;
    background: #171722;
}

.story-card-media img,
.story-card-media .character-image-fallback {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.story-card-media::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 35%, rgba(8, 8, 13, 0.82));
    pointer-events: none;
}

.story-language-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    height: 28px;
    padding: 0 9px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 999px;
    background: rgba(10, 10, 16, 0.74);
    backdrop-filter: blur(14px);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.08em;
}

.story-card-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 18px;
}

.story-card-body h3,
.story-card-body p {
    margin: 0;
}

.story-character-name {
    color: #c4b5fd;
    font-weight: 700;
}

.story-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    min-height: 26px;
}

.story-card-meta span {
    padding: 5px 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.055);
    color: #aaa9b8;
    font-size: 0.74rem;
}

.story-card-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(110px, auto);
    gap: 8px;
    margin-top: 4px;
}

.story-open-button,
.story-delete-button {
    width: 100%;
}

@media (max-width: 430px) {
    .story-card-actions {
        grid-template-columns: 1fr;
    }
}

.modal-layer {
    position: fixed;
    inset: 0;
    z-index: 5000;
    display: grid;
    place-items: center;
    padding: 18px;
}

.modal-layer[hidden] {
    display: none;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(4, 4, 8, 0.78);
    backdrop-filter: blur(12px);
}

.v2-modal {
    position: relative;
    z-index: 1;
    width: min(620px, 100%);
    max-height: min(820px, calc(100dvh - 36px));
    overflow-y: auto;
    padding: 22px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    background: #12121a;
    box-shadow: 0 30px 100px rgba(0, 0, 0, 0.6);
}

.v2-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.v2-modal-header h2,
.v2-modal-header p {
    margin: 0;
}

.selected-character-summary {
    display: grid;
    grid-template-columns: 82px 1fr;
    gap: 14px;
    align-items: center;
    margin-bottom: 20px;
    padding: 12px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.045);
}

.selected-character-summary img,
.selected-character-summary .character-image-fallback {
    width: 82px;
    height: 82px;
    border-radius: 14px;
    object-fit: cover;
}

.selected-character-summary h3,
.selected-character-summary p {
    margin: 0;
}

.selected-character-summary p {
    display: -webkit-box;
    margin-top: 5px;
    overflow: hidden;
    color: #aaa9b8;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.modal-actions {
    justify-content: flex-end;
}

body.modal-open {
    overflow: hidden;
}

/* Immersive story start */
.v2-modal.story-start-modal-card {
    width: min(1120px, calc(100vw - 36px));
    height: min(860px, calc(100dvh - 36px));
    max-height: min(860px, calc(100dvh - 36px));
    display: grid;
    grid-template-columns: minmax(330px, .82fr) minmax(0, 1.18fr);
    overflow: hidden;
    padding: 0;
    border-radius: 28px;
    background: #0d0d12;
}

.story-start-visual {
    position: relative;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    background: radial-gradient(circle at 50% 20%, rgba(168, 85, 247, .24), transparent 44%), #17171e;
}

.story-start-visual::after {
    content: "";
    position: absolute;
    z-index: 1;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(180deg, transparent 40%, rgba(7, 7, 11, .45) 66%, rgba(7, 7, 11, .98) 100%);
}

.story-start-visual .selected-character-summary {
    position: absolute;
    inset: 0;
    display: block;
    margin: 0;
    padding: 0;
    border-radius: 0;
    background: transparent;
}

.story-start-visual .selected-character-summary > img,
.story-start-visual .selected-character-summary > .character-image-fallback {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
    object-fit: cover;
}

.story-start-visual .selected-character-summary > .character-image-fallback {
    display: grid;
    place-items: center;
    background: radial-gradient(circle at 50% 30%, #392351, #15131c 64%);
    font-size: clamp(4rem, 10vw, 8rem);
}

.story-start-visual .selected-character-summary > div:last-child:not(.character-image-fallback) {
    position: absolute;
    z-index: 2;
    right: 26px;
    bottom: 84px;
    left: 26px;
}

.story-start-visual .selected-character-summary h3 {
    margin: 0;
    color: #fff;
    font-size: clamp(2rem, 3.5vw, 3.4rem);
    line-height: .98;
    letter-spacing: -.045em;
    text-shadow: 0 3px 24px rgba(0, 0, 0, .65);
}

.story-start-visual .selected-character-summary p {
    -webkit-line-clamp: 3;
    margin-top: 10px;
    color: #ded8e8;
    font-size: .9rem;
    line-height: 1.5;
    text-shadow: 0 2px 16px rgba(0, 0, 0, .8);
}

.story-start-visual .story-age-notice {
    position: absolute;
    z-index: 3;
    right: 22px;
    bottom: 20px;
    left: 22px;
    margin: 0;
    border-color: rgba(255, 255, 255, .12);
    background: rgba(14, 12, 20, .72);
    backdrop-filter: blur(16px);
}

.story-start-config {
    min-width: 0;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    padding: clamp(26px, 3vw, 40px);
}

.story-start-header {
    position: sticky;
    z-index: 5;
    top: -1px;
    margin: -4px -4px 20px;
    padding: 4px 4px 14px;
    background: linear-gradient(180deg, #0d0d12 76%, transparent);
}

.story-start-header h2 {
    font-size: clamp(1.8rem, 3vw, 2.55rem);
    letter-spacing: -.035em;
}

.story-start-form { gap: 22px; }
.story-start-section { gap: 9px; }

.story-start-section-title {
    color: #f7f3ff;
    font-size: .88rem;
    font-weight: 800;
}

.story-start-options {
    display: grid;
    grid-template-columns: minmax(0, .72fr) minmax(0, 1.28fr);
    gap: 12px;
}

.story-start-submit-row {
    position: sticky;
    z-index: 4;
    bottom: -1px;
    display: grid;
    grid-template-columns: auto minmax(210px, 1fr);
    gap: 10px;
    margin: 2px -4px -4px;
    padding: 16px 4px 4px;
    background: linear-gradient(0deg, #0d0d12 76%, transparent);
}

.story-start-submit {
    min-height: 52px;
    background: linear-gradient(135deg, #b15cff, #782fd0);
    box-shadow: 0 12px 30px rgba(126, 48, 210, .22);
}

.story-start-modal-card .choice-card-grid { max-height: 250px; }
.story-start-modal-card .choice-card-grid.compact { max-height: 190px; }

@media (max-width: 780px) {
    .v2-modal.story-start-modal-card {
        width: 100%;
        height: min(94dvh, 900px);
        max-height: 94dvh;
        grid-template-columns: 1fr;
        grid-template-rows: minmax(190px, 28dvh) minmax(0, 1fr);
        border-radius: 26px 26px 0 0;
        padding: 0;
    }

    .story-start-visual .selected-character-summary > div:last-child:not(.character-image-fallback) {
        right: 20px;
        bottom: 64px;
        left: 20px;
    }

    .story-start-visual .selected-character-summary h3 { font-size: clamp(1.8rem, 8vw, 2.55rem); }
    .story-start-visual .selected-character-summary p { -webkit-line-clamp: 1; margin-top: 6px; }
    .story-start-visual .story-age-notice { right: 16px; bottom: 12px; left: 16px; padding: 8px 10px; font-size: .72rem; }
    .story-start-config { padding: 22px 18px calc(18px + env(safe-area-inset-bottom)); }
    .story-start-options { grid-template-columns: 1fr; }
    .story-start-submit-row { grid-template-columns: 1fr; }
    .story-start-submit-row .secondary-button { display: none; }
}

/* Storyraum 3.0 assisted AI director */
.director-modal-card {
    width: min(980px, calc(100vw - 28px));
    max-height: min(92vh, 980px);
    overflow: auto;
}

.director-intro {
    margin: 0 0 14px;
    color: var(--muted-text, #aaa4b5);
    line-height: 1.55;
}

.director-safety {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 11px;
    align-items: start;
    margin-bottom: 16px;
    padding: 13px 15px;
    border: 1px solid rgba(96, 165, 250, .3);
    border-radius: 15px;
    background: rgba(37, 99, 235, .08);
}
.director-safety > span { color: #93c5fd; font-weight: 900; }
.director-safety p,
.director-safety strong,
.director-safety small { display: block; margin: 0; }
.director-safety small { margin-top: 3px; color: var(--muted-text, #aaa4b5); line-height: 1.45; }

.director-content,
.director-settings-form,
.director-cast-list,
.director-active-suggestion,
.director-history { display: grid; gap: 16px; }
.director-content[hidden],
#directorLoading[hidden],
#directorSuggestionSection[hidden],
#directorHistorySection[hidden] { display: none !important; }

.director-section {
    padding: 17px;
    border: 1px solid var(--border-color, rgba(255,255,255,.09));
    border-radius: 20px;
    background: var(--surface-soft, rgba(255,255,255,.025));
}
.director-toggle { margin: -3px 0 2px; }
.director-settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(220px, 1fr));
    gap: 13px;
}
.director-settings-form input,
.director-settings-form select,
.director-settings-form textarea { width: 100%; }
.director-settings-form .creator-mode-control input { width: auto; }
.director-section-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 12px;
}
.director-section-heading h3 { margin: 3px 0 0; }
.director-section-note { margin: -3px 0 14px; color: var(--muted-text, #aaa4b5); line-height: 1.5; }
.director-settings-actions,
.director-footer { justify-content: flex-end; }

.director-cast-card {
    padding: 14px;
    border: 1px solid rgba(255,255,255,.09);
    border-radius: 17px;
    background: rgba(0,0,0,.14);
    opacity: .72;
    transition: border-color .16s ease, opacity .16s ease, background .16s ease;
}
.director-cast-card.is-selected {
    border-color: rgba(96,165,250,.4);
    background: rgba(37,99,235,.07);
    opacity: 1;
}
.director-cast-select {
    display: grid;
    grid-template-columns: auto auto minmax(0, 1fr);
    gap: 11px;
    align-items: center;
    cursor: pointer;
}
.director-cast-select > input { width: auto; accent-color: #8b5cf6; }
.director-cast-avatar {
    display: grid;
    width: 44px;
    height: 44px;
    overflow: hidden;
    place-items: center;
    border: 1px solid rgba(147,197,253,.3);
    border-radius: 14px;
    background: rgba(59,130,246,.14);
    color: #dbeafe;
    font-weight: 850;
}
.director-cast-avatar img { width: 100%; height: 100%; object-fit: cover; }
.director-cast-copy strong,
.director-cast-copy small { display: block; }
.director-cast-copy small { margin-top: 3px; color: var(--muted-text, #aaa4b5); }
.director-cast-controls {
    display: grid;
    grid-template-columns: minmax(220px, .8fr) minmax(230px, 1.2fr);
    gap: 13px;
    align-items: end;
    margin-top: 13px;
}
.director-presence { min-height: 48px; align-items: center; }
.director-presence input { width: auto; }
.director-cast-notes { margin-top: 12px; }

.director-suggestion-card {
    padding: 15px;
    border: 1px solid rgba(255,255,255,.09);
    border-radius: 17px;
    background: rgba(0,0,0,.15);
}
.director-suggestion-card.is-active { border-color: rgba(168,85,247,.42); background: rgba(124,58,237,.08); }
.director-suggestion-card.status-accepted { border-color: rgba(34,197,94,.4); background: rgba(22,163,74,.07); }
.director-suggestion-heading {
    display: flex;
    justify-content: space-between;
    align-items: start;
    gap: 14px;
}
.director-suggestion-heading strong,
.director-suggestion-heading small { display: block; }
.director-suggestion-heading small { min-height: 1em; margin-top: 4px; color: var(--muted-text, #aaa4b5); }
.director-scene-goal,
.director-scene-beat { margin: 12px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; }
.director-scene-beat { color: #ece8f5; }
.director-suggestion-list { margin-top: 12px; }
.director-suggestion-list strong { font-size: .82rem; color: #c4b5fd; }
.director-suggestion-list ul { margin: 6px 0 0; padding-left: 20px; color: var(--muted-text, #aaa4b5); }
.director-suggestion-actions { margin-top: 15px; justify-content: flex-end; }
.director-accepted-notice {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    margin-top: 15px;
    padding: 11px 13px;
    border-radius: 13px;
    background: rgba(34,197,94,.1);
    color: #bbf7d0;
    font-size: .88rem;
}
.director-empty {
    padding: 18px;
    border: 1px dashed rgba(255,255,255,.13);
    border-radius: 15px;
    color: var(--muted-text, #aaa4b5);
    text-align: center;
    line-height: 1.5;
}
.director-history-section > summary { cursor: pointer; list-style: none; }
.director-history-section > summary::-webkit-details-marker { display: none; }
.director-history-section > summary strong,
.director-history-section > summary small { display: block; }
.director-history-section > summary small { margin-top: 4px; color: var(--muted-text, #aaa4b5); }
.director-history { margin-top: 14px; }

@media (max-width: 780px) {
    .director-modal-card { width: calc(100vw - 14px); max-height: calc(100vh - 14px); }
    .director-settings-grid,
    .director-cast-controls { grid-template-columns: 1fr; }
    .director-section-heading,
    .director-suggestion-heading,
    .director-accepted-notice { align-items: stretch; flex-direction: column; }
    .director-section-heading > button,
    .director-suggestion-actions > button,
    .director-accepted-notice > button { width: 100%; }
}

.chat-page {
    height: calc(100dvh - 170px);
    min-height: 560px;
}

.chat-shell {
    display: grid;
    grid-template-rows: auto auto 1fr auto;
    width: 100%;
    height: 100%;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 24px;
    background: rgba(10, 10, 15, 0.94);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.3);
}

.chat-header {
    display: grid;
    grid-template-columns: auto auto minmax(0, 1fr) auto auto;
    gap: 12px;
    align-items: center;
    min-height: 74px;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    background: rgba(18, 18, 26, 0.94);
    backdrop-filter: blur(16px);
}

.chat-avatar {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border: 2px solid rgba(139, 92, 246, 0.7);
    border-radius: 50%;
    background: #242032 center / cover no-repeat;
    color: #fff;
    font-weight: 800;
}

.chat-header-copy {
    min-width: 0;
}

.chat-header-copy h2,
.chat-header-copy p {
    overflow: hidden;
    margin: 0;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-header-copy h2 {
    font-size: 1rem;
}

.chat-header-copy p {
    margin-top: 3px;
    color: #9c9aaa;
    font-size: 0.78rem;
}

.chat-header .story-language-badge {
    position: static;
}

.chat-messages {
    min-height: 0;
    overflow-y: auto;
    padding: 24px clamp(12px, 3vw, 34px);
    scroll-behavior: smooth;
}

.chat-empty-state {
    display: grid;
    place-items: center;
    max-width: 480px;
    min-height: 100%;
    margin: auto;
    padding: 40px 20px;
    text-align: center;
    color: #9e9dac;
}

.chat-empty-state h3,
.chat-empty-state p {
    margin: 8px 0 0;
}

.v2-message {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
    margin: 14px 0;
}

.v2-message.is-user {
    align-items: flex-end;
}

.v2-message-bubble {
    max-width: min(760px, 86%);
    padding: 13px 15px;
    border: 1px solid rgba(255, 255, 255, 0.055);
    border-radius: 18px 18px 18px 6px;
    background: #1a1a23;
    color: #d5d4dc;
    line-height: 1.62;
    overflow-wrap: anywhere;
}

.v2-message.is-user .v2-message-bubble {
    border-color: rgba(139, 92, 246, 0.25);
    border-radius: 18px 18px 6px 18px;
    background: linear-gradient(135deg, #4c1d95, #312e81);
    color: #fff;
}

.v2-message.is-pending {
    opacity: 0.58;
}

.v2-message.is-error .v2-message-bubble {
    border-color: rgba(248, 113, 113, 0.35);
    background: rgba(127, 29, 29, 0.28);
}

.v2-message-language {
    padding: 0 5px;
    color: #777583;
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.08em;
}

.chat-action-text {
    color: #a8a7b5;
    font-style: italic;
}

.chat-dialogue {
    color: #fff;
    font-weight: 650;
}

@font-face {
    font-family: "Roleplay Ink";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../vendor/kalam/kalam-latin-400-normal.woff2") format("woff2");
}

.chat-math-inline {
    display: inline-flex;
    max-width: 100%;
    margin-inline: 0.08em;
    padding: 0.08em 0.32em;
    overflow-x: auto;
    vertical-align: -0.08em;
    border: 1px solid rgba(196, 181, 253, 0.18);
    border-radius: 7px;
    background: rgba(139, 92, 246, 0.09);
    color: #f5f3ff;
    scrollbar-width: thin;
}

.chat-math-sheet {
    position: relative;
    display: block;
    width: min(100%, 680px);
    margin: 16px 0;
    padding: 20px 22px 18px 52px;
    overflow-x: auto;
    border: 1px solid #ded8c9;
    border-radius: 13px;
    background-color: #fbfaf5;
    background-image: repeating-linear-gradient(
        to bottom,
        transparent 0,
        transparent 27px,
        rgba(120, 151, 183, 0.18) 28px
    );
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.9);
    color: #1d2433;
    font-style: normal;
    font-weight: 400;
    line-height: 1.5;
    scrollbar-color: #b9ad92 transparent;
    scrollbar-width: thin;
}

.chat-math-sheet::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 38px;
    width: 1px;
    background: rgba(206, 93, 93, 0.38);
}

.chat-math-paper-hole {
    position: absolute;
    top: 17px;
    left: 13px;
    width: 10px;
    height: 10px;
    border: 1px solid #c9c2b1;
    border-radius: 50%;
    background: #ece8dc;
    box-shadow: 0 28px 0 #ece8dc, 0 28px 0 1px #c9c2b1, 0 56px 0 #ece8dc, 0 56px 0 1px #c9c2b1;
}

.chat-math-display {
    display: block;
    min-width: max-content;
    color: #174a8b;
    font-size: 1.08em;
}

.chat-math-display .katex-display {
    margin: 0;
    text-align: left;
}

.chat-math-display .katex-display > .katex {
    color: #174a8b;
    filter: contrast(1.04);
    opacity: 0.96;
    text-align: left;
    text-shadow: 0.18px 0 rgba(19, 61, 119, 0.48);
    transform: rotate(-0.28deg);
    transform-origin: left center;
}

.chat-math-sheet .katex .mord,
.chat-math-sheet .katex .mopen,
.chat-math-sheet .katex .mclose,
.chat-math-sheet .katex .mrel,
.chat-math-sheet .katex .mbin,
.chat-math-sheet .katex .mpunct,
.chat-math-sheet .katex .minner,
.chat-math-sheet .katex .mathnormal {
    font-family: "Roleplay Ink", "Comic Sans MS", "Noto Sans KR Variable", cursive;
    font-style: normal;
    font-weight: 400;
}

.chat-scene-image {
    width: min(100%, 760px);
    margin: 0;
    display: grid;
    gap: 8px;
}

.chat-scene-image img {
    display: block;
    width: 100%;
    max-height: min(68vh, 760px);
    object-fit: contain;
    border-radius: 16px;
    border: 1px solid rgba(168, 85, 247, .28);
    background: #0b0910;
    box-shadow: 0 18px 50px rgba(0, 0, 0, .22);
}

.chat-scene-video video {
    display: block;
    width: 100%;
    max-height: min(68vh, 760px);
    border-radius: 16px;
    border: 1px solid rgba(168, 85, 247, .28);
    background: #050507;
    box-shadow: 0 18px 50px rgba(0, 0, 0, .22);
}

.media-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 14px;
}

.media-gallery-card {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: rgba(255,255,255,.025);
}

.media-gallery-card img,
.media-gallery-card video {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 10;
    object-fit: cover;
    background: #07070b;
}

.media-gallery-card-body { padding: 12px; display: grid; gap: 8px; }
.media-gallery-card-body strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-gallery-card-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.media-gallery-card-actions > * { flex: 1 1 auto; text-align: center; }

@media (max-width: 760px) {
    .media-gallery-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
}

@media (max-width: 430px) {
    .media-gallery-grid { grid-template-columns: 1fr; }
}

.chat-scene-image figcaption {
    color: var(--muted, #9e9aa8);
    font-size: .78rem;
}

.chat-math-fallback {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", "Noto Sans KR Variable", monospace;
    white-space: pre-wrap;
}

.v2-chat-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: end;
    padding: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
    background: rgba(18, 18, 26, 0.98);
}

.v2-chat-form textarea {
    min-height: 48px;
    max-height: 160px;
    resize: none;
    padding: 13px 14px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    background: #1a1a24;
    color: #fff;
    font: inherit;
    line-height: 1.45;
    outline: none;
}

.v2-chat-form textarea:focus {
    border-color: rgba(139, 92, 246, 0.68);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.12);
}

.chat-send-button {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 15px;
    background: linear-gradient(135deg, #8b5cf6, #6366f1);
    color: #fff;
    cursor: pointer;
    font-size: 1.15rem;
    font-weight: 800;
}

.chat-send-button:disabled,
.v2-chat-form textarea:disabled {
    cursor: wait;
    opacity: 0.58;
}

@media (max-width: 760px) {
    .story-grid {
        grid-template-columns: 1fr;
    }

    .modal-layer {
        place-items: end center;
        padding: 0;
    }

    .v2-modal {
        width: 100%;
        max-height: 91dvh;
        border-radius: 24px 24px 0 0;
        padding-bottom: calc(22px + env(safe-area-inset-bottom));
    }

    .chat-page {
        position: fixed;
        z-index: 1200;
        top: var(--chat-visual-top, 0px);
        right: 0;
        bottom: auto;
        left: 0;
        width: 100%;
        height: var(--chat-visual-height, 100dvh);
        min-height: 0;
        padding: 0;
        background: #0a0a0f;
    }

    .chat-page:not(.is-active) {
        display: none;
    }

    .chat-shell {
        border: 0;
        border-radius: 0;
    }

    .chat-header {
        padding-top: calc(10px + env(safe-area-inset-top));
    }

    .chat-messages {
        padding: 16px 10px;
    }

    .v2-message-bubble {
        max-width: 92%;
    }

    .v2-chat-form {
        padding-bottom: calc(10px + env(safe-area-inset-bottom));
    }

    .chat-math-sheet {
        width: 100%;
        margin: 13px 0;
        padding: 17px 16px 16px 41px;
        border-radius: 11px;
    }

    .chat-math-sheet::before { left: 31px; }
    .chat-math-paper-hole { left: 10px; transform: scale(0.82); transform-origin: top left; }
    .chat-math-display { font-size: 1em; }
}

.chat-language-control select {
    width: auto;
    min-width: 74px;
    height: 38px;
    padding: 0 28px 0 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    background: #1a1a24;
    color: #fff;
    font-size: 0.76rem;
    font-weight: 750;
    cursor: pointer;
}


/* =========================================================
   PHASE 5: BOOKS, WHATSAPP IMPORT & PRECISE AGE FEEDBACK
========================================================= */

.books-heading {
    margin-bottom: 20px;
}

.book-member-gate {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 18px;
    margin-bottom: 20px;
    padding: 20px;
    border: 1px solid rgba(168, 85, 247, 0.32);
    border-radius: 20px;
    background:
        radial-gradient(circle at 8% 20%, rgba(124, 58, 237, 0.22), transparent 34%),
        linear-gradient(135deg, rgba(20, 16, 32, 0.98), rgba(13, 15, 23, 0.96));
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.2);
}

.book-member-gate[hidden] {
    display: none;
}

.book-member-icon {
    display: grid;
    place-items: center;
    width: 54px;
    height: 54px;
    border-radius: 17px;
    color: #fff;
    background: linear-gradient(135deg, #7c3aed, #c026d3);
    box-shadow: 0 10px 30px rgba(124, 58, 237, 0.3);
    font-size: 1.45rem;
}

.book-member-copy h3 {
    margin: 3px 0 7px;
    font-size: 1.15rem;
}

.book-member-copy > p:not(.eyebrow) {
    margin: 0;
    color: var(--muted);
    line-height: 1.55;
    font-size: 0.88rem;
}

.book-member-features {
    display: flex;
    flex-wrap: wrap;
    gap: 7px 14px;
    margin-top: 10px;
    color: #d8d4e4;
    font-size: 0.8rem;
}

.book-member-features > span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.book-member-features i {
    color: #55e5a6;
    font-style: normal;
}

.book-member-cta {
    white-space: nowrap;
    text-decoration: none;
}

.book-member-only.is-member-locked {
    opacity: 0.48;
    filter: saturate(0.65);
}

.book-member-only.is-member-locked .settings-form {
    pointer-events: none;
}

.book-tools-grid {
    display: grid;
    grid-template-columns: minmax(0, 0.82fr) minmax(0, 1.18fr);
    gap: 20px;
    align-items: start;
}

.book-export-card,
.whatsapp-import-card {
    min-width: 0;
}

.book-export-card h3,
.whatsapp-import-card h3 {
    margin: 4px 0 0;
    font-size: clamp(1.35rem, 2.2vw, 1.85rem);
    letter-spacing: -0.035em;
}

.two-column-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.file-field input[type="file"] {
    padding: 10px;
    border-style: dashed;
}

.book-list-heading {
    margin-top: 34px;
}

.book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
    gap: 18px;
}

.book-card {
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: rgba(17, 17, 24, 0.9);
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.23);
}

.book-card-media {
    position: relative;
    height: 150px;
    overflow: hidden;
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.28), rgba(35, 35, 48, 0.8));
}

.book-card-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: saturate(0.9) brightness(0.72);
}

.book-card-media img.is-book-cover {
    object-position: center 32%;
    filter: saturate(0.92) brightness(0.8);
}

.book-card-media::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(12, 12, 18, 0.9), transparent 70%);
}

.book-card-media .story-language-badge {
    position: absolute;
    z-index: 2;
    top: 12px;
    right: 12px;
}

.book-card-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 215px;
    padding: 18px;
}

.book-card-body h3 {
    margin: 0;
    font-size: 1.08rem;
    line-height: 1.3;
}

.book-story-name,
.book-processing-text,
.book-error-text {
    margin: 0;
    color: var(--muted);
    line-height: 1.55;
    font-size: 0.86rem;
}

.book-error-text {
    color: #ff9ca8;
}

.book-progress {
    display: grid;
    gap: 8px;
    padding: 11px 12px;
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 13px;
    background: rgba(124, 58, 237, 0.07);
}

.book-progress-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: var(--muted);
    font-size: 0.8rem;
}

.book-progress-header span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.book-progress-header strong {
    flex: 0 0 auto;
    color: #e9ddff;
    font-variant-numeric: tabular-nums;
}

.book-progress-track {
    height: 8px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
}

.book-progress-fill {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #7c3aed, #a855f7 55%, #22d3ee);
    box-shadow: 0 0 14px rgba(168, 85, 247, 0.36);
    transition: width 0.45s ease;
}

.book-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    color: var(--muted);
    font-size: 0.75rem;
}

.book-status {
    display: inline-flex;
    align-items: center;
    min-height: 25px;
    padding: 0 9px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
}

.book-status.is-ready {
    background: rgba(57, 217, 138, 0.11);
    color: #a0f2c9;
}

.book-status.is-processing {
    background: rgba(255, 184, 77, 0.11);
    color: #ffd28c;
}

.book-status.is-failed {
    background: rgba(255, 107, 122, 0.11);
    color: #ffadb7;
}

.book-download {
    width: 100%;
    margin-top: auto;
    text-align: center;
    text-decoration: none;
}

.book-card-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
    margin-top: auto;
}

.book-card-actions > * {
    width: 100%;
    min-width: 0;
    margin: 0;
    text-align: center;
}

.book-error-text.is-warning {
    color: #ffd28c;
}

.book-manuscript-modal-card {
    width: min(940px, 100%);
}

.book-manuscript-intro {
    margin: -8px 0 16px;
    color: var(--muted);
    line-height: 1.6;
}

.book-manuscript-rule {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 13px;
    margin-bottom: 18px;
    padding: 14px;
    border: 1px solid rgba(168, 85, 247, 0.24);
    border-radius: 16px;
    background: rgba(124, 58, 237, 0.08);
}

.book-manuscript-rule > span {
    color: #c084fc;
    font-size: 1.35rem;
}

.book-manuscript-rule p,
.book-manuscript-rule strong,
.book-manuscript-rule small {
    display: block;
    margin: 0;
}

.book-manuscript-rule small {
    margin-top: 3px;
    color: var(--muted);
    line-height: 1.5;
}

.book-manuscript-summary {
    display: grid;
    grid-template-columns: 132px minmax(0, 1fr);
    gap: 18px;
    align-items: center;
    margin-bottom: 22px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.025);
}

.book-manuscript-cover,
.book-manuscript-cover img,
.book-manuscript-cover .character-image-fallback {
    width: 132px;
    height: 166px;
    border-radius: 12px;
}

.book-manuscript-cover {
    overflow: hidden;
    background: rgba(124, 58, 237, 0.12);
}

.book-manuscript-cover img {
    display: block;
    object-fit: cover;
}

.book-manuscript-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.book-manuscript-section-heading,
.book-manuscript-chapter-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.book-manuscript-section-heading {
    margin: 18px 0 12px;
}

.book-manuscript-section-heading h3,
.book-manuscript-section-heading p {
    margin: 0;
}

.book-manuscript-chapter-list {
    display: grid;
    gap: 14px;
}

.book-manuscript-chapter {
    display: grid;
    gap: 11px;
    padding: 16px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 17px;
    background: rgba(255, 255, 255, 0.025);
}

.book-manuscript-chapter-number span,
.book-manuscript-chapter-number small {
    display: block;
}

.book-manuscript-chapter-number small {
    margin-top: 3px;
    color: var(--muted);
    font-size: 0.75rem;
}

.book-manuscript-order-controls {
    display: flex;
    gap: 7px;
}

.book-manuscript-chapter > input {
    font-family: Georgia, 'Times New Roman', "Noto Sans KR Variable", serif;
    font-size: 1.04rem;
    font-weight: 700;
}

.book-manuscript-chapter > textarea {
    min-height: 230px;
    resize: vertical;
    font-family: Georgia, 'Times New Roman', "Noto Sans KR Variable", serif;
    font-size: 1rem;
    line-height: 1.65;
}

.book-manuscript-chapter-visual {
    display: grid;
    grid-template-columns: 76px minmax(0, 1fr);
    gap: 11px;
    align-items: center;
    color: var(--muted);
}

.book-manuscript-chapter-visual img {
    width: 76px;
    height: 76px;
    border-radius: 10px;
    object-fit: cover;
}

.book-manuscript-actions {
    position: sticky;
    bottom: -22px;
    z-index: 2;
    padding: 14px 0 2px;
    background: linear-gradient(to top, #12121a 78%, transparent);
}

.story-age-notice {
    margin: -4px 0 18px;
    padding: 11px 13px;
    border: 1px solid rgba(57, 217, 138, 0.2);
    border-radius: 12px;
    background: rgba(57, 217, 138, 0.07);
    color: #b8f7d7;
    font-size: 0.79rem;
    line-height: 1.45;
}

.story-age-notice:empty {
    display: none;
}

.story-age-notice.is-error {
    border-color: rgba(255, 107, 122, 0.3);
    background: rgba(255, 107, 122, 0.08);
    color: #ffadb7;
}

@media (max-width: 1040px) {
    .book-tools-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 620px) {
    .book-member-gate {
        grid-template-columns: auto minmax(0, 1fr);
        align-items: start;
        padding: 17px;
    }

    .book-member-cta {
        grid-column: 1 / -1;
        width: 100%;
        text-align: center;
    }

    .two-column-fields,
    .book-grid {
        grid-template-columns: 1fr;
    }

    .book-tools-grid {
        gap: 14px;
    }

    .book-card-body {
        min-height: 0;
    }

    .book-card-actions,
    .book-manuscript-summary {
        grid-template-columns: 1fr;
    }

    .book-manuscript-cover,
    .book-manuscript-cover img,
    .book-manuscript-cover .character-image-fallback {
        width: 104px;
        height: 132px;
    }

    .book-manuscript-actions {
        display: grid;
        grid-template-columns: 1fr;
    }

    .bottom-nav-item small {
        font-size: 0.61rem;
    }
}


/* =========================================================
   PHASE 6: MESSAGE ACTIONS
========================================================= */
.chat-notice {
    margin: 10px 16px 0;
    padding: 10px 12px;
    border: 1px solid rgba(139, 92, 246, 0.28);
    border-radius: 12px;
    background: rgba(76, 29, 149, 0.2);
    color: #ddd8ff;
    font-size: 0.82rem;
}

.chat-notice.is-error {
    border-color: rgba(248, 113, 113, 0.35);
    background: rgba(127, 29, 29, 0.24);
    color: #fecaca;
}

.v2-message-meta {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 0 5px;
}

.v2-message.is-user .v2-message-meta {
    justify-content: flex-end;
}

.v2-message-edited {
    color: #8d8a98;
    font-size: 0.65rem;
}

.v2-message-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    max-width: min(760px, 86%);
    opacity: 0;
    transform: translateY(-2px);
    transition: opacity 0.16s ease, transform 0.16s ease;
}

.v2-message:hover .v2-message-actions,
.v2-message:focus-within .v2-message-actions {
    opacity: 1;
    transform: translateY(0);
}

.message-action-button {
    min-width: 30px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 0 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    background: rgba(26, 26, 35, 0.92);
    color: #aaa7b7;
    cursor: pointer;
    font: inherit;
    font-size: 0.7rem;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.message-action-button:hover {
    border-color: rgba(139, 92, 246, 0.45);
    background: rgba(76, 29, 149, 0.34);
    color: #fff;
}

.message-action-button.is-danger:hover {
    border-color: rgba(248, 113, 113, 0.45);
    background: rgba(127, 29, 29, 0.3);
}

.message-action-button:disabled {
    cursor: wait;
    opacity: 0.42;
}

.message-variant-control {
    height: 28px;
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 0 3px;
    border: 1px solid rgba(192, 132, 252, 0.16);
    border-radius: 999px;
    background: rgba(76, 29, 149, 0.15);
}

.message-variant-button {
    width: 24px;
    height: 24px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #c4b5fd;
    cursor: pointer;
    font: inherit;
    font-size: 1rem;
    line-height: 1;
}

.message-variant-button:hover:not(:disabled) {
    background: rgba(139, 92, 246, 0.22);
    color: #fff;
}

.message-variant-button:disabled {
    cursor: default;
    opacity: 0.28;
}

.message-variant-counter {
    min-width: 34px;
    color: #aaa7b7;
    text-align: center;
    font-size: 0.68rem;
    font-variant-numeric: tabular-nums;
}

.chat-shell.is-action-busy .v2-chat-form,
.chat-shell.is-action-busy .v2-message-actions {
    pointer-events: none;
    opacity: 0.55;
}

.message-edit-modal {
    max-width: 660px;
}

.message-edit-modal textarea {
    min-height: 180px;
    resize: vertical;
}

@media (max-width: 760px) {
    .v2-message-actions {
        max-width: 92%;
        opacity: 1;
        transform: none;
    }

    .message-action-button {
        width: 32px;
        padding: 0;
    }

    .message-action-button .action-label {
        display: none;
    }

    .chat-notice {
        margin: 8px 10px 0;
    }
}

/* =========================================================
   PHASE 9: PERSONAS, FAVORITES & SCENARIO PICKER
========================================================= */
.filter-toggle,
.favorite-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-2);
    color: var(--muted);
    cursor: pointer;
    transition: 160ms ease;
}

.filter-toggle:hover,
.favorite-button:hover,
.filter-toggle[aria-pressed="true"],
.favorite-button[aria-pressed="true"] {
    border-color: rgba(155, 92, 255, 0.45);
    background: var(--accent-soft);
    color: #f1e7ff;
}

.favorite-button {
    width: 42px;
    min-width: 42px;
    padding: 0;
    font-size: 1.05rem;
}

.character-card-media > .favorite-button,
.scenario-card-media > .favorite-button {
    position: absolute;
    z-index: 5;
    top: 12px;
    right: 12px;
    border-color: rgba(255, 255, 255, 0.16);
    background: rgba(10, 10, 16, 0.72);
    backdrop-filter: blur(12px);
}

.scenario-grid,
.persona-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 18px;
}

.scenario-card,
.persona-card,
.choice-card {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(28, 28, 38, 0.98), rgba(17, 17, 24, 0.98));
    box-shadow: 0 14px 38px rgba(0, 0, 0, 0.18);
}

.scenario-card-media {
    position: relative;
    height: 156px;
    overflow: hidden;
    background: linear-gradient(135deg, rgba(155, 92, 255, 0.28), rgba(20, 20, 29, 0.94));
}

.scenario-card-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.scenario-card-media::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(12, 12, 18, 0.82), transparent 66%);
    pointer-events: none;
}

.scenario-card-body,
.persona-card-body {
    display: flex;
    flex-direction: column;
    gap: 11px;
    padding: 18px;
}

.scenario-card h3,
.persona-card h3 {
    margin: 0;
    font-size: 1.05rem;
}

.scenario-card p,
.persona-card p {
    margin: 0;
    color: var(--muted);
    line-height: 1.55;
    font-size: 0.84rem;
}

.scenario-card-meta,
.persona-card-meta,
.persona-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.scenario-card-meta span,
.persona-card-meta span {
    display: inline-flex;
    min-height: 25px;
    align-items: center;
    padding: 0 9px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.055);
    color: #c7c3d2;
    font-size: 0.72rem;
}

.scenario-card-actions,
.persona-card-actions {
    margin-top: auto;
}

.scenario-card-actions .primary-button,
.scenario-card-actions .secondary-button,
.persona-card-actions .primary-button,
.persona-card-actions .secondary-button,
.persona-card-actions .danger-button {
    flex: 1 1 auto;
}

.default-badge {
    display: inline-flex;
    width: fit-content;
    min-height: 25px;
    align-items: center;
    padding: 0 9px;
    border-radius: 999px;
    background: rgba(57, 217, 138, 0.11);
    color: #a0f2c9;
    font-size: 0.72rem;
    font-weight: 800;
}

.choice-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 10px;
    max-height: 300px;
    overflow: auto;
    padding: 2px;
}

.choice-card-grid.compact {
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    max-height: 220px;
}

.choice-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 7px;
    min-height: 104px;
    padding: 14px;
    color: var(--text);
    text-align: left;
    cursor: pointer;
    transition: 150ms ease;
}

.choice-card:hover,
.choice-card.is-selected {
    border-color: rgba(155, 92, 255, 0.52);
    background: linear-gradient(180deg, rgba(91, 46, 151, 0.25), rgba(27, 22, 39, 0.98));
}

.choice-card.is-selected::after {
    content: "✓";
    position: absolute;
    top: 10px;
    right: 11px;
    display: grid;
    width: 24px;
    height: 24px;
    place-items: center;
    border-radius: 999px;
    background: var(--accent-strong);
    color: white;
    font-size: 0.72rem;
    font-weight: 900;
}

.choice-card strong {
    padding-right: 24px;
    font-size: 0.9rem;
}

.choice-card small {
    color: var(--muted);
    line-height: 1.35;
}

.choice-card .choice-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: auto;
}

.choice-card .choice-meta span {
    padding: 3px 7px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.055);
    color: #c7c3d2;
    font-size: 0.66rem;
}

.persona-modal {
    max-width: 760px;
}

.persona-modal textarea {
    resize: vertical;
}

.check-field {
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.025);
    color: var(--muted);
}

.check-field input {
    width: 18px;
    height: 18px;
}

.story-scenario-name {
    color: #c7a9ff;
}

@media (max-width: 760px) {
    .filter-toggle {
        min-width: 42px;
        padding: 0 11px;
    }

    .filter-toggle span:last-child {
        display: none;
    }

    .scenario-grid,
    .persona-grid,
    .choice-card-grid,
    .choice-card-grid.compact {
        grid-template-columns: 1fr;
    }

    .choice-card-grid {
        max-height: 260px;
    }

    .mobile-bottom-nav {
        overflow: hidden;
    }

    .bottom-nav-item {
        min-width: 0;
    }
}

/* =========================================================
   PHASE 10: STORY SETTINGS, ARCHIVE & DETAILS
========================================================= */
.heading-actions,
.chat-header-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.story-card.is-archived {
    opacity: 0.86;
    border-style: dashed;
}

.story-card.is-archived .story-card-media img {
    filter: saturate(0.55) brightness(0.78);
}

.story-status-badge {
    position: absolute;
    z-index: 4;
    left: 12px;
    top: 12px;
    display: inline-flex;
    min-height: 27px;
    align-items: center;
    padding: 0 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    background: rgba(12, 12, 18, 0.78);
    color: #e5d9ff;
    font-size: 0.7rem;
    font-weight: 800;
    backdrop-filter: blur(10px);
}

.story-card-actions {
    gap: 8px;
}

.story-card-actions .icon-button {
    flex: 0 0 42px;
}

.story-details-panel {
    position: relative;
    z-index: 3;
    margin: 0 16px 12px;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(27, 27, 38, 0.98), rgba(17, 17, 24, 0.98));
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.26);
}

.story-details-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.story-details-header h3,
.story-details-header p {
    margin: 0;
}

.story-details-content {
    display: grid;
    gap: 18px;
}

.story-details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
}

.story-detail-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-height: 74px;
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 13px;
    background: rgba(255, 255, 255, 0.025);
}

.story-detail-item span {
    color: var(--muted);
    font-size: 0.7rem;
}

.story-detail-item strong {
    overflow-wrap: anywhere;
    font-size: 0.86rem;
}

.story-detail-books {
    display: grid;
    gap: 10px;
}

.story-detail-books-header,
.story-detail-book,
.story-detail-export {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.story-detail-books-header h4,
.story-detail-book p {
    margin: 0;
}

.story-detail-book {
    padding: 11px 12px;
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.025);
}

.story-detail-book-copy {
    display: grid;
    gap: 3px;
}

.story-detail-book-copy small {
    color: var(--muted);
}

.story-detail-book-status {
    display: inline-flex;
    min-height: 25px;
    align-items: center;
    padding: 0 9px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    font-size: 0.68rem;
    font-weight: 800;
}

.story-detail-book-status.is-ready {
    background: rgba(57, 217, 138, 0.12);
    color: #9df2c7;
}

.story-detail-book-status.is-failed {
    background: rgba(255, 92, 120, 0.12);
    color: #ffb1bf;
}

.story-detail-export {
    justify-content: flex-start;
    padding-top: 4px;
}

.story-detail-export select {
    min-width: 150px;
}

.chat-archive-notice[hidden] {
    display: none !important;
}

.chat-archive-notice {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    margin: 0 16px 12px;
    padding: 12px 14px;
    border: 1px solid rgba(214, 168, 76, 0.32);
    border-radius: 14px;
    background: rgba(214, 168, 76, 0.08);
    color: #f1dfb8;
}

.chat-archive-notice span {
    flex: 1 1 360px;
    color: #d8cba9;
    font-size: 0.8rem;
}

.chat-shell.is-archived .v2-chat-form {
    opacity: 0.58;
}

.story-settings-modal {
    max-width: 780px;
}

.story-archive-check {
    min-height: 100%;
}

.settings-warning {
    display: block;
    padding: 11px 12px;
    border-radius: 12px;
    background: rgba(155, 92, 255, 0.08);
    color: var(--muted);
    line-height: 1.5;
}

@media (max-width: 760px) {
    .heading-actions {
        width: 100%;
    }

    .heading-actions > * {
        flex: 1 1 auto;
    }

    .chat-header-actions {
        order: 4;
        margin-left: auto;
    }

    .story-details-panel,
    .chat-archive-notice {
        margin-inline: 8px;
    }

    .story-details-grid {
        grid-template-columns: 1fr 1fr;
    }

    .story-detail-export {
        align-items: stretch;
    }

    .story-detail-export select,
    .story-detail-export button {
        flex: 1 1 100%;
    }
}

/* =========================================================
   PHASE 11: STORY MEMORY & CONTEXT
========================================================= */
.story-knowledge-modal {
    width: min(980px, calc(100vw - 32px));
    max-height: min(900px, calc(100vh - 32px));
    overflow: auto;
}

.story-knowledge-content {
    display: grid;
    gap: 20px;
}

.story-knowledge-content[hidden],
#storyKnowledgeLoading[hidden] {
    display: none !important;
}

.compact-loading {
    min-height: 180px;
}

.knowledge-summary-card,
.knowledge-memory-section {
    border: 1px solid var(--border-color, rgba(255,255,255,.09));
    border-radius: 20px;
    padding: 18px;
    background: var(--surface-soft, rgba(255,255,255,.025));
}

.knowledge-section-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.knowledge-section-heading h3 {
    margin: 3px 0 0;
}

.knowledge-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}

.knowledge-stat {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    padding: 12px;
    border-radius: 14px;
    background: rgba(255,255,255,.045);
}

.knowledge-stat strong {
    font-size: 1.1rem;
}

.knowledge-stat small {
    color: var(--muted-text, #9ca3af);
    line-height: 1.25;
}

.knowledge-summary-content {
    max-height: 320px;
    overflow: auto;
    padding: 16px;
    border-radius: 14px;
    background: rgba(0,0,0,.18);
    white-space: pre-wrap;
    line-height: 1.62;
}

.knowledge-summary-content p {
    margin: 0;
}

.knowledge-empty-text {
    color: var(--muted-text, #9ca3af);
}

.memory-create-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 120px 130px auto;
    gap: 12px;
    align-items: end;
    margin-bottom: 16px;
}

.memory-content-field textarea {
    min-height: 92px;
}

.memory-pin-field {
    min-height: 48px;
    align-self: end;
}

.memory-form-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    align-self: end;
    min-height: 48px;
}

.story-memory-list {
    display: grid;
    gap: 10px;
}

.story-memory-card {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    padding: 14px;
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 16px;
    background: rgba(255,255,255,.025);
}

.story-memory-card.is-pinned {
    border-color: color-mix(in srgb, var(--accent, #8b5cf6) 42%, transparent);
    background: color-mix(in srgb, var(--accent, #8b5cf6) 8%, transparent);
}

.story-memory-body {
    min-width: 0;
}

.story-memory-body p {
    margin: 8px 0 0;
    white-space: pre-wrap;
    line-height: 1.5;
}

.story-memory-meta,
.story-memory-actions {
    display: flex;
    gap: 7px;
    align-items: center;
    flex-wrap: wrap;
}

.story-memory-actions {
    flex: 0 0 auto;
}

.danger-icon {
    color: var(--danger, #ef4444);
}

.compact-empty {
    min-height: auto;
    padding: 22px;
}

@media (max-width: 840px) {
    .knowledge-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .memory-create-form {
        grid-template-columns: 1fr 1fr;
    }

    .memory-content-field {
        grid-column: 1 / -1;
    }

    .memory-form-actions {
        justify-content: flex-end;
    }
}

@media (max-width: 560px) {
    .story-knowledge-modal {
        width: 100%;
        max-height: 100dvh;
        min-height: 100dvh;
        border-radius: 0;
    }

    .knowledge-section-heading,
    .story-memory-card {
        flex-direction: column;
    }

    .story-memory-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .memory-create-form {
        grid-template-columns: 1fr;
    }

    .memory-content-field {
        grid-column: auto;
    }
}

/* Storyraum 3.0: registered multi-player stories and orderly hand queue. */
.chat-collaboration-bar {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 10px clamp(16px, 4vw, 54px);
    border-bottom: 1px solid rgba(192, 132, 252, 0.18);
    background: linear-gradient(90deg, rgba(92, 44, 142, 0.23), rgba(15, 15, 23, 0.94));
}

.chat-collaboration-bar[hidden] { display: none; }

.collaboration-bar-main { min-width: 0; }
.collaboration-bar-main p { margin: 5px 0 0; color: #c8c1d3; font-size: .8rem; }
.collaboration-participants { display: flex; flex-wrap: wrap; gap: 6px; }
.collaboration-persona-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 25px;
    padding: 3px 9px;
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 999px;
    background: rgba(255,255,255,.045);
    color: #cfc8d9;
    font-size: .72rem;
    font-weight: 750;
}
.collaboration-persona-chip.is-active { border-color: rgba(192,132,252,.72); background: rgba(126,34,206,.24); color: #f2e8ff; }
.collaboration-persona-chip.is-me::before { content: "•"; color: #9ef2c2; }
.collaboration-hand-button { flex: 0 0 auto; min-width: 132px; }
.collaboration-hand-button.is-lowered { background: rgba(255,255,255,.08); color: #e1dae9; }

.collaboration-modal { z-index: 6500; }
.collaboration-invite-modal { z-index: 6600; }
.collaboration-modal-card { width: min(720px, 100%); }
.collaboration-intro { margin: -4px 0 18px; color: var(--muted); line-height: 1.55; }
.collaboration-section {
    margin-top: 15px;
    padding: 15px;
    border: 1px solid rgba(255,255,255,.085);
    border-radius: 17px;
    background: rgba(255,255,255,.025);
}
.collaboration-section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.collaboration-section-heading h3 { margin: 0; font-size: .96rem; }
.collaboration-toggle { padding: 13px; }
.collaboration-invite-actions,.collaboration-footer { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 12px; }
.collaboration-invite-result { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px; align-items: end; margin-top: 12px; }
.collaboration-invite-result small { grid-column: 1 / -1; color: var(--muted); }
.collaboration-participant-list,.collaboration-queue-list { display: grid; gap: 8px; }
.collaboration-list-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 44px;
    padding: 9px 11px;
    border-radius: 13px;
    background: rgba(255,255,255,.04);
}
.collaboration-list-copy { min-width: 0; }
.collaboration-list-copy strong,.collaboration-list-copy small { display: block; }
.collaboration-list-copy small { margin-top: 3px; color: var(--muted); }
.collaboration-list-row.is-active { outline: 1px solid rgba(192,132,252,.55); background: rgba(126,34,206,.16); }
.collaboration-empty { margin: 4px 0; color: var(--muted); font-size: .85rem; }
.collaboration-footer { justify-content: flex-end; }
.collaboration-footer .danger-button { margin-right: auto; }
#collaborationInvitePreview { padding: 15px; border-radius: 16px; background: rgba(192,132,252,.08); }
#collaborationInvitePreview h3,#collaborationInvitePreview p { margin: 0; }
#collaborationInvitePreview p { margin-top: 7px; color: var(--muted); }
.v2-message.is-user .v2-message-speaker { color: #9ee4c1; text-align: right; }
.story-shared-badge { display: inline-flex; align-items: center; gap: 4px; }

/* Storyraum 3.0: non-destructive checkpoints and alternative timelines. */
.timeline-modal { z-index: 6550; }
.timeline-modal-card { width: min(820px, 100%); }
.timeline-intro { margin: -4px 0 18px; color: var(--muted); line-height: 1.55; }
.timeline-busy-notice {
    margin: 0 0 14px;
    padding: 11px 13px;
    border: 1px solid rgba(245,158,11,.35);
    border-radius: 13px;
    background: rgba(120,53,15,.18);
    color: #fde5ad;
    font-size: .84rem;
    line-height: 1.45;
}
.timeline-create-section,.timeline-list-section {
    margin-top: 15px;
    padding: 15px;
    border: 1px solid rgba(255,255,255,.085);
    border-radius: 17px;
    background: rgba(255,255,255,.025);
}
.timeline-section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.timeline-section-heading .eyebrow { margin-bottom: 4px; }
.timeline-section-heading h3 { margin: 0; font-size: 1rem; }
.timeline-checkpoint-form { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1.25fr) auto; gap: 10px; align-items: end; }
.timeline-checkpoint-form textarea { min-height: 46px; resize: vertical; }
.timeline-checkpoint-form .primary-button { min-height: 46px; }
.timeline-branch-list { display: grid; gap: 12px; }
.timeline-branch-card {
    overflow: hidden;
    border: 1px solid rgba(255,255,255,.09);
    border-radius: 15px;
    background: rgba(8,8,14,.46);
}
.timeline-branch-card.is-current { border-color: rgba(168,85,247,.56); box-shadow: inset 3px 0 0 #a855f7; }
.timeline-branch-card.is-canon { background: linear-gradient(135deg,rgba(126,34,206,.12),rgba(8,8,14,.5)); }
.timeline-branch-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px; }
.timeline-branch-copy { min-width: 0; }
.timeline-branch-title-row { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.timeline-branch-title-row h4 { margin: 0; font-size: .98rem; overflow-wrap: anywhere; }
.timeline-branch-copy > small { display: block; margin-top: 5px; color: var(--muted); }
.timeline-current-pill { border-color: rgba(168,85,247,.45); color: #ead8ff; }
.timeline-canon-pill { border-color: rgba(250,204,21,.38); color: #fde68a; }
.timeline-branch-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 7px; }
.timeline-small-icon { width: 36px; height: 36px; min-width: 36px; }
.timeline-checkpoint-list { display: grid; gap: 1px; border-top: 1px solid rgba(255,255,255,.075); }
.timeline-checkpoint-row {
    display: grid;
    grid-template-columns: 22px minmax(0,1fr) auto;
    gap: 10px;
    align-items: start;
    padding: 12px 13px;
    border-bottom: 1px solid rgba(255,255,255,.06);
}
.timeline-checkpoint-row:last-child { border-bottom: 0; }
.timeline-checkpoint-marker { padding-top: 2px; color: #c084fc; font-size: .72rem; }
.timeline-checkpoint-copy { min-width: 0; }
.timeline-checkpoint-copy strong,.timeline-checkpoint-copy small { display: block; }
.timeline-checkpoint-copy small { margin-top: 3px; color: var(--muted); }
.timeline-checkpoint-copy p { margin: 7px 0 0; color: #d8d0e2; font-size: .84rem; }
.timeline-checkpoint-copy blockquote {
    margin: 8px 0 0;
    padding: 8px 10px;
    border-left: 2px solid rgba(192,132,252,.5);
    border-radius: 0 9px 9px 0;
    background: rgba(255,255,255,.035);
    color: #aaa2b6;
    font-size: .78rem;
    line-height: 1.45;
}
.timeline-empty { margin: 0; padding: 12px 13px; color: var(--muted); font-size: .84rem; }
.timeline-footer { justify-content: flex-end; }
.story-timeline-badge { display: inline-flex; align-items: center; gap: 4px; color: #ddc5ff; }

@media (max-width: 680px) {
    .chat-collaboration-bar { align-items: stretch; flex-direction: column; padding: 9px 13px; }
    .collaboration-hand-button { width: 100%; }
    .collaboration-invite-result { grid-template-columns: 1fr; }
    .collaboration-invite-result small { grid-column: auto; }
    .collaboration-modal,.collaboration-invite-modal { padding: 0; }
    .collaboration-modal-card { width: 100%; max-height: 100dvh; min-height: 100dvh; border-radius: 0; padding: 18px 15px calc(22px + env(safe-area-inset-bottom)); }
    .timeline-modal { padding: 0; }
    .timeline-modal-card { width: 100%; max-height: 100dvh; min-height: 100dvh; border-radius: 0; padding: 18px 15px calc(22px + env(safe-area-inset-bottom)); }
    .timeline-checkpoint-form { grid-template-columns: 1fr; }
    .timeline-branch-header { align-items: flex-start; flex-direction: column; }
    .timeline-branch-actions { width: 100%; justify-content: flex-start; }
    .timeline-checkpoint-row { grid-template-columns: 18px minmax(0,1fr); }
    .timeline-checkpoint-row > button { grid-column: 2; width: 100%; }
}

/* =========================================================
   PHASE 18: ACCOUNT SELF-SERVICE
========================================================= */
.account-page-notice{margin-bottom:18px}.account-dashboard-grid,.account-settings-columns{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:18px;margin-bottom:18px}.account-identity-card,.account-plan-card{min-height:100%}.account-fact-list{display:grid;gap:10px;margin:18px 0}.account-fact-list>div{display:flex;justify-content:space-between;gap:16px;padding:11px 0;border-bottom:1px solid rgba(255,255,255,.08)}.account-fact-list span{color:var(--muted,#a9a5b3)}.account-fact-list strong{text-align:right;overflow-wrap:anywhere}.quota-self-grid{display:grid;gap:16px;margin-top:18px}.quota-self-item{display:grid;gap:8px}.quota-self-item>div{display:flex;justify-content:space-between;gap:14px}.quota-self-item>div span{color:var(--muted,#a9a5b3)}.quota-progress{height:9px;border-radius:999px;background:rgba(255,255,255,.08);overflow:hidden}.quota-progress i{display:block;height:100%;width:0;border-radius:inherit;background:linear-gradient(90deg,#8b5cf6,#ec4899);transition:width .3s ease}.quota-progress i.is-warning{background:linear-gradient(90deg,#f59e0b,#f97316)}.quota-progress i.is-blocked{background:linear-gradient(90deg,#ef4444,#dc2626)}.policy-inline-card{display:flex;align-items:center;gap:20px;margin-top:20px;padding:16px;border:1px solid rgba(255,255,255,.09);border-radius:16px;background:rgba(255,255,255,.025)}.policy-inline-card .age-display{min-width:92px}.policy-inline-card p{margin:2px 0}.account-danger-card{border-color:rgba(239,68,68,.35);background:linear-gradient(145deg,rgba(127,29,29,.12),rgba(18,16,25,.92));margin-bottom:24px}.danger-button{background:linear-gradient(135deg,#dc2626,#991b1b)!important}.danger-form{max-width:820px}.account-plan-card .pill{white-space:nowrap}.account-settings-columns .settings-card{min-width:0}.account-settings-columns textarea{resize:vertical}.notice-card button{margin-top:10px}
@media(max-width:980px){.account-dashboard-grid,.account-settings-columns{grid-template-columns:1fr}}@media(max-width:640px){.account-fact-list>div,.quota-self-item>div{display:grid;gap:4px}.account-fact-list strong,.quota-self-item strong{text-align:left}.policy-inline-card{align-items:flex-start;flex-direction:column}.account-plan-card .settings-card-header{align-items:flex-start;flex-direction:column}}
@media(max-width:640px){.billing-plan-grid,.payment-method-grid{grid-template-columns:1fr}.billing-plan-description{min-height:0}.wallet-breakdown{grid-template-columns:1fr}.billing-plan-card{padding:16px}}
@media(max-width:640px){.billing-history-row{align-items:flex-start}.billing-history-row>div:last-child{min-width:96px}}
.sepa-payment-card{width:min(860px,calc(100vw - 32px));max-height:min(860px,calc(100vh - 32px));overflow:auto}.sepa-payment-layout{display:grid;grid-template-columns:minmax(220px,300px) minmax(0,1fr);gap:22px;align-items:start;margin:20px 0}.sepa-qr-panel{display:grid;justify-items:center;gap:9px;padding:16px;border:1px solid var(--border);border-radius:16px;background:#fff;color:#111}.sepa-qr-panel small{color:#555;text-align:center}.sepa-payment-qr{width:min(260px,100%);aspect-ratio:1;display:grid;place-items:center}.sepa-payment-qr svg{display:block;width:100%;height:auto}.sepa-payment-details{display:grid;gap:0;margin:0;border:1px solid var(--border);border-radius:16px;overflow:hidden}.sepa-payment-details>div{display:grid;grid-template-columns:minmax(120px,.7fr) minmax(0,1.3fr);gap:14px;padding:12px 14px;border-bottom:1px solid var(--border);background:var(--surface-2)}.sepa-payment-details>div:last-child{border-bottom:0}.sepa-payment-details dt{color:var(--muted)}.sepa-payment-details dd{margin:0;font-weight:700;overflow-wrap:anywhere}.sepa-reference-row dd{color:#c4b5fd;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,"Noto Sans KR Variable",monospace;font-size:1.05rem;letter-spacing:.02em}.topup-package .secondary-button:not(:disabled){background:linear-gradient(135deg,#7c3aed,#9333ea);border-color:rgba(167,139,250,.55);color:#fff}.payment-method-item.is-available{border-color:rgba(52,211,153,.35)}.payment-method-item.is-available .payment-method-status{color:#34d399!important}
@media(max-width:700px){.sepa-payment-layout{grid-template-columns:1fr}.sepa-qr-panel{width:100%;max-width:340px;margin:0 auto}.sepa-payment-details>div{grid-template-columns:1fr;gap:4px}.sepa-payment-card{width:min(100vw - 18px,860px);max-height:calc(100vh - 18px)}}

/* Step 59: compact account information architecture */
.account-settings-group{margin:0 0 14px;border:1px solid rgba(255,255,255,.085);border-radius:18px;background:rgba(255,255,255,.018);overflow:hidden;transition:border-color .18s ease,background .18s ease}
.account-settings-group[open]{border-color:rgba(168,85,247,.28);background:rgba(126,34,206,.035)}
.account-settings-group-summary{display:grid;grid-template-columns:42px minmax(0,1fr) 22px;align-items:center;gap:14px;padding:17px 19px;cursor:pointer;list-style:none;user-select:none}
.account-settings-group-summary::-webkit-details-marker{display:none}
.account-settings-group-summary:hover{background:rgba(255,255,255,.025)}
.account-settings-group-summary::after{content:'›';justify-self:end;color:#8d8797;font-size:26px;line-height:1;transition:transform .18s ease,color .18s ease}
.account-settings-group[open]>.account-settings-group-summary::after{transform:rotate(90deg);color:#c084fc}
.account-settings-group-icon{display:grid;place-items:center;width:42px;height:42px;border-radius:13px;background:linear-gradient(145deg,rgba(168,85,247,.18),rgba(124,58,237,.07));color:#d8b4fe;font-weight:750;border:1px solid rgba(192,132,252,.13)}
.account-settings-group-summary>span:nth-child(2){display:grid;gap:3px;min-width:0}
.account-settings-group-summary strong{font-size:1rem;color:#f3eff8}
.account-settings-group-summary small{color:var(--muted,#a9a5b3);font-size:.82rem;font-weight:400;line-height:1.35}
.account-settings-group-body{padding:4px 16px 16px}
.account-settings-group-body>.settings-card{margin-bottom:18px}
.account-settings-group-body>.settings-card:last-child,.account-settings-group-body>.account-settings-columns:last-child{margin-bottom:0}
.account-settings-group-body .account-billing-catalogue{margin-top:0}
.account-settings-group-danger{border-color:rgba(248,113,113,.12)}
.account-settings-group-danger[open]{border-color:rgba(248,113,113,.25);background:rgba(127,29,29,.035)}
.account-settings-group-danger .account-settings-group-icon{background:rgba(127,29,29,.16);border-color:rgba(248,113,113,.15);color:#fca5a5}
.account-settings-group-danger .account-danger-card{margin-bottom:0}
@media(max-width:640px){.account-settings-group-summary{grid-template-columns:38px minmax(0,1fr) 18px;gap:11px;padding:14px}.account-settings-group-icon{width:38px;height:38px}.account-settings-group-summary small{font-size:.76rem}.account-settings-group-body{padding:2px 10px 12px}.account-settings-group-body .settings-card{padding:16px}}

/* Step 60: second-level navigation inside profile & security */
.account-profile-subnav{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:7px;margin:4px 0 16px;padding:6px;border:1px solid rgba(255,255,255,.07);border-radius:14px;background:rgba(5,5,8,.38)}
.account-profile-tab{min-width:0;padding:10px 12px;border:1px solid transparent;border-radius:10px;background:transparent;color:#9f9aa8;font:inherit;font-size:.82rem;font-weight:650;line-height:1.25;cursor:pointer;transition:background .16s ease,border-color .16s ease,color .16s ease}
.account-profile-tab:hover{color:#f3eff8;background:rgba(255,255,255,.035)}
.account-profile-tab.is-active{color:#f4e8ff;border-color:rgba(192,132,252,.23);background:linear-gradient(135deg,rgba(126,34,206,.23),rgba(91,33,182,.1));box-shadow:inset 0 0 0 1px rgba(168,85,247,.04)}
.account-profile-tab:focus-visible{outline:2px solid #a855f7;outline-offset:2px}
.account-profile-panel[hidden]{display:none!important}
.account-profile-panel>.account-settings-columns{margin-bottom:0}
.account-profile-panel>.settings-card:last-child{margin-bottom:0}
.account-profile-panel>.account-topup-card:first-child{margin-top:0}
.account-profile-subnav-three{grid-template-columns:repeat(3,minmax(0,1fr))}
.account-profile-subnav-two{grid-template-columns:repeat(2,minmax(0,1fr))}
@media(max-width:760px){.account-profile-subnav{grid-template-columns:repeat(2,minmax(0,1fr));}.account-profile-tab{min-height:44px}}

/* Phase 19: Login- und Kontosicherheit */
.security-settings-columns { align-items: start; }
.security-setup { margin-top: 1rem; padding: 1rem; border: 1px solid var(--border-color, #30394b); border-radius: 14px; background: rgba(10,15,25,.35); }
.security-uri { max-height: 5.5rem; overflow: auto; padding: .75rem; border-radius: 10px; background: #0e1420; color: #aeb9ce; font-size: .78rem; overflow-wrap: anywhere; }

.security-two-factor-qr-panel {
    display: grid;
    justify-items: center;
    gap: .65rem;
    width: min(260px, 100%);
    margin: 1rem auto;
    padding: 1rem;
    border-radius: 14px;
    background: #fff;
    color: #111;
}

.security-two-factor-qr-panel[hidden] {
    display: none;
}

.security-two-factor-qr {
    width: min(230px, 100%);
    aspect-ratio: 1;
    display: grid;
    place-items: center;
}

.security-two-factor-qr svg {
    display: block;
    width: 100%;
    height: auto;
}

.security-two-factor-qr-panel small {
    color: #555;
    text-align: center;
}
.recovery-code-grid { margin-top: 1rem; padding: 1rem; border: 1px solid #4f8f70; border-radius: 14px; background: rgba(35,107,74,.16); display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .55rem; }
.recovery-code-grid strong { grid-column: 1 / -1; }
.recovery-code-grid code { display: block; padding: .55rem; border-radius: 8px; background: #0d1714; text-align: center; user-select: all; }
.security-session-list,.security-login-list { display: grid; gap: .65rem; margin: .75rem 0 1rem; }
.security-session-row,.security-login-row { display: flex; align-items: center; justify-content: space-between; gap: .8rem; padding: .8rem; border: 1px solid var(--border-color,#30394b); border-radius: 12px; background: rgba(13,18,28,.45); }
.security-session-row div,.security-login-row div { min-width: 0; display: grid; gap: .2rem; }
.security-session-row small,.security-login-row small { color: #9ca7bd; overflow-wrap: anywhere; }
.security-event-dot { width: .65rem; height: .65rem; border-radius: 50%; flex: 0 0 auto; background: #78849a; }
.security-event-dot.is-success { background: #45c486; box-shadow: 0 0 0 4px rgba(69,196,134,.12); }
.security-event-dot.is-error { background: #e76868; box-shadow: 0 0 0 4px rgba(231,104,104,.12); }
.security-login-row { justify-content: flex-start; }
@media (max-width:640px){.recovery-code-grid{grid-template-columns:1fr}.security-session-row{align-items:flex-start;flex-direction:column}.security-session-row .icon-button{width:100%}}


/* =========================================================
   Phase 20: compliance, legal documents and content reports
========================================================= */
.character-card-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: .65rem;
    align-items: center;
}
.character-card-actions .character-chat-button {
    width: 100%;
}
.report-content-button {
    min-width: auto;
}
.compliance-settings-columns {
    align-items: stretch;
}
.compliance-document-list,
.privacy-request-list,
.compliance-gate-documents {
    display: grid;
    gap: .7rem;
    margin: 1rem 0;
}
.compliance-document-row,
.privacy-request-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    padding: .85rem 1rem;
    border: 1px solid var(--border-color, rgba(148, 163, 184, .2));
    border-radius: .9rem;
    background: rgba(15, 23, 42, .45);
}
.compliance-document-row strong,
.privacy-request-row strong {
    display: block;
}
.compliance-document-row small,
.privacy-request-row small {
    display: block;
    margin-top: .2rem;
    color: var(--muted-text, #94a3b8);
}
.compliance-row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .45rem;
    justify-content: flex-end;
}
.compliance-modal-card {
    max-width: 720px;
}
.compliance-gate-documents {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.compliance-gate-document {
    display: block;
    padding: .85rem 1rem;
    border: 1px solid rgba(96, 165, 250, .35);
    border-radius: .8rem;
    background: rgba(30, 64, 175, .12);
    color: #bfdbfe;
    text-decoration: none;
}
.compliance-gate-document:hover {
    border-color: #60a5fa;
}
.compliance-gate-modal .check-field {
    margin: .7rem 0;
}
.report-modal-card {
    max-width: 650px;
}
.story-detail-moderation {
    display: flex;
    justify-content: flex-end;
    margin: .75rem 0 1rem;
}
.legal-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: .85rem 1.25rem;
    padding: 1.3rem 1rem 6.5rem;
    color: #94a3b8;
    font-size: .86rem;
}
.legal-footer a,
.legal-footer button {
    display: inline-flex;
    min-height: 1.4em;
    align-items: center;
    justify-content: center;
    margin: 0;
    color: inherit;
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    line-height: 1.4;
    vertical-align: middle;
    cursor: pointer;
    text-decoration: none;
}
.legal-footer button {
    appearance: none;
    -webkit-appearance: none;
}
.legal-footer a:hover,
.legal-footer button:hover {
    color: #e2e8f0;
    text-decoration: underline;
}
.cookie-session-notice {
    position: fixed;
    z-index: 95;
    left: clamp(1rem, 3vw, 2.5rem);
    right: clamp(1rem, 3vw, 2.5rem);
    bottom: 1rem;
    display: flex;
    justify-content: space-between;
    gap: 1.25rem;
    align-items: center;
    max-width: 1100px;
    margin: 0 auto;
    padding: 1rem 1.15rem;
    border: 1px solid rgba(96, 165, 250, .35);
    border-radius: 1rem;
    background: rgba(8, 15, 28, .97);
    box-shadow: 0 18px 55px rgba(0, 0, 0, .45);
    backdrop-filter: blur(18px);
}
.cookie-session-notice[hidden] {
    display: none !important;
}
.cookie-session-notice strong {
    display: block;
    margin-bottom: .2rem;
}
.cookie-session-notice p {
    margin: 0;
    color: #aab6c8;
    font-size: .88rem;
}
.cookie-notice-actions {
    display: flex;
    align-items: center;
    gap: .8rem;
    flex-shrink: 0;
}
.cookie-notice-actions a {
    color: #93c5fd;
}
.account-danger-card {
    margin-bottom: 1rem;
}
@media (max-width: 720px) {
    .compliance-document-row,
    .privacy-request-row,
    .cookie-session-notice {
        align-items: stretch;
        flex-direction: column;
    }
    .compliance-row-actions,
    .cookie-notice-actions {
        justify-content: flex-start;
    }
    .legal-footer {
        padding-bottom: 7.5rem;
    }
}

/* =========================================================
   PRODUCT UI: DISCOVERY / IMMERSIVE ROLEPLAY
========================================================= */

:root {
    --bg: #07070a;
    --surface: #101014;
    --surface-2: #17171d;
    --surface-3: #202028;
    --accent: #a855f7;
    --accent-strong: #7c3aed;
    --accent-soft: rgba(168, 85, 247, 0.14);
    --sidebar-width: 248px;
}

body {
    background:
        radial-gradient(circle at 76% -12%, rgba(126, 34, 206, 0.18), transparent 32rem),
        radial-gradient(circle at 18% 78%, rgba(76, 29, 149, 0.08), transparent 30rem),
        #07070a;
}

.app-sidebar {
    padding: 18px 13px;
    background: rgba(8, 8, 11, 0.94);
    border-right-color: rgba(255, 255, 255, 0.065);
}

.brand-row { padding: 1px 7px 22px; }

.brand-mark {
    border-radius: 13px;
    background: linear-gradient(135deg, #c084fc, #7c3aed 58%, #4c1d95);
    box-shadow: 0 12px 34px rgba(124, 58, 237, 0.28);
}

.primary-nav { gap: 4px; }
.nav-item { min-height: 46px; border-radius: 12px; }

.nav-item.is-active {
    background: linear-gradient(90deg, rgba(126, 34, 206, 0.2), rgba(126, 34, 206, 0.055));
    border-color: rgba(192, 132, 252, 0.16);
    color: #f0e4ff;
}

.account-card {
    border-color: rgba(255, 255, 255, 0.065);
    background: rgba(255, 255, 255, 0.025);
}

.topbar {
    min-height: 76px;
    background: rgba(7, 7, 10, 0.78);
    border-bottom-color: rgba(255, 255, 255, 0.055);
}

.topbar .eyebrow { color: #8d8797; letter-spacing: 0.1em; }
.page-area { padding-top: clamp(20px, 3vw, 42px); }

.discovery-hero {
    min-height: 405px;
    border-color: rgba(192, 132, 252, 0.18);
    background:
        radial-gradient(circle at 80% 25%, rgba(192, 132, 252, 0.18), transparent 26rem),
        linear-gradient(116deg, rgba(88, 28, 135, 0.24), rgba(20, 12, 30, 0.82) 43%, rgba(11, 11, 16, 0.92));
    box-shadow: 0 28px 90px rgba(0, 0, 0, 0.38);
}

.discovery-hero::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(90deg, rgba(7, 7, 10, 0.16), transparent 60%);
}

.discovery-hero .hero-copy h2 {
    max-width: 830px;
    font-size: clamp(2.45rem, 5.5vw, 5.35rem);
    line-height: 0.94;
}

.discovery-hero .hero-copy p { max-width: 610px; color: #b7b1c0; }

.discovery-hero .primary-button {
    min-height: 50px;
    padding-inline: 22px;
    background: linear-gradient(135deg, #b65cff, #7c3aed);
}

.hero-trust-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 18px;
    margin-top: 22px;
    color: #918b9a;
    font-size: 0.78rem;
    font-weight: 700;
}

.hero-trust-row > span { display: inline-flex; align-items: center; gap: 6px; }
.discovery-hero .hero-orbit { transform: scale(1.08); }

.discovery-hero .orbit-card {
    border-color: rgba(255, 255, 255, 0.11);
    background: linear-gradient(155deg, rgba(65, 42, 82, 0.74), rgba(20, 18, 27, 0.82));
}

.discovery-section-heading {
    align-items: end;
    margin-top: clamp(32px, 5vw, 58px);
    margin-bottom: 15px;
}

.discovery-section-heading h2 {
    margin: 4px 0 0;
    font-size: clamp(1.55rem, 2.4vw, 2.15rem);
    letter-spacing: -0.045em;
}

.discovery-stories-heading { margin-top: clamp(42px, 6vw, 72px); }

.text-action {
    padding: 8px 0;
    border: 0;
    background: transparent;
    color: #ba9ee7;
    cursor: pointer;
    font-size: 0.86rem;
    font-weight: 750;
}

.text-action:hover { color: #e2ceff; }

.discovery-rail {
    display: grid;
    grid-auto-columns: minmax(220px, 250px);
    grid-auto-flow: column;
    gap: 14px;
    overflow-x: auto;
    padding: 2px 2px 16px;
    overscroll-behavior-inline: contain;
    scroll-snap-type: inline proximity;
    scrollbar-width: thin;
    scrollbar-color: rgba(168, 85, 247, 0.42) transparent;
}

.discovery-rail > * { scroll-snap-align: start; }

.discovery-rail .character-card {
    display: grid;
    height: 100%;
    min-width: 0;
    grid-template-rows: auto minmax(0, 1fr);
    border-color: rgba(255, 255, 255, 0.07);
    border-radius: 18px;
    background: #101014;
    box-shadow: 0 18px 45px rgba(0, 0, 0, 0.24);
}

.discovery-rail .character-card-media { aspect-ratio: 4 / 5.25; }
.discovery-rail .character-card-body {
    display: flex;
    min-height: 0;
    flex-direction: column;
    gap: 9px;
    padding: 13px;
}
.discovery-rail .character-title-row {
    min-height: 2.7em;
    align-items: flex-start;
    flex-direction: row;
}
.discovery-rail .character-title-row h3 {
    display: -webkit-box;
    line-height: 1.35;
    overflow: hidden;
    overflow-wrap: anywhere;
    text-overflow: clip;
    white-space: normal;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}
.discovery-rail .character-description {
    min-height: 2.8em;
    max-height: 2.8em;
    -webkit-line-clamp: 2;
}
.discovery-rail .character-meta { display: none; }

.discovery-rail .character-chat-button {
    flex: 0 0 44px;
    height: 44px;
    min-height: 44px;
    margin-top: auto;
    border: 0;
    background: linear-gradient(135deg, #8b38db, #6826b7);
    color: #fff;
}

.discovery-story-rail { grid-auto-columns: minmax(300px, 360px); }

.discovery-story-card {
    display: grid;
    grid-template-columns: 116px minmax(0, 1fr);
    min-height: 164px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 18px;
    background: linear-gradient(145deg, #141419, #0d0d11);
}

.discovery-story-media { min-height: 164px; overflow: hidden; background: #18181e; }

.discovery-story-media img,
.discovery-story-media .character-image-fallback {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.discovery-story-body {
    display: flex;
    min-width: 0;
    flex-direction: column;
    align-items: flex-start;
    padding: 15px;
}

.discovery-story-body h3,
.discovery-story-body p {
    max-width: 100%;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.discovery-story-body h3 { width: 100%; font-size: 1rem; }
.discovery-story-body p { margin-top: 4px; color: #a78bfa; font-size: 0.8rem; font-weight: 700; }
.discovery-story-meta { margin-top: 10px; color: #837e8c; font-size: 0.72rem; }

.discovery-story-body .primary-button {
    width: 100%;
    min-height: 38px;
    margin-top: auto;
    padding: 0 12px;
    border-radius: 10px;
    font-size: 0.78rem;
}

.discovery-loading,
.discovery-empty-card {
    display: flex;
    min-height: 160px;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: 1px solid rgba(255, 255, 255, 0.065);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.02);
    color: var(--muted);
}

.discovery-empty-card {
    width: min(380px, calc(100vw - 44px));
    align-items: flex-start;
    flex-direction: column;
    padding: 20px;
}

.discovery-empty-card h3,
.discovery-empty-card p { margin: 0; }
.discovery-empty-card p { color: var(--muted); font-size: 0.85rem; line-height: 1.5; }
.discovery-empty-icon { color: #c084fc; font-size: 1.55rem; }
.catalogue-heading h2 { font-size: clamp(1.85rem, 3vw, 2.75rem); }

.character-card,
.scenario-card,
.story-card { border-color: rgba(255, 255, 255, 0.07); background: #101014; }

.character-card:hover,
.scenario-card:hover,
.story-card:hover { border-color: rgba(192, 132, 252, 0.24); }

.chat-shell {
    border-color: rgba(255, 255, 255, 0.065);
    background: rgba(7, 7, 10, 0.97);
    box-shadow: 0 28px 90px rgba(0, 0, 0, 0.38);
}

.chat-header,
.v2-chat-form { background: rgba(13, 13, 18, 0.97); }
.v2-message-bubble { background: #17171d; }
.v2-message.is-user .v2-message-bubble { background: linear-gradient(135deg, #6526a9, #4c1d95); }

@media (max-width: 760px) {
    .discovery-hero { min-height: 360px; padding: 28px 22px; }
    .discovery-hero .hero-copy h2 { font-size: clamp(2.25rem, 12vw, 3.7rem); }
    .hero-trust-row { gap: 8px 14px; }
    .discovery-section-heading { align-items: center; flex-direction: row; }
    .discovery-rail {
        grid-auto-columns: minmax(178px, 66vw);
        margin-right: calc(-1 * clamp(20px, 4vw, 56px));
        padding-right: clamp(20px, 4vw, 56px);
    }
    .discovery-story-rail { grid-auto-columns: minmax(280px, 84vw); }
    .discovery-rail .character-card-media { aspect-ratio: 4 / 5; }
    .character-grid .character-card {
        display: grid;
        grid-template-rows: auto minmax(0, 1fr);
    }
    .character-grid .character-card-body {
        display: flex;
        min-height: 0;
        flex-direction: column;
    }
    .character-grid .character-title-row {
        min-height: 4.9em;
    }
    .character-grid .character-title-row h3 {
        display: -webkit-box;
        overflow: hidden;
        overflow-wrap: anywhere;
        white-space: normal;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
    }
    .character-grid .character-chat-button,
    .character-grid .character-card-actions {
        margin-top: auto;
    }
}

@media (max-width: 430px) {
    .discovery-hero .hero-actions { display: grid; grid-template-columns: 1fr; }
    .discovery-hero .hero-actions > * { width: 100%; }
    .discovery-story-card { grid-template-columns: 98px minmax(0, 1fr); }
}

/* Character detail experience */
.character-card.is-interactive { cursor: pointer; }

.character-card.is-interactive:focus-visible {
    outline: 3px solid rgba(192, 132, 252, 0.42);
    outline-offset: 3px;
}

.character-detail-modal {
    z-index: 5600;
    isolation: isolate;
}

/* R45_CHARACTER_DETAIL_AMBIENT_BACKDROP */
.character-detail-modal::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    background: rgba(4, 4, 8, 0.74);
}

.character-detail-backdrop-image {
    position: absolute;
    z-index: 1;
    inset: -2%;
    width: 104%;
    height: 104%;
    object-fit: cover;
    object-position: center;
    pointer-events: none;
    opacity: 0.52;
    filter:
        blur(10px)
        saturate(1.02)
        brightness(0.86);
    transform: scale(1.01);
}

.character-detail-backdrop-image[hidden] {
    display: none;
}

.character-detail-modal > .modal-backdrop {
    z-index: 2;
    background: rgba(4, 4, 8, 0.10);
    backdrop-filter: blur(2px);
}

.character-detail-card {
    position: relative;
    z-index: 3;
    display: grid;
    width: min(1060px, calc(100vw - 36px));
    height: min(860px, calc(100dvh - 36px));
    max-height: min(860px, calc(100dvh - 36px));
    grid-template-columns: minmax(330px, 0.9fr) minmax(0, 1.1fr);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 26px;
    background: #0d0d12;
    box-shadow: 0 40px 120px rgba(0, 0, 0, 0.7);
}

.character-detail-close {
    position: absolute;
    z-index: 4;
    top: 16px;
    right: 16px;
    border-color: rgba(255, 255, 255, 0.14);
    background: rgba(10, 10, 14, 0.72);
    backdrop-filter: blur(16px);
}

.character-detail-media {
    position: relative;
    min-height: 660px;
    overflow: hidden;
    background:
        radial-gradient(circle at 50% 24%, rgba(168, 85, 247, 0.24), transparent 42%),
        #17171e;
}

.character-detail-media::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(90deg, transparent 70%, rgba(13, 13, 18, 0.54));
}

.character-detail-media img,
.character-detail-media .character-image-fallback {
    width: 100%;
    height: 100%;
    min-height: 660px;
}

.character-detail-media img {
    display: block;
    object-fit: cover;
}

.character-detail-content {
    display: flex;
    min-width: 0;
    min-height: 0;
    flex-direction: column;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    padding: clamp(28px, 4vw, 48px);
    padding-top: clamp(34px, 5vw, 58px);
}

.character-detail-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    padding-right: 48px;
}

.character-detail-heading .eyebrow { margin-bottom: 6px; }

.character-detail-heading h2 {
    margin: 0;
    font-size: clamp(2rem, 4vw, 3.5rem);
    line-height: 0.98;
    letter-spacing: -0.055em;
}

.character-detail-favorite {
    flex: 0 0 44px;
    width: 44px;
    min-width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 14px;
}

.character-detail-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 18px;
}

.character-detail-badges .character-origin {
    display: inline-flex;
    min-height: 25px;
    align-items: center;
    padding: 0 9px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.035);
    color: #bcb5c7;
    font-size: 0.68rem;
    font-weight: 780;
}

.character-detail-description {
    margin: 24px 0 0;
    color: #d4ceda;
    font-size: 1rem;
    line-height: 1.72;
}

.character-detail-facts {
    display: grid;
    gap: 0;
    margin-top: 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.075);
}

.character-detail-facts[hidden] { display: none; }

.character-detail-fact {
    padding: 17px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.075);
}

.character-detail-fact h3,
.character-detail-fact p { margin: 0; }

.character-detail-fact h3 {
    color: #a98dce;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.character-detail-fact p {
    margin-top: 7px;
    color: #aaa4b2;
    font-size: 0.9rem;
    line-height: 1.62;
    white-space: pre-line;
}

.character-detail-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    margin-top: auto;
    padding-top: 28px;
}

.character-detail-chat {
    min-height: 52px;
    background: linear-gradient(135deg, #b15cff, #782fd0);
}

.character-detail-report {
    min-height: 52px;
}

@media (max-width: 780px) {
    .character-detail-modal {
        padding: 0;
    }

    .character-detail-card {
        width: 100%;
        height: 100dvh;
        max-height: none;
        grid-template-columns: 1fr;
        grid-template-rows: minmax(280px, 43dvh) minmax(0, 1fr);
        border: 0;
        border-radius: 0;
    }

    .character-detail-media,
    .character-detail-media img,
    .character-detail-media .character-image-fallback {
        min-height: 0;
        height: 100%;
    }

    .character-detail-media::after {
        background: linear-gradient(180deg, transparent 60%, #0d0d12);
    }

    .character-detail-content {
        padding: 22px 20px calc(22px + env(safe-area-inset-bottom));
    }

    .character-detail-heading { padding-right: 38px; }
    .character-detail-heading h2 { font-size: clamp(2rem, 10vw, 3rem); }
}

@media (max-width: 430px) {
    .character-detail-actions { grid-template-columns: 1fr; }
    .character-detail-report { min-height: 44px; }
}

/* Immersive chat experience */
.chat-shell {
    position: relative;
    isolation: isolate;
    border-color: rgba(192, 132, 252, 0.12);
    background: #09090d;
    box-shadow: 0 30px 100px rgba(0, 0, 0, 0.46);
}

.chat-shell::before {
    content: "";
    position: absolute;
    z-index: 0;
    inset: -42px;
    pointer-events: none;
    background-image:
        linear-gradient(90deg, rgba(9, 9, 13, 0.98) 0%, rgba(9, 9, 13, 0.91) 48%, rgba(9, 9, 13, 0.76) 100%),
        var(--chat-character-image, none);
    background-position: center, right 18% center;
    background-size: cover, min(52vw, 760px) auto;
    background-repeat: no-repeat;
    opacity: 0;
    filter: blur(18px) saturate(0.8);
    transform: scale(1.05);
    transition: opacity 240ms ease;
}

.chat-shell.has-character-art::before { opacity: 0.26; }

.chat-header,
.chat-archive-notice,
.chat-notice,
.chat-messages,
.v2-chat-form {
    position: relative;
    z-index: 1;
}

.chat-header {
    min-height: 82px;
    padding: 13px 18px;
    border-bottom-color: rgba(255, 255, 255, 0.065);
    background: linear-gradient(180deg, rgba(13, 13, 18, 0.96), rgba(13, 13, 18, 0.87));
}

.chat-avatar {
    width: 52px;
    height: 52px;
    border-color: rgba(192, 132, 252, 0.72);
    box-shadow: 0 0 0 4px rgba(192, 132, 252, 0.07), 0 8px 28px rgba(0, 0, 0, 0.34);
}

.chat-header-copy h2 {
    font-size: 1.06rem;
    letter-spacing: -0.02em;
}

.chat-header-copy p { color: #8f8998; }

.chat-messages {
    scrollbar-gutter: stable;
    overscroll-behavior: contain;
    padding: 30px clamp(18px, 5vw, 74px) 38px;
    background:
        radial-gradient(circle at 78% 18%, rgba(126, 34, 206, 0.055), transparent 34rem),
        linear-gradient(180deg, rgba(7, 7, 10, 0.1), rgba(7, 7, 10, 0.42));
}

.v2-message {
    gap: 6px;
    margin: 18px auto;
    width: min(100%, 1040px);
}

.v2-message-speaker {
    padding: 0 7px;
    color: #a98dce;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.04em;
}

.v2-message.is-user.is-pending { opacity: 1; }

.v2-message.is-typing .typing-bubble {
    display: inline-flex;
    min-width: 132px;
    align-items: center;
    gap: 10px;
    color: #aaa4b2;
}

.typing-copy {
    font-size: 0.82rem;
    font-style: italic;
}

.typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.typing-dots > span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #c084fc;
    animation: chat-typing-dot 1.1s ease-in-out infinite;
}

.typing-dots > span:nth-child(2) { animation-delay: 0.14s; }
.typing-dots > span:nth-child(3) { animation-delay: 0.28s; }

.streaming-caret {
    display: inline-block;
    width: 2px;
    height: 1.05em;
    margin-left: 3px;
    border-radius: 999px;
    background: #c084fc;
    vertical-align: -0.15em;
    animation: chat-stream-caret 0.8s steps(1, end) infinite;
}

.chat-shell.is-generating .chat-avatar {
    animation: chat-avatar-thinking 1.8s ease-in-out infinite;
}

@keyframes chat-typing-dot {
    0%, 60%, 100% { opacity: 0.38; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-4px); }
}

@keyframes chat-avatar-thinking {
    0%, 100% { box-shadow: 0 0 0 4px rgba(192, 132, 252, 0.07), 0 8px 28px rgba(0, 0, 0, 0.34); }
    50% { box-shadow: 0 0 0 7px rgba(192, 132, 252, 0.13), 0 8px 32px rgba(109, 40, 217, 0.28); }
}

@keyframes chat-stream-caret {
    0%, 48% { opacity: 1; }
    49%, 100% { opacity: 0.16; }
}

@media (prefers-reduced-motion: reduce) {
    .typing-dots > span,
    .streaming-caret,
    .chat-shell.is-generating .chat-avatar { animation: none; }
}

/* =========================================================
   STEP 55: INSTALLABLE PWA
========================================================= */
.pwa-install-button {
    flex: 0 0 auto;
    border-color: rgba(168, 85, 247, .34);
    background: rgba(126, 34, 206, .16);
    color: #e9d5ff;
    font-size: 1.15rem;
    font-weight: 850;
}

.pwa-install-button:hover {
    border-color: rgba(192, 132, 252, .55);
    background: rgba(126, 34, 206, .28);
}

.pwa-install-button[hidden] { display: none !important; }

@media (display-mode: standalone) {
    .pwa-install-button { display: none !important; }
    .topbar { padding-top: max(var(--topbar-padding-top, 0px), env(safe-area-inset-top)); }
}

/* =========================================================
   STEP 56: FIRST-RUN ONBOARDING
========================================================= */
.onboarding-help-button {
    flex: 0 0 auto;
    border-color: rgba(255, 255, 255, .12);
    color: #c9c2d8;
    font-size: .95rem;
    font-weight: 850;
}

.onboarding-layer { z-index: 6500; }
.onboarding-modal {
    width: min(700px, 100%);
    overflow: hidden;
    padding: 28px;
    border-color: rgba(168, 85, 247, .22);
    background:
        radial-gradient(circle at 95% 0%, rgba(126, 34, 206, .18), transparent 35%),
        #12121a;
}

.onboarding-header { margin-bottom: 10px; }
.onboarding-lead {
    max-width: 590px;
    margin: 0;
    color: var(--muted);
    line-height: 1.6;
}

.onboarding-progress {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 20px 0;
}

.onboarding-progress strong {
    margin-left: auto;
    color: #9993a7;
    font-size: .75rem;
    font-variant-numeric: tabular-nums;
}

.onboarding-dot {
    width: 22px;
    height: 5px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .10);
    transition: width 180ms ease, background 180ms ease;
}

.onboarding-dot.is-active {
    width: 42px;
    background: linear-gradient(90deg, #a855f7, #7c3aed);
}

.onboarding-stage {
    min-height: 300px;
    padding: 28px;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 22px;
    background: rgba(255, 255, 255, .025);
}

.onboarding-step[hidden],
.onboarding-step [hidden] { display: none !important; }

.onboarding-step-icon {
    display: grid;
    width: 58px;
    height: 58px;
    place-items: center;
    margin-bottom: 20px;
    border: 1px solid rgba(192, 132, 252, .22);
    border-radius: 18px;
    background: linear-gradient(135deg, rgba(168, 85, 247, .32), rgba(76, 29, 149, .16));
    box-shadow: 0 16px 38px rgba(76, 29, 149, .16);
    color: #f3e8ff;
    font-size: 1.35rem;
    font-weight: 900;
}

.onboarding-step h3 {
    margin: 7px 0 11px;
    color: #f8f5ff;
    font-size: clamp(1.35rem, 4vw, 1.8rem);
    line-height: 1.18;
}

.onboarding-step > p:not(.eyebrow) {
    max-width: 590px;
    margin: 0;
    color: #b9b4c5;
    line-height: 1.65;
}

.onboarding-feature-row {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    margin-top: 20px;
}

.onboarding-feature-row > span {
    padding: 7px 10px;
    border: 1px solid rgba(255, 255, 255, .09);
    border-radius: 999px;
    background: rgba(255, 255, 255, .035);
    color: #d8d2e2;
    font-size: .78rem;
    font-weight: 700;
}

.onboarding-register-cta {
    display: inline-flex;
    width: auto;
    margin-top: 20px;
    text-decoration: none;
}

.onboarding-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-top: 20px;
}

.onboarding-skip { padding: 8px 2px; }
.onboarding-navigation { display: flex; gap: 10px; }
.onboarding-navigation .primary-button,
.onboarding-navigation .secondary-button { min-width: 112px; }

@media (max-width: 760px) {
    .onboarding-modal {
        max-height: 92dvh;
        overflow-y: auto;
        padding: 22px 18px calc(18px + env(safe-area-inset-bottom));
    }
    .onboarding-stage { min-height: 330px; padding: 22px 18px; }
    .onboarding-actions { align-items: stretch; flex-direction: column-reverse; }
    .onboarding-navigation { width: 100%; }
    .onboarding-navigation .primary-button,
    .onboarding-navigation .secondary-button { flex: 1 1 0; width: auto; }
    .onboarding-skip { align-self: center; }
}

.v2-message-bubble {
    max-width: min(790px, 82%);
    padding: 15px 18px;
    border-color: rgba(255, 255, 255, 0.06);
    border-radius: 20px 20px 20px 7px;
    background: rgba(23, 23, 29, 0.9);
    box-shadow: 0 10px 32px rgba(0, 0, 0, 0.14);
    backdrop-filter: blur(12px);
    color: #d9d5de;
    line-height: 1.68;
}

.v2-message.is-user .v2-message-bubble {
    border-color: rgba(192, 132, 252, 0.2);
    border-radius: 20px 20px 7px 20px;
    background: linear-gradient(135deg, rgba(103, 39, 171, 0.96), rgba(76, 29, 149, 0.96));
    box-shadow: 0 12px 34px rgba(76, 29, 149, 0.16);
}

.v2-message-actions { max-width: min(790px, 82%); }

.v2-chat-form {
    grid-template-columns: auto minmax(0, 860px) auto;
    justify-content: center;
    padding: 15px clamp(16px, 5vw, 70px) 17px;
    border-top-color: rgba(255, 255, 255, 0.055);
    background: linear-gradient(180deg, rgba(9, 9, 13, 0.82), rgba(9, 9, 13, 0.98));
    backdrop-filter: blur(18px);
}

.chat-suggestions-button {
    width: 52px;
    height: 52px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 1px solid rgba(192, 132, 252, 0.2);
    border-radius: 17px;
    background: rgba(76, 29, 149, 0.2);
    color: #d8b4fe;
    cursor: pointer;
    font: inherit;
    font-size: 1.12rem;
    transition: border-color 160ms ease, background 160ms ease, color 160ms ease, transform 160ms ease;
}

.chat-suggestions-button:hover:not(:disabled) {
    border-color: rgba(192, 132, 252, 0.5);
    background: rgba(109, 40, 217, 0.34);
    color: #fff;
    transform: translateY(-1px);
}

.chat-suggestions-button:disabled {
    cursor: default;
    opacity: 0.34;
}

.chat-suggestion-tray {
    position: absolute;
    z-index: 6;
    right: clamp(16px, 5vw, 70px);
    bottom: 82px;
    left: clamp(16px, 5vw, 70px);
    width: min(930px, calc(100% - 32px));
    margin-inline: auto;
    padding: 12px;
    border: 1px solid rgba(192, 132, 252, 0.2);
    border-radius: 20px;
    background: rgba(15, 13, 21, 0.97);
    box-shadow: 0 22px 65px rgba(0, 0, 0, 0.46);
    backdrop-filter: blur(20px);
}

.chat-scroll-latest {
    position: absolute;
    z-index: 7;
    right: 50%;
    bottom: 86px;
    min-height: 36px;
    padding: 7px 13px;
    transform: translateX(50%);
    border: 1px solid rgba(192, 132, 252, .26);
    border-radius: 999px;
    background: rgba(24, 20, 31, .95);
    box-shadow: 0 10px 32px rgba(0, 0, 0, .34);
    color: #ddcdf3;
    cursor: pointer;
    font: inherit;
    font-size: .72rem;
    font-weight: 780;
    backdrop-filter: blur(16px);
}

.chat-scroll-latest:hover { border-color: rgba(192, 132, 252, .48); color: #fff; }
.chat-scroll-latest[hidden] { display: none !important; }

.chat-suggestion-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 3px 9px;
    color: #c4b5fd;
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.03em;
}

.chat-suggestion-heading > div {
    display: flex;
    gap: 4px;
}

.suggestion-tray-button {
    width: 27px;
    height: 27px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #8f8998;
    cursor: pointer;
}

.suggestion-tray-button:hover:not(:disabled) { background: rgba(255, 255, 255, 0.07); color: #fff; }
.suggestion-tray-button:disabled { opacity: 0.35; cursor: wait; }

.chat-suggestion-list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.chat-suggestion-chip {
    min-width: 0;
    min-height: 64px;
    padding: 11px 13px;
    border: 1px solid rgba(255, 255, 255, 0.075);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.035);
    color: #d8d3de;
    cursor: pointer;
    text-align: left;
    font: inherit;
    font-size: 0.78rem;
    line-height: 1.45;
}

.chat-suggestion-chip:hover {
    border-color: rgba(192, 132, 252, 0.35);
    background: rgba(109, 40, 217, 0.16);
    color: #fff;
}

.chat-suggestion-loading,
.chat-suggestion-empty {
    grid-column: 1 / -1;
    display: flex;
    min-height: 58px;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 0;
    color: #aaa4b2;
    font-size: 0.8rem;
}

.v2-chat-form textarea {
    min-height: 52px;
    padding: 14px 17px;
    border-color: rgba(255, 255, 255, 0.09);
    border-radius: 18px;
    background: rgba(25, 25, 31, 0.92);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.025);
}

.chat-send-button {
    width: 52px;
    height: 52px;
    border-radius: 17px;
    background: linear-gradient(135deg, #a855f7, #6d28d9);
    box-shadow: 0 10px 26px rgba(109, 40, 217, 0.25);
}

@media (max-width: 760px) {
    .chat-shell::before {
        background-position: center, center top;
        background-size: cover, 100% auto;
    }

    .chat-shell.has-character-art::before { opacity: 0.2; }
    .chat-header { min-height: 70px; padding-inline: 10px; }
    .chat-avatar { width: 44px; height: 44px; }
    .chat-messages { padding: 18px 12px 26px; }
    .v2-message { margin-block: 14px; }
    .v2-message-bubble,
    .v2-message-actions { max-width: 92%; }
    .v2-chat-form {
        grid-template-columns: auto minmax(0, 1fr) auto;
        padding-inline: 10px;
    }
    .chat-suggestions-button { width: 48px; height: 48px; border-radius: 15px; }
    .chat-suggestion-tray { right: 10px; bottom: 76px; left: 10px; width: auto; }
    .chat-scroll-latest { bottom: calc(76px + env(safe-area-inset-bottom)); }
    .chat-suggestion-list { grid-template-columns: 1fr; }
    .chat-suggestion-chip { min-height: 0; }
}

/* Conversation-first stories overview */
.story-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(430px, 100%), 1fr));
    gap: 14px;
}

.story-conversation-card {
    display: grid;
    grid-template-columns: 158px minmax(0, 1fr);
    min-height: 224px;
    cursor: pointer;
    border-color: rgba(255, 255, 255, 0.07);
    border-radius: 22px;
    background: rgba(15, 15, 20, 0.94);
    box-shadow: 0 18px 54px rgba(0, 0, 0, 0.22);
    transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.story-conversation-card:hover {
    border-color: rgba(192, 132, 252, 0.24);
    transform: translateY(-2px);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.3);
}

.story-conversation-card:focus-visible {
    outline: 2px solid rgba(192, 132, 252, 0.72);
    outline-offset: 3px;
}

.story-conversation-card .story-card-media {
    height: 100%;
    min-height: 224px;
}

.story-conversation-card .story-card-media::after {
    background:
        linear-gradient(180deg, rgba(7, 7, 10, 0.03) 32%, rgba(7, 7, 10, 0.75) 100%),
        linear-gradient(90deg, transparent 70%, rgba(12, 12, 17, 0.42));
}

.story-conversation-card .story-card-media img {
    transition: transform 260ms ease, filter 180ms ease;
}

.story-conversation-card .story-card-media.is-character-customizable {
    cursor: pointer;
}

.story-conversation-card .story-card-media.is-character-customizable:focus-visible {
    outline: 2px solid rgba(192, 132, 252, 0.78);
    outline-offset: -3px;
}

.story-conversation-card:hover .story-card-media img { transform: scale(1.035); }

.story-conversation-card .story-card-body {
    min-width: 0;
    justify-content: center;
    gap: 9px;
    padding: 19px 20px;
}

.story-card-heading-copy { min-width: 0; }

.story-conversation-card .story-character-name {
    margin-bottom: 3px;
    color: #b996f8;
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.04em;
}

.story-conversation-card .story-character-link {
    display: inline-block;
    width: fit-content;
    max-width: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.story-conversation-card .story-character-link:hover,
.story-conversation-card .story-character-link:focus-visible {
    color: #d8bcff;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.story-conversation-card .story-card-body h3 {
    overflow: hidden;
    color: #f3eff6;
    font-size: 1.05rem;
    line-height: 1.22;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.story-conversation-card .story-scenario-name {
    overflow: hidden;
    color: #837d8b;
    font-size: 0.74rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.story-card-preview {
    display: -webkit-box;
    min-height: 42px;
    overflow: hidden;
    color: #aaa4b1;
    font-size: 0.82rem;
    line-height: 1.55;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.story-card-preview.is-user { color: #938ca0; }

.story-conversation-card .story-card-meta {
    gap: 10px 14px;
    min-height: 20px;
}

.story-conversation-card .story-card-meta span {
    padding: 0;
    background: none;
    color: #77717e;
    font-size: 0.68rem;
    white-space: nowrap;
}

.story-conversation-card .story-card-actions {
    grid-template-columns: minmax(120px, 1fr) repeat(3, 42px);
    gap: 7px;
    align-items: center;
    margin-top: 3px;
}

.story-conversation-card .story-open-button {
    min-height: 42px;
    border-radius: 13px;
    background: linear-gradient(135deg, #9b4de0, #6d28d9);
}

.story-conversation-card .story-card-actions .icon-button {
    width: 42px;
    min-width: 42px;
    height: 42px;
    border-radius: 13px;
    color: #aaa4b1;
}

.story-conversation-card .story-delete-button:hover {
    border-color: rgba(248, 113, 113, 0.34);
    background: rgba(127, 29, 29, 0.2);
    color: #fecaca;
}

.story-conversation-card.is-archived {
    opacity: 0.72;
    border-style: solid;
}

@media (max-width: 620px) {
    .story-conversation-card {
        grid-template-columns: 112px minmax(0, 1fr);
        min-height: 210px;
    }

    .story-conversation-card .story-card-media { min-height: 210px; }
    .story-conversation-card .story-card-body { padding: 16px 14px; }
    .story-conversation-card .story-persona { display: none; }
}

@media (max-width: 430px) {
    .story-conversation-card { grid-template-columns: 96px minmax(0, 1fr); }
    .story-conversation-card .story-card-actions { grid-template-columns: repeat(3, 1fr); }
    .story-conversation-card .story-open-button { grid-column: 1 / -1; }
    .story-conversation-card .story-card-actions .icon-button { width: 100%; }
    .story-conversation-card .story-last-active { display: none; }
}

/* =========================================================
   RELEASE POLISH: DISCOVERY, STORIES, PERSONAS & CHAT
========================================================= */
.discovery-compact-heading { margin-top: clamp(28px, 4vw, 44px); }

.scenarios-page .catalogue-toolbar {
    grid-template-columns: minmax(260px, 1fr) auto auto;
    margin-bottom: 10px;
}

.scenario-spotlight .character-spotlight-media img { object-position: center; }

.scenario-discovery-card {
    overflow: hidden;
    border-radius: 20px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, .24);
    transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.scenario-discovery-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 24px 64px rgba(0, 0, 0, .32);
}

.scenario-discovery-card .scenario-card-media { min-height: 230px; }
.scenario-discovery-card .scenario-card-media img { transition: transform 360ms cubic-bezier(.2,.7,.2,1); }
.scenario-discovery-card:hover .scenario-card-media img { transform: scale(1.045); }
.scenario-discovery-card .scenario-card-body { padding: 16px; }
.scenario-discovery-card .scenario-card-actions { display: grid; grid-template-columns: minmax(0, 1fr) auto; }

.scenario-detail-card .character-detail-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.character-detail-fact {
    padding-top: 14px;
    border-top: 1px solid rgba(255,255,255,.07);
}

.character-detail-fact h3 {
    margin: 0 0 6px;
    color: #b78cf3;
    font-size: .69rem;
    letter-spacing: .09em;
    text-transform: uppercase;
}

.character-detail-fact p { margin: 0; color: #aaa4b2; line-height: 1.58; white-space: pre-wrap; }

.story-list-toolbar {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) minmax(170px, auto);
    gap: 10px;
    margin: -2px 0 22px;
}

.persona-card {
    position: relative;
    overflow: hidden;
    border-radius: 20px;
    background: radial-gradient(circle at 10% 0%, rgba(126,34,206,.16), transparent 16rem), #111016;
}

.persona-card-body { padding: 20px; }
.persona-avatar {
    display: grid;
    width: 52px;
    height: 52px;
    place-items: center;
    margin-bottom: 4px;
    border: 1px solid rgba(192,132,252,.22);
    border-radius: 17px;
    background: linear-gradient(135deg, rgba(168,85,247,.34), rgba(76,29,149,.2));
    color: #f4eaff;
    font-size: 1.25rem;
    font-weight: 850;
}

.persona-card-actions { display: flex; flex-wrap: wrap; }
.persona-card-actions .secondary-button { flex: 1 1 110px; }
.persona-card-actions .danger-button { flex: 0 0 auto; }

.v2-chat-form .chat-stop-button {
    width: 52px;
    height: 52px;
    border: 1px solid rgba(248,113,113,.28);
    border-radius: 17px;
    background: rgba(127,29,29,.25);
    color: #fecaca;
    cursor: pointer;
    font: inherit;
}

.v2-chat-form .chat-stop-button:hover { background: rgba(153,27,27,.38); }
.v2-chat-form .chat-stop-button[hidden] { display: none !important; }
.chat-shell.is-generating .chat-send-button { display: none; }

@media (max-width: 760px) {
    .scenarios-page .catalogue-toolbar { grid-template-columns: minmax(0, 1fr) auto; }
    .scenarios-page .catalogue-search { grid-column: 1 / -1; }
    .story-list-toolbar { grid-template-columns: 1fr; }
    .scenario-discovery-card .scenario-card-media { min-height: 190px; }
    .scenario-detail-card { grid-template-columns: 1fr; }
}

/* =========================================================
   RC1: RESILIENCE, MOBILE & ACCESSIBILITY
========================================================= */
.global-connection-notice {
    position: fixed;
    z-index: 2000;
    top: max(14px, env(safe-area-inset-top));
    left: 50%;
    width: min(620px, calc(100vw - 32px));
    padding: 11px 16px;
    transform: translateX(-50%);
    border: 1px solid rgba(251, 191, 36, .3);
    border-radius: 14px;
    background: rgba(35, 26, 11, .96);
    box-shadow: 0 16px 50px rgba(0, 0, 0, .38);
    color: #fde68a;
    font-size: .86rem;
    line-height: 1.45;
    text-align: center;
    backdrop-filter: blur(18px);
}

.global-connection-notice[hidden] { display: none !important; }
.catalogue-state.is-error strong { color: #f8d7da; }
.catalogue-state.is-error .secondary-button { margin-top: 4px; }

@media (max-width: 760px) {
    .page-content {
        padding-right: max(14px, env(safe-area-inset-right));
        padding-left: max(14px, env(safe-area-inset-left));
    }

    .global-connection-notice {
        top: max(8px, env(safe-area-inset-top));
        width: calc(100vw - 20px - env(safe-area-inset-left) - env(safe-area-inset-right));
    }

    .character-detail-modal,
    .story-start-modal,
    .message-edit-modal {
        padding-right: max(8px, env(safe-area-inset-right));
        padding-left: max(8px, env(safe-area-inset-left));
    }

    .character-detail-card {
        max-height: calc(100dvh - max(16px, env(safe-area-inset-top)) - max(16px, env(safe-area-inset-bottom)));
    }

    .v2-chat-form {
        padding-right: max(10px, env(safe-area-inset-right));
        padding-bottom: calc(10px + env(safe-area-inset-bottom));
        padding-left: max(10px, env(safe-area-inset-left));
    }

    button,
    .button,
    .primary-button,
    .secondary-button,
    .icon-button,
    select {
        min-height: 42px;
    }
}

/* Step 57: private character editor */
.character-create-button{flex:0 0 auto;min-height:46px;padding:0 18px;white-space:nowrap}
.character-editor-modal{z-index:6400;padding:24px;overflow:auto}
.character-editor-card{width:min(920px,100%);max-height:min(92dvh,980px);overflow:auto;padding:24px;margin:auto}
.character-editor-privacy{margin:0 0 20px;padding:12px 14px;border:1px solid rgba(155,92,255,.22);border-radius:13px;background:rgba(155,92,255,.08);color:var(--muted);line-height:1.55}
.character-create-actions{display:flex;align-items:center;justify-content:flex-end;gap:10px;flex-wrap:wrap}
.character-ai-assistant{margin:0 0 20px;padding:18px;border:1px solid rgba(168,85,247,.35);border-radius:18px;background:linear-gradient(135deg,rgba(91,33,182,.14),rgba(15,15,24,.88));box-shadow:inset 0 1px 0 rgba(255,255,255,.025)}
.character-ai-modal{padding:24px}.character-ai-card{width:min(720px,calc(100vw - 32px));max-height:min(900px,calc(100dvh - 48px));overflow:auto}.character-ai-card .character-ai-assistant{margin:0;padding:0;border:0;background:none;box-shadow:none}
.character-ai-assistant-head{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;margin-bottom:8px}
.character-ai-assistant-head .eyebrow{margin:0 0 4px}.character-ai-assistant-head h3{margin:0;font-size:1.08rem}
.character-ai-private-badge{display:inline-flex;align-items:center;white-space:nowrap;padding:6px 9px;border:1px solid rgba(52,211,153,.28);border-radius:999px;background:rgba(16,185,129,.08);color:#8ff0c7;font-size:.76rem;font-weight:700}
.character-ai-intro{margin:0 0 14px;color:var(--muted);line-height:1.55}
.character-ai-controls{display:grid;grid-template-columns:minmax(180px,.55fr) minmax(220px,1fr);align-items:end;gap:14px;margin-top:12px}
.character-ai-generate{min-height:46px}.character-ai-note{display:block;margin-top:10px;color:var(--muted);line-height:1.5}
.character-ai-assistant .form-message{margin-top:10px}.character-ai-assistant .form-message.is-success{color:#7ee2b8}.character-ai-assistant .form-message.is-warning{color:#f6c86f}
.character-ai-limit-card{display:flex;align-items:center;justify-content:space-between;gap:20px;margin:16px 0;padding:14px 16px;border:1px solid rgba(168,85,247,.3);border-radius:14px;background:rgba(139,92,246,.09)}.character-ai-limit-card>div{display:flex;flex-direction:column;gap:3px}.character-ai-limit-card span,.character-ai-limit-card small{color:var(--muted)}.character-ai-limit-card strong{font-size:1.35rem;color:#dcc6ff}
.character-ai-progress{display:grid;gap:8px;margin:14px 0;padding:12px 14px;border:1px solid rgba(139,92,246,.24);border-radius:13px;background:rgba(124,58,237,.07)}.character-ai-progress[hidden]{display:none}.character-ai-progress-header{display:flex;align-items:center;justify-content:space-between;gap:12px;color:var(--muted);font-size:.82rem}.character-ai-progress-track{height:8px;overflow:hidden;border-radius:999px;background:rgba(255,255,255,.08)}.character-ai-progress-fill{display:block;width:32%;height:100%;border-radius:inherit;background:linear-gradient(90deg,#7c3aed,#a855f7 55%,#22d3ee);box-shadow:0 0 14px rgba(168,85,247,.36);animation:character-ai-progress-sweep 1.35s ease-in-out infinite}.character-ai-progress.is-complete .character-ai-progress-fill{width:100%;animation:none;transform:none}@keyframes character-ai-progress-sweep{0%{transform:translateX(-125%)}100%{transform:translateX(335%)}}@media(prefers-reduced-motion:reduce){.character-ai-progress-fill{width:55%;animation:none;transform:none}}
.character-ai-estimate{display:flex;flex-direction:column;gap:4px;margin-top:14px;padding:13px 15px;border:1px solid var(--border);border-radius:14px;background:rgba(255,255,255,.025)}.character-ai-estimate>span,.character-ai-estimate small{color:var(--muted)}.character-ai-estimate strong{color:var(--text)}.character-ai-billing-warning{margin-top:14px}.character-ai-billing-warning p{margin-bottom:0}
.character-editor-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px}
.character-editor-form .field-group textarea{width:100%;padding:13px 14px;border:1px solid var(--border);border-radius:14px;background:var(--surface-2);color:var(--text);font:inherit;line-height:1.5;resize:vertical}
.character-editor-form .field-group textarea:focus{outline:2px solid rgba(155,92,255,.4);outline-offset:1px}
.character-editor-image-preview{display:flex;align-items:center;gap:16px;padding:12px;border:1px solid var(--border);border-radius:14px;background:var(--surface-2)}
.character-editor-image-preview img{width:82px;height:82px;border-radius:12px;object-fit:cover;background:#111}
.character-editor-actions{border-top:1px solid var(--border);padding-top:18px}
.character-editor-delete{margin-left:auto;border-color:rgba(239,68,68,.4);color:#ff9b9b}
.character-edit-button{min-height:44px;padding:0 14px;white-space:nowrap}
.characters-page .character-card-actions{margin-top:auto;grid-template-columns:minmax(0,1fr) auto}
@media(max-width:760px){.character-editor-modal,.character-ai-modal{padding:0}.character-editor-card,.character-ai-card{width:100%;max-height:100dvh;min-height:100dvh;border-radius:0;padding:20px 16px calc(24px + env(safe-area-inset-bottom))}.character-editor-grid,.character-ai-controls{grid-template-columns:1fr}.character-create-actions{width:100%}.character-create-button{width:100%}.characters-page .character-card-actions{grid-template-columns:1fr}.character-edit-button{width:100%}.character-editor-delete{margin-left:0}.character-ai-assistant{padding:15px}.character-ai-card .character-ai-assistant{padding:0}.character-ai-assistant-head{align-items:flex-start;flex-direction:column}.character-ai-private-badge{align-self:flex-start}.character-ai-limit-card{align-items:flex-start;flex-direction:column;gap:6px}}

/* Step 66: stable character-card sizing on catalogue grids */
.characters-page .character-grid .character-card {
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.characters-page .character-grid .character-title-row {
    min-width: 0;
}

.characters-page .character-grid .character-title-row h3 {
    display: -webkit-box;
    min-width: 0;
    overflow: hidden;
    overflow-wrap: anywhere;
    line-height: 1.28;
    text-overflow: clip;
    white-space: normal;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.characters-page .character-card-overlay {
    padding-right: 66px;
}

@media (min-width: 761px) {
    .characters-page .character-grid {
        grid-template-columns: repeat(auto-fill, minmax(235px, 1fr));
        gap: 16px;
    }
}

@media (hover: none) {
    .scenario-discovery-card:hover,
    .character-card:hover,
    .story-conversation-card:hover { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}


/* Administrative birthdate lock */
.field-group small.is-locked { color: #fbbf24; font-weight: 650; }
#realBirthdate:disabled { cursor: not-allowed; }

/* Keep the 3.0 editor wider than the shared compact modal defaults. */
#worldEditorModal .world-editor-card {
    width: min(760px, calc(100vw - 28px));
    max-height: min(90dvh, 900px);
    padding: 0;
}

#worldEditorModal .v2-modal-header {
    margin-bottom: 0;
    padding: 22px 22px 0;
}

@media (max-width: 820px) {
    body[data-registered="1"] .mobile-bottom-nav {
        grid-template-columns: repeat(8, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    #worldEditorModal .world-editor-card {
        width: min(100% - 16px, 760px);
        max-height: calc(100dvh - 16px);
    }
}

/* Storyraum 3.0: optional creator surface */
[data-creator-only][hidden] {
    display: none !important;
}

.creator-mode-section-icon {
    color: #dcc2ff;
    background: linear-gradient(145deg, rgba(137, 82, 218, 0.28), rgba(88, 52, 158, 0.12));
}

.creator-mode-card {
    overflow: hidden;
    border-color: rgba(156, 112, 223, 0.25);
    background:
        radial-gradient(circle at 88% 0%, rgba(135, 82, 216, 0.18), transparent 36%),
        var(--panel);
}

body[data-creator-mode="1"] .creator-mode-card {
    border-color: rgba(169, 125, 235, 0.48);
    box-shadow: 0 18px 55px rgba(58, 30, 99, 0.18);
}

.creator-mode-benefits {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin: 22px 0;
}

.creator-mode-benefits > div {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 11px;
    align-items: start;
    min-width: 0;
    padding: 15px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.025);
}

.creator-mode-benefits > div > span {
    display: grid;
    width: 32px;
    height: 32px;
    place-items: center;
    border-radius: 10px;
    color: #dec8ff;
    background: rgba(148, 96, 224, 0.16);
}

.creator-mode-benefits p,
.creator-mode-benefits strong,
.creator-mode-benefits small {
    display: block;
    min-width: 0;
    margin: 0;
}

.creator-mode-benefits small {
    margin-top: 4px;
    color: var(--muted);
    line-height: 1.45;
}

.creator-mode-form {
    gap: 14px;
}

.creator-mode-control {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 18px;
    align-items: center;
    padding: 17px 18px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 18px;
    background: rgba(8, 8, 13, 0.42);
    cursor: pointer;
}

.creator-mode-control strong,
.creator-mode-control small {
    display: block;
}

.creator-mode-control small {
    margin-top: 5px;
    color: var(--muted);
    line-height: 1.45;
}

.creator-mode-control input {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
}

.creator-mode-control i {
    position: relative;
    display: block;
    width: 56px;
    height: 32px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 999px;
    background: #292832;
    transition: background 160ms ease, border-color 160ms ease;
}

.creator-mode-control i::after {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #f8f5ff;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35);
    content: "";
    transition: transform 160ms ease;
}

.creator-mode-control input:checked + i {
    border-color: rgba(183, 137, 247, 0.8);
    background: linear-gradient(135deg, #7d42c8, #a15ce0);
}

.creator-mode-control input:checked + i::after {
    transform: translateX(24px);
}

.creator-mode-control input:focus-visible + i {
    outline: 3px solid rgba(183, 137, 247, 0.38);
    outline-offset: 3px;
}

.creator-mode-control:has(input:disabled) {
    cursor: wait;
    opacity: 0.68;
}

.creator-mode-preservation {
    margin: 0;
    color: #aaa4b5;
    font-size: 0.82rem;
    line-height: 1.5;
}

.creator-mode-actions {
    align-items: center;
}

.creator-mode-actions .form-message {
    flex-basis: 100%;
}

.world-creator-gate {
    max-width: 720px;
    margin-inline: auto;
}

@media (max-width: 820px) {
    body[data-registered="1"] .mobile-bottom-nav {
        grid-template-columns: repeat(7, minmax(0, 1fr));
    }

    body[data-registered="1"][data-creator-mode="1"] .mobile-bottom-nav {
        grid-template-columns: repeat(8, minmax(0, 1fr));
    }

    .creator-mode-benefits {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 560px) {
    .creator-mode-control {
        padding: 15px;
    }

    .creator-mode-actions > button {
        width: 100%;
    }
}

/* =========================================================
   STORYRAUM 3.0: CONTROLLED STORY KNOWLEDGE
========================================================= */
.knowledge3-modal-card {
    width: min(1040px, calc(100vw - 30px));
    max-height: min(940px, calc(100vh - 30px));
    overflow: auto;
}

.knowledge3-intro {
    margin: 0 0 16px;
    color: var(--muted-text, #a9a4b5);
    line-height: 1.55;
}

.knowledge3-content,
.knowledge3-entry-list {
    display: grid;
    gap: 16px;
}

.knowledge3-content[hidden],
#controlledKnowledgeLoading[hidden],
#controlledKnowledgeKnownByField[hidden] {
    display: none !important;
}

.knowledge3-overview,
.knowledge3-form,
.knowledge3-list-section {
    border: 1px solid var(--border-color, rgba(255,255,255,.09));
    border-radius: 20px;
    padding: 17px;
    background: var(--surface-soft, rgba(255,255,255,.025));
}

.knowledge3-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.knowledge3-stat {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    padding: 12px;
    border-radius: 14px;
    background: rgba(255,255,255,.045);
}

.knowledge3-stat strong { font-size: 1.12rem; }
.knowledge3-stat small,
.knowledge3-entry-meta { color: var(--muted-text, #9ca3af); }

.knowledge3-filters {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(150px, .7fr) auto;
    align-items: end;
    gap: 10px;
    margin-top: 12px;
}

.knowledge3-filters label { display: grid; gap: 6px; }
.knowledge3-filters label > span { color: var(--muted-text, #a9a4b5); font-size: .8rem; }
.knowledge3-filters select,
.knowledge3-form select,
.knowledge3-form input,
.knowledge3-form textarea { width: 100%; }

.knowledge3-form { display: grid; gap: 13px; }
.knowledge3-form-grid {
    display: grid;
    grid-template-columns: 1.4fr .8fr .6fr;
    gap: 12px;
}
.knowledge3-scope-grid { grid-template-columns: 1fr 1fr; }
.knowledge3-checks { display: flex; flex-wrap: wrap; gap: 12px 20px; }
.knowledge3-form-actions,
.knowledge3-footer { justify-content: flex-end; }

.knowledge3-section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.knowledge3-section-heading h3 { margin: 3px 0 0; }

.knowledge3-entry-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 16px;
    padding: 16px;
    border: 1px solid rgba(255,255,255,.1);
    border-left: 4px solid rgba(139,92,246,.7);
    border-radius: 16px;
    background: rgba(0,0,0,.16);
}
.knowledge3-entry-card.is-pinned { background: linear-gradient(135deg, rgba(124,58,237,.12), rgba(0,0,0,.16)); }
.knowledge3-entry-card.is-archived { opacity: .7; }
.knowledge3-entry-card.is-secret { border-left-color: #e879f9; }
.knowledge3-entry-card.is-relationship { border-left-color: #fb7185; }
.knowledge3-entry-card.is-condition { border-left-color: #f59e0b; }
.knowledge3-entry-card.is-promise { border-left-color: #38bdf8; }
.knowledge3-entry-card.is-location { border-left-color: #34d399; }
.knowledge3-entry-card.is-open_thread { border-left-color: #a78bfa; }

.knowledge3-entry-body { min-width: 0; }
.knowledge3-entry-body h4 { margin: 10px 0 6px; overflow-wrap: anywhere; }
.knowledge3-entry-body p { margin: 0 0 10px; white-space: pre-wrap; line-height: 1.55; overflow-wrap: anywhere; }
.knowledge3-entry-badges,
.knowledge3-entry-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.knowledge3-entry-actions { align-content: flex-start; justify-content: flex-end; }
.knowledge3-secret-pill { border-color: rgba(232,121,249,.45); background: rgba(232,121,249,.12); }

@media (max-width: 760px) {
    .knowledge3-modal-card { width: calc(100vw - 14px); max-height: calc(100vh - 14px); }
    .knowledge3-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .knowledge3-filters,
    .knowledge3-form-grid,
    .knowledge3-scope-grid,
    .knowledge3-entry-card { grid-template-columns: 1fr; }
    .knowledge3-entry-actions { justify-content: flex-start; }
}

/* =========================================================
   STORYRAUM 3.0: CHARACTER DEVELOPMENT
========================================================= */
.character-development-card {
    width: min(1080px, calc(100vw - 30px));
    max-height: min(950px, calc(100vh - 30px));
    overflow: auto;
}

.character-development-intro {
    margin: 0 0 14px;
    color: var(--muted-text, #aaa4b5);
    line-height: 1.55;
}

.character-development-privacy {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 11px;
    align-items: start;
    margin-bottom: 16px;
    padding: 13px 15px;
    border: 1px solid rgba(167, 139, 250, .28);
    border-radius: 15px;
    background: rgba(124, 58, 237, .09);
}

.character-development-privacy > span { color: #c4b5fd; }
.character-development-privacy p,
.character-development-privacy strong,
.character-development-privacy small { display: block; margin: 0; }
.character-development-privacy small { margin-top: 3px; color: var(--muted-text, #aaa4b5); line-height: 1.45; }

.character-development-content,
.character-development-relationships,
.character-development-history { display: grid; gap: 16px; }
.character-development-content[hidden],
#characterDevelopmentLoading[hidden] { display: none !important; }

.character-development-section {
    padding: 17px;
    border: 1px solid var(--border-color, rgba(255,255,255,.09));
    border-radius: 20px;
    background: var(--surface-soft, rgba(255,255,255,.025));
}

.character-development-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}
.character-development-heading h3 { margin: 3px 0 0; }
.character-development-section-note { margin: -4px 0 14px; color: var(--muted-text, #aaa4b5); line-height: 1.5; }

.character-development-form,
.character-development-relationship-form { display: grid; gap: 14px; }
.character-development-state-grid,
.character-development-relationship-text-grid {
    display: grid;
    grid-template-columns: minmax(220px, .7fr) minmax(300px, 1.3fr);
    gap: 13px;
}
.character-development-form input,
.character-development-form textarea,
.character-development-relationship-form input,
.character-development-relationship-form textarea { width: 100%; }

.character-development-form-footer {
    display: grid;
    grid-template-columns: minmax(220px, .75fr) minmax(280px, 1.25fr);
    gap: 13px;
    align-items: end;
}
.character-development-form-footer .check-field { min-height: 48px; align-items: center; }
.character-development-actions { justify-content: flex-end; }
.character-development-modal-actions { justify-content: flex-end; }

.character-development-relationship-card {
    overflow: hidden;
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 17px;
    background: rgba(0,0,0,.16);
}
.character-development-relationship-card[open] { border-color: rgba(167,139,250,.38); }
.character-development-relationship-card > summary {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    padding: 14px 16px;
    cursor: pointer;
    list-style: none;
}
.character-development-relationship-card > summary::-webkit-details-marker { display: none; }
.character-development-relationship-card > summary::after {
    grid-column: 4;
    color: var(--muted-text, #aaa4b5);
    content: "⌄";
}
.character-development-relationship-card[open] > summary::after { transform: rotate(180deg); }

.character-development-persona-avatar {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    border: 1px solid rgba(167,139,250,.32);
    border-radius: 14px;
    background: rgba(124,58,237,.15);
    color: #e9ddff;
    font-weight: 850;
}
.character-development-persona-copy strong,
.character-development-persona-copy small { display: block; }
.character-development-persona-copy small { margin-top: 3px; color: var(--muted-text, #aaa4b5); }

.character-development-relationship-form {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,.08);
}
.character-development-relationship-visual {
    display: grid;
    grid-template-columns: minmax(230px, .7fr) minmax(330px, 1.3fr);
    gap: 20px;
    align-items: center;
}
.character-development-radar {
    display: block;
    width: min(100%, 300px);
    margin: 0 auto;
    overflow: visible;
}
.character-development-radar-grid,
.character-development-radar-axis { fill: rgba(139,92,246,.025); stroke: rgba(196,181,253,.2); stroke-width: 1; }
.character-development-radar-value { fill: rgba(168,85,247,.28); stroke: #c084fc; stroke-width: 2; }
.character-development-radar-label { fill: #aaa4b5; font-size: 8px; text-anchor: middle; dominant-baseline: central; }

.character-development-sliders { display: grid; gap: 9px; }
.character-development-slider { display: grid; gap: 5px; }
.character-development-slider-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.character-development-slider-heading strong { font-size: .86rem; }
.character-development-slider-heading output {
    min-width: 34px;
    padding: 3px 7px;
    border-radius: 999px;
    background: rgba(168,85,247,.14);
    color: #e2ceff;
    text-align: center;
    font-size: .78rem;
    font-weight: 750;
}
.character-development-slider input[type="range"] { accent-color: #a855f7; }

.character-development-history-section > summary {
    cursor: pointer;
    list-style: none;
}
.character-development-history-section > summary::-webkit-details-marker { display: none; }
.character-development-history-section > summary span { display: block; }
.character-development-history-section > summary strong,
.character-development-history-section > summary small { display: block; }
.character-development-history-section > summary small { margin-top: 4px; color: var(--muted-text, #aaa4b5); }
.character-development-history { margin-top: 14px; }
.character-development-history-row {
    padding: 12px 14px;
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 14px;
    background: rgba(0,0,0,.13);
}
.character-development-history-heading { display: flex; justify-content: space-between; gap: 14px; }
.character-development-history-heading small,
.character-development-history-row > small { color: var(--muted-text, #aaa4b5); }
.character-development-history-row p { margin: 8px 0; white-space: pre-wrap; overflow-wrap: anywhere; }

@media (max-width: 780px) {
    .character-development-card { width: calc(100vw - 14px); max-height: calc(100vh - 14px); }
    .character-development-state-grid,
    .character-development-relationship-text-grid,
    .character-development-form-footer,
    .character-development-relationship-visual { grid-template-columns: 1fr; }
    .character-development-relationship-card > summary { grid-template-columns: auto minmax(0, 1fr); }
    .character-development-relationship-card > summary .pill { grid-column: 2; justify-self: start; }
    .character-development-relationship-card > summary::after { grid-column: 3; grid-row: 1 / span 2; }
    .character-development-actions > button { width: 100%; }
}

/* =========================================================
   STORYRAUM_SEO_VISIBLE_BEGIN
   Compact, visible homepage information for users and search
========================================================= */
.dashboard-seo-intro {
    display: grid;
    grid-template-columns: minmax(260px, .8fr) minmax(0, 1.7fr);
    gap: clamp(22px, 3vw, 38px);
    align-items: start;
    margin-top: clamp(26px, 4vw, 42px);
    padding: clamp(22px, 3vw, 34px);
    border: 1px solid rgba(178, 128, 255, .14);
    border-radius: var(--radius-lg);
    background: rgba(17, 17, 24, .58);
}

.dashboard-seo-copy h2 {
    margin: 8px 0 12px;
    font-size: clamp(1.45rem, 2.6vw, 2.25rem);
    line-height: 1.08;
    letter-spacing: -.035em;
}

.dashboard-seo-copy > p:last-child,
.dashboard-seo-card p {
    color: var(--muted);
    line-height: 1.65;
}

.dashboard-seo-copy > p:last-child {
    margin: 0;
    max-width: 620px;
}

.dashboard-seo-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.dashboard-seo-card {
    min-width: 0;
    padding: 17px 18px;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 17px;
    background: rgba(255, 255, 255, .025);
}

.dashboard-seo-card h3 {
    margin: 9px 0 7px;
    font-size: .98rem;
    line-height: 1.25;
}

.dashboard-seo-card p {
    margin: 0;
    font-size: .87rem;
}

.dashboard-seo-icon {
    display: inline-grid;
    width: 30px;
    height: 30px;
    place-items: center;
    border: 1px solid rgba(155, 92, 255, .22);
    border-radius: 10px;
    background: var(--accent-soft);
    color: #d9c3ff;
    font-size: .82rem;
}

@media (max-width: 900px) {
    .dashboard-seo-intro {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 620px) {
    .dashboard-seo-intro {
        padding: 20px 17px;
        border-radius: 20px;
    }

    .dashboard-seo-grid {
        grid-template-columns: 1fr;
    }
}
/* STORYRAUM_SEO_VISIBLE_END */

/* =========================================================
   STORYRAUM_MOBILE_CHAT_TOOLS_BEGIN
   Compact mobile chat header + overflow tool sheet
========================================================= */

.chat-mobile-more-button {
    display: none;
}

.chat-mobile-tools-layer {
    display: none;
}

body.chat-mobile-tools-open {
    overflow: hidden;
}

@media (max-width: 760px) {
    .chat-header {
        grid-template-columns: auto auto minmax(0, 1fr) auto;
        gap: 8px;
        min-height: 68px;
        padding: 10px 12px;
    }

    .chat-header-actions {
        order: 0;
        flex-wrap: nowrap;
        gap: 6px;
        margin-left: 0;
    }

    .chat-header-actions .icon-button {
        width: 40px;
        min-width: 40px;
        height: 40px;
        min-height: 40px;
        padding: 0;
        border-radius: 12px;
    }

    .chat-avatar {
        width: 42px;
        height: 42px;
    }

    .chat-header-copy p {
        display: none;
    }

    #chatTimelineBtn,
    #chatKnowledgeBtn,
    #chatCharacterDevelopmentBtn,
    #chatCustomizeCharacterBtn,
    #chatMediaBtn,
    #chatSettingsBtn,
    .chat-language-control {
        display: none !important;
    }

    .chat-mobile-more-button {
        display: grid;
        place-items: center;
        font-size: 1.45rem;
        line-height: 1;
    }

    .chat-mobile-tools-layer:not([hidden]) {
        position: fixed;
        inset: 0;
        z-index: 2500;
        display: block;
    }

    .chat-mobile-tools-backdrop {
        position: absolute;
        inset: 0;
        background: rgba(0, 0, 0, .68);
        backdrop-filter: blur(5px);
    }

    .chat-mobile-tools-sheet {
        position: absolute;
        right: 0;
        bottom: 0;
        left: 0;
        max-height: min(72dvh, 620px);
        overflow-y: auto;
        padding:
            18px
            16px
            calc(18px + env(safe-area-inset-bottom));
        border: 1px solid rgba(255, 255, 255, .09);
        border-bottom: 0;
        border-radius: 24px 24px 0 0;
        background: #111116;
        box-shadow: 0 -24px 80px rgba(0, 0, 0, .5);
    }

    .chat-mobile-tools-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 16px;
        margin-bottom: 14px;
    }

    .chat-mobile-tools-header h3 {
        margin: 3px 0 0;
        font-size: 1.25rem;
    }

    .chat-mobile-tools-header .eyebrow {
        margin: 0;
    }

    .chat-mobile-tools-list {
        display: grid;
        gap: 9px;
    }

    .chat-mobile-tool-row {
        display: grid;
        grid-template-columns: 44px minmax(0, 1fr);
        gap: 12px;
        align-items: center;
        width: 100%;
        min-height: 58px;
        padding: 8px 14px 8px 10px;
        border: 1px solid rgba(255, 255, 255, .075);
        border-radius: 15px;
        background: rgba(255, 255, 255, .035);
        color: #f4f1f7;
        font: inherit;
        text-align: left;
        cursor: pointer;
    }

    .chat-mobile-tool-row:hover,
    .chat-mobile-tool-row:focus-visible {
        border-color: rgba(192, 132, 252, .34);
        background: rgba(192, 132, 252, .08);
    }

    .chat-mobile-tool-row:disabled {
        cursor: default;
        opacity: .45;
    }

    .chat-mobile-tool-icon {
        display: grid;
        width: 40px;
        height: 40px;
        place-items: center;
        border: 1px solid rgba(255, 255, 255, .08);
        border-radius: 12px;
        background: rgba(255, 255, 255, .035);
        font-size: 1.05rem;
    }

    .chat-mobile-tool-label {
        min-width: 0;
        overflow-wrap: anywhere;
        font-size: .94rem;
        font-weight: 650;
        line-height: 1.3;
    }

    .chat-mobile-language-row {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 14px;
        align-items: center;
        min-height: 58px;
        padding: 8px 12px 8px 16px;
        border: 1px solid rgba(255, 255, 255, .075);
        border-radius: 15px;
        background: rgba(255, 255, 255, .035);
    }

    .chat-mobile-language-label {
        color: #f4f1f7;
        font-size: .94rem;
        font-weight: 650;
    }

    .chat-mobile-language-select {
        width: auto;
        min-width: 94px;
        height: 40px;
        padding: 0 30px 0 12px;
        border: 1px solid rgba(255, 255, 255, .12);
        border-radius: 999px;
        background: #1a1a24;
        color: #fff;
        font: inherit;
        font-size: .82rem;
        font-weight: 700;
    }
}

@media (max-width: 430px) {
    .chat-header {
        gap: 6px;
        padding-inline: 8px;
    }

    .chat-header-actions {
        gap: 5px;
    }

    .chat-header-actions .icon-button {
        width: 38px;
        min-width: 38px;
        height: 38px;
        min-height: 38px;
    }

    .chat-avatar {
        width: 40px;
        height: 40px;
    }

    .chat-header-copy h2 {
        font-size: .92rem;
    }
}

/* STORYRAUM_MOBILE_CHAT_TOOLS_END */


/* Tarifkarten: Aktionsbereich immer einheitlich unten */
.billing-plan-actions {
    margin-top: auto;
    display: grid;
    gap: 10px;
    width: 100%;
}

.billing-plan-actions > .primary-button,
.billing-plan-actions > .secondary-button {
    width: 100%;
    margin: 0;
    text-align: center;
}


/* private assigned plan highlight */

.billing-plan-heading {
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.billing-plan-heading > div:first-child {
    min-width: 0;
    flex: 1 1 auto;
}

.billing-plan-badges {
    display: flex;
    flex: 0 0 auto;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.4rem;
    margin-left: auto;
}

.billing-plan-card.is-exclusive {
    position: relative;
    overflow: hidden;
    border-color: rgba(168, 85, 247, 0.82);
    background:
        radial-gradient(
            circle at 90% 4%,
            rgba(168, 85, 247, 0.22),
            transparent 35%
        ),
        linear-gradient(
            180deg,
            rgba(124, 58, 237, 0.13),
            rgba(18, 15, 27, 0.98)
        );
    box-shadow:
        0 0 0 1px rgba(168, 85, 247, 0.16),
        0 18px 42px rgba(88, 28, 135, 0.22);
}

.billing-plan-card.is-exclusive::before {
    content: "";
    position: absolute;
    top: 0;
    left: 10%;
    width: 80%;
    height: 2px;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(216, 180, 254, 0.95),
        transparent
    );
    pointer-events: none;
}

.billing-plan-card.is-exclusive .eyebrow {
    color: rgba(216, 180, 254, 0.96);
}

.billing-plan-card.is-exclusive h3 {
    color: rgba(250, 245, 255, 1);
}

.billing-plan-card.is-exclusive .billing-plan-price {
    color: rgba(250, 245, 255, 1);
}

.billing-plan-card.is-exclusive .pill.exclusive {
    border-color: rgba(248, 113, 113, 0.42);
    background: linear-gradient(
        135deg,
        rgba(153, 27, 27, 0.88),
        rgba(220, 38, 38, 0.78)
    );
    color: rgba(255, 241, 242, 1);
    box-shadow: 0 6px 18px rgba(127, 29, 29, 0.30);
}

.billing-plan-card.is-exclusive .billing-plan-exclusive-note {
    color: rgba(253, 230, 138, 0.98);
    text-shadow: 0 0 12px rgba(202, 138, 4, 0.12);
}

@media (max-width: 680px) {
    .billing-plan-heading {
        gap: 0.5rem;
    }

    .billing-plan-badges {
        max-width: 48%;
    }
}

/* =========================================================
   R40.3 – CHARACTER CARD BADGES / OWN CHARACTERS
   ========================================================= */

/*
 * Linke Badge-Seite.
 * Der Favorite-Button bleibt separat absolut rechts oben.
 */
.character-card .character-card-overlay {
    justify-content: flex-start;
}

.character-card .character-badges {
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: flex-start;
    justify-content: flex-start;
    max-width: calc(100% - 58px);
}

.character-card .category-badge {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;

    color: #eee8f8;
    background: rgba(20, 17, 28, .80);
    border-color: rgba(192, 132, 252, .27);
}

/*
 * Adult immer deutlich rot.
 */
.character-card .adult-age-badge {
    color: #fff;
    background: rgba(185, 28, 28, .92);
    border-color: rgba(254, 202, 202, .46);
    font-weight: 900;
    letter-spacing: .025em;
}

/*
 * Eigene Charaktere:
 * kein Herkunfts-Badge nötig.
 * Stattdessen dezente türkise Abgrenzung der Karte.
 */
.character-card.is-own-character {
    border-color: rgba(45, 212, 191, .44);

    box-shadow:
        0 18px 44px rgba(0, 0, 0, .18),
        inset 0 0 0 1px rgba(45, 212, 191, .08);
}

.character-card.is-own-character:hover {
    border-color: rgba(94, 234, 212, .68);

    box-shadow:
        0 24px 55px rgba(0, 0, 0, .27),
        0 0 0 1px rgba(45, 212, 191, .11),
        inset 0 0 30px rgba(20, 184, 166, .05);
}

.characters-page .character-card.is-own-character {
    border-color: rgba(45, 212, 191, .50);
}

/* =========================================================
   R40.3.1 – OWN CHARACTER MODERATE HIGHLIGHT
   ========================================================= */

/*
 * Bewusst nur moderat stärker als r40.3.
 * Falls es im Alltag noch zu dezent wirkt, kann der Effekt
 * später ohne JS-/API-Änderung weiter verstärkt werden.
 */

.character-card.is-own-character {
    border-color: rgba(45, 212, 191, .64);

    box-shadow:
        0 18px 44px rgba(0, 0, 0, .20),
        0 0 0 1px rgba(45, 212, 191, .15),
        0 0 18px rgba(20, 184, 166, .08),
        inset 0 0 24px rgba(20, 184, 166, .055);
}

.character-card.is-own-character:hover {
    border-color: rgba(94, 234, 212, .82);

    box-shadow:
        0 24px 55px rgba(0, 0, 0, .29),
        0 0 0 1px rgba(94, 234, 212, .20),
        0 0 26px rgba(20, 184, 166, .13),
        inset 0 0 32px rgba(20, 184, 166, .075);
}

.characters-page .character-card.is-own-character {
    border-color: rgba(45, 212, 191, .68);
}

/* =========================================================
   R4032_OWN_CHARACTER_STRONGER
   Eigene Charaktere bewusst deutlich sichtbarer.
   ========================================================= */

.character-card.is-own-character {
    border: 2px solid rgba(45, 212, 191, .82);

    background:
        linear-gradient(
            145deg,
            rgba(20, 184, 166, .075),
            rgba(17, 17, 24, .94) 42%
        );

    box-shadow:
        0 18px 44px rgba(0, 0, 0, .22),
        0 0 0 1px rgba(94, 234, 212, .18),
        0 0 24px rgba(20, 184, 166, .16),
        inset 0 0 36px rgba(20, 184, 166, .07);
}

.character-card.is-own-character::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 4;
    pointer-events: none;
    border-radius: inherit;

    background:
        linear-gradient(
            135deg,
            rgba(94, 234, 212, .11),
            transparent 24%,
            transparent 74%,
            rgba(20, 184, 166, .06)
        );
}

.character-card.is-own-character:hover {
    transform: translateY(-4px);

    border-color: rgba(153, 246, 228, .96);

    box-shadow:
        0 25px 58px rgba(0, 0, 0, .32),
        0 0 0 1px rgba(153, 246, 228, .27),
        0 0 36px rgba(20, 184, 166, .24),
        inset 0 0 42px rgba(20, 184, 166, .10);
}

/*
 * Auf der großen Charakterübersicht darf der Rahmen
 * noch etwas klarer wirken.
 */
.characters-page .character-card.is-own-character {
    border-color: rgba(45, 212, 191, .88);
}

/*
 * Bildfläche eigener Charaktere leicht anders einfärben,
 * ohne das eigentliche Bild stark zu verfälschen.
 */
.character-card.is-own-character .character-card-media::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;

    background:
        linear-gradient(
            180deg,
            rgba(20, 184, 166, .035),
            transparent 42%,
            rgba(20, 184, 166, .07)
        );
}

/*
 * Bestehende Ebenen bleiben vor dem zusätzlichen Overlay.
 */
.character-card.is-own-character .character-card-overlay {
    z-index: 2;
}

.character-card.is-own-character .character-card-body {
    z-index: 5;
}

.character-card.is-own-character > .character-card-media > .favorite-button {
    z-index: 6;
}

/* =========================================================
   R4033_CATEGORY_SCROLLER
   Horizontale Charakter-Kategorienavigation
   ========================================================= */

.character-category-scroll-shell {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 6px;

    min-width: 0;
    width: 100%;
    max-width: 100%;
    flex: 1 1 0;
}

.character-category-scroll-viewport {
    min-width: 0;
    overflow: hidden;
}

#characterCategoryChips {
    display: flex;
    flex-wrap: nowrap !important;
    align-items: center;
    gap: 6px;

    min-width: 0;
    max-width: 100%;

    overflow-x: auto !important;
    overflow-y: hidden;

    scroll-behavior: smooth;
    overscroll-behavior-x: contain;
    scrollbar-width: none;

    padding: 2px 1px 5px;
}

#characterCategoryChips::-webkit-scrollbar {
    display: none;
}

#characterCategoryChips > * {
    flex: 0 0 auto;
}

.character-category-scroll-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 31px;
    min-width: 31px;
    height: 31px;

    padding: 0;

    border: 1px solid rgba(192, 132, 252, .24);
    border-radius: 10px;

    background: rgba(28, 23, 35, .92);
    color: #e8ddf6;

    font: inherit;
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1;

    cursor: pointer;

    transition:
        border-color 150ms ease,
        background 150ms ease,
        color 150ms ease,
        opacity 150ms ease,
        transform 150ms ease;
}

.character-category-scroll-button:hover:not(:disabled) {
    border-color: rgba(192, 132, 252, .58);
    background: rgba(126, 34, 206, .25);
    color: #fff;
    transform: scale(1.04);
}

.character-category-scroll-button:disabled {
    opacity: .28;
    cursor: default;
}

.character-category-scroll-button[hidden] {
    display: none !important;
}

/*
 * Wenn kein Überlauf besteht, brauchen die unsichtbaren
 * Buttons auch keinen Platz.
 */
.character-category-scroll-shell:not(.has-overflow) {
    grid-template-columns: minmax(0, 1fr);
}

.character-category-scroll-shell:not(.has-overflow)
.character-category-scroll-viewport {
    grid-column: 1;
}

@media (max-width: 760px) {
    .character-category-scroll-shell {
        gap: 4px;
    }

    .character-category-scroll-button {
        width: 29px;
        min-width: 29px;
        height: 29px;
        border-radius: 9px;
    }
}

/* =========================================================
   R4034_CATEGORY_ICONS_OWN_VIEW
   Kategorieicons + Discovery "Selbst erstellt"
   ========================================================= */

/*
 * Kategorie-Icons werden ausschließlich per ::before
 * dargestellt. Der eigentliche Buttontext bleibt unverändert.
 */
#characterCategoryChips
button[data-category-icon]::before {
    content: attr(data-category-icon);

    display: inline-flex;
    align-items: center;
    justify-content: center;

    flex: 0 0 auto;

    min-width: 1.25em;

    margin-right: .46em;

    font-size: 1.03em;
    line-height: 1;

    opacity: 1;

    pointer-events: none;
}

#characterCategoryChips
button[data-category-icon]:hover::before,
#characterCategoryChips
button[data-category-icon].is-active::before {
    opacity: 1;
}

/*
 * "Selbst erstellt" bekommt passend zur eigenen
 * Character-Kartenfarbe ein kleines Türkis-Icon.
 */
.character-view-own-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    margin-right: .28rem;

    color: rgb(94, 234, 212);

    font-size: .92em;
    font-weight: 900;

    pointer-events: none;
}

.character-view-own-label {
    pointer-events: none;
}

[data-character-view="own"].is-active
.character-view-own-icon {
    color: #d5fffa;
}


/* R4035_CATEGORY_ICON_REFRESH
   Größere und deutlichere Kategorien-Icons */
#characterCategoryChips
button[data-category-icon="🧟"]::before {
    color: #ff4d5f;
    filter: drop-shadow(0 0 6px rgba(255, 77, 95, .20));
}

#characterCategoryChips
button[data-category-icon="❤️"]::before {
    color: #ff4d67;
    filter: drop-shadow(0 0 6px rgba(255, 77, 103, .18));
}

#characterCategoryChips
button[data-category-icon="💮"]::before {
    color: #ff7ac8;
    filter: drop-shadow(0 0 6px rgba(255, 122, 200, .16));
}

#characterCategoryChips
button[data-category-icon="😂"]::before {
    color: #ffd24d;
}

#characterCategoryChips
button[data-category-icon="🪄"]::before,
#characterCategoryChips
button[data-category-icon="🛸"]::before,
#characterCategoryChips
button[data-category-icon="💥"]::before,
#characterCategoryChips
button[data-category-icon="📖"]::before,
#characterCategoryChips
button[data-category-icon="🏠"]::before {
    transform: translateY(.01em);
}



/* R40351_CATEGORY_ICON_TWEAK */

/*
 * Horror darf weiterhin einen leicht roten Akzent haben,
 * obwohl das eigentliche Symbol jetzt ein Zombie ist.
 */
#characterCategoryChips
button[data-category-icon="🧟"]::before {
    filter:
        drop-shadow(
            0 0 6px
            rgba(255, 65, 85, .32)
        );

    transform:
        translateY(.01em)
        scale(1.04);
}

/*
 * Fantasy und Manga minimal größer, damit die Icons
 * bei der kompakten Chip-Höhe gut lesbar bleiben.
 */
#characterCategoryChips
button[data-category-icon="🪄"]::before,
#characterCategoryChips
button[data-category-icon="📖"]::before {
    transform: scale(1.05);
}


/* =========================================================
   R40353_CATEGORY_ICON_TWEAK
   Fantasy -> Kristallkugel
   Anime & Manga -> Comic-Sprechblase
   ========================================================= */

#characterCategoryChips
button[data-category-icon="🔮"]::before {
    transform:
        translateY(.01em)
        scale(1.07);

    filter:
        drop-shadow(
            0 0 6px
            rgba(168, 85, 247, .22)
        );
}

#characterCategoryChips
button[data-category-icon="🗯️"]::before {
    transform:
        translateY(.01em)
        scale(1.12);

    filter:
        drop-shadow(
            0 0 5px
            rgba(236, 72, 153, .14)
        );
}

/* R46_PUBLIC_SEO_INTERNAL_LINKS */
.dashboard-seo-card h3 a{
color:inherit;
text-decoration:none
}
.dashboard-seo-card h3 a:hover{text-decoration:underline}
.dashboard-seo-sub-links{
display:flex;
flex-wrap:wrap;
gap:5px;
margin-top:10px;
font-size:.86rem
}
.dashboard-seo-sub-links a{
color:var(--accent,#c4a7ff);
text-decoration:none
}
.dashboard-seo-sub-links a:hover{text-decoration:underline}

/* USER_FEEDBACK_UI_R2 */

.feedback-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.user-feedback-launcher {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 6750;

    display: inline-flex;
    align-items: center;
    gap: 8px;

    min-height: 42px;
    padding: 9px 13px;

    border: 1px solid rgba(192,132,252,.35);
    border-radius: 999px;

    background:
        linear-gradient(
            135deg,
            rgba(91,33,182,.96),
            rgba(126,34,206,.96)
        );

    color: #fff;
    box-shadow:
        0 10px 30px rgba(0,0,0,.35);

    cursor: pointer;
}

.user-feedback-launcher:hover {
    transform: translateY(-1px);
}

.user-feedback-launcher-icon {
    font-size: 1.05rem;
}

body.feedback-modal-open
.user-feedback-launcher {
    visibility: hidden;
}

.feedback-modal-layer {
    z-index: 6800;
}

.feedback-modal-card {
    width:
        min(
            760px,
            calc(100vw - 32px)
        );

    max-height:
        min(
            900px,
            calc(100dvh - 32px)
        );

    overflow: auto;
}

.feedback-choice-fieldset {
    display: grid;
    gap: 10px;

    margin: 18px 0;
    padding: 0;

    border: 0;
}

.feedback-choice-fieldset > legend {
    margin-bottom: 8px;
    font-weight: 750;
}

.feedback-choice-card {
    display: grid;
    grid-template-columns:
        22px minmax(0, 1fr);

    align-items: start;
    gap: 11px;

    padding: 13px 14px;

    border:
        1px solid var(--border);

    border-radius: 14px;

    background:
        var(--surface-2);

    cursor: pointer;
}

.feedback-choice-card:has(
    input:checked
) {
    border-color:
        rgba(168,85,247,.6);

    background:
        rgba(126,34,206,.09);
}

.feedback-choice-card input {
    margin-top: 3px;
}

.feedback-choice-card span {
    display: grid;
    gap: 3px;
}

.feedback-choice-card small {
    color: var(--muted);
    line-height: 1.4;
}

.feedback-context-card {
    display: grid;
    gap: 4px;

    margin:
        14px 0 18px;

    padding:
        12px 14px;

    border:
        1px solid
        rgba(168,85,247,.2);

    border-radius: 13px;

    background:
        rgba(126,34,206,.05);
}

.feedback-context-card span {
    color: var(--muted);
    overflow-wrap: anywhere;
}

.feedback-list-actions {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 12px;
}

.feedback-list {
    display: grid;
    gap: 12px;
}

.feedback-item {
    display: grid;
    gap: 10px;

    padding: 15px;

    border:
        1px solid var(--border);

    border-radius: 15px;

    background:
        var(--surface-2);
}

.feedback-item-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.feedback-item-title {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.feedback-item-title h3 {
    margin: 0;
    overflow-wrap: anywhere;
}

.feedback-item-meta {
    color: var(--muted);
    font-size: .82rem;
    overflow-wrap: anywhere;
}

.feedback-item-text {
    margin: 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.feedback-status-pill {
    flex: 0 0 auto;
}

.feedback-note {
    padding: 10px 12px;

    border-radius: 11px;

    background:
        rgba(255,255,255,.035);
}

.feedback-note strong {
    display: block;
    margin-bottom: 3px;
}

.feedback-empty {
    margin: 0;
    padding: 16px;

    color: var(--muted);

    text-align: center;
}

@media (max-width: 760px) {
    .user-feedback-launcher {
        right: 12px;

        bottom:
            calc(
                72px
                + env(
                    safe-area-inset-bottom
                )
            );
    }

    .feedback-modal-layer {
        padding: 0;
    }

    .feedback-modal-card {
        width: 100%;

        min-height: 100dvh;
        max-height: 100dvh;

        border-radius: 0;

        padding:
            18px 15px
            calc(
                22px
                + env(
                    safe-area-inset-bottom
                )
            );
    }

    .feedback-item-head {
        display: grid;
    }

    .feedback-status-pill {
        justify-self: start;
    }
}

/*
 * USER_FEEDBACK_STATUS_COLORS_R1
 *
 * Nur Status-Badges unter
 * "Meine Meldungen".
 *
 * Bedeutung bleibt zusätzlich als Text
 * erhalten – keine reine Farbcodierung.
 */

.feedback-status-pill {
    border-width: 1px;
    border-style: solid;
    font-weight: 700;
    transition:
        background-color .16s ease,
        border-color .16s ease,
        color .16s ease;
}


/* Eingegangen · neutral/blau */

.feedback-status-pill.is-submitted {
    background:
        rgba(59, 130, 246, .16);

    border-color:
        rgba(96, 165, 250, .48);

    color:
        #bfdbfe;
}


/* In Prüfung · aufmerksam/orange */

.feedback-status-pill.is-reviewing {
    background:
        rgba(245, 158, 11, .17);

    border-color:
        rgba(245, 158, 11, .52);

    color:
        #fde68a;
}


/* Angenommen · positiv/grün */

.feedback-status-pill.is-accepted {
    background:
        rgba(34, 197, 94, .17);

    border-color:
        rgba(34, 197, 94, .52);

    color:
        #bbf7d0;
}


/* Übertragen · technisch/cyan */

.feedback-status-pill.is-transferred {
    background:
        rgba(6, 182, 212, .17);

    border-color:
        rgba(34, 211, 238, .52);

    color:
        #a5f3fc;
}


/* In Umsetzung · Storyraum-Violett */

.feedback-status-pill.is-in-progress {
    background:
        rgba(139, 92, 246, .19);

    border-color:
        rgba(167, 139, 250, .55);

    color:
        #ddd6fe;
}


/* Erledigt · deutlich abgeschlossen */

.feedback-status-pill.is-done {
    background:
        rgba(16, 185, 129, .20);

    border-color:
        rgba(52, 211, 153, .58);

    color:
        #a7f3d0;
}


/* Abgelehnt · rot */

.feedback-status-pill.is-rejected {
    background:
        rgba(239, 68, 68, .17);

    border-color:
        rgba(248, 113, 113, .55);

    color:
        #fecaca;
}


/* Abgebrochen · gedämpft */

.feedback-status-pill.is-cancelled {
    background:
        rgba(100, 116, 139, .18);

    border-color:
        rgba(148, 163, 184, .42);

    color:
        #cbd5e1;
}


/*
 * USER_FEEDBACK_SIDEBAR_NAV_R1
 *
 * Feedback nur im linken Hauptmenü.
 * Kein Floating-Button und kein Mobile-Bottom-Icon.
 */

.user-feedback-nav-item {
    border: 1px solid rgba(250, 204, 21, .30);
    background: rgba(250, 204, 21, .035);
}

.user-feedback-nav-item:hover,
.user-feedback-nav-item:focus-visible {
    border-color: rgba(250, 204, 21, .58);
    background: rgba(250, 204, 21, .075);
}

.user-feedback-nav-item .user-feedback-launcher-icon {
    display: inline-grid;
    place-items: center;
    flex: 0 0 22px;
    width: 22px;
    height: 22px;
    margin: 0;
    font-size: 1rem;
    line-height: 1;
    color: #fde047;
}


/*
 * USER_FEEDBACK_SIDEBAR_BULB_R1
 *
 * Schlichtes einfarbiges Lampensymbol,
 * passend zur übrigen Hauptnavigation.
 */

.user-feedback-nav-item
.user-feedback-nav-icon {
    color: rgba(253, 224, 71, .92);
}

.user-feedback-nav-item
.user-feedback-nav-icon svg {
    display: block;
    width: 20px;
    height: 20px;
}


/* =========================================================
   DEVELOPMENT #28 ACCOUNT PRIMARY NAV R1
   Horizontale Bereichsnavigation in "Mein Konto"
========================================================= */

.account-primary-nav-shell {
    position: relative;
    margin: 0 0 18px;
}

.account-primary-nav {
    display: flex;
    align-items: stretch;
    gap: 7px;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 6px;
    border: 1px solid rgba(255, 255, 255, .07);
    border-radius: 14px;
    background: rgba(5, 5, 8, .38);
    scrollbar-width: thin;
    scroll-behavior: smooth;
    overscroll-behavior-inline: contain;
}

.account-primary-tab {
    flex: 0 0 auto;
    min-height: 42px;
    padding: 10px 15px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    color: #9f9aa8;
    font: inherit;
    font-size: .84rem;
    font-weight: 650;
    line-height: 1.2;
    white-space: nowrap;
    cursor: pointer;
    transition:
        background .16s ease,
        border-color .16s ease,
        color .16s ease,
        box-shadow .16s ease;
}

.account-primary-tab:hover {
    color: #f3eff8;
    background: rgba(255, 255, 255, .035);
}

.account-primary-tab.is-active {
    color: #f4e8ff;
    border-color: rgba(192, 132, 252, .28);
    background:
        linear-gradient(
            135deg,
            rgba(126, 34, 206, .25),
            rgba(91, 33, 182, .11)
        );
    box-shadow:
        inset 0 0 0 1px
        rgba(168, 85, 247, .05);
}

.account-primary-tab:focus-visible {
    outline: 2px solid #a855f7;
    outline-offset: 2px;
}

.account-primary-panel[hidden],
.page-view[data-page="profile"] >
.account-settings-group[hidden] {
    display: none !important;
}

/*
 * Die bisherigen <details>-Elemente bleiben nur noch
 * als robuste DOM-Hülle erhalten.
 */
.page-view[data-page="profile"] >
.account-settings-group {
    margin: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    overflow: visible;
}

.page-view[data-page="profile"] >
.account-settings-group[open] {
    border: 0;
    background: transparent;
}

.page-view[data-page="profile"] >
.account-settings-group >
.account-settings-group-summary {
    display: none;
}

.page-view[data-page="profile"] >
.account-settings-group >
.account-settings-group-body {
    padding: 0;
}

.page-view[data-page="profile"] >
.account-settings-group >
.account-settings-group-body >
.settings-card:last-child {
    margin-bottom: 0;
}

@media (max-width: 760px) {
    .account-primary-nav-shell {
        margin-bottom: 14px;
    }

    .account-primary-nav {
        gap: 5px;
        padding: 5px;
        scroll-padding-inline: 5px;
    }

    .account-primary-tab {
        min-height: 44px;
        padding: 9px 13px;
        font-size: .8rem;
    }
}


/* DEVELOPMENT #28 ACCOUNT PRIMARY NAV R1 END */

/* =========================================================
   DEVELOPMENT #28 PRIMARY NAV GROUPS R2A
========================================================= */

.nav-group {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.nav-group-toggle {
    width: 100%;
}

.nav-group-chevron {
    margin-left: auto;
    font-size: 1.1rem;
    line-height: 1;
    opacity: .58;
    transform: rotate(0deg);
    transition:
        transform .16s ease,
        opacity .16s ease;
}

.nav-group.is-open
.nav-group-chevron {
    transform: rotate(90deg);
    opacity: .9;
}

.nav-group.has-active-child
> .nav-group-toggle {
    color: #f4e8ff;
    background:
        linear-gradient(
            135deg,
            rgba(126, 34, 206, .16),
            rgba(91, 33, 182, .07)
        );
}

.nav-submenu {
    display: grid;
    gap: 2px;
    margin: 0 0 3px 17px;
    padding: 2px 0 3px 12px;
    border-left: 1px solid rgba(192, 132, 252, .18);
}

.nav-submenu[hidden] {
    display: none !important;
}

.nav-subitem {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 38px;
    padding: 8px 10px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--muted, #a9a5b3);
    font: inherit;
    font-size: .86rem;
    line-height: 1.25;
    text-align: left;
    cursor: pointer;
}

.nav-subitem
> span:first-child {
    display: grid;
    place-items: center;
    width: 18px;
    min-width: 18px;
    opacity: .78;
}

.nav-subitem:hover,
.nav-subitem:focus-visible {
    color: #f4eff8;
    background: rgba(255, 255, 255, .045);
}

.nav-subitem.is-active,
.nav-subitem[aria-current="page"] {
    color: #f4e8ff;
    background:
        linear-gradient(
            135deg,
            rgba(126, 34, 206, .23),
            rgba(91, 33, 182, .09)
        );
}

.nav-subitem:focus-visible,
.nav-group-toggle:focus-visible {
    outline: 2px solid #a855f7;
    outline-offset: 2px;
}


/*
 * Creator, Galerie und Feedback sind jetzt
 * eigene Page-Views.
 */
.standalone-feature-page
> details.account-settings-group {
    display: block;
    margin: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    overflow: visible;
}

.standalone-feature-page
> details.account-settings-group
> .account-settings-group-summary {
    display: none;
}

.standalone-feature-page
> details.account-settings-group
> .account-settings-group-body {
    padding: 0;
}


/*
 * Altersanzeige:
 * Die Zahl mit "Jahre" erhält auf breiteren
 * Layouts einen festen eigenen Bereich.
 */
.policy-inline-card
> .age-display {
    display: flex;
    flex: 0 0 128px;
    align-items: baseline;
    gap: 7px;
    min-width: 128px;
    max-width: 128px;
    white-space: nowrap;
}

.policy-inline-card
> .age-display
+ div {
    flex: 1 1 auto;
    min-width: 0;
}

@media (max-width: 640px) {
    .policy-inline-card
    > .age-display {
        flex-basis: auto;
        width: auto;
        min-width: 0;
        max-width: none;
    }
}


/* DEVELOPMENT #28 PRIMARY NAV GROUPS R2A END */

/* =========================================================
   DEVELOPMENT #28 MOBILE NAV R2B
   Maximal fünf mobile Hauptaktionen.
========================================================= */

@media (max-width: 820px) {
    .mobile-bottom-nav {
        grid-template-columns:
            repeat(5, minmax(0, 1fr));
    }

    /*
     * Diese beiden Selektoren bleiben bewusst erhalten,
     * weil Worlds/Creator-Quality ihre responsive
     * Existenz separat absichert.
     */
    body[data-registered="1"]
    .mobile-bottom-nav {
        grid-template-columns:
            repeat(5, minmax(0, 1fr));
    }

    body[data-registered="1"][data-creator-mode="1"]
    .mobile-bottom-nav {
        grid-template-columns:
            repeat(5, minmax(0, 1fr));
    }

    .bottom-nav-item small {
        display: block;
        width: 100%;
        min-width: 0;
        overflow: hidden;
        text-align: center;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .bottom-nav-item[aria-current="true"],
    .bottom-nav-item.is-active {
        color: var(--text);
    }
}


/* DEVELOPMENT #28 MOBILE NAV R2B END */

/* =========================================================
   DEVELOPMENT #30 R30-R1C CONSENT BOTTOM BAR

   Nur BASE-Consent wird non-modal dargestellt.
   Adult-Freigaben verwenden weiterhin das bestehende Modal.
========================================================= */

.compliance-gate-modal.is-bottom-bar {
    inset: auto 0 0 0;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding:
        0
        18px
        calc(18px + env(safe-area-inset-bottom, 0px));
    pointer-events: none;
}

.compliance-gate-modal.is-bottom-bar > .modal-backdrop {
    display: none;
}

.compliance-gate-modal.is-bottom-bar .compliance-modal-card {
    width: min(1040px, calc(100vw - 36px));
    max-width: 1040px;
    max-height: min(56dvh, 540px);
    padding: 15px 17px;
    overflow-y: auto;
    pointer-events: auto;
    border:
        1px solid
        rgba(168, 85, 247, 0.28);
    border-radius: 18px;
    background:
        linear-gradient(
            145deg,
            rgba(22, 19, 31, 0.98),
            rgba(13, 13, 18, 0.97)
        );
    box-shadow:
        0 18px 54px rgba(0, 0, 0, 0.46),
        0 0 0 1px rgba(255, 255, 255, 0.025);
    backdrop-filter: blur(18px);
}

.compliance-gate-modal.is-bottom-bar .v2-modal-header {
    margin-bottom: 7px;
}

.compliance-gate-modal.is-bottom-bar .v2-modal-header .eyebrow {
    margin-bottom: 2px;
    font-size: 0.66rem;
}

.compliance-gate-modal.is-bottom-bar .v2-modal-header h2 {
    font-size: clamp(1rem, 2vw, 1.16rem);
    line-height: 1.2;
}

.compliance-gate-modal.is-bottom-bar #complianceGateIntro {
    margin: 0;
    padding: 8px 10px;
    border-radius: 11px;
    font-size: 0.8rem;
    line-height: 1.35;
}

.compliance-gate-modal.is-bottom-bar .compliance-gate-documents {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin: 8px 0;
}

.compliance-gate-modal.is-bottom-bar .compliance-gate-document {
    flex: 0 1 auto;
    padding: 7px 10px;
    border-radius: 10px;
    font-size: 0.78rem;
}

.compliance-gate-modal.is-bottom-bar #complianceBaseConsentFields {
    display: grid;
    grid-template-columns:
        repeat(
            2,
            minmax(0, 1fr)
        );
    gap: 8px;
}

.compliance-gate-modal.is-bottom-bar .check-field {
    min-height: 42px;
    margin: 0;
    padding: 8px 10px;
    border-radius: 11px;
    font-size: 0.79rem;
    line-height: 1.3;
}

.compliance-gate-modal.is-bottom-bar #complianceGateMessage:empty {
    display: none;
}

.compliance-gate-modal.is-bottom-bar #complianceGateMessage {
    margin-top: 7px;
}

.compliance-gate-modal.is-bottom-bar .modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 9px;
}

.compliance-gate-modal.is-bottom-bar .modal-actions button {
    min-height: 38px;
    padding: 7px 13px;
    font-size: 0.8rem;
}


/*
 * Tablet / Mobile:
 * Bottom-Bar wird breiter und Inhalte werden gestapelt,
 * bleibt aber weiterhin non-modal.
 */
@media (max-width: 760px) {
    .compliance-gate-modal.is-bottom-bar {
        padding:
            0
            8px
            calc(8px + env(safe-area-inset-bottom, 0px));
    }

    .compliance-gate-modal.is-bottom-bar .compliance-modal-card {
        width: 100%;
        max-height: min(72dvh, 650px);
        padding: 13px;
        border-radius: 16px;
    }

    .compliance-gate-modal.is-bottom-bar #complianceBaseConsentFields {
        grid-template-columns: 1fr;
    }

    .compliance-gate-modal.is-bottom-bar .modal-actions {
        display: grid;
        grid-template-columns:
            repeat(
                2,
                minmax(0, 1fr)
            );
    }

    .compliance-gate-modal.is-bottom-bar .modal-actions button {
        width: 100%;
    }
}


@media (max-width: 460px) {
    .compliance-gate-modal.is-bottom-bar .compliance-gate-documents {
        display: grid;
        grid-template-columns: 1fr;
    }

    .compliance-gate-modal.is-bottom-bar .compliance-gate-document {
        width: 100%;
    }
}


/*
 * R78_BROWSER_INDEPENDENT_LANGUAGE_FLAGS
 * R78_DYNAMIC_LOCAL_COUNTRY_FLAGSET
 *
 * Standard ist die lokale Globe-Grafik.
 * Bei einer Unicode-Länderflagge ergänzt app.js
 * dynamisch eine Country-Klasse. Alle URLs bleiben
 * relativ zum Stylesheet und funktionieren dadurch
 * auch im Staging-Pfad.
 */
select.storyraum-language-flag-select {
    background-image: url("../flags/globe.svg");
    background-repeat: no-repeat;
    background-position: 11px 50%;
    background-size: 21px 14px;
    padding-left: 40px;
}

select.storyraum-language-flag-country-ad {
    background-image: url("../flags/country/ad.svg");
}

select.storyraum-language-flag-country-ae {
    background-image: url("../flags/country/ae.svg");
}

select.storyraum-language-flag-country-af {
    background-image: url("../flags/country/af.svg");
}

select.storyraum-language-flag-country-ag {
    background-image: url("../flags/country/ag.svg");
}

select.storyraum-language-flag-country-ai {
    background-image: url("../flags/country/ai.svg");
}

select.storyraum-language-flag-country-al {
    background-image: url("../flags/country/al.svg");
}

select.storyraum-language-flag-country-am {
    background-image: url("../flags/country/am.svg");
}

select.storyraum-language-flag-country-ao {
    background-image: url("../flags/country/ao.svg");
}

select.storyraum-language-flag-country-aq {
    background-image: url("../flags/country/aq.svg");
}

select.storyraum-language-flag-country-ar {
    background-image: url("../flags/country/ar.svg");
}

select.storyraum-language-flag-country-as {
    background-image: url("../flags/country/as.svg");
}

select.storyraum-language-flag-country-at {
    background-image: url("../flags/country/at.svg");
}

select.storyraum-language-flag-country-au {
    background-image: url("../flags/country/au.svg");
}

select.storyraum-language-flag-country-aw {
    background-image: url("../flags/country/aw.svg");
}

select.storyraum-language-flag-country-ax {
    background-image: url("../flags/country/ax.svg");
}

select.storyraum-language-flag-country-az {
    background-image: url("../flags/country/az.svg");
}

select.storyraum-language-flag-country-ba {
    background-image: url("../flags/country/ba.svg");
}

select.storyraum-language-flag-country-bb {
    background-image: url("../flags/country/bb.svg");
}

select.storyraum-language-flag-country-bd {
    background-image: url("../flags/country/bd.svg");
}

select.storyraum-language-flag-country-be {
    background-image: url("../flags/country/be.svg");
}

select.storyraum-language-flag-country-bf {
    background-image: url("../flags/country/bf.svg");
}

select.storyraum-language-flag-country-bg {
    background-image: url("../flags/country/bg.svg");
}

select.storyraum-language-flag-country-bh {
    background-image: url("../flags/country/bh.svg");
}

select.storyraum-language-flag-country-bi {
    background-image: url("../flags/country/bi.svg");
}

select.storyraum-language-flag-country-bj {
    background-image: url("../flags/country/bj.svg");
}

select.storyraum-language-flag-country-bl {
    background-image: url("../flags/country/bl.svg");
}

select.storyraum-language-flag-country-bm {
    background-image: url("../flags/country/bm.svg");
}

select.storyraum-language-flag-country-bn {
    background-image: url("../flags/country/bn.svg");
}

select.storyraum-language-flag-country-bo {
    background-image: url("../flags/country/bo.svg");
}

select.storyraum-language-flag-country-bq {
    background-image: url("../flags/country/bq.svg");
}

select.storyraum-language-flag-country-br {
    background-image: url("../flags/country/br.svg");
}

select.storyraum-language-flag-country-bs {
    background-image: url("../flags/country/bs.svg");
}

select.storyraum-language-flag-country-bt {
    background-image: url("../flags/country/bt.svg");
}

select.storyraum-language-flag-country-bv {
    background-image: url("../flags/country/bv.svg");
}

select.storyraum-language-flag-country-bw {
    background-image: url("../flags/country/bw.svg");
}

select.storyraum-language-flag-country-by {
    background-image: url("../flags/country/by.svg");
}

select.storyraum-language-flag-country-bz {
    background-image: url("../flags/country/bz.svg");
}

select.storyraum-language-flag-country-ca {
    background-image: url("../flags/country/ca.svg");
}

select.storyraum-language-flag-country-cc {
    background-image: url("../flags/country/cc.svg");
}

select.storyraum-language-flag-country-cd {
    background-image: url("../flags/country/cd.svg");
}

select.storyraum-language-flag-country-cf {
    background-image: url("../flags/country/cf.svg");
}

select.storyraum-language-flag-country-cg {
    background-image: url("../flags/country/cg.svg");
}

select.storyraum-language-flag-country-ch {
    background-image: url("../flags/country/ch.svg");
}

select.storyraum-language-flag-country-ci {
    background-image: url("../flags/country/ci.svg");
}

select.storyraum-language-flag-country-ck {
    background-image: url("../flags/country/ck.svg");
}

select.storyraum-language-flag-country-cl {
    background-image: url("../flags/country/cl.svg");
}

select.storyraum-language-flag-country-cm {
    background-image: url("../flags/country/cm.svg");
}

select.storyraum-language-flag-country-cn {
    background-image: url("../flags/country/cn.svg");
}

select.storyraum-language-flag-country-co {
    background-image: url("../flags/country/co.svg");
}

select.storyraum-language-flag-country-cp {
    background-image: url("../flags/country/cp.svg");
}

select.storyraum-language-flag-country-cr {
    background-image: url("../flags/country/cr.svg");
}

select.storyraum-language-flag-country-cu {
    background-image: url("../flags/country/cu.svg");
}

select.storyraum-language-flag-country-cv {
    background-image: url("../flags/country/cv.svg");
}

select.storyraum-language-flag-country-cw {
    background-image: url("../flags/country/cw.svg");
}

select.storyraum-language-flag-country-cx {
    background-image: url("../flags/country/cx.svg");
}

select.storyraum-language-flag-country-cy {
    background-image: url("../flags/country/cy.svg");
}

select.storyraum-language-flag-country-cz {
    background-image: url("../flags/country/cz.svg");
}

select.storyraum-language-flag-country-de {
    background-image: url("../flags/country/de.svg");
}

select.storyraum-language-flag-country-dg {
    background-image: url("../flags/country/dg.svg");
}

select.storyraum-language-flag-country-dj {
    background-image: url("../flags/country/dj.svg");
}

select.storyraum-language-flag-country-dk {
    background-image: url("../flags/country/dk.svg");
}

select.storyraum-language-flag-country-dm {
    background-image: url("../flags/country/dm.svg");
}

select.storyraum-language-flag-country-do {
    background-image: url("../flags/country/do.svg");
}

select.storyraum-language-flag-country-dz {
    background-image: url("../flags/country/dz.svg");
}

select.storyraum-language-flag-country-ec {
    background-image: url("../flags/country/ec.svg");
}

select.storyraum-language-flag-country-ee {
    background-image: url("../flags/country/ee.svg");
}

select.storyraum-language-flag-country-eg {
    background-image: url("../flags/country/eg.svg");
}

select.storyraum-language-flag-country-eh {
    background-image: url("../flags/country/eh.svg");
}

select.storyraum-language-flag-country-er {
    background-image: url("../flags/country/er.svg");
}

select.storyraum-language-flag-country-es {
    background-image: url("../flags/country/es.svg");
}

select.storyraum-language-flag-country-et {
    background-image: url("../flags/country/et.svg");
}

select.storyraum-language-flag-country-eu {
    background-image: url("../flags/country/eu.svg");
}

select.storyraum-language-flag-country-fi {
    background-image: url("../flags/country/fi.svg");
}

select.storyraum-language-flag-country-fj {
    background-image: url("../flags/country/fj.svg");
}

select.storyraum-language-flag-country-fk {
    background-image: url("../flags/country/fk.svg");
}

select.storyraum-language-flag-country-fm {
    background-image: url("../flags/country/fm.svg");
}

select.storyraum-language-flag-country-fo {
    background-image: url("../flags/country/fo.svg");
}

select.storyraum-language-flag-country-fr {
    background-image: url("../flags/country/fr.svg");
}

select.storyraum-language-flag-country-ga {
    background-image: url("../flags/country/ga.svg");
}

select.storyraum-language-flag-country-gb {
    background-image: url("../flags/country/gb.svg");
}

select.storyraum-language-flag-country-gd {
    background-image: url("../flags/country/gd.svg");
}

select.storyraum-language-flag-country-ge {
    background-image: url("../flags/country/ge.svg");
}

select.storyraum-language-flag-country-gf {
    background-image: url("../flags/country/gf.svg");
}

select.storyraum-language-flag-country-gg {
    background-image: url("../flags/country/gg.svg");
}

select.storyraum-language-flag-country-gh {
    background-image: url("../flags/country/gh.svg");
}

select.storyraum-language-flag-country-gi {
    background-image: url("../flags/country/gi.svg");
}

select.storyraum-language-flag-country-gl {
    background-image: url("../flags/country/gl.svg");
}

select.storyraum-language-flag-country-gm {
    background-image: url("../flags/country/gm.svg");
}

select.storyraum-language-flag-country-gn {
    background-image: url("../flags/country/gn.svg");
}

select.storyraum-language-flag-country-gp {
    background-image: url("../flags/country/gp.svg");
}

select.storyraum-language-flag-country-gq {
    background-image: url("../flags/country/gq.svg");
}

select.storyraum-language-flag-country-gr {
    background-image: url("../flags/country/gr.svg");
}

select.storyraum-language-flag-country-gs {
    background-image: url("../flags/country/gs.svg");
}

select.storyraum-language-flag-country-gt {
    background-image: url("../flags/country/gt.svg");
}

select.storyraum-language-flag-country-gu {
    background-image: url("../flags/country/gu.svg");
}

select.storyraum-language-flag-country-gw {
    background-image: url("../flags/country/gw.svg");
}

select.storyraum-language-flag-country-gy {
    background-image: url("../flags/country/gy.svg");
}

select.storyraum-language-flag-country-hk {
    background-image: url("../flags/country/hk.svg");
}

select.storyraum-language-flag-country-hm {
    background-image: url("../flags/country/hm.svg");
}

select.storyraum-language-flag-country-hn {
    background-image: url("../flags/country/hn.svg");
}

select.storyraum-language-flag-country-hr {
    background-image: url("../flags/country/hr.svg");
}

select.storyraum-language-flag-country-ht {
    background-image: url("../flags/country/ht.svg");
}

select.storyraum-language-flag-country-hu {
    background-image: url("../flags/country/hu.svg");
}

select.storyraum-language-flag-country-ic {
    background-image: url("../flags/country/ic.svg");
}

select.storyraum-language-flag-country-id {
    background-image: url("../flags/country/id.svg");
}

select.storyraum-language-flag-country-ie {
    background-image: url("../flags/country/ie.svg");
}

select.storyraum-language-flag-country-il {
    background-image: url("../flags/country/il.svg");
}

select.storyraum-language-flag-country-im {
    background-image: url("../flags/country/im.svg");
}

select.storyraum-language-flag-country-in {
    background-image: url("../flags/country/in.svg");
}

select.storyraum-language-flag-country-io {
    background-image: url("../flags/country/io.svg");
}

select.storyraum-language-flag-country-iq {
    background-image: url("../flags/country/iq.svg");
}

select.storyraum-language-flag-country-ir {
    background-image: url("../flags/country/ir.svg");
}

select.storyraum-language-flag-country-is {
    background-image: url("../flags/country/is.svg");
}

select.storyraum-language-flag-country-it {
    background-image: url("../flags/country/it.svg");
}

select.storyraum-language-flag-country-je {
    background-image: url("../flags/country/je.svg");
}

select.storyraum-language-flag-country-jm {
    background-image: url("../flags/country/jm.svg");
}

select.storyraum-language-flag-country-jo {
    background-image: url("../flags/country/jo.svg");
}

select.storyraum-language-flag-country-jp {
    background-image: url("../flags/country/jp.svg");
}

select.storyraum-language-flag-country-ke {
    background-image: url("../flags/country/ke.svg");
}

select.storyraum-language-flag-country-kg {
    background-image: url("../flags/country/kg.svg");
}

select.storyraum-language-flag-country-kh {
    background-image: url("../flags/country/kh.svg");
}

select.storyraum-language-flag-country-ki {
    background-image: url("../flags/country/ki.svg");
}

select.storyraum-language-flag-country-km {
    background-image: url("../flags/country/km.svg");
}

select.storyraum-language-flag-country-kn {
    background-image: url("../flags/country/kn.svg");
}

select.storyraum-language-flag-country-kp {
    background-image: url("../flags/country/kp.svg");
}

select.storyraum-language-flag-country-kr {
    background-image: url("../flags/country/kr.svg");
}

select.storyraum-language-flag-country-kw {
    background-image: url("../flags/country/kw.svg");
}

select.storyraum-language-flag-country-ky {
    background-image: url("../flags/country/ky.svg");
}

select.storyraum-language-flag-country-kz {
    background-image: url("../flags/country/kz.svg");
}

select.storyraum-language-flag-country-la {
    background-image: url("../flags/country/la.svg");
}

select.storyraum-language-flag-country-lb {
    background-image: url("../flags/country/lb.svg");
}

select.storyraum-language-flag-country-lc {
    background-image: url("../flags/country/lc.svg");
}

select.storyraum-language-flag-country-li {
    background-image: url("../flags/country/li.svg");
}

select.storyraum-language-flag-country-lk {
    background-image: url("../flags/country/lk.svg");
}

select.storyraum-language-flag-country-lr {
    background-image: url("../flags/country/lr.svg");
}

select.storyraum-language-flag-country-ls {
    background-image: url("../flags/country/ls.svg");
}

select.storyraum-language-flag-country-lt {
    background-image: url("../flags/country/lt.svg");
}

select.storyraum-language-flag-country-lu {
    background-image: url("../flags/country/lu.svg");
}

select.storyraum-language-flag-country-lv {
    background-image: url("../flags/country/lv.svg");
}

select.storyraum-language-flag-country-ly {
    background-image: url("../flags/country/ly.svg");
}

select.storyraum-language-flag-country-ma {
    background-image: url("../flags/country/ma.svg");
}

select.storyraum-language-flag-country-mc {
    background-image: url("../flags/country/mc.svg");
}

select.storyraum-language-flag-country-md {
    background-image: url("../flags/country/md.svg");
}

select.storyraum-language-flag-country-me {
    background-image: url("../flags/country/me.svg");
}

select.storyraum-language-flag-country-mf {
    background-image: url("../flags/country/mf.svg");
}

select.storyraum-language-flag-country-mg {
    background-image: url("../flags/country/mg.svg");
}

select.storyraum-language-flag-country-mh {
    background-image: url("../flags/country/mh.svg");
}

select.storyraum-language-flag-country-mk {
    background-image: url("../flags/country/mk.svg");
}

select.storyraum-language-flag-country-ml {
    background-image: url("../flags/country/ml.svg");
}

select.storyraum-language-flag-country-mm {
    background-image: url("../flags/country/mm.svg");
}

select.storyraum-language-flag-country-mn {
    background-image: url("../flags/country/mn.svg");
}

select.storyraum-language-flag-country-mo {
    background-image: url("../flags/country/mo.svg");
}

select.storyraum-language-flag-country-mp {
    background-image: url("../flags/country/mp.svg");
}

select.storyraum-language-flag-country-mq {
    background-image: url("../flags/country/mq.svg");
}

select.storyraum-language-flag-country-mr {
    background-image: url("../flags/country/mr.svg");
}

select.storyraum-language-flag-country-ms {
    background-image: url("../flags/country/ms.svg");
}

select.storyraum-language-flag-country-mt {
    background-image: url("../flags/country/mt.svg");
}

select.storyraum-language-flag-country-mu {
    background-image: url("../flags/country/mu.svg");
}

select.storyraum-language-flag-country-mv {
    background-image: url("../flags/country/mv.svg");
}

select.storyraum-language-flag-country-mw {
    background-image: url("../flags/country/mw.svg");
}

select.storyraum-language-flag-country-mx {
    background-image: url("../flags/country/mx.svg");
}

select.storyraum-language-flag-country-my {
    background-image: url("../flags/country/my.svg");
}

select.storyraum-language-flag-country-mz {
    background-image: url("../flags/country/mz.svg");
}

select.storyraum-language-flag-country-na {
    background-image: url("../flags/country/na.svg");
}

select.storyraum-language-flag-country-nc {
    background-image: url("../flags/country/nc.svg");
}

select.storyraum-language-flag-country-ne {
    background-image: url("../flags/country/ne.svg");
}

select.storyraum-language-flag-country-nf {
    background-image: url("../flags/country/nf.svg");
}

select.storyraum-language-flag-country-ng {
    background-image: url("../flags/country/ng.svg");
}

select.storyraum-language-flag-country-ni {
    background-image: url("../flags/country/ni.svg");
}

select.storyraum-language-flag-country-nl {
    background-image: url("../flags/country/nl.svg");
}

select.storyraum-language-flag-country-no {
    background-image: url("../flags/country/no.svg");
}

select.storyraum-language-flag-country-np {
    background-image: url("../flags/country/np.svg");
}

select.storyraum-language-flag-country-nr {
    background-image: url("../flags/country/nr.svg");
}

select.storyraum-language-flag-country-nu {
    background-image: url("../flags/country/nu.svg");
}

select.storyraum-language-flag-country-nz {
    background-image: url("../flags/country/nz.svg");
}

select.storyraum-language-flag-country-om {
    background-image: url("../flags/country/om.svg");
}

select.storyraum-language-flag-country-pa {
    background-image: url("../flags/country/pa.svg");
}

select.storyraum-language-flag-country-pc {
    background-image: url("../flags/country/pc.svg");
}

select.storyraum-language-flag-country-pe {
    background-image: url("../flags/country/pe.svg");
}

select.storyraum-language-flag-country-pf {
    background-image: url("../flags/country/pf.svg");
}

select.storyraum-language-flag-country-pg {
    background-image: url("../flags/country/pg.svg");
}

select.storyraum-language-flag-country-ph {
    background-image: url("../flags/country/ph.svg");
}

select.storyraum-language-flag-country-pk {
    background-image: url("../flags/country/pk.svg");
}

select.storyraum-language-flag-country-pl {
    background-image: url("../flags/country/pl.svg");
}

select.storyraum-language-flag-country-pm {
    background-image: url("../flags/country/pm.svg");
}

select.storyraum-language-flag-country-pn {
    background-image: url("../flags/country/pn.svg");
}

select.storyraum-language-flag-country-pr {
    background-image: url("../flags/country/pr.svg");
}

select.storyraum-language-flag-country-ps {
    background-image: url("../flags/country/ps.svg");
}

select.storyraum-language-flag-country-pt {
    background-image: url("../flags/country/pt.svg");
}

select.storyraum-language-flag-country-pw {
    background-image: url("../flags/country/pw.svg");
}

select.storyraum-language-flag-country-py {
    background-image: url("../flags/country/py.svg");
}

select.storyraum-language-flag-country-qa {
    background-image: url("../flags/country/qa.svg");
}

select.storyraum-language-flag-country-re {
    background-image: url("../flags/country/re.svg");
}

select.storyraum-language-flag-country-ro {
    background-image: url("../flags/country/ro.svg");
}

select.storyraum-language-flag-country-rs {
    background-image: url("../flags/country/rs.svg");
}

select.storyraum-language-flag-country-ru {
    background-image: url("../flags/country/ru.svg");
}

select.storyraum-language-flag-country-rw {
    background-image: url("../flags/country/rw.svg");
}

select.storyraum-language-flag-country-sa {
    background-image: url("../flags/country/sa.svg");
}

select.storyraum-language-flag-country-sb {
    background-image: url("../flags/country/sb.svg");
}

select.storyraum-language-flag-country-sc {
    background-image: url("../flags/country/sc.svg");
}

select.storyraum-language-flag-country-sd {
    background-image: url("../flags/country/sd.svg");
}

select.storyraum-language-flag-country-se {
    background-image: url("../flags/country/se.svg");
}

select.storyraum-language-flag-country-sg {
    background-image: url("../flags/country/sg.svg");
}

select.storyraum-language-flag-country-sh {
    background-image: url("../flags/country/sh.svg");
}

select.storyraum-language-flag-country-si {
    background-image: url("../flags/country/si.svg");
}

select.storyraum-language-flag-country-sj {
    background-image: url("../flags/country/sj.svg");
}

select.storyraum-language-flag-country-sk {
    background-image: url("../flags/country/sk.svg");
}

select.storyraum-language-flag-country-sl {
    background-image: url("../flags/country/sl.svg");
}

select.storyraum-language-flag-country-sm {
    background-image: url("../flags/country/sm.svg");
}

select.storyraum-language-flag-country-sn {
    background-image: url("../flags/country/sn.svg");
}

select.storyraum-language-flag-country-so {
    background-image: url("../flags/country/so.svg");
}

select.storyraum-language-flag-country-sr {
    background-image: url("../flags/country/sr.svg");
}

select.storyraum-language-flag-country-ss {
    background-image: url("../flags/country/ss.svg");
}

select.storyraum-language-flag-country-st {
    background-image: url("../flags/country/st.svg");
}

select.storyraum-language-flag-country-sv {
    background-image: url("../flags/country/sv.svg");
}

select.storyraum-language-flag-country-sx {
    background-image: url("../flags/country/sx.svg");
}

select.storyraum-language-flag-country-sy {
    background-image: url("../flags/country/sy.svg");
}

select.storyraum-language-flag-country-sz {
    background-image: url("../flags/country/sz.svg");
}

select.storyraum-language-flag-country-tc {
    background-image: url("../flags/country/tc.svg");
}

select.storyraum-language-flag-country-td {
    background-image: url("../flags/country/td.svg");
}

select.storyraum-language-flag-country-tf {
    background-image: url("../flags/country/tf.svg");
}

select.storyraum-language-flag-country-tg {
    background-image: url("../flags/country/tg.svg");
}

select.storyraum-language-flag-country-th {
    background-image: url("../flags/country/th.svg");
}

select.storyraum-language-flag-country-tj {
    background-image: url("../flags/country/tj.svg");
}

select.storyraum-language-flag-country-tk {
    background-image: url("../flags/country/tk.svg");
}

select.storyraum-language-flag-country-tl {
    background-image: url("../flags/country/tl.svg");
}

select.storyraum-language-flag-country-tm {
    background-image: url("../flags/country/tm.svg");
}

select.storyraum-language-flag-country-tn {
    background-image: url("../flags/country/tn.svg");
}

select.storyraum-language-flag-country-to {
    background-image: url("../flags/country/to.svg");
}

select.storyraum-language-flag-country-tr {
    background-image: url("../flags/country/tr.svg");
}

select.storyraum-language-flag-country-tt {
    background-image: url("../flags/country/tt.svg");
}

select.storyraum-language-flag-country-tv {
    background-image: url("../flags/country/tv.svg");
}

select.storyraum-language-flag-country-tw {
    background-image: url("../flags/country/tw.svg");
}

select.storyraum-language-flag-country-tz {
    background-image: url("../flags/country/tz.svg");
}

select.storyraum-language-flag-country-ua {
    background-image: url("../flags/country/ua.svg");
}

select.storyraum-language-flag-country-ug {
    background-image: url("../flags/country/ug.svg");
}

select.storyraum-language-flag-country-um {
    background-image: url("../flags/country/um.svg");
}

select.storyraum-language-flag-country-un {
    background-image: url("../flags/country/un.svg");
}

select.storyraum-language-flag-country-us {
    background-image: url("../flags/country/us.svg");
}

select.storyraum-language-flag-country-uy {
    background-image: url("../flags/country/uy.svg");
}

select.storyraum-language-flag-country-uz {
    background-image: url("../flags/country/uz.svg");
}

select.storyraum-language-flag-country-va {
    background-image: url("../flags/country/va.svg");
}

select.storyraum-language-flag-country-vc {
    background-image: url("../flags/country/vc.svg");
}

select.storyraum-language-flag-country-ve {
    background-image: url("../flags/country/ve.svg");
}

select.storyraum-language-flag-country-vg {
    background-image: url("../flags/country/vg.svg");
}

select.storyraum-language-flag-country-vi {
    background-image: url("../flags/country/vi.svg");
}

select.storyraum-language-flag-country-vn {
    background-image: url("../flags/country/vn.svg");
}

select.storyraum-language-flag-country-vu {
    background-image: url("../flags/country/vu.svg");
}

select.storyraum-language-flag-country-wf {
    background-image: url("../flags/country/wf.svg");
}

select.storyraum-language-flag-country-ws {
    background-image: url("../flags/country/ws.svg");
}

select.storyraum-language-flag-country-xk {
    background-image: url("../flags/country/xk.svg");
}

select.storyraum-language-flag-country-xx {
    background-image: url("../flags/country/xx.svg");
}

select.storyraum-language-flag-country-ye {
    background-image: url("../flags/country/ye.svg");
}

select.storyraum-language-flag-country-yt {
    background-image: url("../flags/country/yt.svg");
}

select.storyraum-language-flag-country-za {
    background-image: url("../flags/country/za.svg");
}

select.storyraum-language-flag-country-zm {
    background-image: url("../flags/country/zm.svg");
}

select.storyraum-language-flag-country-zw {
    background-image: url("../flags/country/zw.svg");
}

.chat-language-control
select.storyraum-language-flag-select {
    min-width: 104px;
}

.chat-mobile-language-select.storyraum-language-flag-select {
    min-width: 116px;
}

/* =========================================================
   STORYRAUM DEVELOPMENT #80
   R80_AI_CHAT_PUBLIC_R3A
========================================================= */

.r80-ai-chat-page {
    position: relative;
}

.r80-ai-chat-shell {
    display: grid;
    grid-template-columns: minmax(220px, 290px) minmax(0, 1fr);
    min-height: min(760px, calc(100vh - 150px));
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 22px;
    overflow: hidden;
    background:
        linear-gradient(
            145deg,
            rgba(24,17,34,.92),
            rgba(8,8,12,.96)
        );
    box-shadow:
        0 20px 60px rgba(0,0,0,.22);
}

.r80-ai-chat-history {
    min-width: 0;
    padding: 18px 14px;
    border-right: 1px solid rgba(255,255,255,.07);
    background: rgba(4,4,8,.34);
}

.r80-ai-chat-history-header,
.r80-ai-chat-header,
.r80-ai-chat-memory-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
}

.r80-ai-chat-history-header {
    margin-bottom: 16px;
}

.r80-ai-chat-history-header h2,
.r80-ai-chat-header h2,
.r80-ai-chat-memory-header h2 {
    margin: 2px 0 0;
}

.r80-ai-chat-thread-list {
    display: grid;
    gap: 7px;
}

.r80-ai-chat-thread-row {
    display: grid;
    grid-template-columns: minmax(0,1fr) 34px;
    align-items: center;
    gap: 4px;
    border: 1px solid transparent;
    border-radius: 13px;
    transition:
        background .16s ease,
        border-color .16s ease;
}

.r80-ai-chat-thread-row:hover {
    background: rgba(255,255,255,.035);
}

.r80-ai-chat-thread-row.is-active {
    border-color: rgba(192,132,252,.23);
    background:
        linear-gradient(
            135deg,
            rgba(126,34,206,.20),
            rgba(91,33,182,.08)
        );
}

.r80-ai-chat-thread-open,
.r80-ai-chat-thread-delete {
    border: 0;
    color: inherit;
    background: transparent;
    font: inherit;
    cursor: pointer;
}

.r80-ai-chat-thread-open {
    display: grid;
    gap: 4px;
    min-width: 0;
    padding: 11px 8px 11px 12px;
    text-align: left;
}

.r80-ai-chat-thread-open strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: .9rem;
}

.r80-ai-chat-thread-open small {
    color: #837d8c;
    font-size: .72rem;
}

.r80-ai-chat-thread-delete {
    width: 30px;
    height: 30px;
    border-radius: 9px;
    color: #918b98;
    font-size: 1.05rem;
}

.r80-ai-chat-thread-delete:hover {
    color: #fff;
    background: rgba(255,255,255,.06);
}

.r80-ai-chat-thread-empty {
    margin: 18px 8px;
    color: #88818f;
    font-size: .84rem;
    line-height: 1.55;
}

.r80-ai-chat-conversation {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    position: relative;
}

.r80-ai-chat-header {
    padding: 20px 22px 17px;
    border-bottom: 1px solid rgba(255,255,255,.07);
    background: rgba(8,8,12,.42);
}

.r80-ai-chat-heading {
    min-width: 0;
}

.r80-ai-chat-intro {
    max-width: 720px;
    margin: 7px 0 0;
    color: #938c9b;
    font-size: .85rem;
    line-height: 1.55;
}

.r80-ai-chat-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}

.r80-ai-chat-image-toggle {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.r80-ai-chat-image-toggle.is-active,
.r80-ai-chat-image-toggle[aria-pressed="true"] {
    border-color: rgba(192,132,252,.48);
    background:
        linear-gradient(
            135deg,
            rgba(126,34,206,.32),
            rgba(91,33,182,.18)
        );
    color: #fff;
}

.r80-ai-chat-notice {
    margin: 12px 22px 0;
    padding: 10px 13px;
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 11px;
    background: rgba(255,255,255,.035);
    font-size: .82rem;
}

.r80-ai-chat-notice.is-error {
    border-color: rgba(248,113,113,.28);
}

.r80-ai-chat-notice.is-success {
    border-color: rgba(74,222,128,.22);
}

.r80-ai-chat-messages {
    flex: 1 1 auto;
    min-height: 360px;
    max-height: calc(100vh - 330px);
    overflow-y: auto;
    padding: 24px clamp(16px,4vw,54px);
    scroll-behavior: smooth;
}

.r80-ai-chat-welcome {
    display: grid;
    place-items: center;
    align-content: center;
    min-height: 340px;
    max-width: 680px;
    margin: 0 auto;
    text-align: center;
}

.r80-ai-chat-welcome-icon {
    display: grid;
    place-items: center;
    width: 54px;
    height: 54px;
    margin-bottom: 15px;
    border: 1px solid rgba(192,132,252,.25);
    border-radius: 18px;
    background:
        linear-gradient(
            145deg,
            rgba(126,34,206,.28),
            rgba(76,29,149,.12)
        );
    font-size: 1.55rem;
}

.r80-ai-chat-welcome h3 {
    margin: 0;
    font-size: clamp(1.2rem,2vw,1.65rem);
}

.r80-ai-chat-welcome p {
    max-width: 560px;
    margin: 10px 0 0;
    color: #938c9b;
    line-height: 1.65;
}

.r80-ai-chat-message {
    width: min(860px,100%);
    margin: 0 auto 22px;
}

.r80-ai-chat-message.is-user {
    display: grid;
    justify-items: end;
}

.r80-ai-chat-message-role {
    margin-bottom: 6px;
    color: #847e8b;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .03em;
}

.r80-ai-chat-message-content {
    max-width: min(760px,92%);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    line-height: 1.7;
}

.r80-ai-chat-message.is-user
.r80-ai-chat-message-content {
    padding: 11px 15px;
    border: 1px solid rgba(192,132,252,.20);
    border-radius: 17px 17px 4px 17px;
    background: rgba(126,34,206,.17);
}

.r80-ai-chat-message.is-assistant
.r80-ai-chat-message-content {
    max-width: 100%;
    padding: 3px 0;
}

.r80-ai-chat-message.is-streaming
.r80-ai-chat-message-content::after {
    content: "▋";
    display: inline-block;
    margin-left: 3px;
    opacity: .7;
    animation: r80-ai-chat-caret .9s steps(1) infinite;
}

@keyframes r80-ai-chat-caret {
    50% {
        opacity: 0;
    }
}

.r80-ai-chat-message-images {
    display: grid;
    grid-template-columns:
        repeat(
            auto-fit,
            minmax(
                min(240px,100%),
                1fr
            )
        );
    gap: 12px;
    width: 100%;
    margin-top: 14px;
}

.r80-ai-chat-message-images img {
    display: block;
    width: 100%;
    max-height: 680px;
    object-fit: contain;
    border-radius: 16px;
    border: 1px solid rgba(255,255,255,.08);
    background: rgba(0,0,0,.22);
}

.r80-ai-chat-form {
    padding: 12px clamp(16px,4vw,54px) 4px;
}

.r80-ai-chat-composer {
    display: grid;
    grid-template-columns:
        minmax(0,1fr)
        42px;
    align-items: end;
    gap: 8px;
    width: min(900px,100%);
    margin: 0 auto;
    padding: 8px;
    border: 1px solid rgba(255,255,255,.11);
    border-radius: 20px;
    background: rgba(12,11,16,.96);
    box-shadow: 0 12px 35px rgba(0,0,0,.22);
}

.r80-ai-chat-composer:focus-within {
    border-color: rgba(192,132,252,.38);
}

.r80-ai-chat-composer textarea {
    width: 100%;
    min-height: 42px;
    max-height: 180px;
    padding: 10px 11px;
    resize: vertical;
    border: 0;
    outline: 0;
    background: transparent;
    color: #f3eff8;
    font: inherit;
    line-height: 1.45;
}

.r80-ai-chat-send,
.r80-ai-chat-stop {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border: 0;
    border-radius: 14px;
    cursor: pointer;
    font-size: 1rem;
}

.r80-ai-chat-send {
    color: #fff;
    background:
        linear-gradient(
            135deg,
            #7e22ce,
            #5b21b6
        );
}

.r80-ai-chat-stop {
    color: #fff;
    background: rgba(239,68,68,.62);
}

.r80-ai-chat-send:disabled,
.r80-ai-chat-stop:disabled {
    opacity: .55;
    cursor: default;
}

.r80-ai-chat-disclaimer {
    margin: 8px auto 16px;
    padding: 0 18px;
    max-width: 900px;
    text-align: center;
    color: #716b78;
    font-size: .7rem;
    line-height: 1.45;
}

.r80-ai-chat-memory-panel {
    position: fixed;
    z-index: 130;
    top: 76px;
    right: 18px;
    bottom: 18px;
    width: min(420px,calc(100vw - 36px));
    overflow-y: auto;
    padding: 20px;
    border: 1px solid rgba(255,255,255,.10);
    border-radius: 20px;
    background: rgba(12,10,17,.985);
    box-shadow: 0 28px 80px rgba(0,0,0,.48);
}

.r80-ai-chat-memory-panel[hidden] {
    display: none !important;
}

.r80-ai-chat-memory-intro,
.r80-ai-chat-memory-hint {
    color: #938c9b;
    font-size: .82rem;
    line-height: 1.55;
}

.r80-ai-chat-memory-setting {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 20px 0 5px;
    font-weight: 650;
}

.r80-ai-chat-memory-form {
    display: grid;
    gap: 10px;
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid rgba(255,255,255,.07);
}

.r80-ai-chat-memory-form label {
    display: grid;
    gap: 8px;
}

.r80-ai-chat-memory-form textarea {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid rgba(255,255,255,.09);
    border-radius: 12px;
    background: rgba(255,255,255,.035);
    color: #f3eff8;
    font: inherit;
    resize: vertical;
}

.r80-ai-chat-memory-list {
    display: grid;
    gap: 8px;
    margin-top: 18px;
}

.r80-ai-chat-memory-card {
    display: grid;
    grid-template-columns: minmax(0,1fr) 32px;
    gap: 8px;
    align-items: start;
    padding: 11px 11px 11px 13px;
    border: 1px solid rgba(255,255,255,.07);
    border-radius: 12px;
    background: rgba(255,255,255,.025);
}

.r80-ai-chat-memory-card p {
    margin: 0;
    overflow-wrap: anywhere;
    font-size: .82rem;
    line-height: 1.55;
}

.r80-ai-chat-memory-forget {
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: #908995;
    cursor: pointer;
}

.r80-ai-chat-memory-forget:hover {
    color: #fff;
    background: rgba(255,255,255,.055);
}

.r80-ai-chat-memory-empty {
    color: #89828f;
    font-size: .82rem;
}

@media (max-width: 860px) {
    .r80-ai-chat-shell {
        display: block;
        min-height: calc(100vh - 130px);
    }

    .r80-ai-chat-history {
        padding: 12px;
        border-right: 0;
        border-bottom: 1px solid rgba(255,255,255,.07);
    }

    .r80-ai-chat-history-header {
        margin-bottom: 9px;
    }

    .r80-ai-chat-thread-list {
        display: flex;
        overflow-x: auto;
        gap: 7px;
        padding-bottom: 3px;
    }

    .r80-ai-chat-thread-row {
        flex: 0 0 min(235px,75vw);
    }

    .r80-ai-chat-header {
        padding: 15px;
    }

    .r80-ai-chat-header-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .r80-ai-chat-image-toggle {
        justify-content: center;
    }

    .r80-ai-chat-messages {
        min-height: 330px;
        max-height: calc(100vh - 430px);
        padding: 18px 14px;
    }

    .r80-ai-chat-form {
        padding-left: 12px;
        padding-right: 12px;
    }
}

/* /R80_AI_CHAT_PUBLIC_R3A */

/* =========================================================
   STORYRAUM DEVELOPMENT #80
   R80_CHATNPC_DESIGN_R6
========================================================= */

.r80-ai-chat-page {
    --r80-chat-width: 860px;
    --r80-history-width: 252px;
    --r80-chat-border: rgba(255,255,255,.075);
    --r80-chat-muted: #938d9b;
    isolation: isolate;
}

.r80-ai-chat-shell {
    width: min(1500px, 100%);
    height: clamp(
        620px,
        calc(100dvh - 152px),
        920px
    );
    min-height: 620px;
    margin-inline: auto;
    grid-template-columns:
        var(--r80-history-width)
        minmax(0,1fr);
    overflow: hidden;
    border-color: var(--r80-chat-border);
    border-radius: 24px;
    background:
        radial-gradient(
            circle at 78% -15%,
            rgba(126,34,206,.11),
            transparent 34%
        ),
        linear-gradient(
            180deg,
            rgba(12,11,17,.985),
            rgba(7,7,11,.985)
        );
    box-shadow:
        0 26px 80px rgba(0,0,0,.28);
}

.r80-ai-chat-history {
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 14px 10px 12px;
    border-right:
        1px solid
        var(--r80-chat-border);
    background:
        linear-gradient(
            180deg,
            rgba(255,255,255,.025),
            rgba(255,255,255,.012)
        );
}

.r80-ai-chat-history-header {
    align-items: center;
    flex: 0 0 auto;
    min-height: 46px;
    margin: 0 4px 10px;
}

.r80-ai-chat-history-header .eyebrow {
    display: none;
}

.r80-ai-chat-history-header h2 {
    margin: 0;
    font-size: .94rem;
    font-weight: 720;
    letter-spacing: -.01em;
}

.r80-ai-chat-history-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.r80-ai-chat-history-actions .icon-button {
    width: 34px;
    height: 34px;
    min-width: 34px;
    border-radius: 10px;
}

.r80-ai-chat-history-close,
.r80-ai-chat-history-toggle {
    display: none;
}

.r80-ai-chat-thread-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color:
        rgba(255,255,255,.13)
        transparent;
    padding: 2px 2px 12px;
}

.r80-ai-chat-thread-row {
    grid-template-columns:
        minmax(0,1fr)
        30px;
    gap: 2px;
    margin-bottom: 3px;
    border-radius: 12px;
}

.r80-ai-chat-thread-row:hover {
    background:
        rgba(255,255,255,.035);
}

.r80-ai-chat-thread-row.is-active {
    border-color:
        rgba(192,132,252,.18);
    background:
        linear-gradient(
            135deg,
            rgba(126,34,206,.16),
            rgba(91,33,182,.055)
        );
}

.r80-ai-chat-thread-open {
    gap: 3px;
    padding: 9px 7px 9px 10px;
}

.r80-ai-chat-thread-open strong {
    font-size: .84rem;
    font-weight: 650;
}

.r80-ai-chat-thread-open small {
    font-size: .66rem;
    color: #77717f;
}

.r80-ai-chat-thread-delete {
    width: 28px;
    height: 28px;
    align-self: center;
    border-radius: 8px;
    opacity: .35;
    transition:
        opacity .15s ease,
        background .15s ease,
        color .15s ease;
}

.r80-ai-chat-thread-row:hover
.r80-ai-chat-thread-delete,
.r80-ai-chat-thread-row.is-active
.r80-ai-chat-thread-delete {
    opacity: .8;
}

.r80-ai-chat-conversation {
    min-height: 0;
    overflow: hidden;
    background:
        radial-gradient(
            circle at 52% 5%,
            rgba(126,34,206,.045),
            transparent 32%
        );
}

.r80-ai-chat-header {
    align-items: center;
    flex: 0 0 auto;
    min-height: 62px;
    padding: 11px 22px;
    border-bottom:
        1px solid
        var(--r80-chat-border);
    background:
        rgba(9,8,13,.78);
    backdrop-filter: blur(18px);
}

.r80-ai-chat-header .eyebrow,
.r80-ai-chat-header .r80-ai-chat-intro {
    display: none;
}

.r80-ai-chat-header h2 {
    margin: 0;
    max-width: 70vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: .98rem;
    font-weight: 680;
    letter-spacing: -.012em;
}

.r80-ai-chat-heading {
    flex: 1 1 auto;
}

.r80-ai-chat-notice {
    width:
        min(
            var(--r80-chat-width),
            calc(100% - 36px)
        );
    margin: 12px auto 0;
    padding: 9px 12px;
    border-radius: 12px;
}

.r80-ai-chat-messages {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    overscroll-behavior: contain;
    scroll-padding:
        30px 0 120px;
    padding:
        32px
        clamp(18px,4vw,58px)
        22px;
    scrollbar-width: thin;
    scrollbar-color:
        rgba(255,255,255,.13)
        transparent;
}

.r80-ai-chat-welcome {
    min-height: 100%;
    width: min(680px, 100%);
    padding: 36px 18px 90px;
}

.r80-ai-chat-welcome-icon {
    position: relative;
    width: 64px;
    height: 64px;
    margin-bottom: 20px;
    border:
        1px solid
        rgba(192,132,252,.22);
    border-radius: 21px;
    background:
        radial-gradient(
            circle at 35% 25%,
            rgba(216,180,254,.22),
            transparent 36%
        ),
        linear-gradient(
            145deg,
            rgba(126,34,206,.23),
            rgba(76,29,149,.07)
        );
    box-shadow:
        0 16px 40px
        rgba(76,29,149,.16);
    font-size: 1.75rem;
}

.r80-ai-chat-welcome-icon::after {
    content: "";
    position: absolute;
    inset: -16px;
    z-index: -1;
    border-radius: 30px;
    background:
        radial-gradient(
            circle,
            rgba(168,85,247,.09),
            transparent 68%
        );
}

.r80-ai-chat-welcome h3 {
    font-size:
        clamp(
            1.45rem,
            2.4vw,
            2rem
        );
    font-weight: 720;
    letter-spacing: -.025em;
}

.r80-ai-chat-welcome p {
    max-width: 540px;
    margin-top: 12px;
    color: var(--r80-chat-muted);
    font-size: .94rem;
    line-height: 1.65;
}

.r80-ai-chat-message {
    width:
        min(
            var(--r80-chat-width),
            100%
        );
    margin: 0 auto 28px;
}

.r80-ai-chat-message-role {
    display: flex;
    align-items: center;
    min-height: 22px;
    margin-bottom: 8px;
    color: #aaa3b1;
    font-size: .72rem;
    font-weight: 720;
    letter-spacing: .01em;
}

.r80-ai-chat-message.is-user
.r80-ai-chat-message-role {
    display: none;
}

.r80-ai-chat-message.is-assistant
.r80-ai-chat-message-role::before {
    content: "✦";
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    margin-right: 7px;
    border-radius: 7px;
    background:
        rgba(126,34,206,.16);
    color: #d8b4fe;
    font-size: .72rem;
}

.r80-ai-chat-message-content {
    overflow-wrap: anywhere;
    line-height: 1.72;
}

.r80-ai-chat-message.is-user {
    justify-items: end;
}

.r80-ai-chat-message.is-user
.r80-ai-chat-message-content {
    max-width:
        min(
            72%,
            650px
        );
    padding: 10px 15px;
    border:
        1px solid
        rgba(192,132,252,.15);
    border-radius:
        18px
        18px
        5px
        18px;
    background:
        linear-gradient(
            145deg,
            rgba(126,34,206,.19),
            rgba(91,33,182,.12)
        );
    box-shadow:
        0 7px 20px
        rgba(0,0,0,.08);
}

.r80-ai-chat-message.is-user.is-pending {
    opacity: .76;
}

.r80-ai-chat-message.is-assistant
.r80-ai-chat-message-content {
    max-width: 100%;
    padding: 0;
    color: #eeeaf2;
    font-size: .96rem;
}

.r80-ai-chat-message-images {
    width: min(760px, 100%);
    margin-top: 18px;
    gap: 14px;
}

.r80-ai-chat-message-images img {
    max-height: 720px;
    border-radius: 18px;
    border-color:
        rgba(255,255,255,.09);
    box-shadow:
        0 20px 45px
        rgba(0,0,0,.2);
}

.r80-ai-chat-form {
    flex: 0 0 auto;
    padding:
        10px
        clamp(18px,4vw,58px)
        3px;
    background:
        linear-gradient(
            180deg,
            rgba(8,7,12,0),
            rgba(8,7,12,.94) 28%,
            rgba(8,7,12,.985)
        );
}

.r80-ai-chat-composer {
    width:
        min(
            var(--r80-chat-width),
            100%
        );
    margin-inline: auto;
    grid-template-columns:
        minmax(0,1fr)
        auto
        auto;
    gap: 5px;
    padding: 6px 6px 6px 13px;
    border:
        1px solid
        rgba(255,255,255,.105);
    border-radius: 25px;
    background:
        rgba(20,18,25,.985);
    box-shadow:
        0 16px 48px
        rgba(0,0,0,.25),
        inset 0 1px
        rgba(255,255,255,.025);
    transition:
        border-color .16s ease,
        box-shadow .16s ease;
}

.r80-ai-chat-composer:focus-within {
    border-color:
        rgba(192,132,252,.36);
    box-shadow:
        0 18px 54px
        rgba(0,0,0,.28),
        0 0 0 3px
        rgba(126,34,206,.055);
}

.r80-ai-chat-composer textarea {
    min-height: 44px;
    max-height: 200px;
    height: 44px;
    padding: 10px 4px;
    overflow-y: hidden;
    resize: none;
    border: 0;
    outline: 0;
    background: transparent;
    line-height: 1.5;
}

.r80-ai-chat-composer textarea::placeholder {
    color: #77717f;
}

.r80-ai-chat-send,
.r80-ai-chat-stop {
    align-self: end;
    width: 42px;
    height: 42px;
    border-radius: 50%;
}

.r80-ai-chat-send {
    background:
        linear-gradient(
            145deg,
            #8b5cf6,
            #6d28d9
        );
    box-shadow:
        0 7px 18px
        rgba(109,40,217,.24);
}

.r80-ai-chat-stop {
    background:
        rgba(185,28,28,.72);
}

.r80-ai-chat-stop[hidden],
.r80-ai-chat-send[hidden] {
    display: none !important;
}

.r80-ai-chat-disclaimer {
    flex: 0 0 auto;
    max-width: var(--r80-chat-width);
    margin: 6px auto 12px;
    color: #68626e;
    font-size: .66rem;
}

.r80-ai-chat-history-backdrop {
    display: none;
}

.r80-ai-chat-image-toggle,
.r80-ai-chat-memory-panel {
    display: none !important;
}

body.r80-ai-chat-history-open {
    overflow: hidden;
}

@media (max-width: 860px) {
    .r80-ai-chat-shell {
        display: block;
        width: 100%;
        height:
            max(
                540px,
                calc(100dvh - 142px)
            );
        min-height: 540px;
        max-height: none;
        border-radius: 20px;
    }

    .r80-ai-chat-conversation {
        height: 100%;
    }

    .r80-ai-chat-history {
        position: fixed;
        z-index: 151;
        top:
            max(
                70px,
                env(safe-area-inset-top)
            );
        left: 10px;
        bottom:
            max(
                72px,
                calc(
                    12px
                    + env(safe-area-inset-bottom)
                )
            );
        width:
            min(
                330px,
                calc(100vw - 28px)
            );
        padding: 13px 10px 12px;
        border:
            1px solid
            rgba(255,255,255,.1);
        border-radius: 19px;
        background:
            rgba(15,13,20,.985);
        box-shadow:
            0 28px 80px
            rgba(0,0,0,.52);
        transform:
            translateX(
                calc(-100% - 28px)
            );
        visibility: hidden;
        transition:
            transform .2s ease,
            visibility .2s linear;
    }

    body.r80-ai-chat-history-open
    .r80-ai-chat-history {
        transform: translateX(0);
        visibility: visible;
    }

    .r80-ai-chat-thread-list {
        display: grid;
        overflow-x: hidden;
        overflow-y: auto;
        gap: 3px;
        padding-bottom: 12px;
    }

    .r80-ai-chat-thread-row {
        flex: none;
        width: 100%;
    }

    .r80-ai-chat-history-backdrop {
        position: fixed;
        z-index: 150;
        inset: 0;
        display: block;
        background:
            rgba(0,0,0,.48);
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        backdrop-filter: blur(2px);
        transition:
            opacity .18s ease,
            visibility .18s linear;
    }

    body.r80-ai-chat-history-open
    .r80-ai-chat-history-backdrop {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    .r80-ai-chat-history-close {
        display: grid;
        place-items: center;
    }

    .r80-ai-chat-history-toggle {
        display: grid;
        place-items: center;
        flex: 0 0 auto;
        width: 38px;
        height: 38px;
        min-width: 38px;
        margin-right: 3px;
        border-radius: 11px;
    }

    .r80-ai-chat-header {
        min-height: 60px;
        padding: 10px 13px;
    }

    .r80-ai-chat-header h2 {
        max-width:
            calc(100vw - 105px);
        font-size: .94rem;
    }

    .r80-ai-chat-messages {
        padding:
            24px
            14px
            18px;
    }

    .r80-ai-chat-welcome {
        padding:
            28px
            14px
            78px;
    }

    .r80-ai-chat-welcome-icon {
        width: 58px;
        height: 58px;
        border-radius: 19px;
    }

    .r80-ai-chat-message {
        margin-bottom: 23px;
    }

    .r80-ai-chat-message.is-user
    .r80-ai-chat-message-content {
        max-width: 86%;
    }

    .r80-ai-chat-form {
        padding: 8px 10px 3px;
    }

    .r80-ai-chat-composer {
        padding-left: 11px;
        border-radius: 23px;
    }

    .r80-ai-chat-disclaimer {
        margin-bottom:
            max(
                8px,
                env(safe-area-inset-bottom)
            );
        padding-inline: 12px;
    }
}

@media (max-width: 480px) {
    .r80-ai-chat-shell {
        border-radius: 16px;
    }

    .r80-ai-chat-messages {
        padding-inline: 11px;
    }

    .r80-ai-chat-message.is-user
    .r80-ai-chat-message-content {
        max-width: 90%;
    }

    .r80-ai-chat-send,
    .r80-ai-chat-stop {
        width: 40px;
        height: 40px;
    }

    .r80-ai-chat-composer textarea {
        min-height: 40px;
        padding-block: 8px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .r80-ai-chat-history,
    .r80-ai-chat-history-backdrop,
    .r80-ai-chat-composer {
        transition: none !important;
    }
}

/* =========================================================
   STORYRAUM DEVELOPMENT #80
   R80_CHATNPC_MOBILE_SPACING_R6A
   Etwas mehr Luft zwischen Mobile-Header und Chatfläche.
========================================================= */

@media (max-width: 860px) {
    .r80-ai-chat-page {
        padding-top: 14px;
    }

    .r80-ai-chat-shell {
        height:
            max(
                540px,
                calc(100dvh - 156px)
            );
    }
}
/* R80_CHATNPC_MOBILE_KEYBOARD_R6B */
:root {
    --r80-ai-chat-visual-viewport-height: 100dvh;
    --r80-ai-chat-keyboard-inset: 0px;
}

@media (max-width: 900px) {
    body.r80-ai-chat-keyboard-open {
        overflow: hidden;
    }

    body.r80-ai-chat-keyboard-open .r80-ai-chat-shell,
    body.r80-ai-chat-keyboard-open .r80-ai-chat-layout,
    body.r80-ai-chat-keyboard-open .r80-ai-chat-main,
    body.r80-ai-chat-keyboard-open .r80-ai-chat-panel {
        min-height: 0 !important;
    }

    body.r80-ai-chat-keyboard-open .r80-ai-chat-shell,
    body.r80-ai-chat-keyboard-open .r80-ai-chat-layout {
        height: calc(var(--r80-ai-chat-visual-viewport-height) - 86px) !important;
        max-height: calc(var(--r80-ai-chat-visual-viewport-height) - 86px) !important;
    }

    body.r80-ai-chat-keyboard-open .r80-ai-chat-main,
    body.r80-ai-chat-keyboard-open .r80-ai-chat-panel {
        height: 100% !important;
        max-height: 100% !important;
    }

    body.r80-ai-chat-keyboard-open #aiChatMessages {
        padding-top: 10px !important;
        padding-bottom: 20px !important;
        scroll-padding-bottom: 160px;
    }

    body.r80-ai-chat-keyboard-open .r80-ai-chat-composer {
        margin-top: 8px !important;
        margin-bottom: 0 !important;
        padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px)) !important;
    }

    body.r80-ai-chat-keyboard-open #aiChatInput {
        scroll-margin-bottom: 20px;
    }
}

/* =========================================================
   STORYRAUM DEVELOPMENT #80
   R80_CHATNPC_HISTORY_R6C

   Kompakte Chat-History nach dem Muster moderner
   Assistant-Seitenleisten:
   - keine gestreckten Karten
   - vertikale Liste
   - dezente aktive Zeile
   - Delete-Aktion nur bei Interaktion
========================================================= */

.r80-ai-chat-history {
    min-height: 0;
}

.r80-ai-chat-history-header {
    flex: 0 0 auto;
    margin-bottom: 4px;
    padding-inline: 4px;
}

.r80-ai-chat-history-header .eyebrow {
    display: none;
}

.r80-ai-chat-history-header h2 {
    margin: 0;
    font-size: .78rem;
    font-weight: 650;
    letter-spacing: .01em;
    color: #a9a2b0;
}

.r80-ai-chat-history-header .icon-button {
    width: 30px;
    height: 30px;
    min-width: 30px;
    border-radius: 8px;
}

.r80-ai-chat-thread-list {
    display: grid;
    grid-auto-rows: max-content;
    align-content: start;
    gap: 2px;

    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;

    padding: 2px 0 10px;

    scrollbar-width: thin;
}

.r80-ai-chat-thread-row {
    display: grid;
    grid-template-columns: minmax(0,1fr) 28px;
    align-items: center;

    width: 100%;
    min-height: 38px;

    gap: 0;

    border: 0;
    border-radius: 8px;

    background: transparent;
    box-shadow: none;

    transition:
        background .12s ease,
        color .12s ease;
}

.r80-ai-chat-thread-row:hover {
    background: rgba(255,255,255,.045);
}

.r80-ai-chat-thread-row.is-active {
    border: 0;
    background: rgba(255,255,255,.07);
    box-shadow: none;
}

.r80-ai-chat-thread-row.is-active:hover {
    background: rgba(255,255,255,.085);
}

.r80-ai-chat-thread-open {
    display: block;

    min-width: 0;
    width: 100%;

    padding: 9px 8px 9px 10px;

    text-align: left;
}

.r80-ai-chat-thread-open strong {
    display: block;

    overflow: hidden;

    color: #d8d4dc;

    font-size: .82rem;
    font-weight: 500;
    line-height: 1.3;

    text-overflow: ellipsis;
    white-space: nowrap;
}

.r80-ai-chat-thread-row.is-active
.r80-ai-chat-thread-open strong {
    color: #fff;
    font-weight: 550;
}

/*
 * ChatGPT-artige kompakte History:
 * kein permanenter Zeitstempel unter jedem Titel.
 * Zeitliche Gruppierung kann später separat ergänzt werden.
 */
.r80-ai-chat-thread-open small {
    display: none;
}

.r80-ai-chat-thread-delete {
    display: grid;
    place-items: center;

    width: 26px;
    height: 26px;

    padding: 0;

    border-radius: 7px;

    opacity: 0;

    color: #918b98;

    font-size: 1rem;
    line-height: 1;

    transition:
        opacity .12s ease,
        background .12s ease,
        color .12s ease;
}

.r80-ai-chat-thread-row:hover
.r80-ai-chat-thread-delete,
.r80-ai-chat-thread-row:focus-within
.r80-ai-chat-thread-delete {
    opacity: 1;
}

.r80-ai-chat-thread-delete:hover {
    color: #fff;
    background: rgba(255,255,255,.08);
}

/*
 * Touchgeräte besitzen keinen zuverlässigen Hover.
 * Dort bleibt die Löschaktion erreichbar, aber zurückhaltend.
 */
@media (hover: none) {
    .r80-ai-chat-thread-delete {
        opacity: .55;
    }

    .r80-ai-chat-thread-row.is-active
    .r80-ai-chat-thread-delete {
        opacity: .8;
    }
}

/*
 * Der bereits vorhandene Mobile-Drawer behält seine Funktion.
 * Seine Threadliste soll aber genauso kompakt aussehen
 * wie auf Desktop.
 */
@media (max-width: 860px) {
    .r80-ai-chat-thread-list {
        display: grid;
        grid-auto-rows: max-content;
        align-content: start;

        overflow-x: hidden;
        overflow-y: auto;

        gap: 2px;
        padding-bottom: 10px;
    }

    .r80-ai-chat-thread-row {
        flex: none;
        width: 100%;
        min-height: 40px;
    }
}

/* =========================================================
   STORYRAUM DEVELOPMENT #80
   R80_CHATNPC_SCROLL_STABILITY_R7C

   ChatNPC steuert seine interne Follow-Latest-Position
   selbst. Smooth-Scrolling auf diesem Container würde beim
   vollständigen Message-Re-Render einen sichtbaren Weg von
   scrollTop=0 bis zum Ende erzeugen.
========================================================= */

.r80-ai-chat-messages {
    scroll-behavior: auto;
    overscroll-behavior: contain;
}


/* =========================================================
   STORYRAUM DEVELOPMENT #80
   R80_CHATNPC_SAFE_MARKDOWN_RENDERER_R20D
========================================================= */

.r80-ai-chat-message.is-assistant
.r80-ai-chat-message-content {
    white-space: normal;
}

.r80-ai-chat-message-content
.r80-ai-chat-markdown-paragraph {
    margin: 0 0 .86em;
    white-space: pre-wrap;
}

.r80-ai-chat-message-content
.r80-ai-chat-markdown-paragraph:last-child {
    margin-bottom: 0;
}

.r80-ai-chat-message-content
.r80-ai-chat-markdown-list {
    margin: .4em 0 1em;
    padding-left: 1.6em;
}

.r80-ai-chat-message-content
.r80-ai-chat-markdown-list li {
    margin: .68em 0;
    padding-left: .12em;
}

.r80-ai-chat-message-content
.r80-ai-chat-list-primary {
    line-height: 1.6;
}

.r80-ai-chat-message-content
.r80-ai-chat-list-detail {
    margin-top: .22em;
    line-height: 1.62;
    white-space: pre-wrap;
}

.r80-ai-chat-message-content strong {
    color: inherit;
    font-weight: 740;
}

.r80-ai-chat-message-content em {
    font-style: italic;
}

.r80-ai-chat-message-content
.r80-ai-chat-markdown-heading {
    margin: 1.05em 0 .48em;
    color: #f2eef5;
    font-size: 1.01em;
    font-weight: 760;
    line-height: 1.4;
}

.r80-ai-chat-message-content
.r80-ai-chat-markdown-heading:first-child {
    margin-top: 0;
}

.r80-ai-chat-message-content
.r80-ai-chat-inline-code {
    padding: .1em .36em;
    border: 1px solid rgba(255,255,255,.09);
    border-radius: 6px;
    background: rgba(255,255,255,.055);
    font-family:
        ui-monospace,
        SFMono-Regular,
        Menlo,
        Monaco,
        Consolas,
        "Liberation Mono",
        monospace;
    font-size: .91em;
}

.r80-ai-chat-message-content
.r80-ai-chat-code-block {
    margin: .7em 0 1em;
    padding: 12px 14px;
    overflow-x: auto;
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 12px;
    background: rgba(0,0,0,.22);
    white-space: pre;
}

.r80-ai-chat-message-content
.r80-ai-chat-code-block code {
    font-family:
        ui-monospace,
        SFMono-Regular,
        Menlo,
        Monaco,
        Consolas,
        "Liberation Mono",
        monospace;
    font-size: .9em;
}

.r80-ai-chat-message-content
.r80-ai-chat-markdown-quote {
    margin: .65em 0 .9em;
    padding: .15em 0 .15em .9em;
    border-left: 3px solid rgba(192,132,252,.4);
    color: #c9c3cf;
}

/*
 * ADULT_STUDIO_AI_PROMPT_ASSISTANT_R10_3R3
 */

.adult-studio-ai-assistant-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .7rem;
    margin: -.15rem 0 .45rem;
}

.adult-studio-ai-assistant-status {
    min-height: 1.25rem;
    font-size: .86rem;
    opacity: .88;
}

.adult-studio-ai-assistant-status.is-success {
    opacity: 1;
}

.adult-studio-ai-assistant-status.is-error {
    opacity: 1;
}

.adult-studio-ai-dialog {
    width:
        min(
            680px,
            calc(100vw - 2rem)
        );

    max-height:
        min(
            820px,
            calc(100vh - 2rem)
        );

    padding: 0;
    overflow: auto;

    border:
        1px solid
        rgba(255,255,255,.13);

    border-radius:
        20px;

    background:
        #18151f;

    color:
        #f4f1f7;

    box-shadow:
        0 24px 80px
        rgba(0,0,0,.45);
}

.adult-studio-ai-dialog::backdrop {
    background:
        rgba(0,0,0,.68);

    backdrop-filter:
        blur(4px);
}

.adult-studio-ai-dialog-form {
    display: grid;
    gap: 1rem;
    padding: 1.25rem;
}

.adult-studio-ai-dialog-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.adult-studio-ai-dialog-header h3 {
    margin:
        .15rem 0 0;
}

.adult-studio-ai-dialog-hint,
.adult-studio-ai-dialog-footnote {
    margin: 0;
    line-height: 1.55;
    opacity: .78;
}

.adult-studio-ai-dialog textarea {
    width: 100%;
    min-height: 190px;
    resize: vertical;
}

.adult-studio-ai-dialog-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: .7rem;
}

.adult-studio-ai-dialog-footnote {
    font-size: .84rem;
}

@media (max-width: 640px) {
    .adult-studio-ai-dialog {
        width:
            calc(
                100vw - 1rem
            );

        max-height:
            calc(
                100vh - 1rem
            );

        border-radius:
            16px;
    }

    .adult-studio-ai-dialog-form {
        padding:
            1rem;
    }

    .adult-studio-ai-dialog-actions {
        display:
            grid;

        grid-template-columns:
            1fr;
    }

    .adult-studio-ai-dialog-actions button {
        width:
            100%;
    }
}


/*
 * ==========================================================
 * STORYRAUM #89
 * R89_CHARACTER_CARD_SVG_ACTIONS_FINAL
 * Character Card – kompakte SVG-Aktionen
 * ==========================================================
 */

.character-card-actions.character-card-icon-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(40px, 1fr));
    align-items: center;
    gap: 8px;
    width: 100%;
    margin-top: 10px;
}

.character-card-icon-action {
    appearance: none;
    -webkit-appearance: none;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 100%;
    min-width: 0;
    height: 42px;

    margin: 0;
    padding: 0;

    border:
        1px solid rgba(255, 255, 255, 0.13);

    border-radius:
        12px;

    background:
        rgba(255, 255, 255, 0.045);

    color:
        rgba(255, 255, 255, 0.88);

    cursor:
        pointer;

    line-height:
        1;

    box-shadow:
        none;

    transition:
        transform 140ms ease,
        background-color 140ms ease,
        border-color 140ms ease,
        box-shadow 140ms ease,
        color 140ms ease,
        opacity 140ms ease;
}

.character-card-icon-action svg {
    display: block;

    width: 21px;
    height: 21px;

    flex:
        0 0 21px;

    pointer-events:
        none;
}

/*
 * Primär: Chat
 */
.character-card-icon-action.is-primary {
    border-color:
        rgba(168, 85, 247, 0.55);

    background:
        linear-gradient(
            135deg,
            rgba(126, 34, 206, 0.96),
            rgba(147, 51, 234, 0.96)
        );

    color:
        #fff;

    box-shadow:
        0 7px 18px rgba(126, 34, 206, 0.20);
}

/*
 * Sekundär: Bearbeiten / Duplizieren
 */
.character-card-icon-action.is-secondary {
    background:
        rgba(255, 255, 255, 0.045);

    color:
        rgba(255, 255, 255, 0.88);
}

/*
 * Destruktiv: Löschen
 */
.character-card-icon-action.is-danger {
    border-color:
        rgba(248, 113, 113, 0.58);

    background:
        linear-gradient(
            135deg,
            rgba(220, 38, 38, 0.94),
            rgba(185, 28, 28, 0.94)
        );

    color:
        #fff;

    box-shadow:
        0 7px 18px rgba(185, 28, 28, 0.16);
}

.character-card-icon-action:hover:not(:disabled) {
    transform:
        translateY(-1px);
}

.character-card-icon-action.is-primary:hover:not(:disabled) {
    border-color:
        rgba(196, 181, 253, 0.82);

    box-shadow:
        0 9px 22px rgba(126, 34, 206, 0.30);
}

.character-card-icon-action.is-secondary:hover:not(:disabled) {
    border-color:
        rgba(167, 139, 250, 0.54);

    background:
        rgba(139, 92, 246, 0.13);

    color:
        #fff;
}

.character-card-icon-action.is-danger:hover:not(:disabled) {
    border-color:
        rgba(254, 202, 202, 0.82);

    background:
        linear-gradient(
            135deg,
            rgba(239, 68, 68, 0.98),
            rgba(220, 38, 38, 0.98)
        );
}

.character-card-icon-action:focus-visible {
    outline:
        2px solid rgba(196, 181, 253, 0.95);

    outline-offset:
        2px;
}

.character-card-icon-action.is-danger:focus-visible {
    outline-color:
        rgba(252, 165, 165, 0.98);
}

.character-card-icon-action:disabled {
    cursor:
        wait;

    opacity:
        0.48;

    transform:
        none;
}

@media (hover: none) {
    .character-card-icon-action:hover:not(:disabled) {
        transform:
            none;
    }
}

@media (max-width: 520px) {
    .character-card-actions.character-card-icon-actions {
        gap:
            7px;
    }

    .character-card-icon-action {
        height:
            44px;

        border-radius:
            11px;
    }

    .character-card-icon-action svg {
        width:
            20px;

        height:
            20px;

        flex-basis:
            20px;
    }
}


/* =========================================================
   DEVELOPMENT #77
   DEV77_INTEGRATED_LEGAL_PAGE_R2
========================================================= */

.legal-page-shell {
    width: min(980px, 100%);
    margin: 0 auto;
}

.legal-page-heading {
    margin-bottom: 16px;
}

.legal-page-summary {
    max-width: 760px;
    margin: 8px 0 0;
    color: var(--muted-text, #94a3b8);
    line-height: 1.65;
    white-space: pre-wrap;
}

.legal-page-navigation {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
    padding: 12px;
    border: 1px solid rgba(148, 163, 184, .18);
    border-radius: 16px;
    background: rgba(12, 15, 24, .94);
    backdrop-filter: blur(14px);
}

.legal-page-navigation .secondary-button {
    width: auto;
}

.legal-page-navigation .secondary-button.is-active {
    border-color: rgba(96, 165, 250, .75);
    background: rgba(59, 130, 246, .18);
    color: #dbeafe;
}

.legal-document-card {
    padding: clamp(20px, 4vw, 38px);
}

.legal-document-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 18px;
    margin-bottom: 22px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(148, 163, 184, .18);
    color: var(--muted-text, #94a3b8);
    font-size: .9rem;
}

.legal-page-status {
    margin: 0 0 14px;
}

.legal-document-content {
    color: var(--text-color, #e5e7eb);
    line-height: 1.72;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.legal-page-summary .protected-email,
.legal-document-content .protected-email {
    appearance: none;
    display: inline;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: .15em;
}

.legal-page-summary .protected-email:focus-visible,
.legal-document-content .protected-email:focus-visible {
    outline: 2px solid #c4b5fd;
    outline-offset: 3px;
    border-radius: 3px;
}

@media (max-width: 720px) {
    .legal-page-navigation {
        flex-wrap: nowrap;
        margin-left: -4px;
        margin-right: -4px;
        overflow-x: auto;
        scrollbar-width: thin;
    }

    .legal-page-navigation .secondary-button {
        flex: 0 0 auto;
    }

    .legal-document-card {
        padding: 18px 15px;
    }
}

/* /DEV77_INTEGRATED_LEGAL_PAGE_R2 */


/*
 * DEV103_PERFORMANCE_R2_STORY_PAGINATION
 */
.story-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-top: 22px;
    padding: 14px 0 4px;
    flex-wrap: wrap;
}

.story-pagination[hidden] {
    display: none !important;
}

.story-pagination-summary {
    color: var(--text-muted);
    font-size: .92rem;
}

.story-pagination-controls {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 7px;
    flex-wrap: wrap;
}

.story-page-button {
    min-width: 42px;
    min-height: 42px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    cursor: pointer;
}

.story-page-button:hover:not(:disabled):not(.is-current) {
    background: var(--surface-3);
}

.story-page-button.is-current {
    font-weight: 700;
    cursor: default;
}

.story-page-button:disabled {
    opacity: .45;
    cursor: default;
}

.story-page-ellipsis {
    min-width: 22px;
    text-align: center;
    color: var(--text-muted);
}

@media (max-width: 760px) {
    .story-pagination {
        align-items: stretch;
        flex-direction: column;
    }

    .story-pagination-controls {
        justify-content: center;
    }

    .story-pagination-summary {
        text-align: center;
    }
}


/*
 * DEV103_R2C_STORY_SORT_DARK_NATIVE
 *
 * Chromium unter Linux rendert die aufgeklappte native
 * Select-Liste sonst teilweise mit hellem Systemhintergrund,
 * obwohl Storyraum selbst im Dark-Theme läuft.
 */
#storySort {
    color-scheme: dark;
    background-color: var(--surface-2, #17131f);
    color: var(--text, #f7f3ff);
    border-color: var(--border, #393243);
}

#storySort option {
    background-color: var(--surface-2, #17131f);
    color: var(--text, #f7f3ff);
}

#storySort option:checked {
    background-color: var(--accent, #7c3aed);
    color: #ffffff;
}

#storySort:focus {
    color: var(--text, #f7f3ff);
}

@media (prefers-color-scheme: dark) {
    #storySort {
        color-scheme: dark;
    }
}

/* =========================================================
   DEVELOPMENT #95 · R7C-B SAFETY GATE
   ========================================================= */

.storyraum-safety-card {
    display: grid;
    gap: 14px;
    width: min(100%, 860px);
    margin: 18px auto 24px;
    padding: 18px;
    border: 1px solid rgba(248, 113, 113, 0.5);
    border-radius: 18px;
    background:
        linear-gradient(
            145deg,
            rgba(127, 29, 29, 0.38),
            rgba(34, 14, 22, 0.96)
        );
    box-shadow:
        0 18px 48px
        rgba(0, 0, 0, 0.28);
    color: #fee2e2;
}

.storyraum-safety-heading {
    display: grid;
    gap: 4px;
}

.storyraum-safety-heading h3,
.storyraum-safety-card p {
    margin: 0;
}

.storyraum-safety-brand {
    color: #fca5a5;
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.storyraum-safety-heading h3 {
    color: #fff1f2;
    font-size: 1.05rem;
}

.storyraum-safety-body,
.storyraum-safety-help-intro,
.storyraum-safety-muted {
    color: #fecaca;
    line-height: 1.55;
}

.storyraum-safety-resources {
    display: grid;
    gap: 10px;
}

.storyraum-safety-support-block {
    display: grid;
    gap: 7px;
    padding: 12px;
    border:
        1px solid
        rgba(254, 202, 202, 0.18);
    border-radius: 14px;
    background:
        rgba(0, 0, 0, 0.16);
}

.storyraum-safety-support-block.is-emergency {
    border-color:
        rgba(248, 113, 113, 0.42);
    background:
        rgba(127, 29, 29, 0.26);
}

.storyraum-safety-support-title,
.storyraum-safety-service-name {
    color: #fff;
}

.storyraum-safety-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px 16px;
}

.storyraum-safety-label,
.storyraum-safety-source-note,
.storyraum-safety-secondary-contact {
    color: #fda4af;
}

.storyraum-safety-value {
    color: #fff7f7;
    overflow-wrap: anywhere;
    text-align: right;
}

.storyraum-safety-country-controls,
.storyraum-safety-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.storyraum-safety-country-select {
    min-width: min(100%, 280px);
    min-height: 40px;
    border:
        1px solid
        rgba(254, 202, 202, 0.28);
    border-radius: 10px;
    background: #211217;
    color: #fff;
}

.storyraum-safety-country-select[hidden] {
    display: none !important;
}

.storyraum-safety-confirm {
    min-height: 42px;
    padding: 0 15px;
    border:
        1px solid
        rgba(254, 202, 202, 0.46);
    border-radius: 12px;
    background:
        linear-gradient(
            135deg,
            #dc2626,
            #991b1b
        );
    color: #fff;
    cursor: pointer;
    font: inherit;
    font-weight: 800;
}

.storyraum-safety-confirm:hover:not(:disabled) {
    filter: brightness(1.08);
}

.storyraum-safety-confirm:disabled {
    cursor: wait;
    opacity: 0.55;
}

.storyraum-safety-confirmed {
    flex: 1 1 100%;
    color: #fecaca;
    font-size: 0.84rem;
}

@media (max-width: 640px) {
    .storyraum-safety-card {
        padding: 15px;
        border-radius: 16px;
    }

    .storyraum-safety-country-controls,
    .storyraum-safety-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .storyraum-safety-country-controls > *,
    .storyraum-safety-actions > * {
        width: 100%;
    }

    .storyraum-safety-value {
        text-align: left;
    }
}

/* /DEVELOPMENT #95 · R7C-B SAFETY GATE */


/* =========================================================
   STORYRAUM DEVELOPMENT #121
   DEV121_PUBLIC_RESPONSE_FORMAT_R1

   Öffentliche Admin-Rückmeldungen bewahren die im Admin-
   Textfeld eingegebenen Absätze und Zeilenumbrüche.
========================================================= */

.feedback-admin-response {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    line-height: 1.62;
}

.feedback-admin-response > strong {
    display: block;
    margin-bottom: .55rem;
}

.feedback-admin-response > span {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
/*
 * ============================================================
 * DEVELOPMENT_102_CHATNPC_PRESENTATION_R1
 * ChatNPC · ruhige Markdown-/Code-Darstellung
 * ============================================================
 */

.r80-ai-chat-markdown-paragraph {
    margin: .55rem 0;
    line-height: 1.68;
    overflow-wrap: anywhere;
}

.r80-ai-chat-markdown-paragraph:first-child {
    margin-top: 0;
}

.r80-ai-chat-markdown-paragraph:last-child {
    margin-bottom: 0;
}

.r80-ai-chat-markdown-heading {
    margin: 1.35rem 0 .55rem;
    line-height: 1.28;
    font-weight: 720;
    letter-spacing: -.015em;
}

h2.r80-ai-chat-markdown-heading {
    font-size: 1.3rem;
}

h3.r80-ai-chat-markdown-heading {
    font-size: 1.16rem;
}

h4.r80-ai-chat-markdown-heading {
    font-size: 1.05rem;
}

.r80-ai-chat-markdown-list {
    margin: .65rem 0 .85rem;
    padding-inline-start: 1.55rem;
}

.r80-ai-chat-markdown-list li {
    margin: .28rem 0;
    padding-inline-start: .15rem;
    line-height: 1.62;
}

.r80-ai-chat-markdown-quote {
    margin: .85rem 0;
    padding: .28rem .2rem .28rem .95rem;
    border-inline-start:
        3px solid rgba(148, 163, 184, .48);
    color: rgba(226, 232, 240, .82);
    line-height: 1.65;
}

.r80-ai-chat-inline-code {
    display: inline;
    padding: .12em .38em;
    border:
        1px solid rgba(148, 163, 184, .2);
    border-radius: .42rem;
    background:
        rgba(148, 163, 184, .13);
    font-family:
        ui-monospace,
        SFMono-Regular,
        Menlo,
        Monaco,
        Consolas,
        "Liberation Mono",
        monospace;
    font-size: .91em;
    line-height: 1.45;
    white-space: break-spaces;
    overflow-wrap: anywhere;
}

.r102-ai-chat-code-shell {
    width: 100%;
    margin: .9rem 0 1rem;
    overflow: hidden;
    border:
        1px solid rgba(148, 163, 184, .2);
    border-radius: 13px;
    background: #0d0f12;
    box-shadow:
        0 1px 1px rgba(0, 0, 0, .16);
}

.r102-ai-chat-code-toolbar {
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 7px 10px 7px 14px;
    border-bottom:
        1px solid rgba(148, 163, 184, .13);
    background: #181a1f;
}

.r102-ai-chat-code-language {
    min-width: 0;
    overflow: hidden;
    color: rgba(226, 232, 240, .76);
    font-size: .78rem;
    font-weight: 600;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.r102-ai-chat-code-copy {
    appearance: none;
    min-height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex: 0 0 auto;
    margin: 0;
    padding: 5px 8px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: rgba(241, 245, 249, .82);
    font: inherit;
    font-size: .76rem;
    font-weight: 560;
    line-height: 1;
    cursor: pointer;
    transition:
        background .14s ease,
        color .14s ease,
        opacity .14s ease;
}

.r102-ai-chat-code-copy:hover {
    background:
        rgba(255, 255, 255, .075);
    color: #fff;
}

.r102-ai-chat-code-copy:focus-visible {
    outline:
        2px solid rgba(167, 139, 250, .9);
    outline-offset: 2px;
}

.r102-ai-chat-code-copy:disabled {
    cursor: default;
    opacity: .84;
}

.r102-ai-chat-code-copy.is-copied {
    color: #bbf7d0;
}

.r102-ai-chat-code-copy.is-error {
    color: #fecaca;
}

.r102-ai-chat-code-copy-icon {
    display: inline-grid;
    place-items: center;
    width: 1rem;
    height: 1rem;
    font-size: .95rem;
    line-height: 1;
}

.r102-ai-chat-code-shell
.r80-ai-chat-code-block {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 16px 18px 18px;
    overflow-x: auto;
    overflow-y: hidden;
    border: 0;
    border-radius: 0;
    background: #0d0f12;
    color: #e8eaed;
    white-space: pre;
    tab-size: 4;
    scrollbar-width: thin;
}

.r102-ai-chat-code-shell
.r80-ai-chat-code-block code {
    display: block;
    min-width: max-content;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font-family:
        ui-monospace,
        SFMono-Regular,
        Menlo,
        Monaco,
        Consolas,
        "Liberation Mono",
        monospace;
    font-size: .88rem;
    line-height: 1.58;
    white-space: pre;
}

.r102-ai-chat-clipboard-fallback {
    position: fixed !important;
    left: -10000px !important;
    top: 0 !important;
    width: 1px !important;
    height: 1px !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

@media (max-width: 640px) {
    .r102-ai-chat-code-toolbar {
        min-height: 40px;
        padding-inline:
            12px 7px;
    }

    .r102-ai-chat-code-copy {
        padding-inline: 7px;
    }

    .r102-ai-chat-code-shell
    .r80-ai-chat-code-block {
        padding:
            14px 14px 16px;
    }

    .r102-ai-chat-code-shell
    .r80-ai-chat-code-block code {
        font-size: .82rem;
    }
}

/*
 * ============================================================
 * DEVELOPMENT_102_SYNTAX_HIGHLIGHTING_CSS_R2
 * ============================================================
 */

.r102-ai-chat-syntax-comment {
    color: #7f8c98;
    font-style: italic;
}

.r102-ai-chat-syntax-keyword {
    color: #c792ea;
    font-weight: 600;
}

.r102-ai-chat-syntax-string {
    color: #a5d6a7;
}

.r102-ai-chat-syntax-number {
    color: #f78c6c;
}

.r102-ai-chat-syntax-function {
    color: #82aaff;
}

.r102-ai-chat-syntax-variable {
    color: #f07178;
}

.r102-ai-chat-syntax-builtin {
    color: #c3e88d;
}

.r102-ai-chat-syntax-property {
    color: #ffcb6b;
}

.r102-ai-chat-syntax-tag {
    color: #89ddff;
}

.r102-ai-chat-syntax-operator {
    color: #89ddff;
}

.r102-ai-chat-syntax-decorator {
    color: #f78c6c;
}

.r102-ai-chat-code-shell
.r80-ai-chat-code-block
::selection {
    background:
        rgba(130, 170, 255, .28);
}


/* DEVELOPMENT #153 · PUBLIC RELEASE VERSION LINK */
.sidebar-version-link {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    margin-top: 7px;
    padding: 5px 8px 2px;
    border: 0;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 0.68rem;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    opacity: 0.82;
    transition:
        color 160ms ease,
        opacity 160ms ease;
}

.sidebar-version-link:hover,
.sidebar-version-link:focus-visible {
    color: var(--text);
    opacity: 1;
}

.sidebar-version-link:focus-visible {
    outline: 2px solid rgba(168, 85, 247, 0.55);
    outline-offset: 2px;
    border-radius: 7px;
}

.sidebar-version-link[hidden] {
    display: none;
}

#storyraumVersionNumber {
    font-variant-numeric: tabular-nums;
}
/* /DEVELOPMENT #153 · PUBLIC RELEASE VERSION LINK */
