/* ========== FONTS ========== */
@font-face {
    font-family: 'Waldenburg';
    src: url('./fonts/KMR-Waldenburg-Normal.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Waldenburg';
    src: url('./fonts/KMR-Waldenburg-Fett.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

/* ========== CLAUDE-INSPIRED DESIGN ========== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg-primary: #212121;
    --bg-secondary: #171717;
    --bg-tertiary: #2a2a2a;
    --bg-hover: #333333;
    --border: #2f2f2f;
    --border-light: #3d3d3d;
    --text-primary: #e0e0e0;
    --text-secondary: #b4b4b4;
    --text-muted: #777777;
    --accent: #0074ba;
    --accent-dim: rgba(0, 116, 186, 0.12);
    --accent-med: rgba(0, 116, 186, 0.22);
    --accent-light: #2196F3;
    --success: #81c995;
    --error: #f28b82;
    --surface: #1a1a1a;
    --shadow: rgba(0, 0, 0, 0.3);
    --shadow-strong: rgba(0, 0, 0, 0.5);
    --overlay: rgba(0, 0, 0, 0.65);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;
}

/* ========== LIGHT MODE ========== */
body.light-mode {
    --bg-primary: #ffffff;
    --bg-secondary: #f7f7f8;
    --bg-tertiary: #ececec;
    --bg-hover: #e5e5e5;
    --border: #d9d9d9;
    --border-light: #c4c4c4;
    --text-primary: #1a1a1a;
    --text-secondary: #555555;
    --text-muted: #888888;
    --accent: #0074ba;
    --accent-dim: rgba(0, 116, 186, 0.08);
    --accent-med: rgba(0, 116, 186, 0.15);
    --accent-light: #1976d2;
    --success: #2e7d32;
    --error: #d32f2f;
    --surface: #f0f0f0;
    --shadow: rgba(0, 0, 0, 0.08);
    --shadow-strong: rgba(0, 0, 0, 0.15);
    --overlay: rgba(0, 0, 0, 0.4);
}

body {
    font-family: 'Waldenburg', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    display: flex;
    overflow: hidden;
    line-height: 1.6;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

body.resizing { cursor: col-resize !important; user-select: none !important; }
body.resizing * { cursor: col-resize !important; user-select: none !important; pointer-events: none !important; }
body.resizing .builder-resize { pointer-events: auto !important; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ========== SIDEBAR ========== */
.sidebar {
    width: 260px;
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width 0.25s cubic-bezier(.4,0,.2,1);
    border-right: 1px solid var(--border);
}

.sidebar.minimized { width: 60px; }
.sidebar.minimized .sidebar-content,
.sidebar.minimized .logo-text,
.sidebar.minimized .logo,
.sidebar.minimized .theme-toggle,
.sidebar.minimized .new-chat-btn { display: none; }
.sidebar.minimized .sidebar-header { justify-content: center; padding: 12px 10px; }
.sidebar.minimized .toggle-sidebar-btn { margin-left: 0; }

.sidebar-mini-actions {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 0;
}
.sidebar.minimized .sidebar-mini-actions { display: flex; }

.mini-action-btn {
    width: 38px; height: 38px;
    background: transparent; border: none;
    color: var(--text-muted); cursor: pointer;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; transition: all 0.2s; position: relative;
}
.mini-action-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.mini-action-btn.accent { color: var(--accent); background: var(--accent-dim); }
.mini-action-btn.accent:hover { background: var(--accent-med); }

.mini-action-btn .mini-tooltip {
    display: none; position: absolute;
    left: calc(100% + 10px); top: 50%; transform: translateY(-50%);
    background: var(--bg-tertiary); border: 1px solid var(--border-light);
    border-radius: var(--radius-md); padding: 8px 12px; width: 200px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.5); z-index: 1200;
    pointer-events: none; white-space: normal; text-align: left;
}
.mini-action-btn .mini-tooltip::before {
    content: ''; position: absolute; right: 100%; top: 50%; transform: translateY(-50%);
    border: 6px solid transparent; border-right-color: var(--border-light);
}
.mini-action-btn .mini-tooltip::after {
    content: ''; position: absolute; right: calc(100% - 1px); top: 50%; transform: translateY(-50%);
    border: 6px solid transparent; border-right-color: var(--bg-tertiary);
}
.mini-tooltip-title { font-size: 12px; font-weight: 600; color: var(--text-primary); margin-bottom: 4px; }
.mini-tooltip-desc { font-size: 11px; color: var(--text-secondary); line-height: 1.5; }
.mini-action-btn:hover .mini-tooltip { display: block; }

.sidebar.minimized .toggle-sidebar-btn { position: relative; }
.sidebar-toggle-tooltip {
    display: none; position: absolute;
    left: calc(100% + 10px); top: 50%; transform: translateY(-50%);
    background: var(--bg-tertiary); border: 1px solid var(--border-light);
    border-radius: var(--radius-md); padding: 8px 12px; width: 200px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.5); z-index: 1200;
    pointer-events: none; white-space: normal; text-align: left;
}
.sidebar-toggle-tooltip::before {
    content: ''; position: absolute; right: 100%; top: 50%; transform: translateY(-50%);
    border: 6px solid transparent; border-right-color: var(--border-light);
}
.sidebar-toggle-tooltip::after {
    content: ''; position: absolute; right: calc(100% - 1px); top: 50%; transform: translateY(-50%);
    border: 6px solid transparent; border-right-color: var(--bg-tertiary);
}
.sidebar.minimized .toggle-sidebar-btn:hover .sidebar-toggle-tooltip { display: block; }

.mini-divider { width: 24px; height: 1px; background: var(--border); margin: 2px 0; }

.sidebar-header {
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo {
    width: 28px; height: 28px;
    background: var(--accent);
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 14px;
}

.logo-text {
    font-weight: 600;
    font-size: 16px;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

.logo-icon { font-size: 14px; color: #fff; }

.new-chat-full-btn {
    margin: 8px 0 4px;
    padding: 10px 14px;
    background: var(--accent);
    border: 1px solid var(--accent);
    border-radius: var(--radius-md);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    transition: all 0.2s;
    width: 100%;
}
.new-chat-full-btn:hover { opacity: 0.9; }
.new-chat-full-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.new-chat-full-btn .ti { font-size: 17px; }
.sidebar.minimized .new-chat-full-btn { display: none; }

.sidebar-nav-btns {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 2px 0 8px;
}
.sidebar-nav-btn {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    transition: all 0.2s;
}
.sidebar-nav-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.sidebar-nav-btn.active { background: var(--accent-dim); color: var(--accent); border-color: var(--accent-med); }
.sidebar-nav-btn .ti { font-size: 17px; flex-shrink: 0; }
.sidebar.minimized .sidebar-nav-btns { display: none; }

.sidebar-section-grow { flex: 1; overflow: hidden; display: flex; flex-direction: column; }
.sidebar-section-grow .section-list { flex: 1; max-height: none; }

.sidebar-section-bottom { border-top: 1px solid var(--border); margin-top: auto; flex-shrink: 0; }
.sidebar-section-bottom .section-list { max-height: 200px; }

/* Tabler icon sizing */
.ti { font-size: 16px; line-height: 1; }
.welcome-icon .ti { font-size: 28px; color: #fff; }
.search-box .ti { font-size: 16px; color: var(--text-muted); }
.input-btn .ti { font-size: 18px; }
.send-btn .ti { font-size: 16px; }
.header-btn .ti { font-size: 14px; }
.builder-header-btn .ti { font-size: 14px; }
.modal-header .ti { font-size: 18px; }
.modal-close .ti { font-size: 18px; }
.menu-btn .ti { font-size: 20px; }
.list-item-delete .ti { font-size: 12px; }
.file-menu-item .ti { font-size: 16px; }
.quick-action .ti { font-size: 14px; }
.section-header .ti { font-size: 14px; }
.list-item-icon.ti { font-size: 14px; }
.section-chevron.ti { font-size: 14px; transition: transform 0.2s; }
.section-header.collapsed .section-chevron.ti { transform: rotate(-90deg); }

.toggle-sidebar-btn {
    width: 32px; height: 32px;
    background: transparent; border: none;
    color: var(--text-muted); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
    font-size: 16px; margin-left: auto; transition: all 0.2s;
}
.toggle-sidebar-btn:hover { color: var(--text-primary); background: var(--bg-hover); }

.search-box {
    margin: 4px 12px 8px;
    padding: 8px 12px;
    background: var(--bg-primary);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}
.search-box:focus-within { border-color: var(--border); background: var(--bg-tertiary); }

.search-box input {
    flex: 1; background: transparent; border: none;
    color: var(--text-primary); font-size: 13px;
    outline: none; font-family: inherit;
}
.search-box input::placeholder { color: var(--text-muted); }

.sidebar-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; padding: 0 12px; }

.sidebar-section { border-bottom: none; }

.section-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 16px; cursor: pointer;
    color: var(--text-muted);
    font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.8px;
}
.section-header:hover { color: var(--text-secondary); }
.section-header.collapsed .section-chevron { transform: rotate(-90deg); }

.section-list { max-height: 250px; overflow-y: auto; padding: 0 8px 8px; }
.section-list.collapsed { display: none; }

.list-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-md);
    cursor: pointer; color: var(--text-secondary);
    transition: all 0.15s; margin-bottom: 1px;
    font-size: 13px;
}
.list-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.list-item.active { background: var(--accent-dim); color: var(--accent-light); }
.list-item-icon { font-size: 14px; }
.list-item-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.list-item-delete { opacity: 0; background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 4px; font-size: 12px; }
.list-item:hover .list-item-delete { opacity: 1; }
.list-item-delete:hover { color: var(--error); }

.project-files { padding-left: 28px; margin-top: 2px; }
.file-item {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 12px;
    border-radius: var(--radius-md);
    cursor: pointer; color: var(--text-muted); font-size: 12px;
}
.file-item:hover { background: var(--bg-hover); color: var(--text-secondary); }

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

/* ========== MAIN ========== */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg-primary); overflow: hidden; }
#app { flex: 1; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }

.main-header {
    padding: 10px 20px;
    display: flex; align-items: center; gap: 12px;
    background: linear-gradient(to bottom, rgba(255,255,255,0.04), transparent);
}

.menu-btn {
    display: none;
    width: 36px; height: 36px;
    background: transparent; border: none;
    color: var(--text-secondary); cursor: pointer;
    border-radius: var(--radius-sm);
    font-size: 18px; transition: background 0.2s;
}
.menu-btn:hover { background: var(--bg-hover); }

.main-title-wrap {
    flex: 1; display: flex; align-items: center; gap: 6px; min-width: 0;
}
.main-title-project {
    font-size: 12px; font-weight: 500; color: var(--accent-light);
    text-decoration: none; white-space: nowrap; cursor: pointer;
    padding: 2px 8px; border-radius: var(--radius-sm);
    background: var(--accent-dim); display: none;
    transition: all 0.15s;
}
.main-title-project:hover { background: var(--accent); color: #fff; }
.main-title-project::after { content: '/'; margin-left: 8px; color: var(--text-muted); font-weight: 400; }
.main-title {
    font-size: 14px; font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.title-chevron-btn {
    background: none; border: 1px solid var(--border); color: var(--text-muted);
    cursor: pointer; padding: 4px 10px; font-size: 13px;
    display: flex; align-items: center; gap: 6px; flex-shrink: 0;
    border-radius: var(--radius-md); transition: all 0.15s;
    max-width: 420px; min-width: 0;
}
.title-chevron-btn:hover { color: var(--text-primary); background: var(--bg-hover); border-color: var(--border-light); }
.title-chevron-btn .title-btn-project {
    white-space: nowrap; flex-shrink: 0;
    font-size: 13px; font-weight: 500; color: var(--text-muted);
}
.title-chevron-btn .title-btn-text {
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    font-size: 13px; font-weight: 500; color: var(--text-secondary);
}
.title-chevron-btn .ti { flex-shrink: 0; font-size: 14px; }
.title-dropdown {
    position: fixed; z-index: 1000;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 6px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    min-width: 200px;
    display: none;
}
.title-dropdown.visible { display: block; }
.title-dropdown button {
    display: flex; align-items: center; gap: 10px;
    width: 100%; padding: 8px 12px;
    background: none; border: none; border-radius: var(--radius-sm);
    color: var(--text-secondary); font-size: 13px; font-family: inherit;
    cursor: pointer; transition: all 0.15s; text-align: left;
}
.title-dropdown button:hover { background: var(--bg-hover); color: var(--text-primary); }
.title-dropdown button .ti { font-size: 16px; width: 18px; }
.title-dropdown button.danger { color: var(--error); }
.title-dropdown button.danger:hover { background: rgba(242,139,130,0.1); }
.title-dropdown-sep { height: 1px; background: var(--border); margin: 4px 0; }
.project-select-search {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 12px; border: 1px solid var(--border);
    border-radius: var(--radius-md); margin-bottom: 8px;
    background: var(--bg-primary);
}
.project-select-search .ti { color: var(--text-muted); font-size: 16px; }
.project-select-search input {
    flex: 1; border: none; background: none; outline: none;
    color: var(--text-primary); font-size: 13px; font-family: inherit;
}
.project-select-search input::placeholder { color: var(--text-muted); }
.project-select-loading {
    position: absolute; inset: 0; background: rgba(0,0,0,0.5);
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
    border-radius: var(--radius-md);
}

.header-stats {
    font-size: 11px; color: var(--text-muted);
    display: flex; align-items: center; gap: 8px;
    padding: 6px 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    position: relative; cursor: pointer;
    border: 1px solid var(--border);
}
.header-stats:hover { color: var(--text-secondary); }

.stats-popover {
    display: none; position: absolute;
    top: calc(100% + 10px); right: 0;
    background: var(--bg-tertiary); border: 1px solid var(--border-light);
    border-radius: var(--radius-md); padding: 14px 16px;
    min-width: 260px; box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    z-index: 1500; pointer-events: none;
}
.stats-popover::after {
    content: ''; position: absolute; bottom: 100%; right: 16px;
    border: 7px solid transparent; border-bottom-color: var(--border-light);
}
.stats-popover::before {
    content: ''; position: absolute; bottom: calc(100% - 1px); right: 17px;
    border: 6px solid transparent; border-bottom-color: var(--bg-tertiary); z-index: 1;
}
.header-stats:hover .stats-popover { display: block; }

.stats-popover-title {
    font-size: 12px; font-weight: 600; color: var(--text-primary);
    margin-bottom: 10px; display: flex; align-items: center; gap: 6px;
}
.stats-popover-title i { color: var(--accent); font-size: 14px; }
.stats-popover-desc { font-size: 11px; color: var(--text-secondary); line-height: 1.6; margin-bottom: 12px; }
.stats-popover-rows { display: flex; flex-direction: column; gap: 6px; }
.stats-popover-row { display: flex; justify-content: space-between; align-items: center; font-size: 11px; }
.stats-popover-row .label { color: var(--text-muted); }
.stats-popover-row .value { color: var(--text-primary); font-weight: 500; font-variant-numeric: tabular-nums; }

.header-btn {
    padding: 8px 16px; background: var(--bg-secondary);
    border: 1px solid var(--border); border-radius: var(--radius-md);
    color: var(--text-secondary); font-size: 13px;
    cursor: pointer; display: flex; align-items: center; gap: 6px;
    font-family: inherit; transition: background 0.2s;
}
.header-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

.main-content { flex: 1; display: flex; overflow: hidden; }

/* ========== CHAT ========== */
.chat-panel { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }

.messages { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 24px; padding-bottom: 140px; }

/* ========== WELCOME — SIRI AI STYLE ========== */
.welcome {
    height: 100%;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    text-align: center; padding: 40px;
    max-width: 740px; margin: 0 auto;
    overflow-y: auto;
    position: relative;
}

/* ---- Siri Orb Icon ---- */
.welcome-icon {
    width: 60px; height: 60px;
    border-radius: 20px;
    display: flex; align-items: center; justify-content: center;
    font-size: 26px; margin-bottom: 24px;
    position: relative; z-index: 1;
    background: linear-gradient(135deg, #0074ba, #7c3aed, #ec4899, #06b6d4);
    background-size: 300% 300%;
    animation: welcomeFadeDown 0.6s cubic-bezier(.16,1,.3,1) both,
               siriOrb 6s ease infinite 0.6s,
               siriGlow 4s ease-in-out infinite 0.6s;
}
@keyframes siriOrb {
    0%,100% { background-position: 0% 50%; }
    25% { background-position: 100% 0%; }
    50% { background-position: 100% 100%; }
    75% { background-position: 0% 100%; }
}
@keyframes siriGlow {
    0%,100% { box-shadow: 0 8px 30px rgba(0,116,186,0.3), 0 0 50px rgba(124,58,237,0.1); }
    33% { box-shadow: 0 8px 35px rgba(124,58,237,0.35), 0 0 60px rgba(236,72,153,0.12); }
    66% { box-shadow: 0 8px 35px rgba(6,182,212,0.3), 0 0 60px rgba(0,116,186,0.12); }
}

.welcome h2 {
    font-size: 28px; font-weight: 400;
    margin-bottom: 8px;
    color: var(--text-primary);
    position: relative; z-index: 1;
    animation: welcomeFadeDown 0.6s cubic-bezier(.16,1,.3,1) 0.1s both;
}

.welcome .welcome-sub {
    font-size: 15px; color: var(--text-muted);
    margin-bottom: 32px;
    position: relative; z-index: 1;
    animation: welcomeFadeDown 0.5s cubic-bezier(.16,1,.3,1) 0.2s both;
}

@keyframes welcomeFadeDown {
    0% { opacity: 0; transform: translateY(-12px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* ========== IDEAS GRID ========== */
.quick-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    max-width: 600px; width: 100%;
    position: relative; z-index: 1;
}
.quick-action.idea-shuffle {
    grid-column: 1 / -1;
}

/* ---- Idea cards — Siri glass style ---- */
.quick-action {
    --i: 0;
    position: relative;
    padding: 14px 16px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: var(--radius-lg);
    color: var(--text-secondary); font-size: 13px;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    display: flex; align-items: center; gap: 12px;
    overflow: hidden;
    transition: all 0.35s cubic-bezier(.4,0,.2,1);
    animation: ideaFloat 7s ease-in-out infinite,
               ideaBorderGlow 8s ease-in-out infinite;
    animation-delay: calc(var(--i) * 0.8s),
                     calc(var(--i) * 1.3s);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    min-height: 62px;
    box-sizing: border-box;
}

/* Rainbow shimmer sweep */
.quick-action::after {
    content: '';
    position: absolute;
    top: 0; left: -130%;
    width: 60%; height: 100%;
    background: linear-gradient(90deg,
        transparent,
        rgba(0,116,186,0.06),
        rgba(124,58,237,0.06),
        rgba(236,72,153,0.04),
        rgba(6,182,212,0.06),
        transparent
    );
    animation: ideaShimmer 7s ease-in-out infinite;
    animation-delay: calc(var(--i) * 1.1s);
    pointer-events: none;
}

.quick-action:hover {
    color: var(--text-primary);
    border-color: rgba(124,58,237,0.4);
    transform: translateY(-4px) scale(1.03);
    box-shadow:
        0 0 20px rgba(0,116,186,0.15),
        0 0 40px rgba(124,58,237,0.08),
        0 8px 32px rgba(0,0,0,0.18);
    background: linear-gradient(135deg, rgba(0,116,186,0.06), rgba(124,58,237,0.04), rgba(6,182,212,0.04));
    animation-play-state: paused, paused;
}
.quick-action:active {
    transform: translateY(-1px) scale(0.97);
    transition: all 0.08s;
}

/* ---- Emoji ---- */
.idea-emoji {
    font-size: 20px;
    display: inline-flex;
    flex-shrink: 0;
    animation: emojiPulse 5s ease-in-out infinite;
    animation-delay: calc(var(--i) * 0.5s);
    filter: drop-shadow(0 0 4px rgba(0,116,186,0.15));
}
.quick-action:hover .idea-emoji {
    animation: emojiPop 0.4s cubic-bezier(.16,1,.3,1) forwards;
    filter: drop-shadow(0 0 8px rgba(124,58,237,0.3));
}

/* ---- Text wrap (label + desc) ---- */
.idea-text-wrap {
    display: flex; flex-direction: column; gap: 2px;
    min-width: 0;
}
.idea-label {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
    white-space: nowrap;
    line-height: 1.2;
}
.idea-desc {
    font-size: 11.5px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
    transition: color 0.3s;
}
.quick-action:hover .idea-label {
    background: linear-gradient(90deg, var(--text-primary), #7c9cff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.quick-action:hover .idea-desc { color: var(--text-secondary); }

/* ---- Card animations ---- */
.quick-action.idea-animate {
    opacity: 0;
    animation: ideaSlideIn 0.55s cubic-bezier(.16,1,.3,1) forwards,
               ideaFloat 7s ease-in-out infinite,
               ideaBorderGlow 8s ease-in-out infinite;
    animation-delay: calc(var(--i) * 0.07s),
                     calc(0.6s + var(--i) * 0.8s),
                     calc(0.6s + var(--i) * 1.3s);
}

@keyframes ideaSlideIn {
    0% { opacity: 0; transform: translateY(22px) scale(0.88); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes ideaFloat {
    0%,100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

@keyframes ideaBorderGlow {
    0%,100% { border-color: rgba(255,255,255,0.06); box-shadow: 0 1px 8px rgba(0,0,0,0.08); }
    25% { border-color: rgba(0,116,186,0.15); box-shadow: 0 2px 12px rgba(0,116,186,0.06); }
    50% { border-color: rgba(124,58,237,0.12); box-shadow: 0 2px 12px rgba(124,58,237,0.05); }
    75% { border-color: rgba(6,182,212,0.12); box-shadow: 0 2px 12px rgba(6,182,212,0.05); }
}

@keyframes ideaShimmer {
    0%,100% { left: -130%; opacity: 0; }
    30% { opacity: 1; }
    50% { left: 170%; opacity: 0; }
}

@keyframes emojiPulse {
    0%,100% { transform: scale(1); }
    50% { transform: scale(1.12) rotate(3deg); }
}

@keyframes emojiPop {
    0% { transform: scale(1); }
    40% { transform: scale(1.3) rotate(-6deg); }
    100% { transform: scale(1.1) rotate(0deg); }
}

/* ---- Shuffle / more button ---- */
.quick-action.idea-shuffle {
    border-style: dashed;
    border-color: rgba(255,255,255,0.08);
    color: var(--text-muted);
    gap: 8px;
    font-weight: 500;
    justify-content: center;
    padding: 10px 22px;
    background: transparent;
    backdrop-filter: none;
}
.quick-action.idea-shuffle:hover {
    color: #7c9cff;
    border-color: rgba(124,58,237,0.35);
    box-shadow: 0 0 20px rgba(124,58,237,0.1);
    background: rgba(124,58,237,0.04);
}
.quick-action.idea-shuffle .ti {
    font-size: 15px;
    transition: transform 0.6s cubic-bezier(.16,1,.3,1);
}
.quick-action.idea-shuffle:hover .ti {
    transform: rotate(360deg);
}

/* ---- Fade out on shuffle ---- */
.quick-actions.ideas-fade-out .quick-action {
    opacity: 0 !important;
    transform: translateY(-12px) scale(0.9) !important;
    transition: all 0.3s cubic-bezier(.4,0,.2,1) !important;
    animation: none !important;
}

/* ========== MESSAGES ========== */
.message {
    max-width: 800px;
    margin: 0 auto 24px;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } }

.message.user { display: flex; justify-content: flex-end; }

.message.user .message-bubble {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    padding: 12px 20px;
    border-radius: 20px 20px 4px 20px;
    white-space: pre-wrap;
    max-width: 80%;
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.6;
    box-shadow: 0 1px 4px var(--shadow);
}

.message.assistant .message-content {
    color: var(--text-primary);
    margin: 10px 0;
}
.message.assistant .message-content p { margin-bottom: 14px; line-height: 1.7; }
.message.assistant .message-content p:last-child { margin-bottom: 0; }

.message-files { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.file-pill {
    display: flex; align-items: center; gap: 6px;
    padding: 7px 14px;
    background: rgba(129, 201, 149, 0.08);
    border: 1px solid rgba(129, 201, 149, 0.2);
    border-radius: var(--radius-md);
    font-size: 12px; color: var(--success);
    cursor: pointer; transition: background 0.15s;
}
.file-pill:hover { background: rgba(129, 201, 149, 0.15); }

.save-project-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 18px;
    background: rgba(0, 116, 186, 0.1);
    border: 1px solid rgba(0, 116, 186, 0.25);
    border-radius: var(--radius-md);
    font-size: 13px; color: var(--accent-light);
    cursor: pointer; font-family: inherit; margin-top: 8px;
    transition: all 0.15s;
}
.save-project-btn:hover { background: rgba(0, 116, 186, 0.18); border-color: rgba(0, 116, 186, 0.4); }
.save-project-btn svg { width: 14px; height: 14px; }

/* ========== AI THINKING INDICATOR ========== */
.thinking-indicator {
    display: flex; align-items: center;
    padding: 12px 0; margin-top: 4px; gap: 14px;
}

.ai-loader {
    position: relative; width: 36px; height: 36px; flex-shrink: 0;
}
.ai-loader.stopped { display: none; }
.thinking-indicator:has(.ai-loader.stopped) { display: none; }

.ai-loader-core {
    position: absolute; top: 50%; left: 50%;
    width: 8px; height: 8px; margin: -4px 0 0 -4px;
    background: var(--accent);
    border-radius: 50%;
    animation: aiCorePulse 2s ease-in-out infinite;
    box-shadow: 0 0 8px var(--accent), 0 0 16px rgba(196,122,74,0.3);
}

@keyframes aiCorePulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 8px var(--accent), 0 0 16px rgba(196,122,74,0.3); }
    50% { transform: scale(1.3); box-shadow: 0 0 12px var(--accent), 0 0 24px rgba(196,122,74,0.5); }
}

.ai-loader-ring {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    border: 1.5px solid transparent;
    border-top-color: var(--accent);
    border-right-color: rgba(196,122,74,0.3);
    border-radius: 50%;
    animation: aiOrbit1 1.4s linear infinite;
}

.ai-loader-dot {
    position: absolute;
    width: 4px; height: 4px;
    background: var(--accent);
    border-radius: 50%;
    box-shadow: 0 0 6px rgba(196,122,74,0.6);
}
.ai-loader-dot:nth-child(4) {
    top: 0; left: 50%; margin-left: -2px;
    animation: aiDotOrbit 1.4s linear infinite;
    transform-origin: 2px 18px;
}
.ai-loader-dot:nth-child(5) {
    bottom: 0; left: 50%; margin-left: -2px;
    animation: aiDotOrbit 2.2s linear infinite reverse;
    transform-origin: 2px -14px;
}

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

.ai-status-text {
    font-size: 13px; font-weight: 500;
    background: linear-gradient(90deg, var(--accent), var(--accent-light), var(--accent));
    background-size: 200% 100%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: aiTextShimmer 3s ease-in-out infinite;
}

@keyframes aiTextShimmer {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.thinking-dots { display: none; }

/* ========== GLOW EFFECT ON MESSAGE WHILE GENERATING ========== */
.message.assistant.ai-generating { position: relative; }

.message.assistant.ai-generating::before {
    content: '';
    position: absolute;
    top: -2px; left: -8px; right: -8px; bottom: -2px;
    background: linear-gradient(135deg, rgba(196,122,74,0.06) 0%, rgba(212,149,106,0.04) 50%, rgba(196,122,74,0.06) 100%);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(196,122,74,0.1);
    animation: aiGlowBorder 3s ease-in-out infinite;
    pointer-events: none; z-index: -1;
}

@keyframes aiGlowBorder {
    0%, 100% { border-color: rgba(196,122,74,0.1); box-shadow: 0 0 15px rgba(196,122,74,0.05); }
    50% { border-color: rgba(196,122,74,0.2); box-shadow: 0 0 25px rgba(196,122,74,0.1); }
}

.message.assistant.ai-generating::after {
    content: '';
    position: absolute; top: 0; left: -8px;
    width: 60px; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(196,122,74,0.06), transparent);
    animation: aiScanline 2.5s ease-in-out infinite;
    pointer-events: none; z-index: -1; border-radius: var(--radius-lg);
}

@keyframes aiScanline {
    0% { transform: translateX(-60px); opacity: 0; }
    20% { opacity: 1; }
    80% { opacity: 1; }
    100% { transform: translateX(calc(800px + 60px)); opacity: 0; }
}

.stop-btn {
    margin-left: auto; padding: 6px 14px;
    background: var(--bg-tertiary); border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary); font-size: 12px;
    cursor: pointer; font-family: inherit; transition: background 0.15s;
}
.stop-btn:hover { background: var(--bg-hover); }

/* ========== CODE BLOCKS ========== */
.code-block {
    margin: 18px 0;
    background: #131313;
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2), 0 1px 3px rgba(0,0,0,0.15);
}

.code-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 11px 18px;
    background: #1a1a1a;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    font-size: 12px; color: #8b949e;
}

.code-lang {
    font-weight: 600; display: flex; align-items: center; gap: 7px;
    font-family: 'JetBrains Mono', 'Monaco', 'Menlo', monospace;
    font-size: 11px; letter-spacing: 0.5px; text-transform: uppercase;
    color: #8b949e;
}
.code-lang::before {
    content: '';
    width: 8px; height: 8px;
    background: var(--accent);
    border-radius: 50%;
}

.code-action-btn {
    padding: 5px 14px;
    background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.08);
    color: #8b949e; cursor: pointer;
    border-radius: 20px; font-size: 11px;
    font-family: inherit; transition: all 0.2s; font-weight: 500;
    display: flex; align-items: center; gap: 5px;
}
.code-action-btn:hover { background: rgba(255,255,255,0.08); color: #e6edf3; border-color: rgba(255,255,255,0.12); }
.code-action-btn.copied { background: rgba(129, 201, 149, 0.1); border-color: rgba(129,201,149,0.25); color: #7ee787; }

.code-content {
    max-height: 420px; overflow-y: auto; overflow-x: auto;
    background: #131313;
}
.code-content::-webkit-scrollbar { width: 5px; height: 5px; }
.code-content::-webkit-scrollbar-track { background: transparent; }
.code-content::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 10px; }
.code-content::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.14); }
.code-content::-webkit-scrollbar-corner { background: #131313; }

.code-content pre { margin: 0; padding: 20px 22px; background: transparent; }
.code-content code {
    font-family: 'JetBrains Mono', 'Monaco', 'Menlo', 'Courier New', monospace;
    font-size: 13px; line-height: 1.75; white-space: pre;
    color: #d4d4d4;
}

.code-block-streaming { border-color: rgba(0,116,186,0.35) !important; box-shadow: 0 4px 20px rgba(0,116,186,0.08); }
.code-block-streaming .code-content { max-height: 350px; overflow-y: auto; }

/* ===EDIT:=== blocks — surgical edits */
.code-block-edit { border-color: rgba(234,179,8,0.25) !important; }
.code-block-edit .code-header { background: rgba(234,179,8,0.06); }
.code-block-edit .code-lang::before { background: #eab308; }
.code-block-edit.code-block-streaming { border-color: rgba(234,179,8,0.4) !important; box-shadow: 0 4px 20px rgba(234,179,8,0.08); }
.edit-badge {
    padding: 2px 8px; border-radius: 10px; font-size: 10px; font-weight: 700;
    background: rgba(234,179,8,0.15); color: #eab308; letter-spacing: 0.5px;
    text-transform: uppercase; font-family: 'JetBrains Mono', monospace;
}
.edit-marker { font-weight: 700; display: inline-block; padding: 1px 0; }
.edit-find { color: #f87171; }
.edit-replace { color: #4ade80; }
.edit-end { color: #8b949e; }

.streaming-indicator {
    display: flex; align-items: center; gap: 8px;
    font-size: 11px; color: var(--accent);
}

.streaming-dot {
    width: 6px; height: 6px;
    background: var(--accent); border-radius: 50%;
    animation: streamPulse 1.2s ease-in-out infinite;
}

@keyframes streamPulse {
    0%, 100% { opacity: 0.3; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1); }
}

.cursor-blink { animation: cursorBlink 0.8s step-end infinite; color: var(--accent); }
@keyframes cursorBlink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

.message-content blockquote {
    border-left: 3px solid var(--accent);
    padding: 12px 18px; margin: 14px 0;
    color: var(--text-secondary); font-size: 13.5px;
    background: var(--accent-dim);
    border-radius: 0 12px 12px 0;
    font-style: italic; line-height: 1.65;
}

/* ========== INLINE CODE ========== */
.inline-code {
    background: rgba(255,255,255,0.06);
    padding: 2px 8px;
    border-radius: 6px;
    font-family: 'JetBrains Mono', 'Monaco', 'Menlo', monospace;
    font-size: 0.85em;
    color: #e0976e;
    border: 1px solid rgba(255,255,255,0.05);
    white-space: nowrap;
    letter-spacing: -0.2px;
}

/* ========== MARKDOWN HEADINGS ========== */
.md-h1 {
    font-size: 18px; font-weight: 700;
    display: block; margin: 20px 0 8px;
    color: var(--text-primary);
    letter-spacing: -0.3px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 6px;
}
.md-h2 {
    font-size: 16px; font-weight: 700;
    display: block; margin: 16px 0 6px;
    color: var(--text-primary);
    letter-spacing: -0.2px;
}
.md-h3 {
    font-size: 14px; font-weight: 600;
    display: block; margin: 12px 0 4px;
    color: var(--text-primary);
}

/* ========== MARKDOWN LISTS ========== */
.md-li {
    display: flex; align-items: baseline; gap: 8px;
    padding: 3px 0 3px 4px;
    line-height: 1.65;
    position: relative;
}
.md-li::before {
    font-family: 'tabler-icons';
    content: '\ea5e';
    font-size: 14px; min-width: 14px;
    color: var(--accent);
    position: relative; top: 2px;
}
.md-li.md-li-num::before { display: none; }
.md-li-n {
    color: var(--accent);
    font-weight: 600;
    min-width: 18px;
}

/* ========== MARKDOWN HR ========== */
.md-hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 16px 0;
    opacity: 0.6;
}

/* ========== TABLES ========== */
.message-content .data-table-wrap {
    overflow-x: auto; margin: 18px 0;
    border-radius: 14px; border: 1px solid var(--border);
    box-shadow: 0 2px 8px var(--shadow);
}
.message-content table { width: 100%; border-collapse: collapse; font-size: 13px; white-space: nowrap; }
.message-content thead { background: var(--bg-tertiary); position: sticky; top: 0; }
.message-content th {
    padding: 11px 18px; text-align: left; font-weight: 600;
    color: var(--text-primary); border-bottom: 2px solid var(--border-light);
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
}
.message-content td {
    padding: 11px 18px; border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
}
.message-content tbody tr { transition: background 0.15s; }
.message-content tbody tr:hover { background: var(--bg-hover); }
.message-content tbody tr:nth-child(even) { background: rgba(255,255,255,0.015); }
.message-content tbody tr:last-child td { border-bottom: none; }

/* ========== ECHARTS ========== */
.echart-wrap {
    margin: 14px 0; border: 1px solid var(--border);
    border-radius: var(--radius-md); overflow: hidden;
    background: var(--bg-secondary);
}
.echart-header {
    display: flex; align-items: center; gap: 6px;
    padding: 10px 16px; background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
    font-size: 13px; font-weight: 500; color: var(--text-primary);
}
.echart-container {
    width: 100%; height: 350px; padding: 14px; box-sizing: border-box;
}

/* ========== API RESULT BLOCKS ========== */
.api-result-block {
    border: 1px solid var(--border); border-radius: var(--radius-md);
    margin: 10px 0; overflow: hidden; background: var(--bg-secondary);
}
.api-result-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 16px; background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
    font-size: 12px; font-weight: 500;
}
.api-result-header .api-tool-name {
    display: flex; align-items: center; gap: 6px; color: var(--text-primary);
}
.api-result-header .api-status {
    font-size: 11px; font-weight: 500; padding: 3px 10px; border-radius: var(--radius-md);
}
.api-result-header .api-status.success { background: rgba(129,201,149,0.12); color: var(--success); }
.api-result-header .api-status.error { background: rgba(242,139,130,0.12); color: var(--error); }
.api-result-body { max-height: 400px; overflow: auto; }
.api-result-body table { width: 100%; border-collapse: collapse; font-size: 12px; }
.api-result-body thead { background: var(--bg-tertiary); position: sticky; top: 0; z-index: 1; }
.api-result-body th {
    padding: 8px 14px; text-align: left; font-weight: 500;
    color: var(--text-primary); border-bottom: 1px solid var(--border-light);
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; white-space: nowrap;
}
.api-result-body td {
    padding: 7px 14px; border-bottom: 1px solid var(--border);
    color: var(--text-secondary); font-size: 12px;
    max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.api-result-body td.wrap { white-space: normal; word-break: break-word; }
.api-result-body tbody tr:hover { background: var(--bg-hover); }
.api-result-body tbody tr:last-child td { border-bottom: none; }
.api-result-params {
    padding: 6px 16px; font-size: 11px; color: var(--text-muted);
    border-bottom: 1px solid var(--border); background: var(--accent-dim);
}
.api-result-params span { color: var(--text-secondary); }

.code-stop-btn {
    padding: 5px 12px; background: var(--error); border: none;
    color: #1a1612; cursor: pointer; border-radius: var(--radius-md);
    font-size: 11px; font-family: inherit; font-weight: 500;
}

/* ========== INPUT ========== */
.input-area {
    position: absolute; bottom: 0;
    left: 0; right: 8px;
    padding: 16px 24px 20px;
    pointer-events: none;
    z-index: 10;
    background: linear-gradient(to top, var(--bg-primary) 60%, transparent 100%);
}

.input-wrapper { max-width: 860px; margin: 0 auto; pointer-events: auto; }

.msg-attachments { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.msg-att-img { border-radius: 8px; overflow: hidden; max-width: 240px; cursor: pointer; }
.msg-att-img img { display: block; max-width: 100%; border-radius: 8px; }
.msg-att-file { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 6px; background: rgba(255,255,255,0.1); font-size: 12px; }

.attachments-preview { display: flex; gap: 8px; padding: 8px 14px 4px; flex-wrap: wrap; }
.attachments-preview:empty { display: none; }
.att-thumb { position: relative; width: 64px; height: 64px; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); flex-shrink: 0; }
.att-thumb img { width: 100%; height: 100%; object-fit: cover; }
.att-thumb .att-remove {
    position: absolute; top: 2px; right: 2px;
    background: rgba(0,0,0,0.7); color: #fff; border: none;
    border-radius: 50%; width: 18px; height: 18px;
    font-size: 12px; cursor: pointer;
    display: flex; align-items: center; justify-content: center; line-height: 1;
}
.att-thumb .att-remove:hover { background: rgba(242,139,130,0.8); }
.att-thumb .att-name {
    position: absolute; bottom: 0; left: 0; right: 0;
    background: rgba(0,0,0,0.6); color: #fff; font-size: 9px;
    padding: 2px 4px; text-overflow: ellipsis; overflow: hidden; white-space: nowrap;
}
.input-area.drag-over .input-container, .project-input-wrap.drag-over .input-container { border-color: var(--accent); background: var(--accent-dim); }

.active-modes {
    display: flex; flex-wrap: wrap; gap: 8px;
    margin-bottom: 10px; justify-content: center;
}

.active-mode-chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 5px 12px;
    background: var(--accent-dim); border: 1px solid rgba(196,122,74,0.2);
    border-radius: var(--radius-md); font-size: 12px; color: var(--accent);
}
.active-mode-chip .remove-chip {
    background: none; border: none; color: var(--accent);
    cursor: pointer; padding: 0; margin-left: 2px; opacity: 0.6;
}
.active-mode-chip .remove-chip:hover { opacity: 1; }

.input-container {
    display: flex; flex-direction: column;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 0;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.input-container:focus-within {
    border-color: rgba(0,116,186,0.35);
    box-shadow: 0 0 0 2px rgba(0,116,186,0.06);
}

.input-toolbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 6px 8px;
    background: transparent;
    gap: 6px;
}
.input-toolbar-left { display: flex; align-items: center; gap: 2px; }
.input-toolbar-right { display: flex; align-items: center; gap: 2px; }

.input-btn {
    width: 32px; height: 32px;
    background: transparent; border: none;
    color: var(--text-muted); cursor: pointer;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    position: relative; transition: all 0.15s;
    font-size: 18px;
}
.input-btn:hover { color: var(--text-primary); background: var(--bg-hover); }
.input-btn.active { color: var(--accent); background: var(--accent-dim); }
.input-btn svg { width: 18px; height: 18px; }

/* Mode selector */
.mode-selector {
    position: relative;
    display: flex;
    align-items: center;
}
.mode-btn {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-secondary);
    padding: 5px 12px;
    height: 32px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.2s ease;
    white-space: nowrap;
}
.mode-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-light);
    color: var(--text-primary);
}
.mode-dropdown {
    position: absolute;
    bottom: 100%;
    left: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.5);
    display: none;
    flex-direction: column;
    gap: 2px;
    padding: 6px;
    margin-bottom: 8px;
    min-width: 240px;
    z-index: 1000;
}
.mode-dropdown.active {
    display: flex;
}
.mode-dropdown-header {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 6px 10px 4px;
}
.mode-option {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    transition: all 0.2s ease;
    font-family: inherit;
    width: 100%;
    text-align: left;
    justify-content: flex-start;
}
.mode-option:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.mode-option.active {
    background: transparent;
    color: var(--text-primary);
    border-color: transparent;
}
.mode-option .mode-check {
    visibility: hidden;
    color: var(--accent-light);
    font-size: 16px;
    margin-left: auto;
    flex-shrink: 0;
}
.mode-option.active .mode-check {
    visibility: visible;
}
.mode-option-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}
.mode-option-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    font-size: 13px;
}
.mode-option-desc {
    font-size: 11px;
    opacity: 0.6;
    font-weight: 400;
}
.mode-btn-icon { font-size: 14px; }

