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

[hidden] {
    display: none !important;
}

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-tertiary: #1a1a25;
    --bg-card: rgba(255, 255, 255, 0.03);
    --text-primary: #f0f0f5;
    --text-secondary: #a0a0b0;
    --text-muted: #6a6a7a;
    --accent-green: #10b981;
    --accent-blue: #3b82f6;
    --accent-purple: #8b5cf6;
    --accent-pink: #ec4899;
    --accent-cyan: #06b6d4;
    --accent-amber: #f59e0b;
    --accent-orange: #f97316;
    --accent-red: #ef4444;
    --border-color: rgba(255, 255, 255, 0.08);
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.08);
    --shadow-color: rgba(0, 0, 0, 0.3);
    --page-bg: var(--bg-primary);
    --surface-hover: rgba(255, 255, 255, 0.05);
    --surface-hover-strong: rgba(255, 255, 255, 0.08);
    --surface-active: rgba(255, 255, 255, 0.06);
    --surface-border-strong: rgba(255, 255, 255, 0.15);
    --scrollbar-thumb-hover: rgba(255, 255, 255, 0.1);
    --view-active-bg: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(59, 130, 246, 0.2));
    --orb-1: radial-gradient(circle, rgba(139, 92, 246, 0.4) 0%, rgba(59, 130, 246, 0.2) 50%, transparent 70%);
    --orb-2: radial-gradient(circle, rgba(16, 185, 129, 0.35) 0%, rgba(6, 182, 212, 0.2) 50%, transparent 70%);
    --orb-3: radial-gradient(circle, rgba(236, 72, 153, 0.3) 0%, rgba(139, 92, 246, 0.2) 50%, transparent 70%);
    --orb-opacity: 0.5;
    --orb-blur: 80px;
    --palette-dot: linear-gradient(135deg, #8b5cf6, #3b82f6);
    --project-card-surface: linear-gradient(148deg, var(--bg-secondary), var(--bg-primary));
    --project-card-tint-top: linear-gradient(165deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0) 44%);
    --project-card-tint-bottom: var(--view-active-bg);
    --project-card-blend-mode: normal, soft-light, normal;
    --project-card-border: var(--border-color);
    --project-card-orb: radial-gradient(circle at center, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0) 72%);
    --project-card-orb-opacity: 0.28;
    --project-card-hover-border: var(--surface-border-strong);
    --project-card-hover-shadow: 0 10px 24px var(--shadow-color);
    --project-icon-bg: var(--view-active-bg);
    --project-icon-color: var(--accent-purple);
    --project-genre-color: var(--accent-cyan);
    --project-stat-bg: var(--glass-bg);
    --project-stat-border: var(--glass-border);
    --project-progress-track: var(--surface-active);
    --project-progress-fill: var(--palette-dot);
    --project-progress-glow: 0 0 6px var(--shadow-color);
    --project-progress-text: var(--text-secondary);
    --project-btn-border: var(--surface-border-strong);
    --project-btn-bg: var(--view-active-bg), linear-gradient(122deg, var(--bg-tertiary), var(--bg-secondary));
    --project-btn-color: var(--text-primary);
    --project-btn-hover-border: var(--accent-blue);
    --project-btn-hover-shadow: 0 6px 12px var(--shadow-color);
    --project-new-hover-border: var(--surface-border-strong);
    --project-new-hover-bg: var(--surface-hover);
    --project-active-border: var(--accent-blue);
    --project-active-shadow: 0 8px 22px var(--shadow-color);
    --project-generating-border: var(--accent-purple);
    --project-generating-shadow: 0 8px 24px var(--shadow-color);
    --project-generating-shadow-active: 0 10px 30px var(--shadow-color);
    --project-generating-overlay: var(--view-active-bg);
    --project-generating-indicator-bg: var(--surface-hover-strong);
    --project-generating-indicator-border: var(--surface-border-strong);
    --project-generating-indicator-text: var(--text-secondary);
    --project-generating-spinner-track: var(--surface-border-strong);
    --project-generating-spinner-head: var(--accent-purple);
    --project-ring-generating-bg: var(--view-active-bg);
    --project-ring-complete-bg: var(--view-active-bg);
    --project-ring-spinner: var(--accent-purple);
    --project-ring-track: var(--surface-border-strong);
    --project-ring-icon: var(--accent-purple);
    --project-ring-complete-icon: var(--accent-cyan);
    --project-ring-complete-track: var(--accent-cyan);
    --project-ring-complete-pulse: var(--accent-cyan);
    --project-creating-border: var(--accent-amber);
    --project-creating-shadow: 0 9px 26px var(--shadow-color);
    --project-creation-overlay-bg: linear-gradient(to top, var(--bg-secondary) 80%, transparent);
    --project-creation-spinner-track: var(--surface-border-strong);
    --project-creation-progress-track: var(--surface-active);
    --project-ring-creating-bg: var(--view-active-bg);
    --project-ring-creating-track: var(--accent-amber);
    --project-failed-border: var(--accent-red);
    --project-ring-failed-bg: var(--view-active-bg);
    --project-ring-failed-track: var(--accent-red);
    --project-tool-group-bg: rgba(53, 67, 140, 0.28);
    --project-tool-group-border: rgba(132, 149, 236, 0.24);
    --project-tool-bg: rgba(83, 102, 196, 0.24);
    --project-tool-border: rgba(132, 149, 236, 0.2);
    --project-tool-color: #aab4dd;
    --project-tool-hover-bg: rgba(106, 128, 230, 0.32);
    --project-tool-hover-color: #d5dcff;
    --project-tool-hover-border: rgba(150, 167, 247, 0.42);
    --project-tool-delete-hover-bg: rgba(239, 68, 68, 0.16);
    --project-tool-delete-hover-border: rgba(248, 113, 113, 0.45);
    --project-tool-delete-hover-color: #f87171;
    --project-title-font-cjk: 'Source Han Serif SC', 'Noto Serif SC', 'Songti SC', 'STSong', 'SimSun', serif;
    --project-title-font-latin: 'Trajan Pro', 'Trajan', 'Cinzel', 'Times New Roman', serif;
    --project-hub-surface: linear-gradient(158deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
    --project-hub-overlay-top: var(--orb-1);
    --project-hub-overlay-bottom: var(--orb-2);
    --project-hub-overlay-opacity: 0.42;
    --project-hub-border: var(--glass-border);
    --project-hub-shadow: inset 0 1px 0 var(--surface-border-strong), 0 14px 26px var(--shadow-color);
    --project-hub-avatar-bg: var(--palette-dot);
    --project-hub-avatar-border: var(--surface-border-strong);
    --project-hub-avatar-shadow: 0 8px 16px var(--shadow-color);
    --project-hub-avatar-text: #f6f8fc;
    --project-hub-primary-bg: var(--palette-dot);
    --project-hub-primary-shadow: 0 12px 22px var(--shadow-color);
    --project-hub-primary-hover-shadow: 0 16px 28px var(--shadow-color);
    --project-hub-ghost-bg: var(--surface-hover);
    --project-hub-ghost-border: var(--glass-border);
    --project-hub-ghost-hover-bg: var(--surface-hover-strong);
    --project-hub-item-hover-bg: var(--surface-hover);
    --project-hub-item-active-bg: var(--view-active-bg);
    --project-hub-item-active-border: var(--surface-border-strong);
    --project-hub-logout-border: var(--glass-border);
    --project-hub-logout-bg: var(--surface-hover);
    --project-hub-logout-text: var(--text-secondary);
    --project-hub-logout-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
    --project-hub-logout-icon-border: var(--glass-border);
    --project-hub-logout-icon-bg: var(--surface-hover-strong);
    --project-hub-logout-icon-color: var(--text-secondary);
    --project-hub-logout-hover-border: var(--surface-border-strong);
    --project-hub-logout-hover-bg: var(--surface-hover-strong);
    --project-hub-logout-hover-text: var(--text-primary);
    --project-hub-logout-hover-shadow: 0 8px 16px var(--shadow-color);
    --project-hub-logout-icon-hover-border: var(--surface-border-strong);
    --project-hub-logout-icon-hover-bg: var(--surface-active);
    --project-hub-logout-icon-hover-color: var(--text-primary);
    --project-hub-logout-focus: var(--accent-blue);
    --lang-switch-track-bg: linear-gradient(145deg, rgba(53, 67, 140, 0.28), rgba(53, 67, 140, 0.2));
    --lang-switch-track-border: rgba(132, 149, 236, 0.22);
    --lang-switch-track-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 8px 18px rgba(6, 10, 24, 0.26);
    --lang-switch-handle-bg: linear-gradient(160deg, rgba(255, 255, 255, 0.98), rgba(237, 242, 255, 0.9));
    --lang-switch-handle-shadow: 0 5px 14px rgba(5, 8, 20, 0.3);
    --lang-switch-text: #aeb8df;
    --lang-switch-text-active: #2f3a69;
}

