/* =================== */
/* FONTS */
/* =================== */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;600&family=Cinzel:wght@400;600&family=Cormorant+Garamond:wght@400;600&family=Lavishly+Yours&family=Love+Light&display=swap');

/* =================== */
/* RESET & ROOT */
/* =================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-tertiary: #1a1a25;
    --bg-card: #16161f;
    --accent: #7c3aed;
    --accent-hover: #6d28d9;
    --accent-glow: rgba(124, 58, 237, 0.4);
    --accent-tint: rgba(124, 58, 237, 0.15);
    --accent-tint-subtle: rgba(124, 58, 237, 0.08);
    --text-primary: #ffffff;
    --text-secondary: #a0a0b0;
    --text-muted: #606070;
    --border: rgba(255,255,255,0.08);
    --danger: #ef4444;
    --success: #22c55e;
    
    /* Theme Variables */
    --msg-opacity: 0.7;
    --name-font: 'Playfair Display';
    --name-font-size: 20px;
    --text-size: 15px;
    --avatar-size: 40px;
    --color-dialog: #e0e0e0;
    --color-italic: #a0a0b0;
    --color-bold: #ffffff;
    --color-custom: #7c3aed;
    --name-weight: 600;
    --name-color: #ffffff;
    --line-height: 1.7;
    --user-msg-color: #7c3aed;
    --char-msg-color: #1e1e23;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-primary);
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center;
    color: var(--text-primary);
    height: 100dvh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* =================== */
/* SCROLLBAR */
/* =================== */
::-webkit-scrollbar { width: 6px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* Scrollbar im Chat visuell entfernen (Scrollen bleibt) */
.chat-messages,
#chat-messages {
    scrollbar-width: none;        /* Firefox */
    -ms-overflow-style: none;     /* alte Edge/IE */
}

.chat-messages::-webkit-scrollbar,
#chat-messages::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;                /* Chrome/Safari/neue Edge */
}

/* =================== */
/* TOP BAR */
/* =================== */
#top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    z-index: 100;
}

#top-left, #top-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

#page-title {
    font-weight: 600;
    font-size: 16px;
    margin-left: 5px;
}

/* =================== */
/* BUTTONS */
/* =================== */
.icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.06);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.15s;
    backdrop-filter: blur(10px);
}

.icon-btn:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    transform: translateY(-1px);
}

.icon-btn:active { transform: scale(0.90); }
.icon-btn svg { width: 20px; height: 20px; }

.btn-primary, .btn-secondary, .btn-danger {
    padding: 10px 16px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    color: white;
    box-shadow: 0 2px 10px rgba(124, 58, 237, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(124, 58, 237, 0.4);
}

.btn-secondary {
    background: var(--bg-tertiary);
    border: 1px solid var(--border) !important;
    color: var(--text-secondary);
}

.btn-secondary:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--accent) !important;
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger), #dc2626);
    color: white;
}

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

.btn-sm { padding: 6px 10px !important; font-size: 11px !important; }

.btn-ghost {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-ghost.danger-hover:hover {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    border-color: var(--danger);
}

button:active { transform: scale(0.96); }

/* =================== */
/* MAIN CONTENT */
/* =================== */
#content {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
    background: transparent;
}

/* =================== */
/* SIDE PANELS */
/* =================== */
.side-panel {
	box-shadow: none;
    position: absolute;
    top: 1px;
    bottom: 1px;
    width: 320px;
    background: var(--bg-secondary);
    overflow: hidden;
    z-index: 200 !important;
    display: none;
    transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.side-panel:not(.open) {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

.side-panel.open { display: flex; }

#left-panel {
    left: 0;
    border-radius: 0 16px 16px 0;
}

#right-panel {
    right: 0;
	top: 60px;
    border-radius: 16px 0 0 16px;
}


.panel-content {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    padding: 20px;
}

.panel-resize-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 6px;
    cursor: col-resize;
    z-index: 10;
    transition: background 0.15s;
}

.panel-resize-handle:hover,
.side-panel.resizing .panel-resize-handle { background: var(--accent); }

.panel-resize-right { right: 0; }
.panel-resize-left { left: 0; }

/* Panel Form Styles */
.panel-content label {
    display: block;
    margin: 15px 0 5px;
    font-size: 13px;
    color: var(--text-secondary);
}

.panel-content label:first-of-type { margin-top: 0; }

.panel-content input,
.panel-content textarea {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
}

.panel-content input:focus,
.panel-content textarea:focus {
    outline: none;
    border-color: var(--accent);
}

/* Panel Headers */
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border);
}

.panel-header h3 {
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.panel-header h3 svg { width: 18px; height: 18px; }

.panel-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 5px;
    display: flex;
    border-radius: 6px;
    transition: 0.15s;
}

.panel-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.panel-close svg { width: 18px; height: 18px; }

/* Panel Tabs */
.panel-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 15px;
}

.panel-tab {
    flex: 1;
    padding: 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    transition: 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

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

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

.panel-tab svg { width: 14px; height: 14px; }

.panel-section { display: none; }
.panel-section.active { display: block; }

/* Right Panel Items */
.right-panel-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: 0.15s;
}

.right-panel-item:hover { border-color: var(--accent); }

.right-panel-item.active {
    border-color: var(--accent);
    background: rgba(124, 58, 237, 0.1);
}

.right-panel-avatar {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.right-panel-avatar img { width: 100%; height: 100%; object-fit: cover; }
.right-panel-avatar svg { width: 20px; height: 20px; color: var(--text-muted); }

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

.right-panel-name {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.right-panel-meta { font-size: 12px; color: var(--text-muted); }

.right-panel-actions { display: flex; gap: 5px; }

.right-panel-actions button {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.15s;
}

.right-panel-actions button:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.right-panel-actions button svg { width: 14px; height: 14px; }

/* =================== */
/* CHAT AREA */
/* =================== */
#chat-area {
    flex: 1;
    display: flex;
    justify-content: center;
    overflow: hidden;
    background: transparent;
    min-width: 0;
}

#chat-page {
    width: 100%;
    max-width: 900px;
    display: none;
    flex-direction: column;
    height: 100%;
    background: transparent;
    position: relative;
}

#chat-page.active {
    display: flex;
}

/* =================== */
/* CHAT HEADER - Fixed Glassy Bar */
/* =================== */
#chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 22px;
    margin: 15px auto 0 auto;
    max-width: 900px;
    width: 100%;
    background: var(--bar-color, rgba(18, 18, 26, 0.85));
    backdrop-filter: blur(var(--bar-blur, 20px));
    -webkit-backdrop-filter: blur(var(--bar-blur, 20px));
    border: 1px solid rgba(19, 25, 31, 1);
    border-bottom: none;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 10;
    flex-shrink: 0;
}

#chat-char-avatar {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
    cursor: pointer;
    transition: 0.15s;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

#chat-char-avatar:hover {
    transform: scale(1.05);
    border-color: var(--accent);
}

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

#chat-header-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

#chat-char-name {
    font-weight: 600;
    font-size: 16px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#chat-header-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
}

#chat-header-meta span:nth-child(2) {
    opacity: 0.4;
}

#chat-token-count {
    color: var(--accent);
    font-weight: 500;
}

#chat-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

#chat-actions .icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 8px;
}

#chat-actions .icon-btn svg {
    width: 18px;
    height: 18px;
}

#chat-actions .icon-btn.active {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

.bulk-delete-toolbar {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 14px;
    margin: 0 auto;
    width: 100%;
    max-width: 900px;
    background: rgba(0, 0, 0, 0.28);
    border-left: 1px solid rgba(255, 255, 255, 0.06);
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(var(--bar-blur, 20px));
    -webkit-backdrop-filter: blur(var(--bar-blur, 20px));
    flex-shrink: 0;
}

.bulk-delete-toolbar.show {
    display: flex;
}

#bulk-delete-count {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
}

.bulk-delete-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Remove old hover trigger */
.chat-header-trigger {
    display: none;
}

/* Chat Container */
#chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 15px;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

#chat-container::-webkit-scrollbar {
    display: none;
}

/* Gallery in Chat Header */
.chat-gallery {
    display: flex;
    gap: 8px;
    margin-left: 10px;
}

.chat-gallery-item {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    border: 1px solid var(--border);
    transition: 0.15s;
}

.chat-gallery-item:hover {
    border-color: var(--accent);
    transform: scale(1.1);
}

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

/* =================== */
/* MESSAGES */
/* =================== */
.message-wrapper {
    display: flex;
    flex-direction: column;
    max-width: 100%;
    margin-bottom: 6px;
    animation: messageFadeIn 0.3s ease-out forwards;
}

/* Message Header */
.message-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 12px 12px 0 0;
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-bottom: none;
}

.msg-select-wrap {
    display: none;
    width: 22px;
    height: 22px;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(0, 0, 0, 0.25);
    flex-shrink: 0;
}

.msg-select-checkbox {
    width: 14px;
    height: 14px;
    accent-color: var(--danger);
    cursor: pointer;
}

#chat-container.bulk-delete-mode .msg-select-wrap {
    display: inline-flex;
}

#chat-container.bulk-delete-mode .message-actions {
    display: none;
}

.message-wrapper.selected-for-delete .message-header,
.message-wrapper.selected-for-delete .message {
    border-color: rgba(239, 68, 68, 0.7);
    box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.45), 0 4px 20px rgba(0, 0, 0, 0.3);
}

.message-avatar {
    width: var(--avatar-size, 40px);
    height: var(--avatar-size, 40px);
    border-radius: 10px;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: 0.15s;
}

.message-avatar:hover { transform: scale(1.1); }

.message-avatar.user-avatar {
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
}

.message-avatar img { width: 100%; height: 100%; object-fit: cover; }
.message-avatar svg { width: 20px; height: 20px; color: var(--text-muted); }
.message-avatar.user-avatar svg { color: white; }

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

.message-name {
    position: relative;
    left: var(--name-pos-x, 0);
    top: var(--name-pos-y, 0);
}

.message-header {
    gap: var(--name-gap, 4px);
}

