/* ═══════════════════════════════════════
   CHAT LIST PAGE (/chat)
   ═══════════════════════════════════════ */

.chat-list-page {
    max-width: 700px;
    margin: 0 auto;
    position: relative;
}

.chat-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.chat-list-header h2 {
    font-size: 1.3rem;
    margin: 0;
}

/* Conversation cards */

.chat-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.conv-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 44px 14px 18px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    position: relative;
}

.conv-card:hover {
    border-color: var(--border-hover);
    background: var(--accent-bg);
}

.conv-avatar {
    width: 72px;
    height: 72px;
    border-radius: 12px;
    background: var(--accent-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    font-weight: 700;
    font-size: 1.6rem;
    flex-shrink: 0;
    overflow: hidden;
}

.conv-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.conv-card-info {
    flex: 1;
    min-width: 0;
}

.conv-card-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-card-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.conv-card .btn-delete {
    position: absolute;
    right: 6px;
    top: 6px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 4px 8px;
    line-height: 1;
    opacity: 0.5;
    transition: opacity 0.15s, color 0.15s;
}

.conv-card:hover .btn-delete,
.conv-card .btn-delete:focus-visible {
    opacity: 1;
}

.conv-card .btn-delete:hover {
    color: var(--delete-hover);
    opacity: 1;
}

.loading-placeholder {
    padding: 40px 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Character picker overlay */

.chat-picker {
    display: flex;
    flex-direction: column;
}

.picker-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.picker-header h2 {
    font-size: 1.1rem;
    margin: 0;
}

.picker-actions {
    margin-bottom: 16px;
}

.picker-modes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.picker-mode {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px 14px;
    cursor: pointer;
    text-align: center;
    transition: border-color 0.15s, background 0.15s, transform 0.1s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: inherit;
    font-family: inherit;
    text-decoration: none;
}

.picker-mode:hover {
    border-color: var(--border-hover);
    background: var(--accent-bg);
}

.picker-mode:active {
    transform: scale(0.98);
}

.picker-mode strong {
    font-size: 1rem;
    font-weight: 600;
}

.picker-mode-desc {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.picker-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.char-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    position: relative;
}

.char-item:hover {
    border-color: var(--border-hover);
    background: var(--accent-bg);
}

.char-avatar-small {
    width: 72px;
    height: 72px;
    border-radius: 12px;
    background: var(--accent-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    font-weight: 700;
    font-size: 1.6rem;
    flex-shrink: 0;
    overflow: hidden;
}

.char-avatar-small img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.char-info {
    flex: 1;
    min-width: 0;
}

.char-name {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text);
}

.char-source {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.char-badge-public {
    font-size: 0.65rem;
    background: var(--accent-bg);
    color: var(--accent);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
}

.char-item .btn-delete-char {
    display: none;
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.1rem;
}

.char-item:hover .btn-delete-char {
    display: block;
}

.char-item .btn-delete-char:hover {
    color: var(--delete-hover);
}

/* Show-more button (under conversations list) */

.btn-show-more {
    display: block;
    width: 100%;
    margin: 10px 0 4px;
    padding: 10px 14px;
    background: none;
    border: 1px dashed var(--border);
    color: var(--text-secondary);
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.85rem;
    font-family: inherit;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.btn-show-more:hover {
    border-color: var(--border-hover);
    background: var(--accent-bg);
    color: var(--text);
}

/* My characters section (on /chat) */

.my-chars-section {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.my-chars-header {
    margin-bottom: 14px;
}

.my-chars-header h2 {
    font-size: 1.1rem;
    margin: 0;
    color: var(--text);
}

.my-chars-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
}

.my-char-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px 10px 10px;
    cursor: pointer;
    text-align: center;
    transition: border-color 0.15s, background 0.15s, transform 0.1s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    position: relative;
    font-family: inherit;
    color: inherit;
}

.my-char-card:hover {
    border-color: var(--border-hover);
    background: var(--accent-bg);
}

.my-char-card:active {
    transform: scale(0.98);
}

.my-char-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--accent-bg);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.6rem;
    overflow: hidden;
}

.my-char-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.my-char-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.2;
    word-break: break-word;
}