:root[data-theme="light"] {
    --bg-primary: #f6f1e9;
    --bg-secondary: #fbf7f1;
    --bg-tertiary: #efe7db;
    --bg-card: rgba(255, 255, 255, 0.72);
    --text-primary: #2b2622;
    --text-secondary: #5a534c;
    --text-muted: #8a8176;
    --accent-purple: #6e79b8;
    --accent-pink: #c98f9e;
    --border-color: rgba(54, 45, 38, 0.12);
    --glass-bg: rgba(255, 255, 255, 0.72);
    --glass-border: rgba(54, 45, 38, 0.1);
    --shadow-color: rgba(52, 42, 33, 0.12);
    --page-bg: radial-gradient(120% 120% at 12% 6%, rgba(240, 198, 160, 0.45), transparent 58%),
        radial-gradient(140% 140% at 88% 0%, rgba(173, 209, 234, 0.42), transparent 62%),
        radial-gradient(120% 120% at 50% 100%, rgba(186, 222, 209, 0.38), transparent 62%),
        linear-gradient(180deg, #f7f3ec 0%, #efe7dc 100%);
    --surface-hover: rgba(35, 29, 24, 0.03);
    --surface-hover-strong: rgba(35, 29, 24, 0.06);
    --surface-active: rgba(35, 29, 24, 0.05);
    --surface-border-strong: rgba(35, 29, 24, 0.16);
    --scrollbar-thumb-hover: rgba(35, 29, 24, 0.18);
    --view-active-bg: linear-gradient(135deg, rgba(91, 140, 255, 0.12), rgba(111, 214, 198, 0.12));
    --orb-1: radial-gradient(circle, rgba(240, 194, 154, 0.3) 0%, rgba(229, 164, 111, 0.18) 52%, transparent 72%);
    --orb-2: radial-gradient(circle, rgba(166, 205, 242, 0.26) 0%, rgba(198, 225, 250, 0.16) 56%, transparent 72%);
    --orb-3: radial-gradient(circle, rgba(176, 226, 210, 0.26) 0%, rgba(206, 240, 230, 0.16) 56%, transparent 72%);
    --orb-opacity: 0.24;
    --orb-blur: 120px;
    --palette-dot: linear-gradient(135deg, #8b5cf6, #3b82f6);
    --project-hub-overlay-opacity: 0.32;
    --project-hub-avatar-text: #f7f9ff;
    --project-hub-logout-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
    --lang-switch-track-bg: linear-gradient(145deg, rgba(233, 226, 214, 0.86), rgba(239, 233, 223, 0.72));
    --lang-switch-track-border: rgba(94, 81, 64, 0.16);
    --lang-switch-track-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75), 0 6px 14px rgba(84, 67, 50, 0.12);
    --lang-switch-handle-bg: linear-gradient(160deg, rgba(255, 255, 255, 0.98), rgba(250, 247, 242, 0.95));
    --lang-switch-handle-shadow: 0 4px 10px rgba(74, 58, 43, 0.14);
    --lang-switch-text: #6c6357;
    --lang-switch-text-active: #2b2622;
}

:root[data-palette="noir"] {
    --palette-dot: linear-gradient(135deg, #8b5cf6, #3b82f6);
}

:root[data-palette="mist"] {
    --bg-primary: #0f1211;
    --bg-secondary: #171d1c;
    --bg-tertiary: #1f2625;
    --bg-card: rgba(255, 255, 255, 0.035);
    --text-primary: #f2efe8;
    --text-secondary: #c3b8ad;
    --text-muted: #8d837a;
    --accent-green: #7fb79a;
    --accent-blue: #4da8b6;
    --accent-purple: #9b8bb3;
    --accent-pink: #d6a090;
    --accent-cyan: #6fc9c3;
    --accent-amber: #e5a46f;
    --accent-orange: #d48a54;
    --accent-red: #d06b5d;
    --border-color: rgba(255, 255, 255, 0.08);
    --glass-bg: rgba(255, 255, 255, 0.035);
    --glass-border: rgba(255, 255, 255, 0.08);
    --shadow-color: rgba(0, 0, 0, 0.35);
    --view-active-bg: linear-gradient(135deg, rgba(77, 168, 182, 0.2), rgba(229, 164, 111, 0.18));
    --orb-1: radial-gradient(circle, rgba(77, 168, 182, 0.35) 0%, rgba(111, 201, 195, 0.18) 50%, transparent 70%);
    --orb-2: radial-gradient(circle, rgba(229, 164, 111, 0.32) 0%, rgba(212, 138, 84, 0.18) 50%, transparent 70%);
    --orb-3: radial-gradient(circle, rgba(141, 154, 123, 0.28) 0%, rgba(127, 183, 154, 0.18) 55%, transparent 72%);
    --orb-opacity: 0.45;
    --palette-dot: linear-gradient(135deg, #4da8b6, #e5a46f);
}

:root[data-theme="light"][data-palette="mist"] {
    --bg-primary: #fdfaf4;
    --bg-secondary: #f7f1e6;
    --bg-tertiary: #efe3d3;
    --bg-card: rgba(255, 255, 255, 0.75);
    --text-primary: #2b2420;
    --text-secondary: #5e564c;
    --text-muted: #8b837a;
    --accent-purple: #9c8fae;
    --accent-pink: #d4a394;
    --border-color: rgba(61, 52, 44, 0.14);
    --glass-bg: rgba(255, 255, 255, 0.75);
    --glass-border: rgba(61, 52, 44, 0.12);
    --shadow-color: rgba(45, 35, 27, 0.12);
    --page-bg: radial-gradient(120% 120% at 12% 6%, rgba(240, 194, 154, 0.4), transparent 58%),
        radial-gradient(140% 140% at 88% 0%, rgba(77, 168, 182, 0.35), transparent 62%),
        radial-gradient(120% 120% at 50% 100%, rgba(141, 154, 123, 0.25), transparent 62%),
        linear-gradient(180deg, #fdfaf4 0%, #f2e8d8 100%);
    --view-active-bg: linear-gradient(135deg, rgba(77, 168, 182, 0.16), rgba(229, 164, 111, 0.16));
    --orb-1: radial-gradient(circle, rgba(240, 194, 154, 0.3) 0%, rgba(229, 164, 111, 0.18) 52%, transparent 72%);
    --orb-2: radial-gradient(circle, rgba(77, 168, 182, 0.28) 0%, rgba(111, 201, 195, 0.16) 56%, transparent 72%);
    --orb-3: radial-gradient(circle, rgba(141, 154, 123, 0.24) 0%, rgba(167, 192, 139, 0.16) 56%, transparent 72%);
    --orb-opacity: 0.3;
    --palette-dot: linear-gradient(135deg, #4da8b6, #e5a46f);
}

:root[data-palette="ember"] {
    --bg-primary: #12100f;
    --bg-secondary: #1a1614;
    --bg-tertiary: #231d19;
    --bg-card: rgba(255, 255, 255, 0.03);
    --text-primary: #f5efe9;
    --text-secondary: #c9b7aa;
    --text-muted: #9d8b80;
    --accent-green: #a7c08b;
    --accent-blue: #6c8fb0;
    --accent-purple: #9a6b5f;
    --accent-pink: #d47d6f;
    --accent-cyan: #7fb3a7;
    --accent-amber: #f0b36b;
    --accent-orange: #dd7f45;
    --accent-red: #c95a3e;
    --border-color: rgba(255, 255, 255, 0.08);
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.08);
    --shadow-color: rgba(0, 0, 0, 0.35);
    --view-active-bg: linear-gradient(135deg, rgba(240, 179, 107, 0.22), rgba(201, 90, 62, 0.18));
    --orb-1: radial-gradient(circle, rgba(240, 179, 107, 0.35) 0%, rgba(221, 127, 69, 0.18) 50%, transparent 70%);
    --orb-2: radial-gradient(circle, rgba(201, 90, 62, 0.3) 0%, rgba(154, 107, 95, 0.18) 50%, transparent 70%);
    --orb-3: radial-gradient(circle, rgba(127, 179, 167, 0.24) 0%, rgba(167, 192, 139, 0.18) 55%, transparent 72%);
    --orb-opacity: 0.45;
    --palette-dot: linear-gradient(135deg, #f0b36b, #d05d52);
}

:root[data-theme="light"][data-palette="ember"] {
    --bg-primary: #fff8ef;
    --bg-secondary: #f8efe5;
    --bg-tertiary: #efe1d2;
    --bg-card: rgba(255, 255, 255, 0.75);
    --text-primary: #2a201a;
    --text-secondary: #5b4a3e;
    --text-muted: #8b7a6f;
    --accent-purple: #a17a70;
    --accent-pink: #d07b6c;
    --border-color: rgba(66, 50, 40, 0.14);
    --glass-bg: rgba(255, 255, 255, 0.75);
    --glass-border: rgba(66, 50, 40, 0.12);
    --shadow-color: rgba(52, 38, 30, 0.12);
    --page-bg: radial-gradient(120% 120% at 10% 6%, rgba(240, 179, 107, 0.38), transparent 58%),
        radial-gradient(140% 140% at 90% 0%, rgba(201, 90, 62, 0.25), transparent 62%),
        radial-gradient(120% 120% at 50% 100%, rgba(127, 179, 167, 0.22), transparent 62%),
        linear-gradient(180deg, #fff8ef 0%, #f2e5d6 100%);
    --view-active-bg: linear-gradient(135deg, rgba(240, 179, 107, 0.18), rgba(201, 90, 62, 0.14));
    --orb-1: radial-gradient(circle, rgba(240, 179, 107, 0.3) 0%, rgba(221, 127, 69, 0.18) 52%, transparent 72%);
    --orb-2: radial-gradient(circle, rgba(201, 90, 62, 0.26) 0%, rgba(154, 107, 95, 0.16) 56%, transparent 72%);
    --orb-3: radial-gradient(circle, rgba(127, 179, 167, 0.22) 0%, rgba(167, 192, 139, 0.16) 56%, transparent 72%);
    --orb-opacity: 0.28;
    --palette-dot: linear-gradient(135deg, #f0b36b, #d05d52);
}

:root[data-palette="aurora"] {
    --bg-primary: #0b1116;
    --bg-secondary: #121a21;
    --bg-tertiary: #1a232c;
    --bg-card: rgba(255, 255, 255, 0.035);
    --text-primary: #edf3f8;
    --text-secondary: #b7c4d4;
    --text-muted: #7b8899;
    --accent-green: #4fd1a5;
    --accent-blue: #60a5fa;
    --accent-purple: #8b7bff;
    --accent-pink: #f472b6;
    --accent-cyan: #22d3ee;
    --accent-amber: #fbbf24;
    --accent-orange: #fb923c;
    --accent-red: #f87171;
    --border-color: rgba(255, 255, 255, 0.08);
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.08);
    --shadow-color: rgba(0, 0, 0, 0.35);
    --view-active-bg: linear-gradient(135deg, rgba(34, 211, 238, 0.2), rgba(96, 165, 250, 0.18));
    --orb-1: radial-gradient(circle, rgba(34, 211, 238, 0.32) 0%, rgba(96, 165, 250, 0.18) 50%, transparent 70%);
    --orb-2: radial-gradient(circle, rgba(79, 209, 165, 0.28) 0%, rgba(34, 211, 238, 0.16) 55%, transparent 72%);
    --orb-3: radial-gradient(circle, rgba(139, 123, 255, 0.24) 0%, rgba(244, 114, 182, 0.16) 55%, transparent 72%);
    --orb-opacity: 0.45;
    --palette-dot: linear-gradient(135deg, #22d3ee, #60a5fa);
}

:root[data-theme="light"][data-palette="aurora"] {
    --bg-primary: #f3f7fb;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e6edf4;
    --bg-card: rgba(255, 255, 255, 0.75);
    --text-primary: #1d2938;
    --text-secondary: #4b5b6d;
    --text-muted: #7b8a9a;
    --accent-purple: #6b7cff;
    --accent-pink: #e684b1;
    --border-color: rgba(15, 23, 42, 0.12);
    --glass-bg: rgba(255, 255, 255, 0.75);
    --glass-border: rgba(15, 23, 42, 0.1);
    --shadow-color: rgba(15, 23, 42, 0.1);
    --page-bg: radial-gradient(120% 120% at 12% 6%, rgba(120, 200, 218, 0.35), transparent 58%),
        radial-gradient(140% 140% at 88% 0%, rgba(130, 176, 255, 0.28), transparent 62%),
        radial-gradient(120% 120% at 50% 100%, rgba(160, 230, 205, 0.25), transparent 62%),
        linear-gradient(180deg, #f3f7fb 0%, #e7eef7 100%);
    --view-active-bg: linear-gradient(135deg, rgba(34, 211, 238, 0.16), rgba(96, 165, 250, 0.14));
    --orb-1: radial-gradient(circle, rgba(120, 200, 218, 0.3) 0%, rgba(130, 176, 255, 0.18) 52%, transparent 72%);
    --orb-2: radial-gradient(circle, rgba(160, 230, 205, 0.26) 0%, rgba(96, 165, 250, 0.16) 56%, transparent 72%);
    --orb-3: radial-gradient(circle, rgba(168, 190, 255, 0.22) 0%, rgba(230, 186, 216, 0.16) 56%, transparent 72%);
    --orb-opacity: 0.28;
    --palette-dot: linear-gradient(135deg, #22d3ee, #60a5fa);
}

:root[data-palette="sakura"] {
    --bg-primary: #120f14;
    --bg-secondary: #1a151c;
    --bg-tertiary: #231d26;
    --bg-card: rgba(255, 255, 255, 0.035);
    --text-primary: #f4eef5;
    --text-secondary: #c4b2c7;
    --text-muted: #8f8096;
    --accent-green: #86efac;
    --accent-blue: #7dd3fc;
    --accent-purple: #c084fc;
    --accent-pink: #f472b6;
    --accent-cyan: #67e8f9;
    --accent-amber: #fbbf24;
    --accent-orange: #fb7185;
    --accent-red: #f43f5e;
    --border-color: rgba(255, 255, 255, 0.08);
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.08);
    --shadow-color: rgba(0, 0, 0, 0.35);
    --view-active-bg: linear-gradient(135deg, rgba(244, 114, 182, 0.22), rgba(192, 132, 252, 0.18));
    --orb-1: radial-gradient(circle, rgba(244, 114, 182, 0.32) 0%, rgba(192, 132, 252, 0.18) 50%, transparent 70%);
    --orb-2: radial-gradient(circle, rgba(125, 211, 252, 0.24) 0%, rgba(103, 232, 249, 0.16) 55%, transparent 72%);
    --orb-3: radial-gradient(circle, rgba(248, 164, 216, 0.22) 0%, rgba(134, 239, 172, 0.16) 55%, transparent 72%);
    --orb-opacity: 0.45;
    --palette-dot: linear-gradient(135deg, #f472b6, #c084fc);
}

:root[data-theme="light"][data-palette="sakura"] {
    --bg-primary: #fff5fb;
    --bg-secondary: #f9eef6;
    --bg-tertiary: #f1e3ee;
    --bg-card: rgba(255, 255, 255, 0.75);
    --text-primary: #2d2430;
    --text-secondary: #594d62;
    --text-muted: #8a7c92;
    --accent-purple: #b58dfc;
    --accent-pink: #f095c0;
    --border-color: rgba(46, 38, 58, 0.12);
    --glass-bg: rgba(255, 255, 255, 0.75);
    --glass-border: rgba(46, 38, 58, 0.1);
    --shadow-color: rgba(46, 38, 58, 0.12);
    --page-bg: radial-gradient(120% 120% at 12% 6%, rgba(248, 186, 214, 0.35), transparent 58%),
        radial-gradient(140% 140% at 88% 0%, rgba(192, 132, 252, 0.25), transparent 62%),
        radial-gradient(120% 120% at 50% 100%, rgba(134, 239, 172, 0.22), transparent 62%),
        linear-gradient(180deg, #fff5fb 0%, #f3e9f2 100%);
    --view-active-bg: linear-gradient(135deg, rgba(244, 114, 182, 0.18), rgba(192, 132, 252, 0.14));
    --orb-1: radial-gradient(circle, rgba(248, 186, 214, 0.3) 0%, rgba(240, 149, 192, 0.18) 52%, transparent 72%);
    --orb-2: radial-gradient(circle, rgba(192, 132, 252, 0.24) 0%, rgba(125, 211, 252, 0.16) 56%, transparent 72%);
    --orb-3: radial-gradient(circle, rgba(134, 239, 172, 0.2) 0%, rgba(248, 164, 216, 0.16) 56%, transparent 72%);
    --orb-opacity: 0.28;
    --palette-dot: linear-gradient(135deg, #f472b6, #c084fc);
}

:root[data-palette="forest"] {
    --bg-primary: #0f1310;
    --bg-secondary: #161d17;
    --bg-tertiary: #1f2720;
    --bg-card: rgba(255, 255, 255, 0.03);
    --text-primary: #eef4ee;
    --text-secondary: #b8c7b8;
    --text-muted: #7d8c7d;
    --accent-green: #7fdc9b;
    --accent-blue: #5eb1d6;
    --accent-purple: #a38bff;
    --accent-pink: #f2a1b8;
    --accent-cyan: #4fd1c5;
    --accent-amber: #fbbf24;
    --accent-orange: #fb923c;
    --accent-red: #f87171;
    --border-color: rgba(255, 255, 255, 0.08);
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.08);
    --shadow-color: rgba(0, 0, 0, 0.35);
    --view-active-bg: linear-gradient(135deg, rgba(127, 220, 155, 0.2), rgba(94, 177, 214, 0.18));
    --orb-1: radial-gradient(circle, rgba(127, 220, 155, 0.32) 0%, rgba(79, 209, 197, 0.18) 50%, transparent 70%);
    --orb-2: radial-gradient(circle, rgba(94, 177, 214, 0.26) 0%, rgba(163, 139, 255, 0.18) 55%, transparent 72%);
    --orb-3: radial-gradient(circle, rgba(160, 206, 148, 0.24) 0%, rgba(127, 220, 155, 0.16) 55%, transparent 72%);
    --orb-opacity: 0.45;
    --palette-dot: linear-gradient(135deg, #7fdc9b, #4fd1c5);
}

:root[data-theme="light"][data-palette="forest"] {
    --bg-primary: #f5fbf6;
    --bg-secondary: #eef6f0;
    --bg-tertiary: #e2efe5;
    --bg-card: rgba(255, 255, 255, 0.75);
    --text-primary: #233126;
    --text-secondary: #516055;
    --text-muted: #7c8a80;
    --accent-purple: #8f7ef5;
    --accent-pink: #e78ea9;
    --border-color: rgba(34, 50, 38, 0.12);
    --glass-bg: rgba(255, 255, 255, 0.75);
    --glass-border: rgba(34, 50, 38, 0.1);
    --shadow-color: rgba(34, 50, 38, 0.12);
    --page-bg: radial-gradient(120% 120% at 12% 6%, rgba(167, 212, 184, 0.35), transparent 58%),
        radial-gradient(140% 140% at 88% 0%, rgba(126, 198, 219, 0.25), transparent 62%),
        radial-gradient(120% 120% at 50% 100%, rgba(196, 228, 206, 0.24), transparent 62%),
        linear-gradient(180deg, #f5fbf6 0%, #e7f0ea 100%);
    --view-active-bg: linear-gradient(135deg, rgba(127, 220, 155, 0.16), rgba(94, 177, 214, 0.14));
    --orb-1: radial-gradient(circle, rgba(167, 212, 184, 0.3) 0%, rgba(126, 198, 219, 0.18) 52%, transparent 72%);
    --orb-2: radial-gradient(circle, rgba(196, 228, 206, 0.26) 0%, rgba(127, 220, 155, 0.16) 56%, transparent 72%);
    --orb-3: radial-gradient(circle, rgba(143, 126, 245, 0.2) 0%, rgba(231, 142, 169, 0.16) 56%, transparent 72%);
    --orb-opacity: 0.28;
    --palette-dot: linear-gradient(135deg, #7fdc9b, #4fd1c5);
}

:root[data-palette="glacier"] {
    --bg-primary: #0e1117;
    --bg-secondary: #151a22;
    --bg-tertiary: #1e2430;
    --bg-card: rgba(255, 255, 255, 0.03);
    --text-primary: #eef2f7;
    --text-secondary: #b6c0d0;
    --text-muted: #7b8796;
    --accent-green: #5eead4;
    --accent-blue: #5b8cff;
    --accent-purple: #8b7bff;
    --accent-pink: #f0abfc;
    --accent-cyan: #7dd3fc;
    --accent-amber: #fbbf24;
    --accent-orange: #fb923c;
    --accent-red: #f87171;
    --border-color: rgba(255, 255, 255, 0.08);
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.08);
    --shadow-color: rgba(0, 0, 0, 0.35);
    --view-active-bg: linear-gradient(135deg, rgba(91, 140, 255, 0.2), rgba(125, 211, 252, 0.18));
    --orb-1: radial-gradient(circle, rgba(91, 140, 255, 0.32) 0%, rgba(125, 211, 252, 0.18) 50%, transparent 70%);
    --orb-2: radial-gradient(circle, rgba(94, 234, 212, 0.26) 0%, rgba(125, 211, 252, 0.16) 55%, transparent 72%);
    --orb-3: radial-gradient(circle, rgba(139, 123, 255, 0.24) 0%, rgba(240, 171, 252, 0.16) 55%, transparent 72%);
    --orb-opacity: 0.45;
    --palette-dot: linear-gradient(135deg, #5b8cff, #7dd3fc);
}

:root[data-theme="light"][data-palette="glacier"] {
    --bg-primary: #f4f7fc;
    --bg-secondary: #edf2f9;
    --bg-tertiary: #e1e8f2;
    --bg-card: rgba(255, 255, 255, 0.75);
    --text-primary: #1f2b3a;
    --text-secondary: #4b5c70;
    --text-muted: #7a889a;
    --accent-purple: #7f73f0;
    --accent-pink: #d6a1f3;
    --border-color: rgba(26, 38, 56, 0.12);
    --glass-bg: rgba(255, 255, 255, 0.75);
    --glass-border: rgba(26, 38, 56, 0.1);
    --shadow-color: rgba(26, 38, 56, 0.12);
    --page-bg: radial-gradient(120% 120% at 12% 6%, rgba(120, 160, 230, 0.32), transparent 58%),
        radial-gradient(140% 140% at 88% 0%, rgba(140, 210, 248, 0.26), transparent 62%),
        radial-gradient(120% 120% at 50% 100%, rgba(180, 230, 220, 0.22), transparent 62%),
        linear-gradient(180deg, #f4f7fc 0%, #e8eef7 100%);
    --view-active-bg: linear-gradient(135deg, rgba(91, 140, 255, 0.16), rgba(125, 211, 252, 0.14));
    --orb-1: radial-gradient(circle, rgba(120, 160, 230, 0.28) 0%, rgba(140, 210, 248, 0.16) 52%, transparent 72%);
    --orb-2: radial-gradient(circle, rgba(180, 230, 220, 0.24) 0%, rgba(125, 211, 252, 0.16) 56%, transparent 72%);
    --orb-3: radial-gradient(circle, rgba(127, 115, 240, 0.2) 0%, rgba(214, 161, 243, 0.16) 56%, transparent 72%);
    --orb-opacity: 0.28;
    --palette-dot: linear-gradient(135deg, #5b8cff, #7dd3fc);
}

:root[data-palette="solar"] {
    --bg-primary: #14100b;
    --bg-secondary: #1d1710;
    --bg-tertiary: #261f16;
    --bg-card: rgba(255, 255, 255, 0.03);
    --text-primary: #f6f0e5;
    --text-secondary: #cbb9a1;
    --text-muted: #9a8a76;
    --accent-green: #a3e635;
    --accent-blue: #60a5fa;
    --accent-purple: #c084fc;
    --accent-pink: #fda4af;
    --accent-cyan: #5eead4;
    --accent-amber: #f59e0b;
    --accent-orange: #fb923c;
    --accent-red: #f87171;
    --border-color: rgba(255, 255, 255, 0.08);
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.08);
    --shadow-color: rgba(0, 0, 0, 0.35);
    --view-active-bg: linear-gradient(135deg, rgba(245, 158, 11, 0.22), rgba(251, 146, 60, 0.18));
    --orb-1: radial-gradient(circle, rgba(245, 158, 11, 0.35) 0%, rgba(251, 146, 60, 0.18) 50%, transparent 70%);
    --orb-2: radial-gradient(circle, rgba(251, 146, 60, 0.3) 0%, rgba(248, 113, 113, 0.18) 50%, transparent 70%);
    --orb-3: radial-gradient(circle, rgba(163, 230, 53, 0.24) 0%, rgba(94, 234, 212, 0.16) 55%, transparent 72%);
    --orb-opacity: 0.45;
    --palette-dot: linear-gradient(135deg, #f59e0b, #fb923c);
}

:root[data-theme="light"][data-palette="solar"] {
    --bg-primary: #fff7ea;
    --bg-secondary: #f9efe0;
    --bg-tertiary: #f1e2cc;
    --bg-card: rgba(255, 255, 255, 0.75);
    --text-primary: #2b2418;
    --text-secondary: #5b4b36;
    --text-muted: #8f7b63;
    --accent-purple: #b58dfc;
    --accent-pink: #f29aa5;
    --border-color: rgba(64, 50, 34, 0.12);
    --glass-bg: rgba(255, 255, 255, 0.75);
    --glass-border: rgba(64, 50, 34, 0.1);
    --shadow-color: rgba(64, 50, 34, 0.12);
    --page-bg: radial-gradient(120% 120% at 12% 6%, rgba(248, 200, 128, 0.35), transparent 58%),
        radial-gradient(140% 140% at 88% 0%, rgba(251, 146, 60, 0.25), transparent 62%),
        radial-gradient(120% 120% at 50% 100%, rgba(198, 232, 146, 0.22), transparent 62%),
        linear-gradient(180deg, #fff7ea 0%, #f3e6d3 100%);
    --view-active-bg: linear-gradient(135deg, rgba(245, 158, 11, 0.18), rgba(251, 146, 60, 0.14));
    --orb-1: radial-gradient(circle, rgba(248, 200, 128, 0.3) 0%, rgba(251, 146, 60, 0.18) 52%, transparent 72%);
    --orb-2: radial-gradient(circle, rgba(251, 146, 60, 0.24) 0%, rgba(248, 113, 113, 0.16) 56%, transparent 72%);
    --orb-3: radial-gradient(circle, rgba(198, 232, 146, 0.2) 0%, rgba(94, 234, 212, 0.16) 56%, transparent 72%);
    --orb-opacity: 0.28;
    --palette-dot: linear-gradient(135deg, #f59e0b, #fb923c);
}

body {
    font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--page-bg);
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    overflow: hidden;
}

.gradient-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
    background: var(--page-bg);
}

/* Context Menu */
.context-menu {
    position: fixed;
    z-index: 10000;
    min-width: 140px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 8px 24px var(--shadow-color);
    padding: 6px;
    animation: contextMenuFadeIn 0.12s ease-out;
}

@keyframes contextMenuFadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: left;
}

.context-menu-item:hover {
    background: var(--surface-hover-strong);
}

.context-menu-item.danger:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.context-menu-item svg {
    opacity: 0.7;
    flex-shrink: 0;
}

.context-menu-item:hover svg {
    opacity: 1;
}

.gradient-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(var(--orb-blur));
    opacity: var(--orb-opacity);
    animation: float 20s ease-in-out infinite;
}

.orb-1 {
    width: 600px;
    height: 600px;
    background: var(--orb-1);
    top: -200px;
    left: -100px;
    animation-delay: 0s;
}

.orb-2 {
    width: 500px;
    height: 500px;
    background: var(--orb-2);
    top: 50%;
    right: -150px;
    animation-delay: -7s;
}

.orb-3 {
    width: 400px;
    height: 400px;
    background: var(--orb-3);
    bottom: -100px;
    left: 30%;
    animation-delay: -14s;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(50px, -30px) scale(1.1); }
    50% { transform: translate(0, 50px) scale(1); }
    75% { transform: translate(-50px, -20px) scale(0.95); }
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: relative;
    z-index: 1;
}

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--glass-border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
}

.logo-icon {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    flex-shrink: 0;
}

.logo-icon svg,
.logo-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.logo-icon img {
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
}

.logo-text {
    font-size: 20px;
    font-weight: 500;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.nav-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-secondary);
    padding: 4px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.nav-tab {
    padding: 10px 20px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.nav-tab:hover { color: var(--text-primary); background: var(--surface-hover); }

.nav-tab.active {
    background: var(--surface-active);
    color: var(--text-primary);
    border: 1px solid var(--surface-border-strong);
}

.header-actions { display: flex; align-items: center; gap: 12px; }

.header-share-btn {
    padding-inline: 16px;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
    box-shadow: 0 4px 15px rgba(6, 182, 212, 0.24);
}

.header-share-btn:hover {
    box-shadow: 0 6px 20px rgba(6, 182, 212, 0.32);
}

.palette-switcher {
    position: relative;
    display: flex;
    align-items: center;
}

.palette-toggle .palette-dot {
    width: 18px;
    height: 18px;
    border-radius: 999px;
    background: var(--palette-dot);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.08);
}

.palette-menu {
    position: absolute;
    top: 48px;
    right: 0;
    display: none;
    gap: 8px;
    padding: 10px;
    min-width: 170px;
    max-height: 320px;
    overflow-y: auto;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    box-shadow: 0 12px 32px var(--shadow-color);
    z-index: 200;
}

.palette-menu.is-open {
    display: grid;
}

.palette-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid transparent;
    background: var(--surface-hover);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.palette-option:hover {
    color: var(--text-primary);
    background: var(--surface-hover-strong);
}

.palette-option.active {
    color: var(--text-primary);
    background: var(--surface-active);
    border: 1px solid var(--surface-border-strong);
}

.palette-swatch {
    width: 14px;
    height: 14px;
    border-radius: 50%;
}

.palette-swatch--mist {
    background: linear-gradient(135deg, #4da8b6, #e5a46f);
}

.palette-swatch--noir {
    background: linear-gradient(135deg, #8b5cf6, #3b82f6);
}

.palette-swatch--ember {
    background: linear-gradient(135deg, #f0b36b, #d05d52);
}

.palette-swatch--aurora {
    background: linear-gradient(135deg, #22d3ee, #60a5fa);
}

.palette-swatch--glacier {
    background: linear-gradient(135deg, #5b8cff, #7dd3fc);
}

.palette-swatch--forest {
    background: linear-gradient(135deg, #7fdc9b, #4fd1c5);
}

.palette-swatch--sakura {
    background: linear-gradient(135deg, #f472b6, #c084fc);
}

.palette-swatch--solar {
    background: linear-gradient(135deg, #f59e0b, #fb923c);
}

.btn-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
}

.lang-switcher {
    position: relative;
    display: inline-grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: center;
    min-width: 104px;
    padding: 4px;
    border-radius: 999px;
    background: var(--lang-switch-track-bg);
    border: 1px solid var(--lang-switch-track-border);
    box-shadow: var(--lang-switch-track-shadow);
    isolation: isolate;
}

.lang-switcher::before {
    content: '';
    position: absolute;
    top: 4px;
    left: 4px;
    width: calc(50% - 4px);
    height: calc(100% - 8px);
    border-radius: 999px;
    background: var(--lang-switch-handle-bg);
    box-shadow: var(--lang-switch-handle-shadow);
    transform: translateX(var(--lang-switch-offset, 0%));
    transition: transform 0.24s cubic-bezier(0.2, 0.8, 0.2, 1), background 0.2s ease;
    z-index: 0;
}

.lang-switcher[data-active-lang="en"] {
    --lang-switch-offset: 100%;
}

.lang-btn {
    position: relative;
    z-index: 1;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.01em;
    padding: 7px 14px;
    min-width: 44px;
    border-radius: 999px;
    border: none;
    background: transparent;
    color: var(--lang-switch-text);
    cursor: pointer;
    transition: color 0.2s ease, transform 0.2s ease;
    line-height: 1;
    text-align: center;
}

.lang-btn:hover {
    color: var(--text-primary);
    transform: translateY(-0.5px);
}

.lang-btn:focus-visible {
    outline: 2px solid var(--accent-blue);
    outline-offset: 2px;
}

.lang-btn.active {
    background: transparent;
    color: var(--lang-switch-text-active);
    transform: none;
}

.theme-toggle {
    position: relative;
}

.theme-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 18px;
    height: 18px;
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.7);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

:root[data-theme="light"] .theme-icon-sun {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

:root[data-theme="light"] .theme-icon-moon {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.7);
}

:root:not([data-theme="light"]) .theme-icon-moon {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

:root:not([data-theme="light"]) .theme-icon-sun {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.7);
}

.btn-icon:hover {
    background: var(--surface-hover-strong);
    color: var(--text-primary);
    transform: translateY(-2px);
}

.btn-primary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: linear-gradient(135deg, var(--accent-green), var(--accent-cyan));
    border: none;
    border-radius: 10px;
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

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

.sidebar {
    width: 260px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar-section {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

/* Project Files section specific styling */
#projectFilesSection {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#projectFilesSection .sidebar-header {
    margin-bottom: 0;
}

.sidebar:not([data-mode="projects"]) #projectHubSection {
    display: none;
}

.sidebar[data-mode="projects"] #projectFilesSection {
    display: none;
}

.sidebar[data-mode="projects"] #seekAgentSection {
    display: none;
}

.project-hub {
    display: grid;
    gap: 14px;
    margin-top: 10px;
    padding: 16px;
    position: relative;
    overflow: hidden;
    isolation: isolate;
    border: 1px solid var(--project-hub-border);
    border-radius: 18px;
    background: var(--project-hub-surface);
    box-shadow: var(--project-hub-shadow);
}

.project-hub::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: var(--project-hub-overlay-top), var(--project-hub-overlay-bottom);
    opacity: var(--project-hub-overlay-opacity);
    pointer-events: none;
    z-index: 0;
}

.project-hub > * {
    position: relative;
    z-index: 1;
}

.project-hub__header-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.project-hub__header {
    display: grid;
    gap: 7px;
    min-width: 0;
    flex: 1 1 auto;
}

.project-hub__welcome {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.3px;
}

.project-hub__identity {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    min-width: 0;
}

.project-hub__avatar {
    width: 34px;
    height: 34px;
    border-radius: 11px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    color: var(--project-hub-avatar-text);
    background: var(--project-hub-avatar-bg);
    border: 1px solid var(--project-hub-avatar-border);
    box-shadow: var(--project-hub-avatar-shadow);
}

.project-hub__logout {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    border: 1px solid var(--project-hub-logout-border);
    background: var(--project-hub-logout-bg);
    color: var(--project-hub-logout-text);
    border-radius: 999px;
    padding: 8px 13px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.15px;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, color 0.18s ease, background 0.18s ease;
    white-space: nowrap;
    box-shadow: var(--project-hub-logout-shadow);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.project-hub__logout-icon {
    width: 18px;
    height: 18px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--project-hub-logout-icon-color);
    border: 1px solid var(--project-hub-logout-icon-border);
    background: var(--project-hub-logout-icon-bg);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.09);
}

.project-hub__logout-icon svg {
    width: 11px;
    height: 11px;
}

.project-hub__logout-label {
    line-height: 1;
    letter-spacing: 0.28px;
}

.project-hub__logout:hover {
    color: var(--project-hub-logout-hover-text);
    border-color: var(--project-hub-logout-hover-border);
    background: var(--project-hub-logout-hover-bg);
    transform: translateY(-1px);
    box-shadow: var(--project-hub-logout-hover-shadow);
}

.project-hub__logout:hover .project-hub__logout-icon {
    border-color: var(--project-hub-logout-icon-hover-border);
    color: var(--project-hub-logout-icon-hover-color);
    background: var(--project-hub-logout-icon-hover-bg);
}

.project-hub__logout:active {
    transform: translateY(0);
}

.project-hub__logout:focus-visible {
    outline: 2px solid var(--project-hub-logout-focus);
    outline-offset: 2px;
}

.project-hub__logout:disabled {
    opacity: 0.74;
    cursor: not-allowed;
    transform: none;
}

.project-hub__logout.is-loading .project-hub__logout-icon {
    animation: project-logout-pulse 1.1s ease-in-out infinite;
}

@keyframes project-logout-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(0.88); }
    100% { transform: scale(1); }
}

.project-hub__name {
    display: block;
    max-width: 100%;
    font-size: clamp(20px, 2.1vw, 22px);
    font-weight: 700;
    line-height: 1.15;
    color: var(--text-primary);
    text-transform: none;
    letter-spacing: 0;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.project-hub__primary {
    border: none;
    border-radius: 15px;
    padding: 13px 14px;
    background: var(--project-hub-primary-bg);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    box-shadow: var(--project-hub-primary-shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.project-hub__primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--project-hub-primary-hover-shadow);
}

.project-hub__plus {
    font-size: 18px;
    line-height: 1;
}

.project-hub__actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.project-hub__ghost {
    border: 1px solid var(--project-hub-ghost-border);
    background: var(--project-hub-ghost-bg);
    color: var(--text-secondary);
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.project-hub__ghost:hover {
    background: var(--project-hub-ghost-hover-bg);
    color: var(--text-primary);
}

.project-hub__nav {
    display: grid;
    gap: 8px;
}

.project-hub__item {
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    padding: 10px 12px;
    border-radius: 12px;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
}

.project-hub__item:hover {
    background: var(--project-hub-item-hover-bg);
    color: var(--text-primary);
}

.project-hub__item.is-active {
    background: var(--project-hub-item-active-bg);
    border: 1px solid var(--project-hub-item-active-border);
    color: var(--text-primary);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-icon-small {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.btn-icon-small:hover {
    background: var(--surface-hover-strong);
    color: var(--text-primary);
}

.file-tree {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-secondary);
    font-size: 13px;
    position: relative;
    background: var(--surface-hover);
    border: 1px solid transparent;
}

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

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

.file-item:hover .file-actions {
    display: flex;
}

.file-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 4px;
    background: var(--surface-hover);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
    opacity: 0.7;
}

.file-action-btn:hover {
    background: var(--surface-hover-strong);
    color: var(--text-primary);
    opacity: 1;
}

.file-action-btn.danger:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.file-item:hover {
    background: var(--surface-hover-strong);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.file-item.active {
    background: var(--view-active-bg);
    color: var(--text-primary);
    border: 1px solid var(--surface-border-strong);
}

.file-item svg { flex-shrink: 0; opacity: 0.7; pointer-events: none; }

.file-item.active svg { opacity: 1; }

.ai-status {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: 10px;
    font-size: 13px;
    color: var(--accent-green);
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-green);
    box-shadow: 0 0 10px var(--accent-green);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.2); }
}

/* ==================== SEEK GENERATE AGENT ==================== */

.seek-agent-section {
    margin: 8px 0 0 0;
    padding: 16px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    box-shadow: none;
}

.seek-agent-section.collapsed .seek-agent-content {
    display: none;
}

.seek-agent-section.collapsed .agent-collapse-icon {
    transform: rotate(-90deg);
}

/* Collapsible Header */
.agent-header-collapsible {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s ease;
    border-radius: 10px;
    margin: 0 0 10px;
    padding: 8px 10px;
    background: transparent;
    border: 1px solid transparent;
}

.agent-header-collapsible:hover {
    background: var(--surface-hover);
}

.agent-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-secondary);
}

.agent-collapse-icon {
    transition: transform 0.2s ease;
    opacity: 0.6;
}

.agent-header-right {
    display: flex;
    align-items: center;
}

.agent-status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px;
    background: rgba(16, 185, 129, 0.12);
    border-radius: 10px;
    font-size: 10px;
    font-weight: 500;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.agent-status-indicator .agent-status-dot {
    width: 6px;
    height: 6px;
}

.agent-status-text {
    color: var(--accent-green);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.agent-status-indicator.generating {
    background: rgba(139, 92, 246, 0.1);
}

.agent-status-indicator.generating .agent-status-text {
    color: var(--accent-purple);
}

.agent-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-green);
    transition: all 0.3s ease;
}

.agent-status-dot.generating {
    background: var(--accent-purple);
    animation: pulse 1s ease-in-out infinite;
}

.agent-status-dot.complete {
    background: var(--accent-green);
    box-shadow: 0 0 8px var(--accent-green);
}

.seek-agent-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 8px;
}

/* Agent Form */
.agent-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.agent-form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.agent-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.agent-textarea {
    width: 100%;
    padding: 10px 12px;
    background: var(--surface-hover);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
    resize: vertical;
    min-height: 60px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-shadow: none;
}

.agent-textarea:focus {
    outline: none;
    border-color: var(--accent-purple);
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.12);
}

.agent-textarea::placeholder {
    color: var(--text-muted);
}

.agent-form-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.agent-input-number {
    width: 80px;
    padding: 6px 10px;
    background: var(--surface-hover);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 13px;
    text-align: center;
}

.agent-input-number:focus {
    outline: none;
    border-color: var(--accent-purple);
}

.agent-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px 0;
    margin-top: 4px;
}

.agent-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}

.agent-checkbox input[type="checkbox"] {
    display: none;
}

.agent-checkbox .checkmark {
    width: 16px;
    height: 16px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--surface-hover);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.agent-checkbox input:checked + .checkmark {
    background: var(--accent-purple);
    border-color: var(--accent-purple);
}

.agent-checkbox input:checked + .checkmark::after {
    content: '';
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    margin-bottom: 2px;
}

.agent-checkbox:hover .checkmark {
    border-color: var(--accent-purple);
}

.agent-generate-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex: 1;
    padding: 10px 14px;
    background: linear-gradient(135deg, var(--accent-purple) 0%, #7c3aed 100%);
    border: none;
    border-radius: 10px;
    color: white;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.25);
}

.agent-generate-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.35);
}

.agent-generate-btn:active {
    transform: translateY(0);
}

.agent-generate-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Agent Button Group */
.agent-btn-group {
    display: flex;
    gap: 10px;
    margin-top: 4px;
}

.agent-background-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex: 1;
    padding: 10px 12px;
    background: transparent;
    border: 1px solid rgba(139, 92, 246, 0.4);
    border-radius: 10px;
    color: var(--accent-purple);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.agent-background-btn:hover {
    background: rgba(139, 92, 246, 0.1);
    border-color: rgba(139, 92, 246, 0.6);
}

.agent-background-btn:active {
    transform: scale(0.98);
}

.agent-background-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Agent Note */
.agent-note {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 12px;
    background: rgba(59, 130, 246, 0.08);
    border-radius: 8px;
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 8px;
}

.agent-note svg {
    flex-shrink: 0;
    opacity: 0.6;
}

.agent-background-btn svg {
    opacity: 0.8;
}

/* Agent Progress View */
.agent-progress {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.agent-progress-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.progress-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

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

.agent-cancel-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

/* Stage List - Expandable Design */
.stage-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.stage-item {
    display: flex;
    flex-direction: column;
    background: var(--surface-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.stage-item:hover {
    border-color: var(--text-muted);
}

.stage-item.active {
    border-color: var(--accent-purple);
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.08), rgba(139, 92, 246, 0.02));
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.15);
}

.stage-item.complete {
    border-color: var(--accent-green);
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.08), rgba(16, 185, 129, 0.02));
}