.input-textarea {
    width: 100%; background: transparent; border: none;
    color: var(--text-primary); font-size: 15px;
    padding: 16px 20px 8px; resize: none;
    max-height: 200px; min-height: 28px;
    font-family: inherit; line-height: 1.5;
    box-sizing: border-box;
}
.input-textarea:focus { outline: none; }
.input-textarea::placeholder { color: var(--text-muted); }

/* Input button tooltips */
.input-btn { position: relative; }
.btn-tooltip {
    display: none; position: absolute;
    bottom: calc(100% + 10px); left: 50%; transform: translateX(-50%);
    background: var(--bg-tertiary); border: 1px solid var(--border-light);
    border-radius: var(--radius-md); padding: 8px 12px; width: 200px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5); z-index: 1200;
    pointer-events: none; white-space: normal; text-align: left;
}
.btn-tooltip::after {
    content: ''; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
    border: 6px solid transparent; border-top-color: var(--bg-tertiary);
}
.btn-tooltip::before {
    content: ''; position: absolute; top: calc(100% + 1px); left: 50%; transform: translateX(-50%);
    border: 6px solid transparent; border-top-color: var(--border-light);
}
.btn-tooltip-title { font-size: 12px; font-weight: 600; color: var(--text-primary); margin-bottom: 4px; }
.btn-tooltip-desc { font-size: 11px; color: var(--text-secondary); line-height: 1.5; }
.input-btn:hover .btn-tooltip { display: block; }

