/* Velvet Study UI kit: toasts, dialogs, telemetry chips, shared utility classes that replace
   former inline styles, accessibility helpers and responsive layout. Loaded after styles.css. */

/* ---------- Accessibility ---------- */
:focus-visible {
    outline: 2px solid var(--focus-ring, #a78bfa);
    outline-offset: 2px;
}
.chat-textarea:focus-visible, .form-input:focus-visible, .form-select:focus-visible, .form-textarea:focus-visible,
.draft-body:focus-visible { outline-offset: 0; }
.modal-card:focus { outline: none; }
[hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) {
    html:not(.motion-full) *, html:not(.motion-full) *::before, html:not(.motion-full) *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}

/* ---------- Shared bits ---------- */
.muted-xs { font-size: 0.72rem; color: var(--text-muted); }
.muted-sm { font-size: 0.75rem; color: var(--text-muted); }
.muted-md { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.25rem; }
.empty-state { text-align: center; color: var(--text-muted); margin-top: 3rem; font-style: italic; }
.empty-note { font-size: 0.85rem; color: var(--text-muted); font-style: italic; }
.error-block { color: var(--danger); padding: 1rem; font-size: 0.85rem; }
.col-gap { display: flex; flex-direction: column; gap: 0.4rem; }
.row-inline { display: flex; gap: 0.5rem; align-items: center; }
.loading-block { display: flex; align-items: center; justify-content: center; gap: 0.6rem; padding: 2rem 1rem; color: var(--text-muted); font-size: 0.85rem; }
.spinner-inline {
    width: 16px; height: 16px; border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.15); border-top-color: var(--primary);
    animation: vs-spin 0.8s linear infinite; display: inline-block;
}
@keyframes vs-spin { to { transform: rotate(360deg); } }
.is-loading { opacity: 0.6; pointer-events: none; }
.skeleton { background: linear-gradient(90deg, #1a1a24 25%, #242433 50%, #1a1a24 75%); background-size: 200% 100%; animation: vs-shimmer 1.4s infinite; border-radius: 4px; }
@keyframes vs-shimmer { to { background-position: -200% 0; } }

button.btn-danger-outline { color: #ef4444; border-color: rgba(239, 68, 68, 0.35); }
button.btn-danger-outline:hover:not(:disabled) { background: rgba(239, 68, 68, 0.12); }
.btn-primary.btn-success { background: #059669; }
.btn-primary.btn-success:hover:not(:disabled) { background: #047857; }
.btn-primary.btn-danger { background: #dc2626; }
.btn-primary.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-primary.btn-indigo { background: #4f46e5; }
.btn-primary:disabled, .btn-secondary:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-icon { width: 2rem; padding: 0.35rem 0; text-align: center; font-weight: 700; }
.btn-mini { padding: 0.2rem 0.5rem; font-size: 0.72rem; }
.btn-mini.btn-delete { font-size: 0.85rem; color: #f87171; }
.btn-link { text-decoration: none; display: inline-flex; align-items: center; padding: 0.4rem 0.85rem; font-size: 0.8rem; }
.btn-small { padding: 0.25rem 0.6rem; font-size: 0.78rem; }
.btn-primary, .btn-secondary { font-family: inherit; }

.footer-split { justify-content: space-between; align-items: center; }
.footer-buttons { display: flex; gap: 0.5rem; }
.consultation-tabs { display: flex; gap: 0.5rem; align-items: center; }
.customer-title-row { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.archived-badge {
    font-size: 0.68rem; font-weight: 700; letter-spacing: 0.05em; padding: 0.15rem 0.5rem; border-radius: 10px;
    background: rgba(251, 191, 36, 0.14); border: 1px solid rgba(251, 191, 36, 0.4); color: var(--accent-gold);
}
.meter-item { min-width: 140px; }
.meter-name { cursor: help; }
.meter-delta { font-size: 0.75rem; }
.meter-delta.up { color: #38bdf8; }
.meter-delta.down { color: #f43f5e; }
body.is-readonly .override-trigger { display: none; }
.override-trigger { min-width: 1.4rem; min-height: 1.4rem; }

/* ---------- Header / side panel ---------- */
.btn-side-toggle { display: none; white-space: nowrap; margin-left: auto; padding: 0.3rem 0.65rem; font-size: 0.78rem; }
.side-close, .side-backdrop { display: none; }
.facts-progress { font-size: 0.72rem; color: var(--text-muted); text-align: right; }
.fact-hidden { opacity: 0.8; }
.fact-placeholder { color: var(--text-muted); font-style: italic; }
.soft-text { white-space: pre-wrap; margin-top: 0.35rem; line-height: 1.45; }
.usage-cost { color: var(--text-muted); }

.shortcuts-popover {
    position: fixed; top: 3.2rem; right: 1rem; z-index: 950; width: min(340px, calc(100vw - 2rem));
    background: #1a1a24; border: 1px solid var(--border-light); border-radius: 8px; padding: 0.8rem 1rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6); font-size: 0.82rem;
}
.shortcuts-title { font-weight: 700; color: var(--accent-gold); margin-bottom: 0.5rem; }
.shortcuts-list { display: grid; grid-template-columns: auto 1fr; gap: 0.35rem 0.9rem; align-items: baseline; }
.shortcuts-list dt { white-space: nowrap; }
.shortcuts-list dd { color: var(--text-muted); }
kbd {
    font-family: monospace; font-size: 0.72rem; background: #272733; border: 1px solid var(--border-light);
    border-bottom-width: 2px; border-radius: 4px; padding: 0.05rem 0.35rem; color: #e4e4e7;
}

/* ---------- Chat input ---------- */
.chat-buttons { display: flex; flex-direction: column; gap: 0.35rem; }
.btn-impersonate { padding: 0.4rem 0.65rem; font-size: 0.75rem; white-space: nowrap; }
.btn-stop {
    background: #b91c1c; color: #fff; border: none; border-radius: 8px; padding: 0.7rem 1.25rem; font-weight: 600;
    cursor: pointer; height: 44px; font-family: inherit;
}
.btn-stop:hover { background: #991b1b; }
.typing-indicator .status-step-pill, .typing-indicator span { margin-right: 0.35rem; }
.stream-placeholder { opacity: 0.5; }
.inline-edit { display: flex; flex-direction: column; gap: 0.5rem; width: 100%; }
.inline-edit-input { width: 100%; min-height: 80px; font-family: inherit; font-size: 0.95rem; }
.inline-edit-actions { display: flex; justify-content: flex-end; gap: 0.4rem; }
.message-actions-bar .msg-btn:disabled { opacity: 0.4; cursor: default; }
.draft-hint { font-size: 0.75rem; color: var(--text-muted); }
.draft-telemetry:empty, .settlement-telemetry:empty, .conclude-telemetry:empty, .qa-telemetry:empty { display: none; }
.conclude-header { margin-bottom: 0.75rem; font-size: 0.9rem; color: var(--accent-gold); font-weight: 600; }
.conclude-telemetry { margin-top: 0.5rem; }
.settlement-fields { display: flex; flex-direction: column; gap: 0.75rem; margin-top: 0.5rem; }
.settlement-label { font-weight: 600; margin-bottom: 0.25rem; display: block; }
.settlement-textarea { min-height: 90px; width: 100%; font-family: inherit; font-size: 0.85rem; }
.settlement-notes { min-height: 75px; }
.settlement-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 0.75rem; }
.settlement-btn { background: #059669; }
/* Run mode: local-only options (LM Studio, ComfyUI) vanish on a server; server-only ones appear there. */
body.mode-server .local-only { display: none !important; }
body:not(.mode-server) .server-only { display: none !important; }

.settlement-btn.settlement-btn-decline { background: transparent; border: 1px solid #7f1d1d; color: #fca5a5; }
.settlement-btn.settlement-btn-decline:hover { background: #7f1d1d; color: #fff; }

/* Quick actions */
button.qa-collapsible-header { width: 100%; border: none; color: inherit; font-family: inherit; text-align: left; }
.qa-confirm-info { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.qa-buttons { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.qa-reroll-btn { padding: 0.25rem 0.55rem; font-size: 0.75rem; }
.qa-clear-btn { padding: 0.25rem 0.5rem; font-size: 0.75rem; }
.qa-confirm-btn { padding: 0.35rem 0.75rem; font-size: 0.8rem; background: #059669; }
.qa-confirm-btn:disabled { background: #272733; }
.qa-option-btn { font-family: inherit; width: 100%; }

/* ---------- Telemetry chips ---------- */
.telemetry-line { flex-wrap: wrap; row-gap: 0.15rem; max-width: 100%; }
.telemetry-line .tl-chip { white-space: nowrap; }
.telemetry-line .tl-model { max-width: 16rem; overflow: hidden; text-overflow: ellipsis; color: #a5b4fc; }
.telemetry-line .tl-sep { opacity: 0.4; }
.telemetry-line .debug-view-btn { font-family: inherit; }
.candidate-telemetry { font-size: 0.62rem; padding: 0.1rem 0.3rem; gap: 0.3rem; margin-top: 0.2rem; }
.candidate-telemetry .debug-view-btn { font-size: 0.62rem; }
.candidate-telemetry .tl-model { max-width: 7rem; }
body.hide-telemetry .telemetry-line { display: none !important; }
.debug-tabs { display: flex; gap: 0.5rem; border-bottom: 1px solid var(--border-color); background: #101015; padding: 0.5rem 1rem; flex-wrap: wrap; }
.debug-content { background: #09090d; font-family: monospace; font-size: 0.8rem; white-space: pre-wrap; color: #e4e4e7; padding: 1rem; overflow-wrap: anywhere; }
.modal-card-debug { max-width: 820px; width: 90vw; height: 80vh; }

/* ---------- Toasts ---------- */
.toast-region {
    position: fixed; right: 1rem; bottom: 1rem; z-index: 5000; display: flex; flex-direction: column; gap: 0.5rem;
    width: min(380px, calc(100vw - 2rem)); pointer-events: none;
}
.toast {
    pointer-events: auto; display: flex; align-items: flex-start; gap: 0.6rem; padding: 0.65rem 0.75rem;
    background: #232330; border: 1px solid var(--border-light); border-left-width: 4px; border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55); font-size: 0.85rem; animation: vs-toast-in 0.18s ease-out;
}
.toast-leaving { opacity: 0; transform: translateX(12px); transition: opacity 0.18s, transform 0.18s; }
@keyframes vs-toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.toast-info { border-left-color: #38bdf8; }
.toast-success { border-left-color: #10b981; }
.toast-warn { border-left-color: #fbbf24; }
.toast-error { border-left-color: #ef4444; background: #2a1c22; }
.toast-icon {
    flex: none; width: 1.2rem; height: 1.2rem; border-radius: 50%; display: grid; place-items: center;
    font-size: 0.72rem; font-weight: 700; color: #0f0f13; background: #38bdf8; margin-top: 0.05rem;
}
.toast-success .toast-icon { background: #10b981; }
.toast-warn .toast-icon { background: #fbbf24; }
.toast-error .toast-icon { background: #ef4444; color: #fff; }
.toast-body { flex: 1; min-width: 0; }
.toast-title { font-weight: 700; margin-bottom: 0.1rem; }
.toast-message { overflow-wrap: anywhere; line-height: 1.35; }
.toast-action {
    flex: none; background: rgba(139, 92, 246, 0.2); border: 1px solid rgba(139, 92, 246, 0.5); color: #ddd6fe;
    border-radius: 5px; padding: 0.15rem 0.55rem; font-size: 0.78rem; cursor: pointer; font-family: inherit;
}
.toast-action:hover { background: rgba(139, 92, 246, 0.4); }
.toast-close { flex: none; background: none; border: none; color: var(--text-muted); font-size: 1.1rem; line-height: 1; cursor: pointer; padding: 0 0.15rem; }
.toast-close:hover { color: #fff; }

/* ---------- Dialogs ---------- */
.dialog-card { max-width: 440px; }
.dialog-body { gap: 0.75rem; }
.dialog-message { font-size: 0.9rem; line-height: 1.45; color: #d4d4d8; white-space: pre-wrap; }
.dialog-error { color: var(--danger); font-size: 0.78rem; min-height: 1em; margin-top: 0.25rem; }

/* ---------- Modal sizing (formerly inline) ---------- */
.modal-card-candidates { max-width: 96vw; width: 96vw; height: 95vh; max-height: 95vh; }
.candidates-body { overflow: hidden; padding: 0.6rem 1rem; min-height: 0; }
.candidate-status { font-size: 0.8rem; color: var(--text-muted); display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.status-step-pill { font-weight: 600; color: var(--accent-gold); background: rgba(217, 119, 6, 0.15); padding: 0.18rem 0.5rem; border-radius: 4px; }
.status-current { color: var(--text-main); font-weight: 500; }
.status-error { color: var(--danger); }
.status-ok { color: #10b981; font-weight: 600; }
.modal-card-ledger { max-width: 980px; width: 92vw; height: 84vh; max-height: 90vh; }
.ledger-body { overflow: hidden; padding: 1rem; gap: 0.75rem; }
.ledger-search-row { display: flex; gap: 0.5rem; align-items: center; }
.ledger-search-row .form-input { flex: 1; }
.ledger-count { font-size: 0.8rem; color: var(--text-muted); white-space: nowrap; }
.ledger-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 0.6rem; padding-right: 0.3rem; }
.modal-card-dossier { max-width: 1050px; width: 94vw; height: 90vh; max-height: 94vh; }
.dossier-body { padding: 1.25rem; gap: 1.25rem; }
.settings-nav-tabs { display: flex; gap: 0.4rem; padding: 0.6rem 1rem 0; border-bottom: 1px solid var(--border-color); background: rgba(0, 0, 0, 0.15); overflow-x: auto; }
.settings-body { padding: 1.25rem; }
.modal-card-settings { max-width: min(1100px, 100%) !important; }
.imgdbg-error { color: #f87171; }
button.imgdbg-item { display: block; width: 100%; text-align: left; background: none; border: none; border-bottom: 1px solid rgba(255, 255, 255, 0.05); color: inherit; font-family: inherit; }

/* Ledger list + dossier */
.ledger-case-main { flex: 1; min-width: 0; }
.ledger-case-head { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.2rem; flex-wrap: wrap; }
.ledger-case-name { font-weight: 700; color: var(--accent-gold); font-size: 1.05rem; }
.ledger-case-summary { font-size: 0.8rem; color: #cbd5e1; line-height: 1.35; margin-bottom: 0.4rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ledger-case-meta { display: flex; gap: 0.6rem; align-items: center; font-size: 0.75rem; color: var(--text-muted); flex-wrap: wrap; }
.ledger-stat { font-weight: 600; }
.btn-view-dossier { padding: 0.4rem 0.85rem; font-size: 0.8rem; white-space: nowrap; }
.dossier-banner { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; background: #14141d; border: 1px solid var(--border-color); border-radius: 8px; padding: 1rem; }
.dossier-name-row { display: flex; align-items: center; gap: 0.6rem; }
.dossier-name { margin: 0; color: var(--accent-gold); font-size: 1.4rem; }
.dossier-finals { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.35rem; }
.dossier-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.dossier-actions .btn-primary { padding: 0.4rem 0.85rem; font-size: 0.8rem; }
.dossier-details { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; font-size: 0.85rem; }
.dossier-details .span-all { grid-column: 1 / -1; }
.dossier-notes-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.75rem; }
.dossier-notes-head .dossier-title { margin: 0; }
.dossier-col { display: flex; flex-direction: column; gap: 0.85rem; }
.dossier-label { font-size: 0.78rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; margin-bottom: 0.25rem; }
.dossier-textarea { min-height: 100px; }
.dossier-edit-actions { display: flex; justify-content: flex-end; gap: 0.5rem; }
button.ledger-gallery-item { font-family: inherit; color: inherit; padding: 0; }

/* ---------- Candidates ---------- */
.candidate-info-center { justify-content: center; gap: 0.35rem; }
.slot-title { font-weight: 700; color: var(--text-muted); font-size: 0.85rem; }
.slot-title.is-active { color: var(--accent-gold); }
.slot-desc { font-size: 0.75rem; color: var(--text-muted); }
.candidate-headline { display: flex; justify-content: space-between; align-items: center; gap: 0.3rem; }
.candidate-facts { display: flex; align-items: center; gap: 0.3rem; margin-top: 0.15rem; font-size: 0.72rem; color: var(--text-muted); flex-wrap: wrap; }
.candidate-gen-meta { font-size: 0.68rem; color: var(--text-muted); margin-top: 0.15rem; }
.candidate-gen-meta:empty { display: none; }
.candidate-accept-row { margin-top: 0.35rem; display: flex; justify-content: flex-end; }
.btn-accept { padding: 0.25rem 0.65rem; font-size: 0.75rem; width: 100%; }
.candidate-portrait-loading .image-status-pill { font-size: 0.65rem; }

/* ---------- Settings editors ---------- */
.manager-card { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; padding: 0.5rem 0.6rem; border-radius: 6px; border: 1px solid rgba(255, 255, 255, 0.08); background: #181824; }
.manager-card.active { border-color: var(--primary); background: rgba(120, 80, 200, 0.12); }
.manager-info { min-width: 0; }
.manager-title { font-weight: 600; font-size: 0.85rem; color: #e4e4e7; }
.manager-active { color: var(--primary); font-size: 0.7rem; }
.manager-sub { font-size: 0.74rem; color: var(--text-muted); }
.manager-ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 360px; }
.manager-actions { display: flex; gap: 0.35rem; flex-shrink: 0; }
.row-card { padding: 0.5rem; background: #141420; border-radius: 5px; border: 1px solid rgba(255, 255, 255, 0.07); display: flex; flex-direction: column; gap: 0.4rem; }
.row-top { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; }
.row-bounds { display: flex; gap: 0.25rem; align-items: center; font-size: 0.7rem; color: var(--text-muted); flex-wrap: wrap; }
.row-check { font-size: 0.72rem; color: var(--text-muted); display: flex; align-items: center; gap: 0.25rem; cursor: pointer; }
.hf-options { display: flex; flex-direction: column; gap: 0.3rem; }
.opt-row { display: flex; gap: 0.35rem; align-items: center; flex-wrap: wrap; background: rgba(255, 255, 255, 0.02); padding: 0.2rem 0.35rem; border-radius: 4px; border: 1px solid rgba(255, 255, 255, 0.04); }
.fi-sm { font-size: 0.75rem; padding: 0.25rem 0.4rem; }
.fi-xs { font-size: 0.72rem; padding: 0.25rem 0.4rem; color: #cbd5e1; }
.fi-num { width: 56px; font-size: 0.75rem; padding: 0.2rem 0.3rem; }
.fi-name { flex: 1.2; min-width: 110px; font-weight: 600; }
.fi-name-strong { flex: 1; font-size: 0.78rem; font-weight: 600; }
.fi-id { flex: 1; min-width: 90px; }
.fi-wide { width: 100%; }
.fi-gold { color: var(--accent-gold); }
.fi-opt-name { flex: 1.2; min-width: 110px; }
.fi-opt-desc { flex: 2; min-width: 180px; color: #cbd5e1; }
#sceneMoods { max-height: 240px; overflow-y: auto; padding-right: 0.3rem; }

/* ---------- Architect assistant ---------- */
.asst-welcome-title { font-weight: 700; color: var(--accent-gold); margin-bottom: 0.4rem; font-size: 0.95rem; }
.asst-bubble-bot p { margin-bottom: 0.5rem; line-height: 1.5; }
.asst-bubble-bot ul { padding-left: 1.25rem; margin-bottom: 0.6rem; line-height: 1.5; }
.asst-welcome-note { font-size: 0.8rem; color: var(--text-muted); border-left: 2px solid var(--accent-gold); padding-left: 0.5rem; }
.asst-text-body.is-pending { color: var(--text-muted); }
.ctx-scene { color: var(--accent-gold); }
.ctx-persona { color: #c084fc; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
    .meters-group { gap: 0.75rem; flex-wrap: wrap; justify-content: flex-end; }
    .meter-item { min-width: 120px; width: 120px; }
}
@media (max-width: 900px) {
    body { height: 100dvh; }
    header { flex-wrap: wrap; padding: 0.5rem 0.75rem; gap: 0.5rem; }
    .header-actions { flex-wrap: wrap; gap: 0.35rem; }
    .tabs-bar { padding: 0.3rem 0.75rem; }
    .btn-side-toggle { display: inline-flex; }
    .workspace-container { grid-template-columns: minmax(0, 1fr); }
    .chat-section { border-right: none; }
    .customer-header-bar { flex-direction: column; align-items: stretch; gap: 0.5rem; padding: 0.5rem 0.75rem; }
    .meters-group { justify-content: flex-start; }
    .chat-input-bar { padding: 0.5rem 0.75rem; }
    .messages-container { padding-left: 0.75rem; padding-right: 0.75rem; }

    .side-panel-section {
        position: fixed; top: 0; right: 0; bottom: 0; width: min(92vw, 380px); height: auto; z-index: 900;
        transform: translateX(105%); visibility: hidden; transition: transform 0.2s ease, visibility 0.2s;
        box-shadow: -10px 0 30px rgba(0, 0, 0, 0.6);
    }
    body.side-open .side-panel-section { transform: none; visibility: visible; }
    .side-close { display: block; background: none; border: none; color: var(--text-muted); font-size: 1.4rem; padding: 0 0.8rem; cursor: pointer; }
    .side-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); z-index: 890; }
    body.side-open .side-backdrop { display: block; }

    .candidate-grid-3x3 { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: none; grid-auto-rows: 210px; height: auto; overflow-y: auto; align-content: start; }
    .candidates-body { overflow-y: auto; }
    .candidate-grid-3x3 .candidate-card { overflow: hidden; min-height: 0; }
    .candidate-grid-3x3 .candidate-card-layout { height: 100%; }
    .candidate-grid-3x3 .candidate-portrait-wrapper { width: 110px; flex: none; }
    .candidate-grid-3x3 .candidate-info-col { overflow: hidden; gap: .3rem; justify-content: flex-start; }
    .modal-overlay { padding: 0.5rem; }
    .modal-card, .modal-card-candidates, .modal-card-ledger, .modal-card-dossier, .modal-card-debug { width: 100% !important; max-width: 100% !important; }
    .modal-card-settings { height: 96vh !important; max-height: 96vh !important; }
    .dossier-details { grid-template-columns: 1fr; }
    .toast-region { right: 0.5rem; left: 0.5rem; bottom: 0.5rem; width: auto; }
}
@media (max-width: 560px) {
    .candidate-grid-3x3 { grid-template-columns: minmax(0, 1fr); }
    .brand-title span:last-child { display: none; }
    .chat-form { flex-wrap: wrap; }
    .chat-buttons { flex-direction: row; width: 100%; }
    .chat-buttons button { flex: 1; }
    .qa-confirm-bar { flex-direction: column; align-items: stretch; gap: 0.4rem; }
    .quick-actions-grid { grid-template-columns: minmax(0, 1fr) !important; }
    .modal-footer { flex-wrap: wrap; }
    .ai-config { grid-template-columns: 1fr; }
}

/* spacing / sizing polish */
.meter-header { gap: .4rem; }
.meter-item { width: auto; min-width: 150px; }
.modal-footer .modal-close-btn { font-size: inherit; }

/* ---------- Accounts (server mode) ---------- */
body.mode-server:not(.is-admin) .admin-only { display: none !important; }

.auth-screen { position: fixed; inset: 0; z-index: 5000; display: flex; align-items: center; justify-content: center; padding: 1rem; background: var(--bg-main, #0b0b10); }
.auth-screen[hidden] { display: none; }
.auth-card { width: min(380px, 100%); background: var(--bg-panel, #15151d); border: 1px solid var(--border-color); border-radius: 12px; padding: 1.5rem; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5); }
.auth-brand { text-align: center; font-weight: 700; letter-spacing: 0.12em; color: var(--accent-gold); margin-bottom: 1rem; }
.auth-tabs { display: flex; gap: 0.4rem; margin-bottom: 1rem; }
.auth-tabs .tab-btn { flex: 1; }
.auth-hint { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 0.6rem; min-height: 1em; }
.auth-message { font-size: 0.85rem; min-height: 1.2em; margin-bottom: 0.6rem; color: #fca5a5; }
.auth-message.ok { color: #6ee7b7; }
.auth-submit { width: 100%; }

.header-user { display: flex; align-items: center; gap: 0.5rem; }
.header-user[hidden] { display: none; }
.user-name { font-size: 0.82rem; color: var(--text-muted); }
.user-credits { font-size: 0.78rem; font-weight: 700; color: var(--accent-gold); border: 1px solid var(--border-color); border-radius: 999px; padding: 0.1rem 0.55rem; }
.user-credits.low { color: #fca5a5; border-color: #7f1d1d; }

.admin-users { display: flex; flex-direction: column; gap: 0.5rem; }
.admin-section-title { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); margin: 0.6rem 0 0.2rem; }
.admin-user-row { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; padding: 0.5rem 0.7rem; border: 1px solid var(--border-color); border-radius: 8px; }
.admin-user-name { font-weight: 600; flex: 1 1 8rem; }
.admin-user-meta { font-size: 0.75rem; color: var(--text-muted); }
.admin-user-actions { display: flex; gap: 0.4rem; align-items: center; margin-left: auto; }
.admin-empty { font-size: 0.85rem; color: var(--text-muted); padding: 0.4rem 0; }
.admin-user-info { flex: 1 1 14rem; display: flex; flex-direction: column; gap: 0.1rem; }
.admin-credit-control { display: flex; gap: 0.35rem; align-items: center; }
.admin-credit-input { width: 5rem; padding: 0.25rem 0.4rem; }
.admin-user-info .admin-user-name { flex: 0 0 auto; }