.message-name.char-name {
    font-family: var(--name-font, 'Playfair Display'), serif;
    font-size: var(--name-font-size, 20px);
    font-weight: var(--name-weight, 600);
    color: var(--name-color, #ffffff);
    -webkit-text-fill-color: var(--name-color, #ffffff);
    background: none;
}

.message-name.user-name {
    font-family: var(--name-font, 'Playfair Display'), serif;
    font-size: var(--name-font-size, 20px);
    font-weight: var(--name-weight, 600);
    color: var(--name-color, #ffffff);
}

.message-details {
    display: flex;
    gap: 10px;
    font-size: 11px;
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.3);
    padding: 4px 10px;
    border-radius: 20px;
    width: fit-content;
}

.message-id, .message-time { opacity: 1; }
.message-tokens { color: var(--accent); font-weight: 600; }

/* Gallery in Message Header */
.message-header-gallery {
    display: flex;
    gap: 6px;
    margin-left: auto;
}

.message-header-gallery-item {
    width: var(--avatar-size, 40px);
    height: var(--avatar-size, 40px);
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: 0.15s;
    flex-shrink: 0;
}

.message-header-gallery-item:hover {
    border-color: var(--accent);
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.message-header-gallery-item img { width: 100%; height: 100%; object-fit: cover; }

/* Message Bubble */
.message {
    padding: 15px 18px;
    border-radius: 0;
    line-height: var(--line-height, 1.7);
    font-size: var(--text-size, 15px);
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    -webkit-backdrop-filter: blur(var(--msg-blur, 10px));
    backdrop-filter: blur(var(--msg-blur, 10px));
}

.message.assistant {
    background: var(--char-msg-bg, rgba(30, 30, 35, 0.7));
}

.message.user {
    background: var(--user-msg-bg, rgba(30, 30, 35, 0.7));
}

/* Banner Support */
.message-wrapper.has-banner .message.assistant .message-thinking,
.message-wrapper.has-banner .message.assistant .message-details-block,
.message-wrapper.has-banner .message.assistant .message-text {
    position: relative;
    z-index: 1;
}

/* Message Actions */
.message-actions {
    display: flex;
    gap: 6px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 0 0 12px 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-top: none;
    -webkit-backdrop-filter: blur(var(--msg-blur, 10px));
    backdrop-filter: blur(var(--msg-blur, 10px));
}

.msg-action-btn {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.msg-action-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.4);
}

.msg-action-btn svg { width: 15px; height: 15px; }

/* Message Text Content */
.message-text {
    color: var(--text-primary);
    line-height: var(--line-height, 1.7);
}

.message-text p { margin: 0 0 10px 0; }
.message-text p:last-child { margin-bottom: 0; }

/* Text Formatting */
.text-dialog { color: var(--color-dialog, #e0e0e0); }
.text-italic { color: var(--color-italic, #a0a0b0); font-style: italic; }
.text-bold { color: var(--color-bold, #ffffff); font-weight: 600; }
.text-custom { color: var(--color-custom, #7c3aed); font-style: italic; }

/* Code in Messages */
.message-text pre {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 12px;
    overflow-x: auto;
    margin: 10px 0;
}

.message-text code { font-family: 'Consolas', 'Monaco', monospace; font-size: 13px; }
.message-text pre code { background: none; padding: 0; }

.message-text :not(pre) > code {
    background: rgba(124, 58, 237, 0.2);
    padding: 2px 6px;
    border-radius: 4px;
}

/* Message Headings */
.message-heading {
    margin: 15px 0 10px 0;
    color: var(--text-primary);
    font-weight: 600;
}

.message-text h1.message-heading {
    font-size: 1.6em;
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
}

.message-text h2.message-heading { font-size: 1.4em; }
.message-text h3.message-heading { font-size: 1.2em; }

/* Message Quote */
.message-quote {
    border-left: 3px solid var(--accent);
    padding: 8px 12px;
    margin: 4px 0;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    font-size: 0.95em;
}

.message-quote + .message-quote { margin-top: -4px; }

/* Thinking Block */
.message-thinking,
.message-details-block {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    margin-bottom: 12px;
    overflow: hidden;
}

.message-thinking summary,
.message-details-block summary {
    padding: 10px 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-muted);
    user-select: none;
    transition: color 0.2s;
}

.message-thinking summary:hover,
.message-details-block summary:hover { color: var(--text-primary); }
.message-thinking summary svg,
.message-details-block summary svg { width: 16px; height: 16px; }

.message-details-block summary span { flex: 1; }
.details-edit-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    padding: 3px;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: inherit;
    cursor: pointer;
}
.details-edit-btn:hover { color: var(--text-primary); background: rgba(255, 255, 255, 0.1); }
.message-details-block summary .details-edit-btn svg { width: 14px; height: 14px; }

.message-thinking .thinking-content,
.message-details-block .details-content {
    padding: 12px 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
}

details.message-thinking[open] summary,
details.message-details-block[open] summary { margin-bottom: 10px; }
details.message-thinking[open] .thinking-content,
details.message-details-block[open] .details-content { animation: fadeIn 0.3s ease; }
.details-edit-area { width: 100%; min-height: 140px; margin-bottom: 8px; }

/* Swipe Controls */
.swipe-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.swipe-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.15s;
}

.swipe-btn:hover:not(:disabled) {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.swipe-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.swipe-btn svg { width: 16px; height: 16px; }
.swipe-counter { font-size: 13px; color: var(--text-muted); min-width: 50px; text-align: center; }
.generating-text { color: var(--text-muted); font-style: italic; }

/* Edit Mode */
.message-edit-area {
    width: 100%;
    min-height: 400px;
    max-height: 800px;
    padding: 12px 14px;
    background: var(--bg-secondary);
    border: 2px solid var(--accent);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    resize: vertical;
    line-height: 1.6;
}

.message-edit-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.message-edit-actions button {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: 0.15s;
}

.edit-save-btn { background: var(--accent); border: none; color: white; }
.edit-save-btn:hover { background: var(--accent-hover); }

.edit-cancel-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.edit-cancel-btn:hover { background: var(--bg-secondary); }

/* =================== */
/* INPUT AREA */
/* =================== */
#input-area-wrap {
    max-width: 900px;
    width: 100%;
    margin: 0 auto 15px auto;
}

#input-area {
    padding: 15px 20px;
    margin: 0;
    max-width: 900px;
    width: 100%;
    background: rgba(18, 18, 26, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(19, 25, 31, 1);
    border-top: none;
    border-radius: 0 0 16px 16px;
    display: flex;
    gap: 10px;
    align-items: flex-end;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.chat-image-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    margin-bottom: 8px;
    border-radius: 12px 12px 0 0;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
}

.chat-image-preview img {
    width: 86px;
    height: 86px;
    border-radius: 10px;
    object-fit: cover;
    border: 1px solid var(--border);
}

#chat-image-clear {
    margin-left: auto;
}

.message-inline-image {
    margin-bottom: 8px;
}

.message-inline-image img {
    max-width: min(320px, 70vw);
    max-height: 320px;
    border-radius: 10px;
    border: 1px solid var(--border);
    object-fit: cover;
    cursor: zoom-in;
}

.chat-input-field {
    position: relative;
    flex: 1;
    min-width: 0;
}

#user-input {
    width: 100%;
    padding: 12px 16px;
    padding-right: 42px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 15px;
    line-height: 20px;
    font-family: inherit;
    resize: none;
    max-height: 400px;
    box-sizing: border-box;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

#user-input::-webkit-scrollbar {
    width: 0;
    display: none;
}

#user-input:focus { outline: none; border-color: var(--accent); }

/* ===================================================== */
/* CHARACTER EDITOR - IN-MODAL EXPAND OVERLAY            */
/* ===================================================== */
.char-expand-overlay {
    position: absolute;
    inset: 0;
    z-index: 300;
    background: rgba(10, 10, 15, 0.75);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    padding: 20px;
    animation: fadeIn 0.15s ease;
}

.char-expand-box {
    margin: auto;
    width: 100%;
    height: 100%;
    max-width: 720px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.char-expand-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.char-expand-header span {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.char-expand-header span svg {
    width: 16px;
    height: 16px;
    color: var(--accent);
}

.char-expand-box textarea {
    flex: 1;
    width: 100%;
    resize: none;
    padding: 16px 18px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    line-height: 1.6;
    outline: none;
}

.char-expand-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 12px 18px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

#send-btn, #stop-btn {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}

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

#stop-btn { background: var(--danger); }
#stop-btn:hover { background: #dc2626; }

#send-btn svg, #stop-btn svg { width: 20px; height: 20px; }

#chat-image-btn {
    position: absolute;
    right: 10px;
    bottom: 8px;
    background: transparent;
    border: none;
    box-shadow: none;
    width: 24px;
    height: 24px;
    min-width: 24px;
    padding: 0;
    border-radius: 0;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

#chat-image-btn:hover {
    background: transparent;
    color: var(--text-primary);
    transform: none;
}

#chat-image-btn svg {
    width: 18px;
    height: 18px;
}

/* =================== */
/* MACRO BAR */
/* =================== */
.macro-bar {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding: 10px 20px;
    display: flex;
    gap: 10px;
    align-items: center;
    overflow: hidden;
    height: 0;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.macro-bar.open {
    height: auto;
    min-height: 50px;
    max-height: 120px;
    padding-top: 10px;
    padding-bottom: 10px;
    opacity: 1;
    border-bottom: 1px solid var(--border);
    overflow: visible;
}

.macro-scroller,
#macro-list {
    display: flex !important;
    flex-wrap: nowrap !important;
    gap: 8px !important;
    flex: 1;
    max-height: 100px;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    padding: 6px 2px !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.macro-scroller::-webkit-scrollbar,
#macro-list::-webkit-scrollbar {
    display: none;
}

.macro-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-secondary);
    font-size: 13px;
    white-space: nowrap;
    cursor: pointer;
    transition: 0.15s;
    user-select: none;
    flex-shrink: 0 !important;
}


.macro-chip:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    transform: translateY(-1px);
}

.macro-chip svg { width: 14px; height: 14px; }

.macro-add-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    border: 1px dashed var(--text-muted);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

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

#macro-toggle-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

#macro-modal .modal-content {
    width: min(560px, calc(100vw - 20px));
    max-width: 560px;
    max-height: min(82vh, 720px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#macro-modal .modal-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 18px 18px 14px;
}

#macro-modal .modal-body label {
    margin: 0;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
}

#macro-modal .modal-body input,
#macro-modal .modal-body textarea {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    padding: 10px 12px;
}

#macro-label {
    min-height: 42px;
}

#macro-content {
    min-height: 120px;
    resize: vertical;
}

#macro-icon-picker {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(38px, 1fr));
    gap: 8px;
    padding: 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 12px;
    max-height: 180px;
    overflow-y: auto;
}

.macro-icon-option {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    margin: 0 auto;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.02);
    color: var(--text-secondary);
    cursor: pointer;
    transition: 0.15s ease;
}

.macro-icon-option:hover {
    border-color: var(--accent);
    color: var(--accent);
    transform: translateY(-1px);
}

.macro-icon-option.selected {
    background: rgba(110, 118, 255, 0.12);
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: inset 0 0 0 1px rgba(110, 118, 255, 0.2);
}

.macro-icon-option svg {
    width: 16px;
    height: 16px;
}

#macro-modal .modal-buttons {
    display: flex;
    gap: 10px;
    margin-top: 4px;
    align-items: center;
}

#macro-modal .modal-buttons button {
    flex: 1;
    min-width: 0;
}

#macro-modal #macro-delete-btn {
    margin-right: auto;
    flex: 0 0 auto;
}