.send-btn {
    width: 32px; height: 32px;
    background: var(--accent); border: none;
    border-radius: 10px;
    color: #fff; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
}
.send-btn:hover { background: var(--accent-light); transform: scale(1.03); }
.send-btn:disabled { opacity: 0.3; cursor: not-allowed; transform: none; }
.send-btn.stop-mode { background: var(--error); color: #1a1612; }
.send-btn svg { width: 16px; height: 16px; }

/* ========== MICROPHONE BUTTON ========== */
.mic-btn {
    position: relative; width: 32px; height: 32px;
    background: transparent; border: none;
    color: var(--text-muted); cursor: pointer;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
}
.mic-btn:hover { color: var(--text-primary); background: var(--bg-hover); }
.mic-btn:hover .btn-tooltip { display: block; }
.mic-btn.recording {
    color: var(--error); background: rgba(242,139,130,0.15);
    animation: mic-pulse 1.5s ease-in-out infinite;
}
.mic-btn.recording .popover {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(-12px);
}
@keyframes mic-pulse {
    0%,100% { box-shadow: 0 0 0 0 rgba(242,139,130,0.3); }
    50% { box-shadow: 0 0 0 8px rgba(242,139,130,0); }
}

/* ========== GENERATED IMAGES ========== */
.generated-image-wrap {
    margin: 12px 0; max-width: 512px;
    border-radius: var(--radius-lg); overflow: hidden;
    border: 1px solid var(--border);
}
.generated-image-wrap img {
    width: 100%; display: block; cursor: pointer;
    transition: transform 0.2s;
}
.generated-image-wrap img:hover { transform: scale(1.02); }
.generated-image-caption {
    padding: 8px 12px; font-size: 12px;
    color: var(--text-secondary); background: var(--bg-secondary);
    font-style: italic;
}

/* ========== RECORDING OVERLAY ========== */
.recording-overlay {
    position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%);
    background: var(--bg-tertiary); border: 1px solid var(--error);
    border-radius: var(--radius-lg); padding: 12px 24px;
    display: flex; align-items: center; gap: 12px;
    z-index: 2000; box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.recording-dot {
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--error); animation: rec-blink 1s ease-in-out infinite;
}
@keyframes rec-blink { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }
.recording-time { font-size: 14px; color: var(--text-primary); font-variant-numeric: tabular-nums; }

