:root {
    color-scheme: light;
    --bg: #f7f1fb;
    --panel: rgba(255, 255, 255, 0.9);
    --text: #22172e;
    --accent: #7b2cbf;
    --accent-dark: #d7263d;
    --accent-soft: #b5179e;
    --border: rgba(58, 21, 88, 0.14);
    --error: #c1121f;
    --success: #6a1b9a;
    --shadow: 0 18px 60px rgba(78, 28, 117, 0.16);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Segoe UI", sans-serif;
    color: var(--text);
    padding: 0;
}

body.menu-open {
    overflow: hidden;
}

body.page-character,
body.page-stories,
body.page-login {
    background:
        radial-gradient(circle at top, rgba(123, 44, 191, 0.26), transparent 36%),
        radial-gradient(circle at right, rgba(215, 38, 61, 0.18), transparent 30%),
        linear-gradient(160deg, #fbf7ff 0%, #f4dce5 100%);
}

body.page-account {
    background:
        radial-gradient(circle at top right, rgba(123, 44, 191, 0.22), transparent 30%),
        radial-gradient(circle at left, rgba(215, 38, 61, 0.16), transparent 28%),
        linear-gradient(180deg, #fbf7ff 0%, #f4dce5 100%);
}

.page,
.layout {
    width: 100%;
    margin: 0 auto;
}

.topbar {
    margin-bottom: 16px;
    position: relative;
    z-index: 100;
}

.topbar__inner,
.card,
.hero {
    background: var(--panel);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
}

.topbar__inner {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 16px;
    border-radius: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
    backdrop-filter: none;
}

/* Mobile-only Aktion oben rechts, vertikal mittig zum Hamburger-Toggle.
   Auf Desktop unsichtbar; die jeweiligen Aktions-Buttons stehen dort
   weiterhin innerhalb der Seite (stories-head / editor-head / ...). */
.top-right-button {
    display: none;
    position: absolute;
    top: 16px;
    right: 16px;
    min-height: 52px;
    padding: 12px 16px;
    border-radius: 16px;
    border: 1px solid rgba(123, 44, 191, 0.18);
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    color: #fff !important;
    font-weight: 700;
    font-size: 0.92rem;
    text-decoration: none !important;
    text-decoration-line: none !important;
    box-shadow: 0 10px 24px rgba(78, 28, 117, 0.18);
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: transform 180ms ease, box-shadow 180ms ease;
}

.top-right-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 28px rgba(78, 28, 117, 0.24);
}

/* Floating "Nach oben"-Button -- erst sichtbar ab scrollY > 1000 (durch JS-Klasse) */
.scroll-top-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    min-height: 48px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    color: #fff;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 10px 24px rgba(78, 28, 117, 0.28);
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);
    transition: opacity 180ms ease, transform 180ms ease, box-shadow 180ms ease;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
}

.scroll-top-btn.is-visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.scroll-top-btn:hover {
    box-shadow: 0 14px 28px rgba(78, 28, 117, 0.36);
    transform: translateY(-1px);
}

@media (max-width: 720px) {
    .top-right-button {
        display: inline-flex;
    }
    /* Desktop-Action-Buttons mit Mobile-Pendant in der Topbar: nur die
       explizit markierten Items ausblenden, damit Funktionen wie
       "Spielleitung" weiterhin sichtbar bleiben. */
    .is-desktop-only,
    .stories-head > .button-link.is-desktop-only,
    .editor-head__actions > .is-desktop-only,
    .stories-head__actions > .is-desktop-only {
        display: none !important;
    }
}

.topbar__toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: fit-content;
    min-width: 52px;
    min-height: 52px;
    padding: 10px 12px;
    border-radius: 16px;
    border: 1px solid rgba(123, 44, 191, 0.18);
    background: linear-gradient(135deg, rgba(123, 44, 191, 0.16), rgba(215, 38, 61, 0.14)), rgba(255, 255, 255, 0.92);
    color: var(--text);
    cursor: pointer;
    box-shadow: 0 10px 24px rgba(78, 28, 117, 0.12);
    transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.topbar__toggle--open {
    align-self: flex-start;
}

.topbar__toggle--close {
    position: absolute;
    top: 16px;
    left: 16px;
    right: auto;
    z-index: 2147483647;
}

.topbar__toggle:hover {
    transform: translateY(-1px);
    border-color: rgba(123, 44, 191, 0.28);
    box-shadow: 0 14px 28px rgba(78, 28, 117, 0.16);
}

.topbar__toggle:focus-visible {
    outline: 2px solid rgba(123, 44, 191, 0.25);
    outline-offset: 2px;
}

.topbar__toggle-icon {
    position: relative;
    display: inline-flex;
    width: 20px;
    height: 16px;
}

.topbar__toggle-icon span {
    position: absolute;
    left: 0;
    display: block;
    width: 20px;
    height: 2px;
    border-radius: 999px;
    background: currentColor;
    transform-origin: center;
    transition: transform 180ms ease, opacity 180ms ease, top 180ms ease;
}

.topbar__toggle-icon span:nth-child(1) {
    top: 0;
}

.topbar__toggle-icon span:nth-child(2) {
    top: 7px;
}

.topbar__toggle-icon span:nth-child(3) {
    top: 14px;
}