.stage-item.skipped {
    opacity: 0.5;
    border-style: dashed;
}

.stage-item.expanded {
    border-color: var(--accent-purple);
}

/* Stage Header (clickable) */
.stage-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    cursor: pointer;
    user-select: none;
}

.stage-header:hover .stage-toggle {
    opacity: 1;
}

/* Stage Icon - Multi-state */
.stage-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--bg-primary);
    transition: all 0.3s ease;
}

.stage-icon svg {
    display: none;
}

.stage-icon .icon-pending {
    display: block;
    color: var(--text-muted);
}

.stage-item.active .stage-icon {
    background: linear-gradient(135deg, var(--accent-purple), #a78bfa);
    animation: pulse-glow 2s infinite;
}

.stage-item.active .stage-icon svg { display: none; }
.stage-item.active .stage-icon .icon-active {
    display: block;
    color: white;
}

.stage-item.complete .stage-icon {
    background: linear-gradient(135deg, var(--accent-green), #34d399);
}

.stage-item.complete .stage-icon svg { display: none; }
.stage-item.complete .stage-icon .icon-complete {
    display: block;
    color: white;
}

.stage-item.skipped .stage-icon svg { display: none; }
.stage-item.skipped .stage-icon .icon-skipped {
    display: block;
    color: var(--text-muted);
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.4); }
    50% { box-shadow: 0 0 0 6px rgba(139, 92, 246, 0); }
}

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