.file-menu {
    position: absolute; bottom: 100%; left: 0; margin-bottom: 8px;
    background: var(--bg-secondary); border: 1px solid var(--border);
    border-radius: var(--radius-md); padding: 6px;
    display: none; min-width: 180px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5); z-index: 100;
}
.file-menu.visible { display: block; }

.file-menu-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px; border-radius: var(--radius-sm);
    cursor: pointer; font-size: 13px; color: var(--text-secondary);
    position: relative; transition: background 0.15s;
}
.file-menu-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.file-menu-item input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* ========== BUILDER PANEL ========== */
.builder-panel {
    width: 0; background: var(--bg-primary);
    border-left: 1px solid var(--border);
    display: flex; flex-direction: column;
    overflow: hidden; position: relative;
}
.builder-panel.visible { width: 50%; min-width: 400px; }

.builder-resize {
    position: absolute; left: -6px; top: 0; bottom: 0;
    width: 12px; cursor: col-resize; z-index: 100;
}
.builder-resize::before {
    content: ''; position: absolute; left: 50%; top: 0; bottom: 0;
    width: 2px; background: transparent;
    transition: background 0.15s; transform: translateX(-50%);
}
.builder-resize:hover::before,
.builder-resize.active::before { background: var(--accent); }

.builder-header {
    display: flex; align-items: center;
    padding: 10px 16px; background: var(--bg-secondary);
    border-bottom: 1px solid var(--border); gap: 8px;
}

