/* ============================================
   CC-Web — Full CoolVibe Style Replica
   Color: #f8fafc bg, #1e40af text, #3b82f6 accent
   Font: Chivo Mono (mono), system sans fallback
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Chivo+Mono:wght@400;500;600;700;800&display=swap');

:root {
  --font-mono: 'Chivo Mono', 'SF Mono', 'Fira Code', ui-monospace, monospace;
  --font-sans: 'Chivo Mono', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans CJK SC', sans-serif;

  --bg: #f0f2ff;
  --bg-card: #ffffff;
  --bg-muted: rgba(30, 58, 138, 0.05);
  --bg-accent: rgba(30, 58, 138, 0.10);
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --primary: #1e3a8a;
  --primary-fg: #ffffff;
  --border: rgba(30, 58, 138, 0.10);
  --border-strong: rgba(30, 58, 138, 0.20);
  --input-bg: rgba(30, 58, 138, 0.04);
  --ring: rgba(30, 58, 138, 0.50);
  --accent-light: #dbeafe;
  --success: #10b981;
  --danger: #ef4444;

  --shadow-sm: 0 1px 3px rgba(30, 58, 138, 0.05);
  --shadow-md: 0 4px 12px rgba(30, 58, 138, 0.08);
  --shadow-lg: 0 8px 30px rgba(30, 58, 138, 0.10);
  --shadow-brand: 0 4px 16px rgba(30, 58, 138, 0.20);
  --shadow-focus: 0 0 0 3px rgba(30, 58, 138, 0.12);

  --sidebar-width: 280px;
  --header-height: 52px;
  --input-max-height: 200px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --radius: 12px;

  /* Upstream variable aliases — app.js inline styles use these names */
  --accent: #1e3a8a;
  --accent-hover: #1e40af;
  --border-color: rgba(30, 58, 138, 0.10);
  --bg-primary: #f0f2ff;
  --bg-secondary: rgba(30, 58, 138, 0.05);
  --bg-tertiary: rgba(30, 58, 138, 0.10);
  --text-primary: #0f172a;
  --scrollbar-thumb: #3b82f64d;
}

/* === Reset === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; height: -webkit-fill-available; }

body {
  height: 100%; height: 100dvh;
  min-height: -webkit-fill-available;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { display: none; }
* { scrollbar-width: none; }

/* ============================================
   Data Stream Background
   ============================================ */
@keyframes data-stream {
  0%   { transform: translateY(-100%); }
  100% { transform: translateY(100vh); }
}
.scanlines {
  position: absolute; inset: 0;
  pointer-events: none; z-index: 0;
  background-image: repeating-linear-gradient(0deg, transparent, transparent 2px, #1e40af0f 2px, #1e40af0f 4px);
}
.data-stream-container {
  position: absolute; inset: 0;
  overflow: hidden; pointer-events: none; z-index: 0;
  opacity: 0.10;
}
@media (min-width: 640px) { .data-stream-container { opacity: 0.25; } }
.data-stream-chat { opacity: 0.03; }
@media (min-width: 640px) { .data-stream-chat { opacity: 0.05; } }
.scanlines-chat { z-index: 0; opacity: 0.3; }
.ds-col {
  position: absolute;
  font-family: var(--font-mono);
  color: #1e40af;
  font-size: 12px;
  white-space: nowrap;
  animation: data-stream linear infinite;
  will-change: transform;
}
.ds-col div { padding: 2px 0; line-height: 1.6; }

/* === Login === */
.login-overlay {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #eef1ff 0%, #e0e6ff 40%, #dce3ff 70%, #f0f2ff 100%);
  z-index: 1000;
}
.login-box {
  text-align: center;
  padding: 40px 32px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 1.5rem;
  width: 90%; max-width: 380px;
  box-shadow: var(--shadow-lg);
  position: relative; z-index: 1;
}
.login-logo {
  width: 72px; height: 72px;
  margin: 0 auto 20px;
  background: var(--primary);
  color: var(--primary-fg);
  border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 800;
  font-family: var(--font-mono);
  box-shadow: var(--shadow-brand);
  letter-spacing: -1px;
}
.login-box h2 {
  font-size: 22px; font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
  font-family: var(--font-mono);
}
.login-box p {
  color: var(--text-muted);
  margin-bottom: 28px;
  font-size: 13px;
  font-family: var(--font-mono);
}
.login-box input {
  width: 100%; padding: 11px 14px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text); font-size: 14px;
  font-family: var(--font-mono);
  outline: none; margin-bottom: 12px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.login-box input:focus { border-color: var(--primary); box-shadow: var(--shadow-focus); }
.login-box button {
  width: 100%; padding: 12px;
  background: var(--primary); color: var(--primary-fg);
  border: none; border-radius: var(--radius);
  font-size: 14px; font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: 0.05em; text-transform: uppercase;
  cursor: pointer;
  box-shadow: var(--shadow-brand);
  transition: all 0.15s ease;
}
.login-box button:hover { background: #1e40af; box-shadow: 0 6px 24px rgba(30,58,138,0.3); transform: translateY(-1px); }
.login-box button:active { transform: scale(0.97); }
.remember-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-muted);
  margin-bottom: 12px; cursor: pointer; user-select: none;
  font-family: var(--font-mono);
}
.remember-label input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
.login-error { color: var(--danger); margin-top: 12px; font-size: 13px; font-family: var(--font-mono); }

