:root {
  /* Color Palette — Dark Mode */
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-tertiary: #1a1a2e;
  --bg-card: #16161f;
  --bg-hover: #1e1e30;
  --bg-input: #1a1a28;
  --bg-glass: rgba(22, 22, 31, 0.85);

  --accent: #6c5ce7;
  --accent-light: #a29bfe;
  --accent-glow: rgba(108, 92, 231, 0.3);
  --accent-gradient: linear-gradient(135deg, #6c5ce7, #a29bfe);

  --success: #00b894;
  --warning: #fdcb6e;
  --danger: #ff6b6b;
  --info: #74b9ff;

  --text-primary: #e8e8f0;
  --text-secondary: #8888a0;
  --text-muted: #555568;

  --border: #2a2a3e;
  --border-light: #333348;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px var(--accent-glow);

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html,
body {
  height: 100%;
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Scrollbar ──────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

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

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

/* ── Auth Page ──────────────────────────────────── */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-primary);
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 48px 40px;
  width: 420px;
  box-shadow: var(--shadow-lg);
}

.auth-card .logo {
  text-align: center;
  margin-bottom: 32px;
}

.auth-card .logo h1 {
  font-size: 28px;
  font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
}

.auth-card .logo p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-top: 4px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 15px;
  font-family: var(--font-sans);
  transition: border var(--transition);
  outline: none;
}

.form-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: var(--accent-gradient);
  color: white;
  width: 100%;
}

.btn-primary:hover {
  box-shadow: var(--shadow-glow);
  transform: translateY(-1px);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-light);
}

.btn-danger {
  background: rgba(255, 107, 107, 0.15);
  color: var(--danger);
  border: 1px solid rgba(255, 107, 107, 0.3);
}

.btn-danger:hover {
  background: rgba(255, 107, 107, 0.25);
}

.btn-success {
  background: rgba(0, 184, 148, 0.15);
  color: var(--success);
  border: 1px solid rgba(0, 184, 148, 0.3);
}

.btn-success:hover {
  background: rgba(0, 184, 148, 0.25);
}

.auth-switch {
  text-align: center;
  margin-top: 20px;
  font-size: 13px;
  color: var(--text-secondary);
}

.auth-switch a {
  color: var(--accent-light);
  cursor: pointer;
  text-decoration: none;
}

.auth-switch a:hover {
  text-decoration: underline;
}

/* ── Layout ─────────────────────────────────────── */
.app-layout {
  display: flex;
  height: 100vh;
}

/* ── Sidebar ────────────────────────────────────── */
.sidebar {
  width: 280px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

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

.sidebar-header h2 {
  font-size: 18px;
  font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  flex: 1;
}

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

.btn-dashboard-header {
  height: 32px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  background: rgba(147, 51, 234, 0.15);
  color: var(--accent);
  border: 1px solid rgba(147, 51, 234, 0.3);
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-dashboard-header:hover {
  background: rgba(147, 51, 234, 0.25);
  box-shadow: 0 0 8px rgba(147, 51, 234, 0.4);
}

.sidebar-header .btn-new {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: var(--radius-sm);
  font-size: 18px;
  background: var(--accent);
  color: white;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
}

.sidebar-header .btn-new:hover {
  background: var(--accent-light);
  box-shadow: var(--shadow-glow);
}

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

.session-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: 2px;
}

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

.session-item.active {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
}

.session-item .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.session-item .status-dot.running {
  background: var(--success);
  box-shadow: 0 0 6px var(--success);
}

.session-item .status-dot.suspended {
  background: var(--text-muted);
}

.session-item .status-dot.starting {
  background: var(--warning);
  animation: pulse 1.5s infinite;
}

.session-item .status-dot.error {
  background: var(--danger);
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.4;
  }
}

.session-item .session-info {
  flex: 1;
  min-width: 0;
}

