:root {
  /* DARK THEME (Default) */
  --bg-depth: #161618; /* Main Background */
  /* Sidebar Background - Updated to be lighter */
  --bg-panel: #121214; 
  --primary: #4D6BFE;
  --primary-dark: #282c85;
  --accent: #6e85ff;
  --text-main: #ececf1;
  --text-muted: #8e8ea0;
  --border: rgba(255, 255, 255, 0.08);
  --glass: rgba(20, 20, 25, 0.7);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --font-ui: 'Inter', -apple-system, sans-serif;
  --font-code: 'JetBrains Mono', monospace;
  --menu-bg: #1e1e1e;
  --menu-hover: rgba(255,255,255,0.1);
}

/* LIGHT THEME OVERRIDES */
.light-theme {
  --bg-depth: #ffffff;
  --bg-panel: #f3f4f6;
  --text-main: #111827;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --glass: rgba(255, 255, 255, 0.9);
  --menu-bg: #ffffff;
  --menu-hover: #f3f4f6;
}
.light-theme .message.bot { color: #374151; }
.light-theme .code-block { background: #f3f4f6; border-color: #e5e7eb; }
.light-theme .code-block pre { color: #1f2937; }
.light-theme .composer { background: #ffffff; box-shadow: 0 4px 20px rgba(0,0,0,0.05); border-color: #e5e7eb; }
.light-theme .prompt-input { color: #111827; }
.light-theme .btn.subtle { background: transparent; color: #4b5563; border-color: transparent; }
.light-theme .btn.subtle:hover { background: rgba(0,0,0,0.05); color: #111827; }
.light-theme .sidebar { background: #f9fafb; border-right-color: #e5e7eb; }
.light-theme .brand-name { color: #111827; }
.light-theme .settings-menu { border-color: #e5e7eb; box-shadow: 0 10px 30px rgba(0,0,0,0.1); }
.light-theme .user-dropdown { background: #ffffff; border-color: #e5e7eb; box-shadow: 0 10px 30px rgba(0,0,0,0.1); }
.light-theme .user-dropdown-name { color: #111827; }
.light-theme .user-dropdown-divider { background-color: #e5e7eb; }
.light-theme .user-dropdown-link:hover { background-color: #f3f4f6; }


* { box-sizing: border-box; }

body {
  margin: 0;
  background-color: var(--bg-depth);
  color: var(--text-main);
  font-family: var(--font-ui);
  height: 100vh;
  overflow: hidden;
  display: flex;
  justify-content: center;
  transition: background-color 0.3s, color 0.3s;
}

.app-root { 
    width: 100%; 
    height: 100%; 
    display: flex; 
    background: transparent; 
    transition: transform 0.8s ease-in-out; 
}
.light-theme .app-root { background: rgba(255,255,255,0.8); }

/* --- UPSIDE DOWN MODE: Invert contents while preserving element flow --- */

.inverted-mode .sidebar,
.inverted-mode .main,
.inverted-mode .right-sidebar,
.inverted-mode .top-right-auth,
.inverted-mode .sidebar-show-btn,
.inverted-mode .right-sidebar-toggle-btn {
    transform: rotate(180deg);
    transition: transform 0.8s ease-in-out; 
}

.inverted-mode .composer-container {
    transform: rotate(180deg);
    transition: transform 0.8s ease-in-out; 
}

.inverted-mode .logo-glow-container {
    transform: rotate(180deg);
    transition: transform 0.8s ease-in-out;
}

/* --- MIRROR WORLD MODE --- */
.mirror-mode .app-root {
    transform: scaleX(-1);
    transition: transform 0.8s ease-in-out;
}

.mirror-mode .fix-btn {
    transform: translateX(-50%) scaleX(-1) !important; 
    background: #FF0055; 
    box-shadow: 0 0 15px rgba(255, 0, 85, 0.5) !important;
}

.text-normal {
    display: inline-block;
    transform: rotate(180deg);
    transition: all 0.5s ease;
}

.fix-btn {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    width: auto !important;
    height: auto !important;
    padding: 10px 24px;
    border-radius: 20px !important;
    box-shadow: 0 0 15px rgba(77, 107, 254, 0.5) !important;
    background: var(--primary);
    color: white;
    font-weight: 600;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: translateX(-50%) scale(1); }
    50% { transform: translateX(-50%) scale(1.05); }
    100% { transform: translateX(-50%) scale(1); }
}

/* --- SIDEBAR --- */
.sidebar { 
    width: 260px; 
    background: var(--bg-panel); 
    border-right: 1px solid var(--border); 
    padding: 24px 16px; 
    display: flex; 
    flex-direction: column; 
    gap: 16px; 
    flex-shrink: 0; 
    height: 100vh; 
    overflow: hidden; 
    transition: width 0.3s ease, padding 0.3s ease, background 0.3s, border 0.3s; 
}

.sidebar.collapsed {
    width: 0;
    padding-left: 0;
    padding-right: 0;
    border-right: none;
    overflow: hidden;
    white-space: nowrap;
}

.brand { display: flex; align-items: center; justify-content: space-between; padding-bottom: 10px; flex-shrink: 0; min-width: 228px; }
.brand-content { display: flex; align-items: center; gap: 12px; }
.brand-logo { width: 42px; height: 42px; border-radius: 10px; object-fit: cover; }
.brand-name { font-weight: 700; font-size: 18px; letter-spacing: -0.5px; color: #fff; }

.sidebar-toggle-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.sidebar-toggle-btn:hover { background: rgba(255,255,255,0.1); color: var(--text-main); }
.light-theme .sidebar-toggle-btn:hover { background: rgba(0,0,0,0.05); }

.sidebar-show-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 90;
    display: none; 
    background: var(--bg-panel);
    border: 1px solid var(--border);
    color: var(--text-muted);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transition: all 0.2s;
}
.sidebar-show-btn:hover { color: var(--text-main); border-color: rgba(255,255,255,0.2); transform: scale(1.05); }
.light-theme .sidebar-show-btn { background: #ffffff; }

.sidebar.collapsed + .main .sidebar-show-btn {
    display: flex;
    animation: fadeIn 0.3s ease;
}


.controls {
    flex: 1; 
    display: flex;
    flex-direction: column;
    overflow: hidden; 
    min-height: 0; 
    gap: 10px;
    min-width: 228px; 
}
.btn.subtle { width: 100%; padding: 12px 16px; background: rgba(255,255,255,0.03); border: 1px solid var(--border); border-radius: var(--radius-md); color: var(--text-main); font-size: 14px; cursor: pointer; display: flex; align-items: center; gap: 10px; transition: all 0.2s; flex-shrink: 0; }
.btn.subtle:hover { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.2); }

#designAiBtn {
    padding-top: 2px;
    padding-bottom: 2px;
    min-height: 46px; 
}

.btn.subtle.locked {
    opacity: 0.5;
    cursor: default;
    background: transparent;
    border-color: rgba(255,255,255,0.05);
}
.btn.subtle.locked:hover {
    background: transparent;
    border-color: rgba(255,255,255,0.05);
}
.lock-icon {
    margin-left: auto;
    opacity: 0.6;
}
.light-theme .btn.subtle.locked {
    background: rgba(0,0,0,0.02);
    border-color: rgba(0,0,0,0.05);
}

.btn.subtle.premium-unlocked {
    border-color: rgba(77, 107, 254, 0.4);
    background: rgba(77, 107, 254, 0.08);
    color: var(--text-main);
    opacity: 1;
    cursor: pointer;
}
.btn.subtle.premium-unlocked:hover {
    background: rgba(77, 107, 254, 0.15);
    border-color: var(--primary);
}
.btn.subtle.premium-unlocked .lock-icon {
    display: none;
}

.btn-icon {
    width: 40px; 
    height: 40px; 
    object-fit: contain;
    filter: invert(1) opacity(0.7); 
    transition: all 0.2s ease;
    margin-right: 6px;
}

.btn.subtle:hover .btn-icon {
    opacity: 1;
}

.light-theme .btn-icon {
    filter: invert(0) opacity(0.7);
}

.btn.subtle.premium-unlocked .btn-icon {
    opacity: 0.9;
}
.btn.subtle.premium-unlocked:hover .btn-icon {
    opacity: 1;
}


.upgrade-icon-container {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(77, 107, 254, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(77, 107, 254, 0.2);
    margin-bottom: 10px;
}

.premium-modal-content {
    border: 1px solid rgba(77, 107, 254, 0.3) !important;
    position: relative;
    overflow: hidden;
}

.premium-glow {
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(77, 107, 254, 0.15) 0%, transparent 60%);
    z-index: -1;
    pointer-events: none;
    animation: rotateGlow 10s linear infinite;
}

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

.history-list { 
    flex: 1; 
    overflow-y: auto; 
    margin-right: -8px; padding-right: 8px; 
    display: flex; flex-direction: column; gap: 4px; 
    min-height: 0;
    min-width: 228px; 
}
.history-item { padding: 10px 12px; border-radius: 8px; color: var(--text-main); font-size: 13px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: background 0.2s; flex-shrink: 0; }
.history-item:hover { background: rgba(255, 255, 255, 0.05); }
.history-item.active { background: rgba(77, 107, 254, 0.15); color: var(--text-main); border: 1px solid rgba(77, 107, 254, 0.3); }

.sidebar-footer { 
    margin-top: 0; 
    font-size: 12px; color: var(--text-muted); 
    display: flex; align-items: center; gap: 8px; 
    flex-shrink: 0; 
    background: var(--bg-panel); 
    padding-top: 10px;
    position: relative;
    min-width: 228px; 
}
#auth-container { flex-shrink: 0; padding-top: 10px; }

.settings-menu {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 0;
    width: 240px;
    background: var(--menu-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px;
    margin-bottom: 10px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    z-index: 150;
}
.settings-menu.show { display: block; animation: fadeIn 0.1s ease; }
.settings-item {
    display: flex; align-items: center; gap: 12px; padding: 10px 12px;
    border-radius: 8px; color: var(--text-main); font-size: 13px; cursor: pointer;
    transition: background 0.2s;
}
.settings-item:hover { background: var(--menu-hover); }
.settings-item.danger { color: #ff5f5f; }
.settings-item.danger:hover { background: rgba(255, 95, 95, 0.1); }

.btn.small { padding: 8px 10px; font-size: 13px; width: auto; }

.top-right-auth { 
    position: fixed; 
    top: 20px; 
    right: 24px; 
    z-index: 2000; 
    display: flex; 
    align-items: center; 
    gap: 12px;
}

.user-top-profile {
    position: relative;
    cursor: pointer;
    display: flex;
    align-items: center;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid rgba(255,255,255,0.15);
    transition: box-shadow 0.2s;
    background-color: #2a2a2f; 
}
.user-avatar:hover {
    box-shadow: 0 0 0 2px var(--primary);
}

.user-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    width: 200px;
    background: var(--menu-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px 0;
    margin-top: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    z-index: 2001;
}

.user-dropdown.show {
    display: block;
    animation: fadeIn 0.1s ease;
}

.user-dropdown-name {
    padding: 8px 16px 4px 16px; 
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-dropdown-plan {
    padding: 0 16px 8px 16px;
    font-size: 11px;
    color: #8e8ea0;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.user-dropdown-expiry {
    padding: 0 16px 8px 16px;
    font-size: 10px;
    color: #6b7280; 
    font-weight: 400;
    white-space: nowrap;
}

.user-dropdown-divider {
    height: 1px;
    background-color: var(--border);
    margin: 4px 0;
}

.user-dropdown-link {
    display: block;
    padding: 8px 16px;
    color: var(--text-main);
    text-decoration: none;
    font-size: 13px;
    transition: background 0.2s;
}

.user-dropdown-link:hover {
    background: var(--menu-hover);
}


.auth-modal { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; z-index: 80; }
.auth-modal[aria-hidden="false"] { display: flex; }
.auth-modal-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); }
.auth-modal-content { position: relative; width: 360px; max-width: calc(100% - 40px); background: linear-gradient(180deg, rgba(12,12,16,0.98), rgba(8,8,12,0.98)); border-radius: 12px; padding: 20px; border: 1px solid rgba(255,255,255,0.06); box-shadow: 0 12px 40px rgba(0,0,0,0.6); z-index: 100; }
.modal-close { position: absolute; top: 8px; right: 8px; background: transparent; color: var(--text-muted); border: none; font-size: 20px; cursor: pointer; }

.main { flex: 1; display: flex; flex-direction: column; position: relative; }
.main-header { display: none; padding: 16px 24px; justify-content: space-between; align-items: center; }
.model-badge { font-size: 11px; background: rgba(77, 107, 254, 0.1); color: var(--accent); padding: 4px 8px; border-radius: 6px; border: 1px solid rgba(77, 107, 254, 0.2); font-family: var(--font-code); }

.chat-area { flex: 1; overflow-y: auto; padding: 20px 0 140px 0; scroll-behavior: smooth; }
.messages { max-width: 800px; margin: 0 auto; display: flex; flex-direction: column; padding: 0 20px; }
.messages.empty { height: 100%; align-items: center; justify-content: center; text-align: center; }
.empty-logo { width: 240px; height: 240px; margin-bottom: 32px; opacity: 0.8; }
.logo-glow-container { position: relative; display: inline-block; }

/* Greatly reduced glow effect */
.logo-glow-container::after { 
    content: ''; 
    position: absolute; 
    top: 50%; 
    left: 50%; 
    transform: translate(-50%, -50%); 
    width: 200px; /* Reduced size */
    height: 200px; /* Reduced size */
    background: var(--primary); 
    filter: blur(60px); /* Reduced blur */
    opacity: 0.1; /* Reduced opacity */
    z-index: -1; 
}
.empty-state h2 { font-weight: 500; color: var(--text-main); font-size: 24px; margin: 0; }

.message { padding: 24px 0; border-bottom: 1px solid rgba(255,255,255,0.03); font-size: 16px; line-height: 1.7; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
.message.user { color: var(--text-main); font-weight: 500; }
.message.bot { color: #d1d5db; }
.message::before { content: 'You'; display: block; font-size: 12px; font-weight: 700; color: var(--text-muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px; }
.message.bot::before { content: 'Archimedes'; color: var(--accent); }

.composer-container {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 24px;
    background: linear-gradient(to top, var(--bg-depth) 20%, transparent);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    z-index: 10;
}

.composer {
    width: 100%;
    max-width: 760px;
    position: relative;
    background: rgba(30, 30, 35, 0.6);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 30px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    padding: 8px 12px;
    min-height: 56px;
    transition: all 0.2s ease;
}

.composer:focus-within {
    border-color: rgba(77, 107, 254, 0.4);
    background: rgba(30, 30, 35, 0.8);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}

.prompt-input {
    flex: 1;
    background: transparent;
    border: none;
    color: #ececf1;
    font-size: 15px;
    padding: 10px 12px;
    outline: none;
    font-family: var(--font-ui);
    line-height: 1.5;
}
.prompt-input::placeholder { color: rgba(255, 255, 255, 0.4); }

.btn.primary {
    background: var(--primary);
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    box-shadow: 0 2px 10px rgba(77, 107, 254, 0.3);
}
.btn.primary:hover {
    background: var(--accent);
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(77, 107, 254, 0.5);
}
.btn.primary:active { transform: scale(0.95); }
.disclaimer { font-size: 11px; color: var(--text-muted); opacity: 0.7; }

.model-selector-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: transparent; 
    border: none; 
    color: #8e8ea0;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    margin-right: 8px; 
    transition: background 0.2s;
    font-family: var(--font-ui);
}
.model-selector-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ececf1;
}
.light-theme .model-selector-btn { background: transparent; color: #4b5563; }
.light-theme .model-selector-btn:hover { background: rgba(0,0,0,0.05); color: #111827; }

.model-menu {
    display: none;
    position: absolute;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
    width: 320px;
    background: #1e1e1e;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 16px;
    box-shadow: 0 12px 36px rgba(0,0,0,0.6);
    padding: 8px;
    z-index: 100;
}
.model-menu.show { display: block; animation: fadeIn 0.1s ease; }
.light-theme .model-menu { background: #ffffff; border-color: #e5e7eb; box-shadow: 0 12px 36px rgba(0,0,0,0.15); }

.model-menu-header {
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 600;
    color: #8e8ea0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.model-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    position: relative;
}
.model-option:hover { background: rgba(255,255,255,0.05); }
.light-theme .model-option:hover { background: rgba(0,0,0,0.05); }

.model-option.selected { background: rgba(77, 107, 254, 0.1); }
.light-theme .model-option.selected { background: #eef2ff; }

.model-icon { width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; border-radius: 50%; color: #8e8ea0; }
.model-option.selected .model-icon { color: var(--primary); }

.model-details { flex: 1; }
.model-name { font-size: 14px; font-weight: 500; color: #ececf1; display: flex; align-items: center; gap: 8px; }
.light-theme .model-name { color: #111827; }
.model-desc { font-size: 12px; color: #8e8ea0; margin-top: 2px; }

.new-badge {
    font-size: 10px;
    background: #4D6BFE;
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 600;
}

.check-icon { display: none; color: var(--primary); }
.model-option.selected .check-icon { display: block; }

.code-block { position: relative; margin: 16px 0; background: #1e1e1e; border-radius: var(--radius-md); border: 1px solid rgba(255,255,255,0.1); overflow: hidden; }
.code-block pre { margin: 0; padding: 16px; padding-right: 40px; overflow-x: auto; font-family: var(--font-code); font-size: 13px; color: #d4d4d4; }
.code-copy-btn { position: absolute; top: 8px; right: 8px; background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.1); border-radius: 6px; padding: 6px; cursor: pointer; color: var(--text-muted); transition: all 0.2s; display: flex; align-items: center; justify-content: center; z-index: 5; }

.file-artifact { background: #1e1e1e; border: 1px solid rgba(255,255,255,0.1); border-radius: 8px; margin: 16px 0; padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; transition: border-color 0.2s; }
.file-info { display: flex; align-items: center; gap: 12px; font-size: 14px; font-weight: 500; color: #ececf1; }
.file-icon { color: var(--primary); }
.btn-file-open { background: rgba(255,255,255,0.1); border: none; border-radius: 6px; padding: 6px 12px; color: #ececf1; font-size: 12px; cursor: pointer; transition: background 0.2s; font-family: var(--font-ui); }

.file-modal { display: none; position: fixed; inset: 0; z-index: 200; align-items: center; justify-content: center; }
.file-modal.active { display: flex; }
.file-modal-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.8); backdrop-filter: blur(4px); }
.file-modal-content { position: relative; background: #1e1e1e; width: 800px; max-width: 90vw; height: 80vh; border-radius: 12px; border: 1px solid rgba(255,255,255,0.1); display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 20px 50px rgba(0,0,0,0.5); }
.file-modal-header { padding: 16px 24px; border-bottom: 1px solid rgba(255,255,255,0.1); display: flex; justify-content: space-between; align-items: center; background: #252526; }
.file-modal-title { font-weight: 600; color: #fff; font-size: 14px; }
.file-modal-close { background: transparent; border: none; color: #8e8ea0; cursor: pointer; font-size: 20px; }
.file-modal-body { flex: 1; overflow: auto; padding: 0; background: #1e1e1e; }

.hljs { background: transparent !important; padding: 0 !important; }

/* Desktop Logic (1200px and up) is implicitly here */

/* RIGHT SIDEBAR (Code Canvas) */
.right-sidebar {
  width: 840px; /* Doubled from 420px */
  max-width: 85vw; /* Increased from 45vw to allow full doubled width */
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100vh;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  /* Updated for smooth transition */
  transition: width 0.3s ease, padding 0.3s ease, opacity 0.2s;
}

.right-sidebar.collapsed {
    width: 0;
    padding: 0;
    border-left: none;
    opacity: 0;
}

.code-canvas-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 6px;
  min-width: 380px; /* Prevent squashing content during transition */
}

.code-canvas-title {
  font-weight: 700;
  font-size: 14px;
}

.code-canvas-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.code-canvas-list {
  overflow-y: auto;
  padding-right: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: calc(100vh - 60px);
  min-width: 380px; 
}

/* Floating Right Sidebar Toggle Button */
.right-sidebar-toggle-btn {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-right: none;
    border-radius: 8px 0 0 8px;
    color: var(--text-muted);
    padding: 8px 4px;
    cursor: pointer;
    z-index: 100;
    display: flex; 
    align-items: center;
    justify-content: center;
    box-shadow: -4px 0 12px rgba(0,0,0,0.1);
    transition: all 0.2s; /* Removed transform from here to stop button rotation */
}

.right-sidebar-toggle-btn:hover {
    color: var(--text-main);
    background: rgba(255,255,255,0.05);
    padding-right: 8px; 
}

/* Add transition to the icon */
.right-sidebar-toggle-btn svg {
    transition: transform 0.25s ease;
}

/* Rotate ONLY the icon when sidebar is collapsed */
.right-sidebar-toggle-btn.rotated svg {
    transform: rotate(180deg); 
}

/* Ensure the button itself stays stable */
.right-sidebar-toggle-btn.rotated {
    transform: translateY(-50%); 
}

.light-theme .right-sidebar-toggle-btn { background: #ffffff; }


.code-file {
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.03);
  padding: 8px;
  border-radius: 8px;
  font-family: var(--font-code);
  font-size: 12px;
  color: var(--text-main);
}

.code-file .file-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.code-file .file-name {
  font-weight: 600;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 70%;
}

.code-file .file-actions {
  display: flex;
  gap: 6px;
}

.code-snippet {
  max-height: 160px;
  overflow: auto;
  border-radius: 6px;
  padding: 8px;
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.02);
}

.code-snippet pre {
  margin: 0;
  font-family: var(--font-code);
  font-size: 11px;
  line-height: 1.4;
  white-space: pre;
}

/* Compact mode for smaller screens - UPDATED */
@media (max-width: 768px) {
  /* 1. LEFT SIDEBAR - FULL SCREEN OVERLAY */
  .sidebar {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3000;
    transform: translateX(0);
    transition: transform 0.3s ease;
  }
  
  .sidebar.collapsed {
    width: 100%;
    padding: 0;
    border: none;
    transform: translateX(-100%);
  }

  /* 2. RIGHT SIDEBAR (CODE CANVAS) */
  .right-sidebar {
    display: flex;
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    z-index: 3000;
    transform: translateX(0);
    transition: transform 0.3s ease;
  }

  .right-sidebar.collapsed {
    width: 100%;
    padding: 0;
    opacity: 1;
    transform: translateX(100%);
  }

  /* 3. HEADER & TITLE CENTERING */
  .main-header {
    display: flex;
    justify-content: center; /* Centers items horizontally */
    align-items: center;     /* Centers items vertically */
    padding: 0;
    height: 70px;            /* Fixed height for alignment math */
    position: relative;
    width: 100%;
  }
  
  .title {
      font-size: 20px;
      margin: 0;
      text-align: center;
      line-height: 1;
      position: relative;
      z-index: 10;
  }

  /* Hide the model badge on mobile to ensure the title is perfectly centered */
  .model-badge {
      display: none;
  }

  /* 4. LEFT BUTTON (SIDEBAR TOGGLE) */
  .sidebar-show-btn {
    display: flex !important;
    position: absolute;
    z-index: 2005;
    background: var(--bg-depth);
    /* (Header Height 70px - Button Height 36px) / 2 = 17px */
    top: 17px; 
    left: 16px;
  }

  /* 5. RIGHT BUTTON (SIGN IN) */
  .top-right-auth {
    position: absolute;
    /* Aligning top with the left button */
    top: 17px; 
    right: 16px;
    z-index: 2005;
  }
  
  /* 6. RIGHT SIDEBAR TOGGLE - MOBILE STATE LOGIC */
  .right-sidebar-toggle-btn {
    display: flex !important;
    z-index: 3500;
    top: 50%;
    transform: translateY(-50%);
    
    /* DEFAULT: Sidebar is OPEN (button moves to LEFT) */
    right: auto;
    left: 0;
    border-radius: 0 8px 8px 0;
    border-left: none;
    border-right: 1px solid var(--border);
  }

  /* STATE: Sidebar is CLOSED (button stays on RIGHT) */
  .right-sidebar-toggle-btn.rotated {
    right: 0;
    left: auto;
    border-radius: 8px 0 0 8px;
    border-right: none;
    border-left: 1px solid var(--border);
  }

  .messages {
    padding: 0 16px;
  }

  .composer {
    border-radius: 24px;
  }
  
  .model-menu {
    bottom: 80px;
    width: 280px;
  }
}


/* --- ZERO GRAVITY MODE --- */
.zero-gravity-mode .btn,
.zero-gravity-mode .brand-logo,
.zero-gravity-mode .history-item,
.zero-gravity-mode .message,
.zero-gravity-mode .prompt-input,
.zero-gravity-mode .model-selector-btn,
.zero-gravity-mode .title,
.zero-gravity-mode .brand-name,
.zero-gravity-mode svg,
.zero-gravity-mode .model-option,
.zero-gravity-mode img {
    animation: float-gravity 6s ease-in-out infinite;
    transition: transform 1s ease;
    display: inline-block; /* Ensures text elements float properly */
}

/* A gentle floating animation */
@keyframes float-gravity {
    0% { transform: translate(0px, 0px) rotate(0deg); }
    25% { transform: translate(5px, -15px) rotate(2deg); }
    50% { transform: translate(-5px, 10px) rotate(-2deg); }
    75% { transform: translate(-10px, -5px) rotate(1deg); }
    100% { transform: translate(0px, 0px) rotate(0deg); }
}

/* Ensure the fix button is visible in this chaos */
.zero-gravity-mode .fix-btn {
    animation: none !important;
    background: #FF9800; /* Orange for visibility */
    box-shadow: 0 0 20px rgba(255, 152, 0, 0.6) !important;
}

/* --- New Style for Chat Placeholders --- */
.code-placeholder-in-chat {
    background: rgba(77, 107, 254, 0.08);
    border: 1px dashed rgba(77, 107, 254, 0.3);
    border-radius: 8px;
    padding: 10px 16px;
    margin: 10px 0;
    color: var(--primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s;
}

.code-placeholder-in-chat:hover {
    background: rgba(77, 107, 254, 0.15);
    border-style: solid;
}

.code-placeholder-in-chat svg {
    opacity: 0.8;
}
/* --- THINKING PROCESS (GEMINI STYLE) --- */
.thinking-container {
    margin-bottom: 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.02);
    max-width: 100%;
    /* New: Allow it to be hidden when not needed (e.g., in simple chat) */
    transition: max-height 0.3s ease, opacity 0.3s ease; 
}

.thinking-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.03);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    transition: background 0.2s, color 0.2s;
    user-select: none;
}

.thinking-header:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-main);
}

.thinking-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    /* Removed pulse-think animation for a cleaner look during streaming */
    animation: none; 
}

.thinking-label {
    flex: 1;
}

.thinking-chevron {
    transition: transform 0.3s ease;
    opacity: 0.6;
}

.thinking-container.expanded .thinking-chevron {
    transform: rotate(180deg);
}

.thinking-body {
    display: none; /* Hidden by default */
    padding: 12px 14px;
    background: rgba(0, 0, 0, 0.2);
    font-family: var(--font-code);
    font-size: 12px;
    color: #8e8ea0;
    line-height: 1.6;
    border-top: 1px solid var(--border);
    max-height: 300px;
    overflow-y: auto;
    white-space: pre-wrap; /* Ensure streamed code/text preserves formatting */
}

.thinking-container.expanded .thinking-body {
    display: block;
    animation: slideDown 0.2s ease-out;
}

.thinking-step {
    margin-bottom: 6px;
    display: flex;
    gap: 8px;
    color: var(--primary); /* Highlight the status messages */
    font-weight: 500;
}
.thinking-step span:first-child { 
    color: #8e8ea0; 
    font-weight: 400; 
} /* De-emphasize the bullet */
.thinking-step:last-child { margin-bottom: 0; }
.thinking-step.active { color: var(--primary); }


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

/* Light theme overrides for thinking */
.light-theme .thinking-container { background: #f9fafb; border-color: #e5e7eb; }
.light-theme .thinking-header { background: #f3f4f6; color: #6b7280; }
.light-theme .thinking-header:hover { background: #e5e7eb; color: #374151; }
.light-theme .thinking-body { background: #ffffff; border-color: #e5e7eb; color: #6b7280; }
.light-theme .thinking-step { color: var(--primary); }
.light-theme .thinking-step span:first-child { color: #6b7280; }