/* =============================================
   NEXUS AI — Design System & Styles
   ============================================= */

/* --- CSS Variables --- */
:root {
   /* Colors */
   --bg-primary: #0a0a0f;
   --bg-secondary: #111118;
   --bg-tertiary: #1a1a24;
   --bg-card: #14141e;
   --bg-hover: #1e1e2e;
   --bg-input: #1a1a26;
   --bg-sidebar: #0d0d14;

   --text-primary: #e8e8ef;
   --text-secondary: #9898a8;
   --text-muted: #5a5a6e;
   --text-accent: #a78bfa;

   --accent-primary: #7c3aed;
   --accent-secondary: #6d28d9;
   --accent-glow: rgba(124, 58, 237, 0.15);
   --accent-gradient: linear-gradient(135deg, #7c3aed 0%, #a78bfa 100%);

   --blue: #3b82f6;
   --blue-glow: rgba(59, 130, 246, 0.15);
   --green: #22c55e;
   --green-glow: rgba(34, 197, 94, 0.15);
   --yellow: #eab308;
   --yellow-glow: rgba(234, 179, 8, 0.15);
   --orange: #f97316;
   --orange-glow: rgba(249, 115, 22, 0.15);
   --red: #ef4444;
   --red-glow: rgba(239, 68, 68, 0.15);
   --cyan: #06b6d4;

   --border-color: #1e1e2e;
   --border-subtle: rgba(255, 255, 255, 0.06);

   /* Spacing */
   --sidebar-width: 280px;
   --thinking-width: 380px;
   --topbar-height: 60px;

   /* Radius */
   --radius-sm: 6px;
   --radius-md: 10px;
   --radius-lg: 16px;
   --radius-xl: 20px;
   --radius-full: 9999px;

   /* Shadows */
   --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
   --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
   --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
   --shadow-glow: 0 0 20px var(--accent-glow);

   /* Transitions */
   --ease: cubic-bezier(0.4, 0, 0.2, 1);
   --transition-fast: 150ms var(--ease);
   --transition-normal: 250ms var(--ease);
   --transition-slow: 400ms var(--ease);
}

/* --- Reset --- */
*,
*::before,
*::after {
   box-sizing: border-box;
   margin: 0;
   padding: 0
}

html {
   font-size: 16px;
   -webkit-text-size-adjust: 100%
}

body {
   font-family: 'Inter', system-ui, -apple-system, sans-serif;
   background: var(--bg-primary);
   color: var(--text-primary);
   line-height: 1.6;
   overflow: hidden;
   height: 100vh;
   width: 100vw
}

button {
   cursor: pointer;
   border: none;
   background: none;
   font-family: inherit;
   color: inherit;
   font-size: inherit
}

input,
textarea,
select {
   font-family: inherit;
   color: inherit;
   font-size: inherit
}

a {
   color: var(--accent-primary);
   text-decoration: none
}

::-webkit-scrollbar {
   width: 6px
}

::-webkit-scrollbar-track {
   background: transparent
}

::-webkit-scrollbar-thumb {
   background: var(--border-color);
   border-radius: 3px
}

::-webkit-scrollbar-thumb:hover {
   background: var(--text-muted)
}

/* --- Layout --- */
.app {
   display: flex;
   height: 100vh;
   width: 100vw;
   overflow: hidden
}

.hidden {
   display: none !important
}

/* ========================
   SIDEBAR
   ======================== */
.sidebar {
   width: var(--sidebar-width);
   background: var(--bg-sidebar);
   border-right: 1px solid var(--border-color);
   display: flex;
   flex-direction: column;
   flex-shrink: 0;
   transition: transform var(--transition-normal);
   z-index: 100;
   overflow: hidden
}

.sidebar-header {
   display: flex;
   align-items: center;
   justify-content: space-between;
   padding: 16px 16px 12px;
   border-bottom: 1px solid var(--border-subtle)
}

.logo {
   display: flex;
   align-items: center;
   gap: 10px
}

.logo-icon {
   font-size: 28px
}

.logo-text {
   font-size: 20px;
   font-weight: 800;
   background: var(--accent-gradient);
   -webkit-background-clip: text;
   -webkit-text-fill-color: transparent;
   background-clip: text;
   letter-spacing: -0.5px
}

.sidebar-close-btn {
   display: none
}

.new-chat-btn {
   margin: 12px 12px 8px;
   padding: 10px 16px;
   display: flex;
   align-items: center;
   gap: 8px;
   background: var(--accent-gradient);
   color: #fff;
   border-radius: var(--radius-md);
   font-weight: 600;
   font-size: 14px;
   transition: all var(--transition-fast);
   box-shadow: var(--shadow-glow)
}

.new-chat-btn:hover {
   transform: translateY(-1px);
   box-shadow: 0 0 30px var(--accent-glow)
}

.new-chat-btn i {
   width: 18px;
   height: 18px
}

.chat-history {
   flex: 1;
   overflow-y: auto;
   padding: 8px
}

.chat-history-label {
   padding: 8px 12px;
   font-size: 11px;
   font-weight: 600;
   text-transform: uppercase;
   letter-spacing: 1px;
   color: var(--text-muted)
}

.chat-history-list {
   display: flex;
   flex-direction: column;
   gap: 2px
}

.chat-history-item {
   padding: 10px 12px;
   border-radius: var(--radius-sm);
   font-size: 13px;
   color: var(--text-secondary);
   cursor: pointer;
   transition: all var(--transition-fast);
   white-space: nowrap;
   overflow: hidden;
   text-overflow: ellipsis;
   display: flex;
   align-items: center;
   gap: 8px
}

.chat-history-item:hover {
   background: var(--bg-hover);
   color: var(--text-primary)
}

.chat-history-item.active {
   background: var(--accent-glow);
   color: var(--text-accent);
   border: 1px solid rgba(124, 58, 237, 0.2)
}

.chat-history-item i {
   width: 16px;
   height: 16px;
   flex-shrink: 0
}

.sidebar-footer {
   border-top: 1px solid var(--border-subtle);
   padding: 8px
}

.sidebar-footer-btn {
   width: 100%;
   display: flex;
   align-items: center;
   gap: 10px;
   padding: 10px 12px;
   border-radius: var(--radius-sm);
   font-size: 14px;
   color: var(--text-secondary);
   transition: all var(--transition-fast)
}

.sidebar-footer-btn:hover {
   background: var(--bg-hover);
   color: var(--text-primary)
}

.sidebar-footer-btn i {
   width: 18px;
   height: 18px
}

.ai-status {
   display: flex;
   align-items: center;
   gap: 8px;
   padding: 10px 12px;
   font-size: 12px;
   color: var(--text-muted)
}

.status-dot {
   width: 8px;
   height: 8px;
   border-radius: 50%;
   flex-shrink: 0;
   animation: pulse 2s infinite
}

.status-active {
   background: var(--green);
   box-shadow: 0 0 8px var(--green-glow)
}

.status-evolving {
   background: var(--blue);
   box-shadow: 0 0 8px var(--blue-glow)
}

.status-studying {
   background: var(--orange);
   box-shadow: 0 0 8px var(--orange-glow)
}

.status-warning {
   background: var(--yellow);
   box-shadow: 0 0 8px var(--yellow-glow)
}

/* Space Status Panel */
.space-status-panel {
   display: flex;
   gap: 12px;
   padding: 8px 12px;
   margin: 4px 0;
   border-radius: var(--radius-sm);
   background: var(--bg-primary)
}

.space-status-item {
   display: flex;
   align-items: center;
   gap: 5px;
   font-size: 11px;
   color: var(--text-muted);
   font-weight: 500
}

@keyframes pulse {

   0%,
   100% {
      opacity: 1
   }

   50% {
      opacity: 0.5
   }
}

.sidebar-overlay {
   position: fixed;
   inset: 0;
   background: rgba(0, 0, 0, 0.6);
   z-index: 99;
   opacity: 0;
   pointer-events: none;
   transition: opacity var(--transition-normal)
}

.sidebar-overlay.active {
   opacity: 1;
   pointer-events: auto
}

/* ========================
   MAIN CONTENT
   ======================== */
.main-content {
   flex: 1;
   display: flex;
   flex-direction: column;
   min-width: 0;
   position: relative
}

.view {
   display: none;
   flex-direction: column;
   height: 100%;
   overflow: hidden
}

.view.active {
   display: flex
}

/* ========================
   CHAT TOPBAR
   ======================== */
.chat-topbar,
.dash-topbar {
   display: flex;
   align-items: center;
   justify-content: space-between;
   height: var(--topbar-height);
   padding: 0 20px;
   border-bottom: 1px solid var(--border-color);
   background: var(--bg-secondary);
   flex-shrink: 0
}

.topbar-left {
   display: flex;
   align-items: center;
   gap: 12px
}

.topbar-right {
   display: flex;
   align-items: center;
   gap: 8px
}

.topbar-title {
   font-size: 18px;
   font-weight: 700;
   letter-spacing: -0.3px
}

.topbar-meta {
   display: flex;
   align-items: center;
   gap: 10px;
   font-size: 12px;
   color: var(--text-muted)
}

.icon-btn {
   width: 36px;
   height: 36px;
   display: flex;
   align-items: center;
   justify-content: center;
   border-radius: var(--radius-sm);
   transition: all var(--transition-fast);
   color: var(--text-secondary)
}

.icon-btn:hover {
   background: var(--bg-hover);
   color: var(--text-primary)
}

.icon-btn i {
   width: 20px;
   height: 20px
}

.confidence-badge {
   display: inline-flex;
   align-items: center;
   gap: 5px;
   padding: 3px 10px;
   border-radius: var(--radius-full);
   font-size: 11px;
   font-weight: 600;
   background: var(--bg-tertiary);
   border: 1px solid var(--border-subtle)
}

.conf-dot {
   width: 6px;
   height: 6px;
   border-radius: 50%
}

.conf-high {
   background: var(--green)
}

.conf-med {
   background: var(--yellow)
}

.conf-low {
   background: var(--red)
}

.model-info {
   display: none
}

.thinking-toggle-btn {
   width: auto;
   padding: 0 12px;
   gap: 6px;
   font-size: 13px;
   font-weight: 500
}

.thinking-label {
   display: inline
}

.back-btn {
   display: flex;
   align-items: center;
   gap: 6px;
   padding: 8px 14px;
   border-radius: var(--radius-sm);
   font-size: 13px;
   font-weight: 500;
   color: var(--text-secondary);
   transition: all var(--transition-fast)
}

.back-btn:hover {
   background: var(--bg-hover);
   color: var(--text-primary)
}

.back-btn i {
   width: 16px;
   height: 16px
}

.dash-refresh-info {
   font-size: 11px;
   color: var(--text-muted);
   padding: 4px 10px;
   background: var(--bg-tertiary);
   border-radius: var(--radius-full)
}

/* ========================
   CHAT CONTAINER
   ======================== */
.chat-container {
   display: flex;
   flex: 1;
   overflow: hidden
}

.chat-messages-wrapper {
   flex: 1;
   display: flex;
   flex-direction: column;
   min-width: 0
}

.chat-messages {
   flex: 1;
   overflow-y: auto;
   padding: 20px;
   display: flex;
   flex-direction: column;
   gap: 16px;
   scroll-behavior: smooth
}

/* Welcome Screen */
.welcome-screen {
   display: flex;
   flex-direction: column;
   align-items: center;
   justify-content: center;
   flex: 1;
   gap: 16px;
   text-align: center;
   padding: 40px;
   animation: fadeIn 0.5s var(--ease)
}

.welcome-icon {
   font-size: 64px;
   line-height: 1;
   margin-bottom: 8px;
   animation: float 3s ease-in-out infinite
}

.welcome-screen h2 {
   font-size: 28px;
   font-weight: 800;
   background: var(--accent-gradient);
   -webkit-background-clip: text;
   -webkit-text-fill-color: transparent;
   background-clip: text
}

.welcome-screen p {
   color: var(--text-secondary);
   font-size: 15px;
   max-width: 420px
}

.welcome-suggestions {
   display: flex;
   flex-wrap: wrap;
   justify-content: center;
   gap: 8px;
   margin-top: 12px
}

.suggestion-chip {
   display: flex;
   align-items: center;
   gap: 6px;
   padding: 10px 16px;
   border-radius: var(--radius-full);
   background: var(--bg-tertiary);
   border: 1px solid var(--border-color);
   font-size: 13px;
   color: var(--text-secondary);
   transition: all var(--transition-fast)
}

.suggestion-chip:hover {
   background: var(--bg-hover);
   border-color: var(--accent-primary);
   color: var(--text-primary);
   transform: translateY(-2px);
   box-shadow: var(--shadow-glow)
}

.suggestion-chip i {
   width: 16px;
   height: 16px
}

@keyframes float {

   0%,
   100% {
      transform: translateY(0)
   }

   50% {
      transform: translateY(-10px)
   }
}

@keyframes fadeIn {
   from {
      opacity: 0;
      transform: translateY(10px)
   }

   to {
      opacity: 1;
      transform: translateY(0)
   }
}

/* Messages */
.message {
   display: flex;
   gap: 12px;
   max-width: 800px;
   animation: fadeIn 0.3s var(--ease)
}

.message.user {
   align-self: flex-end;
   flex-direction: row-reverse
}

.message.ai {
   align-self: flex-start
}

.message-avatar {
   width: 32px;
   height: 32px;
   border-radius: var(--radius-sm);
   display: flex;
   align-items: center;
   justify-content: center;
   flex-shrink: 0;
   font-size: 16px
}

.message.user .message-avatar {
   background: var(--accent-gradient)
}

.message.ai .message-avatar {
   background: var(--bg-tertiary);
   border: 1px solid var(--border-color)
}

.message-body {
   max-width: 680px;
   display: flex;
   flex-direction: column;
   gap: 4px
}

.message-bubble {
   padding: 12px 16px;
   border-radius: var(--radius-lg);
   font-size: 14px;
   line-height: 1.7
}

.message.user .message-bubble {
   background: var(--accent-secondary);
   color: #fff;
   border-bottom-right-radius: 4px
}

.message.ai .message-bubble {
   background: var(--bg-tertiary);
   border: 1px solid var(--border-color);
   border-bottom-left-radius: 4px
}

.message-meta {
   display: flex;
   align-items: center;
   gap: 8px;
   font-size: 11px;
   color: var(--text-muted);
   padding: 0 4px
}

.message.user .message-meta {
   justify-content: flex-end
}

/* Markdown in messages */
.message-bubble h1,
.message-bubble h2,
.message-bubble h3,
.message-bubble h4 {
   margin: 12px 0 6px;
   font-weight: 700
}

.message-bubble h1 {
   font-size: 20px
}

.message-bubble h2 {
   font-size: 17px
}

.message-bubble h3 {
   font-size: 15px
}

.message-bubble p {
   margin: 6px 0
}

.message-bubble ul,
.message-bubble ol {
   margin: 6px 0;
   padding-left: 20px
}

.message-bubble li {
   margin: 3px 0
}

.message-bubble a {
   color: var(--text-accent)
}

.message-bubble strong {
   font-weight: 600
}

.message-bubble em {
   font-style: italic;
   color: var(--text-secondary)
}

.message-bubble blockquote {
   border-left: 3px solid var(--accent-primary);
   padding-left: 12px;
   margin: 8px 0;
   color: var(--text-secondary)
}

/* Code Blocks */
.message-bubble code {
   font-family: 'JetBrains Mono', monospace;
   font-size: 13px;
   background: var(--bg-primary);
   padding: 2px 6px;
   border-radius: 4px
}

.message-bubble pre {
   margin: 10px 0;
   border-radius: var(--radius-md);
   overflow: hidden;
   border: 1px solid var(--border-color);
   position: relative
}

.message-bubble pre code {
   display: block;
   padding: 16px;
   background: var(--bg-primary);
   overflow-x: auto;
   font-size: 13px;
   line-height: 1.5
}

.code-header {
   display: flex;
   align-items: center;
   justify-content: space-between;
   padding: 6px 12px;
   background: rgba(255, 255, 255, 0.03);
   border-bottom: 1px solid var(--border-subtle);
   font-size: 12px;
   color: var(--text-muted)
}

.copy-btn {
   display: flex;
   align-items: center;
   gap: 4px;
   padding: 3px 8px;
   border-radius: 4px;
   font-size: 11px;
   color: var(--text-muted);
   transition: all var(--transition-fast)
}

.copy-btn:hover {
   background: var(--bg-hover);
   color: var(--text-primary)
}

/* Typing indicator */
.typing-indicator {
   display: flex;
   align-items: center;
   gap: 4px;
   padding: 8px 0
}

.typing-indicator span {
   width: 6px;
   height: 6px;
   border-radius: 50%;
   background: var(--text-muted);
   animation: typing 1.4s infinite
}

.typing-indicator span:nth-child(2) {
   animation-delay: 0.2s
}

.typing-indicator span:nth-child(3) {
   animation-delay: 0.4s
}

@keyframes typing {

   0%,
   60%,
   100% {
      transform: translateY(0);
      opacity: 0.4
   }

   30% {
      transform: translateY(-6px);
      opacity: 1
   }
}

/* ========================
   CHAT INPUT
   ======================== */
.chat-input-area {
   padding: 12px 20px 16px;
   border-top: 1px solid var(--border-subtle);
   background: var(--bg-secondary)
}

.input-wrapper {
   display: flex;
   align-items: flex-end;
   gap: 8px;
   background: var(--bg-input);
   border: 1px solid var(--border-color);
   border-radius: var(--radius-lg);
   padding: 6px 8px;
   transition: all var(--transition-fast)
}

.input-wrapper:focus-within {
   border-color: var(--accent-primary);
   box-shadow: 0 0 0 3px var(--accent-glow)
}

.chat-input {
   flex: 1;
   background: none;
   border: none;
   outline: none;
   resize: none;
   padding: 8px;
   font-size: 14px;
   line-height: 1.5;
   color: var(--text-primary);
   max-height: 200px;
   overflow-y: auto
}

.chat-input::placeholder {
   color: var(--text-muted)
}

.attach-btn {
   flex-shrink: 0;
   width: 32px;
   height: 32px;
   color: var(--text-muted)
}

.attach-btn:hover {
   color: var(--text-secondary)
}

.send-btn {
   width: 36px;
   height: 36px;
   border-radius: var(--radius-sm);
   display: flex;
   align-items: center;
   justify-content: center;
   background: var(--accent-primary);
   color: #fff;
   transition: all var(--transition-fast);
   flex-shrink: 0
}

.send-btn:hover:not(:disabled) {
   background: var(--accent-secondary);
   transform: scale(1.05)
}

.send-btn:disabled {
   opacity: 0.3;
   cursor: not-allowed
}

.send-btn i {
   width: 18px;
   height: 18px
}

.input-disclaimer {
   text-align: center;
   font-size: 11px;
   color: var(--text-muted);
   margin-top: 8px
}

/* ========================
   THINKING PANEL
   ======================== */
.thinking-panel {
   width: var(--thinking-width);
   border-left: 1px solid var(--border-color);
   background: var(--bg-secondary);
   display: flex;
   flex-direction: column;
   flex-shrink: 0;
   transition: all var(--transition-normal);
   overflow: hidden
}

.thinking-panel.collapsed {
   width: 0;
   border: none;
   overflow: hidden
}

.thinking-header {
   display: flex;
   align-items: center;
   justify-content: space-between;
   padding: 12px 16px;
   border-bottom: 1px solid var(--border-subtle);
   flex-shrink: 0
}

.thinking-header h3 {
   display: flex;
   align-items: center;
   gap: 8px;
   font-size: 14px;
   font-weight: 600;
   color: var(--text-accent)
}

.thinking-header h3 i {
   width: 18px;
   height: 18px
}

.thinking-content {
   flex: 1;
   overflow-y: auto;
   padding: 12px
}

.thinking-placeholder {
   display: flex;
   flex-direction: column;
   align-items: center;
   justify-content: center;
   padding: 40px 20px;
   text-align: center;
   color: var(--text-muted);
   gap: 12px
}

.thinking-placeholder i {
   width: 40px;
   height: 40px;
   opacity: 0.3
}

.thinking-placeholder p {
   font-size: 13px
}

/* Thinking Steps */
.thinking-steps {
   display: flex;
   flex-direction: column;
   gap: 8px
}

.think-section {
   border: 1px solid var(--border-subtle);
   border-radius: var(--radius-md);
   overflow: hidden;
   animation: fadeIn 0.3s var(--ease)
}

.think-section.active {
   border-color: var(--accent-primary);
   box-shadow: 0 0 12px var(--accent-glow);
   animation: sectionPulse 2s infinite
}

.think-section.done {
   border-color: rgba(34, 197, 94, 0.2)
}

.think-section.error {
   border-color: rgba(239, 68, 68, 0.2)
}

@keyframes sectionPulse {

   0%,
   100% {
      box-shadow: 0 0 12px var(--accent-glow)
   }

   50% {
      box-shadow: 0 0 24px var(--accent-glow)
   }
}

.think-section-header {
   display: flex;
   align-items: center;
   justify-content: space-between;
   padding: 10px 12px;
   cursor: pointer;
   transition: background var(--transition-fast);
   font-size: 13px;
   font-weight: 600
}

.think-section-header:hover {
   background: var(--bg-hover)
}

.think-section-title {
   display: flex;
   align-items: center;
   gap: 8px
}

.think-section-time {
   font-size: 10px;
   color: var(--text-muted);
   font-weight: 400
}

.think-section-chevron {
   transition: transform var(--transition-fast);
   color: var(--text-muted)
}

.think-section-chevron i {
   width: 14px;
   height: 14px
}

.think-section.expanded .think-section-chevron {
   transform: rotate(180deg)
}

.think-section-body {
   padding: 0 12px;
   max-height: 0;
   overflow: hidden;
   transition: all var(--transition-normal)
}

.think-section.expanded .think-section-body {
   max-height: 500px;
   padding: 8px 12px 12px
}

.think-section-body p {
   font-size: 12px;
   color: var(--text-secondary);
   line-height: 1.6;
   margin: 4px 0
}

.think-section-body .think-item {
   display: flex;
   align-items: flex-start;
   gap: 6px;
   font-size: 12px;
   color: var(--text-secondary);
   margin: 4px 0;
   line-height: 1.5
}

.think-item-icon {
   font-size: 14px;
   flex-shrink: 0;
   line-height: 1.4
}

/* Plan steps */
.plan-step {
   display: flex;
   align-items: center;
   gap: 8px;
   padding: 4px 0;
   font-size: 12px;
   color: var(--text-secondary);
   transition: all var(--transition-fast)
}

.plan-step.completed {
   color: var(--green)
}

.plan-step.in-progress {
   color: var(--yellow)
}

.plan-step-icon {
   font-size: 14px;
   flex-shrink: 0
}

/* Execution steps */
.exec-step {
   display: flex;
   align-items: center;
   gap: 8px;
   padding: 5px 0;
   font-size: 12px;
   color: var(--text-secondary)
}

.exec-step.done {
   color: var(--green)
}

.exec-step.working {
   color: var(--yellow)
}

.exec-step .exec-time {
   font-size: 10px;
   color: var(--text-muted);
   margin-left: auto
}

.exec-spinner {
   width: 14px;
   height: 14px;
   border: 2px solid var(--border-color);
   border-top-color: var(--yellow);
   border-radius: 50%;
   animation: spin 0.8s linear infinite;
   flex-shrink: 0
}

@keyframes spin {
   to {
      transform: rotate(360deg)
   }
}

/* Raw Thinking Section */
.raw-thinking-section {
   border-color: rgba(147, 51, 234, 0.3);
   background: linear-gradient(135deg, rgba(124, 58, 237, 0.05), rgba(147, 51, 234, 0.02))
}

.raw-thinking-section .think-section-header {
   background: rgba(124, 58, 237, 0.06)
}

.raw-thinking-content {
   font-family: 'JetBrains Mono', monospace;
   font-size: 11.5px;
   font-style: italic;
   color: var(--text-secondary);
   line-height: 1.8;
   white-space: pre-wrap;
   word-break: break-word;
   padding: 8px 10px;
   background: rgba(124, 58, 237, 0.04);
   border-radius: var(--radius-sm);
   border-left: 3px solid var(--accent-primary);
   position: relative
}

.raw-thinking-content.typing-active::after {
   content: '|';
   animation: blink 0.8s step-end infinite;
   color: var(--accent-primary);
   font-weight: bold
}

@keyframes blink {
   50% {
      opacity: 0
   }
}

.think-section.expanded .raw-thinking-content {
   max-height: 400px;
   overflow-y: auto
}

/* ========================
   EVOLUTION DISPLAY
   ======================== */
.evolution-display {
   display: flex;
   flex-direction: column;
   gap: 12px
}

.evolution-banner {
   display: flex;
   align-items: center;
   gap: 8px;
   padding: 12px;
   background: linear-gradient(135deg, rgba(124, 58, 237, 0.15), rgba(34, 197, 94, 0.1));
   border: 1px solid rgba(124, 58, 237, 0.3);
   border-radius: var(--radius-md);
   font-size: 14px;
   font-weight: 700;
   color: var(--text-accent);
   animation: sectionPulse 3s infinite
}

.evolution-icon {
   font-size: 20px
}

.evolution-current {
   display: flex;
   flex-direction: column;
   gap: 6px;
   padding: 10px;
   background: var(--bg-tertiary);
   border-radius: var(--radius-sm)
}

.evo-stat {
   display: flex;
   align-items: center;
   gap: 8px;
   font-size: 13px;
   color: var(--text-secondary)
}

.evo-stat i {
   width: 16px;
   height: 16px;
   color: var(--text-muted)
}

.evolution-log-section,
.evolution-progress-section {
   padding-top: 8px
}

.evolution-log-section h4,
.evolution-progress-section h4 {
   font-size: 13px;
   font-weight: 600;
   margin-bottom: 8px;
   color: var(--text-primary)
}

.evolution-log-entries {
   display: flex;
   flex-direction: column;
   gap: 4px;
   max-height: 200px;
   overflow-y: auto
}

.evo-log-entry {
   font-size: 11px;
   color: var(--text-secondary);
   padding: 3px 0;
   border-bottom: 1px solid var(--border-subtle);
   display: flex;
   gap: 8px
}

.evo-log-entry .evo-log-time {
   color: var(--text-muted);
   flex-shrink: 0;
   font-family: 'JetBrains Mono', monospace
}

.evo-log-entry .evo-log-text {
   flex: 1
}

.evolution-today-stats {
   display: grid;
   grid-template-columns: 1fr 1fr;
   gap: 6px
}

.evo-mini-stat {
   display: flex;
   justify-content: space-between;
   padding: 6px 10px;
   background: var(--bg-primary);
   border-radius: var(--radius-sm);
   font-size: 12px;
   color: var(--text-secondary)
}

.evo-mini-stat strong {
   color: var(--text-primary)
}

/* ========================
   DASHBOARD
   ======================== */
.dashboard-content {
   flex: 1;
   overflow-y: auto;
   padding: 20px;
   display: flex;
   flex-direction: column;
   gap: 20px
}

.dash-row {
   display: flex;
   gap: 16px;
   flex-wrap: wrap
}

.dash-cards-row {
   display: grid;
   grid-template-columns: repeat(4, 1fr);
   gap: 16px
}

.dash-card {
   background: var(--bg-card);
   border: 1px solid var(--border-color);
   border-radius: var(--radius-lg);
   padding: 20px;
   transition: all var(--transition-fast)
}

.dash-card:hover {
   border-color: rgba(124, 58, 237, 0.2);
   box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3)
}