.stage-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
}

.stage-item.active .stage-name {
    color: var(--accent-purple);
}

.stage-item.complete .stage-name {
    color: var(--accent-green);
}

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

/* Stage Toggle Arrow */
.stage-toggle {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    opacity: 0.5;
    transition: all 0.2s ease;
}

.stage-item.expanded .stage-toggle {
    transform: rotate(180deg);
    opacity: 1;
}

.stage-item.has-sub-items .stage-toggle {
    opacity: 0.7;
}

/* Sub-Progress Container */
.stage-sub-progress {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: rgba(0, 0, 0, 0.1);
}

.stage-item.expanded .stage-sub-progress {
    max-height: 300px;
    border-top: 1px solid var(--border-color);
}

.stage-sub-progress-inner {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 12px;
}

/* Sub-Progress Item (Chapter Pill) */
.sub-progress-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    font-size: 11px;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.sub-progress-item.pending {
    color: var(--text-muted);
}

.sub-progress-item.active {
    border-color: var(--accent-purple);
    background: rgba(139, 92, 246, 0.15);
    color: var(--accent-purple);
}

.sub-progress-item.active::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-purple);
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.sub-progress-item.complete {
    border-color: var(--accent-green);
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-green);
}

.sub-progress-item.complete::before {
    content: '✓';
    font-size: 10px;
    font-weight: bold;
}

.sub-progress-item.error {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.sub-progress-item.error::before {
    content: '✗';
    font-size: 10px;
    font-weight: bold;
}

.sub-progress-item .item-detail {
    font-size: 10px;
    color: var(--text-muted);
    margin-left: 2px;
}

/* Current Activity */
.agent-current-activity {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 8px;
}

.activity-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.spinner-small {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(139, 92, 246, 0.3);
    border-top-color: var(--accent-purple);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.activity-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.activity-action {
    font-size: 12px;
    font-weight: 500;
    color: var(--accent-purple);
}

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

/* Agent Progress Bar */
.agent-progress-bar {
    display: flex;
    align-items: center;
    gap: 10px;
}

.agent-progress-bar .progress-track {
    flex: 1;
    height: 6px;
    background: var(--surface-bg);
    border-radius: 3px;
    overflow: hidden;
}

.agent-progress-bar .progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-purple), #a78bfa);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.agent-progress-bar .progress-text {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    min-width: 32px;
    text-align: right;
}

/* Agent Complete View */
.agent-complete {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 16px;
    text-align: center;
}

.complete-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(16, 185, 129, 0.1);
    border-radius: 50%;
    color: var(--accent-green);
}

.complete-stats {
    display: flex;
    gap: 16px;
    font-size: 13px;
    color: var(--text-secondary);
}

.stat-item strong {
    color: var(--text-primary);
}

.agent-reset-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--surface-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.agent-reset-btn:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

/* Stop Generation Button */
.agent-stop-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 10px 16px;
    margin-top: 12px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 6px;
    color: #ef4444;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.agent-stop-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.5);
}

.agent-stop-btn svg {
    flex-shrink: 0;
}

/* Generation History */
.agent-history {
    display: none;
    border-top: 1px solid var(--border-color);
    margin-top: 8px;
}

.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.history-header:hover {
    background: var(--surface-hover);
}

.history-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.history-title svg {
    opacity: 0.6;
}

.history-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: var(--surface-bg);
    border-radius: 9px;
    font-size: 10px;
    color: var(--text-muted);
}

.history-toggle {
    transition: transform 0.2s ease;
}

.agent-history.expanded .history-toggle {
    transform: rotate(180deg);
}

.history-list {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.agent-history.expanded .history-list {
    max-height: 500px;
    overflow-y: auto;
}

.history-item {
    border-top: 1px solid var(--border-subtle);
}

.history-item:first-child {
    border-top: none;
}

.history-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.history-item-header:hover {
    background: var(--surface-hover);
}

.history-item-time {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.history-date {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
}

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

.history-item-stats {
    display: flex;
    gap: 6px;
    flex: 1;
    justify-content: center;
}

.stat-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 500;
}

.stat-badge.chapters {
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent-purple);
}

.stat-badge.fixes {
    background: rgba(245, 158, 11, 0.1);
    color: var(--accent-yellow);
}

.stat-badge.duration {
    background: rgba(107, 114, 128, 0.1);
    color: var(--text-secondary);
}

.history-item-toggle {
    transition: transform 0.2s ease;
    opacity: 0.4;
}

.history-item.expanded .history-item-toggle {
    transform: rotate(180deg);
}

.history-item-details {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
    background: var(--surface-bg);
}

.history-item.expanded .history-item-details {
    max-height: 800px;
    padding: 8px 12px 12px;
    overflow-y: auto;
}

.detail-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 0;
    font-size: 11px;
}

.detail-label {
    color: var(--text-muted);
    min-width: 70px;
}

.detail-value {
    color: var(--text-secondary);
}

.detail-value.score {
    color: var(--accent-green);
    font-weight: 600;
}

.detail-row.options {
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.option-tag {
    display: inline-flex;
    padding: 2px 6px;
    background: var(--border-color);
    border-radius: 3px;
    font-size: 9px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.detail-row.instructions {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    margin-top: 4px;
    padding-top: 6px;
    border-top: 1px dashed var(--border-subtle);
}

.detail-row.instructions .detail-value {
    font-size: 10px;
    line-height: 1.4;
    color: var(--text-muted);
    font-style: italic;
}

/* History Stage Details */
.history-stages {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-subtle);
}

.history-stage-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    font-size: 11px;
}

.history-stage-row.pending {
    opacity: 0.4;
}

.history-stage-row.skipped {
    opacity: 0.5;
    text-decoration: line-through;
}

.history-stage-row.complete .stage-icon-small {
    color: var(--accent-green);
}

.stage-icon-small {
    width: 14px;
    text-align: center;
    font-size: 10px;
}

.stage-name-small {
    flex: 1;
    color: var(--text-secondary);
    font-weight: 500;
}

.stage-detail-small {
    color: var(--text-muted);
    font-size: 10px;
}

.stage-duration-small {
    color: var(--text-muted);
    font-size: 10px;
    min-width: 35px;
    text-align: right;
}

/* ==================== COHERENCE REPORT STYLES ==================== */

.coherence-report {
    margin-top: 12px;
    background: var(--surface-dark);
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--border-subtle);
}

.report-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.1), rgba(59, 130, 246, 0.1));
    cursor: pointer;
    transition: background 0.2s;
}

.report-header:hover {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(59, 130, 246, 0.15));
}

.report-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
}

.report-overall-score {
    font-size: 13px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
}

.report-overall-score.score-high {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
}

.report-overall-score.score-medium {
    background: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
}