@media (max-width: 640px) {
    #macro-modal .modal-content {
        width: min(100vw - 14px, 440px);
        max-height: min(88vh, 700px);
        border-radius: 14px;
    }

    #macro-modal .modal-body {
        padding: 14px 14px 12px;
        gap: 10px;
    }

    #macro-icon-picker {
        grid-template-columns: repeat(6, minmax(0, 1fr));
        gap: 6px;
        padding: 8px;
    }

    .macro-icon-option {
        width: 100%;
        max-width: 40px;
    }

    #macro-content {
        min-height: 150px;
    }

    #macro-modal .modal-buttons {
        flex-wrap: wrap;
    }

    #macro-modal .modal-buttons button {
        flex: 1 1 calc(50% - 5px);
    }
}

/* ===================================================== */
/* CHANGELOG MODAL                                       */
/* ===================================================== */
.modal-content.changelog-modal-content {
    max-width: 860px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 18px 45px rgba(0, 0, 0, 0.52);
    background: rgba(17, 20, 28, 0.72);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    overflow: hidden;
    transform: scale(1) translateY(0);
    opacity: 1;
}

.modal.open .modal-content.changelog-modal-content {
    transform: scale(1) translateY(0);
    opacity: 1;
}

.changelog-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    position: relative;
    padding: 22px 26px 16px;
    background: transparent;
    border-bottom: 1px solid var(--border);
}

.changelog-header .close-modal {
    position: absolute;
    top: 16px;
    right: 16px;
}

.changelog-badge-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.changelog-badge-latest {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    background: var(--accent);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
}

.changelog-date {
    font-size: 11px;
    color: var(--text-muted);
}

.changelog-body {
    padding: 20px 26px 18px;
    max-height: 55vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
    background: transparent;
}

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

.changelog-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.changelog-section-warning {
    background: color-mix(in srgb, var(--accent) 8%, transparent);
    border: 1px solid color-mix(in srgb, var(--accent) 26%, transparent);
    border-radius: 12px;
    padding: 10px 12px 12px;
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 12%, transparent);
}

.changelog-section-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-top: 6px;
}

.changelog-section-warning .changelog-section-title {
    color: var(--accent);
    text-shadow: 0 0 10px color-mix(in srgb, var(--accent) 25%, transparent);
}

.changelog-release-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px dashed var(--border);
}

.changelog-version-tag {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
}

.changelog-date-dim {
    font-size: 10px;
    color: var(--text-muted);
}

.changelog-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 0;
    padding: 0;
}

.changelog-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 13px;
    line-height: 1.55;
    color: var(--text-primary);
}

.changelog-tag {
    font-size: 9px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    flex-shrink: 0;
    margin-top: 3px;
    letter-spacing: 0.5px;
}

.tag-new {
    background: rgba(34, 197, 94, 0.2);
    color: var(--success, #22c55e);
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.tag-improved {
    background: rgba(124, 58, 237, 0.2);
    color: var(--accent);
    border: 1px solid rgba(124, 58, 237, 0.3);
}

.tag-fix {
    background: rgba(59, 130, 246, 0.2);
    color: #3b82f6;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.tag-note {
    background: color-mix(in srgb, var(--accent) 18%, transparent);
    color: var(--accent);
    border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
}

.changelog-text {
    color: var(--text-primary);
    font-size: 13px;
    line-height: 1.55;
}

.changelog-text strong {
    color: var(--text-primary);
    font-weight: 600;
}

/* =================== */
/* LANDING PAGE */
/* =================== */
#landing-page {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 15, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 50;
    padding: 80px 20px 20px;
    overflow-y: auto;
    display: none;
    justify-content: center;
    align-items: flex-start;
}

#landing-page.active { display: flex; }

/* =================== */
/* CHARACTER GRID */
/* =================== */
#character-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

.character-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    cursor: pointer;
    opacity: 0;
    animation: cardPop 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
    animation-delay: calc(var(--i) * 0.05s);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.character-card:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 15px 30px -10px rgba(124, 58, 237, 0.3);
    border-color: var(--accent);
}

.character-avatar {
    width: 100%;
    aspect-ratio: 1;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.character-avatar img { width: 100%; height: 100%; object-fit: cover; }
.character-avatar svg { width: 64px; height: 64px; color: var(--text-muted); }

.character-info { padding: 15px; }
.character-info h3 { font-weight: 600; font-size: 16px; margin-bottom: 5px; }

.character-actions { padding: 0 15px 15px; }

.character-actions button,
.char-edit-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: 0.15s;
}

.character-actions button:hover,
.char-edit-btn:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* FAB */
.fab {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--accent);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(124, 58, 237, 0.4);
    transition: 0.2s;
    z-index: 60;
}

.fab:hover { background: var(--accent-hover); transform: scale(1.05); }
.fab svg { width: 28px; height: 28px; }

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state svg { width: 64px; height: 64px; margin-bottom: 20px; opacity: 0.5; }
.empty-state h3 { font-size: 18px; margin-bottom: 10px; color: var(--text-secondary); }

/* Load More Button */
#load-more-container {
    text-align: center;
    padding: 15px;
    margin-bottom: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

#load-more-btn,
#load-all-btn {
    padding: 10px 18px;
    gap: 8px;
    display: inline-flex;
    align-items: center;
}

/* =================== */
/* MODALS */
/* =================== */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s, backdrop-filter 0.2s;
    backdrop-filter: blur(0px);
}

.modal.open {
    display: flex;
    opacity: 1;
    visibility: visible;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 16px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.95) translateY(10px);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s;
}

.modal.open .modal-content {
    transform: scale(1) translateY(0);
    opacity: 1;
}

.modal-large { max-width: 650px; }

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

.modal-header h3 {
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.close-modal {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 5px;
    display: flex;
    transition: 0.15s;
}

.close-modal:hover { color: var(--text-primary); }
.close-modal svg { width: 24px; height: 24px; }

.modal-body { padding: 20px; }

.modal-body label {
    display: block;
    margin: 15px 0 5px;
    font-size: 13px;
    color: var(--text-secondary);
}

.modal-body label:first-child { margin-top: 0; }

.modal-body input,
.modal-body textarea {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
}

.modal-body textarea { resize: vertical; }

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

.modal-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.modal-buttons button {
    flex: 1;
    padding: 12px;
    border-radius: 8px;
    border: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.modal-buttons button svg { width: 16px; height: 16px; }

/* Modal Tabs */
.modal-tabs {
    display: flex;
    gap: 5px;
    background: transparent;
    margin: -20px -20px 20px -20px;
    padding: 15px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-tab {
    flex: 1;
    padding: 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: 0.15s;
    border-bottom: none;
}

.modal-tab:hover { 
    color: var(--text-primary); 
    background: rgba(255, 255, 255, 0.05);
}

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

.char-tab-content {
    display: none;
    animation: fadeIn 0.2s ease;
}

.char-tab-content.active { display: block; }

/* Fixed Modal Layout */
.char-visual-box {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 15px;
}

.char-visual-box h4 {
    margin: 0 0 12px 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}
.modal-xl {
    max-width: 950px;
    height: 92vh;
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-fixed-header {
    flex-shrink: 0;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    z-index: 10;
}

.modal-header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px 0 25px;
}

.fixed-tabs {
    margin: 15px 25px 0 25px !important;
    border-bottom: none !important;
}

.modal-fixed-footer {
    flex-shrink: 0;
    padding: 20px 25px;
    margin-top: 15px;
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    z-index: 10;
}

.modal-fixed-footer .btn-danger {
    margin-right: auto;
}

.modal-fixed-footer button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.modal-fixed-footer button svg {
    width: 14px;
    height: 14px;
}

.modal-fixed-footer .btn-danger {
    margin-right: auto;
    padding: 10px 16px;
}

.modal-fixed-footer .btn-secondary,
.modal-fixed-footer .btn-primary {
    padding: 10px 16px;
}

.modal-scroll-body {
    flex: 1;
    overflow-y: auto;
    padding: 25px;
    background: var(--bg-secondary);
}

.modal-scroll-body input[type="text"],
.modal-scroll-body input[type="number"],
.modal-scroll-body textarea {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.2s;
}

.modal-scroll-body input:focus,
.modal-scroll-body textarea:focus {
    outline: none;
    border-color: var(--accent);
    background: rgba(124, 58, 237, 0.05);
}

.modal-scroll-body label {
    display: block;
    margin: 15px 0 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

/* Status Messages */
.status-msg {
    margin-top: 15px;
    padding: 10px;
    border-radius: 8px;
    font-size: 13px;
    text-align: center;
    display: none;
}

.status-msg.success { display: block; background: rgba(34, 197, 94, 0.2); color: var(--success); }
.status-msg.error { display: block; background: rgba(239, 68, 68, 0.2); color: var(--danger); }

/* Character Form */
.char-form-grid {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
}

.char-avatar-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

#char-avatar-preview {
    width: 120px;
    height: 120px;
    border-radius: 16px;
    background: var(--bg-tertiary);
    border: 2px dashed var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    overflow: hidden;
    color: var(--text-muted);
}

#char-avatar-preview img { width: 100%; height: 100%; object-fit: cover; }

.char-main-fields { flex: 1; }

/* =================== */
/* CHARACTER VISUALS - UNIFIED */
/* =================== */

.char-visuals-top-row {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
}

.char-visuals-avatar-col {
    width: 180px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#char-avatar-preview {
    width: 100%;
    height: 180px;
    border-radius: 12px;
    background: var(--bg-secondary);
    border: 2px dashed var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 64px;
    overflow: hidden;
    color: var(--text-muted);
}

#char-avatar-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Unified Visual Box */
.char-visual-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 15px;
}

.char-visual-box:last-child {
    margin-bottom: 0;
}

.visual-box-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.visual-box-header h4 {
    margin: 0;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}

.visual-box-actions {
    display: flex;
    gap: 6px;
}

.visual-box-actions .btn-sm {
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.visual-box-actions .btn-sm svg {
    width: 14px;
    height: 14px;
}

/* Unified Preview Area */
.visual-preview {
    width: 100%;
    height: 100px;
    background: var(--bg-tertiary);
    border: 1px dashed var(--border);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.visual-preview span {
    color: var(--text-muted);
    font-size: 13px;
}

.visual-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Banner Settings Row */
.banner-settings {
    display: flex;
    gap: 20px;
    margin-top: 12px;
}

.banner-setting {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}

.banner-setting input[type="number"] {
    width: 70px;
    padding: 6px 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 12px;
}

.banner-setting input[type="range"] {
    width: 100px;
}

/* Gallery List */
.gallery-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    min-height: 60px;
}

.gallery-empty {
    width: 100%;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    padding: 20px;
}

/* =================== */
/* CHARACTER BANNER/GALLERY */
/* =================== */
.char-banner-section {
    margin: 20px 0;
    padding: 15px;
    background: var(--bg-tertiary);
    border-radius: 12px;
    border: 1px solid var(--border);
}

.banner-preview-row {
    display: flex;
    gap: 15px;
    align-items: flex-start;
    margin-bottom: 10px;
}

.banner-preview {
    width: 200px;
    height: 80px;
    border-radius: 8px;
    background: var(--bg-secondary);
    border: 1px dashed var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.banner-preview span { color: var(--text-muted); font-size: 12px; }
.banner-preview img { width: 100%; height: 100%; object-fit: cover; }

.banner-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.banner-settings { display: flex; gap: 20px; }

.banner-setting {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}

.banner-setting input[type="number"] {
    width: 60px;
    padding: 4px 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 12px;
}

.banner-setting input[type="range"] { width: 100px; }

.char-gallery-section {
    margin: 20px 0;
    padding: 15px;
    background: var(--bg-tertiary);
    border-radius: 12px;
    border: 1px solid var(--border);
}

.gallery-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 10px;
}

.gallery-empty { color: var(--text-muted); font-size: 13px; padding: 10px; }

.gallery-item {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: pointer;
}

.gallery-item img:hover { opacity: 0.8; }

.gallery-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s;
}

.gallery-item:hover .gallery-remove { opacity: 1; }
.gallery-remove svg { width: 12px; height: 12px; }

.gallery-add-row { margin-top: 10px; }

/* =================== */
/* FLOATING PANELS */
/* =================== */
.floating-panel {
    position: fixed;
    top: 80px;
    right: 20px;
    width: 320px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: none;
    z-index: 150;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.floating-panel.open { display: flex; }

.floating-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
    cursor: move;
    user-select: none;
}

.floating-panel-header span {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 14px;
}

.floating-panel-header svg { width: 16px; height: 16px; }

.panel-close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.panel-close-btn:hover { color: var(--text-primary); }

/* Notepad */
#notepad-panel {
    height: 300px;
    resize: both;
    min-width: 250px;
    min-height: 200px;
}

#notepad-content {
    flex: 1;
    width: 100%;
    padding: 12px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    line-height: 1.6;
    resize: none;
}