.session-item .session-name {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-item .session-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.session-item .session-more-btn {
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  opacity: 0;
  transition: all var(--transition);
  flex-shrink: 0;
}

.session-item:hover .session-more-btn {
  opacity: 1;
}

.session-item .session-more-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-footer .user-info {
  font-size: 13px;
  color: var(--text-secondary);
}

.sidebar-footer .btn-logout {
  font-size: 12px;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  transition: color var(--transition);
}

.sidebar-footer .btn-logout:hover {
  color: var(--danger);
}

/* ── Main Content ───────────────────────────────── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ── Toolbar ────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.toolbar .agent-info {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
}

.toolbar .agent-icon {
  font-size: 20px;
}

.toolbar .agent-name {
  font-size: 15px;
  font-weight: 600;
}

.toolbar .agent-status {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 500;
}

.agent-status.running {
  background: rgba(0, 184, 148, 0.15);
  color: var(--success);
}

.agent-status.suspended {
  background: rgba(85, 85, 104, 0.2);
  color: var(--text-muted);
}

.agent-status.starting {
  background: rgba(253, 203, 110, 0.15);
  color: var(--warning);
}

.agent-status.error {
  background: rgba(255, 107, 107, 0.15);
  color: var(--danger);
}

.toolbar .tool-buttons {
  display: flex;
  gap: 6px;
}

.toolbar .tool-btn {
  padding: 6px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 12px;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 4px;
}

.tool-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-light);
}

.tool-btn.suspend-highlight {
  border-color: var(--accent);
  background: var(--accent-glow);
  color: var(--accent-light);
  animation: glow-pulse 2s infinite;
}

@keyframes glow-pulse {

  0%,
  100% {
    box-shadow: 0 0 8px var(--accent-glow);
  }

  50% {
    box-shadow: 0 0 20px var(--accent-glow);
  }
}

/* ── Chat ───────────────────────────────────────── */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.message {
  max-width: 80%;
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  line-height: 1.7;
  animation: msg-in 0.3s ease;
}

@keyframes msg-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message.user {
  align-self: flex-end;
  background: var(--accent);
  color: white;
  border-bottom-right-radius: 4px;
  white-space: pre-wrap;
}

.message.assistant {
  align-self: flex-start;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.message.system {
  align-self: center;
  background: rgba(116, 185, 255, 0.1);
  border: 1px solid rgba(116, 185, 255, 0.2);
  color: var(--info);
  font-size: 12px;
  padding: 8px 16px;
  border-radius: 20px;
}

.message pre {
  background: var(--bg-primary);
  padding: 12px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  margin: 8px 0;
}

.message code {
  font-family: var(--font-mono);
  font-size: 13px;
  background: rgba(108, 92, 231, 0.15);
  padding: 2px 6px;
  border-radius: 4px;
}

.message pre code {
  background: none;
  padding: 0;
}

.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 14px 18px;
  align-self: flex-start;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: var(--text-muted);
  border-radius: 50%;
  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(-8px);
    opacity: 1;
  }
}

/* ── Chat Input ─────────────────────────────────── */
.chat-input-area {
  padding: 16px 24px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
}

.chat-input-wrapper {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  max-width: 900px;
  margin: 0 auto;
  position: relative;
}

.slash-command-menu {
  position: absolute;
  left: 60px;
  right: 60px;
  bottom: calc(100% + 10px);
  background: rgba(23, 23, 28, 0.98);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  z-index: 30;
}

.slash-command-header {
  padding: 12px 16px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.slash-command-list {
  max-height: 320px;
  overflow-y: auto;
}

.slash-command-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 16px;
  cursor: pointer;
  transition: background var(--transition);
}

.slash-command-item:hover,
.slash-command-item.active {
  background: rgba(255, 255, 255, 0.06);
}

.slash-command-icon {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(122, 92, 255, 0.18);
  border: 1px solid rgba(122, 92, 255, 0.35);
  color: #cfc3ff;
  font-size: 16px;
}

.slash-command-body {
  min-width: 0;
  flex: 1;
}

.slash-command-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 3px;
}

.slash-command-name {
  color: var(--text-primary);
  font-size: 20px;
  font-weight: 700;
  line-height: 1.1;
}

.slash-command-args {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
}

.slash-command-desc {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.4;
}

.slash-command-empty {
  padding: 16px;
  color: var(--text-muted);
  font-size: 13px;
}

.chat-input-wrapper textarea {
  flex: 1;
  padding: 14px 18px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-sans);
  resize: none;
  outline: none;
  min-height: 48px;
  max-height: 200px;
  line-height: 1.5;
  transition: border var(--transition);
}

