/* Parlor — Premium Chat UI */

/* ============================================================
   SELF-HOSTED FONTS
   ============================================================ */
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 400; font-display: swap; src: url('/fonts/inter-regular.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 500; font-display: swap; src: url('/fonts/inter-500.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 600; font-display: swap; src: url('/fonts/inter-600.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 700; font-display: swap; src: url('/fonts/inter-700.woff2') format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-style: normal; font-weight: 400; font-display: swap; src: url('/fonts/jetbrains-mono-regular.woff2') format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-style: normal; font-weight: 500; font-display: swap; src: url('/fonts/jetbrains-mono-500.woff2') format('woff2'); }
@font-face { font-family: 'Cinzel'; font-style: normal; font-weight: 400; font-display: swap; src: url('/fonts/cinzel-regular.woff2') format('woff2'); }
@font-face { font-family: 'Cinzel'; font-style: normal; font-weight: 700; font-display: swap; src: url('/fonts/cinzel-700.woff2') format('woff2'); }

/* ============================================================
   THEME SYSTEM — CSS Custom Properties
   ============================================================ */

:root {
    --transition-speed: 0.15s;
    --transition-theme: 0.5s;
    --easing: cubic-bezier(0.4, 0, 0.2, 1);
    --easing-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Consolas', 'Monaco', monospace;
    --font-deco: 'Cinzel', 'Georgia', serif;
}

/* --- Midnight (Default) — Digital Speakeasy dark --- */
[data-theme="midnight"], :root {
    --bg-primary: #0f1115;
    --bg-secondary: #13151d;
    --bg-sidebar: rgba(15, 17, 21, 0.85);
    --bg-input: #1a1d27;
    --bg-hover: #1e2130;
    --bg-active: #252838;
    --bg-card: #161821;
    --bg-user-msg: #1e2330;
    --bg-assistant-msg: transparent;
    --bg-tool-call: #141729;
    --bg-gradient-start: #0f1115;
    --bg-gradient-end: #0d0f15;

    --text-primary: #e4e5e9;
    --text-secondary: #b8c4d4;
    --text-muted: #8890a0;

    --border-color: rgba(255, 255, 255, 0.06);
    --border-glow: rgba(197, 160, 89, 0.2);

    --accent: #C5A059;
    --accent-hover: #b08d4a;
    --accent-glow: rgba(197, 160, 89, 0.3);
    --accent-subtle: rgba(197, 160, 89, 0.1);
    --accent-gradient-start: #C5A059;
    --accent-gradient-end: #b08d4a;
    --accent-blue: #3B82F6;

    --error: #ef4444;
    --warning: #f59e0b;

    --code-bg: #0d0f15;
    --code-header-bg: #13151d;
    --code-border: rgba(255, 255, 255, 0.04);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3), 0 1px 3px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4), 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 20px rgba(197, 160, 89, 0.15);

    --input-glow: 0 0 0 2px rgba(197, 160, 89, 0.15), 0 0 20px rgba(197, 160, 89, 0.08);
    --sidebar-blur: blur(20px);
    --sidebar-opacity: 0.85;
    --modal-backdrop-blur: blur(8px);

    --topbar-bg: rgba(15, 17, 21, 0.8);

    --scrollbar-thumb: #2a2d3a;
    --scrollbar-track: transparent;

    --msg-user-border: var(--accent-blue);
    --welcome-gradient: linear-gradient(135deg, #C5A059, #3B82F6);
}

/* --- Dawn — Warm editorial light --- */
[data-theme="dawn"] {
    --bg-primary: #faf8f5;
    --bg-secondary: #f2efe9;
    --bg-sidebar: rgba(242, 239, 233, 0.95);
    --bg-input: #ffffff;
    --bg-hover: #edeae4;
    --bg-active: #e5e1da;
    --bg-card: #ffffff;
    --bg-user-msg: #ffffff;
    --bg-assistant-msg: transparent;
    --bg-tool-call: #faf6ee;
    --bg-gradient-start: #faf8f5;
    --bg-gradient-end: #f5f2ed;

    --text-primary: #1a1a1a;
    --text-secondary: #6b6b6b;
    --text-muted: #9a9a9a;

    --border-color: rgba(0, 0, 0, 0.08);
    --border-glow: rgba(156, 124, 58, 0.2);

    --accent: #9C7C3A;
    --accent-hover: #86692e;
    --accent-glow: rgba(156, 124, 58, 0.2);
    --accent-subtle: rgba(156, 124, 58, 0.08);
    --accent-gradient-start: #9C7C3A;
    --accent-gradient-end: #86692e;
    --accent-blue: #2563EB;

    --error: #dc2626;
    --warning: #d97706;

    --code-bg: #f6f4f0;
    --code-header-bg: #edeae4;
    --code-border: rgba(0, 0, 0, 0.06);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.08), 0 2px 6px rgba(0, 0, 0, 0.04);
    --shadow-glow: 0 0 20px rgba(156, 124, 58, 0.1);

    --input-glow: 0 0 0 2px rgba(156, 124, 58, 0.12), 0 0 16px rgba(156, 124, 58, 0.06);
    --sidebar-blur: blur(12px);
    --sidebar-opacity: 0.95;
    --modal-backdrop-blur: blur(6px);

    --topbar-bg: rgba(250, 248, 245, 0.9);

    --scrollbar-thumb: #d4d0c8;
    --scrollbar-track: transparent;

    --msg-user-border: var(--accent-blue);
    --welcome-gradient: linear-gradient(135deg, #9C7C3A, #C5A059);
}

/* --- Aurora — Dark with animated gradient accents --- */
[data-theme="aurora"] {
    --bg-primary: #090b10;
    --bg-secondary: #0c0e14;
    --bg-sidebar: rgba(9, 11, 16, 0.85);
    --bg-input: #12151e;
    --bg-hover: #161a26;
    --bg-active: #1c2030;
    --bg-card: #0f1118;
    --bg-user-msg: #12151e;
    --bg-assistant-msg: transparent;
    --bg-tool-call: #10122a;
    --bg-gradient-start: #090b10;
    --bg-gradient-end: #060810;

    --text-primary: #e2e4ea;
    --text-secondary: #8a8ea0;
    --text-muted: #555872;

    --border-color: rgba(255, 255, 255, 0.05);
    --border-glow: rgba(197, 160, 89, 0.3);

    --accent: #C5A059;
    --accent-hover: #b08d4a;
    --accent-glow: rgba(197, 160, 89, 0.3);
    --accent-subtle: rgba(197, 160, 89, 0.1);
    --accent-gradient-start: #C5A059;
    --accent-gradient-end: #3B82F6;
    --accent-blue: #3B82F6;

    --error: #ef4444;
    --warning: #f59e0b;

    --code-bg: #060810;
    --code-header-bg: #0c0e14;
    --code-border: rgba(255, 255, 255, 0.04);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4), 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 30px rgba(197, 160, 89, 0.15), 0 0 60px rgba(59, 130, 246, 0.08);

    --input-glow: 0 0 0 2px rgba(197, 160, 89, 0.2), 0 0 20px rgba(197, 160, 89, 0.1);
    --sidebar-blur: blur(24px);
    --sidebar-opacity: 0.85;
    --modal-backdrop-blur: blur(12px);

    --topbar-bg: rgba(9, 11, 16, 0.8);

    --scrollbar-thumb: #1c2030;
    --scrollbar-track: transparent;

    --msg-user-border: linear-gradient(to bottom, #C5A059, #3B82F6);
    --welcome-gradient: linear-gradient(135deg, #C5A059, #3B82F6, #10b981);
}

/* --- Ember — Warm luxury dark --- */
[data-theme="ember"] {
    --bg-primary: #171210;
    --bg-secondary: #1a1512;
    --bg-sidebar: rgba(23, 18, 16, 0.88);
    --bg-input: #211a16;
    --bg-hover: #271f1a;
    --bg-active: #30261e;
    --bg-card: #1e1814;
    --bg-user-msg: #231c17;
    --bg-assistant-msg: transparent;
    --bg-tool-call: #241a14;
    --bg-gradient-start: #171210;
    --bg-gradient-end: #130f0c;

    --text-primary: #e8e0d8;
    --text-secondary: #a89888;
    --text-muted: #6e5e50;

    --border-color: rgba(255, 255, 255, 0.06);
    --border-glow: rgba(197, 160, 89, 0.25);

    --accent: #C5A059;
    --accent-hover: #b08d4a;
    --accent-glow: rgba(197, 160, 89, 0.25);
    --accent-subtle: rgba(197, 160, 89, 0.1);
    --accent-gradient-start: #C5A059;
    --accent-gradient-end: #b08d4a;
    --accent-blue: #3B82F6;

    --error: #ef4444;
    --warning: #f59e0b;

    --code-bg: #130f0c;
    --code-header-bg: #1a1512;
    --code-border: rgba(255, 255, 255, 0.04);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3), 0 1px 3px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4), 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 20px rgba(197, 160, 89, 0.12);

    --input-glow: 0 0 0 2px rgba(197, 160, 89, 0.15), 0 0 20px rgba(197, 160, 89, 0.08);
    --sidebar-blur: blur(20px);
    --sidebar-opacity: 0.88;
    --modal-backdrop-blur: blur(8px);

    --topbar-bg: rgba(23, 18, 16, 0.8);

    --scrollbar-thumb: #30261e;
    --scrollbar-track: transparent;

    --msg-user-border: var(--accent-blue);
    --welcome-gradient: linear-gradient(135deg, #C5A059, #b08d4a);
}


/* ============================================================
   RESET & BASE
   ============================================================ */

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

html {
    height: 100%;
    transition: background-color var(--transition-theme) var(--easing),
                color var(--transition-theme) var(--easing);
}

body {
    height: 100%;
    font-family: var(--font-ui);
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================================================
   SCROLLBAR
   ============================================================ */

::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}
::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 3px;
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}