.dash-card h4 {
   font-size: 14px;
   font-weight: 600;
   margin-bottom: 12px;
   display: flex;
   align-items: center;
   gap: 6px
}

/* Stat Cards */
.stat-card {
   display: flex;
   align-items: flex-start;
   gap: 16px
}

.stat-icon {
   font-size: 32px;
   flex-shrink: 0
}

.stat-info {
   flex: 1;
   display: flex;
   flex-direction: column;
   gap: 4px
}

.stat-info h4 {
   font-size: 13px;
   color: var(--text-muted);
   font-weight: 500;
   margin-bottom: 2px
}

.stat-value {
   font-size: 20px;
   font-weight: 700;
   color: var(--text-primary)
}

.stat-sub {
   font-size: 12px;
   color: var(--text-muted)
}

.trend-up {
   color: var(--green) !important
}

.trend-down {
   color: var(--red) !important
}

/* Circular Progress */
.circular-progress {
   position: relative;
   width: 64px;
   height: 64px;
   margin: 4px 0
}

.circular-progress svg {
   width: 100%;
   height: 100%;
   transform: rotate(-90deg)
}

.circular-progress .bg {
   fill: none;
   stroke: var(--bg-primary);
   stroke-width: 6
}

.circular-progress .fg {
   fill: none;
   stroke: var(--accent-primary);
   stroke-width: 6;
   stroke-linecap: round;
   stroke-dasharray: 220;
   stroke-dashoffset: 220;
   transition: stroke-dashoffset 1s var(--ease)
}