.topbar__toggle[aria-expanded="true"] .topbar__toggle-icon span:nth-child(1) {
    top: 7px;
    transform: rotate(45deg);
}

.topbar__toggle[aria-expanded="true"] .topbar__toggle-icon span:nth-child(2) {
    opacity: 0;
}

.topbar__toggle[aria-expanded="true"] .topbar__toggle-icon span:nth-child(3) {
    top: 7px;
    transform: rotate(-45deg);
}

.topbar__nav {
    display: none;
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    min-height: 100vh;
    flex-direction: column;
    justify-content: flex-start;
    gap: 4px;
    margin-left: 0;
    margin: 0;
    padding: 96px 0;
    background:
        radial-gradient(circle at top, rgba(123, 44, 191, 0.3), transparent 34%),
        radial-gradient(circle at bottom, rgba(215, 38, 61, 0.22), transparent 32%),
        rgba(251, 247, 255, 0.97);
    backdrop-filter: blur(18px);
    z-index: 2147483646;
}

.topbar__nav.is-open {
    display: flex;
}

.topbar__link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 16px 18px;
    border-radius: 18px;
    text-decoration: none;
    color: var(--text);
    font-weight: 700;
    border: 1px solid rgba(123, 44, 191, 0.14);
    transition: background 180ms ease, border-color 180ms ease, transform 180ms ease;
    flex: 0 0 auto;
    background: rgba(255, 255, 255, 0.7);
}

.topbar__link:hover,
.topbar__link.is-active {
    background: linear-gradient(135deg, rgba(123, 44, 191, 0.18), rgba(215, 38, 61, 0.16));
    border-color: rgba(123, 44, 191, 0.24);
}

.is-hidden {
    display: none !important;
}

.topbar__link:hover {
    transform: translateY(-1px);
}

.card {
    width: 100%;
    border-radius: 18px;
    padding: 20px 18px;
}

.card.card--wide {
    width: 100%;
    padding: 20px 18px;
}

.hero {
    width: 100%;
    border-radius: 24px;
    padding: 22px 18px;
}

.hero--characters {
    padding-bottom: 32px;
}

.hero--stories {
    padding-bottom: 32px;
}

.hero--account {
    padding-bottom: 32px;
}

.hero .card + .card {
    margin-top: 16px;
}

.editor-head {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 20px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.72);
}

.editor-head__actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.editor-head--compact {
    margin-bottom: 14px;
}

.story-card--clickable,
.story-card--clickable:link,
.story-card--clickable:visited {
    display: block;
    text-decoration: none !important;
    text-decoration-line: none !important;
    color: inherit !important;
    transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.story-card--clickable:hover {
    transform: translateY(-1px);
    border-color: rgba(123, 44, 191, 0.24);
    box-shadow: 0 20px 34px rgba(78, 28, 117, 0.14);
}

.floating-action-button,
.floating-action-button:link,
.floating-action-button:visited {
    position: fixed;
    right: 18px !important;
    bottom: 18px !important;
    left: auto !important;
    top: auto !important;
    z-index: 2147483000;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 62px;
    height: 62px;
    border-radius: 999px;
    border: 0;
    text-decoration: none !important;
    text-decoration-line: none !important;
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
    color: #fff !important;
    background: linear-gradient(135deg, var(--accent), var(--accent-dark)) !important;
    box-shadow: 0 18px 34px rgba(78, 28, 117, 0.28) !important;
    transition: transform 180ms ease, box-shadow 180ms ease, filter 180ms ease;
}

.floating-action-button:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 22px 40px rgba(78, 28, 117, 0.34);
    filter: saturate(1.08);
}

.floating-action-button:focus-visible {
    outline: 3px solid rgba(123, 44, 191, 0.22);
    outline-offset: 3px;
}

.login-wrap {
    min-height: calc(100vh - 110px);
    display: block;
}

h1,
h2 {
    margin: 0 0 10px;
}

h1 {
    font-size: 1.7rem;
}

p {
    margin: 0 0 24px;
    line-height: 1.5;
}

label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
}

input,
select {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px 16px;
    font: inherit;
    margin-bottom: 18px;
    background: #fff;
}

textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px 16px;
    font: inherit;
    margin-bottom: 18px;
    background: #fff;
    resize: vertical;
    min-height: 160px;
}

input:focus {
    outline: 2px solid rgba(123, 44, 191, 0.22);
    border-color: var(--accent);
}

select:focus {
    outline: 2px solid rgba(123, 44, 191, 0.22);
    border-color: var(--accent);
}

textarea:focus {
    outline: 2px solid rgba(123, 44, 191, 0.22);
    border-color: var(--accent);
}

.story-play {
    display: grid;
    gap: 18px;
    background: transparent !important;
}

.card
{
    box-shadow: none;
}

.story-play__status-card,
.story-play__entries,
.story-play__form-card,
.story-play__waiting,
.story-play__director {
    width: 100%;
}

/* ---------- Director-Mode (ChiroxT-only) ----------------------------- */
.story-play__director {
    border-left: 4px solid #a855f7;
}

.story-play__director h2 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 0;
}

.story-director__badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.72em;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    background: #a855f7;
    color: #fff;
}

.story-director__pending {
    margin: 8px 0 12px;
    padding: 8px 12px;
    border-radius: 10px;
    background: rgba(168, 85, 247, 0.12);
    border: 1px solid rgba(168, 85, 247, 0.35);
    color: #581c87;
    font-size: 0.92em;
}