.report-overall-score.score-low {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.report-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.coherence-report.expanded .report-body {
    max-height: 600px;
    overflow-y: auto;
    padding: 12px;
}

/* Dimension Scores Row */
.dimension-scores-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.dimension-score {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    background: var(--surface-bg);
    border: 1px solid var(--border-subtle);
}

.dimension-score.score-high {
    border-color: rgba(16, 185, 129, 0.3);
}

.dimension-score.score-medium {
    border-color: rgba(245, 158, 11, 0.3);
}

.dimension-score.score-low {
    border-color: rgba(239, 68, 68, 0.3);
}

.dim-icon {
    font-size: 12px;
}

.dim-score {
    font-weight: 600;
    color: var(--text-primary);
}

.dimension-score.score-high .dim-score { color: #10b981; }
.dimension-score.score-medium .dim-score { color: #f59e0b; }
.dimension-score.score-low .dim-score { color: #ef4444; }

.dim-issues {
    font-size: 9px;
    padding: 1px 4px;
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    border-radius: 3px;
}

/* Report Sections */
.report-section {
    margin-bottom: 10px;
    background: var(--surface-bg);
    border-radius: 4px;
    overflow: hidden;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    cursor: pointer;
    transition: background 0.2s;
}

.section-header:hover {
    background: var(--surface-hover);
}

.section-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
}

.section-count {
    font-size: 10px;
    padding: 1px 5px;
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border-radius: 3px;
}

.section-score {
    font-size: 10px;
    font-weight: 600;
    padding: 1px 5px;
    border-radius: 3px;
}

.section-score.score-high {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.section-score.score-medium {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

.section-score.score-low {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.section-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
}

.report-section.expanded .section-content {
    max-height: 300px;
    overflow-y: auto;
    padding: 8px 10px;
    border-top: 1px solid var(--border-subtle);
}

/* Priority Fixes */
.priority-fix-item {
    display: flex;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px dashed var(--border-subtle);
}

.priority-fix-item:last-child {
    border-bottom: none;
}

.fix-rank {
    font-size: 10px;
    font-weight: 700;
    color: #ef4444;
    min-width: 20px;
}

.fix-content {
    flex: 1;
}

.fix-issue {
    font-size: 11px;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.fix-approach {
    font-size: 10px;
    color: var(--text-muted);
    font-style: italic;
}

.fix-chapters {
    font-size: 9px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Issue Items */
.report-issue {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    padding: 6px 8px;
    margin-bottom: 4px;
    background: var(--surface-dark);
    border-radius: 4px;
    border-left: 2px solid var(--border-subtle);
}

.report-issue.severity-high {
    border-left-color: #ef4444;
    background: rgba(239, 68, 68, 0.05);
}

.report-issue.severity-medium {
    border-left-color: #f59e0b;
    background: rgba(245, 158, 11, 0.05);
}

.report-issue.severity-low {
    border-left-color: #10b981;
    background: rgba(16, 185, 129, 0.05);
}

.issue-severity {
    font-size: 8px;
    text-transform: uppercase;
    padding: 1px 4px;
    border-radius: 2px;
    font-weight: 600;
}

.severity-high .issue-severity {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.severity-medium .issue-severity {
    background: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
}

.severity-low .issue-severity {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
}

.issue-desc {
    flex: 1;
    font-size: 10px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.issue-chapters {
    font-size: 9px;
    color: var(--text-muted);
    white-space: nowrap;
}

.no-issues {
    font-size: 10px;
    color: var(--text-muted);
    font-style: italic;
}

/* Character Reviews */
.character-review-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 6px 0;
    border-bottom: 1px dashed var(--border-subtle);
}

.character-review-item:last-child {
    border-bottom: none;
}

.char-name {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-primary);
}

.char-arc {
    font-size: 9px;
    padding: 1px 4px;
    border-radius: 3px;
}

.char-arc.complete {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.char-arc.incomplete {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

.char-issues {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.char-issue {
    font-size: 9px;
    padding: 2px 6px;
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border-radius: 3px;
}

/* Subsections */
.subsection {
    margin-bottom: 10px;
}

.subsection-title {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
    display: block;
}

/* Strengths */
.strength-item {
    font-size: 10px;
    color: var(--text-secondary);
    padding: 4px 0;
    padding-left: 16px;
    position: relative;
}

.strength-item::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: #10b981;
}

/* Verdict */
.report-verdict {
    margin-top: 12px;
    padding: 10px;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.08), rgba(59, 130, 246, 0.08));
    border-radius: 4px;
    border: 1px solid var(--border-subtle);
}

.verdict-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    display: block;
    margin-bottom: 4px;
}

.verdict-text {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Score badge in history header */
.stat-badge.score {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(59, 130, 246, 0.2));
    color: #8b5cf6;
}

/* ==================== END COHERENCE REPORT STYLES ==================== */

/* ==================== END SEEK GENERATE AGENT ==================== */

.content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.tab-content {
    display: none;
    flex: 1;
    flex-direction: column;
    overflow: auto;
}

.tab-content.active { display: flex; }

.editor-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: var(--glass-bg);
    border-bottom: 1px solid var(--border-color);
}

.toolbar-group { display: flex; gap: 4px; }

.btn-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-toolbar:hover {
    background: var(--surface-active);
    color: var(--text-primary);
    border-color: var(--surface-border-strong);
}

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

.btn-toolbar:disabled:hover {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border-color);
}

.view-btn.active {
    background: var(--surface-active);
    color: var(--text-primary);
}

.view-toggle {
    display: flex;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 3px;
}

.view-btn {
    padding: 6px 14px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.view-btn.active {
    background: var(--view-active-bg);
    color: var(--text-primary);
}

.editor-panels {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.editor-panel {
    display: none;
    flex-direction: row; /* Changed from column to row */
    overflow: hidden;
}

.editor-panel.active { 
    display: flex; 
    flex: 1; /* Allow the active panel to fill the entire width */
}

.editor-panels.split-view .editor-panel { 
    display: flex; 
    flex: 1; 
}

.edit-panel {
    /* No border by default when in full-width Edit mode */
    border-right: none;
    flex-direction: row;
    position: relative; /* For absolute positioning of mirror element */
}

/* Only show the middle divider in Split view */
.editor-panels.split-view .edit-panel {
    border-right: 1px solid var(--border-color);
}

.preview-panel {
    background: var(--bg-secondary);
    flex-direction: column;
}

.line-numbers {
    display: flex;
    flex-direction: column;
    padding: 20px 0;
    background: var(--bg-secondary);
    color: var(--text-muted);
    font-family: 'IBM Plex Mono', 'SF Mono', 'Fira Code', monospace;
    font-size: 14px;
    line-height: 24px;
    text-align: right;
    user-select: none;
    border-right: 1px solid var(--border-color);
    overflow: hidden; /* JavaScript handles scrolling */
    width: 48px;
    flex-shrink: 0;
}

.line-numbers span {
    flex-shrink: 0;
    /* Height and line-height set dynamically by JavaScript */
    min-height: 24px;
    font-variant-numeric: tabular-nums;
    padding-right: 16px;
    padding-left: 8px;
    display: flex;
    align-items: flex-start; /* Align number to top when line wraps */
    justify-content: flex-end;
}

.editor {
    flex: 1;
    padding: 20px 24px;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: 'IBM Plex Mono', 'SF Mono', 'Fira Code', monospace;
    font-size: 14px;
    line-height: 24px;
    resize: none;
    overflow-y: auto;
    overflow-x: hidden;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    min-height: 0;
    tab-size: 4;
}

.editor::placeholder { color: var(--text-muted); }

.editor.is-readonly {
    color: var(--text-secondary);
    cursor: default;
}

/* Hidden mirror element for measuring line heights */
.editor-mirror {
    position: absolute;
    top: 0;
    left: 0;
    visibility: hidden;
    pointer-events: none;
    /* Match editor styles exactly */
    padding: 20px 24px;
    font-family: 'IBM Plex Mono', 'SF Mono', 'Fira Code', monospace;
    font-size: 14px;
    line-height: 24px;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    tab-size: 4;
    /* Width will be set by JavaScript or use calc */
    width: calc(100% - 48px); /* Subtract line-numbers width */
    box-sizing: border-box;
}

.editor-mirror .mirror-line {
    /* Each line in mirror */
    min-height: 24px;
}

.markdown-preview {
    flex: 1;
    padding: 24px 32px;
    overflow-y: auto;
    font-family: 'Georgia', 'Times New Roman', serif;
    line-height: 1.8;
    font-size: 16px;
}

.markdown-preview h1 {
    font-size: 1.5em;
    font-weight: 400;
    font-family: 'IBM Plex Sans', sans-serif;
    margin: 0 0 24px 0;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.markdown-preview h2 {
    font-size: 1.2em;
    font-weight: 500;
    font-family: 'IBM Plex Sans', sans-serif;
    margin: 28px 0 12px 0;
    color: var(--text-primary);
}

.markdown-preview h3 {
    font-size: 1.1em;
    font-weight: 500;
    font-family: 'IBM Plex Sans', sans-serif;
    margin: 24px 0 8px 0;
    color: var(--text-primary);
}

.markdown-preview p {
    margin: 14px 0;
    color: var(--text-secondary);
}

.markdown-preview strong {
    color: var(--text-primary);
    font-weight: 500;
}

.markdown-preview em {
    font-style: italic;
    color: var(--text-secondary);
}

.markdown-preview blockquote {
    border-left: 2px solid rgba(255,255,255,0.1);
    padding-left: 20px;
    margin: 20px 0;
    color: var(--text-muted);
    font-style: italic;
}

.editor-footer {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 12px 20px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    font-size: 12px;
    color: var(--text-muted);
}

.word-count, .cursor-position, .char-count {
    display: flex;
    align-items: center;
    gap: 6px;
}

.save-status {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    color: var(--accent-green);
}

.save-status.saving {
    color: var(--text-secondary);
}

.save-status.error {
    color: var(--accent-red);
}

.panel-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 14px;
    border-bottom: 1px solid var(--border-color);
}

.panel-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.header-subtitle {
    color: var(--text-muted);
    font-size: 13px;
}

.projects-grid {
    --project-card-min-width: 316px;
    --project-card-max-width: 432px;
    --project-card-height: 620px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--project-card-min-width), var(--project-card-max-width)));
    grid-auto-rows: var(--project-card-height);
    justify-content: center;
    gap: 12px;
    padding: 12px 8px 18px;
    align-content: start;
    width: 100%;
}

.projects-empty-state {
    grid-column: 1 / -1;
    align-self: start;
    padding: 36px 24px;
    text-align: center;
    color: var(--text-secondary, rgba(255, 255, 255, 0.65));
    font-size: 15px;
    line-height: 1.6;
    border: 1px dashed var(--project-card-border, rgba(255, 255, 255, 0.12));
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.02);
}

.project-card {
    background:
        var(--project-card-tint-top),
        var(--project-card-tint-bottom),
        var(--project-card-surface);
    background-blend-mode: var(--project-card-blend-mode);
    border: 1px solid var(--project-card-border);
    border-radius: 18px;
    padding: 14px 14px 12px;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    position: relative;
    width: 100%;
    max-width: none;
    height: var(--project-card-height);
    overflow: hidden;
}

.project-card::after {
    content: '';
    position: absolute;
    right: -84px;
    bottom: -108px;
    width: 176px;
    height: 176px;
    background: var(--project-card-orb);
    filter: blur(12px);
    opacity: var(--project-card-orb-opacity);
    pointer-events: none;
}

.project-card > * {
    position: relative;
    z-index: 1;
}

.project-card:hover {
    transform: translateY(-2px);
    border-color: var(--project-card-hover-border);
    box-shadow: var(--project-card-hover-shadow);
}

.project-info {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    height: 100%;
    align-self: stretch;
}

.project-head {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 4px;
    min-width: 0;
    padding: 6px 84px 2px 36px;
}

.project-title {
    font-size: 19px;
    font-weight: 620;
    margin: 0;
    line-height: 1.18;
    letter-spacing: -0.01em;
    white-space: normal;
    word-break: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    max-height: calc(1.24em * 2);
}

.project-title-segment {
    font-style: normal;
}

.project-title-segment--cjk {
    font-family: var(--project-title-font-cjk);
}

.project-title-segment--latin {
    font-family: var(--project-title-font-latin);
}

.project-genre {
    font-size: 12px;
    font-weight: 500;
    color: var(--project-genre-color);
    margin: 0;
    white-space: normal;
    overflow: hidden;
    text-overflow: ellipsis;
}

.project-updated {
    font-size: 11px;
    color: var(--text-muted);
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.project-updated::before {
    content: '';
    display: inline-block;
    width: 11px;
    height: 11px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236a6a7a' stroke-width='2'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 6v6l4 2'/%3E%3C/svg%3E") no-repeat center;
    background-size: contain;
    flex-shrink: 0;
}

.project-cover-stage {
    width: clamp(230px, 82%, 330px);
    aspect-ratio: 2 / 3;
    margin: 0 auto;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: linear-gradient(156deg, rgba(24, 34, 56, 0.95), rgba(14, 20, 36, 0.9));
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 14px 32px rgba(0, 0, 0, 0.34);
}

.project-cover-stage.has-cover {
    border-color: rgba(132, 149, 236, 0.34);
}

.project-cover-thumb {
    width: 100%;
    height: 100%;
    border-radius: inherit;
    object-fit: contain;
    display: block;
    background: rgba(1, 6, 20, 0.88);
}

.project-cover-poster {
    object-position: center center;
}

.project-cover-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(189, 205, 255, 0.72);
}

.project-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
}

.project-stat {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 7px 9px;
    border-radius: 8px;
    border: 1px solid var(--project-stat-border);
    background: var(--project-stat-bg);
    min-width: 0;
}

.project-stat strong {
    font-size: 13px;
    font-weight: 640;
    color: var(--text-primary);
    line-height: 1.15;
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.project-stat small {
    font-size: 9px;
    color: var(--text-muted);
    letter-spacing: 0.07em;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.project-progress-meta {
    display: flex;
    justify-content: center;
    margin-top: 0;
}

.project-card .progress-bar {
    height: 4px;
    background: var(--project-progress-track);
    border-radius: 999px;
    overflow: hidden;
}

.project-card .progress-fill {
    height: 100%;
    background: var(--project-progress-fill);
    border-radius: 999px;
    box-shadow: var(--project-progress-glow);
    transition: width 0.3s ease;
}

.project-card .progress-text {
    margin: 0;
    font-size: 11px;
    color: var(--project-progress-text);
}

.project-card-actions {
    margin-top: auto;
    padding-top: 4px;
}

.project-read-btn {
    width: 100%;
    border: 1px solid var(--project-btn-border);
    background: var(--project-btn-bg);
    color: var(--project-btn-color);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.project-read-btn:hover:not(:disabled) {
    border-color: var(--project-btn-hover-border);
    box-shadow: var(--project-btn-hover-shadow);
    transform: translateY(-1px);
}

.project-read-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

@media (max-width: 1100px) {
    .projects-grid {
        --project-card-min-width: 300px;
        --project-card-max-width: 400px;
        --project-card-height: 592px;
        grid-template-columns: repeat(auto-fill, minmax(var(--project-card-min-width), var(--project-card-max-width)));
        grid-auto-rows: var(--project-card-height);
        justify-content: center;
        gap: 10px;
        padding: 10px 8px 14px;
    }

    .project-card {
        width: 100%;
        max-width: none;
        height: var(--project-card-height);
        padding: 14px;
    }

    .project-head {
        padding: 6px 80px 2px 34px;
    }

    .project-title {
        font-size: 18px;
    }

    .project-cover-stage {
        width: clamp(216px, 82%, 308px);
    }

    .project-read-btn {
        padding: 9px 11px;
    }

    .project-status-ring {
        top: 11px;
        left: 10px;
        width: 34px;
        height: 34px;
    }

    .project-card-tools {
        top: 10px;
        right: 10px;
        padding: 4px;
        gap: 4px;
    }

    .project-card-tool {
        width: 24px;
        height: 24px;
        border-radius: 7px;
    }

    .project-rename,
    .project-delete {
        top: 8px;
        width: 26px;
        height: 26px;
        border-radius: 8px;
    }

    .project-rename {
        right: 40px;
    }

    .project-delete {
        right: 8px;
    }
}

@media (max-width: 560px) {
    .projects-grid {
        --project-card-height: 576px;
        grid-template-columns: 1fr;
        grid-auto-rows: var(--project-card-height);
        padding: 9px 6px 12px;
        gap: 10px;
    }

    .project-card {
        width: 100%;
        max-width: none;
        height: var(--project-card-height);
        padding: 12px;
    }

    .project-head {
        padding: 6px 74px 2px 30px;
    }

    .project-title {
        font-size: 16px;
    }

    .project-cover-stage {
        width: clamp(200px, 84%, 300px);
    }

    .project-stats {
        gap: 6px;
    }

    .project-stat {
        padding: 6px 8px;
    }

    .project-status-ring {
        top: 10px;
        left: 8px;
        width: 32px;
        height: 32px;
    }
}

.new-project {
    border: 2px dashed var(--border-color);
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.new-project::after {
    display: none;
}

.new-project:hover {
    border-color: var(--project-new-hover-border);
    background: var(--project-new-hover-bg);
}

.new-project-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: var(--text-muted);
}

.project-card.selectable {
    cursor: pointer;
}

.project-card.active {
    border-color: var(--project-active-border);
    box-shadow: var(--project-active-shadow);
}

/* 项目卡片生成状态指示器 */
.project-card.generating {
    border-color: var(--project-generating-border);
    box-shadow: var(--project-generating-shadow);
    animation: generating-pulse 2s ease-in-out infinite;
}

.project-card.generating::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: inherit;
    background: var(--project-generating-overlay);
    animation: gradient-shift 3s ease infinite;
    pointer-events: none;
}

@keyframes generating-pulse {
    0%, 100% {
        box-shadow: var(--project-generating-shadow);
    }
    50% {
        box-shadow: var(--project-generating-shadow-active);
    }
}

@keyframes gradient-shift {
    0%, 100% {
        opacity: 0.5;
    }
    50% {
        opacity: 1;
    }
}

.generating-indicator {
    position: absolute;
    bottom: 10px;
    left: 10px;
    right: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 9px;
    background: var(--project-generating-indicator-bg);
    border: 1px solid var(--project-generating-indicator-border);
    border-radius: 8px;
    font-size: 11px;
    color: var(--project-generating-indicator-text);
    font-weight: 500;
}

.generating-spinner {
    width: 12px;
    height: 12px;
    border: 2px solid var(--project-generating-spinner-track);
    border-top-color: var(--project-generating-spinner-head);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* 项目卡片上的圆环生成状态指示器 */
.project-status-ring {
    position: absolute;
    top: 12px;
    left: 12px;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.project-status-ring.generating {
    background: var(--project-ring-generating-bg);
}

.project-status-ring.complete {
    background: var(--project-ring-complete-bg);
}

.project-status-ring .ring-spinner {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 2px solid transparent;
    border-top-color: var(--project-ring-spinner);
    border-right-color: var(--project-ring-spinner);
    border-radius: 50%;
    animation: ring-spin 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}

.project-status-ring .ring-track {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 2px solid var(--project-ring-track);
    border-radius: 50%;
}

.project-status-ring .ring-icon {
    z-index: 1;
    color: var(--project-ring-icon);
}

.project-status-ring.complete .ring-icon {
    color: var(--project-ring-complete-icon);
}

.project-status-ring.complete .ring-track {
    border-color: var(--project-ring-complete-track);
}

@keyframes ring-spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* 生成完成的脉冲效果 */
.project-status-ring.complete::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid var(--project-ring-complete-pulse);
    animation: complete-pulse 2s ease-out infinite;
}

@keyframes complete-pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

/* 项目卡片创建中状态 */
.project-card.creating {
    border-color: var(--project-creating-border);
    box-shadow: var(--project-creating-shadow);
}

.project-card.creating .project-creation-status {
    display: flex;
}

.project-creation-status {
    display: none;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px 16px;
    background: var(--project-creation-overlay-bg);
    border-radius: 0 0 20px 20px;
    flex-direction: column;
    gap: 8px;
}

.creation-status-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
}

.creation-status-stage {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--accent-amber);
    font-weight: 500;
}

.creation-status-stage .stage-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid var(--project-creation-spinner-track);
    border-top-color: var(--accent-amber);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.creation-status-percent {
    color: var(--text-muted);
    font-size: 11px;
}

.creation-progress-bar {
    height: 4px;
    background: var(--project-creation-progress-track);
    border-radius: 2px;
    overflow: hidden;
}

.creation-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-amber), var(--accent-orange));
    border-radius: 2px;
    transition: width 0.3s ease;
}