/* ============================================================
   LAYOUT
   ============================================================ */

.app-container {
    display: flex;
    height: 100vh;
    background: linear-gradient(180deg, var(--bg-gradient-start), var(--bg-gradient-end));
}


/* ============================================================
   SIDEBAR
   ============================================================ */

.sidebar {
    width: 260px;
    min-width: 260px;
    background: var(--bg-sidebar);
    -webkit-backdrop-filter: var(--sidebar-blur);
    backdrop-filter: var(--sidebar-blur);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    transition: width 0.25s var(--easing), min-width 0.25s var(--easing),
                background-color var(--transition-theme) var(--easing);
    z-index: 10;
}

.sidebar-header {
    padding: 12px 12px 8px;
}

.btn-new-chat {
    width: 100%;
    padding: 9px 14px;
    background: transparent;
    color: var(--text-primary);
    border: 1px dashed var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font-ui);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all var(--transition-speed) var(--easing);
}
.btn-new-chat:hover {
    background: var(--accent-subtle);
    border-style: solid;
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: var(--shadow-glow);
}
.btn-new-chat svg {
    flex-shrink: 0;
    opacity: 0.7;
    transition: transform var(--transition-speed) var(--easing),
                opacity var(--transition-speed) var(--easing);
}
.btn-new-chat:hover svg {
    opacity: 1;
    transform: rotate(90deg);
}

.new-chat-row {
    display: flex;
    gap: 4px;
}
.new-chat-row .btn-new-chat {
    flex: 1;
}
.btn-new-type-dropdown {
    padding: 9px 8px;
    background: transparent;
    color: var(--text-muted);
    border: 1px dashed var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-speed) var(--easing);
}
.btn-new-type-dropdown:hover {
    background: var(--accent-subtle);
    border-style: solid;
    border-color: var(--accent);
    color: var(--accent);
}

.new-conv-dropdown {
    min-width: 130px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    z-index: 60;
    padding: 4px;
    font-size: 13px;
}
.new-conv-dropdown-item {
    padding: 7px 12px;
    border-radius: 5px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: background var(--transition-speed) var(--easing);
}
.new-conv-dropdown-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.sidebar-search {
    padding: 0 12px 10px;
    display: flex;
    gap: 6px;
}
.sidebar-search input {
    flex: 1;
    min-width: 0;
    padding: 7px 12px;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 12px;
    font-family: var(--font-ui);
    outline: none;
    transition: border-color var(--transition-speed) var(--easing),
                box-shadow var(--transition-speed) var(--easing);
}
.sidebar-search input:focus {
    border-color: var(--accent);
    box-shadow: var(--input-glow);
}
.sidebar-search input::placeholder {
    color: var(--text-muted);
}
.type-filter-select {
    width: 72px;
    padding: 5px 6px;
    background: var(--bg-input);
    color: var(--text-secondary);
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 11px;
    font-family: var(--font-ui);
    outline: none;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 4px center;
    padding-right: 18px;
    transition: border-color var(--transition-speed) var(--easing);
}
.type-filter-select:focus {
    border-color: var(--accent);
}
.type-filter-select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.conversation-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 8px;
}

.conversation-item {
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all var(--transition-speed) var(--easing);
}
.conversation-item:hover {
    background: var(--bg-hover);
}
.conversation-item.active {
    background: var(--bg-active);
    color: var(--text-primary);
}
.conversation-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--accent);
    border-radius: 0 2px 2px 0;
    animation: slideIndicator 0.2s var(--easing);
}

@keyframes slideIndicator {
    from { height: 0%; opacity: 0; }
    to { height: 60%; opacity: 1; }
}

.conversation-item .conv-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-item .conv-actions {
    display: none;
    gap: 4px;
    flex-shrink: 0;
}
.conversation-item:hover .conv-actions {
    display: flex;
}

.conv-actions button {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 4px;
    font-size: 12px;
    border-radius: 4px;
    transition: all var(--transition-speed) var(--easing);
}
.conv-actions button:hover {
    color: var(--text-primary);
    background: var(--bg-primary);
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border-color);
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
}
.btn-settings {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 13px;
    font-family: var(--font-ui);
    transition: all var(--transition-speed) var(--easing);
}
.btn-settings:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}
.mcp-status {
    font-size: 11px;
    color: var(--text-muted);
    margin-left: auto;
}