#notepad-content:focus { outline: none; }

/* ===================================================== */
/* THEME PANEL - Docked Right Side Panel (Full)          */
/* ===================================================== */
.theme-panel {
    position: fixed;
    top: 80px;
    right: 20px;
    bottom: 20px;
    width: 340px;
    min-width: 300px;
    max-width: 600px;
    background: rgba(18, 18, 26, 0.7);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    z-index: 1000;
    display: none;
    flex-direction: column;
    overflow: hidden;
    resize: none;
}

.theme-panel.open { display: flex; }

/* Left edge resize handle */
.theme-panel .panel-resize-handle {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 6px;
    cursor: col-resize;
    z-index: 20;
    transition: background 0.15s;
}

.theme-panel .panel-resize-handle:hover,
.theme-panel.resizing .panel-resize-handle { background: var(--accent); }

/* ===================================================== */
/* THEME PANEL - HEADER, TABS & CONTENT                   */
/* ===================================================== */

#theme-panel,
.theme-panel {
    background: rgba(18, 18, 26, 0.75);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

#theme-panel .floating-panel-header,
.theme-panel .floating-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 34px 26px 14px;
    background: transparent;
    border-bottom: none;
    border-radius: 0;
    flex-shrink: 0;
    cursor: default;
}

#theme-panel .floating-panel-header span,
.theme-panel .floating-panel-header span {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 10px;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
}

#theme-panel .floating-panel-header svg,
.theme-panel .floating-panel-header svg {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
}

#theme-panel .panel-close-btn,
.theme-panel .panel-close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: 0.15s ease;
}

#theme-panel .panel-close-btn:hover,
.theme-panel .panel-close-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.theme-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.theme-tabs {
    display: flex;
    gap: 6px;
    width: calc(100% - 52px);
    margin: 0 auto;
    padding: 0;
    border-bottom: 1px solid var(--border);
    background: transparent;
    flex-shrink: 0;
}

.theme-tab {
    flex: 1;
    padding: 20px 8px 10px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    cursor: pointer;
    transition: color 0.15s ease, border-color 0.15s ease;
}

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

.theme-tab.active {
    color: var(--text-primary);
    border-bottom-color: var(--accent);
    background: transparent;
    box-shadow: none;
}

.theme-tab-content {
    display: none;
    flex: 1;
    overflow-y: auto;
    padding: 22px 26px 18px;
}

.theme-tab-content.active {
    display: block;
}

/* Sections (glassy cards) */
.theme-section {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 12px;
}

.theme-section:last-child { margin-bottom: 0; }

.theme-section label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.theme-value {
    font-variant-numeric: tabular-nums;
    color: var(--accent);
}

.theme-section input[type="text"],
.theme-section select {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 13px;
}

/* Color grid */
.theme-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 4px;
}

.theme-color-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.theme-color-item label {
    font-size: 11px;
    color: var(--text-muted);
    display: block;
    margin-bottom: 0;
}

.theme-color-item input[type="color"] {
    width: 100%;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    background: var(--bg-tertiary);
    padding: 2px;
}

/* Range sliders */
.theme-section input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    outline: none;
    cursor: pointer;
    margin-top: 4px;
}

.theme-section input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-glow);
    transition: transform 0.15s, box-shadow 0.15s;
}

.theme-section input[type="range"]:hover::-webkit-slider-thumb {
    transform: scale(1.15);
    box-shadow: 0 0 0 6px var(--accent-glow);
}

.theme-section input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    border: none;
    box-shadow: 0 0 0 4px var(--accent-glow);
}

/* Presets */
.theme-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.preset-btn {
    padding: 8px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: 0.15s;
}

.preset-btn:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    transform: translateY(-1px);
}

/* User avatar row */
.theme-user-avatar-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.theme-avatar-preview {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    background: var(--bg-tertiary);
    border: 2px dashed var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.theme-avatar-preview img { width: 100%; height: 100%; object-fit: cover; }
.theme-avatar-preview svg { width: 24px; height: 24px; color: var(--text-muted); }

.theme-avatar-btns {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Footer */
.theme-footer {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.theme-footer button {
    flex: 1;
    padding: 8px 12px !important;
    font-size: 12px !important;
    border-radius: 8px !important;
    height: 36px;
}

.theme-footer button svg {
    width: 14px !important;
    height: 14px !important;
}

#theme-save.saved { 
    background: var(--success) !important; 
}

/* =================== */
/* IMAGE PREVIEW */
/* =================== */
#image-preview-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
}

#image-preview-overlay.open { display: flex; }

#image-preview-img {
    max-width: 90%;
    max-height: 90%;
    border-radius: 12px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.8);
}

#image-preview-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

#image-preview-close:hover { background: rgba(255, 255, 255, 0.2); }

/* =================== */
/* DEBUG PANEL */
/* =================== */
.debug-section {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
}

.debug-section h4 {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.debug-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    padding: 4px 0;
}

.debug-row span:first-child { color: var(--text-muted); }
.debug-row span:last-child { color: var(--text-primary); }

.debug-details {
    margin-top: 15px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.debug-details summary {
    padding: 12px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
}

.debug-details summary:hover { color: var(--text-primary); }
.debug-details[open] summary { color: var(--accent); }

.debug-payload-content {
    padding: 15px;
    max-height: 60vh;
    overflow-y: auto;
}

.payload-model,
.payload-thinking {
    padding: 10px 12px;
    background: var(--bg-secondary);
    border-radius: 6px;
    margin-bottom: 10px;
    font-size: 13px;
    color: var(--text-secondary);
}

.payload-thinking {
    background: rgba(124, 58, 237, 0.1);
    color: var(--accent);
}

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

.payload-message {
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.payload-role {
    padding: 8px 12px;
    font-size: 11px;
    font-weight: 600;
}

.payload-message.system .payload-role { background: rgba(124, 58, 237, 0.2); color: var(--accent); }
.payload-message.user .payload-role { background: rgba(34, 197, 94, 0.2); color: var(--success); }
.payload-message.assistant .payload-role { background: rgba(59, 130, 246, 0.2); color: #3b82f6; }

.payload-content {
    padding: 12px;
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-secondary);
    background: var(--bg-primary);
}

.payload-content p { margin-bottom: 10px; }
.payload-content p:last-child { margin-bottom: 0; }

/* =================== */
/* STORY DIRECTOR */
/* =================== */
.director-section {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 15px;
}

.director-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.director-section-header h4 {
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
}

.director-section-header h4 svg { width: 16px; height: 16px; }

.director-add-btn {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: var(--accent);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.15s;
}

.director-add-btn:hover { background: var(--accent-hover); }
.director-add-btn svg { width: 14px; height: 14px; }

.director-empty {
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
    padding: 10px;
}

.director-warning {
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
    padding: 15px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    margin-bottom: 15px;
}

.director-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
}

.director-card.active {
    border-color: var(--success);
    background: rgba(34, 197, 94, 0.05);
}

.director-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.director-card-header input[type="text"] {
    flex: 1;
    padding: 8px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 13px;
}

.director-card-header input[type="radio"] {
    width: 16px;
    height: 16px;
    accent-color: var(--success);
}

.director-card-header select {
    padding: 8px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 13px;
}

.director-card textarea {
    width: 100%;
    padding: 8px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 13px;
    resize: vertical;
    min-height: 60px;
    font-family: inherit;
}

.director-delete-btn {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.15s;
    flex-shrink: 0;
}

.director-delete-btn:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: white;
}

.director-delete-btn svg { width: 14px; height: 14px; }

.arc-active-badge {
    font-size: 10px;
    background: var(--success);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
}

.director-pacing {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.pacing-icon { font-size: 18px; }

.director-pacing input[type="range"] {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    background: var(--bg-secondary);
    border-radius: 3px;
    outline: none;
}

.director-pacing input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
}

.pacing-label {
    font-size: 13px;
    color: var(--text-secondary);
    min-width: 80px;
    text-align: right;
}

.director-focus {
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.focus-label {
    display: block;
    margin-bottom: 8px;
    font-size: 12px;
    color: var(--text-muted);
}

.focus-options {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: baseline;
}

.focus-option {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 0;
    transition: 0.15s;
}

.focus-option:hover { color: var(--text-primary); }

.focus-option input {
    width: 14px;
    height: 14px;
    accent-color: var(--accent);
}

.focus-option input:checked + span { color: var(--accent); }

.director-textarea {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
    resize: vertical;
    min-height: 80px;
}

.director-textarea:focus { outline: none; border-color: var(--accent); }

.director-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 15px;
    border-top: 1px solid var(--border);
}

.director-tokens { font-size: 12px; color: var(--text-muted); }

