*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root
{
    --bg:          #0e0f11;
    --surface:     #16181c;
    --surface2:    #1e2026;
    --border:      #2a2d35;
    --accent:      #c8a96e;
    --accent-dim:  #7a6440;
    --text:        #d4cfc8;
    --text-dim:    #6b6760;
    --text-bright: #f0ebe3;
    --user-bubble: #1a2235;
    --ai-bubble:   #1a1f18;
    --danger:      #8b3a3a;
    --success:     #3a6b4a;
    --font-mono:   'Geist Mono', monospace;
    --font-serif:  'Instrument Serif', serif;
    --chat-font:   'Geist Mono', monospace;
    --chat-size:   13px;
    --radius:      6px;
    --header-h:    48px;
    --tab-h:       38px;
}

html, body
{
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 13px;
    overflow: hidden;
}

/* ── Layout ─────────────────────────────────────── */

#app
{
    display: flex;
    flex-direction: column;
    height: 100vh;   /* fallback for browsers without dvh support */
    /* Mobile browsers size 100vh as if the URL bar were hidden, pushing the
       bottom controls off-screen; dvh tracks the actually-visible viewport. */
    height: 100dvh;
}

#header
{
    height: var(--header-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 16px;
    flex-shrink: 0;
}

#header .logo
{
    font-family: var(--font-serif);
    font-size: 18px;
    color: var(--accent);
    letter-spacing: 0.02em;
    font-style: italic;
}

#header .project-name
{
    color: var(--text-dim);
    font-size: 12px;
}

#header .spacer { flex: 1; }

/* ── Menubar ──────────────────────────────────────── */

#menubar
{
    display: flex;
    align-self: stretch;
    margin-left: -4px;
}

.menu-root
{
    position: relative;
    display: flex;
    align-items: stretch;
}

.menu-root-label
{
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    border: 1px solid var(--border);
    background: var(--surface2);
    transition: all 0.15s;
}

.menu-root-label:hover,
.menu-root.open .menu-root-label
{
    border-color: var(--accent-dim);
    color: var(--accent);
}

.menu-dropdown
{
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-top: none;
    min-width: 220px;
    z-index: 1000;
    box-shadow: 0 6px 20px rgba(0,0,0,0.5);
    display: none;
    flex-direction: column;
    padding: 4px 0;
}

.menu-root.open .menu-dropdown
{
    display: flex;
}

.menu-action
{
    background: none;
    border: none;
    padding: 6px 20px;
    text-align: left;
    font-size: 12px;
    color: var(--text);
    cursor: pointer;
    white-space: nowrap;
    font-family: var(--font-mono);
    width: 100%;
    line-height: 1.4;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
}

.menu-kbd
{
    color: var(--text-dim);
    font-size: 11px;
    flex-shrink: 0;
}

.menu-action:hover:not(:disabled)
{
    background: var(--accent-dim);
    color: var(--text-bright);
}

.menu-action:disabled
{
    color: var(--text-dim);
    cursor: default;
}

.menu-separator
{
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

#main
{
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ── Left Pane ───────────────────────────────────── */

#left-pane
{
    display: flex;
    flex-direction: column;
    width: 55%;
    min-width: 300px;
    border-right: 1px solid var(--border);
    overflow: hidden;
}

#file-tabs
{
    height: var(--tab-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: flex-end;
    padding: 0 8px;
    gap: 2px;
    overflow-x: auto;
    flex-shrink: 0;
}

#file-tabs::-webkit-scrollbar,
#context-tabs::-webkit-scrollbar          { height: 3px; }
#file-tabs::-webkit-scrollbar-thumb,
#context-tabs::-webkit-scrollbar-thumb   { background: transparent; border-radius: 2px; }
#file-tabs:hover::-webkit-scrollbar,
#context-tabs:hover::-webkit-scrollbar   { height: 5px; }
#file-tabs:hover::-webkit-scrollbar-thumb,
#context-tabs:hover::-webkit-scrollbar-thumb { background: var(--text-dim); }

.tab
{
    padding: 6px 14px;
    font-size: 11px;
    color: var(--text-dim);
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: var(--radius) var(--radius) 0 0;
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.15s;
    background: transparent;
    font-family: var(--font-mono);
}

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

.tab.active
{
    color: var(--accent);
    background: var(--bg);
    border-color: var(--border);
}

.tab .tab-close
{
    margin-left: 6px;
    color: var(--text-dim);
    font-size: 10px;
}

.tab .tab-close:hover { color: var(--danger); }

.tab .tab-menu
{
    margin-right: 4px;
    color: var(--text-dim);
    font-size: 9px;
    cursor: pointer;
}

.tab .tab-menu:hover { color: var(--accent); }

#tab-file-menu
{
    position: fixed;
    z-index: 1000;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
    padding: 4px;
    min-width: 190px;
    font-size: 12px;
    outline: none;
}

#tab-file-menu .tab-file-menu-item
{
    padding: 5px 10px;
    border-radius: 3px;
    cursor: pointer;
    color: var(--text-bright);
    white-space: nowrap;
}

#tab-file-menu .tab-file-menu-item:hover
{
    background: var(--bg);
    color: var(--accent);
}

.tab.invalid { color: var(--danger); }
.tab.invalid:hover { color: var(--danger); }
.tab.invalid.active { color: var(--danger); }

#add-context-tab
{
    padding: 6px 10px;
    font-size: 16px;
    color: var(--text-dim);
    cursor: pointer;
    line-height: 1;
    align-self: center;
    transition: color 0.15s;
    background: none;
    border: none;
    font-family: var(--font-mono);
}

#add-context-tab:hover { color: var(--accent); }

#editor-container
{
    flex: 1;
    overflow: hidden;
}

#left-toolbar
{
    height: 40px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 12px;
    gap: 8px;
    flex-shrink: 0;
}

/* ── Right Pane ──────────────────────────────────── */

#right-pane
{
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    position: relative;
}

#chat-toolbar
{
    height: 40px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 12px;
    gap: 8px;
    flex-shrink: 0;
}

#chat-history
{
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#chat-history::-webkit-scrollbar              { width: 4px; }
#chat-history::-webkit-scrollbar-thumb        { background: var(--border); border-radius: 2px; }
#chat-history:hover::-webkit-scrollbar        { width: 10px; }
#chat-history:hover::-webkit-scrollbar-thumb  { background: var(--text-dim); border-radius: 5px; }

.message
{
    display: flex;
    flex-direction: column;
    gap: 4px;
}

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

.message-role
{
    font-size: 10px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.message-actions
{
    display: none;
    gap: 4px;
    margin-left: auto;
}

.message:hover .message-actions,
.message.active .message-actions { display: flex; }

.message-bubble
{
    padding: 10px 14px;
    border-radius: var(--radius);
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: var(--chat-font);
    font-size: var(--chat-size);
}

.message.user .message-bubble
{
    background: var(--user-bubble);
    border: 1px solid #253050;
    color: var(--text-bright);
}

.message.assistant .message-bubble
{
    background: var(--ai-bubble);
    border: 1px solid #252e20;
    color: var(--text);
}

#chat-input-area
{
    padding: 12px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
}

#chat-input
{
    width: 100%;
    min-height: 72px;
    max-height: 200px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-bright);
    font-family: var(--chat-font);
    font-size: var(--chat-size);
    padding: 10px 14px;
    resize: vertical;
    outline: none;
    line-height: 1.6;
    transition: border-color 0.15s;
}

#chat-input:focus { border-color: var(--accent-dim); }

#chat-input-row
{
    display: flex;
    align-items: center;
    gap: 8px;
}

#chat-input-row .spacer { flex: 1; }

/* ── Buttons ─────────────────────────────────────── */

.btn
{
    padding: 6px 14px;
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: 12px;
    cursor: pointer;
    border: 1px solid var(--border);
    background: var(--surface2);
    color: var(--text);
    transition: all 0.15s;
    white-space: nowrap;
}

.btn:hover
{
    border-color: var(--accent-dim);
    color: var(--accent);
}

.btn.primary
{
    background: var(--accent-dim);
    border-color: var(--accent);
    color: var(--accent);
}

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

.btn.danger
{
    border-color: var(--danger);
    color: #c06060;
}

.btn.danger:hover
{
    background: var(--danger);
    color: var(--text-bright);
}

.btn.small
{
    padding: 3px 9px;
    font-size: 11px;
}

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

/* ── Modals ──────────────────────────────────────── */

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

.modal
{
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    min-width: 400px;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.modal h2
{
    font-family: var(--font-serif);
    font-size: 18px;
    color: var(--accent);
    font-style: italic;
}

.modal label
{
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 11px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.modal input, .modal select
{
    padding: 8px 12px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-bright);
    font-family: var(--font-mono);
    font-size: 13px;
    outline: none;
    transition: border-color 0.15s;
}

.modal input:focus, .modal select:focus { border-color: var(--accent-dim); }

.modal-actions
{
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* ── Confirmation dialog (confirmAction, character-shared.js) ────
   A real <dialog> so we inherit the top layer, a focus trap and Esc.
   It reuses the .modal vocabulary above; these rules only strip the UA
   chrome and re-centre it. Every selector is qualified with .confirm-dlg
   because character-player.css (loaded after this file in the Player and
   PartyLine) styles bare `dialog` as a header-anchored slide-out panel —
   we have to out-specify all of it, [open] included.
   Focus starts on the dialog itself, never a button: see confirmAction. */

dialog.confirm-dlg,
dialog.confirm-dlg[open]
{
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    inset: 0;
    top: 0;
    right: 0;
    left: 0;
    margin: auto;
    width: auto;
    max-width: none;
    max-height: none;
    border: none;
    border-radius: 0;
    background: none;
    box-shadow: none;
    padding: 0;
    overflow: visible;
    color: var(--text);
    outline: none;                 /* focus parks here — it must not draw a ring */
}

dialog.confirm-dlg::backdrop { background: rgba(0,0,0,0.7); }

/* Wide enough for a three-button row (chooseAction) without overflowing;
   .modal-actions is justify-content:flex-end, so an over-wide row would spill
   out of the left edge of the box rather than clip. Wrapping is the backstop
   at narrow widths. */
dialog.confirm-dlg .modal { max-width: min(560px, 90vw); width: 90vw; }

dialog.confirm-dlg .modal-actions { flex-wrap: wrap; }

dialog.confirm-dlg .confirm-dlg-body
{
    margin: 0;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text);
}

/* ── Settings dialog (grouped nav + search) ──────── */

.settings-modal
{
    max-width: 860px;
    width: 92vw;
    gap: 12px;
}

.settings-body
{
    display: flex;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    height: min(56vh, 520px);
}

#settings-nav
{
    display: flex;
    flex-direction: column;
    width: 168px;
    flex-shrink: 0;
    padding: 8px 0;
    background: var(--surface2);
    border-right: 1px solid var(--border);
}

.settings-nav-btn
{
    text-align: left;
    padding: 9px 14px;
    background: none;
    border: none;
    border-left: 2px solid transparent;
    color: var(--text-dim);
    font-family: inherit;
    font-size: 12.5px;
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
}

.settings-nav-btn:hover { color: var(--text-bright); background: rgba(255,255,255,0.03); }

.settings-nav-btn.active
{
    color: var(--accent);
    border-left-color: var(--accent);
    background: var(--surface);
}

.settings-nav-btn.dimmed { opacity: 0.35; }

#settings-panes
{
    flex: 1;
    overflow-y: auto;
    padding: 14px 18px;
}

.settings-pane
{
    display: none;
    flex-direction: column;
    gap: 14px;
}

.settings-pane.active { display: flex; }

/* Group heading inside a pane — only shown in search mode, where all panes
   are stacked and the user needs to see which group each match belongs to */
.settings-pane-heading
{
    display: none;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent-dim, var(--accent));
    margin-bottom: -4px;
}

.settings-intro, .setting-hint
{
    font-size: 11px;
    color: var(--text-dim);
}

.settings-intro
{
    padding: 6px 8px;
    background: var(--surface2);
    border-radius: var(--radius);
}

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

/* Search mode: stack every pane, show group headings, hide non-matching rows */
.settings-modal.searching .settings-pane { display: flex; margin-bottom: 10px; }
.settings-modal.searching .settings-pane-heading { display: block; }
.settings-modal.searching .settings-intro { display: none; }
.settings-modal.searching .setting-row.search-miss { display: none; }
.settings-modal.searching .settings-pane.no-matches { display: none; }

/* ── Status bar ──────────────────────────────────── */

#status-bar
{
    height: 24px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 12px;
    gap: 16px;
    font-size: 11px;
    color: var(--text-dim);
    flex-shrink: 0;
}

#status-bar .status-msg { color: var(--accent); }

/* ── Git log panel ───────────────────────────────── */

#git-panel
{
    display: none;
    position: fixed;
    right: 0;
    top: var(--header-h);
    bottom: 24px;
    width: 340px;
    background: var(--surface);
    border-left: 1px solid var(--border);
    flex-direction: column;
    z-index: 100;
}

#git-panel.open { display: flex; }

#git-panel-header
{
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

#git-panel-header .spacer { flex: 1; }

#git-log
{
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

#git-log::-webkit-scrollbar { width: 4px; }
#git-log::-webkit-scrollbar-thumb { background: var(--border); }

.git-commit
{
    padding: 8px 10px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.12s;
    margin-bottom: 4px;
}

.git-commit:hover
{
    background: var(--surface2);
    border-color: var(--border);
}

.git-commit .commit-hash
{
    font-size: 10px;
    color: var(--accent-dim);
    font-family: var(--font-mono);
}

.git-commit .commit-msg
{
    font-size: 12px;
    color: var(--text);
    margin-top: 2px;
}

.git-commit .commit-date
{
    font-size: 10px;
    color: var(--text-dim);
    margin-top: 2px;
}

/* ── Splitter ─────────────────────────────────────── */

#splitter
{
    width: 4px;
    background: var(--border);
    cursor: col-resize;
    flex-shrink: 0;
    transition: background 0.15s;
}

#splitter:hover { background: var(--accent-dim); }

/* ── Sticky message header ───────────────────────── */

.message-header
{
    display: flex;
    align-items: center;
    gap: 8px;
    position: sticky;
    top: -17px;
    z-index: 10;
    padding: 3px 0;
    /* Solid background matching the chat pane so content scrolling behind is hidden */
    background: var(--bg);
    /* Bleed the background edge-to-edge to cover the padding gap */
    margin: 0 -16px;
    padding-left: 16px;
    padding-right: 16px;
}

/* ── In-place message editor (shared openBubbleEditor) ───────────
   The .bubble-mirror textarea copies the measured bubble box (inline
   width/height) and these rules match the bubble's typography, so
   entering edit mode barely moves the text. The Player overrides
   these in character-player.css with its own bubble metrics. */

.edit-textarea
{
    background: var(--surface2);
    border: 1px solid var(--accent-dim);
    color: var(--text);
    outline: none;
    white-space: pre-wrap;
    word-break: break-word;
}

.edit-textarea.bubble-mirror
{
    max-width: 100%;
    padding: 10px 14px;
    border-radius: var(--radius);
    font-family: var(--chat-font);
    font-size: var(--chat-size);
    line-height: 1.6;
    resize: none;          /* auto-grows on input instead */
    overflow-y: auto;
}

.message.user .edit-textarea.bubble-mirror
{
    background: var(--user-bubble);
    color: var(--text-bright);
}

.message.assistant .edit-textarea.bubble-mirror
{
    background: var(--ai-bubble);
    color: var(--text);
}

.edit-controls
{
    display: flex;
    gap: 6px;
    justify-content: flex-end;
    margin-top: 5px;
}

.spinner
{
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    vertical-align: middle;
}

/* Input Corrector word-diff (shared renderCorrectorDiff) */
.diff-del
{
    background: rgba(180, 60, 60, 0.25);
    color: #e07070;
    text-decoration: line-through;
    border-radius: 2px;
    padding: 0 1px;
}

.diff-ins
{
    background: rgba(60, 160, 80, 0.2);
    color: #70c080;
    border-radius: 2px;
    padding: 0 1px;
}

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

/* ── Markdown in bubbles and preview ────────────── */

.message-bubble,
.markdown-content                { line-height: 1.7; }

.message-bubble p,
.markdown-content p              { margin: 0 0 0.7em 0; }
.message-bubble p:last-child,
.markdown-content p:last-child   { margin-bottom: 0; }

.message-bubble h1,
.markdown-content h1,
.message-bubble h2,
.markdown-content h2,
.message-bubble h3,
.markdown-content h3             { font-family: var(--font-serif); color: var(--accent); margin: 1em 0 0.4em 0; font-style: italic; }
.message-bubble h1,
.markdown-content h1             { font-size: 1.4em; }
.message-bubble h2,
.markdown-content h2             { font-size: 1.2em; }
.message-bubble h3,
.markdown-content h3             { font-size: 1.05em; }

.message-bubble ul,
.markdown-content ul,
.message-bubble ol,
.markdown-content ol             { padding-left: 1.4em; margin: 0.4em 0; }
.message-bubble li,
.markdown-content li             { margin: 0.25em 0; }
.message-bubble li > p,
.markdown-content li > p         { margin: 0; }

.message-bubble code,
.markdown-content code           { background: var(--surface2); padding: 1px 5px; border-radius: 3px; font-family: var(--font-mono); font-size: 0.88em; }
.message-bubble pre,
.markdown-content pre            { background: var(--surface2); padding: 10px 14px; border-radius: var(--radius); overflow-x: auto; margin: 0.6em 0; }
.message-bubble pre code,
.markdown-content pre code       { background: none; padding: 0; }

.message-bubble blockquote,
.markdown-content blockquote     { border-left: 2px solid var(--accent-dim); margin: 0.4em 0; padding: 2px 10px; color: var(--text-dim); font-size: 0.9em; }
.message-bubble blockquote p,
.markdown-content blockquote p   { margin: 0; }

.message-bubble em,
.markdown-content em             { color: var(--text-dim); font-style: italic; }
.message-bubble strong,
.markdown-content strong         { color: var(--text-bright); font-style: normal; }

.message-bubble hr,
.markdown-content hr             { border: none; border-top: 1px solid var(--border); margin: 0.8em 0; }
.message-bubble a,
.markdown-content a              { color: var(--accent); text-decoration: underline; }

/* Preview gets more breathing room than chat bubbles */
.markdown-content                { font-size: 13px; color: var(--text); }

#welcome
{
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 16px;
    color: var(--text-dim);
}

#welcome h1
{
    font-family: var(--font-serif);
    font-size: 32px;
    color: var(--accent);
    font-style: italic;
}

#welcome p { font-size: 12px; max-width: 320px; text-align: center; line-height: 1.7; }


/* ── User input syntax highlighting ─────────────── */

/* Ensure user bubble em (private thoughts) stays dimmed even with markdown rules */
.message.user .message-bubble em { color: var(--text-dim); font-style: italic; }


/* ── Markdown spacing variants ───────────────────── */

/* Tight: minimal spacing, dense reading */
#chat-history.md-tight .message-bubble   { line-height: 1.3; }
#chat-history.md-tight .message-bubble p { margin: 0; }
#chat-history.md-tight .message-bubble h1,
#chat-history.md-tight .message-bubble h2,
#chat-history.md-tight .message-bubble h3 { margin: 0.25em 0 0.1em 0; }
#chat-history.md-tight .message-bubble ul,
#chat-history.md-tight .message-bubble ol { margin: 0; }
#chat-history.md-tight .message-bubble li { margin: 0; }
#chat-history.md-tight .message-bubble blockquote { margin: 0.1em 0; }
#chat-history.md-tight .message-bubble hr { margin: 0.2em 0; }

/* Comfortable: current default — no overrides needed */

/* Spacious: generous spacing, airy reading */
#chat-history.md-spacious .message-bubble   { line-height: 1.9; }
#chat-history.md-spacious .message-bubble p { margin: 0 0 1.1em 0; }
#chat-history.md-spacious .message-bubble h1,
#chat-history.md-spacious .message-bubble h2,
#chat-history.md-spacious .message-bubble h3 { margin: 1.4em 0 0.6em 0; }
#chat-history.md-spacious .message-bubble ul,
#chat-history.md-spacious .message-bubble ol { margin: 0.6em 0; }
#chat-history.md-spacious .message-bubble li { margin: 0.4em 0; }
#chat-history.md-spacious .message-bubble blockquote { margin: 0.7em 0; padding: 4px 14px; }
#chat-history.md-spacious .message-bubble hr { margin: 1.2em 0; }

/* ── Driver.js tour popover styling ─────────────── */

.studio-tour-popover.driver-popover
{
    background:    var(--surface);
    border:        1px solid var(--accent-dim);
    border-radius: var(--radius);
    color:         var(--text);
    font-family:   var(--font-mono);
    font-size:     13px;
    max-width:     380px;
}

.studio-tour-popover .driver-popover-title
{
    font-family: var(--font-serif);
    font-style:  italic;
    font-size:   17px;
    color:       var(--accent);
    margin-bottom: 8px;
}

.studio-tour-popover .driver-popover-description
{
    color:       var(--text);
    line-height: 1.6;
}

.studio-tour-popover .driver-popover-description code
{
    background:    var(--surface2);
    padding:       1px 5px;
    border-radius: 3px;
    font-family:   var(--font-mono);
    font-size:     0.88em;
    color:         var(--accent);
}

.studio-tour-popover .driver-popover-footer
{
    margin-top:  12px;
    border-top:  1px solid var(--border);
    padding-top: 10px;
}

.studio-tour-popover .driver-popover-progress-text
{
    color:     var(--text-dim);
    font-size: 11px;
}

.studio-tour-popover button.driver-popover-next-btn,
.studio-tour-popover button.driver-popover-prev-btn,
.studio-tour-popover button.driver-popover-close-btn
{
    background:    var(--surface2);
    border:        1px solid var(--border);
    color:         var(--text);
    border-radius: var(--radius);
    font-family:   var(--font-mono);
    font-size:     12px;
    padding:       4px 12px;
    cursor:        pointer;
    transition:    border-color 0.15s, color 0.15s;
}

.studio-tour-popover button.driver-popover-next-btn
{
    background:  var(--accent);
    border-color: var(--accent);
    color:       var(--bg);
}

.studio-tour-popover button.driver-popover-next-btn:hover
{
    background:  var(--text-bright);
    border-color: var(--text-bright);
}

.studio-tour-popover button.driver-popover-prev-btn:hover,
.studio-tour-popover button.driver-popover-close-btn:hover
{
    border-color: var(--accent);
    color:        var(--accent);
}

/* ── Tour button star indicator ─────────────────── */

#btn-tour { position: relative; }

#btn-tour.has-tour-update::after
{
    content:        "\2605";   /* ★ — escaped: charset-proof (see character-player.css cursor note) */
    position:       absolute;
    top:            -8px;
    right:          -5px;
    font-size:      13px;
    color:          #f5c518;
    line-height:    1;
    pointer-events: none;
    text-shadow:    0 0 6px rgba(245, 197, 24, 0.5);
}

/* ── Tour picker modal ───────────────────────────── */

.tour-section-row
{
    position:       relative;
    display:        flex;
    align-items:    center;
    gap:            12px;
    padding:        10px 12px;
    border:         1px solid var(--border);
    border-radius:  var(--radius);
    background:     var(--surface2);
    transition:     border-color 0.15s;
}
.tour-section-row:hover { border-color: var(--accent-dim); }

.tour-row-star
{
    position:       absolute;
    top:            -7px;
    right:          -4px;
    font-size:      13px;
    color:          #f5c518;
    line-height:    1;
    pointer-events: none;
    text-shadow:    0 0 6px rgba(245, 197, 24, 0.5);
}

.tour-section-icon { font-size: 20px; width: 28px; text-align: center; flex-shrink: 0; }

.tour-section-info
{
    flex:           1;
    min-width:      0;
    display:        flex;
    flex-direction: column;
    gap:            2px;
}

.tour-section-label { font-size: 13px; color: var(--text-bright); display: flex; align-items: center; gap: 8px; }
.tour-section-desc  { font-size: 11px; color: var(--text-dim); }

.tour-seen-badge
{
    font-size:     10px;
    color:         var(--accent);
    border:        1px solid var(--accent);
    border-radius: 3px;
    padding:       1px 5px;
    line-height:   1.4;
}

.tour-updated-badge
{
    font-size:  10px;
    color:      #a07838;
    font-style: italic;
}

.tour-start-btn
{
    padding:       5px 12px;
    font-size:     12px;
    font-family:   var(--font-mono);
    background:    var(--surface);
    border:        1px solid var(--border);
    border-radius: var(--radius);
    color:         var(--text);
    cursor:        pointer;
    white-space:   nowrap;
    transition:    all 0.15s;
    flex-shrink:   0;
}
.tour-start-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ── Model browser ───────────────────────────────── */

#models-list table
{
    width:           100%;
    border-collapse: collapse;
    font-size:       12px;
}

#models-list th
{
    text-align:    left;
    padding:       6px 10px;
    border-bottom: 1px solid var(--border);
    color:         var(--text-dim);
    font-size:     10px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    white-space:   nowrap;
    position:      sticky;
    top:           0;
    background:    var(--surface);
}

#models-list td
{
    padding:       8px 10px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
    color:         var(--text);
}

#models-list tr:hover td  { background: var(--surface2); cursor: pointer; }
#models-list tr.selected td { background: var(--accent-dim); }
#models-list tr.selected .model-id,
#models-list tr.selected .model-ctx,
#models-list tr.selected .model-price,
#models-list tr.selected .model-type  { color: var(--text); }

#models-list .model-id    { color: var(--text-bright); font-weight: 500; }
#models-list .model-ctx   { color: var(--text-dim); white-space: nowrap; }
#models-list .model-price { color: var(--accent); white-space: nowrap; }
#models-list .model-type  { font-size: 10px; color: var(--text-dim); }
#models-list .model-caps  { white-space: nowrap; }

.cap-badge {
    display:       inline-block;
    font-size:     10px;
    padding:       1px 4px;
    border-radius: 3px;
    margin-right:  2px;
    font-family:   var(--font-mono);
    vertical-align: middle;
}
.cap-badge.cap-yes     { color: var(--accent); border: 1px solid var(--accent); }
.cap-badge.cap-no      { color: var(--text-dim); border: 1px solid var(--border); opacity: 0.5; }
.cap-badge.cap-unknown { color: var(--text-dim); border: 1px solid var(--border); }

#cfg-model-caps .cap-badge { font-size: 11px; padding: 2px 5px; }

.caps-row {
    display:     flex;
    align-items: center;
    gap:         8px;
    padding:     4px 0;
}
.caps-row .cap-icon       { font-size: 13px; min-width: 24px; text-align: center; font-family: var(--font-mono); }
.caps-row .cap-icon.cap-yes     { color: var(--accent); }
.caps-row .cap-icon.cap-no      { color: var(--text-dim); }
.caps-row .cap-icon.cap-unknown { color: var(--text-dim); }
.caps-row .cap-label      { flex: 1; }

/* ── Image Gallery ───────────────────────────────── */

#image-gallery
{
    display:               grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap:                   12px;
    align-items:           start;
    width:                 100%;
    box-sizing:            border-box;
    overflow-x:            hidden;
}

#image-gallery::-webkit-scrollbar { width: 4px; }
#image-gallery::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.img-col-sizer, .img-gutter-sizer { display: none; }

.img-card
{
    position:      relative;
    width:         100%;       /* fill the grid cell — never overflow it */
    min-width:     0;          /* prevent grid blowout */
    border:        1px solid var(--border);
    border-radius: var(--radius);
    background:    var(--surface);
    overflow:      hidden;
    transition:    border-color 0.15s;
    box-sizing:    border-box;
}

.img-card:hover { border-color: var(--accent-dim); }

/* Image area fills card, click opens lightbox */
.img-card-image-wrap
{
    position: relative;
    cursor:   pointer;
    display:  block;
}

.img-card-image-wrap img
{
    width:   100%;
    display: block;
    height:  auto;
}

/* Trash — absolutely positioned top-right, only visible on hover */
.img-card-trash
{
    position:      absolute;
    top:           6px;
    right:         6px;
    width:         26px;
    height:        26px;
    display:       flex;
    align-items:   center;
    justify-content: center;
    background:    rgba(0,0,0,0.55);
    border:        none;
    border-radius: 50%;
    color:         var(--text-dim);
    font-size:     13px;
    cursor:        pointer;
    opacity:       0;
    transition:    opacity 0.15s, background 0.15s, color 0.15s;
    padding:       0;
    line-height:   1;
}

.img-card:hover .img-card-trash,
.img-card.tour-hover .img-card-trash   { opacity: 1; }
.img-card-trash:hover                  { background: var(--danger); color: #fff; }
.img-card.tour-hover .img-card-trash   { background: var(--danger); color: #fff; }  /* tour: show active state */

/* Bottom bar: icons | divider | caption — all on one line */
.img-card-bar
{
    display:     flex;
    align-items: center;
    gap:         0;
    padding:     3px 6px;
    border-top:  1px solid var(--border);
    background:  var(--surface);
    min-width:   0;
}

.img-card-icons
{
    display:     flex;
    align-items: center;
    gap:         0;
    flex-shrink: 0;
}

/* Thin divider between icons and caption */
.img-card-icons::after
{
    content:      "";
    display:      block;
    width:        1px;
    height:       12px;
    background:   var(--border);
    margin:       0 6px;
}

.img-icon-btn
{
    background:  none;
    border:      none;
    padding:     3px 4px;
    cursor:      pointer;
    color:       var(--text-dim);
    font-size:   14px;
    line-height: 1;
    display:     flex;
    align-items: center;
    transition:  color 0.12s;
    border-radius: 3px;
}

.img-icon-btn:hover { color: var(--accent); }

/* Use SVG icons via mask-image for clean monochrome rendering */
.img-icon-reload,
.img-icon-download
{
    width:            16px;
    height:           16px;
    background-color: var(--text-dim);
    -webkit-mask-repeat: no-repeat;
    mask-repeat:      no-repeat;
    -webkit-mask-position: center;
    mask-position:    center;
    -webkit-mask-size: contain;
    mask-size:        contain;
    transition:       background-color 0.12s;
    display:          inline-block;
}

.img-icon-btn:hover .img-icon-reload,
.img-icon-btn:hover .img-icon-download { background-color: var(--accent); }

/* Reload: circular arrows */
.img-icon-reload
{
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M17.65 6.35A7.958 7.958 0 0 0 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08A5.99 5.99 0 0 1 12 18c-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z'/%3E%3C/svg%3E");
    mask-image:         url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M17.65 6.35A7.958 7.958 0 0 0 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08A5.99 5.99 0 0 1 12 18c-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z'/%3E%3C/svg%3E");
}

/* Restore: upload arrow (opposite of download) */
.img-icon-restore
{
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z' transform='scale(1,-1) translate(0,-24)'/%3E%3C/svg%3E");
    mask-image:         url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z' transform='scale(1,-1) translate(0,-24)'/%3E%3C/svg%3E");
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    -webkit-mask-size: contain;
    mask-size: contain;
    width:  16px;
    height: 16px;
    background-color: var(--text-dim);
    display: inline-block;
    transition: background-color 0.12s;
}

.img-icon-btn:hover .img-icon-restore { background-color: var(--accent); }

/* Download: arrow pointing down with a line beneath */
.img-icon-download
{
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z'/%3E%3C/svg%3E");
    mask-image:         url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z'/%3E%3C/svg%3E");
}

.img-card-caption
{
    font-size:     10px;
    color:         var(--text-dim);
    white-space:   nowrap;
    overflow:      hidden;
    text-overflow: ellipsis;
    line-height:   1.5;
    flex:          1;
    min-width:     0;
}

/* ── Pending image card ──────────────────────────── */

.img-card-pending
{
    cursor:       default;
    background:   var(--surface2);
    border-color: var(--accent-dim);
    min-height:   180px;
}

.img-card-pending:hover { border-color: var(--accent-dim); }

.pending-body
{
    display:        flex;
    flex-direction: column;
    align-items:    center;
    gap:            8px;
    padding:        16px 12px;
    width:          100%;
    box-sizing:     border-box;
}

.pending-spinner { line-height: 1; }
.pending-spinner .spinner { width: 18px; height: 18px; }

.pending-model
{
    font-size:  10px;
    color:      var(--accent);
    text-align: center;
    word-break: break-all;
}

.pending-timer
{
    font-size:           14px;
    color:               var(--text-bright);
    font-variant-numeric: tabular-nums;
}

.pending-prompt
{
    font-size:    10px;
    color:        var(--text-dim);
    text-align:   center;
    line-height:  1.4;
    max-height:   48px;
    overflow:     hidden;
    text-overflow: ellipsis;
    display:      -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

/* ── Censored image card ─────────────────────────── */

.img-card-censored
{
    border-color: var(--danger);
    cursor:       default;
}

.img-card-censored:hover { transform: none; border-color: var(--danger); }

.censored-icon  { font-size: 24px; line-height: 1; }

.censored-label
{
    font-size:  11px;
    color:      #c06060;
    font-weight: 500;
}

/* ── Video icon ──────────────────────────────────── */

.img-icon-video
{
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M17 10.5V7a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-3.5l4 4v-11l-4 4z'/%3E%3C/svg%3E");
    mask-image:         url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M17 10.5V7a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-3.5l4 4v-11l-4 4z'/%3E%3C/svg%3E");
    -webkit-mask-repeat: no-repeat;
    mask-repeat:        no-repeat;
    -webkit-mask-position: center;
    mask-position:      center;
    -webkit-mask-size:  contain;
    mask-size:          contain;
    width:              16px;
    height:             16px;
    background-color:   var(--text-dim);
    display:            inline-block;
    transition:         background-color 0.12s;
}

.img-icon-btn:hover .img-icon-video { background-color: var(--accent); }

/* ── Video cards ─────────────────────────────────── */

.img-card-video .img-card-image-wrap video
{
    width:      100%;
    display:    block;
    height:     auto;
    cursor:     pointer;
}

.img-card-video-pending .video-pending-icon
{
    font-size:   24px;
    line-height: 1;
}

/* ── Toast notifications ─────────────────────────── */

#toast-container
{
    position:       fixed;
    top:            24px;
    right:          24px;
    z-index:        9000;
    display:        flex;
    flex-direction: column;
    gap:            10px;
    pointer-events: none;
}

.toast
{
    background:    var(--surface);
    border:        1px solid var(--border);
    border-radius: var(--radius);
    box-shadow:    0 4px 20px rgba(0,0,0,0.4);
    padding:       10px 14px;
    font-size:     12px;
    color:         var(--text);
    display:       flex;
    align-items:   center;
    gap:           10px;
    max-width:     340px;
    pointer-events: all;
    animation:     toast-in 0.2s ease;
}

.toast.toast-success { border-left: 3px solid #3a6b4a; }
.toast.toast-error   { border-left: 3px solid var(--danger); }
.toast.toast-info    { border-left: 3px solid var(--accent-dim); }

.toast-dismiss
{
    background:  none;
    border:      none;
    color:       var(--text-dim);
    cursor:      pointer;
    font-size:   14px;
    line-height: 1;
    padding:     0;
    flex-shrink: 0;
}

.toast-dismiss:hover { color: var(--text); }

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

/* ── Jobs dropdown ───────────────────────────────── */

#jobs-dropdown
{
    font-family: var(--font-mono);
}

#jobs-dropdown > div > div:last-child
{
    border-bottom: none;
}

/* ── Photos tab ──────────────────────────────────── */

.photo-drop-zone
{
    flex:           1;
    border:         2px dashed var(--border);
    border-radius:  var(--radius);
    background:     var(--surface);
    display:        flex;
    flex-direction: column;
    align-items:    center;
    justify-content: center;
    padding:        24px 16px;
    gap:            12px;
    cursor:         pointer;
    transition:     border-color 0.15s, background 0.15s;
    box-sizing:     border-box;
    text-align:     center;
}

.photo-drop-zone:hover,
.photo-drop-zone.drag-over
{
    border-color: var(--accent-dim);
    background:   var(--surface2);
}

/* Generic file-drop highlight — context/agent toolbars, empty-state panels,
   and the editor pane. An ::after overlay (not outline/background) so the
   highlight stays visible above Monaco's opaque editor surface. */
.file-drop-hover
{
    position: relative;
}

.file-drop-hover::after
{
    content:        "";
    position:       absolute;
    inset:          0;
    border:         2px dashed var(--accent);
    background:     rgba(200, 169, 110, 0.08);
    pointer-events: none;
    z-index:        100;
}

.photo-drop-label
{
    font-size:   18px;
    color:       var(--text-bright);
    font-weight: 500;
}

.photo-drop-hint
{
    font-size: 11px;
    color:     var(--text-dim);
}

/* The saved avatar image */
.photo-avatar
{
    width:         160px;
    height:        160px;
    object-fit:    cover;
    border-radius: 50%;
    border:        2px solid var(--border);
    display:       block;
}

/* Remove button under the avatar */
.photo-avatar-del
{
    background:    none;
    border:        1px solid var(--border);
    border-radius: var(--radius);
    color:         var(--text-dim);
    font-size:     11px;
    padding:       3px 10px;
    cursor:        pointer;
    transition:    color 0.12s, border-color 0.12s;
}

.photo-avatar-del:hover
{
    color:        #c06060;
    border-color: var(--danger);
}

/* ── Chat avatars ────────────────────────────────── */

.message-avatar-row
{
    display:     flex;
    align-items: flex-start;
    gap:         10px;
}

.message-avatar-row .message
{
    flex:      1;
    min-width: 0;
}

.message-avatar
{
    width:         40px;
    height:        40px;
    border-radius: 50%;
    object-fit:    cover;
    flex-shrink:   0;
    border:        1px solid var(--border);
    position:      relative;
    z-index:       12;   /* sit above the message header text */
}

@keyframes progress-pulse
{
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.4; }
}

/* PTT mic button — shared recording state for main button and dialog test button */
#btn-ptt.recording,
#btn-vcfg-test.recording
{
    border-color: var(--danger);
    color:        var(--danger);
    animation:    ptt-pulse 1s ease-in-out infinite;
}

@keyframes ptt-pulse
{
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.5; }
}

/* PTT transcribing overlay — shown over the active textarea while STT request is in-flight */
#ptt-transcribing-overlay.active,
#ptt-transcribing-overlay-image.active,
#ptt-transcribing-overlay-edit.active
{
    display: flex !important;
}

/* ── Library Manager (Agents panel) ─────────────── */

.lib-manager
{
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-top: 4px;
}

.lib-manager-header
{
    background: var(--surface2);
    padding: 8px 12px;
    font-size: 12px;
    color: var(--text-bright);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.lib-manager-body
{
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.lib-manager-file
{
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}

.lib-manager-empty
{
    font-size: 11px;
    color: var(--text-dim);
    font-style: italic;
}

/* ── Chat model picker dropdown ─────────────────────────── */
.chat-model-item
{
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    cursor: pointer;
    font-size: 12px;
    font-family: var(--font-mono);
    color: var(--text);
    user-select: none;
}
.chat-model-item:hover  { background: var(--surface2); }
.chat-model-item.selected { background: var(--accent-dim); color: var(--accent); }
.chat-model-item .cmi-id   { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-model-item .cmi-tier { color: var(--text-dim); font-size: 11px; flex-shrink: 0; }
.chat-model-item.selected .cmi-tier { color: var(--accent); opacity: 0.7; }
.chat-model-item .cmi-star
{
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-dim);
    font-size: 13px;
    padding: 0 1px;
    opacity: 0;
    transition: opacity 0.1s;
    line-height: 1;
}
.chat-model-item:hover .cmi-star  { opacity: 0.5; }
.chat-model-item .cmi-star.starred { opacity: 1; color: var(--accent); }
.chat-cost-filter.active { background: var(--accent-dim) !important; color: var(--accent) !important; border-color: var(--accent-dim) !important; }
.chat-model-section-header
{
    padding: 5px 10px 2px;
    font-size: 10px;
    letter-spacing: 0.08em;
    color: var(--text-dim);
    text-transform: uppercase;
    border-top: 1px solid var(--border);
    margin-top: 2px;
}

/* ── Greeting picker (shared by Studio and Player) ──────────── */

.greeting-picker
{
    max-width: 85%;
    margin: 0 auto;
    /* Never taller than the history viewport: the preview shrinks and
       scrolls internally instead of making the history scroll. */
    max-height: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px;
    background: var(--surface);
    border: 1px solid var(--accent-dim);
    border-radius: var(--radius);
}

.greeting-name-row
{
    display: flex;
    align-items: center;
    gap: 10px;
}

.greeting-name-row label
{
    font-size: 12px;
    color: var(--text-dim);
    white-space: nowrap;
}

.greeting-name-input
{
    flex: 1;
    min-width: 0;
    padding: 6px 10px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 13px;
    outline: none;
}

.greeting-name-input:focus { border-color: var(--accent-dim); }

.greeting-nav-row
{
    display: flex;
    align-items: center;
    gap: 10px;
}

.greeting-nav-btn { padding: 2px 12px; font-size: 15px; line-height: 1.4; }
.greeting-nav-btn:disabled { opacity: 0.35; cursor: default; }
.greeting-nav-btn:disabled:hover { border-color: var(--border); color: var(--text); }

.greeting-counter
{
    flex: 1;
    text-align: center;
    font-size: 12px;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.greeting-preview
{
    flex: 0 1 auto;      /* shrinks first when space is tight */
    min-height: 60px;
    max-height: 40vh;
    overflow-y: auto;
    line-height: 1.6;
}

.greeting-footer
{
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.greeting-preview:focus
{
    outline: 1px solid var(--accent-dim);
    outline-offset: 2px;
}

#greeting-chooser-row
{
    display: flex;
    justify-content: flex-start;
    flex-shrink: 0;
}

/* Substituted {user} names render as inline code chips in the preview;
   tint them so the replacement stands out from the surrounding prose. */
.greeting-preview code
{
    color: var(--accent);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0 5px;
}

/* Markdown-rendered bubbles: the newlines marked emits between <p> blocks
   each painted a blank line under pre-wrap, doubling paragraph spacing
   (found during PartyLine Step 9 smoke; same latent issue here). Markdown is
   the only source of <p> inside a bubble; plain-text bubbles keep pre-wrap. */
.message-bubble:has(p) { white-space: normal; }