/* === App Layout === */
.app {
  display: flex; height: 100%; height: 100dvh;
  min-height: -webkit-fill-available;
  width: 100%; overflow: hidden;
}

/* === Sidebar === */
.sidebar {
  width: var(--sidebar-width); min-width: var(--sidebar-width);
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  transition: transform 0.3s ease; overflow: hidden;
}
.sidebar-header {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.new-chat-btn {
  width: 100%; padding: 10px;
  background: var(--primary); border: none;
  border-radius: var(--radius);
  color: var(--primary-fg);
  font-size: 13px; font-weight: 600;
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
  cursor: pointer; box-shadow: var(--shadow-brand);
  transition: all 0.15s ease;
}
.new-chat-btn:hover { background: #1e40af; transform: translateY(-1px); }
.new-chat-btn:active { transform: scale(0.97); }
.session-list {
  flex: 1; overflow-y: auto; padding: 8px;
  -webkit-overflow-scrolling: touch;
}
.session-item {
  display: flex; align-items: center; gap: 6px;
  padding: 9px 12px; border-radius: 10px;
  cursor: pointer; margin-bottom: 2px;
  transition: all 0.15s ease; position: relative;
  font-family: var(--font-mono);
  border: 1px solid transparent;
}
.session-item:hover { background: var(--bg-muted); border-color: var(--border); }
.session-item.active {
  background: var(--bg-accent);
  border-color: var(--border-strong);
  border-left: 3px solid var(--primary);
}
.session-item-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}
.session-item-title {
  display: block;
  flex: 1; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; font-size: 13px; color: var(--text);
  min-width: 0;
}
.session-item.active .session-item-title { color: var(--text-secondary); font-weight: 600; }
.session-item-status {
  flex-shrink: 0;
  font-size: 10px;
  color: var(--primary);
  background: var(--bg-accent);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 1px 6px;
}
.session-item-time { font-size: 10px; color: var(--text-muted); margin-left: 8px; flex-shrink: 0; }
.session-item-actions { display: none; gap: 2px; margin-left: 4px; flex-shrink: 0; position: relative; z-index: 1; }
.session-item:hover .session-item-actions { display: flex; }
.session-item-btn {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; padding: 2px 5px; font-size: 13px;
  border-radius: 4px; line-height: 1; transition: all 0.15s;
}
.session-item-btn:hover { color: var(--text); background: var(--bg-muted); }
.session-item-btn.delete:hover { color: var(--danger); background: #fef2f2; }
.session-item-edit-input {
  flex: 1; padding: 2px 6px;
  border: 1px solid var(--primary); border-radius: 4px;
  background: var(--bg-card); color: var(--text);
  font-size: 13px; font-family: var(--font-mono);
  outline: none; min-width: 0;
}
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
  text-align: center; flex-shrink: 0;
}
.brand { font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); letter-spacing: 0.1em; text-transform: uppercase; }

/* === Chat Main === */
.chat-main {
  flex: 1; display: flex; flex-direction: column;
  min-width: 0; position: relative; background: var(--bg);
}
.chat-header {
  height: var(--header-height); min-height: var(--header-height);
  display: flex; align-items: center; padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(240,242,255,0.88);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  gap: 10px; flex-shrink: 0;
  position: relative; z-index: 10;
}
.menu-btn {
  display: none; background: none; border: none;
  color: var(--text-secondary); font-size: 20px;
  cursor: pointer; padding: 4px 8px; border-radius: 6px;
}
.menu-btn:hover { background: var(--bg-muted); }
.chat-title {
  flex: 1; min-width: 0; font-weight: 600; font-size: 14px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text); font-family: var(--font-mono);
  cursor: pointer; padding: 2px 6px; border-radius: 6px;
  transition: background 0.15s;
}
.chat-title:hover { background: var(--bg-muted); }
.cost-display {
  font-size: 11px; color: var(--primary);
  flex-shrink: 0; background: var(--bg-accent);
  padding: 3px 10px; border-radius: 6px;
  font-family: var(--font-mono); font-weight: 600;
  border: 1px solid var(--border);
}
.cost-display:empty { display: none; }

/* Mode selector */
.mode-select {
  -webkit-appearance: none; appearance: none;
  background: var(--bg-card); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 4px 24px 4px 10px;
  font-size: 11px; font-weight: 600;
  font-family: var(--font-mono); letter-spacing: 0.02em;
  cursor: pointer; flex-shrink: 0; outline: none;
  transition: all 0.15s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%231e3a8a'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center;
}
.mode-select:focus { border-color: var(--primary); box-shadow: var(--shadow-focus); }
.mode-select option { background: var(--bg-card); color: var(--text); }

/* === Messages === */
.messages-wrap {
  flex: 1; position: relative; overflow: hidden;
  min-height: 0; z-index: 1;
}
.messages {
  height: 100%; overflow-y: scroll; overflow-x: hidden;
  padding: 20px 16px; padding-right: 20px;
  display: flex; flex-direction: column; gap: 16px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain; scrollbar-width: none;
}
.messages::-webkit-scrollbar { display: none; }