/* ============================================================
   FOLDERS
   ============================================================ */

.folder-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    transition: color var(--transition-speed) var(--easing);
    user-select: none;
}
.folder-header:hover {
    color: var(--text-secondary);
}
.folder-header .folder-chevron {
    display: flex;
    transition: transform var(--transition-speed) var(--easing);
}
.folder-header.collapsed .folder-chevron {
    transform: rotate(-90deg);
}
.folder-header .folder-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.folder-header .folder-actions {
    display: none;
    gap: 2px;
}
.folder-header:hover .folder-actions {
    display: flex;
}
.folder-actions button {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 4px;
    font-size: 11px;
    border-radius: 3px;
    transition: color var(--transition-speed) var(--easing);
}
.folder-actions button:hover {
    color: var(--text-primary);
}

.folder-contents {
    overflow: hidden;
    transition: max-height 0.3s var(--easing);
}
.folder-contents.collapsed {
    max-height: 0 !important;
}

.folder-contents .conversation-item {
    padding-left: 28px;
}
.folder-header .folder-actions button[data-action="subfolder"] {
    font-size: 14px;
    font-weight: 700;
}

.move-to-folder-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 4px;
    font-size: 12px;
    border-radius: 4px;
    transition: color var(--transition-speed) var(--easing);
}
.move-to-folder-btn:hover {
    color: var(--accent);
}

.folder-dropdown {
    position: fixed;
    min-width: 160px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    z-index: 60;
    padding: 4px;
    font-size: 13px;
}
.folder-dropdown-item {
    padding: 6px 10px;
    border-radius: 5px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: background var(--transition-speed) var(--easing);
}
.folder-dropdown-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.db-copy-dropdown {
    position: fixed;
    min-width: 160px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    z-index: 60;
    padding: 4px;
    font-size: 13px;
}

/* Tags on conversations */
.conv-tags {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-top: 2px;
}
.conv-tag {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 3px;
    border: 1px solid;
    line-height: 1.4;
    white-space: nowrap;
}
.conversation-item {
    flex-wrap: wrap;
}

/* Tag dropdown */
.tag-dropdown {
    position: fixed;
    min-width: 160px;
    max-height: 240px;
    overflow-y: auto;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    z-index: 60;
    padding: 4px;
    font-size: 13px;
}
.tag-dropdown-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 5px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: background var(--transition-speed) var(--easing);
}
.tag-dropdown-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.tag-dropdown-item.active {
    color: var(--accent);
    font-weight: 500;
}
.tag-dropdown-new {
    border-top: 1px solid var(--border-color);
    margin-top: 2px;
    padding-top: 8px;
    color: var(--accent);
}
.tag-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Drag-and-drop */
.conversation-item.dragging {
    opacity: 0.4;
}
.folder-header.drag-over,
.folder-contents.drag-over,
.unfiled-zone.drag-over {
    background: var(--accent-glow);
    border-radius: 6px;
    outline: 2px dashed var(--accent);
    outline-offset: -2px;
}
.drop-candidate {
    transition: background 0.15s var(--easing), outline 0.15s var(--easing);
}
.unfiled-zone {
    min-height: 8px;
}

/* Conversation type badges */
.conv-type-badge {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 1px 5px;
    border-radius: 3px;
    flex-shrink: 0;
    line-height: 1.4;
}
.conv-type-note {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
}
.conv-type-document {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
}


/* ============================================================
   NOTE ENTRIES
   ============================================================ */

/* --- Date Group Headers --- */
.note-date-header {
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px 8px;
}
.note-date-header:first-child {
    padding-top: 8px;
}
.note-date-line {
    flex: 1;
    height: 1px;
    background: var(--border-color);
}
.note-date-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

/* --- Note Entries --- */
.note-entry {
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-color);
    animation: messageIn 0.3s var(--easing);
    position: relative;
}
.note-entry:last-child {
    border-bottom: none;
}

.note-entry-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.note-entry-timestamp {
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.note-entry-actions {
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.15s var(--easing);
}
.note-entry:hover .note-entry-actions {
    opacity: 1;
}

.note-action-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 3px 5px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    transition: all 0.12s var(--easing);
}
.note-action-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}
.note-action-delete:hover {
    color: var(--error);
    background: rgba(239, 68, 68, 0.1);
}

.note-entry-content {
    font-size: 15px;
    line-height: 1.65;
    color: var(--text-primary);
}
.note-entry-content p { margin-bottom: 8px; }
.note-entry-content p:last-child { margin-bottom: 0; }
.note-entry-content pre { margin: 8px 0; }
.note-entry-content code {
    background: var(--code-bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 13px;
    border: 1px solid var(--code-border);
}
.note-entry-content pre code {
    display: block;
    padding: 12px 16px;
    border-radius: 0;
    border: none;
}

/* --- Note Inline Edit --- */
.note-edit-textarea {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--accent);
    border-radius: 8px;
    font-size: 15px;
    line-height: 1.6;
    font-family: var(--font-ui);
    resize: vertical;
    min-height: 80px;
    outline: none;
    box-shadow: var(--input-glow);
}
.note-edit-buttons {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    justify-content: flex-end;
}
.note-edit-buttons .btn-modal-save,
.note-edit-buttons .btn-modal-cancel {
    padding: 6px 14px;
    font-size: 12px;
}

/* --- Note Delete Confirmation --- */
.note-delete-confirm {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    margin-top: 8px;
    background: rgba(239, 68, 68, 0.06);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    animation: messageIn 0.15s var(--easing);
}
.note-delete-yes {
    padding: 4px 12px;
    background: var(--error);
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font-ui);
    transition: background 0.12s;
}
.note-delete-yes:hover {
    background: #dc2626;
}
.note-delete-no {
    padding: 4px 12px;
    background: var(--bg-input);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-family: var(--font-ui);
    transition: all 0.12s;
}
.note-delete-no:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* --- Note Entry Remove Animation --- */
@keyframes noteRemove {
    from { opacity: 1; max-height: 500px; padding: 12px 20px; margin-bottom: 0; }
    to { opacity: 0; max-height: 0; padding: 0 20px; margin-bottom: 0; overflow: hidden; }
}
.note-entry-removing {
    animation: noteRemove 0.3s var(--easing) forwards;
}


/* ============================================================
   DOCUMENT VIEW
   ============================================================ */

/* --- Document Toolbar --- */
.document-toolbar {
    max-width: 720px;
    margin: 0 auto;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px 0;
}
.document-word-count {
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}
.document-edit-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    font-family: var(--font-ui);
    transition: all 0.15s var(--easing);
}
.document-edit-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-subtle);
}

/* --- Document Edit Mode --- */
.document-edit-area {
    max-width: 720px;
    margin: 0 auto;
    padding: 16px 20px 40px;
    width: 100%;
}
.document-edit-textarea {
    width: 100%;
    min-height: 400px;
    padding: 20px;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 14px;
    line-height: 1.7;
    font-family: var(--font-mono);
    resize: vertical;
    outline: none;
    transition: border-color 0.15s var(--easing), box-shadow 0.15s var(--easing);
}
.document-edit-textarea:focus {
    border-color: var(--accent);
    box-shadow: var(--input-glow);
}
.document-edit-buttons {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    justify-content: flex-end;
}
.document-edit-buttons .btn-modal-save,
.document-edit-buttons .btn-modal-cancel {
    padding: 8px 18px;
    font-size: 13px;
}