.chat-input-wrapper textarea:focus {
  border-color: var(--accent);
}

.chat-input-wrapper textarea::placeholder {
  color: var(--text-muted);
}

.chat-input-wrapper .btn-send {
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: white;
  border: none;
  cursor: pointer;
  font-size: 18px;
  transition: all var(--transition);
  flex-shrink: 0;
}

.chat-input-wrapper .btn-send:hover {
  background: var(--accent-light);
  box-shadow: var(--shadow-glow);
}

.chat-input-wrapper .btn-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.chat-input-wrapper .btn-upload {
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: var(--radius-md);
  background: var(--bg-input);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 18px;
  transition: all var(--transition);
  flex-shrink: 0;
}

.chat-input-wrapper .btn-upload:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
}

.upload-progress {
  max-width: 900px;
  margin: 8px auto 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.upload-progress .progress-bar {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.upload-progress .progress-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.3s;
}

.upload-progress .upload-filename {
  font-size: 12px;
  color: var(--text-muted);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Empty State ────────────────────────────────── */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  gap: 12px;
}

.empty-state .icon {
  font-size: 48px;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 18px;
  color: var(--text-secondary);
}

.empty-state p {
  font-size: 13px;
}

/* ── Modal ──────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  /* 防止小屏幕时弹窗贴紧屏幕边缘 */
  z-index: 1000;
  backdrop-filter: blur(4px);
  animation: fade-in 0.2s ease;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 32px;
  width: 480px;
  max-width: 100%;
  /* 防止超宽 */
  max-height: calc(100vh - 48px);
  /* 适配 14寸小屏和低高度屏幕 */
  overflow-y: auto;
  /* 内容过多时在弹窗内自由滚动，不至于让按钮被裁切 */
  box-shadow: var(--shadow-lg);
  animation: modal-in 0.3s ease;
}

.modal-sm {
  width: 360px;
  padding: 24px;
}

.modal-sm h3 {
  margin-bottom: 16px;
}

.modal-sm .form-group {
  margin-bottom: 20px;
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 24px;
}

.modal .template-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}

.modal .template-card {
  padding: 16px;
  background: var(--bg-tertiary);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
}

.modal .template-card:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
}

.modal .template-card.selected {
  border-color: var(--accent);
  background: var(--accent-glow);
}

.modal .template-card .icon {
  font-size: 24px;
  margin-bottom: 8px;
}

.modal .template-card .name {
  font-size: 13px;
  font-weight: 600;
}