.builder-title {
    font-size: 14px; font-weight: 500; flex: 1;
}

.builder-header-btn {
    padding: 6px 12px; background: transparent;
    border: 1px solid var(--border); border-radius: var(--radius-md);
    color: var(--text-secondary); cursor: pointer;
    font-size: 12px; font-family: inherit;
    display: flex; align-items: center; gap: 4px;
    transition: all 0.15s;
}
.builder-header-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.builder-header-btn.close:hover { background: rgba(242,139,130,0.15); border-color: var(--error); color: var(--error); }

.builder-tabs {
    display: flex; background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    overflow-x: auto; padding: 0 8px;
}

.builder-tab {
    padding: 10px 16px; background: transparent;
    border: none; color: var(--text-muted); font-size: 12px;
    cursor: pointer; border-bottom: 2px solid transparent;
    white-space: nowrap; display: flex; align-items: center; gap: 6px;
    font-family: inherit; margin-bottom: -1px; transition: color 0.15s;
}
.builder-tab:hover { color: var(--text-secondary); }
.builder-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.builder-tab .tab-delete {
    opacity: 0; background: none; border: none;
    color: var(--text-muted); cursor: pointer;
    padding: 2px; font-size: 10px; margin-left: 2px;
}
.builder-tab:hover .tab-delete { opacity: 1; }
.builder-tab .tab-delete:hover { color: var(--error); }

.builder-content { flex: 1; overflow: hidden; position: relative; }

.code-editor { height: 100%; display: none; }
.code-editor.visible { display: flex; flex-direction: column; }

.CodeMirror { flex: 1; height: auto !important; font-family: 'JetBrains Mono', 'Monaco', 'Menlo', monospace; font-size: 13px; }

.preview-container { height: 100%; display: flex; flex-direction: column; background: white; }
.preview-container.hidden { display: none; }

.preview-iframe { flex: 1; border: none; }

/* ========== MODALS ========== */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.65);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000; opacity: 0; visibility: hidden;
    transition: all 0.25s; backdrop-filter: blur(4px);
}
.modal-overlay.visible { opacity: 1; visibility: visible; }

.modal {
    background: var(--bg-secondary); border: 1px solid var(--border);
    border-radius: var(--radius-xl); padding: 28px;
    width: 100%; max-width: 480px; max-height: 90vh;
    overflow-y: auto; box-shadow: 0 24px 48px rgba(0,0,0,0.3);
}
.modal.large { max-width: 640px; }

.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.modal-header h3 { font-size: 18px; font-weight: 500; display: flex; align-items: center; gap: 8px; }
.modal-close {
    background: none; border: none; color: var(--text-muted);
    cursor: pointer; font-size: 18px; padding: 8px;
    border-radius: var(--radius-sm); transition: background 0.15s;
}
.modal-close:hover { color: var(--text-primary); background: var(--bg-hover); }

.file-modal-tabs { display: flex; gap: 4px; margin-left: auto; margin-right: 12px; }
.file-modal-tab {
    padding: 5px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border);
    background: none; color: var(--text-muted); cursor: pointer; font-size: 12px;
    display: flex; align-items: center; gap: 5px; transition: all 0.15s;
}
.file-modal-tab:hover { color: var(--text-primary); background: var(--bg-hover); }
.file-modal-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 8px; font-weight: 500; }
.form-group input, .form-group textarea {
    width: 100%; padding: 12px 14px;
    background: var(--bg-tertiary); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text-primary);
    font-size: 14px; font-family: inherit; transition: border-color 0.2s;
}
.form-group input:focus, .form-group textarea:focus { outline: none; border-color: var(--accent); }
.form-group textarea { resize: vertical; min-height: 80px; }
.form-group textarea.code-textarea {
    min-height: 280px;
    font-family: 'JetBrains Mono', 'Monaco', 'Menlo', monospace;
    font-size: 13px; white-space: pre;
}
.form-group small { display: block; margin-top: 6px; color: var(--text-muted); font-size: 12px; }