.director-save-indicator {
    position: fixed;
    top: 70px;
    right: 340px;
    background: var(--success);
    color: white;
    padding: 8px 15px;
    border-radius: 6px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
    opacity: 0;
    transform: translateY(-10px);
    transition: 0.2s;
    z-index: 100;
}

.director-save-indicator.show { opacity: 1; transform: translateY(0); }
.director-save-indicator svg { width: 14px; height: 14px; }

.director-preview-content {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 15px;
    max-height: 50vh;
    overflow-y: auto;
}

.director-preview-content pre {
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: inherit;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-secondary);
    margin: 0;
}

.director-preview-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-muted);
}

/* =================== */
/* MODEL PICKER */
/* =================== */
.model-input-row {
    display: flex;
    gap: 8px;
}

.model-input-row input { flex: 1; }

.model-fetch-btn {
    width: 42px !important;
    flex-shrink: 0;
    padding: 0 !important;
    display: flex;
    align-items: center;
    justify-content: center;
}

.model-fetch-btn svg { width: 18px; height: 18px; }

.model-search-input {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
}

.model-search-input:focus { outline: none; border-color: var(--accent); }

.model-list { max-height: 400px; overflow-y: auto; }

.model-item {
    padding: 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: 0.15s;
}

.model-item:hover {
    border-color: var(--accent);
    background: rgba(124, 58, 237, 0.1);
}

.model-item-id {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    word-break: break-all;
}

.model-item-context {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

.model-loading,
.model-error,
.model-empty {
    text-align: center;
    padding: 30px;
    color: var(--text-muted);
}

.model-error { color: var(--danger); }

/* Thinking Toggle */
.thinking-toggle {
    margin-top: 15px;
    padding: 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
}

.toggle-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}

.thinking-hint {
    margin-top: 8px;
    font-size: 11px;
    color: var(--text-muted);
}

/* =====================
   SETTINGS PANEL V2
   ===================== */

/* Panel Container - Floating Effect */
#settings-panel {
    display: flex;
    flex-direction: column;
    height: calc(100% - 40px);
    margin: 20px;
    margin-right: 0;
    background: rgba(18, 18, 26, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

/* Panel Header */
#settings-panel .panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

#settings-panel .panel-header h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    margin: 0;
}

#settings-panel .panel-header h3 svg {
    width: 16px;
    height: 16px;
    color: var(--accent);
}

#settings-panel .panel-close {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.15s;
}

#settings-panel .panel-close:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

#settings-panel .panel-close svg {
    width: 16px;
    height: 16px;
}

/* Panel Body */
#settings-panel .panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

/* Collapsible Sections */
.settings-section {
    margin-bottom: 6px;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.15);
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    cursor: pointer;
    transition: 0.15s;
    user-select: none;
}

.section-header:hover {
    background: rgba(255, 255, 255, 0.03);
}

.section-header h4 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0;
}

.section-header h4 svg {
    width: 14px;
    height: 14px;
}

.section-header .chevron {
    width: 14px;
    height: 14px;
    color: var(--text-muted);
    transition: transform 0.2s;
}

/* Open State */
.settings-section.open .section-header .chevron {
    transform: rotate(180deg);
}

.settings-section.open .section-header h4 {
    color: var(--accent);
}

.section-body {
    display: none;
    padding: 12px;
    padding-top: 0;
    border-top: 1px solid var(--border);
}

.settings-section.open .section-body {
    display: block;
    padding-top: 12px;
}

.extra-api-summary {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    list-style-position: outside;
}

/* Form Elements */
.form-group {
    margin-bottom: 12px;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    font-size: 10px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 8px 10px;
    font-size: 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    transition: 0.15s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent);
}

.form-row {
    display: flex;
    gap: 8px;
}

.form-row .form-group {
    flex: 1;
}

/* Slider Group */
.slider-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.slider-group input[type="range"] {
    flex: 1;
    height: 3px;
    -webkit-appearance: none;
    background: var(--bg-tertiary);
    border-radius: 2px;
    border: none;
    padding: 0;
}

.slider-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    transition: 0.15s;
}

.slider-group input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.slider-value {
    min-width: 32px;
    font-size: 11px;
    color: var(--accent);
    font-weight: 600;
    text-align: right;
}

/* Toggle Row */
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
}

.toggle-row + .toggle-row {
    border-top: 1px solid var(--border);
}

.toggle-label {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    width: 36px;
    height: 20px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--bg-tertiary);
    border-radius: 10px;
    transition: 0.2s;
}

.toggle-slider::before {
    content: "";
    position: absolute;
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: 0.2s;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--color-custom, var(--accent));
    box-shadow: 0 0 10px var(--accent-glow);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(16px);
    background: white;
}

/* Prompt List */
.prompt-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.prompt-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: 0.15s;
}

.prompt-item:hover {
    border-color: rgba(255, 255, 255, 0.15);
}

.prompt-item.active {
    border-color: var(--accent);
    background: rgba(124, 58, 237, 0.08);
}

.prompt-item.active .prompt-indicator {
    background: var(--accent);
    box-shadow: 0 0 8px rgba(124, 58, 237, 0.5);
}

.prompt-indicator {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
    transition: 0.15s;
}

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

.prompt-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.prompt-tokens {
    font-size: 10px;
    color: var(--text-muted);
}

.prompt-item.active .prompt-tokens {
    color: var(--accent);
}

.prompt-actions {
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: 0.15s;
}

.prompt-item:hover .prompt-actions {
    opacity: 1;
}

.prompt-action-btn {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.15s;
}

.prompt-action-btn:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.prompt-action-btn svg {
    width: 12px;
    height: 12px;
}

/* Add Button */
.add-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 8px;
    margin-top: 8px;
    background: transparent;
    border: 1px dashed var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 11px;
    cursor: pointer;
    transition: 0.15s;
}

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

.add-btn svg {
    width: 12px;
    height: 12px;
}

/* Profile Selector - Cleaner */
.profile-selector {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
    padding: 0;
    border-bottom: none;
}

.profile-selector select {
    flex: 1;
    padding: 10px 12px;
    font-size: 12px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    cursor: pointer;
}

.profile-selector select:focus {
    outline: none;
    border-color: var(--accent);
}

.profile-btn {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.15s;
}

.profile-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(124, 58, 237, 0.1);
}

.profile-btn svg {
    width: 14px;
    height: 14px;
}

/* Panel Footer - FIXED */
#settings-panel .panel-footer {
    padding: 12px;
    border-top: none;
    background: transparent;
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

#settings-panel .panel-footer .btn {
    flex: 1;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    transition: 0.15s;
    border: none;
}

#settings-panel .panel-footer .btn svg {
    width: 14px;
    height: 14px;
}

#settings-panel .panel-footer .btn-primary {
    background: var(--accent);
    color: white;
}

#settings-panel .panel-footer .btn-primary:hover {
    background: var(--accent-hover, #6d28d9);
}

#settings-panel .panel-footer .btn-secondary {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

#settings-panel .panel-footer .btn-secondary:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

/* Left Panel - Transparent für floating Settings */
#left-panel {
    background: transparent !important;
    border-right: none !important;
}

.footer-status {
    flex: 1;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0 10px;
    text-align: right;
}

.settings-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 15px;
}

.settings-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 20px;
    margin-bottom: 20px;
}

.settings-grid-3 label, 
.settings-grid-2 label {
    margin-top: 0;
    margin-bottom: 5px;
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.toggle-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: 0.2s;
    font-size: 13px;
    color: var(--text-secondary);
}

.toggle-card:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--accent);
    color: var(--text-primary);
}

.toggle-card input {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--accent);
    cursor: pointer;
}

.compact-close-btn {
    width: 32px;
    height: 32px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.15s;
}

.compact-close-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

/* Profile Card */
.profile-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 20px;
}

.profile-row {
    display: flex;
    gap: 8px;
}

.profile-row select {
    flex: 1;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    height: 36px;
    border-radius: 6px;
    padding: 0 10px;
    color: var(--text-primary);
}

.profile-row .btn-sm {
    padding: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
}

#api-profile-select {
    background-color: rgba(0, 0, 0, 0.3);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 10px 12px;
    border-radius: 8px;
    outline: none;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23a0a0b0%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 10px;
    padding-right: 32px;
}

#api-profile-select:focus { 
    border-color: var(--accent); 
}

#api-profile-select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* Textarea with Expand */
.textarea-with-expand {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 20px;
}

.textarea-with-expand label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin: 0;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.textarea-with-expand .expand-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    height: 24px;
    width: 24px;
}

.textarea-with-expand .expand-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.2);
}

.textarea-with-expand .expand-btn svg {
    width: 14px;
    height: 14px;
}

.textarea-with-expand textarea {
    width: 100%;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px;
    font-size: 0.9rem;
    line-height: 1.5;
    resize: vertical;
    transition: border-color 0.2s;
}

.textarea-with-expand textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 1px rgba(124, 58, 237, 0.2);
}

/* List Card */
.list-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 8px;
    overflow: hidden;
    transition: border-color 0.2s;
}

.list-card:hover { border-color: rgba(255, 255, 255, 0.15); }

.list-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    cursor: pointer;
    min-height: 48px;
}

.list-card-header input[type="text"] {
    background: transparent !important;
    border: none !important;
    color: var(--text-primary) !important;
    font-weight: 600;
    font-size: 14px;
    padding: 0 5px !important;
    width: 100%;
}

.list-card-header input[type="text"]:focus {
    background: rgba(255, 255, 255, 0.05) !important;
    outline: none;
}

/* Clean Close Button */
.clean-close-btn {
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.15s;
}

.clean-close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

#top-bar {
}

#chat-header {
    background: var(--bar-color, rgba(10, 10, 12, 0.85));
    backdrop-filter: blur(var(--bar-blur, 10px));
    -webkit-backdrop-filter: blur(var(--bar-blur, 10px));
}

#settings-panel .panel-footer .footer-status {
    flex: 1;
    font-size: 12px;
    color: var(--success);
    text-align: center;
    min-width: 0;
}