.story-play__director textarea {
    width: 100%;
    min-height: 72px;
    resize: vertical;
    margin-bottom: 0;
}

.story-director__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.story-director__counter {
    font-size: 0.85em;
    color: var(--muted, #666);
    font-variant-numeric: tabular-nums;
}

.story-play__entries
{
    background: transparent !important;
    border: 0 !important;
    padding: 0px !important;
}

.story-play__meta {
    margin: 0 0 10px;
}

.story-status-actions {
    margin: 14px 0 4px;
}

.story-entries {
    display: grid;
    gap: 16px;
}

.story-entry {
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.72);
    display: grid;
    gap: 14px;
    box-shadow: var(--shadow);
}

.story-entry__label {
    margin: 0 0 10px;
    font-weight: 700;
    color: var(--accent-dark);
}

.story-entry__text {
    line-height: 1.65;
    white-space: normal;
}

.story-entry__audio {
    width: 100%;
    margin-top: 8px;
}

.story-card__unread {
    display: inline-block;
    margin-top: 4px;
    padding: 2px 10px;
    border-radius: 999px;
    background: var(--accent, #7b2cbf);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 700;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(34, 23, 46, 0.55);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 60px 20px 20px;
    z-index: 9000;
    overflow-y: auto;
    backdrop-filter: blur(2px);
}

.modal {
    width: 100%;
    max-width: 720px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow);
    padding: 18px 18px 22px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    backdrop-filter: blur(10px);
}

/* Vollbild-Modal auf Mobile (Spielleitung etc.) -- ueber der gesamten UI */
@media (max-width: 720px) {
    .modal-backdrop {
        padding: 0;
        align-items: stretch;
    }
    .modal {
        max-width: none;
        width: 100%;
        min-height: 100%;
        border-radius: 0;
        border: 0;
    }
}

.modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.modal__header h2 {
    margin: 0;
}

.modal__close {
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.78);
    color: var(--text);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    transition: background 160ms ease, transform 160ms ease;
}

.modal__close:hover {
    background: rgba(255, 255, 255, 0.95);
    transform: scale(1.05);
}

.modal__body {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

body.modal-open {
    overflow: hidden;
}

.story-play__owner {
    margin-bottom: 16px;
}

.story-owner__players {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 12px 0 18px;
}

.story-owner__player {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.7);
}

.story-owner__player-name {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.story-owner__player-link {
    cursor: pointer;
    text-decoration: underline;
    text-decoration-color: rgba(34, 23, 46, 0.25);
    text-underline-offset: 3px;
    transition: text-decoration-color 0.15s ease;
}

.story-owner__player-link:hover,
.story-owner__player-link:focus-visible {
    text-decoration-color: rgba(159, 102, 200, 0.8);
}

.story-owner__player-meta {
    color: rgba(34, 23, 46, 0.66);
    font-size: 0.85rem;
}

.story-owner__player-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-end;
}

.button-link.danger {
    background: #b3261e;
    color: #fff;
    border-color: #b3261e;
}

.button-link.danger:hover:not(:disabled) {
    background: #931d17;
    border-color: #931d17;
}

.story-owner__invite {
    margin-top: 10px;
    padding-top: 14px;
    border-top: 1px solid rgba(58, 21, 88, 0.1);
}

.story-owner__invite h3 {
    margin: 0 0 4px;
}

.story-owner__invite-form {
    display: grid;
    gap: 8px;
    margin-top: 10px;
}

.story-owner__invite-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 14px;
}

.story-owner__invite-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.6);
}

.story-owner__invite-item.is-used {
    opacity: 0.6;
}

.story-owner__invite-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.story-owner__invite-meta code {
    font-family: ui-monospace, monospace;
    font-size: 0.85rem;
}

.story-owner__invite-meta span {
    color: rgba(34, 23, 46, 0.66);
    font-size: 0.85rem;
}

.story-entry__footer {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 10px;
}

.story-entry__media {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.story-entry__media .story-entry__audio,
.story-entry__media .story-entry__progress {
    width: 100%;
    margin: 0;
}

.story-entry__actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.story-entry__action-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.78);
    color: var(--text);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    transition: background 160ms ease, color 160ms ease, transform 160ms ease, border-color 160ms ease;
}

.story-entry__action-btn:hover {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(123, 44, 191, 0.3);
    transform: translateY(-1px);
}

.story-entry__read {
    color: rgba(34, 23, 46, 0.42);
}