.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; }

.btn {
    padding: 10px 20px; border-radius: var(--radius-md);
    font-size: 13px; cursor: pointer; font-family: inherit;
    font-weight: 500; transition: all 0.2s;
}
.btn-primary, .btn-secondary {
    padding: 10px 20px; border-radius: var(--radius-md);
    font-size: 13px; cursor: pointer; font-family: inherit;
    font-weight: 500; transition: all 0.2s;
}
.btn-primary { background: var(--accent); color: #fff; border: none; }
.btn-primary:hover { background: var(--accent-light); }
.btn-secondary { background: transparent; color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg-hover); }

.toast {
    position: fixed; bottom: 24px; right: 24px;
    padding: 12px 20px;
    background: var(--bg-secondary); border: 1px solid var(--border);
    border-radius: var(--radius-md); font-size: 13px;
    transform: translateY(100px); opacity: 0;
    transition: all 0.35s; z-index: 1001;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.toast.visible { transform: translateY(0); opacity: 1; }
.toast-with-action { display: flex; align-items: center; gap: 12px; }
.toast-action {
    background: var(--accent); color: #fff; border: none; border-radius: var(--radius-sm);
    padding: 5px 12px; font-size: 12px; font-weight: 600; cursor: pointer;
    white-space: nowrap; transition: opacity 0.15s; font-family: inherit;
}
.toast-action:hover { opacity: 0.85; }

/* ========== POPOVERS ========== */
.popover {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    min-width: 220px;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.4);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 999;
    white-space: normal;
}
.popover::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid var(--bg-secondary);
}
[data-popover].popover-active .popover {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(-12px);
}
body.popovers-off [data-popover].popover-active .popover {
    opacity: 0 !important;
    pointer-events: none !important;
}
.popover-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}
.popover-desc {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Popovers para elementos en el input area */
.input-btn,
.mode-btn,
.mic-btn,
.send-btn {
    position: relative;
}

/* Popovers en el sidebar - aparecer a la derecha */
.sidebar-nav-btn,
.new-chat-full-btn,
.logo {
    position: relative;
}
.sidebar-nav-btn .popover,
.new-chat-full-btn .popover,
.logo .popover {
    bottom: auto;
    left: 100%;
    right: auto;
    top: 50%;
    transform: translateY(-50%) translateX(8px);
}
.sidebar-nav-btn .popover::after,
.new-chat-full-btn .popover::after,
.logo .popover::after {
    bottom: auto;
    left: auto;
    right: 100%;
    top: 50%;
    transform: translateY(-50%);
    border-left: 6px solid var(--bg-secondary);
    border-right: none;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
}
.sidebar-nav-btn.popover-active .popover,
.new-chat-full-btn.popover-active .popover,
.logo.popover-active .popover {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(-50%) translateX(12px);
}
body.iframe-mode .logo .popover { display: none; }


/* ========== IFRAME MODE - TOP BAR LAYOUT ========== */
body.iframe-mode { flex-direction: column; }
body.iframe-mode .sidebar {
    width: 100% !important;
    flex-direction: row;
    align-items: center;
    border-right: none;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, var(--bg-secondary) 0%, rgba(23, 23, 23, 0.95) 100%);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    height: 50px;
    flex-shrink: 0;
    overflow: visible;
    padding: 0 16px;
    gap: 12px;
    transition: all 0.3s ease;
    position: static !important;
    transform: none !important;
    z-index: auto !important;
}
body.iframe-mode .sidebar.minimized {
    width: 100% !important;
    height: 50px;
    position: static !important;
    transform: none !important;
}
body.iframe-mode .sidebar.minimized .sidebar-content {
    display: flex !important;
}
body.iframe-mode .sidebar.minimized .logo {
    display: flex !important;
}
body.iframe-mode .sidebar .sidebar-header {
    padding: 0;
    gap: 8px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
}
body.iframe-mode .sidebar .logo {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--accent) 0%, #0062a1 100%);
    border-radius: var(--radius-md);
    flex-shrink: 0;
}
body.iframe-mode .sidebar .logo-text {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
    white-space: nowrap;
}
body.iframe-mode .sidebar .toggle-sidebar-btn { display: none; }
body.iframe-mode .sidebar .sidebar-mini-actions { display: none !important; }
body.iframe-mode .sidebar .sidebar-content {
    flex-direction: row !important;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    overflow: visible;
    flex: 1;
    min-width: 0;
    padding: 0;
}
body.iframe-mode .sidebar .new-chat-full-btn,
body.iframe-mode .sidebar .sidebar-nav-btn {
    margin: 0;
    padding: 0 14px;
    height: 34px;
    width: auto;
    flex: 0 0 auto;
    white-space: nowrap;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    background: rgba(51, 51, 51, 0.6);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}
body.iframe-mode .sidebar .new-chat-full-btn:hover,
body.iframe-mode .sidebar .sidebar-nav-btn:hover {
    background: rgba(51, 51, 51, 0.9);
    border-color: var(--border-light);
    color: var(--text-primary);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}
body.iframe-mode .sidebar .new-chat-full-btn.active,
body.iframe-mode .sidebar .sidebar-nav-btn.active {
    background: rgba(255, 255, 255, 0.12);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: none;
}
body.iframe-mode .sidebar .new-chat-full-btn.active:hover,
body.iframe-mode .sidebar .sidebar-nav-btn.active:hover {
    background: rgba(255, 255, 255, 0.18);
    box-shadow: none;
}
body.iframe-mode .sidebar .sidebar-nav-btns {
    padding: 0;
    flex-shrink: 0;
    gap: 8px;
    display: flex;
    flex-direction: row;
}
@media (max-width: 520px) {
    body.iframe-mode .sidebar .logo-text { display: none; }
    body.iframe-mode .sidebar .new-chat-full-btn .ti,
    body.iframe-mode .sidebar .sidebar-nav-btn .ti { display: none; }
    body.iframe-mode .sidebar .new-chat-full-btn,
    body.iframe-mode .sidebar .sidebar-nav-btn { padding: 0 10px; font-size: 12px; }
}
@media (max-width: 400px) {
    body.iframe-mode .sidebar .new-chat-full-btn .btn-label { display: none; }
    body.iframe-mode .sidebar .new-chat-full-btn .ti { display: inline-block !important; }
    body.iframe-mode .sidebar .new-chat-full-btn { padding: 0 10px; min-width: auto; }
    body.iframe-mode .sidebar .btn-label-long { display: none; }
}
body.iframe-mode .sidebar .sidebar-dynamic { display: none; }
body.iframe-mode .menu-btn { display: none; }
body.iframe-mode .main { min-height: 0; }

.sidebar-dynamic { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow: hidden; }
.mini-action-btn.active { color: var(--accent-light); background: var(--accent-dim); }
a.mini-action-btn, button.mini-action-btn { text-decoration: none; border: none; font-family: inherit; }
.project-card { cursor: pointer; }


/* ========== CHATS LIST PAGE ========== */
.chats-page {
    flex: 1; display: flex; flex-direction: column; overflow: hidden;
    padding: 40px 40px 0; max-width: 900px; margin: 0 auto; width: 100%;
}
.chats-list {
    flex: 1; overflow-y: auto; margin-top: 12px; padding: 0 16px 40px;
}
.chats-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 24px;
}
.chats-header h1 { font-size: 28px; font-weight: 500; color: var(--text-primary); }
.chats-search {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 12px;
}
.chats-search .ti { color: var(--text-muted); font-size: 16px; }
.chats-search input {
    flex: 1; background: none; border: none; outline: none;
    color: var(--text-primary); font-size: 14px; font-family: inherit;
}
.chats-search input::placeholder { color: var(--text-muted); }
.chats-meta {
    display: flex; align-items: center; gap: 12px;
    padding: 8px 4px; font-size: 13px; color: var(--text-muted);
    margin-bottom: 4px;
}
.chats-meta a {
    color: var(--accent-light); text-decoration: none; font-weight: 500;
}
.chats-meta a:hover { text-decoration: underline; }
.chats-meta .danger-link { color: var(--error); }

.chats-list-item {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 16px;
    cursor: pointer; transition: background 0.15s;
    position: relative; border-radius: 12px;
}
.chats-list-item + .chats-list-item::before {
    content: ''; position: absolute; top: 0; left: 16px; right: 16px;
    height: 1px; background: var(--border);
}
.chats-list-item:hover::before,
.chats-list-item:hover + .chats-list-item::before { background: transparent; }
.chats-list-item:first-child::before { display: none; }
.chats-list-item:hover { background: var(--bg-hover); }
.chats-list-item.selected { background: var(--accent-dim); }

.chats-hover-check {
    width: 20px; height: 20px; border-radius: 4px;
    border: 2px solid var(--border-light);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; transition: all 0.15s;
    color: transparent; opacity: 0; cursor: pointer;
}
.chats-list-item:hover .chats-hover-check { opacity: 1; }
.chats-hover-check.checked {
    background: var(--accent); border-color: var(--accent);
    color: #fff; opacity: 1;
}
.chats-hover-check .ti { font-size: 12px; }
.chats-select-mode .chats-hover-check { opacity: 1; }

.chats-checkbox {
    width: 20px; height: 20px; border-radius: 4px;
    border: 2px solid var(--border-light);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; transition: all 0.15s;
    color: transparent;
}
.chats-checkbox.checked {
    background: var(--accent); border-color: var(--accent);
    color: #fff;
}
.chats-checkbox .ti { font-size: 12px; }