.document-view {
    max-width: 720px;
    margin: 0 auto;
    padding: 40px 20px;
}
.document-section {
    font-size: 16px;
    line-height: 1.75;
    color: var(--text-primary);
    margin-bottom: 24px;
}
.document-section:last-child { margin-bottom: 0; }
.document-section h1,
.document-section h2,
.document-section h3 {
    margin-top: 1.5em;
    margin-bottom: 0.5em;
}
.document-section h1:first-child,
.document-section h2:first-child,
.document-section h3:first-child {
    margin-top: 0;
}
.document-section p { margin-bottom: 12px; }
.document-section p:last-child { margin-bottom: 0; }
.document-section pre {
    position: relative;
    margin: 12px 0;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--code-border);
}
.document-section code {
    background: var(--code-bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 13px;
    border: 1px solid var(--code-border);
}
.document-section pre code {
    display: block;
    padding: 12px 16px;
    background: var(--code-bg);
    border-radius: 0;
    border: none;
}
.document-section ul, .document-section ol {
    margin: 8px 0;
    padding-left: 24px;
}
.document-section li { margin: 4px 0; }
.document-section table {
    border-collapse: collapse;
    margin: 12px 0;
    width: 100%;
}
.document-section th, .document-section td {
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    text-align: left;
}
.document-section th {
    background: var(--bg-input);
}
.document-section blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 16px;
    margin: 12px 0;
    color: var(--text-secondary);
}


/* ============================================================
   MAIN CHAT AREA
   ============================================================ */

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: linear-gradient(180deg, var(--bg-gradient-start), var(--bg-gradient-end));
}

.setup-banner {
    padding: 12px 20px;
    background: var(--warning);
    color: #000;
    text-align: center;
    font-size: 14px;
}
.setup-banner code {
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: var(--font-mono);
}

/* Chat topbar */
.chat-topbar {
    padding: 8px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    background: var(--topbar-bg);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
}

.mobile-menu-btn {
    display: none;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: all var(--transition-speed) var(--easing);
}
.mobile-menu-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}


/* ============================================================
   MESSAGES
   ============================================================ */

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px 0;
}

.welcome-message {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-secondary);
    animation: fadeIn 0.5s var(--easing);
}
.welcome-message h2 {
    font-family: var(--font-deco);
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 12px;
    background: var(--welcome-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.welcome-tips {
    margin-top: 24px;
    text-align: left;
    display: inline-block;
}
.welcome-tips ul {
    list-style: none;
    padding: 0;
    margin-top: 8px;
}
.welcome-tips li {
    padding: 4px 0;
    font-size: 13px;
}
.welcome-tips li strong {
    font-family: var(--font-mono);
    font-size: 12px;
    padding: 2px 6px;
    background: var(--bg-input);
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

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

.message {
    padding: 16px 0;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    padding-left: 20px;
    padding-right: 20px;
    animation: messageIn 0.3s var(--easing);
}

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

.message.user .message-content {
    background: var(--bg-user-msg);
    padding: 12px 16px;
    border-radius: 12px;
    border-left: 3px solid var(--accent);
    box-shadow: var(--shadow-sm);
}

.message.assistant .message-content {
    border-left: 2px solid var(--accent);
    padding-left: 16px;
}

.message-role {
    font-size: 11px;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.message.user .message-role {
    color: var(--accent-blue, var(--accent));
}
.message.assistant .message-role {
    color: var(--accent);
}

.message-content {
    line-height: 1.65;
    font-size: 15px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.message-content p {
    margin-bottom: 12px;
}
.message-content p:last-child {
    margin-bottom: 0;
}

.message-content ul, .message-content ol {
    margin: 8px 0;
    padding-left: 24px;
}

.message-content li {
    margin: 4px 0;
}

.message-content table {
    border-collapse: collapse;
    margin: 12px 0;
    width: 100%;
}
.message-content th, .message-content td {
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    text-align: left;
}
.message-content th {
    background: var(--bg-input);
}


/* ============================================================
   CODE BLOCKS
   ============================================================ */

.message-content pre {
    position: relative;
    margin: 12px 0;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--code-border);
    box-shadow: var(--shadow-sm);
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 12px;
    background: var(--code-header-bg);
    font-size: 12px;
    font-family: var(--font-mono);
    color: var(--text-muted);
    border-bottom: 1px solid var(--code-border);
}

.btn-copy-code {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 12px;
    font-family: var(--font-ui);
    padding: 2px 8px;
    border-radius: 4px;
    opacity: 0;
    transition: all var(--transition-speed) var(--easing);
}
.message-content pre:hover .btn-copy-code {
    opacity: 1;
}
.btn-copy-code:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.message-content pre code {
    display: block;
    padding: 12px 16px;
    background: var(--code-bg);
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.5;
}

.message-content code {
    background: var(--code-bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 13px;
    border: 1px solid var(--code-border);
}
.message-content pre code {
    padding: 12px 16px;
    border-radius: 0;
    border: none;
}


/* ============================================================
   MESSAGE ACTIONS
   ============================================================ */

.message-actions {
    margin-top: 8px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity var(--transition-speed) var(--easing);
}
.message:hover .message-actions {
    opacity: 1;
}

.btn-action-icon {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-family: var(--font-ui);
    transition: all var(--transition-speed) var(--easing);
}
.btn-action-icon:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
    transform: scale(1.05);
}

.btn-copy-message {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 12px;
    font-family: var(--font-ui);
    padding: 4px 8px;
    border-radius: 4px;
    transition: all var(--transition-speed) var(--easing);
}
.btn-copy-message:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}


/* ============================================================
   MESSAGE EDIT
   ============================================================ */

.message-edit-textarea {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--accent);
    border-radius: 8px;
    font-size: 15px;
    line-height: 1.6;
    font-family: var(--font-ui);
    resize: vertical;
    min-height: 60px;
    outline: none;
    box-shadow: var(--input-glow);
}
.message-edit-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    justify-content: flex-end;
}
.message-edit-actions .btn-modal-save,
.message-edit-actions .btn-modal-cancel {
    padding: 6px 14px;
    font-size: 12px;
}


/* ============================================================
   TOOL CALLS
   ============================================================ */

.tool-call {
    margin: 8px 0;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-tool-call);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.tool-call summary {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
    list-style: none;
    transition: background var(--transition-speed) var(--easing);
}
.tool-call summary:hover {
    background: var(--bg-hover);
}
.tool-call summary::-webkit-details-marker {
    display: none;
}
.tool-call summary::before {
    content: '\25B6 ';
    font-size: 10px;
    margin-right: 6px;
    display: inline-block;
    transition: transform var(--transition-speed) var(--easing);
}
.tool-call[open] summary::before {
    transform: rotate(90deg);
}
.tool-call .tool-content {
    padding: 8px 12px;
    border-top: 1px solid var(--border-color);
    font-size: 13px;
}
.tool-call .tool-content pre {
    margin: 4px 0;
}
.tool-call.tool-status-success summary::after {
    content: '\2713';
    color: #22c55e;
    margin-left: 6px;
    font-size: 12px;
}
.tool-call.tool-status-error summary::after {
    content: '\2717';
    color: var(--error);
    margin-left: 6px;
    font-size: 12px;
}
.tool-call.tool-status-error {
    border-color: rgba(239, 68, 68, 0.3);
}
.tool-call .tool-spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid var(--text-muted);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-left: 8px;
    vertical-align: middle;
}