.modal .template-card .desc {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

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

/* ── Dropdown Menu ──────────────────────────────────────── */
.dropdown-menu {
  background: rgba(30, 30, 38, 0.85);
  /* Slightly translucent dark background */
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  /* More subtle border */
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  /* Softer, larger shadow + inner highlight */
  z-index: 1000;
  min-width: 140px;
  padding: 6px;
  animation: dropdown-in 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  transform-origin: top right;
}

@keyframes dropdown-in {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(-6px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: 8px;
  /* Slightly more rounded items inside */
  transition: all 0.2s ease;
}

.dropdown-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.dropdown-item svg {
  color: var(--text-muted);
  flex-shrink: 0;
}

.dropdown-item:hover svg {
  color: var(--text-primary);
}

/* ── Toast ──────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 13px;
  box-shadow: var(--shadow-md);
  animation: toast-in 0.3s ease;
  max-width: 400px;
}

.toast.success {
  border-left: 3px solid var(--success);
}

.toast.error {
  border-left: 3px solid var(--danger);
}

.toast.info {
  border-left: 3px solid var(--info);
}

.toast.warning {
  border-left: 3px solid var(--warning);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(20px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ── Files Panel ────────────────────────────────── */
.files-panel {
  width: 420px;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  animation: slide-in 0.3s ease;
}

@keyframes slide-in {
  from {
    transform: translateX(20px);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

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

.files-panel .panel-header h3 {
  font-size: 14px;
  font-weight: 600;
}

.files-panel .file-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  transition: background var(--transition);
}

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

.file-item .file-icon {
  font-size: 16px;
  flex-shrink: 0;
}

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

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

/* ── Terminal Panel ────────────────────────────── */
.terminal-panel {
  display: flex;
  flex-direction: column;
  height: 320px;
  min-height: 150px;
  max-height: 80vh;
  border-top: 2px solid var(--accent);
  background: #0a0a0f;
  flex-shrink: 0;
  animation: slide-up 0.25s ease;
}

.terminal-resize-bar {
  height: 6px;
  cursor: ns-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
}

.terminal-resize-bar::after {
  content: '';
  width: 40px;
  height: 3px;
  background: var(--border-light);
  border-radius: 2px;
  transition: background var(--transition);
}

.terminal-resize-bar:hover::after {
  background: var(--accent-light);
}

@keyframes slide-up {
  from {
    transform: translateY(20px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.terminal-header {
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.terminal-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-light);
}

.terminal-actions {
  display: flex;
  gap: 4px;
}

.terminal-container {
  flex: 1;
  padding: 4px;
  overflow: hidden;
}

/* ── File Preview ──────────────────────────────── */
.file-preview {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border);
  flex: 2;
  min-height: 0;
  animation: fade-in 0.2s ease;
}

.preview-header {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-tertiary);
  flex-shrink: 0;
}

.preview-filename {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-light);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.preview-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.preview-content {
  flex: 1;
  overflow: auto;
  padding: 16px;
  margin: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-primary);
  white-space: pre-wrap;
  word-break: break-word;
  tab-size: 4;
}

/* ── Admin Dashboard ──────────────────────────────────────── */

.admin-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 30px 40px;
  background: var(--bg-base);
  overflow-y: auto;
  gap: 24px;
}

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

.admin-header h2 {
  font-size: 24px;
  font-weight: 600;
  margin: 0;
  color: var(--text-primary);
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px;
}

.admin-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}

.admin-card.full-width {
  grid-column: 1 / -1;
}

.admin-card h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 500;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 12px;
}

.stats-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  color: var(--text-secondary);
}

.stat-row strong {
  color: var(--text-primary);
  font-weight: 600;
  font-family: var(--font-mono);
}

.btn-dashboard {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(147, 51, 234, 0.15);
  color: var(--accent);
  border: 1px solid rgba(147, 51, 234, 0.3);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-dashboard:hover {
  background: rgba(147, 51, 234, 0.25);
  box-shadow: 0 0 8px rgba(147, 51, 234, 0.4);
}

/* User Progress Table */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.admin-table th {
  text-align: left;
  padding: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  border-bottom: 1px solid var(--border);
}

.admin-table td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
}

.progress-container {
  width: 100%;
  height: 24px;
  background: var(--bg-layer);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  border: 1px solid var(--border-light);
}

.progress-used {
  height: 100%;
  background: var(--accent-gradient);
  transition: width 0.5s ease;
  opacity: 0.8;
}

.progress-text {
  position: absolute;
  width: 100%;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-mono);
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  pointer-events: none;
}

/* ── Mobile Adaptation ────────────────────────────────────────── */
.btn-menu {
  display: none;
}

.sidebar-overlay {
  display: none;
}

@media (max-width: 768px) {
  .app-layout {
    position: relative;
    overflow: hidden;
  }

  .sidebar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 1001;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: none;
    width: 280px;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.5);
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity 0.3s;
  }

  .sidebar-overlay.show {
    display: block;
    opacity: 1;
  }

  .btn-menu {
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    margin-right: 8px;
  }

  .toolbar {
    padding: 10px 12px;
    flex-wrap: wrap;
  }

  .toolbar .tool-buttons {
    margin-top: 8px;
    width: 100%;
    justify-content: space-between;
    overflow-x: auto;
  }

  .chat-messages {
    padding: 12px;
  }

  .chat-input-area {
    padding: 12px 12px 16px;
  }

  .message {
    max-width: 95%;
  }

  .modal,
  .auth-card {
    width: 90vw;
    margin: 0 auto;
    padding: 24px 20px;
  }

  .files-panel {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 999;
    width: 100%;
    max-width: 100vw;
  }

  .admin-area {
    padding: 16px;
  }

  .tool-btn {
    padding: 6px 8px;
    font-size: 11px;
    white-space: nowrap;
  }
}