.my-char-actions {
    display: flex;
    gap: 4px;
    position: absolute;
    top: 6px;
    right: 6px;
    opacity: 0;
    transition: opacity 0.15s;
}

.my-char-card:hover .my-char-actions,
.my-char-card:focus-within .my-char-actions {
    opacity: 1;
}

.my-char-action {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-muted);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.85rem;
    line-height: 1;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.my-char-action:hover {
    color: var(--text);
    border-color: var(--border-hover);
    background: var(--accent-bg);
}

.my-char-action--delete:hover {
    color: var(--delete-hover);
}

.my-char-card--create {
    border-style: dashed;
    color: var(--text-secondary);
}

.my-char-create-plus {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--accent-bg);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 300;
    line-height: 1;
}

/* Pick conversation modal (when char has existing conv) */

.modal-content--narrow {
    max-width: 420px;
}

.pick-conv-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 10px;
}

.picker-mode--strong {
    border-color: var(--accent);
    background: var(--accent-bg);
}

/* ═══════════════════════════════════════
   CHAT CONVERSATION PAGE (/chat/:id)
   ═══════════════════════════════════════ */

.chat-conv-page {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 140px);
    min-height: 400px;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    background: var(--bg-surface);
}

/* Sur mobile on se met en mode "app plein écran" : le site header du haut
   (nav + tagline marketing) et le footer sont masqués, le chat prend toute
   la hauteur visible. `dvh` évite les débordements quand la barre d'adresse
   mobile se replie/déplie. `overflow: hidden` sur body empêche tout résidu
   de scroller par-dessus. */
@media (max-width: 899px) {
    body:has(.chat-conv-page) {
        overflow: hidden;
    }
    body:has(.chat-conv-page) .container > header,
    body:has(.chat-conv-page) .site-footer {
        display: none;
    }
    body:has(.chat-conv-page) .container {
        padding: 8px;
    }
    .chat-conv-page {
        height: calc(100dvh - 16px);
    }
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--panel);
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--accent-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    font-weight: 700;
    font-size: 0.9rem;
    overflow: hidden;
}

.chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-header-name {
    font-weight: 600;
    color: var(--text);
}

.btn-thoughts-toggle {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--accent-bg);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.8rem;
    font-family: inherit;
    transition: border-color 0.15s, color 0.15s, background 0.15s, opacity 0.15s;
}

.btn-thoughts-toggle:hover {
    border-color: var(--border-hover);
    color: var(--text);
}

.btn-thoughts-toggle[aria-pressed="false"] {
    opacity: 0.55;
}

.btn-thoughts-toggle[aria-pressed="false"] .btn-thoughts-label::after {
    content: ' masqu\00e9es';
}

.btn-thoughts-toggle[aria-pressed="true"] .btn-thoughts-label::after {
    content: ' visibles';
}

.chat-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.chat-messages-col {
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.chat-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* Persistent scene anchor above the scroll area — reminds the reader where
   the roleplay currently is, independently of scroll position.
   Tinted with a subtle accent wash so it reads as "chrome" distinct from
   the message content below. */
.chat-scene-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 20px;
    background: var(--accent-bg-strong);
    border-bottom: 1px solid var(--accent-border);
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    line-height: 1.3;
}

.chat-scene-bar::before {
    content: '📍';
    font-size: 0.9rem;
    line-height: 1;
    flex-shrink: 0;
}

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

/* ─── Portrait panel ─── */

/* Mobile (default): bandeau horizontal sous le header — remplace l'avatar du header */
.portrait-panel {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--panel);
}

.portrait-panel[aria-hidden="true"] {
    display: none;
}

/* Mobile : on masque l'avatar du header car le bandeau portrait en-dessous
   montre déjà (en plus grand, et avec mood dynamique) le personnage */