.chats-star-icon { color: var(--warning, #f5a623); font-size: 14px; flex-shrink: 0; }

.chats-list-item-content { flex: 1; min-width: 0; }
.chats-list-item-title {
    font-size: 14px; font-weight: 600; color: var(--text-primary);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chats-list-item-sub {
    font-size: 12px; color: var(--text-muted); margin-top: 2px;
    display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.chats-project-link {
    display: inline-flex; align-items: center; gap: 3px;
    color: var(--accent); cursor: pointer; font-weight: 500;
    padding: 1px 6px; border-radius: 4px; background: rgba(99,102,241,0.08);
    transition: background 0.15s;
}
.chats-project-link:hover { background: rgba(99,102,241,0.16); }
.chats-project-link .ti { font-size: 12px; }

.chats-list-item-menu {
    background: none; border: none; cursor: pointer;
    color: var(--text-muted); padding: 4px 6px; border-radius: var(--radius-sm);
    opacity: 0; transition: all 0.15s; flex-shrink: 0;
}
.chats-list-item:hover .chats-list-item-menu { opacity: 1; }
.chats-list-item-menu:hover { color: var(--text-primary); background: var(--bg-tertiary); }
.chats-list-item-menu .ti { font-size: 18px; }

/* Context Menu */
.chats-context-menu {
    position: fixed; z-index: 1000;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    padding: 6px;
    min-width: 200px;
    display: none;
}
.chats-context-menu.visible { display: block; }
.chats-context-menu button {
    display: flex; align-items: center; gap: 10px;
    width: 100%; padding: 8px 12px;
    background: none; border: none; border-radius: var(--radius-sm);
    color: var(--text-secondary); font-size: 13px; font-family: inherit;
    cursor: pointer; transition: all 0.15s; text-align: left;
}
.chats-context-menu button:hover { background: var(--bg-hover); color: var(--text-primary); }
.chats-context-menu button .ti { font-size: 16px; width: 18px; }
.chats-context-menu button.danger { color: var(--error); }
.chats-context-menu button.danger:hover { background: rgba(242,139,130,0.1); }
.chats-context-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* Project select in modal */
.project-select-list {
    display: flex; flex-direction: column; gap: 4px;
    max-height: 300px; overflow-y: auto;
}
.project-select-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: var(--radius-sm);
    cursor: pointer; transition: background 0.15s;
    color: var(--text-secondary); font-size: 13px;
}
.project-select-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.project-select-item .ti { font-size: 16px; color: var(--text-muted); }
.project-select-create, .project-select-move { border-bottom: 1px solid var(--border-color); margin-bottom: 4px; padding-bottom: 12px; }
.project-select-create .ti { color: var(--accent); }
.project-select-create:hover { background: rgba(99,102,241,0.08); }
.project-select-move { background: rgba(34,197,94,0.06); color: var(--text-primary) !important; font-weight: 500; }
.project-select-move .ti { color: #22c55e; }
.project-select-move:hover { background: rgba(34,197,94,0.13); }

/* ========== PROJECTS PAGE ========== */
.page-container {
    flex: 1; display: flex; flex-direction: column; overflow: hidden; padding: 40px 40px 0;
}
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    max-width: 900px; margin: 0 auto 24px; width: 100%;
}
.page-header h1 { font-size: 28px; font-weight: 500; color: var(--text-primary); }
.page-search {
    max-width: 900px; margin: 0 auto 16px; width: 100%;
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px; background: var(--bg-secondary);
    border: 1px solid var(--border); border-radius: var(--radius-md);
}
.page-search i { color: var(--text-muted); font-size: 18px; }
.page-search input {
    flex: 1; background: transparent; border: none;
    color: var(--text-primary); font-size: 14px; outline: none; font-family: inherit;
}
.page-search input::placeholder { color: var(--text-muted); }
.page-sort {
    max-width: 900px; margin: 0 auto 8px; width: 100%;
    display: flex; align-items: center; justify-content: flex-end;
    font-size: 13px; color: var(--text-muted);
}
.sort-dropdown-wrap { position: relative; }
.sort-dropdown-btn {
    display: flex; align-items: center; gap: 6px;
    background: none; border: 1px solid var(--border); border-radius: var(--radius-md);
    color: var(--text-secondary); padding: 6px 12px;
    font-size: 13px; font-family: inherit; cursor: pointer; transition: all 0.15s;
}
.sort-dropdown-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.sort-dropdown-btn .ti { font-size: 14px; transition: transform 0.2s; }
.sort-dropdown {
    display: none; position: absolute; top: calc(100% + 6px); right: 0;
    background: var(--bg-secondary); border: 1px solid var(--border);
    border-radius: var(--radius-md); min-width: 140px; padding: 4px;
    box-shadow: 0 8px 24px var(--shadow-strong); z-index: 50;
}
.sort-dropdown.visible { display: block; }
.sort-dropdown button {
    display: block; width: 100%; text-align: left;
    background: none; border: none; color: var(--text-secondary);
    padding: 8px 12px; font-size: 13px; font-family: inherit;
    border-radius: 8px; cursor: pointer; transition: all 0.15s;
}
.sort-dropdown button:hover { background: var(--bg-hover); color: var(--text-primary); }
.sort-dropdown button.active { color: var(--accent); font-weight: 500; }
.projects-grid {
    max-width: 900px; margin: 0 auto;
    display: grid; grid-template-columns: repeat(2, 1fr);
    gap: 16px; flex: 1; overflow-y: auto; margin-top: 12px; padding: 3px 16px 40px;
    align-content: start; width: 100%;
}
.project-card {
    background: var(--bg-primary); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 20px;
    cursor: pointer; transition: all 0.2s;
    display: flex; flex-direction: column;
    min-height: 140px;
}
.project-card:hover { border-color: var(--border-light); box-shadow: 0 4px 16px var(--shadow); transform: translateY(-1px); }
.project-card-name {
    font-size: 15px; font-weight: 500; color: var(--text-primary);
    margin-bottom: 6px;
}
.project-card-desc {
    font-size: 13px; color: var(--text-secondary); line-height: 1.5;
    flex: 1;
}
.project-card-meta {
    margin-top: auto; padding-top: 12px;
    font-size: 12px; color: var(--text-muted);
}
.project-card-files {
    display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px;
}
.project-card-file {
    padding: 3px 8px; background: var(--bg-primary);
    border-radius: var(--radius-sm); font-size: 11px;
    color: var(--text-muted);
}

/* ========== PROJECT DETAIL PAGE ========== */
.project-page-wrap {
    display: flex; flex: 1; overflow: hidden;
}
.project-page {
    flex: 1; display: flex; gap: 32px;
    padding: 32px 40px; overflow-y: auto;
}
.project-main {
    flex: 1; min-width: 0; display: flex; flex-direction: column;
}
.project-back-row {
    display: flex; align-items: center; gap: 8px; margin-bottom: 24px;
}
.project-back-link {
    color: var(--text-secondary); font-size: 14px;
    text-decoration: none; cursor: pointer; transition: color 0.15s;
}
.project-back-link:hover { color: var(--text-primary); }
.project-title-row {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 16px; margin-bottom: 32px;
}
.project-title-info { flex: 1; min-width: 0; }
.project-title {
    font-size: 28px; font-weight: 600; color: var(--text-primary);
    line-height: 1.2; margin: 0;
}
.project-subtitle {
    font-size: 14px; color: var(--text-secondary); margin: 6px 0 0; display: none;
}
.project-title-actions {
    display: flex; align-items: center; gap: 2px; flex-shrink: 0;
}
.project-dots-btn, .project-star-btn {
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    background: none; border: none; color: var(--text-muted);
    cursor: pointer; border-radius: var(--radius-md);
    font-size: 20px; transition: all 0.15s;
}
.project-dots-btn:hover, .project-star-btn:hover {
    background: var(--bg-hover); color: var(--text-primary);
}
.project-star-btn.active { color: #f59e0b; }
.project-menu-wrap { position: relative; }
.project-dropdown {
    display: none; position: absolute; top: calc(100% + 4px); right: 0;
    background: var(--bg-secondary); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 6px; min-width: 200px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.25); z-index: 100;
}
.project-dropdown.visible { display: block; }
.project-dropdown button {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 10px 14px; background: none; border: none;
    color: var(--text-secondary); font-size: 14px; font-family: inherit;
    cursor: pointer; border-radius: var(--radius-md); transition: all 0.15s;
}
.project-dropdown button:hover { background: var(--bg-hover); color: var(--text-primary); }
.project-dropdown button.danger { color: #f87171; }
.project-dropdown button.danger:hover { background: rgba(248,113,113,0.1); }
.project-dropdown-sep { height: 1px; background: var(--border); margin: 4px 8px; }

.project-input-wrap { margin-bottom: 24px; max-width: 700px; }
.project-input-wrap .mode-dropdown {
    bottom: auto; top: 100%; margin-bottom: 0; margin-top: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.model-display-btn {
    display: flex; align-items: center; gap: 6px;
    background: none; border: none; color: var(--text-secondary);
    font-size: 13px; font-family: inherit; cursor: pointer;
    padding: 4px 8px; border-radius: 8px; transition: all 0.15s;
}
.model-display-btn:hover { color: var(--text-primary); background: var(--bg-hover); }
.model-extended-label {
    color: var(--text-muted); font-size: 12px;
}
.extended-toggle-btn {
    width: 32px; height: 32px; border-radius: 8px;
    background: none; border: none; color: var(--text-muted);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all 0.15s; font-size: 18px;
}
.extended-toggle-btn:hover { color: var(--text-primary); background: var(--bg-hover); }
.extended-toggle-btn.active { color: var(--accent); }
.project-chats-meta {
    font-size: 13px; color: var(--text-muted); padding: 8px 4px; margin-bottom: 4px;
}
.project-chats { flex: 1; overflow-y: auto; padding: 0 8px 40px; }
.project-chats .chats-list-item { margin-bottom: 0; }

.project-right-panel {
    width: 380px; flex-shrink: 0;
    display: flex; flex-direction: column; gap: 20px;
}

/* File selection bar */
.project-files-selection {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 12px; margin-bottom: 10px;
    background: var(--bg-tertiary); border-radius: var(--radius-md);
    font-size: 13px; color: var(--text-secondary);
}
.project-files-selection input[type="checkbox"] { accent-color: var(--accent); }
.project-files-selection button {
    background: none; border: none; color: var(--text-muted);
    cursor: pointer; padding: 4px; font-size: 16px;
    border-radius: var(--radius-sm); transition: all 0.15s;
}
.project-files-selection button:hover { color: var(--text-primary); background: var(--bg-hover); }

.project-file-bottom {
    display: flex; align-items: center; justify-content: space-between;
    margin-top: auto; padding-top: 8px;
}
.project-file-check {
    width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer;
}

/* File preview modal */
.file-preview-meta {
    font-size: 13px; color: var(--text-muted); margin-bottom: 16px;
}
.file-preview-code {
    background: #1a1a1a; border-radius: 12px; padding: 20px;
    font-family: 'JetBrains Mono', 'Monaco', 'Menlo', monospace;
    font-size: 13px; color: #cdd6f4; white-space: pre-wrap;
    word-break: break-all; max-height: 60vh; overflow-y: auto;
    line-height: 1.6; margin: 0; border: 1px solid rgba(255,255,255,0.06);
}

/* Project card menu */
.project-card { position: relative; }
.project-card-actions {
    position: absolute; top: 12px; right: 12px;
    opacity: 0; transition: opacity 0.15s;
}
.project-card:hover .project-card-actions { opacity: 1; }
.project-card-menu-btn {
    width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
    background: var(--bg-secondary); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text-muted);
    cursor: pointer; font-size: 18px; transition: all 0.15s;
}
.project-card-menu-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.project-card-dropdown {
    display: none; position: absolute; top: calc(100% + 4px); right: 0;
    background: var(--bg-secondary); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 6px; min-width: 180px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3); z-index: 100;
}
.project-card-dropdown.visible { display: block; }
.project-card-dropdown button {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 9px 14px; background: none; border: none;
    color: var(--text-secondary); font-size: 13px; font-family: inherit;
    cursor: pointer; border-radius: var(--radius-md); transition: all 0.15s;
}
.project-card-dropdown button:hover { background: var(--bg-hover); color: var(--text-primary); }
.project-card-dropdown button.danger { color: #f87171; }
.project-card-dropdown button.danger:hover { background: rgba(248,113,113,0.1); }
.project-section {
    background: var(--bg-secondary); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 20px;
}
.project-section-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 12px;
}
.project-section-header h3 { font-size: 15px; font-weight: 500; color: var(--text-primary); }
.project-section-header button {
    background: none; border: none; color: var(--text-muted);
    cursor: pointer; font-size: 18px; padding: 4px;
    border-radius: var(--radius-sm); transition: all 0.15s;
}
.project-section-header button:hover { color: var(--text-primary); background: var(--bg-hover); }
.project-section-desc {
    font-size: 13px; color: var(--text-muted); line-height: 1.5;
}
.project-files-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px;
}
.project-file-card {
    background: var(--bg-primary); border: 1px solid var(--border);
    border-radius: var(--radius-md); padding: 14px;
    cursor: pointer; transition: all 0.15s;
    display: flex; flex-direction: column; min-height: 90px;
}
.project-file-card:hover { border-color: var(--border-light); background: var(--bg-tertiary); }
.project-file-name { font-size: 13px; font-weight: 500; color: var(--text-primary); margin-bottom: 4px; }
.project-file-lines { font-size: 11px; color: var(--text-muted); }
.project-file-badge {
    display: inline-block; padding: 2px 8px;
    background: var(--bg-tertiary); border: 1px solid var(--border);
    border-radius: var(--radius-sm); font-size: 10px;
    color: var(--text-muted); text-transform: uppercase; font-weight: 600;
    width: fit-content;
}
.project-capacity {
    margin-bottom: 12px;
}
.project-capacity-bar {
    height: 4px; background: var(--border); border-radius: 2px;
    margin-bottom: 6px; overflow: hidden;
}
.project-capacity-fill {
    height: 100%; background: var(--accent); border-radius: 2px;
    transition: width 0.3s;
}
.project-capacity-text {
    font-size: 11px; color: var(--text-muted);
}

.btn-icon {
    width: 36px; height: 36px;
    background: var(--bg-secondary); border: 1px solid var(--border);
    border-radius: var(--radius-md); color: var(--text-secondary);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all 0.15s;
}
.btn-icon:hover { background: var(--bg-hover); color: var(--text-primary); }

@media (max-width: 900px) {
    .projects-grid { grid-template-columns: 1fr; }
    .project-page { flex-direction: column; gap: 24px; padding: 20px; }
    .project-right-panel { width: 100%; }
}

@media (max-width: 768px) {
    .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 200; transform: translateX(-100%); }
    .sidebar:not(.collapsed) { transform: translateX(0); }
    body.iframe-mode .sidebar { position: static !important; transform: none !important; z-index: auto !important; bottom: auto !important; }
    .builder-panel.visible { width: 100%; }
    .menu-btn { display: flex; }
    body.iframe-mode .menu-btn { display: none; }
    .page-container { padding: 20px; }
}

/* ========== THEME TOGGLE ========== */
.theme-toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 16px;
    flex-shrink: 0;
}
.theme-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-light);
}
body.iframe-mode .theme-toggle { display: none; }