/* Scrollbar */
.custom-scrollbar {
  position: absolute; right: 2px; top: 0; bottom: 0;
  width: 6px; pointer-events: none; opacity: 0;
  transition: opacity 0.2s;
}
.messages-wrap:hover .custom-scrollbar,
.custom-scrollbar.active { opacity: 1; }
@media (pointer: coarse) {
  .messages-wrap:hover .custom-scrollbar { opacity: 0; }
  .custom-scrollbar.scrolling { opacity: 1; }
}
.custom-scrollbar-thumb {
  position: absolute; right: 0; width: 6px; min-height: 30px;
  border-radius: 4px; background: #3b82f64d;
  cursor: grab; pointer-events: all;
  transition: width 0.15s, background 0.15s;
}
.custom-scrollbar-thumb:hover,
.custom-scrollbar-thumb.dragging { width: 10px; background: #3b82f680; }
.custom-scrollbar-thumb.dragging { cursor: grabbing; }
@media (pointer: coarse) {
  .custom-scrollbar { width: 18px; right: 0; opacity: 0; }
  .custom-scrollbar.active { opacity: 1; }
  .custom-scrollbar-thumb { width: 8px; right: 5px; min-height: 40px; }
  .custom-scrollbar-thumb:hover,
  .custom-scrollbar-thumb.dragging { width: 14px; right: 2px; }
}

/* Welcome */
.welcome-msg { text-align: center; margin: auto; padding: 40px 20px; }
.welcome-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.3; filter: grayscale(0.5); }
.welcome-msg h3 {
  font-size: 18px; color: var(--text-secondary);
  margin-bottom: 6px; font-weight: 700;
  font-family: var(--font-mono);
}
.welcome-msg p {
  font-size: 13px; color: var(--text-muted);
  font-family: var(--font-mono);
}