/* =================== */
/* ANIMATIONS */
/* =================== */
@keyframes messageFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes cardPop {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

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

@keyframes waveJump {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

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

/* Typing Wave */
.typing-wave { display: inline-block; }

.typing-wave span {
    display: inline-block;
    animation: waveJump 1.4s infinite ease-in-out both;
    font-weight: bold;
    font-size: 20px;
    color: var(--accent);
    margin: 0 1px;
}

.typing-wave span:nth-child(1) { animation-delay: -0.32s; }
.typing-wave span:nth-child(2) { animation-delay: -0.16s; }
.typing-wave span:nth-child(3) { animation-delay: 0s; }

/* TTS Loading Spinner */
.spinning { animation: spin 1s linear infinite; }

/* Custom Prompt Name - Sichtbares Textfeld */
.custom-prompt-item input[type="text"],
.list-card-header input[type="text"] {
    background: var(--bg-tertiary) !important;
    border: 1px solid var(--border) !important;
    border-radius: 6px;
    padding: 8px 10px !important;
    color: var(--text-primary) !important;
    font-weight: 500;
    font-size: 13px;
    transition: 0.2s;
}

.custom-prompt-item input[type="text"]:focus,
.list-card-header input[type="text"]:focus {
    border-color: var(--accent) !important;
    background: var(--bg-secondary) !important;
}

/* Grayed out wenn Checkbox nicht aktiv */
.custom-prompt-item:has(input[type="checkbox"]:not(:checked)) input[type="text"],
.list-card:has(input[type="checkbox"]:not(:checked)) .list-card-header input[type="text"] {
    opacity: 0.5;
    color: var(--text-muted) !important;
}

.custom-prompt-item:has(input[type="checkbox"]:not(:checked)),
.list-card:has(input[type="checkbox"]:not(:checked)) {
    opacity: 0.6;
}

/* Settings Footer Buttons - Kleinere Icons */
.settings-fixed-footer button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.settings-fixed-footer button svg {
    width: 14px;
    height: 14px;
}

/* Avatar Shape Variable - Nur Chat Messages */
.message-avatar {
    border-radius: var(--avatar-radius, 50%);
    aspect-ratio: var(--avatar-ratio, 1);
    width: var(--avatar-size, 40px);
    height: auto;
}

/* Theme Preview */
.theme-avatar-preview {
    border-radius: var(--avatar-radius, 50%);
}

/* Fixed Shapes - Landing Page & Chat Header */
#chat-char-avatar {
    border-radius: 8px;
}

.character-avatar {
    border-radius: 12px;
}

#char-avatar-preview {
    border-radius: 12px;
}

.banner-setting select {
    padding: 6px 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 12px;
}

/* Expand Button - Global */
.expand-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    height: 24px;
    width: 24px;
}

.expand-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.2);
}

.expand-btn svg {
    width: 14px;
    height: 14px;
}

/* Avatar Preview Boxen im Character Editor */
#char-avatar-preview,
#char-user-avatar-preview {
    width: 100%;
    height: 120px;
    overflow: hidden;
    border-radius: 8px;
    background: var(--bg-tertiary);
    border: 1px dashed var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
}

#char-avatar-preview img,
#char-user-avatar-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.message-wrapper.has-banner {
    position: relative;
    border: none;
}

.message-wrapper.has-banner::before {
    content: "";
    position: absolute;
    inset: 0;
    border: 1px solid rgba(19, 25, 31, 1);
    border-bottom: none;
    border-radius: 10px 10px 0 0;
    pointer-events: none;
    z-index: 100;
    -webkit-mask-image: linear-gradient(to bottom, black 50%, transparent 100%);
    mask-image: linear-gradient(to bottom, black 50%, transparent 100%);
}

/* =================== */
/* TOKEN COUNTER */
/* =================== */
.token-count {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 400;
    margin-left: 8px;
    opacity: 0.7;
}

.token-count:hover {
    opacity: 1;
}

.textarea-with-expand label .token-count {
    margin-left: auto;
    margin-right: 8px;
}

/* Right Panel - Floating Effect */
#right-panel {
    background: transparent !important;
    border-left: none !important;
}

#right-panel .panel-content {
    height: calc(100% - 40px);
    margin: 20px;
    margin-left: 0;
    background: rgba(18, 18, 26, 0.7);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    padding: 20px;
    overflow-y: auto;
}

#right-panel .panel-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

#right-panel .panel-header h3 {
    font-size: 14px;
}

/* Character Items - Kompakter */
.right-panel-item {
    margin: 6px 12px;
    padding: 10px 12px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.2);
}

.right-panel-avatar {
    width: 40px;
    height: 40px;
    border-radius: 8px;
}

/* Director Panel - Match Right Panel Style */
#context-panel .director-section {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 15px;
    margin: 6px 12px 10px 12px;
}

#context-panel .director-section-header {
    margin-bottom: 12px;
}

#context-panel .director-section-header h4 {
    font-size: 13px;
    color: var(--text-secondary);
}

#context-panel .director-card {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

#context-panel .director-textarea {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

#context-panel .director-footer {
    margin: 0 12px;
    padding: 12px 0;
}

/* ===================================================== */
/* DESKTOP CAT LAUNCHER & PANEL ALIGNMENT                */
/* ===================================================== */
@media (min-width: 769px) {
    /* 1. Cat & Home Buttons etwas weiter nach unten & rechts */
    #top-bar {
        position: fixed;
        top: 24px;                  /* vorher 15px */
        left: 28px;                 /* vorher 20px */
        right: auto !important;
        bottom: auto !important;
        width: auto !important;
        height: auto !important;
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        padding: 0 !important;
        background: transparent !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        border: none !important;
        box-shadow: none !important;
        z-index: 500;
        pointer-events: none;
        gap: 8px;
        contain: layout;
    }

    body.on-dashboard #top-bar {
        display: none !important;
    }

    #top-left {
        display: flex;
        gap: 8px;
        pointer-events: auto;
    }

    #page-title {
        display: none !important;
    }

    /* Feste Glass-Kacheln für Trigger & Home – 100% identischer Look */
    #cat-nav-btn,
    #top-left #home-btn {
        width: 44px;
        height: 44px;
        border-radius: 12px;
        background: rgba(18, 18, 26, 0.3) !important;
        backdrop-filter: blur(15px);
        -webkit-backdrop-filter: blur(15px);
        border: 1px solid rgba(255, 255, 255, 0.1) !important;
        color: var(--text-secondary) !important;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
        transform: translateY(0);
        transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    }

    /* Katze im Ruhezustand neutral wie alle anderen Icons */
    #cat-nav-btn svg {
        width: 20px;
        height: 20px;
        stroke-width: 1.6px;
        color: var(--text-secondary) !important;
        transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), color 0.15s ease;
    }

    #top-left #home-btn svg {
        width: 18px;
        height: 18px;
        stroke-width: 1.6px;
        color: var(--text-secondary) !important;
    }

    /* Hover & Active State – absolut synchron */
    #cat-nav-btn:hover,
    #top-bar.open #cat-nav-btn,
    #top-left #home-btn:hover {
        background: var(--accent) !important;
        color: white !important;
        border-color: var(--accent) !important;
        box-shadow: 0 0 14px var(--accent-glow, rgba(124, 58, 237, 0.4)) !important;
        transform: translateY(-1px);
    }

    #cat-nav-btn:hover svg,
    #top-bar.open #cat-nav-btn svg {
        color: white !important;
    }

    #top-bar.open #cat-nav-btn svg {
        transform: rotate(15deg);
    }

    #top-left #home-btn:hover {
        background: var(--accent) !important;
        color: white !important;
        border-color: var(--accent) !important;
        transform: translateY(-1px);
    }

    /* 2. Kacheldeck / Akkordeon Auffächerung nach unten */
    #top-right {
        display: flex;
        flex-direction: column;
        gap: 6px;
        pointer-events: none;
        align-items: flex-start;
        margin-top: 2px;
    }

    /* Einzelne Kacheln starten übereinander geschoben */
    #top-right .icon-btn,
    #top-right .nav-dropdown-wrap {
        opacity: 0;
        transform: translateY(-20px) scale(0.85);
        pointer-events: none;
        transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1),
                    opacity 0.2s ease;
    }

    /* Wenn offen: Fächern sie kaskadierend wie ein Kartendeck auseinander */
    #top-bar.open #top-right {
        pointer-events: auto;
    }

    #top-bar.open #top-right > *:nth-child(1) { transition-delay: 0.02s; }
    #top-bar.open #top-right > *:nth-child(2) { transition-delay: 0.05s; }
    #top-bar.open #top-right > *:nth-child(3) { transition-delay: 0.08s; }
    #top-bar.open #top-right > *:nth-child(4) { transition-delay: 0.11s; }
    #top-bar.open #top-right > *:nth-child(5) { transition-delay: 0.14s; }
    #top-bar.open #top-right > *:nth-child(6) { transition-delay: 0.17s; }
    #top-bar.open #top-right > *:nth-child(7) { transition-delay: 0.20s; }

    #top-bar.open #top-right .icon-btn,
    #top-bar.open #top-right .nav-dropdown-wrap {
        opacity: 1;
        transform: translateY(0) scale(1);
        pointer-events: auto;
    }

    /* Fester Glas-Hintergrund bereits von Frame 1 an (verhindert das Aufblitzen) */
    #top-right .icon-btn {
        width: 44px;
        height: 44px;
        border-radius: 12px;
        background: rgba(18, 18, 26, 0.75) !important;
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        border: 1px solid rgba(255, 255, 255, 0.1) !important;
        color: var(--text-secondary) !important;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
    }

    #top-right .icon-btn svg {
        width: 18px;
        height: 18px;
        stroke-width: 1.6px;
    }

    #top-right .icon-btn:hover {
        background: var(--accent) !important;
        color: white !important;
        border-color: var(--accent) !important;
        transform: scale(1.06) translateX(2px);
        box-shadow: 0 0 14px var(--accent-glow, rgba(124, 58, 237, 0.4));
    }

    /* 3. More-Dropdown klappt nach RECHTS auf (nie wieder links raus) */
    #top-bar .nav-dropdown-menu {
        left: 54px !important;
        right: auto !important;
        top: 0 !important;
        position: absolute !important;
    }

    /* 4. Perfekte Symmetrie & Höhenangleichung (Exakt -18px) */
    #left-panel,
    #right-panel {
        top: 93px !important;
        bottom: 20px !important;
        height: calc(100vh - 113px) !important;
    }

    #settings-panel {
        height: 100% !important;
        margin: 0 0 0 15px !important;
    }

    #right-panel .panel-content {
        height: 100% !important;
        margin: 0 15px 0 0 !important;
    }

    /* ===================================================== */
    /* COMPANION ACTIVE DOCK (Rechts neben dem Paw-Button)   */
    /* ===================================================== */
    #companion-dock {
        display: flex;
        align-items: center;
        gap: 8px;
        margin-left: 4px;
        pointer-events: auto;
    }

    .dock-badge {
        width: 44px !important;
        height: 44px !important;
        border-radius: 12px !important;
        background: rgba(18, 18, 26, 0.3) !important;
        backdrop-filter: blur(15px);
        -webkit-backdrop-filter: blur(15px);
        border: 1px solid var(--accent) !important;
        color: var(--color-custom, var(--accent)) !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        cursor: pointer;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
        position: relative;
        animation: dockPopIn 0.28s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
        transition: transform 0.18s cubic-bezier(0.16, 1, 0.3, 1), background 0.18s ease, box-shadow 0.18s ease;
    }

    .dock-badge:hover {
        background: var(--accent) !important;
        color: white !important;
        transform: translateY(-2px) scale(1.05);
        box-shadow: 0 0 16px var(--accent-glow, rgba(124, 58, 237, 0.5)) !important;
    }

    .dock-badge:active {
        transform: translateY(0) scale(0.94);
        transition-duration: 0.08s;
    }

    .dock-badge svg {
        width: 18px !important;
        height: 18px !important;
        stroke-width: 1.6px !important;
        transition: transform 0.18s cubic-bezier(0.16, 1, 0.3, 1);
    }

    .dock-badge:hover svg {
        transform: scale(1.08);
    }

    /* Glühender kleiner Punkt oben rechts mit sanftem Puls */
    .dock-dot {
        position: absolute;
        top: 6px;
        right: 6px;
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: var(--color-custom, var(--accent));
        box-shadow: 0 0 8px var(--accent);
        animation: dockDotPulse 2s infinite ease-in-out;
    }

    @keyframes dockDotPulse {
        0%, 100% {
            transform: scale(1);
            opacity: 0.9;
            box-shadow: 0 0 6px var(--accent);
        }
        50% {
            transform: scale(1.25);
            opacity: 1;
            box-shadow: 0 0 12px var(--accent), 0 0 4px #fff;
        }
    }

    .dock-badge:hover .dock-dot {
        background: white;
        box-shadow: 0 0 8px white;
        animation: none;
    }

    @keyframes dockPopIn {
        0% {
            opacity: 0;
            transform: scale(0.5) translateY(-6px);
        }
        70% {
            transform: scale(1.08) translateY(0);
        }
        100% {
            opacity: 1;
            transform: scale(1) translateY(0);
        }
    }

    .theme-panel {
        top: 93px !important;
        bottom: 20px !important;
        height: calc(100vh - 113px) !important;
    }
}