.progress-text {
   position: absolute;
   inset: 0;
   display: flex;
   align-items: center;
   justify-content: center;
   font-size: 15px;
   font-weight: 700;
   color: var(--text-primary)
}

/* Charts */
.dash-charts-row {
   display: grid;
   grid-template-columns: 1.2fr 0.8fr;
   gap: 16px
}

.chart-card {
   min-height: 300px
}

.chart-wrapper {
   position: relative;
   height: 250px
}

/* Tables */
.table-wrapper {
   overflow-x: auto
}

.dash-table {
   width: 100%;
   border-collapse: collapse;
   font-size: 13px
}

.dash-table thead {
   border-bottom: 2px solid var(--border-color)
}

.dash-table th {
   text-align: left;
   padding: 10px 12px;
   font-weight: 600;
   color: var(--text-muted);
   font-size: 11px;
   text-transform: uppercase;
   letter-spacing: 0.5px
}

.dash-table td {
   padding: 10px 12px;
   border-bottom: 1px solid var(--border-subtle)
}

.dash-table tr:hover td {
   background: var(--bg-hover)
}

.dash-table .highlight-row {
   background: var(--accent-glow);
   border-left: 3px solid var(--accent-primary)
}

.rank-badge {
   display: inline-flex;
   align-items: center;
   justify-content: center;
   width: 24px;
   height: 24px;
   border-radius: 50%;
   font-size: 11px;
   font-weight: 700
}