/* ========== LIGHT MODE OVERRIDES ========== */
body.light-mode .sidebar {
    background: var(--bg-secondary);
    border-right-color: var(--border);
}
body.light-mode .mode-btn {
    background: rgba(0, 0, 0, 0.05);
    border-color: var(--border);
}
body.light-mode .mode-btn:hover {
    background: rgba(0, 0, 0, 0.1);
}
body.light-mode .mode-dropdown {
    box-shadow: 0 -8px 24px var(--shadow-strong);
}
body.light-mode .input-wrapper {
    background: var(--bg-secondary);
    border-color: var(--border);
}
body.light-mode .welcome-icon {
    background: linear-gradient(135deg, #0074ba, #7c3aed, #ec4899, #06b6d4);
    background-size: 300% 300%;
}
body.light-mode .quick-action {
    background: rgba(0,0,0,0.02);
    border-color: rgba(0,0,0,0.08);
}
body.light-mode .quick-action:hover {
    background: linear-gradient(135deg, rgba(0,116,186,0.05), rgba(124,58,237,0.03));
    border-color: rgba(124,58,237,0.3);
}
body.light-mode .quick-action:hover .idea-label {
    background: linear-gradient(90deg, var(--text-primary), #5b3cc4);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
body.light-mode .attachment-chip {
    background: rgba(0, 0, 0, 0.06);
    color: var(--text-primary);
}
body.light-mode .attachment-remove {
    background: rgba(0, 0, 0, 0.1);
    color: var(--text-primary);
}
body.light-mode .attachment-size {
    background: rgba(0, 0, 0, 0.06);
    color: var(--text-secondary);
}
body.light-mode .code-block {
    background: #fafafa;
    border-color: #e2e2e2;
    box-shadow: 0 2px 10px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.03);
}
body.light-mode .code-header {
    background: #f2f2f2;
    border-bottom-color: #e2e2e2;
    color: #6e6e6e;
}
body.light-mode .code-lang { color: #6e6e6e; }
body.light-mode .code-lang::before { background: var(--accent); }
body.light-mode .code-action-btn {
    background: rgba(0,0,0,0.03); border-color: rgba(0,0,0,0.08);
    color: #6e6e6e;
}
body.light-mode .code-action-btn:hover { background: rgba(0,0,0,0.06); color: #333; }
body.light-mode .code-content { background: #fafafa; }
body.light-mode .code-content code { color: #1a1a1a; }
body.light-mode .code-content::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); }
body.light-mode .code-content::-webkit-scrollbar-corner { background: #fafafa; }
body.light-mode .code-block-edit { border-color: rgba(202,138,4,0.3) !important; }
body.light-mode .code-block-edit .code-header { background: rgba(234,179,8,0.08); }
body.light-mode .edit-badge { background: rgba(202,138,4,0.12); color: #a16207; }
body.light-mode .edit-find { color: #dc2626; }
body.light-mode .edit-replace { color: #16a34a; }
body.light-mode .edit-end { color: #6e6e6e; }
body.light-mode .inline-code {
    background: rgba(0,0,0,0.04);
    color: #c05621;
    border-color: rgba(0,0,0,0.06);
}
body.light-mode .code-toolbar {
    background: #f5f5f5;
    border-bottom: 1px solid var(--border);
}
body.light-mode .code-toolbar button {
    color: var(--text-secondary);
}
body.light-mode .msg pre {
    background: #f5f5f5;
    border: 1px solid var(--border);
}
body.light-mode .msg code {
    background: rgba(0, 0, 0, 0.06);
}
body.light-mode .message-content tbody tr:nth-child(even) { background: rgba(0,0,0,0.02); }
body.light-mode .modal-overlay {
    background: rgba(0, 0, 0, 0.4);
}
body.light-mode .modal {
    box-shadow: 0 24px 48px var(--shadow-strong);
}
body.light-mode .main-header {
    background: linear-gradient(to bottom, rgba(0,0,0,0.03), transparent);
}
body.light-mode .stats-popover {
    box-shadow: 0 8px 24px var(--shadow);
}
body.light-mode .popover {
    box-shadow: 0 -4px 16px var(--shadow);
}
body.light-mode .mini-tooltip {
    box-shadow: 0 4px 16px var(--shadow);
}
body.light-mode .sidebar-toggle-tooltip {
    box-shadow: 0 4px 16px var(--shadow);
}
body.light-mode .chats-context-menu,
body.light-mode .title-dropdown {
    box-shadow: 0 8px 24px var(--shadow-strong);
}
body.light-mode .send-btn {
    background: var(--accent);
    color: #fff;
}
body.light-mode .toast {
    box-shadow: 0 8px 24px var(--shadow-strong);
}

/* Light mode iframe overrides */
body.light-mode.iframe-mode .sidebar {
    background: linear-gradient(180deg, var(--bg-secondary) 0%, rgba(240, 240, 240, 0.98) 100%);
    box-shadow: 0 2px 8px var(--shadow);
}
body.light-mode.iframe-mode .sidebar .new-chat-full-btn,
body.light-mode.iframe-mode .sidebar .sidebar-nav-btn {
    background: rgba(0, 0, 0, 0.04);
    border-color: var(--border);
}
body.light-mode.iframe-mode .sidebar .new-chat-full-btn:hover,
body.light-mode.iframe-mode .sidebar .sidebar-nav-btn:hover {
    background: rgba(0, 0, 0, 0.08);
}
body.light-mode.iframe-mode .sidebar .new-chat-full-btn.active,
body.light-mode.iframe-mode .sidebar .sidebar-nav-btn.active {
    background: rgba(0, 0, 0, 0.1);
    color: var(--text-primary);
}