/* ============================================================
   ATTACHMENTS
   ============================================================ */

.message-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}
.attachment-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--bg-input);
    border-radius: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}
.attachment-chip img {
    max-width: 120px;
    max-height: 80px;
    border-radius: 4px;
}


/* ============================================================
   THINKING INDICATOR
   ============================================================ */

.thinking-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 0;
    color: var(--text-muted);
    font-size: 13px;
}
.thinking-dot {
    width: 6px;
    height: 6px;
    background: var(--accent);
    border-radius: 50%;
    animation: pulse 1.4s infinite;
}
.thinking-dot:nth-child(2) { animation-delay: 0.2s; }
.thinking-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes pulse {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

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


/* ============================================================
   INPUT AREA
   ============================================================ */

.input-area {
    border-top: 1px solid var(--border-color);
    padding: 16px 20px;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

.attachment-previews {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}
.attachment-previews:empty {
    display: none;
    margin: 0;
}

.attachment-preview {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}
.attachment-preview .remove-attachment {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    padding: 0 2px;
    transition: color var(--transition-speed) var(--easing);
}
.attachment-preview .remove-attachment:hover {
    color: var(--error);
}
.attachment-preview img {
    max-width: 48px;
    max-height: 32px;
    border-radius: 3px;
}

.input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: transparent;
    border-radius: 0;
    padding: 8px 4px;
    border: none;
    border-bottom: 1px solid #334155;
    transition: border-color var(--transition-speed) var(--easing),
                box-shadow var(--transition-speed) var(--easing);
}
.input-row:focus-within {
    border-bottom-color: var(--accent);
    box-shadow: 0 1px 0 0 var(--accent);
}

#message-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 15px;
    line-height: 1.5;
    resize: none;
    outline: none;
    max-height: 200px;
    font-family: var(--font-ui);
}
#message-input::placeholder {
    color: var(--text-muted);
}

.btn-attach, .btn-send, .btn-stop {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all var(--transition-speed) var(--easing);
}
.btn-attach:hover {
    color: var(--text-primary);
    transform: scale(1.05);
}
.btn-send {
    color: var(--accent);
}
.btn-send:hover {
    color: var(--accent-hover);
    transform: scale(1.05);
    filter: drop-shadow(0 0 8px var(--accent-glow));
}
.btn-send:disabled {
    color: var(--text-muted);
    cursor: default;
    transform: none;
    filter: none;
}
.btn-stop {
    color: var(--error);
}
.btn-stop:hover {
    color: #dc2626;
}


/* ============================================================
   ERRORS & LOADING
   ============================================================ */

.error-message {
    padding: 8px 12px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--error);
    border-radius: 6px;
    color: var(--error);
    font-size: 13px;
    margin-top: 8px;
}

.btn-retry {
    background: none;
    border: 1px solid var(--error);
    color: var(--error);
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-family: var(--font-ui);
    margin-top: 6px;
    transition: background var(--transition-speed) var(--easing);
}
.btn-retry:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* --- Approval Prompt --- */
.approval-prompt {
    display: flex;
    gap: 12px;
    padding: 14px 16px;
    margin: 12px 0;
    background: rgba(234, 179, 8, 0.06);
    border: 1px solid rgba(234, 179, 8, 0.3);
    border-radius: 8px;
    font-size: 13px;
    animation: approval-slide-in 0.2s var(--easing);
}
@keyframes approval-slide-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.approval-icon {
    flex-shrink: 0;
    color: #eab308;
    padding-top: 2px;
}
.approval-body {
    flex: 1;
    min-width: 0;
}
.approval-title {
    font-weight: 600;
    color: #eab308;
    margin-bottom: 4px;
}
.approval-reason {
    color: var(--text-secondary);
    margin-bottom: 8px;
    word-break: break-word;
}
.approval-details code {
    display: inline-block;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-primary);
    word-break: break-all;
    margin-bottom: 8px;
}
.approval-actions {
    display: flex;
    gap: 8px;
}
.approval-btn {
    padding: 6px 16px;
    border-radius: 6px;
    font-family: var(--font-ui);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: background var(--transition-speed) var(--easing), opacity var(--transition-speed);
}
.approval-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.approval-deny {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}
.approval-deny:hover:not(:disabled) {
    background: rgba(239, 68, 68, 0.25);
}
.approval-allow {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
    border: 1px solid rgba(34, 197, 94, 0.3);
}
.approval-allow:hover:not(:disabled) {
    background: rgba(34, 197, 94, 0.25);
}
.approval-session {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
    border: 1px solid rgba(59, 130, 246, 0.3);
}
.approval-session:hover:not(:disabled) {
    background: rgba(59, 130, 246, 0.25);
}
.approval-always {
    background: rgba(168, 85, 247, 0.15);
    color: #a855f7;
    border: 1px solid rgba(168, 85, 247, 0.3);
}
.approval-always:hover:not(:disabled) {
    background: rgba(168, 85, 247, 0.25);
}
.approval-status {
    font-size: 12px;
    font-weight: 500;
    padding: 4px 0;
}
.approval-allowed .approval-status {
    color: #22c55e;
}
.approval-denied .approval-status {
    color: #ef4444;
}
.approval-allowed {
    border-color: rgba(34, 197, 94, 0.2);
    background: rgba(34, 197, 94, 0.04);
}
.approval-denied {
    border-color: rgba(239, 68, 68, 0.2);
    background: rgba(239, 68, 68, 0.04);
}

.loading-spinner {
    display: flex;
    justify-content: center;
    padding: 20px;
}
.loading-spinner::after {
    content: '';
    width: 24px;
    height: 24px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}


/* ============================================================
   OFFLINE BANNER
   ============================================================ */

.offline-banner {
    padding: 8px 16px;
    background: rgba(239, 68, 68, 0.15);
    border-bottom: 1px solid var(--error);
    color: var(--error);
    font-size: 13px;
    text-align: center;
}


/* ============================================================
   DRAG & DROP
   ============================================================ */

.drag-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--accent-subtle);
    border: 3px dashed var(--accent);
    display: none;
    z-index: 100;
    pointer-events: none;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--accent);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}
.drag-overlay.active {
    display: flex;
}


/* ============================================================
   RENAME INPUT
   ============================================================ */