/* 创建状态环 */
.project-status-ring.creating {
    background: var(--project-ring-creating-bg);
}

.project-status-ring.creating .ring-spinner {
    border-top-color: var(--accent-amber);
    border-right-color: var(--accent-amber);
}

.project-status-ring.creating .ring-track {
    border-color: var(--project-ring-creating-track);
}

.project-status-ring.creating .ring-icon {
    color: var(--accent-amber);
}

/* 创建失败状态 */
.project-card.creation-failed {
    border-color: var(--project-failed-border);
}

.project-status-ring.failed {
    background: var(--project-ring-failed-bg);
}

.project-status-ring.failed .ring-track {
    border-color: var(--project-ring-failed-track);
}

.project-status-ring.failed .ring-icon {
    color: var(--accent-red);
}

.project-card-tools {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px;
    border-radius: 10px;
    border: 1px solid var(--project-tool-group-border);
    background: rgba(34, 46, 99, 0.26);
    backdrop-filter: blur(10px);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
    z-index: 3;
}

.project-card-tool {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 25px;
    height: 25px;
    border-radius: 7px;
    border: 1px solid var(--project-tool-border);
    background: var(--project-tool-bg);
    color: var(--project-tool-color);
    cursor: pointer;
    transition: all 0.2s ease;
}

.project-card-tool:hover {
    background: var(--project-tool-hover-bg);
    border-color: var(--project-tool-hover-border);
    color: var(--project-tool-hover-color);
}

.project-card-tool-delete:hover {
    background: var(--project-tool-delete-hover-bg);
    border-color: var(--project-tool-delete-hover-border);
    color: var(--project-tool-delete-hover-color);
}

.project-card-tool-cover:hover {
    background: rgba(56, 189, 248, 0.2);
    border-color: rgba(56, 189, 248, 0.45);
    color: #7dd3fc;
}

.project-card-tool svg {
    pointer-events: none;
}

/* Backward-compatible styling for stale HTML/JS cache that still renders old classes */
.project-rename,
.project-delete {
    position: absolute;
    top: 10px;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: 1px solid var(--project-tool-border);
    background: var(--project-tool-bg);
    color: var(--project-tool-color);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 3;
}

.project-rename {
    right: 44px;
}

.project-delete {
    right: 10px;
}

.project-rename:hover {
    background: var(--project-tool-hover-bg);
    border-color: var(--project-tool-hover-border);
    color: var(--project-tool-hover-color);
}

.project-delete:hover {
    background: var(--project-tool-delete-hover-bg);
    border-color: var(--project-tool-delete-hover-border);
    color: var(--project-tool-delete-hover-color);
}

.project-details {
    padding: 0 24px 24px;
}

.detail-section {
    margin-bottom: 32px;
}