/* === Message Bubbles === */
.msg {
  display: flex; gap: 10px;
  max-width: 85%; min-width: 0;
  animation: fadeIn 0.25s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg.assistant { align-self: flex-start; }

.msg-avatar {
  width: 30px; height: 30px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800;
  flex-shrink: 0;
  font-family: var(--font-mono);
  letter-spacing: -0.5px;
  transition: transform 0.15s;
}
.msg-avatar:hover { transform: scale(1.08); }
.msg.user .msg-avatar {
  background: var(--primary); color: var(--primary-fg);
  box-shadow: 0 2px 8px rgba(30, 58, 138, 0.25);
}
.msg.assistant .msg-avatar {
  background: var(--success); color: #fff;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25);
}
.msg-avatar svg { display: block; flex-shrink: 0; }
.msg.assistant.agent-claude .msg-avatar {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
  font-size: 18px;
}
.msg.assistant.agent-codex .msg-avatar {
  background: #10a37f;
  color: #fff;
}

.msg-bubble {
  padding: 12px 16px;
  border-radius: var(--radius);
  line-height: 1.65;
  word-break: break-word;
  min-width: 0; max-width: 100%;
  font-size: 14px;
}
.msg.user .msg-bubble {
  background: var(--primary);
  color: var(--primary-fg);
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 10px rgba(30,58,138,0.20);
}
.msg.assistant .msg-bubble {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* System messages */
.msg.system { align-self: center; max-width: 90%; }
.msg.system .msg-bubble {
  background: var(--bg-muted);
  border: 1px dashed var(--border);
  border-radius: 10px;
  color: var(--text-secondary);
  font-size: 12px; padding: 8px 16px;
  text-align: center; white-space: pre-line;
  font-family: var(--font-mono);
}

/* === Markdown === */
.msg-bubble p { margin: 0 0 8px 0; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble ul, .msg-bubble ol { margin: 4px 0 8px 20px; }
.msg-bubble li { margin-bottom: 2px; }
.msg-bubble h1, .msg-bubble h2, .msg-bubble h3, .msg-bubble h4 { margin: 12px 0 6px 0; font-family: var(--font-mono); }
.msg-bubble h1 { font-size: 1.3em; }
.msg-bubble h2 { font-size: 1.15em; }
.msg-bubble h3 { font-size: 1.05em; }
.msg-bubble a { color: var(--primary); text-decoration: none; }
.msg-bubble a:hover { text-decoration: underline; }
.msg-bubble blockquote {
  border-left: 3px solid var(--border-strong);
  padding-left: 12px; color: var(--text-secondary);
  margin: 8px 0;
}
.msg-bubble table { border-collapse: collapse; margin: 8px 0; font-size: 12px; width: 100%; overflow-x: auto; display: block; }
.msg-bubble th, .msg-bubble td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.msg-bubble th { background: var(--bg-muted); font-family: var(--font-mono); font-weight: 600; }

/* Inline code */
.msg-bubble code:not(pre code) {
  background: var(--bg-accent); padding: 2px 6px;
  border-radius: 5px; font-size: 0.88em;
  font-family: var(--font-mono); color: var(--text-secondary);
  border: 1px solid var(--border);
}
.msg.user .msg-bubble code:not(pre code) {
  background: rgba(255,255,255,0.18); color: #fff; border-color: rgba(255,255,255,0.2);
}

/* === Code Blocks === */
.code-block-wrapper {
  position: relative; margin: 8px 0;
  border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--border);
  max-width: 100%; box-shadow: var(--shadow-sm);
}
.code-block-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 12px;
  background: #0a0f1a; font-size: 11px; color: #60a5fa;
  font-family: var(--font-mono); font-weight: 500;
}
.code-block-actions { display: flex; gap: 4px; align-items: center; }
.code-copy-btn, .code-preview-btn {
  background: none; border: none; color: #60a5fa80;
  cursor: pointer; font-size: 11px; padding: 2px 8px;
  border-radius: 4px; transition: all 0.15s;
  font-family: var(--font-mono);
}
.code-copy-btn:hover, .code-preview-btn:hover { color: #60a5fa; background: #3b82f61a; }
.code-preview-btn { border: 1px solid #3b82f633; }
.code-block-wrapper pre {
  margin: 0; padding: 12px;
  overflow-x: auto; overflow-y: hidden;
  max-width: 100%; -webkit-overflow-scrolling: touch;
  background: #0a0f1a;
}
.code-block-wrapper pre code {
  font-family: var(--font-mono);
  font-size: 13px; line-height: 1.55; white-space: pre;
  color: #e8e8e8;
}
.code-preview-pane { display: none; background: #fff; border-top: 1px solid var(--border); }
.code-preview-iframe { width: 100%; min-height: 120px; max-height: 600px; border: none; display: block; }
.code-block-wrapper.preview-mode .code-preview-pane { display: block; }
.code-block-wrapper.preview-mode pre { display: none; }

/* === Tool Calls === */
.tool-call {
  margin: 8px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden; transition: all 0.15s;
}
.tool-call:hover { box-shadow: var(--shadow-sm); border-color: var(--border-strong); }
.tool-call summary {
  padding: 8px 12px; cursor: pointer;
  font-size: 12px; color: var(--text-secondary);
  background: var(--bg-card);
  display: flex; align-items: center; gap: 8px;
  user-select: none; list-style: none;
  font-family: var(--font-mono); font-weight: 500;
}
.tool-call summary::-webkit-details-marker { display: none; }
.tool-call summary::before {
  content: '\25B8'; font-size: 10px;
  transition: transform 0.2s; color: var(--primary);
}
.tool-call[open] summary::before { transform: rotate(90deg); }
.tool-call summary:hover { background: var(--bg-muted); }
.tool-call-icon { display: inline-block; width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.tool-call-icon.done { background: var(--success); box-shadow: 0 0 6px #10b98166; }
.tool-call-icon.running { background: #f59e0b; animation: pulse 1s infinite; box-shadow: 0 0 6px #f59e0b66; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.3} }
.tool-call-content {
  padding: 8px 12px; font-size: 11px;
  color: var(--text-secondary);
  background: var(--bg);
  max-height: 250px; overflow-y: auto;
  white-space: pre-wrap; word-break: break-all;
  font-family: var(--font-mono);
}

/* === AskUserQuestion === */
.ask-user-question { padding: 10px 12px; background: var(--bg); display: flex; flex-direction: column; gap: 10px; }
.ask-question-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-card); padding: 10px; box-shadow: var(--shadow-sm);
}
.ask-question-header {
  font-size: 11px; font-weight: 700; color: var(--primary);
  margin-bottom: 6px; font-family: var(--font-mono);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.ask-question-text { font-size: 13px; line-height: 1.5; color: var(--text); margin-bottom: 8px; }
.ask-options-layout { display: flex; flex-direction: column; gap: 6px; }
.ask-options-layout.has-preview {
  display: grid; grid-template-columns: 1fr 1fr;
  grid-template-rows: auto auto; gap: 8px; align-items: start;
}
.ask-question-options { display: flex; flex-direction: column; gap: 6px; grid-row: 1; grid-column: 1; }
.ask-option-preview {
  grid-row: 1; grid-column: 2;
  background: var(--bg-muted); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px;
  font-size: 12px; line-height: 1.6; color: var(--text-secondary);
  min-height: 60px; white-space: pre-wrap; word-break: break-word;
  font-family: var(--font-mono);
}
.ask-confirm-btn {
  display: none; grid-row: 2; grid-column: 1 / -1; width: 100%;
  padding: 9px 0; border: 1.5px solid var(--primary); border-radius: 8px;
  background: transparent; color: var(--primary);
  font-size: 12px; font-weight: 600; cursor: pointer;
  font-family: var(--font-mono);
  transition: background 0.12s, color 0.12s;
}
.ask-confirm-btn:active { background: var(--primary); color: #fff; }
@media (pointer: coarse) { .ask-confirm-btn { display: block; } }
.ask-option-item {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px; background: var(--bg-card); width: 100%;
  text-align: left; cursor: pointer;
  transition: all 0.15s; color: var(--text);
}
.ask-option-item:hover { background: var(--bg-accent); border-color: var(--border-strong); }
.ask-option-item.ask-option-selected { background: var(--bg-accent); border-color: var(--primary); }
.ask-option-label { font-size: 12px; font-weight: 600; color: var(--text); font-family: var(--font-mono); }
.ask-option-desc { font-size: 12px; color: var(--text-secondary); line-height: 1.45; margin-top: 4px; }

/* === Typing Indicator === */
.typing-indicator { display: inline-flex; gap: 5px; padding: 8px 4px; }
.typing-indicator span {
  width: 6px; height: 6px; background: var(--primary);
  border-radius: 50%; opacity: 0.4; animation: bounce 1.4s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce { 0%,60%,100%{transform:translateY(0)} 30%{transform:translateY(-6px)} }

/* === Slash Command Menu === */
.cmd-menu {
  position: absolute; bottom: 80px; left: 50%; transform: translateX(-50%);
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 6px; min-width: 240px; max-width: 320px; z-index: 50;
}
.cmd-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px;
  cursor: pointer; transition: all 0.15s;
}
.cmd-item:hover, .cmd-item.active { background: var(--bg-accent); }
.cmd-item-cmd { font-weight: 600; font-size: 13px; color: var(--primary); white-space: nowrap; font-family: var(--font-mono); }
.cmd-item-desc { font-size: 12px; color: var(--text-secondary); }

/* === Input Area === */
.input-area {
  padding: 10px 16px; padding-bottom: max(14px, var(--safe-bottom));
  background: var(--bg);
  border-top: 1px solid var(--border);
  flex-shrink: 0; position: relative; z-index: 1;
}
.input-wrapper {
  display: flex; align-items: flex-end; gap: 8px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px 12px;
  max-width: 800px; margin: 0 auto;
  transition: all 0.2s; box-shadow: var(--shadow-sm);
}
.input-wrapper:focus-within {
  border-color: var(--primary);
  box-shadow: var(--shadow-focus), var(--shadow-md);
}
#msg-input {
  flex: 1; background: transparent; border: none;
  color: var(--text); font-size: 14px;
  font-family: var(--font-sans);
  line-height: 1.5; resize: none; outline: none;
  max-height: var(--input-max-height); min-height: 24px;
  overflow-y: auto;
}
#msg-input::placeholder { color: var(--text-muted); font-family: var(--font-mono); font-size: 13px; }
.send-btn, .abort-btn {
  width: 34px; height: 34px;
  border: none; border-radius: 10px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: all 0.15s;
}
.send-btn:active, .abort-btn:active { transform: scale(0.92); }
.send-btn { background: var(--primary); color: #fff; box-shadow: var(--shadow-brand); }
.send-btn:hover { background: #1e40af; transform: translateY(-1px); }
.send-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.abort-btn { background: var(--danger); color: #fff; }
.abort-btn:hover { background: #dc2626; }

/* === Option Picker === */
.option-picker {
  position: absolute; bottom: 80px; left: 50%; transform: translateX(-50%);
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 16px; min-width: 280px; max-width: 380px;
  z-index: 50; animation: fadeIn 0.2s ease;
}
.option-picker-title { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 12px; padding: 0 4px; font-family: var(--font-mono); }
.option-picker-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: 10px;
  cursor: pointer; transition: all 0.15s; margin-bottom: 4px;
}
.option-picker-item:last-child { margin-bottom: 0; }
.option-picker-item:hover { background: var(--bg-accent); }
.option-picker-item.active { background: var(--bg-accent); outline: 1px solid var(--primary); }
.option-picker-item-info { flex: 1; min-width: 0; }
.option-picker-item-label { font-weight: 600; font-size: 14px; color: var(--text); font-family: var(--font-mono); }
.option-picker-item-desc { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.option-picker-item-check { color: var(--primary); font-size: 16px; font-weight: 700; flex-shrink: 0; }

/* === Mobile === */
@media (max-width: 768px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    z-index: 100; transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay {
    position: fixed; inset: 0;
    background: rgba(10, 15, 26, 0.25); z-index: 99;
    backdrop-filter: blur(4px);
  }
  .menu-btn { display: block; }
  .msg { max-width: 95%; }
  .input-area { padding: 8px 10px; padding-bottom: max(10px, var(--safe-bottom)); }
  .messages { padding: 12px 8px; gap: 10px; }
  .session-item-actions { display: flex; }
  .cmd-menu { left: 10px; right: 10px; transform: none; min-width: auto; bottom: 72px; }
  .option-picker { left: 10px; right: 10px; transform: none; min-width: auto; bottom: 72px; }
}
@media (max-width: 480px) {
  .msg-avatar { width: 26px; height: 26px; font-size: 10px; border-radius: 8px; }
  .msg-bubble { padding: 10px 12px; font-size: 13px; border-radius: 10px; }
  .msg.user .msg-bubble { border-bottom-right-radius: 4px; }
  .msg.assistant .msg-bubble { border-bottom-left-radius: 4px; }
  .code-block-wrapper pre code { font-size: 12px; }
  .input-wrapper { padding: 6px 10px; border-radius: 10px; }
  .send-btn, .abort-btn { width: 32px; height: 32px; }
}

/* === Utility === */
[hidden] { display: none !important; }

/* === Toast === */
.toast-notification {
  position: fixed; top: 16px; right: 16px;
  background: var(--bg-card); color: var(--primary);
  padding: 10px 18px; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 13px; font-weight: 600;
  box-shadow: var(--shadow-md); z-index: 200;
  opacity: 0; transform: translateY(-10px);
  transition: opacity 0.3s, transform 0.3s;
  font-family: var(--font-mono);
}
.toast-notification.show { opacity: 1; transform: translateY(0); }

/* === Session Unread === */
.session-unread-dot {
  width: 7px; height: 7px; background: var(--primary);
  border-radius: 50%; flex-shrink: 0; margin-left: 4px;
  box-shadow: 0 0 6px rgba(30,58,138,0.4);
}

/* === Settings === */
.settings-btn {
  background: none; border: none; font-size: 18px;
  cursor: pointer; color: var(--text-muted);
  padding: 4px 8px; border-radius: 6px;
  transition: all 0.15s; vertical-align: middle; margin-right: 8px;
}
.settings-btn:hover { color: var(--primary); background: var(--bg-accent); }

.settings-overlay {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(10, 15, 26, 0.25);
  backdrop-filter: blur(6px); z-index: 1000;
  animation: fadeIn 0.2s ease;
}
.settings-panel {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 1.5rem; width: 90%; max-width: 420px;
  max-height: 85vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  padding: 32px 28px; animation: fadeIn 0.25s ease;
}
.settings-panel h3 {
  font-size: 16px; font-weight: 700; color: var(--text);
  margin-bottom: 20px; display: flex; align-items: center; gap: 8px;
  font-family: var(--font-mono);
}
.settings-panel h3 .settings-close,
.settings-header .settings-close {
  margin-left: auto; background: none; border: none;
  font-size: 20px; cursor: pointer; color: var(--text-muted);
  padding: 2px 6px; border-radius: 6px;
}
.settings-panel h3 .settings-close:hover,
.settings-header .settings-close:hover { color: var(--text); background: var(--bg-muted); }
.settings-header { display: flex; align-items: center; gap: 8px; margin-bottom: 20px; }
.settings-header h3 { margin-bottom: 0; flex: 1; }
.settings-field { margin-bottom: 16px; }
.settings-field label {
  display: block; font-size: 11px; font-weight: 700;
  color: var(--text-secondary); margin-bottom: 6px;
  font-family: var(--font-mono);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.settings-field input,
.settings-select {
  width: 100%; padding: 10px 14px;
  background: var(--input-bg); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text);
  font-size: 13px; font-family: var(--font-mono);
  outline: none; transition: all 0.2s;
}
.settings-field input:focus,
.settings-select:focus { border-color: var(--primary); box-shadow: var(--shadow-focus); }
.settings-select {
  -webkit-appearance: none; appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%231e3a8a'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  padding-right: 32px;
}
.settings-actions { display: flex; gap: 10px; margin-top: 24px; }
.settings-actions button {
  flex: 1; padding: 10px; border: none;
  border-radius: var(--radius); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all 0.15s;
  font-family: var(--font-mono);
}
.settings-actions .btn-test {
  background: var(--bg-muted); color: var(--text);
  border: 1px solid var(--border);
}
.settings-actions .btn-test:hover { background: var(--bg-accent); }
.settings-actions .btn-save {
  background: var(--primary); color: #fff;
  box-shadow: var(--shadow-brand);
}
.settings-actions .btn-save:hover { background: #1e40af; transform: translateY(-1px); }
.settings-status { margin-top: 12px; font-size: 12px; text-align: center; min-height: 20px; font-family: var(--font-mono); }
.settings-status.success { color: var(--success); }
.settings-status.error { color: var(--danger); }

@media (max-width: 768px) { .settings-panel { padding: 24px 20px; border-radius: 16px; } }
@media (max-width: 480px) { .settings-panel { width: 95%; padding: 20px 16px; } }

/* === Force Change Password === */
.force-change-overlay {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(10, 15, 26, 0.35); backdrop-filter: blur(6px);
  z-index: 2000; animation: fadeIn 0.25s ease;
}
.force-change-panel {
  text-align: center; padding: 40px 32px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 1.5rem; width: 90%; max-width: 400px;
  box-shadow: var(--shadow-lg); animation: fadeIn 0.25s ease;
}
.force-change-panel .login-logo {
  width: 56px; height: 56px; margin: 0 auto 12px;
  background: var(--primary); color: #fff;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 800;
  box-shadow: var(--shadow-brand); font-family: var(--font-mono);
}
.force-change-panel h2 { font-size: 20px; margin-bottom: 4px; color: var(--text); font-weight: 700; font-family: var(--font-mono); }
.force-change-panel p { color: var(--text-secondary); margin-bottom: 24px; font-size: 13px; }
.force-change-form input {
  width: 100%; padding: 11px 14px;
  background: var(--input-bg); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text);
  font-size: 14px; font-family: var(--font-mono);
  outline: none; margin-bottom: 10px; transition: all 0.2s;
}
.force-change-form input:focus { border-color: var(--primary); box-shadow: var(--shadow-focus); }
.fc-submit-btn {
  width: 100%; padding: 12px;
  background: var(--primary); color: #fff;
  border: none; border-radius: var(--radius);
  font-size: 14px; font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: 0.05em; text-transform: uppercase;
  cursor: pointer; box-shadow: var(--shadow-brand);
  transition: all 0.15s; margin-top: 6px;
}
.fc-submit-btn:hover:not(:disabled) { background: #1e40af; transform: translateY(-1px); }
.fc-submit-btn:active:not(:disabled) { transform: scale(0.97); }
.fc-submit-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.fc-status { margin-top: 10px; font-size: 12px; min-height: 18px; color: var(--text-secondary); font-family: var(--font-mono); }
.fc-status.error { color: var(--danger); }
.fc-status.success { color: var(--success); }

/* === Password Hint === */
.password-hint { font-size: 11px; color: var(--text-muted); margin: -4px 0 10px 2px; text-align: left; font-family: var(--font-mono); }
.password-hint.error { color: var(--danger); }
.password-hint.success { color: var(--success); }

/* === Settings Divider / Section === */
.settings-divider { height: 1px; background: var(--border); margin: 24px 0; }
.settings-section-title {
  font-size: 12px; font-weight: 700;
  color: var(--text-secondary); margin-bottom: 14px;
  font-family: var(--font-mono);
  text-transform: uppercase; letter-spacing: 0.05em;
}

/* ============================================
   New UI Elements (CoolVibe-adapted)
   ============================================ */

/* === New Chat Split Button === */
.sidebar-header { position: relative; }
.new-chat-split {
  display: flex;
  align-items: stretch;
  gap: 6px;
}
.new-chat-split.single .new-chat-btn { border-radius: 10px; }
.new-chat-split.single .new-chat-arrow { display: none; }
.new-chat-split .new-chat-btn {
  flex: 1;
  min-height: 48px;
  border-radius: 10px 0 0 10px;
}
.new-chat-arrow {
  width: 52px;
  min-height: 48px;
  padding: 0;
  background: var(--primary);
  border: none;
  border-radius: 0 10px 10px 0;
  color: #fff;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-brand);
  font-family: var(--font-mono);
}
.new-chat-arrow:hover { background: #1e40af; }
.new-chat-dropdown {
  position: absolute;
  top: 54px;
  left: 12px;
  right: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  overflow: hidden;
}
.new-chat-dropdown button {
  display: block;
  width: 100%;
  padding: 12px 16px;
  background: none;
  border: none;
  text-align: left;
  font-size: 14px;
  font-family: var(--font-mono);
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s;
}
.new-chat-dropdown button:hover { background: var(--accent-light); }

/* === Chat Agent Selector === */
.chat-agent-btn {
  appearance: none;
  font-size: 11px;
  color: var(--text);
  background: var(--bg-accent);
  border: 1px solid var(--border);
  padding: 2px 22px 2px 10px;
  border-radius: 999px;
  flex-shrink: 0;
  font-weight: 700;
  font-family: var(--font-mono);
  cursor: pointer;
  position: relative;
  transition: all 0.15s;
}
.chat-agent-btn::after {
  content: '▾';
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-48%);
  font-size: 10px;
  color: var(--text-secondary);
}
.chat-agent-btn:hover {
  background: var(--accent-light);
  border-color: var(--border-strong);
}
.chat-agent-menu {
  position: absolute;
  top: calc(100% - 6px);
  right: 16px;
  min-width: 148px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(240, 242, 255, 0.98);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(14px);
  z-index: 80;
}
.chat-agent-option {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 11px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: all 0.15s;
}
.chat-agent-option:hover {
  background: var(--bg-accent);
}
.chat-agent-option.active {
  background: var(--accent-light);
  color: var(--primary);
}
.chat-agent-option.active::after {
  content: '当前';
  font-size: 10px;
  letter-spacing: 0.04em;
}

/* === Runtime State / CWD === */
.chat-runtime-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.25);
  color: #92400e;
  font-size: 11px;
  font-weight: 800;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
.chat-runtime-state::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 1.1s infinite;
}
.chat-cwd {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-muted);
  padding: 2px 8px;
  border-radius: 6px;
  flex-shrink: 0;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: default;
  font-family: var(--font-mono);
}

/* === Attach Button & Attachment Tray === */
.attach-btn {
  appearance: none;
  width: 40px;
  height: 40px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
  border-radius: 12px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.18s, background 0.18s, border-color 0.18s;
}
.attach-btn:hover {
  color: var(--primary);
  background: var(--bg-accent);
  border-color: var(--border);
}
.attach-btn:disabled {
  opacity: 0.45;
  cursor: default;
}
.attachment-tray {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 800px;
  margin: 0 auto 10px;
}
.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-card);
  color: var(--text);
  font-size: 12px;
  font-family: var(--font-mono);
  line-height: 1.4;
}
.attachment-chip.uploading {
  border-style: dashed;
  border-color: var(--border-strong);
  background: var(--bg-muted);
}
.attachment-chip-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.attachment-chip-name {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attachment-chip-note {
  color: var(--text-muted);
  font-size: 11px;
  white-space: nowrap;
}
.attachment-chip-remove {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 2px;
  border-radius: 6px;
}
.attachment-chip-remove:hover {
  color: var(--danger);
  background: #fef2f2;
}
.attachment-tray-note {
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 246, 223, 0.95);
  border: 1px solid rgba(245, 158, 11, 0.25);
  color: #92400e;
  font-size: 12px;
  font-family: var(--font-mono);
  line-height: 1.55;
}
.input-wrapper.drag-active {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.12);
}

/* === Session Loading Overlay === */
body.session-loading-active {
  cursor: progress;
}
.session-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    linear-gradient(135deg, rgba(240, 242, 255, 0.78), rgba(224, 230, 255, 0.84)),
    rgba(15, 23, 42, 0.16);
  backdrop-filter: blur(10px);
}
.session-loading-card {
  width: min(440px, 100%);
  padding: 24px 24px 20px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(240, 242, 255, 0.96));
  box-shadow: 0 24px 60px rgba(30, 58, 138, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.8);
}
.session-loading-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 74px;
  margin-bottom: 12px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--accent-light);
  color: var(--primary);
  font-size: 11px;
  font-weight: 800;
  font-family: var(--font-mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.session-loading-title {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0.01em;
  color: var(--text);
  font-family: var(--font-mono);
}
.session-loading-label {
  margin-top: 8px;
  color: var(--text-secondary);
  font-size: 14px;
  font-family: var(--font-mono);
  line-height: 1.7;
}
.session-loading-bar {
  margin-top: 18px;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--bg-accent);
}
.session-loading-bar-fill {
  display: block;
  width: 44%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #1e3a8a, #3b82f6, #1e3a8a);
  animation: session-loading-pulse 1.2s ease-in-out infinite;
  transform-origin: left center;
}
@keyframes session-loading-pulse {
  0%   { transform: translateX(-55%) scaleX(0.82); opacity: 0.72; }
  50%  { transform: translateX(120%) scaleX(1.08); opacity: 1; }
  100% { transform: translateX(250%) scaleX(0.88); opacity: 0.72; }
}

/* === Session List Empty === */
.session-list-empty {
  margin: 12px 6px;
  padding: 16px 14px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.6;
  background: var(--bg-muted);
  font-family: var(--font-mono);
}

/* === Settings Subpage / Nav Card === */
.settings-back {
  appearance: none;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.settings-back:hover { background: var(--bg-muted); }
.settings-subpage-header { align-items: flex-start; }
.settings-subpage-copy { flex: 1; min-width: 0; }
.settings-subpage-copy h3 { margin-bottom: 0; }
.settings-subpage-kicker {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  margin-bottom: 4px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 800;
  font-family: var(--font-mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.settings-subpage-panel { max-width: 460px; }
.settings-nav-card {
  appearance: none;
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255,255,255,0.92), rgba(240,242,255,0.92));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.18s, transform 0.18s, box-shadow 0.18s;
}
.settings-nav-card:hover {
  transform: translateY(-1px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}
.settings-nav-card-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.settings-nav-card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  font-family: var(--font-mono);
}
.settings-nav-card-meta {
  font-size: 12px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}
.settings-nav-card-arrow {
  color: var(--text-muted);
  font-size: 22px;
  line-height: 1;
  flex-shrink: 0;
}
.settings-inline-note {
  margin: -4px 0 16px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.65;
  color: var(--text-secondary);
  background: var(--bg-muted);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
}
.settings-inline-note.warning {
  color: #92400e;
  background: rgba(255, 246, 223, 0.95);
  border-color: rgba(245, 158, 11, 0.25);
}
.settings-inline-note code {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 5px;
  border-radius: 6px;
  background: var(--bg-accent);
  color: var(--text);
}

/* === Agent Context Card === */
.agent-context-card {
  margin: -6px 0 18px;
  padding: 14px 16px 15px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background:
    radial-gradient(circle at top right, rgba(30, 58, 138, 0.08), transparent 45%),
    linear-gradient(135deg, var(--accent-light), rgba(240, 242, 255, 0.96));
}
.agent-context-kicker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 6px;
}
.agent-context-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  font-family: var(--font-mono);
  margin-bottom: 4px;
}
.agent-context-copy {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.65;
}

/* === Theme Grid & Cards === */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
.theme-card {
  appearance: none;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(240, 242, 255, 0.72);
  padding: 12px;
  text-align: left;
  cursor: pointer;
  transition: transform 0.18s, border-color 0.18s, box-shadow 0.18s;
}
.theme-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
}
.theme-card.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(30, 58, 138, 0.12);
}
.theme-card-preview {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 10px;
}
.theme-card-swatch {
  height: 18px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.06);
}
.theme-card-title {
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
  font-family: var(--font-mono);
  margin-bottom: 2px;
}
.theme-card-desc {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.45;
}