.rename-input {
    background: var(--bg-input);
    border: 1px solid var(--accent);
    color: var(--text-primary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
    font-family: var(--font-ui);
    width: 100%;
    outline: none;
    box-shadow: var(--input-glow);
}


/* ============================================================
   EMPTY & PLEASE-WAIT STATES
   ============================================================ */

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

.please-wait {
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
    padding: 4px;
    animation: fadeInOut 2s ease-in-out;
}

@keyframes fadeInOut {
    0%, 100% { opacity: 0; }
    20%, 80% { opacity: 1; }
}


/* ============================================================
   MODALS
   ============================================================ */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    -webkit-backdrop-filter: var(--modal-backdrop-blur);
    backdrop-filter: var(--modal-backdrop-blur);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    width: 520px;
    max-width: 90vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.2s var(--easing);
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(-8px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}
.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
}
.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 20px;
    padding: 0 4px;
    border-radius: 4px;
    transition: all var(--transition-speed) var(--easing);
}
.modal-close:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}
.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}
.setting-group {
    margin-bottom: 20px;
}
.setting-group:last-child {
    margin-bottom: 0;
}
.setting-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.setting-group select,
.setting-group textarea,
.setting-group input[type="text"] {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    font-family: var(--font-ui);
    outline: none;
    transition: border-color var(--transition-speed) var(--easing),
                box-shadow var(--transition-speed) var(--easing);
}
.setting-group select:focus,
.setting-group textarea:focus,
.setting-group input[type="text"]:focus {
    border-color: var(--accent);
    box-shadow: var(--input-glow);
}
.setting-group textarea {
    resize: vertical;
    min-height: 80px;
}
.setting-hint {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}
.setting-group select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
    cursor: pointer;
}
.setting-group select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 8px;
}
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid var(--border-color);
}
.btn-modal-cancel {
    padding: 8px 16px;
    background: var(--bg-input);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-family: var(--font-ui);
    transition: all var(--transition-speed) var(--easing);
}
.btn-modal-cancel:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.btn-modal-save {
    padding: 8px 16px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font-ui);
    transition: all var(--transition-speed) var(--easing);
}
.btn-modal-save:hover {
    background: var(--accent-hover);
    box-shadow: 0 0 16px var(--accent-glow);
}


/* ============================================================
   THEME PICKER (in Settings Modal)
   ============================================================ */

.theme-picker {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-top: 8px;
}
.theme-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 12px 8px;
    background: var(--bg-input);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    cursor: pointer;
    transition: all var(--transition-speed) var(--easing);
}
.theme-card:hover {
    border-color: var(--text-muted);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.theme-card.active {
    border-color: var(--accent);
    box-shadow: 0 0 12px var(--accent-glow);
}
.theme-preview {
    display: flex;
    gap: 3px;
    width: 100%;
    height: 24px;
    border-radius: 4px;
    overflow: hidden;
}
.theme-preview span {
    flex: 1;
    border-radius: 3px;
}
.theme-card-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: capitalize;
}
.theme-card.active .theme-card-label {
    color: var(--accent);
}


/* ============================================================
   FILE BROWSER (Add Database modal)
   ============================================================ */

.browse-path-row {
    display: flex;
    gap: 8px;
}
.browse-path-row input {
    flex: 1;
}
.btn-browse {
    padding: 8px 16px;
    background: var(--bg-hover);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-family: var(--font-ui);
    white-space: nowrap;
    transition: all var(--transition-speed) var(--easing);
}
.btn-browse:hover {
    background: var(--bg-active);
    color: var(--text-primary);
    border-color: var(--accent);
}

.browse-panel {
    margin-top: 8px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    max-height: 280px;
    display: flex;
    flex-direction: column;
}
.browse-current {
    padding: 8px 12px;
    font-size: 12px;
    font-family: var(--font-mono);
    color: var(--text-secondary);
    background: var(--bg-input);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.browse-entries {
    overflow-y: auto;
    flex: 1;
}
.browse-entry {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background var(--transition-speed) var(--easing);
}
.browse-entry:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.browse-entry-icon {
    flex-shrink: 0;
    width: 16px;
    text-align: center;
    opacity: 0.7;
}
.browse-entry.is-dir .browse-entry-icon {
    color: var(--accent);
    opacity: 1;
}
.browse-entry.is-file .browse-entry-icon {
    color: var(--warning);
}
.browse-entry-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.browse-up {
    font-weight: 500;
    color: var(--text-muted);
}


/* ============================================================
   MODEL SELECTOR
   ============================================================ */

.model-selector {
    position: relative;
    font-size: 13px;
}
.model-selector-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-family: var(--font-ui);
    transition: all var(--transition-speed) var(--easing);
}
.model-selector-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
    border-color: var(--border-color);
}
.model-selector-btn.active {
    color: var(--text-primary);
    background: var(--bg-input);
    border-color: var(--border-color);
}
.model-selector-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 200px;
    max-height: 320px;
    overflow-y: auto;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    z-index: 50;
    padding: 4px;
}
.model-selector-dropdown.open {
    display: block;
    animation: dropdownIn 0.15s var(--easing);
}

@keyframes dropdownIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.model-selector-item {
    padding: 7px 10px;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background var(--transition-speed) var(--easing);
}
.model-selector-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.model-selector-item.selected {
    color: var(--accent);
}
.model-selector-item.selected::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    background: var(--accent);
    border-radius: 50%;
    margin-right: 8px;
    vertical-align: middle;
}


/* ============================================================
   SIDEBAR SECTIONS & PROJECTS
   ============================================================ */

.sidebar-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    margin-bottom: 6px;
}
.sidebar-section-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
}
.btn-section-action {
    display: flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-family: var(--font-ui);
    transition: color var(--transition-speed) var(--easing),
                background var(--transition-speed) var(--easing);
}
.btn-section-action:hover {
    color: var(--accent);
    background: var(--bg-hover);
}

/* --- Database Selector --- */

.sidebar-databases {
    padding: 4px 0 0;
    border-bottom: 1px solid rgba(197, 160, 89, 0.15);
    margin-bottom: 4px;
}

.db-list {
    padding: 0 8px;
    max-height: 120px;
    overflow-y: auto;
}

.db-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
    transition: all var(--transition-speed) var(--easing);
}

.db-item:hover {
    background: var(--bg-hover);
}

.db-item.active {
    background: var(--bg-active);
    color: var(--accent);
    font-weight: 500;
}

.db-item-icon {
    display: flex;
    flex-shrink: 0;
    opacity: 0.6;
}

.db-item.active .db-item-icon {
    opacity: 1;
    color: var(--accent);
}

.db-item-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.db-item-remove {
    opacity: 0;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
    padding: 0 2px;
    line-height: 1;
    transition: opacity 0.15s, color 0.15s;
}

.db-item:hover .db-item-remove {
    opacity: 0.6;
}

.db-item-remove:hover {
    opacity: 1 !important;
    color: var(--danger, #ef4444);
}

/* --- Projects --- */

.sidebar-projects {
    padding: 4px 0 0;
    border-bottom: 1px solid rgba(197, 160, 89, 0.15);
    margin-bottom: 4px;
}

.project-list {
    padding: 0 8px;
    max-height: 120px;
    overflow-y: auto;
}
.project-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
    transition: all var(--transition-speed) var(--easing);
}
.project-item:hover {
    background: var(--bg-hover);
}
.project-item.active {
    background: var(--bg-active);
    color: var(--text-primary);
}
.project-item-icon {
    flex-shrink: 0;
    color: var(--text-muted);
    display: flex;
}
.project-item.active .project-item-icon {
    color: var(--accent);
}
.project-item-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.project-all {
    color: var(--text-muted);
    font-size: 12px;
}
.project-all.active {
    color: var(--text-primary);
}
.project-empty {
    padding: 8px 12px;
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
}