.detail-section h3 {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 16px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.stat-card {
    padding: 20px;
    border: 1px solid rgba(255,255,255,0.06);
    transition: all 0.2s ease;
}

.stat-card:hover {
    border-color: rgba(255,255,255,0.1);
}

.stat-value {
    font-size: 24px;
    font-weight: 400;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

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

.stat-change.positive { color: var(--accent-green); }

.activity-list { display: flex; flex-direction: column; gap: 12px; }

.activity-item {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 12px;
    background: var(--glass-bg);
    border-radius: 10px;
}

.activity-dot {
    width: 6px;
    height: 6px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    margin-top: 6px;
    flex-shrink: 0;
}

.progress-bar {
    height: 3px;
    background: rgba(255,255,255,0.06);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: rgba(255,255,255,0.2);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.activity-content p {
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 4px;
}

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

.header-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 400;
}

.characters-container {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.character-card {
    display: flex;
    align-items: flex-start;
    gap: 24px;
    padding: 24px;
    background: linear-gradient(135deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 2px;
    transition: all 0.3s ease;
}

.character-card:hover {
    background: linear-gradient(135deg, rgba(255,255,255,0.03), rgba(255,255,255,0.02));
}

.character-initial {
    width: 56px;
    height: 56px;
    min-width: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 300;
    color: var(--accent);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 50%;
    font-family: 'Times New Roman', serif;
}

.character-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
    flex: 0 0 180px;
}

.character-name {
    font-size: 18px;
    font-weight: 500;
    color: var(--text-primary);
    letter-spacing: 0.5px;
}

.character-title {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.character-desc {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 16px;
    max-width: 600px;
    flex: 1 1 0;
    min-width: 0;
}

.character-quote {
    font-size: 14px;
    font-style: italic;
    color: var(--text-muted);
    padding-left: 16px;
    border-left: 1px solid rgba(255,255,255,0.1);
    margin: 0;
    flex: 1 1 0;
    min-width: 0;
}

.outline-container {
    flex: 1;
    padding: 32px 48px;
    overflow-y: auto;
}

.outline-section {
    margin-bottom: 40px;
}

.outline-act {
    display: flex;
    align-items: baseline;
    gap: 16px;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.act-number {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.act-title {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 500;
}

.outline-chapters {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-left: 32px;
}

.outline-chapter {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    transition: all 0.2s ease;
}

.outline-chapter:hover {
    background: rgba(255,255,255,0.02);
}

.chapter-num {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: var(--text-muted);
    font-family: 'IBM Plex Mono', monospace;
}

.chapter-name {
    flex: 1;
    font-size: 14px;
    color: var(--text-secondary);
}

.chapter-status {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    padding: 4px 10px;
    border-radius: 2px;
}

.outline-chapter.complete .chapter-status {
    color: var(--accent-green);
    background: rgba(16, 185, 129, 0.08);
}

.outline-chapter.in-progress .chapter-status {
    color: var(--accent-amber);
    background: rgba(245, 158, 11, 0.08);
}

.outline-chapter.planned .chapter-status {
    color: var(--text-muted);
    background: rgba(255,255,255,0.04);
}

.ai-panel {
    width: 340px;
    min-width: 280px;
    max-width: 600px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border-left: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* AI Panel Resize Handle */
.ai-panel-resize-handle {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 6px;
    cursor: ew-resize;
    background: transparent;
    z-index: 10;
    transition: background 0.2s ease;
}

.ai-panel-resize-handle:hover,
.ai-panel-resize-handle.dragging {
    background: linear-gradient(180deg, var(--accent-purple), var(--accent-cyan));
}

.ai-panel-resize-handle::after {
    content: '';
    position: absolute;
    left: 2px;
    top: 50%;
    transform: translateY(-50%);
    width: 2px;
    height: 40px;
    background: var(--border-color);
    border-radius: 1px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.ai-panel-resize-handle:hover::after {
    opacity: 1;
}

.ai-panel-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.ai-panel-header h3 {
    font-size: 14px;
    font-weight: 600;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    flex: 1;
}

.ai-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.btn-new-chat {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-new-chat:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border-color: var(--accent-purple);
}

.btn-new-chat:active {
    transform: scale(0.95);
}

.model-selector {
    flex-shrink: 0;
}

/* AI Chat Mode Switcher (Muse / Roleplay) */
.ai-mode-switch {
    display: flex;
    gap: 4px;
    padding: 4px;
    margin: 10px 14px 0;
    background: var(--bg-tertiary, rgba(255, 255, 255, 0.04));
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
    border-radius: 10px;
}

.ai-mode-switch__option {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    padding: 6px 10px;
    border-radius: 7px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.ai-mode-switch__option:hover {
    color: var(--text-primary);
}

.ai-mode-switch__option.is-active {
    background: linear-gradient(135deg, #8b5cf6 0%, #ec4899 100%);
    color: #fff;
    box-shadow: 0 2px 10px rgba(139, 92, 246, 0.25);
}

.ai-mode-switch__option[data-mode="roleplay"].is-active {
    background: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
    box-shadow: 0 2px 10px rgba(239, 68, 68, 0.25);
}

/* Roleplay character card */
.ai-roleplay-card {
    margin: 10px 14px 0;
    padding: 10px 12px;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.08), rgba(239, 68, 68, 0.06));
    border: 1px solid rgba(245, 158, 11, 0.25);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ai-roleplay-card[hidden] { display: none; }

.ai-roleplay-card__picker {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-roleplay-card__label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    flex-shrink: 0;
}

.ai-roleplay-card__select {
    flex: 1;
    padding: 6px 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 12px;
    cursor: pointer;
    outline: none;
}

.ai-roleplay-card__select:focus { border-color: #f59e0b; }
.ai-roleplay-card__select:disabled { opacity: 0.5; cursor: not-allowed; }

.ai-roleplay-card__body {
    display: flex;
    align-items: center;
    gap: 10px;
}
.ai-roleplay-card__body[hidden] { display: none; }

.ai-roleplay-card__avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #c4b5fd;
    color: #1a1a1a;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.ai-roleplay-card__meta {
    flex: 1;
    min-width: 0;
}

.ai-roleplay-card__name {
    display: flex;
    align-items: baseline;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.ai-roleplay-card__role {
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 400;
    padding: 2px 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

.ai-roleplay-card__desc {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ai-roleplay-card__hint {
    font-size: 11px;
    color: var(--text-muted);
    font-style: italic;
    padding: 4px 2px;
}
.ai-roleplay-card__hint[hidden] { display: none; }

/* Conversation Info Bar */
.ai-conversation-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 12px;
    background: rgba(139, 92, 246, 0.05);
    border-bottom: 1px solid var(--border-color);
    font-size: 10px;
    color: var(--text-muted);
    opacity: 0.7;
    transition: all 0.3s ease;
}

.ai-conversation-info.has-history {
    opacity: 1;
    background: rgba(139, 92, 246, 0.1);
}

.conversation-turns {
    font-weight: 500;
    color: var(--accent-purple);
}

.ai-conversation-info.has-history .conversation-turns {
    color: var(--accent-cyan);
}

.conversation-hint {
    font-size: 9px;
}

.model-selector select {
    padding: 6px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 12px;
    cursor: pointer;
    outline: none;
}

.model-selector select:focus { border-color: var(--accent-purple); }

.ai-conversation {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.ai-message {
    display: flex;
    gap: 12px;
    animation: fadeIn 0.3s ease;
}

.ai-message-stack {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ai-thinking-block {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: rgba(16, 185, 129, 0.06);
    overflow: hidden;
}

.ai-thinking-summary {
    list-style: none;
    cursor: pointer;
    padding: 10px 14px;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ai-thinking-summary::-webkit-details-marker {
    display: none;
}

.ai-thinking-summary::after {
    content: '▾';
    font-size: 11px;
    color: var(--text-muted);
    transition: transform 0.2s ease;
}

.ai-thinking-block:not([open]) .ai-thinking-summary::after {
    transform: rotate(-90deg);
}

.ai-thinking-content.message-content {
    flex: none;
    margin: 0;
    border: none;
    border-top: 1px solid var(--border-color);
    border-radius: 0;
    background: transparent;
    padding: 10px 14px 12px;
    font-size: 12px;
    color: var(--text-muted);
}

.ai-answer-content {
    min-width: 0;
}

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

.ai-avatar {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
}

.message-content {
    flex: 1;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-secondary);
}

/* Markdown styles for AI chat messages */
.message-content.markdown-body {
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.message-content.markdown-body p {
    margin: 0 0 0.75em 0;
}

.message-content.markdown-body p:last-child {
    margin-bottom: 0;
}

.message-content.markdown-body h1,
.message-content.markdown-body h2,
.message-content.markdown-body h3,
.message-content.markdown-body h4,
.message-content.markdown-body h5,
.message-content.markdown-body h6 {
    margin: 1em 0 0.5em 0;
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary);
}

.message-content.markdown-body h1:first-child,
.message-content.markdown-body h2:first-child,
.message-content.markdown-body h3:first-child {
    margin-top: 0;
}

.message-content.markdown-body h1 { font-size: 1.4em; }
.message-content.markdown-body h2 { font-size: 1.25em; }
.message-content.markdown-body h3 { font-size: 1.1em; }
.message-content.markdown-body h4 { font-size: 1em; }

.message-content.markdown-body strong {
    font-weight: 600;
    color: var(--text-primary);
}

.message-content.markdown-body em {
    font-style: italic;
    color: var(--accent-purple);
}

.message-content.markdown-body ul,
.message-content.markdown-body ol {
    margin: 0.5em 0;
    padding-left: 1.5em;
}

.message-content.markdown-body li {
    margin: 0.25em 0;
}

.message-content.markdown-body li::marker {
    color: var(--accent-cyan);
}

.message-content.markdown-body code {
    background: rgba(0, 0, 0, 0.3);
    padding: 0.15em 0.4em;
    border-radius: 4px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.9em;
    color: var(--accent-pink);
}

.message-content.markdown-body pre {
    background: rgba(0, 0, 0, 0.4);
    border-radius: 8px;
    padding: 12px;
    margin: 0.75em 0;
    overflow-x: auto;
    border: 1px solid var(--border-color);
}

.message-content.markdown-body pre code {
    background: transparent;
    padding: 0;
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.5;
}

.message-content.markdown-body blockquote {
    border-left: 3px solid var(--accent-purple);
    margin: 0.75em 0;
    padding: 0.5em 0 0.5em 1em;
    color: var(--text-muted);
    background: rgba(139, 92, 246, 0.05);
    border-radius: 0 6px 6px 0;
}

.message-content.markdown-body blockquote p {
    margin: 0;
}

.message-content.markdown-body a {
    color: var(--accent-cyan);
    text-decoration: none;
}

.message-content.markdown-body a:hover {
    text-decoration: underline;
}

.message-content.markdown-body hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 1em 0;
}

.message-content.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.75em 0;
    font-size: 12px;
}

.message-content.markdown-body th,
.message-content.markdown-body td {
    border: 1px solid var(--border-color);
    padding: 6px 10px;
    text-align: left;
}

.message-content.markdown-body th {
    background: rgba(255, 255, 255, 0.05);
    font-weight: 600;
    color: var(--text-primary);
}

.message-content.markdown-body tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

.user-message {
    flex-direction: row-reverse;
}

.user-message .message-content {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(139, 92, 246, 0.15));
    border-color: rgba(99, 102, 241, 0.2);
}

.ai-input-container {
    padding: 16px;
    border-top: 1px solid var(--border-color);
}

.prompt-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.suggestion-chip {
    padding: 6px 12px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 20px;
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.suggestion-chip:hover {
    background: rgba(255,255,255,0.06);
    color: var(--text-primary);
}

.ai-input-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.ai-input {
    flex: 1;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 13px;
    resize: none;
    outline: none;
    min-height: 44px;
    max-height: 120px;
    font-family: inherit;
}

.ai-input:focus { border-color: var(--accent-purple); }

.ai-input::placeholder { color: var(--text-muted); }

.btn-send {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
    border: none;
    border-radius: 12px;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.btn-send:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
}

.ai-loading {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    gap: 12px;
}

.ai-loading.visible {
    display: flex;
}

.loading-dots {
    display: flex;
    gap: 6px;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
    border-radius: 50%;
    animation: bounce 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(1) { animation-delay: 0s; }
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

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

.message-content.typing {
    min-height: 40px;
    position: relative;
}

.message-content.typing::after {
    content: '▋';
    display: inline;
    animation: blink-cursor 1s infinite;
    color: var(--accent-cyan);
    font-weight: normal;
    margin-left: 2px;
}

@keyframes blink-cursor {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

.status-indicator.offline {
    background: #ef4444;
    box-shadow: 0 0 10px #ef4444;
}

/* Rewrite Panel Styles */
.rewrite-panel {
    width: 320px;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.rewrite-panel.visible {
    display: flex;
}

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

.rewrite-panel-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

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

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

.rewrite-mode-selector {
    display: flex;
    padding: 12px 16px;
    gap: 8px;
}

.rewrite-mode-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.rewrite-mode-btn:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.rewrite-mode-btn.active {
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
    border-color: transparent;
    color: white;
}

.selected-text-preview {
    padding: 12px 16px;
    margin: 0 16px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    transition: border-color 0.2s ease;
}

.selected-text-preview:has(.has-diff) {
    border-color: rgba(248, 113, 113, 0.3);
    background: linear-gradient(135deg, var(--bg-tertiary), rgba(248, 113, 113, 0.05));
}

.preview-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.preview-content {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
    max-height: 120px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

/* 自定义滚动条 */
.preview-content::-webkit-scrollbar {
    width: 4px;
}

.preview-content::-webkit-scrollbar-track {
    background: transparent;
}

.preview-content::-webkit-scrollbar-thumb {
    background: rgba(139, 92, 246, 0.3);
    border-radius: 2px;
}

/* Continue Mode Settings */
.continue-settings {
    padding: 12px 16px;
    background: rgba(16, 185, 129, 0.05);
    border-bottom: 1px solid var(--border-color);
}

.setting-row-inline {
    display: flex;
    align-items: center;
    gap: 10px;
}

.setting-row-inline label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
}

.token-input {
    width: 90px;
    padding: 6px 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 13px;
    font-family: 'IBM Plex Mono', monospace;
    text-align: center;
}

.token-input:focus {
    outline: none;
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.15);
}

.token-input::-webkit-inner-spin-button,
.token-input::-webkit-outer-spin-button {
    opacity: 1;
}

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

.rewrite-prompt-container {
    padding: 16px;
}

.rewrite-prompt-container label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.rewrite-prompt-input {
    width: 100%;
    min-height: 80px;
    padding: 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
    resize: vertical;
    outline: none;
    transition: all 0.2s ease;
}

.rewrite-prompt-input:focus {
    border-color: var(--accent-purple);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.rewrite-prompt-input::placeholder {
    color: var(--text-muted);
}

.btn-rewrite {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 0 16px;
    padding: 12px 20px;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
    border: none;
    border-radius: 10px;
    color: white;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-rewrite:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
}

.btn-rewrite:active {
    transform: translateY(0);
}

.btn-rewrite:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.rewrite-loading {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    gap: 12px;
}

.rewrite-loading.visible {
    display: flex;
}

.rewrite-result {
    display: none;
    flex-direction: column;
    flex: 1;
    margin: 12px 16px 16px;
    min-height: 0;
    overflow: hidden;
}

.rewrite-result.visible {
    display: flex;
}

/* ==================== Modern Diff Styles ==================== */

/* Diff View Wrapper - 类似 GitHub/VS Code 的风格 */
.diff-view-wrapper {
    display: flex;
    flex-direction: column;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
}

.diff-view-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.1), rgba(236, 72, 153, 0.1));
    border-bottom: 1px solid var(--border-color);
}

.diff-stats {
    display: flex;
    gap: 8px;
}

.diff-stat {
    font-family: 'IBM Plex Mono', 'SF Mono', monospace;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
}

.diff-stat.removed {
    color: #f87171;
    background: rgba(248, 113, 113, 0.15);
}

.diff-stat.added {
    color: #34d399;
    background: rgba(52, 211, 153, 0.15);
}

.diff-title {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Unified Diff Container */
.diff-unified-container {
    max-height: 280px;
    overflow-y: auto;
    font-family: 'IBM Plex Mono', 'SF Mono', 'Menlo', monospace;
    font-size: 12px;
    line-height: 1.7;
    background: var(--bg-primary);
}

/* 自定义滚动条样式 - 更精致 */
.diff-unified-container::-webkit-scrollbar {
    width: 6px;
}

.diff-unified-container::-webkit-scrollbar-track {
    background: transparent;
}

.diff-unified-container::-webkit-scrollbar-thumb {
    background: rgba(139, 92, 246, 0.3);
    border-radius: 3px;
}

.diff-unified-container::-webkit-scrollbar-thumb:hover {
    background: rgba(139, 92, 246, 0.5);
}

/* Diff Line Styles */
.diff-line {
    display: flex;
    align-items: flex-start;
    padding: 2px 0;
    transition: background 0.15s ease;
}

.diff-line:hover {
    filter: brightness(1.1);
}

.diff-line-prefix {
    flex-shrink: 0;
    width: 24px;
    text-align: center;
    color: var(--text-muted);
    font-weight: 500;
    user-select: none;
    opacity: 0.7;
}

.diff-line-content {
    flex: 1;
    padding: 0 12px 0 4px;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Unchanged Lines */
.diff-line-unchanged {
    color: var(--text-secondary);
    background: transparent;
}

.diff-line-unchanged .diff-line-prefix {
    color: var(--text-muted);
}

/* Removed Lines - Red Theme */
.diff-line-removed {
    background: linear-gradient(90deg, rgba(248, 113, 113, 0.2) 0%, rgba(248, 113, 113, 0.08) 100%);
    color: #fca5a5;
}

.diff-line-removed .diff-line-prefix {
    color: #f87171;
    opacity: 1;
}

.diff-line-removed .diff-line-content {
    text-decoration: line-through;
    text-decoration-color: rgba(248, 113, 113, 0.5);
}

/* Added Lines - Green Theme */
.diff-line-added {
    background: linear-gradient(90deg, rgba(52, 211, 153, 0.2) 0%, rgba(52, 211, 153, 0.08) 100%);
    color: #6ee7b7;
}

.diff-line-added .diff-line-prefix {
    color: #34d399;
    opacity: 1;
}

/* Selected Text Preview with Diff Highlight */
.preview-content.has-diff {
    font-family: 'IBM Plex Mono', 'SF Mono', monospace;
    font-size: 12px;
    line-height: 1.6;
    white-space: pre-wrap;
}

.preview-content .diff-highlight-removed {
    background: linear-gradient(90deg, rgba(248, 113, 113, 0.25) 0%, rgba(248, 113, 113, 0.1) 100%);
    color: #fca5a5;
    text-decoration: line-through;
    text-decoration-color: rgba(248, 113, 113, 0.6);
    border-radius: 2px;
    padding: 0 2px;
}

/* Legacy Diff Styles (保持向后兼容) */
.diff-container {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12px;
    line-height: 1.6;
    max-height: 200px;
    overflow-y: auto;
    padding: 8px;
    background: var(--bg-secondary);
    border-radius: 6px;
}

.diff-unchanged {
    color: var(--text-muted);
}

.diff-removed {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
    text-decoration: line-through;
}

.diff-added {
    color: #10b981;
    background: rgba(16, 185, 129, 0.1);
}

/* Editor Diff Overlay - 编辑器区域的 diff 显示层 */
.editor-diff-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    overflow: auto;
    padding: 16px;
    font-family: 'IBM Plex Mono', 'SF Mono', monospace;
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    background: var(--bg-primary);
    z-index: 5;
}

.editor-diff-overlay .diff-text-removed {
    background: rgba(248, 113, 113, 0.2);
    color: #fca5a5;
    text-decoration: line-through;
    text-decoration-color: rgba(248, 113, 113, 0.6);
    border-radius: 2px;
    padding: 0 2px;
}

.editor-diff-overlay .diff-text-added {
    background: rgba(52, 211, 153, 0.2);
    color: #6ee7b7;
    border-radius: 2px;
    padding: 0 2px;
}

.editor-diff-overlay .diff-text-unchanged {
    color: var(--text-secondary);
}

/* 编辑器容器需要相对定位 */
.editor-panel {
    position: relative;
}

.rewrite-actions {
    display: flex;
    gap: 10px;
    margin-top: 12px;
    padding: 12px 0 0;
}

.btn-reject {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 14px;
    background: rgba(248, 113, 113, 0.08);
    border: 1px solid rgba(248, 113, 113, 0.25);
    border-radius: 8px;
    color: #f87171;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-reject:hover {
    background: rgba(248, 113, 113, 0.15);
    border-color: rgba(248, 113, 113, 0.4);
    transform: translateY(-1px);
}

.btn-reject:active {
    transform: translateY(0);
}

.btn-accept {
    flex: 1.2;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 14px;
    background: linear-gradient(135deg, #34d399, #10b981);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(52, 211, 153, 0.25);
}

.btn-accept:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(52, 211, 153, 0.35);
}

.btn-accept:active {
    transform: translateY(0);
}

::-webkit-scrollbar { width: 8px; height: 8px; }

::-webkit-scrollbar-track { background: var(--bg-secondary); }

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-thumb-hover); }

@media (max-width: 1200px) {
    .sidebar { width: 220px; }
    .ai-panel { width: 300px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
    .sidebar, .ai-panel { display: none; }
    .nav-tabs { display: none; }
}

.ai-loading.visible {
    display: flex;
}

.loading-dots {
    display: flex;
    gap: 6px;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
    border-radius: 50%;
    animation: bounce 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(1) { animation-delay: 0s; }
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

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

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

/* Removed duplicate typing styles - using main definition above */

.status-indicator.offline {
    background: #ef4444;
    box-shadow: 0 0 10px #ef4444;
}

::-webkit-scrollbar { width: 8px; height: 8px; }

::-webkit-scrollbar-track { background: var(--bg-secondary); }

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-thumb-hover); }

@media (max-width: 1200px) {
    .sidebar { width: 220px; }
    .ai-panel { width: 300px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
    .sidebar, .ai-panel { display: none; }
    .nav-tabs { display: none; }
}

.modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.modal.is-visible {
    display: flex;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(6, 6, 12, 0.72);
    backdrop-filter: blur(6px);
}

.modal-card {
    position: relative;
    width: min(960px, 92vw);
    max-height: 90vh;
    overflow: auto;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 24px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
    z-index: 1;
}

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.modal-header h2 {
    font-size: 22px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 6px;
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.modal-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

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

.field-span {
    grid-column: 1 / -1;
}

.field label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.field input,
.field select,
.field textarea {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 10px 12px;
    color: var(--text-primary);
    font-size: 13px;
    font-family: 'IBM Plex Sans', sans-serif;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    border-color: rgba(139, 92, 246, 0.5);
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.15);
}

/* Model selector in project modal - full width with emphasis */
.field .model-select-full {
    background: var(--bg-tertiary);
    border: 1px solid var(--accent-purple);
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 14px;
    cursor: pointer;
}

.field .model-select-full:focus {
    border-color: var(--accent-purple);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

.field .model-select-full optgroup {
    font-weight: 600;
    color: var(--text-secondary);
    padding: 8px 0;
}

.field .model-select-full option {
    padding: 8px 12px;
    color: var(--text-primary);
}

.modal-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
}

/* Export Dialog - Minimal Design */
.export-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    z-index: 9999;
}

.export-dialog {
    position: relative;
    width: 380px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.4);
    overflow: hidden;
}

.export-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.15s ease;
}

.export-close:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
}

.export-header {
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border-color);
}

.export-title-row {
    display: flex;
    align-items: baseline;
    gap: 12px;
}

.export-book-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

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

.export-content {
    padding: 20px 24px;
}

.export-format-row {
    display: flex;
    gap: 8px;
    padding: 4px;
    background: var(--bg-tertiary);
    border-radius: 10px;
}

.format-btn {
    flex: 1;
    padding: 10px 16px;
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.format-btn .format-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: color 0.15s ease;
}

.format-btn:hover .format-label {
    color: var(--text-primary);
}

.format-btn.selected {
    background: var(--bg-secondary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.format-btn.selected .format-label {
    color: var(--text-primary);
    font-weight: 600;
}

.export-settings {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.author-row {
    display: flex;
    align-items: center;
    padding: 12px 14px;
    margin-bottom: 8px;
    background: var(--bg-tertiary);
    border-radius: 8px;
}

.author-label {
    font-size: 13px;
    color: var(--text-secondary);
    min-width: 60px;
}

.author-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 13px;
    padding: 4px 8px;
    border-bottom: 1px solid var(--border-color);
    transition: border-color 0.15s ease;
}

.author-input:focus {
    border-bottom-color: var(--accent-cyan);
}

.author-input::placeholder {
    color: var(--text-muted);
}

/* 字体选择行 */
.font-row {
    display: flex;
    align-items: center;
    padding: 12px 14px;
    margin-bottom: 8px;
    background: var(--bg-tertiary);
    border-radius: 8px;
}

.font-label {
    font-size: 13px;
    color: var(--text-secondary);
    min-width: 60px;
}

.font-select {
    flex: 1;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    outline: none;
    color: var(--text-primary);
    font-size: 13px;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: border-color 0.15s ease;
}

.font-select:focus {
    border-color: var(--accent-cyan);
}

.font-select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* 颜色选择器包装 */
.color-select-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    border-radius: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.color-preview {
    width: 28px;
    height: 28px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    flex-shrink: 0;
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.2), inset 0 0 0 2px rgba(255, 255, 255, 0.4);
}

.color-select-wrapper .font-select {
    flex: 1;
    background: transparent;
    border: none;
    padding: 4px 2px;
}

.setting-row {
    display: flex;
    align-items: center;
    padding: 12px 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.setting-row:hover {
    background: rgba(255, 255, 255, 0.03);
}

.setting-row input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.setting-label {
    flex: 1;
    font-size: 13px;
    color: var(--text-secondary);
}

.setting-check {
    width: 18px;
    height: 18px;
    border: 1.5px solid var(--border-color);
    border-radius: 5px;
    position: relative;
    transition: all 0.15s ease;
}

.setting-row input:checked ~ .setting-check {
    background: linear-gradient(135deg, var(--accent-green), var(--accent-cyan));
    border-color: transparent;
}

.setting-row input:checked ~ .setting-check::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 2px;
    width: 5px;
    height: 9px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.setting-row input:checked ~ .setting-label {
    color: var(--text-primary);
}

.export-progress-section {
    margin-top: 16px;
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: 10px;
}

.progress-track {
    height: 4px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent-green), var(--accent-cyan));
    border-radius: 2px;
    transition: width 0.3s ease;
}

.progress-text {
    display: block;
    margin-top: 10px;
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
}

.export-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px 20px;
    border-top: 1px solid var(--border-color);
}

.export-cancel-btn {
    padding: 9px 16px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.export-cancel-btn:hover {
    border-color: var(--text-muted);
    color: var(--text-primary);
}

.export-submit-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    background: linear-gradient(135deg, var(--accent-green), var(--accent-cyan));
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25);
}

.export-submit-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
}

.export-submit-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.export-submit-btn svg {
    opacity: 0.9;
}

.btn-secondary {
    padding: 10px 18px;
    border-radius: 10px;
    border: 1px solid var(--glass-border);
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    border-color: var(--surface-border-strong);
    color: var(--text-primary);
    background: var(--surface-hover);
}

/* Background option checkbox in modal */
.background-option {
    margin-top: 8px;
    padding-top: 16px;
    border-top: 1px solid var(--glass-border);
}

.checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    display: none;
}

.checkbox-custom {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    border: 2px solid var(--glass-border);
    border-radius: 6px;
    background: var(--surface-bg);
    position: relative;
    transition: all 0.2s ease;
    margin-top: 2px;
}

.checkbox-label:hover .checkbox-custom {
    border-color: var(--accent-purple);
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom {
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
    border-color: transparent;
}

.checkbox-custom::after {
    content: '';
    position: absolute;
    top: 4px;
    left: 6px;
    width: 5px;
    height: 9px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg) scale(0);
    transition: transform 0.15s ease;
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom::after {
    transform: rotate(45deg) scale(1);
}

.checkbox-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.checkbox-text strong {
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
}

.checkbox-text small {
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.4;
}

.background-option-hint {
    margin: 10px 0 0 32px;
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.45;
}

.modal-status {
    border-radius: 14px;
    border: 1px solid var(--glass-border);
    background: var(--glass-bg);
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
    min-height: 24px;
}

.status-preview {
    border-top: 1px dashed var(--glass-border);
    padding-top: 10px;
    margin-top: 6px;
}

.status-preview-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.status-preview pre {
    white-space: pre-wrap;
    word-break: break-word;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 11px;
    line-height: 1.5;
    color: var(--text-secondary);
}

.status-line.active {
    color: var(--text-primary);
}

.status-line.active .status-dot {
    animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
    0% { transform: scale(0.9); opacity: 0.7; }
    50% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(0.9); opacity: 0.7; }
}

.status-line {
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
}

.status-line.active .status-dot {
    background: var(--accent-green);
}

.status-line.error .status-dot {
    background: var(--accent-red);
}

.cover-modal-card {
    width: min(560px, 92vw);
}

.cover-modal-body {
    gap: 14px;
}

.cover-modal-status {
    min-height: 36px;
    border: 1px dashed var(--border-color);
    border-radius: 10px;
    padding: 9px 11px;
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
}

.cover-modal-status.is-info {
    border-style: solid;
    border-color: rgba(59, 130, 246, 0.35);
    color: #93c5fd;
    background: rgba(30, 64, 175, 0.14);
}

.cover-modal-status.is-warning {
    border-style: solid;
    border-color: rgba(245, 158, 11, 0.38);
    color: #fcd34d;
    background: rgba(120, 53, 15, 0.16);
}

.cover-modal-status.is-success {
    border-style: solid;
    border-color: rgba(16, 185, 129, 0.4);
    color: #86efac;
    background: rgba(6, 95, 70, 0.16);
}

.cover-modal-status.is-error {
    border-style: solid;
    border-color: rgba(239, 68, 68, 0.45);
    color: #fca5a5;
    background: rgba(127, 29, 29, 0.16);
}

.cover-progress {
    margin-top: 10px;
    display: grid;
    gap: 6px;
}

.cover-progress-bar {
    width: 100%;
    height: 8px;
    border-radius: 999px;
    overflow: hidden;
    border: 1px solid rgba(59, 130, 246, 0.24);
    background: rgba(15, 23, 42, 0.7);
}

.cover-progress-fill {
    width: 0%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #2563eb 0%, #06b6d4 100%);
    transition: width 0.28s ease;
}

.cover-progress-label {
    font-size: 11px;
    color: var(--text-muted);
    text-align: right;
    letter-spacing: 0.2px;
}

.cover-preview-frame {
    width: min(100%, 250px);
    aspect-ratio: 2 / 3;
    margin: 2px auto 0;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: linear-gradient(140deg, rgba(20, 28, 46, 0.9), rgba(15, 23, 42, 0.7));
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cover-preview-frame img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.cover-preview-placeholder {
    padding: 12px;
    font-size: 12px;
    line-height: 1.5;
    text-align: center;
    color: var(--text-muted);
}

#coverGenerateBtn:disabled,
#coverGenerateBgBtn:disabled {
    opacity: 0.58;
    cursor: not-allowed;
}

@media (max-width: 900px) {
    .modal-grid {
        grid-template-columns: 1fr;
    }
}

/* ===========================================
   AI Panel Collapsible Feature
   =========================================== */

/* AI Panel transition for smooth collapse/expand */
.ai-panel {
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.25s ease,
                transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: width, transform;
}

.ai-panel.collapsed {
    width: 0 !important;
    min-width: 0 !important;
    max-width: 0 !important;
    flex-basis: 0 !important;
    opacity: 0;
    transform: translateX(100%);
    overflow: hidden;
    border-left: none;
    pointer-events: none;
}

/* Content area expands when AI panel is collapsed */
.main-content.ai-collapsed .content-area {
    flex: 1;
}

/* AI Panel Toggle Button - Header style */
.btn-ai-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
}

.btn-ai-toggle::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, 
        rgba(139, 92, 246, 0.1) 0%, 
        rgba(236, 72, 153, 0.1) 100%);
    opacity: 0;
    transition: opacity 0.25s ease;
}