.rank-1 {
   background: linear-gradient(135deg, #fbbf24, #f59e0b);
   color: #000
}

.rank-2 {
   background: linear-gradient(135deg, #94a3b8, #64748b);
   color: #fff
}

.rank-3 {
   background: linear-gradient(135deg, #cd7f32, #a0522d);
   color: #fff
}

/* Detail Cards */
.detail-card {
   flex: 1;
   min-width: 300px
}

.detail-card.full-width {
   width: 100%;
   flex-basis: 100%
}

/* Activity Log */
.activity-log {
   max-height: 300px;
   overflow-y: auto;
   display: flex;
   flex-direction: column;
   gap: 4px
}

.activity-entry {
   display: flex;
   align-items: flex-start;
   gap: 10px;
   padding: 8px;
   border-radius: var(--radius-sm);
   font-size: 12px;
   transition: background var(--transition-fast)
}

.activity-entry:hover {
   background: var(--bg-hover)
}

.activity-time {
   color: var(--text-muted);
   font-family: 'JetBrains Mono', monospace;
   flex-shrink: 0;
   font-size: 11px;
   padding-top: 1px
}

.activity-text {
   flex: 1;
   color: var(--text-secondary)
}

.activity-result {
   padding: 2px 8px;
   border-radius: var(--radius-full);
   font-size: 10px;
   font-weight: 600;
   flex-shrink: 0
}

.activity-result.success {
   background: var(--green-glow);
   color: var(--green)
}

.activity-result.fail {
   background: var(--red-glow);
   color: var(--red)
}

.activity-result.info {
   background: var(--blue-glow);
   color: var(--blue)
}

/* DNA Section */
.dna-section {
   display: flex;
   flex-direction: column;
   gap: 10px
}

.dna-stat {
   display: flex;
   justify-content: space-between;
   padding: 6px 0;
   font-size: 13px;
   color: var(--text-secondary);
   border-bottom: 1px solid var(--border-subtle)
}

.dna-stat strong {
   color: var(--text-primary)
}

.dna-history {
   max-height: 200px;
   overflow-y: auto;
   display: flex;
   flex-direction: column;
   gap: 4px
}

.dna-entry {
   display: flex;
   justify-content: space-between;
   padding: 6px 8px;
   border-radius: var(--radius-sm);
   font-size: 12px;
   color: var(--text-secondary);
   background: var(--bg-primary)
}

.dna-entry .gen-num {
   font-weight: 600;
   color: var(--text-accent)
}

/* Predictions */
.predictions-list {
   display: flex;
   flex-direction: column;
   gap: 8px
}

.prediction-item {
   display: flex;
   align-items: center;
   gap: 10px;
   padding: 10px;
   border-radius: var(--radius-sm);
   background: var(--bg-primary);
   border: 1px solid var(--border-subtle);
   font-size: 13px
}

.prediction-icon {
   font-size: 18px;
   flex-shrink: 0
}

.prediction-text {
   flex: 1;
   color: var(--text-secondary)
}

.prediction-conf {
   font-size: 11px;
   font-weight: 600;
   padding: 2px 8px;
   border-radius: var(--radius-full)
}

.prediction-conf.high {
   background: var(--green-glow);
   color: var(--green)
}

.prediction-conf.med {
   background: var(--yellow-glow);
   color: var(--yellow)
}

.prediction-conf.low {
   background: var(--red-glow);
   color: var(--red)
}

/* Daily Report */
.daily-report {
   font-size: 13px;
   line-height: 1.7;
   color: var(--text-secondary)
}

.daily-report h3 {
   font-size: 15px;
   color: var(--text-primary);
   margin: 12px 0 6px
}

.daily-report p {
   margin: 6px 0
}

.daily-report ul {
   padding-left: 18px;
   margin: 6px 0
}

.daily-report li {
   margin: 3px 0
}

.report-placeholder {
   text-align: center;
   color: var(--text-muted);
   padding: 20px
}

/* ========================
   SETTINGS MODAL
   ======================== */
.modal {
   position: fixed;
   inset: 0;
   z-index: 200;
   display: flex;
   align-items: center;
   justify-content: center
}

.modal-overlay {
   position: absolute;
   inset: 0;
   background: rgba(0, 0, 0, 0.7);
   backdrop-filter: blur(4px)
}

.modal-content {
   position: relative;
   background: var(--bg-card);
   border: 1px solid var(--border-color);
   border-radius: var(--radius-xl);
   padding: 24px;
   width: 90%;
   max-width: 440px;
   box-shadow: var(--shadow-lg);
   animation: fadeIn 0.3s var(--ease)
}

.modal-header {
   display: flex;
   align-items: center;
   justify-content: space-between;
   margin-bottom: 20px
}

.modal-header h3 {
   font-size: 18px;
   font-weight: 700
}

.modal-body {
   display: flex;
   flex-direction: column;
   gap: 16px
}

.setting-group {
   display: flex;
   flex-direction: column;
   gap: 6px
}

.setting-group label {
   font-size: 13px;
   font-weight: 500;
   color: var(--text-secondary)
}

.setting-input {
   padding: 10px 12px;
   border-radius: var(--radius-sm);
   background: var(--bg-input);
   border: 1px solid var(--border-color);
   outline: none;
   color: var(--text-primary);
   font-size: 14px;
   transition: border-color var(--transition-fast)
}

.setting-input:focus {
   border-color: var(--accent-primary)
}

select.setting-input {
   cursor: pointer
}

.primary-btn {
   padding: 12px;
   border-radius: var(--radius-md);
   background: var(--accent-gradient);
   color: #fff;
   font-weight: 600;
   font-size: 14px;
   transition: all var(--transition-fast);
   margin-top: 8px
}

.primary-btn:hover {
   transform: translateY(-1px);
   box-shadow: var(--shadow-glow)
}

/* Toggle Switch */
.toggle-switch {
   position: relative;
   display: inline-block;
   width: 44px;
   height: 24px
}

.toggle-switch input {
   opacity: 0;
   width: 0;
   height: 0
}

.toggle-slider {
   position: absolute;
   cursor: pointer;
   inset: 0;
   background: var(--bg-tertiary);
   border: 1px solid var(--border-color);
   border-radius: var(--radius-full);
   transition: all var(--transition-fast)
}

.toggle-slider::before {
   content: '';
   position: absolute;
   width: 18px;
   height: 18px;
   left: 3px;
   bottom: 2px;
   background: var(--text-muted);
   border-radius: 50%;
   transition: all var(--transition-fast)
}

input:checked+.toggle-slider {
   background: var(--accent-primary);
   border-color: var(--accent-primary)
}

input:checked+.toggle-slider::before {
   transform: translateX(19px);
   background: #fff
}

/* ========================
   WAKEUP OVERLAY
   ======================== */
.wakeup-overlay {
   position: fixed;
   inset: 0;
   z-index: 300;
   background: var(--bg-primary);
   display: flex;
   align-items: center;
   justify-content: center;
   flex-direction: column
}

.wakeup-content {
   text-align: center;
   display: flex;
   flex-direction: column;
   align-items: center;
   gap: 16px
}

.wakeup-content h2 {
   font-size: 22px;
   font-weight: 700
}

.wakeup-content p {
   color: var(--text-secondary);
   font-size: 14px
}

.wakeup-spinner {
   width: 48px;
   height: 48px;
   border: 3px solid var(--border-color);
   border-top-color: var(--accent-primary);
   border-radius: 50%;
   animation: spin 1s linear infinite
}

.wakeup-progress {
   width: 240px;
   height: 4px;
   background: var(--bg-tertiary);
   border-radius: 2px;
   overflow: hidden
}

.wakeup-progress-bar {
   height: 100%;
   width: 0;
   background: var(--accent-gradient);
   border-radius: 2px;
   animation: wakeProgress 8s ease-out forwards
}

@keyframes wakeProgress {
   0% {
      width: 0
   }

   50% {
      width: 60%
   }

   80% {
      width: 85%
   }

   100% {
      width: 95%
   }
}

/* Wakeup Service Status */
.wakeup-status {
   display: flex;
   flex-direction: column;
   gap: 8px;
   margin-top: 8px;
   padding: 12px 20px;
   background: var(--bg-tertiary);
   border-radius: var(--radius-md)
}

.wakeup-service {
   display: flex;
   align-items: center;
   gap: 8px;
   font-size: 13px;
   color: var(--text-secondary)
}

/* System Health Card */
.system-health-grid {
   display: grid;
   grid-template-columns: repeat(3, 1fr);
   gap: 16px
}

.health-item {
   display: flex;
   gap: 12px;
   padding: 14px;
   background: var(--bg-primary);
   border: 1px solid var(--border-subtle);
   border-radius: var(--radius-md);
   transition: all var(--transition-fast)
}

.health-item:hover {
   border-color: rgba(124, 58, 237, 0.2);
   box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2)
}

.health-icon {
   font-size: 28px;
   flex-shrink: 0
}

.health-info {
   display: flex;
   flex-direction: column;
   gap: 2px
}

.health-info h5 {
   font-size: 13px;
   font-weight: 600;
   color: var(--text-primary)
}

.health-model {
   font-size: 11px;
   color: var(--text-muted)
}

.health-status {
   display: flex;
   align-items: center;
   gap: 6px;
   font-size: 12px;
   color: var(--text-secondary)
}

.health-sub {
   font-size: 11px;
   color: var(--text-muted)
}

/* ========================
   RESPONSIVE
   ======================== */
@media(min-width:1024px) {
   .model-info {
      display: inline
   }
}

@media(max-width:1200px) {
   .thinking-panel {
      width: 320px
   }

   .dash-charts-row {
      grid-template-columns: 1fr
   }

   .system-health-grid {
      grid-template-columns: 1fr 1fr
   }
}

@media(max-width:900px) {
   .thinking-panel {
      position: absolute;
      right: 0;
      top: 0;
      bottom: 0;
      z-index: 50;
      width: 340px;
      box-shadow: var(--shadow-lg)
   }

   .thinking-panel.collapsed {
      transform: translateX(100%)
   }

   .dash-cards-row {
      grid-template-columns: repeat(2, 1fr)
   }
}

@media(max-width:768px) {
   .sidebar {
      position: fixed;
      left: 0;
      top: 0;
      bottom: 0;
      transform: translateX(-100%);
      z-index: 100;
      width: 280px;
      box-shadow: var(--shadow-lg)
   }

   .sidebar.open {
      transform: translateX(0)
   }

   .sidebar-close-btn {
      display: flex
   }

   .dash-cards-row {
      grid-template-columns: 1fr 1fr
   }

   .dash-details-row {
      flex-direction: column
   }

   .detail-card {
      min-width: 0
   }

   .thinking-label {
      display: none
   }
}

@media(max-width:480px) {
   .dash-cards-row {
      grid-template-columns: 1fr
   }

   .welcome-suggestions {
      flex-direction: column;
      align-items: center
   }

   .topbar-meta {
      display: none
   }
}

/* =============================================
   AI Study Status Card
   ============================================= */
.ai-study-card {
   border: 1px solid rgba(124, 58, 237, 0.2);
   background: linear-gradient(135deg, rgba(124, 58, 237, 0.05), transparent);
}

.ai-study-grid {
   display: grid;
   grid-template-columns: 1fr 1fr;
   gap: 16px;
   margin-bottom: 16px;
}

.ai-study-item {
   padding: 10px 12px;
   background: var(--bg-secondary);
   border-radius: var(--radius-sm);
   border: 1px solid var(--border-color);
}

.ai-study-label {
   font-size: 12px;
   font-weight: 600;
   color: var(--text-secondary);
   margin-bottom: 6px;
   text-transform: uppercase;
   letter-spacing: 0.5px;
}

.ai-study-value {
   color: var(--text-primary);
   font-size: 14px;
   margin: 0;
   line-height: 1.4;
}

.ai-learning-text {
   font-style: italic;
   color: var(--text-accent);
   font-size: 13px;
}

/* Budget bar */
.budget-bar-wrapper {
   display: flex;
   align-items: center;
   gap: 10px;
}

.budget-bar {
   flex: 1;
   height: 8px;
   background: var(--bg-primary);
   border-radius: 4px;
   overflow: hidden;
}

.budget-fill {
   height: 100%;
   background: linear-gradient(90deg, #7c3aed, #a78bfa);
   border-radius: 4px;
   transition: width 0.5s ease;
}

.budget-fill.budget-warning {
   background: linear-gradient(90deg, #ef4444, #f97316);
}

.budget-text {
   font-size: 12px;
   color: var(--text-secondary);
   white-space: nowrap;
}

/* Study log */
.ai-study-log-section h5 {
   font-size: 13px;
   color: var(--text-secondary);
   margin-bottom: 8px;
   font-weight: 600;
}

.ai-study-log {
   max-height: 140px;
   overflow-y: auto;
}

.study-entry {
   display: flex;
   align-items: center;
   gap: 8px;
   padding: 6px 10px;
   border-bottom: 1px solid var(--border-color);
   font-size: 13px;
}

.study-entry.study-empty {
   color: var(--text-muted);
   font-style: italic;
}

.study-mode {
   font-size: 16px;
}

.study-info {
   flex: 1;
   color: var(--text-secondary);
}

.study-time {
   color: var(--text-muted);
   font-size: 12px;
}

@media(max-width:768px) {
   .ai-study-grid {
      grid-template-columns: 1fr;
   }
}