.project-active-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px 8px;
    gap: 8px;
}
.project-active-info {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--accent);
    font-size: 12px;
    font-weight: 500;
    min-width: 0;
}
.project-active-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.project-active-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}
.btn-project-action {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition-speed) var(--easing),
                background var(--transition-speed) var(--easing);
}
.btn-project-action:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}
.btn-project-action-danger:hover {
    color: var(--error);
}


/* ============================================================
   RAW TOGGLE
   ============================================================ */

.btn-raw-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-family: var(--font-ui);
    transition: all var(--transition-speed) var(--easing);
    margin-left: auto;
}
.btn-raw-toggle:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
    border-color: var(--border-color);
}
.btn-raw-toggle.active {
    color: var(--accent);
    background: var(--accent-subtle);
    border-color: var(--accent);
}


/* ============================================================
   COMMAND PALETTE
   ============================================================ */

.palette-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    z-index: 300;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 15vh;
}
.palette-modal {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    width: 520px;
    max-width: 90vw;
    max-height: 400px;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    overflow: hidden;
    animation: paletteIn 0.2s var(--easing-spring);
}

@keyframes paletteIn {
    from { opacity: 0; transform: scale(0.95) translateY(-12px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.palette-input {
    padding: 14px 16px;
    background: transparent;
    color: var(--text-primary);
    border: none;
    border-bottom: 1px solid var(--border-color);
    font-size: 15px;
    font-family: var(--font-ui);
    outline: none;
}
.palette-input::placeholder {
    color: var(--text-muted);
}
.palette-results {
    overflow-y: auto;
    flex: 1;
    padding: 4px;
}
.palette-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: background var(--transition-speed) var(--easing);
}
.palette-item:hover,
.palette-item.active {
    background: var(--bg-hover);
}
.palette-icon {
    font-size: 14px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}
.palette-label {
    flex: 1;
    font-size: 14px;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.palette-hint {
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
}
.palette-empty {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
    font-size: 13px;
}


/* ============================================================
   AURORA BACKGROUND ANIMATION
   ============================================================ */

[data-theme="aurora"] .app-container::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 0;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(197, 160, 89, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(59, 130, 246, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(16, 185, 129, 0.05) 0%, transparent 50%);
    animation: auroraShift 20s ease-in-out infinite alternate;
}

@keyframes auroraShift {
    0% {
        background:
            radial-gradient(ellipse at 20% 50%, rgba(197, 160, 89, 0.08) 0%, transparent 50%),
            radial-gradient(ellipse at 80% 20%, rgba(59, 130, 246, 0.06) 0%, transparent 50%),
            radial-gradient(ellipse at 50% 80%, rgba(16, 185, 129, 0.05) 0%, transparent 50%);
    }
    33% {
        background:
            radial-gradient(ellipse at 40% 30%, rgba(197, 160, 89, 0.06) 0%, transparent 50%),
            radial-gradient(ellipse at 70% 70%, rgba(59, 130, 246, 0.08) 0%, transparent 50%),
            radial-gradient(ellipse at 20% 60%, rgba(16, 185, 129, 0.06) 0%, transparent 50%);
    }
    66% {
        background:
            radial-gradient(ellipse at 60% 70%, rgba(197, 160, 89, 0.07) 0%, transparent 50%),
            radial-gradient(ellipse at 30% 30%, rgba(59, 130, 246, 0.05) 0%, transparent 50%),
            radial-gradient(ellipse at 80% 50%, rgba(16, 185, 129, 0.07) 0%, transparent 50%);
    }
    100% {
        background:
            radial-gradient(ellipse at 50% 40%, rgba(197, 160, 89, 0.08) 0%, transparent 50%),
            radial-gradient(ellipse at 60% 60%, rgba(59, 130, 246, 0.07) 0%, transparent 50%),
            radial-gradient(ellipse at 30% 80%, rgba(16, 185, 129, 0.06) 0%, transparent 50%);
    }
}

[data-theme="aurora"] .sidebar {
    border-right-color: transparent;
    border-image: linear-gradient(to bottom, rgba(197, 160, 89, 0.3), rgba(59, 130, 246, 0.2), rgba(16, 185, 129, 0.2)) 1;
}

[data-theme="aurora"] .message.user .message-content {
    border-image: linear-gradient(to bottom, #C5A059, #3B82F6) 1;
    border-left-style: solid;
    border-left-width: 3px;
}

[data-theme="aurora"] ::-webkit-scrollbar-thumb {
    background: linear-gradient(to bottom, #C5A059, #3B82F6);
    border-radius: 3px;
}


/* ============================================================
   DAWN LIGHT THEME OVERRIDES
   ============================================================ */

[data-theme="dawn"] .message.user .message-content {
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06), 0 0 1px rgba(0, 0, 0, 0.04);
}

/* Light-mode highlight.js overrides for code blocks */
[data-theme="dawn"] .hljs {
    color: #383a42;
    background: #f6f4f0;
}
[data-theme="dawn"] .hljs-comment,
[data-theme="dawn"] .hljs-quote {
    color: #a0a1a7;
    font-style: italic;
}
[data-theme="dawn"] .hljs-keyword,
[data-theme="dawn"] .hljs-selector-tag,
[data-theme="dawn"] .hljs-subst {
    color: #a626a4;
}
[data-theme="dawn"] .hljs-number,
[data-theme="dawn"] .hljs-literal,
[data-theme="dawn"] .hljs-variable,
[data-theme="dawn"] .hljs-template-variable,
[data-theme="dawn"] .hljs-tag .hljs-attr {
    color: #986801;
}
[data-theme="dawn"] .hljs-string,
[data-theme="dawn"] .hljs-doctag {
    color: #50a14f;
}
[data-theme="dawn"] .hljs-title,
[data-theme="dawn"] .hljs-section,
[data-theme="dawn"] .hljs-selector-id {
    color: #4078f2;
    font-weight: bold;
}
[data-theme="dawn"] .hljs-type,
[data-theme="dawn"] .hljs-class .hljs-title {
    color: #c18401;
}
[data-theme="dawn"] .hljs-tag,
[data-theme="dawn"] .hljs-name,
[data-theme="dawn"] .hljs-attribute {
    color: #e45649;
}
[data-theme="dawn"] .hljs-regexp,
[data-theme="dawn"] .hljs-link {
    color: #50a14f;
}
[data-theme="dawn"] .hljs-symbol,
[data-theme="dawn"] .hljs-bullet {
    color: #4078f2;
}
[data-theme="dawn"] .hljs-built_in,
[data-theme="dawn"] .hljs-builtin-name {
    color: #c18401;
}
[data-theme="dawn"] .hljs-meta {
    color: #4078f2;
}
[data-theme="dawn"] .hljs-deletion {
    background: #fdd;
}
[data-theme="dawn"] .hljs-addition {
    background: #dfd;
}
[data-theme="dawn"] .hljs-emphasis {
    font-style: italic;
}
[data-theme="dawn"] .hljs-strong {
    font-weight: bold;
}

/* Dawn paper texture */
[data-theme="dawn"] .app-container {
    background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.015'/%3E%3C/svg%3E");
}


/* ============================================================
   MOBILE SIDEBAR OVERLAY
   ============================================================ */

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9;
    opacity: 0;
    transition: opacity 0.25s var(--easing);
}
.sidebar-overlay.active {
    display: block;
    opacity: 1;
}


/* ============================================================
   RESPONSIVE DESIGN
   ============================================================ */

/* Large desktop */
@media (min-width: 1400px) {
    .sidebar {
        width: 300px;
        min-width: 300px;
    }
    .message {
        max-width: 900px;
    }
    .input-area {
        max-width: 900px;
    }
}

/* Tablet */
@media (max-width: 1024px) and (min-width: 769px) {
    .sidebar {
        width: 240px;
        min-width: 240px;
    }
    .message {
        max-width: 100%;
    }
    .input-area {
        max-width: 100%;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 280px;
        min-width: 280px;
        transform: translateX(-100%);
        transition: transform 0.25s var(--easing);
        z-index: 20;
        box-shadow: none;
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }

    .mobile-menu-btn {
        display: flex;
    }

    .message {
        max-width: 100%;
        padding-left: 12px;
        padding-right: 12px;
    }
    .input-area {
        max-width: 100%;
        padding: 12px;
    }

    .palette-modal {
        width: 95vw;
    }
    .modal {
        width: 95vw;
    }

    .theme-picker {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ============================================================
   MCP SERVER MODAL
   ============================================================ */

.mcp-server-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
    gap: 12px;
}
.mcp-server-row:last-child {
    border-bottom: none;
}

.mcp-server-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    flex: 1;
}

.mcp-server-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.mcp-status-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 500;
    padding: 1px 8px;
    border-radius: 10px;
    text-transform: capitalize;
}
.mcp-status-connected {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}
.mcp-status-error {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
}
.mcp-status-disconnected {
    background: rgba(100, 100, 100, 0.15);
    color: var(--text-muted);
}

.mcp-server-detail {
    font-size: 12px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mcp-server-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.btn-mcp-action {
    padding: 5px 12px;
    font-size: 12px;
    font-family: var(--font-ui);
    border-radius: 6px;
    cursor: pointer;
    border: 1px solid var(--border-color);
    background: var(--bg-input);
    color: var(--text-secondary);
    transition: all var(--transition-speed) var(--easing);
}
.btn-mcp-action:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--text-muted);
}
.btn-mcp-connect {
    background: var(--accent-subtle);
    color: var(--accent);
    border-color: var(--accent);
}
.btn-mcp-connect:hover {
    background: var(--accent);
    color: #fff;
}
.btn-mcp-danger {
    color: var(--error);
    border-color: transparent;
}
.btn-mcp-danger:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--error);
}