.btn-ai-toggle:hover {
    background: var(--surface-hover-strong);
    color: var(--text-primary);
    border-color: rgba(139, 92, 246, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.15);
}

.btn-ai-toggle:hover::before {
    opacity: 1;
}

.btn-ai-toggle svg {
    position: relative;
    z-index: 1;
    flex-shrink: 0;
}

.btn-ai-toggle .toggle-label {
    position: relative;
    z-index: 1;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 600;
}

/* Active state when panel is expanded */
.btn-ai-toggle.active {
    background: linear-gradient(135deg, 
        rgba(139, 92, 246, 0.15) 0%, 
        rgba(236, 72, 153, 0.15) 100%);
    border-color: rgba(139, 92, 246, 0.4);
    color: var(--text-primary);
}

.btn-ai-toggle.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 2px;
    background: linear-gradient(90deg, var(--accent-purple), var(--accent-pink));
    border-radius: 1px;
}

/* Panel collapse button inside the header */
.ai-panel-collapse-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.ai-panel-collapse-btn:hover {
    background: var(--surface-hover);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.ai-panel-collapse-btn svg {
    width: 16px;
    height: 16px;
    transition: transform 0.2s ease;
}

.ai-panel-collapse-btn:hover svg {
    transform: translateX(2px);
}

/* Light theme adjustments for AI panel toggle */
:root[data-theme="light"] .btn-ai-toggle {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(0, 0, 0, 0.08);
}

:root[data-theme="light"] .btn-ai-toggle:hover {
    background: rgba(255, 255, 255, 1);
    border-color: rgba(139, 92, 246, 0.3);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.1);
}

:root[data-theme="light"] .btn-ai-toggle.active {
    background: linear-gradient(135deg, 
        rgba(139, 92, 246, 0.1) 0%, 
        rgba(236, 72, 153, 0.1) 100%);
}

/* Responsive adjustments */
@media (max-width: 900px) {
    .btn-ai-toggle .toggle-label {
        display: none;
    }
    
    .btn-ai-toggle {
        padding: 10px 12px;
    }
}

/* ============================================
   Character & Chapter Management
   ============================================ */

/* Add button in panel header */
.btn-add-item {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    margin-left: auto;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-add-item:hover {
    background: rgba(139, 92, 246, 0.15);
    border-color: rgba(139, 92, 246, 0.4);
    color: #a78bfa;
}

/* Smaller modal card for character/chapter forms */
.modal-card-small {
    width: min(580px, 92vw);
}

/* Character card with actions */
.character-card {
    position: relative;
}

.character-actions {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    gap: 6px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.character-card:hover .character-actions {
    opacity: 1;
}

.btn-card-action {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.btn-card-action.btn-delete:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.4);
    color: #f87171;
}

/* Outline chapter with actions */
.outline-chapter {
    position: relative;
}

.chapter-actions {
    position: absolute;
    right: 80px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    gap: 6px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.outline-chapter:hover .chapter-actions {
    opacity: 1;
}

/* Color picker styling */
.field input[type="color"] {
    width: 100%;
    height: 40px;
    padding: 4px;
    border-radius: 10px;
    cursor: pointer;
}

/* Confirm delete dialog */
.delete-confirm-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(6, 6, 12, 0.72);
    backdrop-filter: blur(6px);
    z-index: 300;
}

.delete-confirm-dialog {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    width: min(400px, 90vw);
    text-align: center;
}

.delete-confirm-dialog h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.delete-confirm-dialog p {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.delete-confirm-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.btn-danger {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-danger:hover {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    transform: translateY(-1px);
}

/* ==================== AI Project Connection Styles ==================== */

.ai-project-connection {
    background: var(--bg-tertiary);
    border-radius: 8px;
    margin: 8px 12px;
    overflow: hidden;
    border: 1px solid var(--border);
    transition: all 0.3s ease;
    font-size: 12px;
}

.ai-project-connection:hover {
    border-color: var(--border-highlight);
}

.connection-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    cursor: pointer;
    user-select: none;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}

.connection-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.connection-label svg {
    width: 12px;
    height: 12px;
    color: var(--accent);
    opacity: 0.8;
}

.connection-toggle {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
    border-radius: 4px;
}

.connection-toggle:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.connection-toggle.collapsed {
    transform: rotate(-90deg);
}

.connection-content {
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 200px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.connection-content.collapsed {
    max-height: 0;
    padding: 0 8px;
    opacity: 0;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    background: var(--bg-secondary);
    border-radius: 6px;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.status-dot.disconnected {
    background: #6b7280;
    box-shadow: 0 0 0 2px rgba(107, 114, 128, 0.2);
}

.status-dot.connected {
    background: #10b981;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
    animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
    0%, 100% {
        box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
    }
    50% {
        box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.1);
    }
}

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

.project-selector {
    width: 100%;
    padding: 5px 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 12px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    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='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 24px;
}

.project-selector:hover {
    border-color: var(--border-highlight);
}

.project-selector:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.project-selector:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

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

.btn-connect,
.btn-disconnect {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 5px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.btn-connect {
    background: linear-gradient(135deg, var(--accent) 0%, #4f46e5 100%);
    color: white;
}

.btn-connect:hover:not(:disabled) {
    background: linear-gradient(135deg, #818cf8 0%, var(--accent) 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-connect:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

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

.btn-disconnect:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: #ef4444;
    color: #ef4444;
}

.connection-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 6px 8px;
    background: var(--bg-secondary);
    border-radius: 6px;
    border: 1px solid var(--border);
}

.info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
}

.info-label {
    color: var(--text-muted);
}

.info-value {
    color: var(--text-primary);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* System message style in AI chat */
.ai-message.system-message .message-content {
    background: var(--bg-tertiary);
    border-left: 3px solid #10b981;
}

/* ====== Project Creation Mode Switch & Import Panel ====== */
.project-mode-switch {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    background: var(--bg-tertiary, rgba(255, 255, 255, 0.06));
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
    border-radius: 10px;
    margin-bottom: 20px;
    align-self: flex-start;
}

.project-mode-switch__option {
    border: none;
    background: transparent;
    color: var(--text-muted);
    padding: 8px 18px;
    border-radius: 7px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.18s ease, color 0.18s ease;
}

.project-mode-switch__option:hover {
    color: var(--text-primary);
}

.project-mode-switch__option.is-active {
    background: var(--accent-color, #6366f1);
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.project-import-section {
    display: none;
    flex-direction: column;
    gap: 12px;
}

.project-import-section.is-visible {
    display: flex;
}

.project-import-dropzone {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 28px 20px;
    border: 1.5px dashed var(--border-color, rgba(255, 255, 255, 0.18));
    border-radius: 12px;
    background: var(--bg-tertiary, rgba(255, 255, 255, 0.03));
    color: var(--text-muted);
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease;
    text-align: center;
}

.project-import-dropzone:hover,
.project-import-dropzone.is-dragover {
    border-color: var(--accent-color, #6366f1);
    background: rgba(99, 102, 241, 0.08);
    color: var(--text-primary);
}

.project-import-dropzone__title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.project-import-dropzone__hint {
    font-size: 12px;
    line-height: 1.5;
}

.project-import-dropzone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.project-import-preview {
    display: none;
    flex-direction: column;
    gap: 6px;
    padding: 14px 16px;
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
    border-radius: 10px;
    background: var(--bg-tertiary, rgba(255, 255, 255, 0.04));
    font-size: 13px;
}

.project-import-preview.is-visible {
    display: flex;
}

.project-import-preview__title {
    font-weight: 600;
    color: var(--text-primary);
}

.project-import-preview__meta {
    color: var(--text-muted);
    font-size: 12px;
}

.project-import-preview__error {
    color: #f87171;
}

.project-import-hint {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.5;
    margin: 0;
}

.project-generation-fields.is-hidden {
    display: none;
}

.project-import-analyze {
    margin-top: 14px;
    padding: 14px 16px;
    border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
    border-radius: 10px;
    background: var(--surface-2, rgba(255, 255, 255, 0.02));
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.project-import-analyze__options {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-left: 28px;
}

.project-import-analyze__options[hidden] {
    display: none;
}

.project-import-analyze__model {
    margin-left: 0;
}

.project-import-analyze__background {
    margin-top: 0;
    padding-top: 14px;
}

.project-import-analyze__background .background-option-hint {
    margin-left: 32px;
}

.project-import-analyze .checkbox-label {
    align-items: flex-start;
}

/* ===== Sharing + trash/archive additions ===== */

.project-hub__actions--secondary {
    margin-top: 8px;
}

.project-hub__ghost--link {
    width: 100%;
    font-size: 13px;
    opacity: 0.85;
}

/* Scope-specific hub badges */
.project-hub__item[data-scope="trashed"].is-active {
    color: #fda4af;
}

.project-hub__item[data-scope="archived"].is-active {
    color: #fcd34d;
}

.project-hub__item[data-scope="shared"].is-active {
    color: #7dd3fc;
}

/* Project card badges for state + share */
.project-card__state-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 3px 9px;
    font-size: 11px;
    border-radius: 999px;
    letter-spacing: 0.04em;
    background: rgba(30, 30, 40, 0.7);
    color: rgba(255, 255, 255, 0.78);
    border: 1px solid rgba(255, 255, 255, 0.08);
    z-index: 2;
}

.project-card__state-badge.is-archived {
    background: rgba(245, 158, 11, 0.18);
    color: #fde68a;
    border-color: rgba(245, 158, 11, 0.35);
}

.project-card__state-badge.is-trashed {
    background: rgba(244, 63, 94, 0.2);
    color: #fecdd3;
    border-color: rgba(244, 63, 94, 0.35);
}

.project-card__state-badge.is-shared {
    background: rgba(56, 189, 248, 0.18);
    color: #bae6fd;
    border-color: rgba(56, 189, 248, 0.35);
}

.project-card__state-badge.is-sharing {
    background: rgba(168, 85, 247, 0.2);
    color: #e9d5ff;
    border-color: rgba(168, 85, 247, 0.35);
}

.project-card-tool-share svg {
    stroke-width: 2;
}

/* Share modal */
.share-modal-body {
    display: flex;
    flex-direction: column;
    gap: 18px;
    max-height: 70vh;
    overflow-y: auto;
}

.share-create-row {
    display: flex;
    gap: 12px;
    align-items: end;
    padding: 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
}

.share-perm-label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.55);
    flex: 1;
}

.share-perm-label select {
    background: rgba(20, 20, 30, 0.7);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 14px;
}

.share-section-title {
    font-size: 13px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.55);
    margin: 0 0 8px;
}

.share-link-list, .share-collab-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.share-link-item, .share-collab-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.035);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
}

.share-link-item__info, .share-collab-item__info {
    flex: 1;
    min-width: 0;
}

.share-link-item__url {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.share-link-item__meta {
    display: flex;
    gap: 10px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 4px;
}

.share-link-item.is-revoked {
    opacity: 0.5;
}

.share-link-item__actions {
    display: flex;
    gap: 6px;
}

.share-link-item__btn, .share-collab-item__btn {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 12px;
    cursor: pointer;
}

.share-link-item__btn:hover, .share-collab-item__btn:hover {
    background: rgba(255, 255, 255, 0.12);
}

.share-link-item__btn--danger {
    color: #fda4af;
    border-color: rgba(244, 63, 94, 0.3);
}

.share-empty-hint {
    color: rgba(255, 255, 255, 0.4);
    font-size: 13px;
    margin: 4px 0 0;
}

.share-perm-pill {
    display: inline-block;
    padding: 2px 8px;
    font-size: 11px;
    border-radius: 999px;
    background: rgba(99, 102, 241, 0.2);
    color: #c7d2fe;
    margin-left: 4px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.share-perm-pill.is-edit {
    background: rgba(34, 197, 94, 0.2);
    color: #bbf7d0;
}

/* Import link modal */
.import-link-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.import-link-field input {
    width: 100%;
    background: rgba(20, 20, 30, 0.7);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.import-link-preview {
    padding: 14px;
    background: rgba(56, 189, 248, 0.08);
    border: 1px solid rgba(56, 189, 248, 0.25);
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.85);
    font-size: 13px;
    line-height: 1.5;
}

.import-link-error {
    padding: 12px;
    background: rgba(244, 63, 94, 0.1);
    border: 1px solid rgba(244, 63, 94, 0.3);
    border-radius: 10px;
    color: #fecaca;
    font-size: 13px;
}