/* Character List Scrollbar weg */
#context-panel {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

#context-panel::-webkit-scrollbar {
    display: none;
}

/* Chat area goes all the way up */
#content {
    margin-top: 0;
    padding-top: 0;
}

#chat-container {
    padding-top: 70px; /* Space for floating icons */
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-10px); }
    40% { transform: translateX(10px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(5px); }
}

/* =================== */
/* EASTER EGGS */
/* =================== */

.confetti-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 99999;
    pointer-events: none;
}

.milestone-popup {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    z-index: 99998;
    background: rgba(10, 10, 15, 0.95);
    border: 1px solid var(--accent);
    border-radius: 16px;
    padding: 24px 36px;
    text-align: center;
    backdrop-filter: blur(20px);
    box-shadow: 0 0 40px rgba(124, 58, 237, 0.3);
    cursor: pointer;
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.5s ease;
    opacity: 0;
}

.milestone-popup.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.milestone-popup.hide {
    transform: translateX(-50%) translateY(-100px);
    opacity: 0;
}

.milestone-emoji {
    font-size: 48px;
    margin-bottom: 8px;
}

.milestone-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.milestone-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.milestone-text {
    font-size: 13px;
    color: var(--text-muted);
    font-style: italic;
    max-width: 300px;
}

.milestone-dismiss {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 12px;
    opacity: 0.5;
}

/* =================== */
/* DEBUG PANEL V2 */
/* =================== */
.debug-panel-wrapper {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.debug-tabs {
    display: flex;
    gap: 4px;
    padding: 0 0 12px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.debug-tab {
    flex: 1;
    min-width: 0;
    padding: 8px 6px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 11px;
    cursor: pointer;
    transition: 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    position: relative;
}

.debug-tab span { white-space: nowrap; }
.debug-tab svg { width: 12px; height: 12px; }

.debug-tab:hover {
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.15);
}

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

.debug-tab.no-data {
    opacity: 0.4;
}

.debug-tab.no-data.active {
    opacity: 1;
}

.debug-tab-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--success);
    position: absolute;
    top: 4px;
    right: 4px;
}

.debug-tab.active .debug-tab-dot {
    background: white;
}

.debug-tab-content {
    flex: 1;
    overflow-y: auto;
}

.debug-tab-content pre {
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 12px;
    line-height: 1.5;
    margin: 0;
}

.debug-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: var(--text-muted);
    text-align: center;
    gap: 8px;
}

.debug-empty svg {
    width: 32px;
    height: 32px;
    opacity: 0.3;
}

.debug-empty p {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.debug-empty span {
    font-size: 12px;
}

.debug-endpoint {
    word-break: break-all;
    font-size: 11px;
}

.debug-error {
    color: var(--danger) !important;
}

/* Ghostwriter & Retry Macro Buttons */
#gw-retry-btn,
.macro-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    min-width: 32px;
    padding: 0;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
}

#gw-retry-btn:hover,
.macro-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.18);
}

#gw-retry-btn svg,
.macro-btn svg {
    width: 15px;
    height: 15px;
}

/* ===================================================== */
/* 1-TURN DIRECTOR NOTE POPOVER                          */
/* ===================================================== */
.director-note-dot {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent);
}

.director-note-popover {
    display: none;
    position: absolute;
    bottom: calc(100% + 12px);
    left: 0;
    width: 320px;
    background: var(--bg-secondary, #16161f);
    border: 1px solid var(--border, rgba(255, 255, 255, 0.12));
    border-radius: 14px;
    padding: 14px;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 500;
    flex-direction: column;
    gap: 8px;
}

.director-note-popover.open {
    display: flex;
}

.dnp-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.dnp-header svg {
    width: 14px;
    height: 14px;
    color: var(--accent);
}

.dnp-hint {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.4;
    margin: 0;
}

.director-note-popover textarea {
    width: 100%;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    padding: 8px 10px;
    font-size: 12px;
    font-family: inherit;
    resize: none;
}

.director-note-popover textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.dnp-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 4px;
}

/* Glassy More-Dropdown */
.nav-dropdown-menu {
    display: none;
    position: absolute;
    min-width: 180px;
    background: rgba(18, 18, 26, 0.75) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 14px !important;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6) !important;
    padding: 6px !important;
    z-index: 1000;
    flex-direction: column;
    gap: 3px;
}

/* ===================================================== */
/* NOTES FLOATING PANEL                                  */
/* ===================================================== */
.notes-panel {
    position: fixed;
    top: 70px;
    right: 80px;
    width: 360px;
    height: 70vh;
    min-width: 280px;
    min-height: 380px;
    background: rgba(18, 18, 26, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    z-index: 150;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Snappy Apple-like Spring Animation */
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px) scale(0.94);
    transform-origin: top right;
    transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1), transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.notes-panel.open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

.notes-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    cursor: move;
    user-select: none;
}

.notes-panel-body {
    flex: 1;
    padding: 12px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* 8-Way Resize Handles für Notes */
.notes-resizer {
    position: absolute;
    z-index: 200;
}
.notes-resizer.r-n { top: 0; left: 10px; right: 10px; height: 6px; cursor: ns-resize; }
.notes-resizer.r-s { bottom: 0; left: 10px; right: 10px; height: 6px; cursor: ns-resize; }
.notes-resizer.r-w { left: 0; top: 10px; bottom: 10px; width: 6px; cursor: ew-resize; }
.notes-resizer.r-e { right: 0; top: 10px; bottom: 10px; width: 6px; cursor: ew-resize; }
.notes-resizer.r-nw { top: 0; left: 0; width: 12px; height: 12px; cursor: nwse-resize; }
.notes-resizer.r-ne { top: 0; right: 0; width: 12px; height: 12px; cursor: nesw-resize; }
.notes-resizer.r-sw { bottom: 0; left: 0; width: 12px; height: 12px; cursor: nesw-resize; }
.notes-resizer.r-se { bottom: 0; right: 0; width: 12px; height: 12px; cursor: nwse-resize; }

/* 1. NUR das More-Dropdown schrumpfen (strikt isoliert!) */
#nav-more-menu .nav-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border: none;
    background: transparent;
    color: var(--text-secondary, #a0a0b0);
    font-size: 12px;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    text-align: left;
    width: 100%;
    transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

#nav-more-menu .nav-dropdown-item i,
#nav-more-menu .nav-dropdown-item svg {
    width: 14px !important;
    height: 14px !important;
    stroke-width: 1.6px !important;
    color: var(--text-secondary, #a0a0b0) !important;
    flex-shrink: 0;
}

#nav-more-menu .nav-dropdown-item:hover {
    background: rgba(255, 255, 255, 0.08) !important;
    color: var(--text-primary, #ffffff) !important;
    transform: translateX(2px);
}

#nav-more-menu .nav-dropdown-item:hover svg {
    color: var(--color-custom, var(--accent)) !important;
}

/* 2. DASHBOARD SIDEBAR ICONS WIEDER AUF ORIGINAL-GRÖSSE SICHERN */
.dash-nav-btn svg {
    width: 18px !important;
    height: 18px !important;
    stroke-width: 1.6px !important;
}

/* 3. CAT LAUNCHER & TOPBAR ICONS WIEDER AUF ORIGINAL-GRÖSSE */
#top-right .icon-btn svg,
#top-left .icon-btn svg {
    width: 18px !important;
    height: 18px !important;
    stroke-width: 1.6px !important;
}

.nav-dropdown-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.08) !important;
    margin: 4px 6px;
}

/* Chat Header Dropdown: Immer sichtbar und sauber unter dem Button ausgerichtet */
.chat-dropdown-wrap .nav-dropdown-menu {
    position: absolute !important;
    top: calc(100% + 8px) !important;
    right: 0 !important;
    left: auto !important;
    z-index: 1000 !important;
}

.chat-dropdown-wrap .nav-dropdown-menu.open {
    display: flex !important;
}

/* Chat Dropdown Menu Styling (1:1 Glassy wie More-Menü) */
#chat-dropdown-menu {
    background: rgba(18, 18, 26, 0.75) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 14px !important;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6) !important;
    padding: 6px !important;
    min-width: 170px !important;
    gap: 3px !important;
}

#chat-dropdown-menu .nav-dropdown-item {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 7px 10px !important;
    border: none !important;
    background: transparent !important;
    color: var(--text-secondary, #a0a0b0) !important;
    font-size: 12px !important;
    font-weight: 500 !important;
    border-radius: 8px !important;
    cursor: pointer !important;
    width: 100% !important;
    text-align: left !important;
    box-shadow: none !important;
    transition: all 0.15s ease !important;
}

#chat-dropdown-menu .nav-dropdown-item svg,
#chat-dropdown-menu .nav-dropdown-item i {
    width: 14px !important;
    height: 14px !important;
    stroke-width: 1.6px !important;
    color: var(--text-secondary, #a0a0b0) !important;
    flex-shrink: 0 !important;
    transition: color 0.15s ease !important;
}

#chat-dropdown-menu .nav-dropdown-item:hover {
    background: rgba(255, 255, 255, 0.08) !important;
    color: var(--text-primary, #ffffff) !important;
    transform: translateX(2px) !important;
}