.chat-avatar#chat-header-avatar {
    display: none;
}

.portrait-frame {
    position: relative;
    width: 72px;
    height: 90px;
    aspect-ratio: 4 / 5;
    border-radius: 10px;
    overflow: hidden;
    background: var(--accent-bg);
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    transition: box-shadow 0.15s ease, transform 0.15s ease;
    padding: 0;
    border: none;
    cursor: zoom-in;
    font: inherit;
    color: inherit;
}

.portrait-frame:hover {
    transform: scale(1.02);
}

.portrait-frame:active {
    transform: scale(0.98);
}

/* Pastille loupe en coin pour signaler que c'est cliquable. Toujours visible
   pour l'affordance tactile mobile (pas de hover sur smartphone). */
.portrait-zoom-hint {
    position: absolute;
    right: 5px;
    bottom: 5px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    backdrop-filter: blur(2px);
}

.portrait-frame.is-mood-change {
    animation: moodHalo 1.1s ease-out;
}

@keyframes moodHalo {
    0%   { box-shadow: 0 0 0 0 var(--accent); }
    40%  { box-shadow: 0 0 0 6px rgba(140, 50, 50, 0.20); }
    100% { box-shadow: 0 0 0 10px rgba(140, 50, 50, 0); }
}

.portrait-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.45s ease;
}

.portrait-img.is-visible {
    opacity: 1;
}

.portrait-didascalie {
    flex: 1;
    min-width: 0;
    font-size: 0.78rem;
    line-height: 1.4;
    color: var(--text-secondary);
    font-style: italic;
    opacity: 0;
    transition: opacity 0.3s ease;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.portrait-didascalie.is-visible {
    opacity: 1;
}

/* Desktop: colonne latérale avec grand portrait */
@media (min-width: 900px) {
    .chat-body {
        flex-direction: row;
    }

    .chat-avatar#chat-header-avatar {
        display: flex;
    }

    .portrait-panel {
        flex-direction: column;
        align-items: stretch;
        width: 280px;
        flex-shrink: 0;
        padding: 18px;
        gap: 12px;
        border-right: 1px solid var(--border);
        border-bottom: none;
    }

    .portrait-frame {
        width: 100%;
        height: auto;
        border-radius: 14px;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    }

    .portrait-frame.is-mood-change {
        animation: moodHaloDesktop 1.1s ease-out;
    }

    @keyframes moodHaloDesktop {
        0%   { box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 0 0 0 var(--accent); }
        40%  { box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 0 0 8px rgba(140, 50, 50, 0.18); }
        100% { box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 0 0 14px rgba(140, 50, 50, 0); }
    }

    .portrait-didascalie {
        flex: initial;
        font-size: 0.82rem;
        line-height: 1.45;
        min-height: 2.4em;
        -webkit-line-clamp: 3;
    }
}

/* ─── Portrait lightbox (tap to enlarge) ─── */

.portrait-lightbox {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    padding: 24px;
    cursor: zoom-out;
    animation: lightboxFadeIn 0.18s ease-out;
}

@keyframes lightboxFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.portrait-lightbox-img {
    max-width: 100%;
    max-height: 75vh;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.portrait-lightbox-caption {
    max-width: 540px;
    color: rgba(255, 255, 255, 0.88);
    font-size: 0.95rem;
    line-height: 1.5;
    font-style: italic;
    text-align: center;
}

.portrait-lightbox-caption:empty {
    display: none;
}

.portrait-lightbox-close {
    position: absolute;
    top: 12px;
    right: 14px;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 1.8rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.portrait-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.22);
}

.btn-load-more {
    align-self: center;
    background: var(--accent-bg);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 6px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    margin-bottom: 8px;
}

.btn-load-more:hover {
    background: var(--accent-bg-strong);
}