/* ============================================================
   CANVAS PANEL
   ============================================================ */

.canvas-panel {
    width: 50%;
    min-width: 400px;
    max-width: 60%;
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--border-color);
    background: var(--bg-secondary);
    z-index: 5;
}

.chat-main.with-canvas {
    flex: 1;
    min-width: 400px;
}

.canvas-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    gap: 8px;
}
.canvas-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: 0.02em;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.canvas-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.canvas-mode-toggle {
    display: flex;
    background: var(--bg-input);
    border-radius: 6px;
    padding: 2px;
    gap: 2px;
}
.canvas-mode-btn {
    padding: 3px 10px;
    font-size: 11px;
    font-family: var(--font-ui);
    font-weight: 500;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-muted);
    background: transparent;
    transition: all 0.12s var(--easing);
}
.canvas-mode-btn.active {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.canvas-mode-btn:hover:not(.active) {
    color: var(--text-secondary);
}
.canvas-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 18px;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.12s var(--easing);
    flex-shrink: 0;
}
.canvas-close:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.canvas-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.canvas-cm-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-primary);
}
.canvas-cm-wrap .cm-editor {
    flex: 1;
    background: var(--bg-primary);
    color: var(--text-primary);
}

.canvas-preview {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.7;
}
.canvas-preview h1, .canvas-preview h2, .canvas-preview h3,
.canvas-preview h4, .canvas-preview h5, .canvas-preview h6 {
    margin: 1.2em 0 0.5em;
    color: var(--text-primary);
}
.canvas-preview h1 { font-size: 1.6em; }
.canvas-preview h2 { font-size: 1.3em; }
.canvas-preview h3 { font-size: 1.1em; }
.canvas-preview p { margin: 0.6em 0; }
.canvas-preview ul, .canvas-preview ol {
    margin: 0.5em 0;
    padding-left: 24px;
}
.canvas-preview li { margin: 0.25em 0; }
.canvas-preview pre {
    margin: 0.8em 0;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--code-border);
}
.canvas-preview pre code {
    display: block;
    padding: 12px 16px;
    background: var(--code-bg);
    font-family: var(--font-mono);
    font-size: 13px;
    overflow-x: auto;
}
.canvas-preview code {
    background: var(--code-bg);
    padding: 2px 5px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 13px;
    border: 1px solid var(--code-border);
}
.canvas-preview pre code {
    border: none;
    border-radius: 0;
}
.canvas-preview blockquote {
    border-left: 3px solid var(--accent);
    margin: 0.8em 0;
    padding: 4px 16px;
    color: var(--text-secondary);
}
.canvas-preview table {
    border-collapse: collapse;
    width: 100%;
    margin: 0.8em 0;
}
.canvas-preview th, .canvas-preview td {
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    text-align: left;
}
.canvas-preview th {
    background: var(--bg-input);
    font-weight: 600;
}

.canvas-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 8px 16px;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
    gap: 8px;
}
#canvas-save {
    padding: 6px 16px;
    background: var(--accent);
    color: #000;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.12s var(--easing);
    font-family: var(--font-ui);
}
#canvas-save:hover {
    background: var(--accent-hover);
}
#canvas-save:disabled {
    opacity: 0.4;
    cursor: default;
}

.btn-canvas-toggle {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
    font-family: var(--font-ui);
    font-size: 12px;
    transition: all 0.12s var(--easing);
}
.btn-canvas-toggle:hover {
    color: var(--text-primary);
    border-color: var(--text-muted);
}
.btn-canvas-toggle.active {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-subtle);
}

/* Responsive: narrow screens -> canvas overlays */
@media (max-width: 900px) {
    .canvas-panel {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: 50%;
        min-width: 320px;
        z-index: 25;
        box-shadow: var(--shadow-lg);
    }
}
@media (max-width: 768px) {
    .canvas-panel {
        width: 100%;
        min-width: 100%;
    }
}


/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-family: var(--font-ui);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    animation: toastIn 0.2s var(--easing);
    pointer-events: auto;
}

.toast-fade-out {
    animation: toastOut 0.3s var(--easing) forwards;
}

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

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