.story-entry__read.is-read {
    color: #fff;
    background: var(--accent, #7b2cbf);
    border-color: var(--accent, #7b2cbf);
    cursor: default;
}

.story-entry__read.is-read:hover {
    transform: none;
}

.story-entry__progress {
    width: 100%;
    margin-top: 8px;
    height: 8px;
    appearance: none;
    border: none;
    background: rgba(58, 21, 88, 0.08);
    border-radius: 4px;
    overflow: hidden;
}

.story-entry__progress::-webkit-progress-bar {
    background: rgba(58, 21, 88, 0.08);
    border-radius: 4px;
}

.story-entry__progress::-webkit-progress-value {
    background: var(--accent-dark, #6c2bd9);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.story-entry__progress::-moz-progress-bar {
    background: var(--accent-dark, #6c2bd9);
    border-radius: 4px;
}

.story-entry__image {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 14px;
    border: 1px solid rgba(58, 21, 88, 0.12);
    background: rgba(255, 255, 255, 0.88);
    margin-bottom: 10px;
}

.story-entry__upload {
    margin-top: 10px;
}

.notification-status {
    margin-top: 16px;
    margin-bottom: 0;
}

/* Solange noch kein Status-Text drin steht (Element wird leer ins DOM gerendert
   und erst von notifications.js bei Bedarf befuellt), den Pill komplett ausblenden. */
.notification-status:empty {
    display: none;
}

button,
.button-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 12px 16px;
    border-radius: 12px;
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    color: #fff;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-soft) 45%, var(--accent-dark) 100%);
    border: 0;
    cursor: pointer;
}

button {
    width: 100%;
}

.button-link.secondary {
    background: #fff;
    color: var(--text);
    border: 1px solid var(--border);
}

.button-link.ghost {
    background: rgba(123, 44, 191, 0.1);
    color: var(--success);
    border: 1px solid rgba(123, 44, 191, 0.12);
}

.error,
.message {
    margin-top: 18px;
    padding: 12px 14px;
    border-radius: 12px;
}

.error,
.message.error {
    margin-bottom: 18px;
    background: rgba(193, 18, 31, 0.1);
    color: var(--error);
}

.message.success {
    background: rgba(123, 44, 191, 0.1);
    color: var(--success);
}

.welcome {
    font-size: 1.1rem;
    margin-bottom: 18px;
}

.meta {
    color: rgba(34, 23, 46, 0.78);
    margin-bottom: 28px;
}

.hint {
    margin-top: 8px;
    color: rgba(34, 23, 46, 0.75);
    font-size: 0.95rem;
}

.actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.character-grid {
    display: grid;
    gap: 18px;
}

.character-list {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
}

.story-list {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
}

.character-card {
    background: rgba(255, 255, 255, 0.76);
}

.list-card {
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: rgba(255, 255, 255, 0.76);
}

.list-card h3 {
    margin-top: 0;
}

.story-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: rgba(255, 255, 255, 0.76);
}

.story-card__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.story-card__head h3
{
    margin: 0;
}

.story-card__meta {
    display: flex;
    flex-direction: column;
    gap: 8px;
    color: rgba(34, 23, 46, 0.72);
    word-break: break-word;
}

.list-card__main {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.list-card__actions {
    display: flex;
    gap: 12px;
}

.list-card__actions--wrap {
    flex-wrap: wrap;
}

.character-card__header,
.import-box__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.import-box__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.character-random-form {
    margin: 0;
}

.character-card__subtitle {
    margin-bottom: 0;
    color: rgba(34, 23, 46, 0.72);
}

.character-card__meta {
    margin: 10px 0 0;
    color: rgba(34, 23, 46, 0.68);
}

.character-card__badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(123, 44, 191, 0.1);
    color: var(--accent);
    font-size: 0.92rem;
    font-weight: 700;
    white-space: nowrap;
}

.character-form,
.character-delete-form,
.character-import-form {
    margin-top: 18px;
}

.inline-form {
    width: 100%;
}

.character-import-form.is-hidden {
    display: none;
}

.character-actions {
    display: flex;
    gap: 12px;
}

.stories-head {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 36px;
}

.button-link--button {
    width: 100%;
}

.import-box {
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid rgba(58, 21, 88, 0.1);
}

.import-box--visible {
    margin-bottom: 24px;
}

.import-box h3 {
    margin: 0;
}

.import-textarea {
    min-height: 220px;
    font-family: inherit;
}

.story-form,
.copy-row {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.hub-section {
    margin-top: 28px;
}

.story-slots {
    margin-top: 14px;
    padding-top: 18px;
    border-top: 1px solid rgba(58, 21, 88, 0.1);
}

.story-slot {
    margin-top: 14px;
}

.choice-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 12px;
}

.choice-pill {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.choice-pill input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.choice-pill span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.86);
    color: var(--text);
    font-weight: 700;
    cursor: pointer;
    transition: background 160ms ease, border-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.choice-pill input:checked + span {
    background: rgba(43, 161, 74, 0.14);
    border-color: rgba(43, 161, 74, 0.55);
    color: #1f6b34;
    box-shadow: inset 0 0 0 1px rgba(43, 161, 74, 0.15);
}

.toggle-switch {
    display: inline-flex;
    align-items: center;
    align-self: flex-start;
    width: fit-content;
    gap: 12px;
    margin: 4px 0 8px;
    cursor: pointer;
    user-select: none;
}

.toggle-switch input {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    border: 0;
    pointer-events: none;
}

.toggle-switch__track {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    border-radius: 999px;
    background: rgba(58, 21, 88, 0.22);
    transition: background 180ms ease;
    flex-shrink: 0;
}

.toggle-switch__track::before {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.18);
    transition: transform 180ms ease;
}

.toggle-switch input:checked + .toggle-switch__track {
    background: var(--accent, #7b2cbf);
}

.toggle-switch input:checked + .toggle-switch__track::before {
    transform: translateX(22px);
}

.toggle-switch input:focus-visible + .toggle-switch__track {
    outline: 2px solid rgba(123, 44, 191, 0.4);
    outline-offset: 2px;
}

.toggle-switch__text {
    font-weight: 700;
    color: var(--text);
}

.empty-state,
.success-card {
    background: rgba(255, 255, 255, 0.76);
}

.prompt-output {
    min-height: 320px;
    font-size: 0.95rem;
    line-height: 1.5;
}

.prompt-output--hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: 0;
    border: 0;
    opacity: 0;
    pointer-events: none;
    overflow: hidden;
}

.character-limit {
    display: inline-flex;
    align-items: center;
    min-height: 48px;
    padding: 12px 16px;
    border-radius: 12px;
    background: rgba(123, 44, 191, 0.08);
    color: var(--accent);
    font-weight: 700;
}

.submit-loading button[type="submit"] {
    opacity: 0.85;
}

@media (min-width: 768px) {
    body {
        padding: 0;
    }

    .topbar__inner {
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
        gap: 16px;
        padding: 18px 22px;
    }

    .topbar__toggle {
        display: none;
    }

    .topbar__toggle--close {
        display: none;
    }

    .topbar__nav {
        position: static;
        display: flex;
        flex-direction: row;
        width: auto;
        height: auto;
        min-height: 0;
        justify-content: flex-start;
        margin-left: 0;
        margin: 0;
        padding: 0;
        gap: 10px;
        background: transparent;
        backdrop-filter: none;
        z-index: auto;
    }

    .topbar__link {
        width: auto;
        flex: 0 0 auto;
        min-height: 44px;
        padding: 10px 14px;
        border-radius: 12px;
        border: 1px solid transparent;
        background: transparent;
    }

    .card {
        padding: 32px;
    }

    .card.card--wide {
        padding: 28px 24px;
    }

    .hero {
        padding: 36px;
    }

    .login-wrap {
        min-height: calc(100vh - 140px);
        display: grid;
        place-items: center;
    }

    h1 {
        font-size: 2rem;
    }

    .actions {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .button-link {
        width: auto;
    }

    .editor-head,
    .list-card,
    .stories-head {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    .editor-head {
        align-items: flex-start;
    }

    .editor-head__actions {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    .list-card__actions {
        flex: 0 0 auto;
    }

    .inline-form {
        width: auto;
    }

    .story-card__meta,
    .copy-row {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    .character-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        align-items: start;
    }

    .import-box__header {
        align-items: center;
    }

    .button-link--button {
        width: auto;
    }
}

/* ----- Character-Card-Ansicht (/characters/<id>) -------------------------
 *
 * Gesamte Seite ist nicht scrollbar -- nur die rechte Spalte (Felder).
 * Links bleibt das Bild fix, rechts uebernimmt overflow-y: auto.
 */
body.page-character-card {
    height: 100vh;
    overflow: hidden;
}

body.page-character-card .page {
    height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

body.page-character-card .hero {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

body.page-character-card .hero > .stories-head {
    flex: 0 0 auto;
}

body.page-character-card .hero > .character-card-card {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.character-card-view {
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(180px, 240px) minmax(0, 1fr);
    gap: 24px;
    align-items: stretch;
    overflow: hidden;
}

.character-card-view__image {
    width: 100%;
    align-self: start;
}

.character-card-view__image-placeholder {
    aspect-ratio: 3 / 4;
    width: 100%;
    border-radius: 16px;
    border: 2px dashed rgba(34, 23, 46, 0.25);
    background: rgba(34, 23, 46, 0.04);
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(34, 23, 46, 0.55);
    font-size: 0.95rem;
    text-align: center;
    padding: 12px;
}

.character-card-view__avatar {
    width: 100%;
    aspect-ratio: 3 / 4;
    object-fit: contain;
    border-radius: 16px;
    background: transparent;
    display: block;
}

/* Bild-Preview im Edit-View */
.character-image-preview {
    display: flex;
    justify-content: center;
    margin: 0 auto 12px;
}

.character-image-preview img {
    height: 500px;
    width: auto;
    max-width: 100%;
    border-radius: 12px;
    background: transparent;
    display: block;
    object-fit: contain;
}

.character-image-form select {
    margin-bottom: 12px;
}

/* Story-Prep: Slot-Uebersicht mit Spielernamen + Charakterbild */
/* Hub-Suche: Container der via AJAX neu befuellt wird */
[data-hub-search-results] {
    transition: opacity 0.15s ease;
}
[data-hub-search-results].is-loading {
    opacity: 0.5;
    pointer-events: none;
}

/* Hub-Suche: Karten-Liste, Karten fliessen nebeneinander und wrappen
   automatisch, wenn das Fenster schmaler wird. */
.hub-search-list {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 18px;
}

.hub-search-card {
    flex: 1 1 220px;
    max-width: 280px;
    min-width: 200px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid rgba(34, 23, 46, 0.08);
    box-shadow: 0 1px 2px rgba(34, 23, 46, 0.04);
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.hub-search-card:hover {
    transform: translateY(-1px);
    border-color: rgba(159, 102, 200, 0.4);
    box-shadow: 0 10px 22px rgba(78, 28, 117, 0.12);
}

/* Klickflaeche: alles ausser den Action-Buttons triggert das Card-Overlay */
.hub-search-card__body {
    display: flex;
    flex-direction: column;
    gap: 10px;
    cursor: pointer;
    min-width: 0;
}

.hub-search-card__body:focus-visible {
    outline: 2px solid rgba(159, 102, 200, 0.6);
    outline-offset: 2px;
    border-radius: 12px;
}

.hub-search-card__name {
    margin: 0;
    font-size: 1.05rem;
    text-align: center;
    color: rgba(34, 23, 46, 0.92);
    overflow-wrap: anywhere;
    display: flex;
    align-items: baseline;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
}

.hub-search-card__age {
    color: rgba(34, 23, 46, 0.55);
    font-weight: 500;
    font-size: 0.9rem;
}

.hub-search-card__image {
    width: 100%;
    aspect-ratio: 3 / 4;
    border-radius: 12px;
    overflow: hidden;
    background: rgba(34, 23, 46, 0.04);
    display: flex;
    align-items: center;
    justify-content: center;
}

.hub-search-card__image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.hub-search-card__placeholder {
    color: rgba(34, 23, 46, 0.5);
    font-size: 0.85rem;
    text-align: center;
    padding: 12px;
}

.hub-search-card__actions {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 38px;
}

.hub-search-card__actions .inline-form,
.hub-search-card__actions button {
    width: 100%;
}

/* Story-Listen-Tabs (laufend / beendet) -- Desktop: Pillen, Mobile: Combobox */
.story-list-tabs {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 0 18px;
    padding: 4px;
    border-radius: 999px;
    background: rgba(34, 23, 46, 0.06);
}

.story-list-tabs-mobile {
    display: none;
    width: 100%;
    height: 40px;
    margin: 0 0 14px;
    padding: 0 36px 0 14px;
    border-radius: 12px;
    border: 1px solid rgba(34, 23, 46, 0.14);
    background:
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' fill='none' stroke='%2322172e' stroke-opacity='0.6' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>")
        no-repeat right 14px center / 10px,
        #fff;
    color: rgba(34, 23, 46, 0.9);
    font-size: 0.95rem;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
}

/* Filter-Toggle: Auf Desktop nicht angezeigt (Filter sind immer offen),
   Mobile zeigt den Toggle als ersten "Header" innerhalb der Filterleiste */
.story-list-filters-toggle {
    display: none;
    width: 100%;
    height: 40px;
    margin: 0;
    padding: 0 4px;
    border: 0;
    background: transparent;
    color: rgba(34, 23, 46, 0.85);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    align-items: center;
    justify-content: space-between;
}

.story-list-filters-toggle__icon {
    transition: transform 0.2s ease;
    font-size: 0.85rem;
    color: rgba(34, 23, 46, 0.55);
}

.story-list-filters-toggle[aria-expanded="true"] .story-list-filters-toggle__icon {
    transform: rotate(180deg);
}

/* Items-Wrapper: auf Desktop transparent fuer das Flex-Layout (display:contents),
   auf Mobile expliziter Block, der ein-/ausgeklappt wird */
.story-list-filters__items {
    display: contents;
}

/* Sort-Wrapper: bindet "Sortieren nach"-Select + Direction-Button zusammen,
   damit sie auf Mobile in EINER Zeile bleiben (anstatt umzubrechen) */
.story-list-filter-sort {
    display: contents;
}

@media (max-width: 720px) {
    .story-list-tabs {
        display: none;
    }
    .story-list-tabs-mobile {
        display: block;
    }
    .story-list-filters {
        flex-direction: column;
        align-items: stretch;
    }
    .story-list-filters-toggle {
        display: inline-flex;
    }
    /* Items by default ausgeblendet, expandiert als Spalte */
    .story-list-filters__items {
        display: none;
    }
    .story-list-filters.is-expanded .story-list-filters__items {
        display: flex;
        flex-direction: column;
        gap: 10px;
        padding-top: 10px;
        border-top: 1px solid rgba(34, 23, 46, 0.08);
    }
    /* Auf Mobile ist jede Filter-Zelle eine Zeile mit gleich breitem Label,
       damit alle Controls auf einer vertikalen Linie starten. */
    .story-list-filter {
        display: flex;
        align-items: center;
        gap: 8px;
        width: 100%;
    }
    .story-list-filter__label {
        flex: 0 0 130px;
        min-width: 130px;
    }
    .story-list-filter > select,
    .story-list-filter > .story-list-filter__input {
        flex: 1 1 auto;
        min-width: 0;
        width: auto;
    }
    /* Toggle-Switch (Ich war dabei): Track + Text zusammen rechts vom Label */
    .toggle-switch.story-list-filter__switch {
        justify-content: flex-start;
        align-self: stretch;
        gap: 10px;
    }
    /* Sort-Wrapper auf Mobile: Select-Label + Direction-Button in einer Zeile */
    .story-list-filter-sort {
        display: flex;
        align-items: center;
        gap: 8px;
        width: 100%;
    }
    .story-list-filter-sort > .story-list-filter {
        flex: 1 1 auto;
        width: auto;
    }
    /* hub-search-card Mobile: volle Breite, keine seitliche Begrenzung */
    .hub-search-card {
        flex: 1 1 100%;
        max-width: none;
        min-width: 0;
    }
}

.story-list-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 999px;
    text-decoration: none;
    color: rgba(34, 23, 46, 0.7);
    font-weight: 500;
    transition: background 0.15s ease, color 0.15s ease;
}

.story-list-tab:hover {
    color: rgba(34, 23, 46, 0.9);
}

.story-list-tab.is-active {
    background: #fff;
    color: rgba(34, 23, 46, 0.95);
    box-shadow: 0 1px 3px rgba(34, 23, 46, 0.08);
}

.story-list-tab__count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 999px;
    background: rgba(34, 23, 46, 0.12);
    color: rgba(34, 23, 46, 0.75);
    font-size: 0.78rem;
    font-weight: 600;
}

.story-list-tab.is-active .story-list-tab__count {
    background: rgba(159, 102, 200, 0.18);
    color: rgba(118, 60, 168, 0.95);
}

/* Filter-Leiste fuer beendete Stories */
.story-list-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 16px;
    margin: 0 0 18px;
    padding: 12px 16px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(34, 23, 46, 0.08);
    box-shadow: 0 1px 2px rgba(34, 23, 46, 0.04);
}

/* Jede Filter-Zelle: Inline-Label + Control. Wir ueberschreiben die globalen
   margin-bottom-Werte von label/select, damit die Cells nicht "rutschen". */
.story-list-filter {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    margin: 0;
}

.story-list-filter__label {
    margin: 0;
    color: rgba(34, 23, 46, 0.6);
    font-size: 0.88rem;
    font-weight: 500;
    white-space: nowrap;
    min-width: fit-content;
}

/* Custom Select: einheitliche Hoehe + eigener Pfeil */
.story-list-filter select {
    appearance: none;
    -webkit-appearance: none;
    width: auto;
    height: 36px;
    min-width: 120px;
    margin: 0;
    padding: 0 32px 0 12px;
    border-radius: 10px;
    border: 1px solid rgba(34, 23, 46, 0.14);
    background:
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' fill='none' stroke='%2322172e' stroke-opacity='0.6' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>")
        no-repeat right 12px center / 10px,
        #fff;
    color: rgba(34, 23, 46, 0.9);
    font-size: 0.92rem;
    line-height: 1;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.story-list-filter select:hover {
    border-color: rgba(159, 102, 200, 0.45);
}

.story-list-filter select:focus-visible {
    outline: none;
    border-color: rgba(159, 102, 200, 0.7);
    box-shadow: 0 0 0 3px rgba(159, 102, 200, 0.18);
}

/* Textinput-Variante in der Filter-Leiste (Name-Suche) */
.story-list-filter__input {
    width: auto;
    min-width: 160px;
    height: 36px;
    margin: 0;
    padding: 0 12px;
    border-radius: 10px;
    border: 1px solid rgba(34, 23, 46, 0.14);
    background: #fff;
    color: rgba(34, 23, 46, 0.9);
    font-size: 0.92rem;
    line-height: 1;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.story-list-filter__input:hover {
    border-color: rgba(159, 102, 200, 0.45);
}

.story-list-filter__input:focus-visible,
.story-list-filter__input:focus {
    outline: none;
    border-color: rgba(159, 102, 200, 0.7);
    box-shadow: 0 0 0 3px rgba(159, 102, 200, 0.18);
}

/* Toggle-Switch in der Filter-Leiste: Marges der globalen .toggle-switch
   neutralisieren und Hoehe an die Selects anpassen */
.story-list-filter__switch {
    height: 36px;
    margin: 0;
    align-self: center;
}

/* Sort-Direction-Button (Aufsteigend/Absteigend): kompakter Icon-Only-Button
   neben dem Sortier-Select, gleiche Hoehe wie die Selects */
.story-list-sort-dir {
    width: 36px;
    height: 36px;
    min-height: 0;
    margin: 0 0 0 -4px;
    padding: 0;
    border-radius: 10px;
    border: 1px solid rgba(34, 23, 46, 0.14);
    background: #fff;
    color: rgba(34, 23, 46, 0.9);
    font-size: 1.05rem;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
    align-self: end;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.story-list-sort-dir:hover {
    border-color: rgba(159, 102, 200, 0.45);
    color: rgba(118, 60, 168, 0.95);
}

.story-list-sort-dir:focus-visible {
    outline: none;
    border-color: rgba(159, 102, 200, 0.7);
    box-shadow: 0 0 0 3px rgba(159, 102, 200, 0.18);
}

.story-list-filter__switch .toggle-switch__text {
    margin: 0;
    color: rgba(34, 23, 46, 0.85);
    font-weight: 500;
    white-space: nowrap;
}

/* (Frueher hatten wir hier zusaetzliche 540px-Mobile-Regeln fuer die
    Filter-Leiste -- die sind jetzt in das 720px-Block oben gewandert.) */

.story-prep-slots {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
    margin: 18px 0 16px;
}

.story-prep-slot {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(34, 23, 46, 0.08);
}

.story-prep-slot.is-empty {
    background: rgba(34, 23, 46, 0.03);
    border-style: dashed;
}

.story-prep-slot__image {
    width: 100%;
    aspect-ratio: 3 / 4;
    border-radius: 10px;
    overflow: hidden;
    background: rgba(34, 23, 46, 0.04);
    display: flex;
    align-items: center;
    justify-content: center;
}

.story-prep-slot__image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.story-prep-slot__placeholder {
    color: rgba(34, 23, 46, 0.5);
    font-size: 0.85rem;
    text-align: center;
}

.story-prep-slot__placeholder--locked {
    color: rgba(34, 23, 46, 0.45);
}

.story-prep-slot__qmark {
    font-size: clamp(2.5rem, 7vw, 4rem);
    font-weight: 700;
    line-height: 1;
    color: rgba(34, 23, 46, 0.45);
}

.story-prep-slot__body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.story-prep-slot__name {
    color: rgba(34, 23, 46, 0.9);
    font-size: 0.95rem;
    overflow-wrap: anywhere;
}

.story-prep-slot__name--empty {
    font-weight: 500;
    color: rgba(34, 23, 46, 0.65);
}

.story-prep-slot__meta {
    color: rgba(34, 23, 46, 0.6);
    font-size: 0.82rem;
}

.character-card-view__image-placeholder--locked {
    border-style: solid;
    background: rgba(34, 23, 46, 0.06);
}

.character-card-view__qmark {
    font-size: clamp(4rem, 14vw, 8rem);
    font-weight: 700;
    color: rgba(34, 23, 46, 0.5);
    line-height: 1;
}

.character-card-view__fields {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 0;
    overflow-y: auto;
    min-height: 0;
    padding-right: 0;
    /* Scrollbar visuell ausblenden, Scrollen bleibt aktiv */
    scrollbar-width: none;              /* Firefox */
    -ms-overflow-style: none;           /* Edge/IE legacy */
}

.character-card-view__fields::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;                       /* Chrome/Safari/WebKit */
}

.character-card-view__field {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(34, 23, 46, 0.08);
}

.character-card-view__field:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.character-card-view__field dt {
    flex: none;
    font-weight: 600;
    color: rgba(34, 23, 46, 0.85);
    margin: 0;
}

.character-card-view__field dd {
    flex: none;
    margin: 0;
    color: rgba(34, 23, 46, 0.78);
    min-width: 0;
    word-wrap: break-word;
    line-height: 1.55;
}

.character-card-view--locked .character-card-view__field dd {
    color: rgba(34, 23, 46, 0.45);
    font-style: italic;
}

@media (max-width: 720px) {
    /* Mobile: Layout darf wieder normal scrollen (body), kein internes Scroll-Pane */
    body.page-character-card {
        height: auto;
        overflow: auto;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    body.page-character-card::-webkit-scrollbar {
        width: 0;
        height: 0;
        display: none;
    }
    body.page-character-card .page,
    body.page-character-card .hero,
    body.page-character-card .hero > .character-card-card {
        flex: 0 0 auto;
        min-height: 0;
        overflow: visible;
        height: auto;
        display: block;
    }

    .character-card-view {
        grid-template-columns: minmax(0, 1fr);
        overflow: visible;
    }

    .character-card-view__image {
        position: static;
    }

    .character-card-view__image-placeholder {
        max-width: 260px;
        margin: 0 auto;
    }

    .character-card-view__fields {
        overflow: visible;
        padding-right: 0;
    }
}

/* Embed-Modus (im iframe) -- Hero-Padding nicht doppelt mit dem Overlay-Rahmen */
.page-character-card.is-embed {
    background: transparent;
}
.page-character-card.is-embed .page {
    padding: 0;
}
.page-character-card.is-embed .hero {
    padding: 24px;
}

/* Klickbare Trigger (z. B. Spielername in Story-Owner-Liste) */
[data-character-card-trigger] {
    cursor: pointer;
}
[data-character-card-trigger]:focus-visible {
    outline: 2px solid rgba(159, 102, 200, 0.6);
    outline-offset: 2px;
    border-radius: 6px;
}

/* Spielernamen in Story-Kapiteln (vom Domain-Linkifier eingehuellt) */
.player-mention {
    cursor: pointer;
    text-decoration: underline dotted;
    text-decoration-thickness: 1.5px;
    text-underline-offset: 3px;
    text-decoration-color: rgba(159, 102, 200, 0.7);
    transition: text-decoration-color 0.15s ease, color 0.15s ease;
}

.player-mention:hover,
.player-mention:focus-visible {
    text-decoration-color: rgba(159, 102, 200, 1);
    color: rgba(118, 60, 168, 0.95);
}

/* ----- Character-Card Overlay ------------------------------------------- */
.character-card-overlay {
    position: fixed;
    inset: 0;
    z-index: 9500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.character-card-overlay.is-hidden {
    display: none;
}

body.character-card-overlay-open {
    overflow: hidden;
}

.character-card-overlay__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(34, 23, 46, 0.55);
    backdrop-filter: blur(2px);
}

.character-card-overlay__frame {
    position: relative;
    background: #f6f1fa;
    border-radius: 18px;
    box-shadow: 0 30px 60px rgba(34, 23, 46, 0.35);
    width: min(960px, 100%);
    height: min(85vh, 900px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.character-card-overlay__close {
    position: absolute;
    top: 8px;
    right: 12px;
    z-index: 2;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.85);
    color: rgba(34, 23, 46, 0.9);
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.character-card-overlay__close:hover {
    background: #ffffff;
}

.character-card-overlay__iframe {
    flex: 1 1 auto;
    width: 100%;
    border: 0;
    background: transparent;
}

@media (max-width: 720px) {
    .character-card-overlay {
        padding: 0;
    }
    .character-card-overlay__frame {
        width: 100%;
        height: 100%;
        border-radius: 0;
    }
}