#chat-dropdown-menu .nav-dropdown-item:hover svg,
#chat-dropdown-menu .nav-dropdown-item:hover i {
    color: var(--color-custom, var(--accent)) !important;
}

#chat-dropdown-menu .nav-dropdown-divider {
    height: 1px !important;
    background: rgba(255, 255, 255, 0.08) !important;
    margin: 4px 6px !important;
}

/* ===================================================== */
/* FLOATING CHARACTER EDITOR                             */
/* ===================================================== */
#character-modal.modal {
    background: transparent !important;
    pointer-events: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    z-index: 140 !important;
}

#character-modal .modal-content {
    pointer-events: auto !important;
    position: fixed !important;
    top: 60px;
    left: 80px;
    width: 720px;
    max-width: calc(100vw - 40px);
    height: 82vh;
    max-height: calc(100vh - 80px);
    min-width: 320px;
    min-height: 400px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: rgba(18, 18, 26, 0.92) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    margin: 0 !important;
    z-index: 141;
}

#character-modal .modal-fixed-header {
    cursor: move;
    user-select: none;
    background: rgba(0, 0, 0, 0.3);
}

#character-modal .modal-fixed-header button,
#character-modal .modal-fixed-header input {
    cursor: pointer;
}

#character-modal .char-editor-resizer {
    position: absolute;
    z-index: 200;
}

#character-modal .char-editor-resizer.r-n { top: 0; left: 12px; right: 12px; height: 6px; cursor: ns-resize; }
#character-modal .char-editor-resizer.r-s { bottom: 0; left: 12px; right: 12px; height: 6px; cursor: ns-resize; }
#character-modal .char-editor-resizer.r-w { left: 0; top: 12px; bottom: 12px; width: 6px; cursor: ew-resize; }
#character-modal .char-editor-resizer.r-e { right: 0; top: 12px; bottom: 12px; width: 6px; cursor: ew-resize; }
#character-modal .char-editor-resizer.r-nw { top: 0; left: 0; width: 14px; height: 14px; cursor: nwse-resize; }
#character-modal .char-editor-resizer.r-ne { top: 0; right: 0; width: 14px; height: 14px; cursor: nesw-resize; }
#character-modal .char-editor-resizer.r-sw { bottom: 0; left: 0; width: 14px; height: 14px; cursor: nesw-resize; }
#character-modal .char-editor-resizer.r-se { bottom: 0; right: 0; width: 14px; height: 14px; cursor: nwse-resize; }

/* ===================================================== */
/* CHAT SEARCH MODAL & HIGHLIGHT                         */
/* ===================================================== */
#chat-search-modal .modal-content {
    max-width: 600px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}

#chat-search-modal .modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-search-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.chat-search-input-wrap input {
    width: 100%;
    padding: 10px 38px 10px 38px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 14px;
}

.chat-search-input-wrap input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.chat-search-input-wrap .search-icon {
    position: absolute;
    left: 12px;
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    pointer-events: none;
}

.chat-search-input-wrap .search-clear-btn {
    position: absolute;
    right: 10px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: 4px;
}

.chat-search-input-wrap .search-clear-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.08);
}

.chat-search-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--text-muted);
    padding: 0 2px;
}

.chat-search-results-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    max-height: 50vh;
    padding-right: 4px;
}

.chat-search-result-item {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    flex-direction: column;
    gap: 6px;
    text-align: left;
}

.chat-search-result-item:hover {
    border-color: var(--accent);
    background: rgba(255, 255, 255, 0.04);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.chat-search-result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
}

.chat-search-result-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
}

.chat-search-result-badge.user {
    background: var(--accent-tint);
    color: var(--accent);
}

.chat-search-result-badge.assistant {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
}

.chat-search-result-date {
    color: var(--text-muted);
}

.chat-search-result-snippet {
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-search-result-jump {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--accent);
    font-weight: 500;
    align-self: flex-end;
    margin-top: 2px;
}

.search-match-highlight {
    background-color: rgba(234, 179, 8, 0.35);
    color: #fef08a;
    font-weight: 600;
    padding: 1px 3px;
    border-radius: 3px;
}

.message-wrapper.search-highlight-target .message-header,
.message-wrapper.search-highlight-target .message {
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 2px var(--accent-glow), 0 0 24px rgba(124, 58, 237, 0.5) !important;
    animation: searchPulse 2.5s ease-in-out;
}

@keyframes searchPulse {
    0% { transform: scale(1); }
    20% { transform: scale(1.015); }
    40% { transform: scale(1); }
    60% { transform: scale(1.01); }
    100% { transform: scale(1); }
}

/* ===================================================== */
/* CHAT MENÜ: STIL & POSITION (Desktop, nur Chatfenster)  */
/* ===================================================== */
@media (min-width: 769px) {
    /* --- Position: rechter Bildschirmrand --- */
    body.menu-pos-right:not(.on-dashboard) #top-bar {
        left: auto !important;
        right: 28px !important;
        align-items: flex-end !important;
    }

    body.menu-pos-right:not(.on-dashboard) #top-left,
    body.menu-pos-right:not(.on-dashboard) #top-right,
    body.menu-pos-right:not(.on-dashboard) #companion-dock {
        align-items: flex-end !important;
    }

    body.menu-pos-right:not(.on-dashboard) #top-left {
        flex-direction: row-reverse;
    }

    body.menu-pos-right:not(.on-dashboard) #companion-dock {
        flex-direction: row-reverse;
        margin-left: 0;
        margin-right: 4px;
    }

    body.menu-pos-right:not(.on-dashboard) #top-bar .nav-dropdown-menu {
        left: auto !important;
        right: 54px !important;
    }

    /* --- Stil: Always Open (kein Klick-Toggle nötig, permanent sichtbar) --- */
    body.menu-style-alwaysopen:not(.on-dashboard) #top-right {
        pointer-events: auto;
    }

    body.menu-style-alwaysopen:not(.on-dashboard) #top-right .icon-btn,
    body.menu-style-alwaysopen:not(.on-dashboard) #top-right .nav-dropdown-wrap {
        opacity: 1 !important;
        transform: none !important;
        pointer-events: auto !important;
        transition: none !important;
    }

    /* Buttons im gleichen Glas-Look wie Menü/Home */
    body.menu-style-alwaysopen:not(.on-dashboard) #top-right .icon-btn {
        background: rgba(18, 18, 26, 0.3) !important;
    }

    body.menu-style-alwaysopen:not(.on-dashboard) #cat-nav-btn {
        cursor: default;
    }

    html.menu-home-slot #cat-nav-btn {
        display: none !important;
    }

    html.menu-home-slot #home-btn {
        order: -1;
    }

    /* --- Stil: Simple (alle Icons in einer flachen Liste, ohne Gruppierung/Animation) --- */
    body.menu-style-simple:not(.on-dashboard) #top-left,
    body.menu-style-simple:not(.on-dashboard) #top-right,
    body.menu-style-simple:not(.on-dashboard) #companion-dock {
        flex-direction: column;
        gap: 8px;
    }

    body.menu-pos-right.menu-style-simple:not(.on-dashboard) #top-left,
    body.menu-pos-right.menu-style-simple:not(.on-dashboard) #companion-dock {
        flex-direction: column;
    }

    body.menu-style-simple:not(.on-dashboard) #top-right {
        margin-top: 0;
        pointer-events: auto;
    }

    body.menu-style-simple:not(.on-dashboard) #top-right .icon-btn,
    body.menu-style-simple:not(.on-dashboard) #top-right .nav-dropdown-wrap {
        opacity: 1 !important;
        transform: none !important;
        pointer-events: auto !important;
        transition: none !important;
    }

    body.menu-style-simple:not(.on-dashboard) #top-right .icon-btn {
        width: 44px;
        height: 44px;
        border-radius: 12px;
        background: rgba(18, 18, 26, 0.3) !important;
        backdrop-filter: blur(15px);
        -webkit-backdrop-filter: blur(15px);
        border: 1px solid rgba(255, 255, 255, 0.1) !important;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    }

    body.menu-style-simple:not(.on-dashboard) #cat-nav-btn {
        cursor: default;
    }

    /* In compact menu modes, minimized panels keep only a status dot on their menu button. */
    body.menu-style-simple:not(.on-dashboard) #top-right .icon-btn.panel-status-active,
    body.menu-style-alwaysopen:not(.on-dashboard) #top-right .icon-btn.panel-status-active {
        position: relative;
    }

    body.menu-style-simple:not(.on-dashboard) #top-right .icon-btn.panel-status-active::after,
    body.menu-style-alwaysopen:not(.on-dashboard) #top-right .icon-btn.panel-status-active::after {
        content: '';
        position: absolute;
        top: 5px;
        right: 5px;
        width: 7px;
        height: 7px;
        border-radius: 50%;
        background: var(--accent);
        box-shadow: 0 0 8px var(--accent), 0 0 14px var(--accent-glow);
    }

    /* --- Panel-Kollision: Menü-Icons (außer Katze) ausblenden solange ein Panel auf derselben Seite offen ist --- */
    body:not(.menu-pos-right).panel-open-left:not(.on-dashboard) #top-bar:not(.open) #top-left #home-btn,
    body:not(.menu-pos-right).panel-open-left:not(.on-dashboard) #top-bar:not(.open) #top-right .icon-btn,
    body:not(.menu-pos-right).panel-open-left:not(.on-dashboard) #top-bar:not(.open) #top-right .nav-dropdown-wrap,
    body:not(.menu-pos-right).panel-open-left:not(.on-dashboard) #top-bar:not(.open) #companion-dock,
    body.menu-pos-right.panel-open-right:not(.on-dashboard) #top-bar:not(.open) #top-left #home-btn,
    body.menu-pos-right.panel-open-right:not(.on-dashboard) #top-bar:not(.open) #top-right .icon-btn,
    body.menu-pos-right.panel-open-right:not(.on-dashboard) #top-bar:not(.open) #top-right .nav-dropdown-wrap,
    body.menu-pos-right.panel-open-right:not(.on-dashboard) #top-bar:not(.open) #companion-dock {
        opacity: 0 !important;
        pointer-events: none !important;
        transform: translateY(-6px) scale(0.85) !important;
    }
}

/* ===================================================== */
/* MOBILE FIX: Character Editor Fullscreen on Smartphones */
/* ===================================================== */
@media (max-width: 768px) {
    #character-modal.modal {
        background: rgba(0, 0, 0, 0.85) !important;
        pointer-events: auto !important;
        padding: 0 !important;
    }

    #character-modal .modal-content {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100vw !important;
        max-width: 100vw !important;
        height: 100dvh !important;
        max-height: 100dvh !important;
        border-radius: 0 !important;
        border: none !important;
        margin: 0 !important;
        transform: none !important;
    }

    #character-modal .char-editor-resizer {
        display: none !important;
    }

    #character-modal .modal-fixed-header {
        cursor: default !important;
    }
}