/* === Modal Overlay / Panel === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 15, 26, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 16px;
  backdrop-filter: blur(4px);
}
.modal-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}
.modal-panel-wide { max-width: 600px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-title {
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
  font-family: var(--font-mono);
}
.modal-close-btn {
  background: none;
  border: none;
  font-size: 16px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  line-height: 1;
}
.modal-close-btn:hover { background: var(--bg-muted); color: var(--text); }
.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 20px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  margin-bottom: 8px;
}
.modal-field-row { display: flex; gap: 8px; }
.modal-select {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  font-family: var(--font-mono);
  outline: none;
  transition: border-color 0.2s;
}
.modal-select:focus { border-color: var(--primary); }
.modal-stack { display: flex; flex-direction: column; gap: 14px; }
.modal-text-input {
  flex: 1;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  font-family: var(--font-mono);
  outline: none;
  transition: border-color 0.2s;
}
.modal-text-input:focus { border-color: var(--primary); }
.modal-btn-primary {
  padding: 9px 20px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: background 0.2s;
  box-shadow: var(--shadow-brand);
}
.modal-btn-primary:hover { background: #1e40af; }
.modal-btn-secondary {
  padding: 9px 20px;
  background: var(--bg-muted);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: background 0.2s;
}
.modal-btn-secondary:hover { background: var(--bg-accent); }
.modal-loading, .modal-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 32px 0;
  font-size: 14px;
  font-family: var(--font-mono);
}

/* === Import Session List === */
.import-group { margin-bottom: 20px; }
.import-group:last-child { margin-bottom: 0; }
.import-group-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  font-family: var(--font-mono);
  padding: 4px 0 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
  word-break: break-all;
}
.import-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--bg-muted);
}
.import-item:last-child { border-bottom: none; }
.import-item-info { flex: 1; min-width: 0; }
.import-item-title {
  font-size: 14px;
  color: var(--text);
  font-family: var(--font-mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 2px;
}
.import-item-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.import-item-tag {
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: 0.03em;
  color: var(--primary);
  background: var(--accent-light);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 7px;
}
.import-item-meta {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.import-item-btn {
  flex-shrink: 0;
  padding: 6px 14px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-mono);
  cursor: pointer;
  box-shadow: var(--shadow-brand);
  transition: background 0.2s;
}
.import-item-btn:hover { background: #1e40af; }

/* === Mobile overrides for new elements === */
@media (max-width: 768px) {
  .chat-agent-menu { right: 10px; min-width: 138px; }
  .chat-cwd { max-width: 120px; }
  .theme-grid { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .attach-btn { width: 38px; height: 38px; border-radius: 11px; }
  .new-chat-btn,
  .new-chat-arrow { min-height: 44px; }
  .new-chat-arrow { width: 48px; }
  .settings-nav-card { padding: 13px 14px; }
  .settings-back { width: 32px; height: 32px; }
}