.msg-bubble {
    max-width: 92%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 0.92rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

@media (min-width: 900px) {
    .msg-bubble {
        max-width: 75%;
    }
}

.msg-bubble.user {
    align-self: flex-end;
    background: var(--accent);
    color: var(--btn-text);
    border-bottom-right-radius: 4px;
}

.msg-bubble.assistant {
    align-self: flex-start;
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

.msg-bubble.assistant .msg-scene {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    color: var(--text-muted);
    letter-spacing: 0.02em;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px dashed var(--border);
    opacity: 0.85;
}

.msg-bubble.assistant .msg-scene::before {
    content: '📍';
    font-size: 0.85rem;
    line-height: 1;
}

/* Chat-scoped hue used for the character's inner voice — cool mauve so it
   reads as clearly distinct from the warm rose accent and the neutral greys. */
.chat-messages { --text-thought: #a898b8; }
[data-theme="light"] .chat-messages { --text-thought: #6a5a78; }

.msg-bubble.assistant .msg-action {
    font-style: italic;
    color: var(--text-secondary);
}

.msg-bubble.assistant .msg-dialogue {
    font-style: normal;
    font-weight: 500;
    color: var(--text);
    letter-spacing: 0.002em;
}

.msg-bubble.assistant .msg-thought {
    font-style: italic;
    color: var(--text-thought);
}

/* ─── Beat grouping (narration / dialogue / thought) ─── */

.msg-bubble.assistant .msg-beat {
    white-space: pre-wrap;
}

.msg-bubble.assistant .msg-beat + .msg-beat {
    margin-top: 10px;
}

.msg-bubble.assistant .msg-beat-dialogue {
    padding-left: 12px;
    border-left: 3px solid var(--accent);
    border-radius: 2px;
}

.msg-bubble.assistant .msg-beat-thought {
    padding-left: 12px;
    border-left: 2px dashed var(--border-hover);
    color: var(--text-thought);
}

/* A full thought-beat wraps its content in .msg-thought; the outer beat
   already colors and italicizes, so unwrap the redundant inner treatment. */
.msg-bubble.assistant .msg-beat-thought .msg-thought {
    color: inherit;
}

.chat-messages[data-hide-thoughts="true"] .msg-bubble.assistant .msg-thought,
.chat-messages[data-hide-thoughts="true"] .msg-bubble.assistant .msg-beat-thought {
    display: none;
}

.chat-typing {
    padding: 4px 20px 8px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.typing-dots span {
    animation: typingDot 1.2s infinite;
    opacity: 0;
    font-size: 1.4em;
    line-height: 0;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingDot {
    0%, 60% { opacity: 0; }
    30% { opacity: 1; }
}

/* ─── Quick actions (scene-change pills) ─── */

.quick-actions {
    display: flex;
    gap: 8px;
    padding: 8px 20px 0;
    background: var(--panel);
    overflow-x: auto;
    scrollbar-width: none;
    transition: max-height 0.2s ease, opacity 0.15s ease, padding 0.2s ease;
    max-height: 44px;
}

.quick-actions::-webkit-scrollbar { display: none; }

.quick-actions.is-hidden,
.quick-actions.is-unavailable {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
    pointer-events: none;
    overflow: hidden;
}

.quick-actions[data-mode="suggestions"] {
    max-height: 220px;
    overflow-y: auto;
}

.quick-suggestions-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: flex-start;
    width: 100%;
    padding-bottom: 8px;
}

.quick-suggestion {
    flex: 1 1 200px;
    min-width: 0;
    background: var(--accent-bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 0.8rem;
    line-height: 1.35;
    font-family: inherit;
    font-style: italic;
    cursor: pointer;
    text-align: left;
    transition: background 0.12s, border-color 0.12s, transform 0.08s;
}

.quick-suggestion:hover {
    background: var(--accent-bg-strong);
    border-color: var(--accent);
}

.quick-suggestion:active {
    transform: scale(0.98);
}

.quick-suggestions-close {
    flex: 0 0 auto;
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    font-family: inherit;
    align-self: center;
    transition: color 0.12s, border-color 0.12s;
}

.quick-suggestions-close:hover {
    color: var(--text);
    border-color: var(--border-hover);
}

.quick-action {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: var(--accent-bg);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 5px 11px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.quick-action:hover {
    background: var(--accent-bg-strong);
    border-color: var(--border-hover);
    color: var(--text);
}

.quick-action-icon {
    font-size: 0.9rem;
    line-height: 1;
}

/* ─── Scene beat card (transition rendered as chapter break) ─── */

.scene-beat {
    display: flex;
    align-items: center;
    gap: 10px;
    align-self: stretch;
    padding: 6px 10px;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-style: italic;
    letter-spacing: 0.02em;
}

.scene-beat::before,
.scene-beat::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--border), transparent);
}

.scene-beat-label {
    display: inline-flex;
    align-items: flex-start;
    gap: 6px;
    max-width: 75%;
    text-align: center;
    white-space: normal;
    line-height: 1.35;
}

.chat-input-bar {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 12px 20px 16px;
    border-top: 1px solid var(--border);
    background: var(--panel);
}

.chat-input-bar textarea {
    flex: 1;
    background: var(--input-bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 0.92rem;
    font-family: inherit;
    resize: none;
    max-height: 120px;
    outline: none;
}

.chat-input-bar textarea:focus {
    border-color: var(--border-focus);
}

.btn-send {
    background: var(--accent);
    color: var(--btn-text);
    border: none;
    padding: 10px 20px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.88rem;
    cursor: pointer;
    white-space: nowrap;
}

.btn-send:hover { background: var(--accent-hover); }
.btn-send:disabled { opacity: 0.5; cursor: not-allowed; }

/* ═══════════════════════════════════════
   SHARED
   ═══════════════════════════════════════ */

.btn-create {
    background: var(--accent);
    color: var(--btn-text);
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

.btn-create:hover { background: var(--accent-hover); }

.btn-gallery {
    background: var(--accent-bg);
    color: var(--accent);
    border: 1px solid var(--border);
    padding: 14px 32px;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.btn-gallery:hover {
    background: var(--accent-bg-strong);
    border-color: var(--border-hover);
}

.btn-back-text {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0;
    text-decoration: none;
}

.btn-back-text:hover { color: var(--text); }

/* Modal */

.chat-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal-content {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    width: 90%;
    max-width: 560px;
    max-height: 85vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 { font-size: 1.1rem; margin: 0; }

.btn-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}

.modal-tabs {
    display: flex;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
}

.modal-tab {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 12px 16px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    border-bottom: 2px solid transparent;
}

.modal-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.modal-body { padding: 20px; }

.modal-body .form-group { margin-bottom: 14px; }

.modal-body label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
    font-weight: 600;
}

.modal-body input[type="text"],
.modal-body textarea {
    width: 100%;
    background: var(--input-bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.88rem;
    font-family: inherit;
    outline: none;
    box-sizing: border-box;
}

.modal-body input:focus,
.modal-body textarea:focus { border-color: var(--border-focus); }

.fiction-row { display: flex; gap: 8px; }
.fiction-row input { flex: 1; }

.btn-generate {
    background: var(--accent);
    color: var(--btn-text);
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    white-space: nowrap;
}

.btn-generate:hover { background: var(--accent-hover); }
.btn-generate:disabled { opacity: 0.5; cursor: not-allowed; }

.avatar-preview {
    width: 120px;
    height: 120px;
    border-radius: 12px;
    object-fit: cover;
    border: 2px solid var(--border);
    margin-bottom: 8px;
}

.form-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

.btn-secondary {
    background: var(--accent-bg);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    padding: 8px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
}

.btn-primary {
    background: var(--accent);
    color: var(--btn-text);
    border: none;
    padding: 8px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
}

.btn-primary:hover { background: var(--accent-hover); }

/* Anon banner */

.anon-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--accent-bg-strong);
    color: var(--text);
    text-align: center;
    padding: 10px;
    font-size: 0.85rem;
    border-top: 1px solid var(--border);
    z-index: 50;
}
