/* ============================================
   Codex Web — 科幻赛博主题 (Sci-Fi Cyber Theme)
   ============================================ */

:root {
  /* --- 配色 --- */
  --bg-primary: #0a0e17;            /* 深空黑 deep space */
  --bg-secondary: #0f1423;          /* 暗舱 dark hull */
  --bg-tertiary: #161d2e;           /* 面板 panel */
  --bg-bubble-user: linear-gradient(135deg, #00b4d8, #7c3aed);  /* 用户气泡渐变 */
  --bg-bubble-assistant: rgba(15, 23, 42, 0.85);  /* 助手气泡 */
  --text-primary: #e2e8f0;          /* 冷白 cool white */
  --text-secondary: #94a3b8;        /* 灰蓝 gray-blue */
  --text-muted: #64748b;            /* 暗灰 muted */
  --border-color: rgba(0, 240, 255, 0.12); /* 半透明青 */
  --accent: #00f0ff;                /* 电光青 electric cyan */
  --accent-hover: #00c8d6;          /* 深青 deep cyan */
  --accent-light: rgba(0, 240, 255, 0.1);  /* 淡青 */
  --accent-glow: 0 0 15px rgba(0, 240, 255, 0.3), 0 0 30px rgba(0, 240, 255, 0.1);
  --accent-glow-strong: 0 0 20px rgba(0, 240, 255, 0.5), 0 0 40px rgba(0, 240, 255, 0.2);
  --purple: #a855f7;                /* 紫 violet */
  --purple-glow: 0 0 15px rgba(168, 85, 247, 0.3);
  --success: #10b981;               /* 翠绿 emerald */
  --danger: #ef4444;                /* 赤 red */
  --warning: #f59e0b;               /* 金 amber */
  --info: #3b82f6;                  /* 蓝 blue */
  --scrollbar-thumb: rgba(0, 240, 255, 0.3);
  --scrollbar-track: transparent;
  --sidebar-width: 280px;
  --header-height: 52px;
  --input-max-height: 200px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font-ui: 'Rajdhani', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', 'Noto Sans CJK SC', Roboto, sans-serif;
  --font-display: 'Orbitron', 'Rajdhani', monospace;
  --page-background: #0a0e17;
  --login-background: radial-gradient(ellipse at 30% 20%, rgba(0, 240, 255, 0.08) 0%, transparent 50%),
                      radial-gradient(ellipse at 70% 80%, rgba(168, 85, 247, 0.06) 0%, transparent 50%),
                      linear-gradient(180deg, #0a0e17 0%, #111827 100%);
  --surface-strong: rgba(15, 20, 35, 0.95);
  --shadow-strong: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 60px rgba(0, 240, 255, 0.05);
  --glass: rgba(15, 20, 35, 0.7);
  --glass-border: rgba(0, 240, 255, 0.15);
  --loading-overlay-layer-a: rgba(10, 14, 23, 0.85);
  --loading-overlay-layer-b: rgba(15, 20, 35, 0.9);
  --loading-overlay-scrim: rgba(0, 0, 0, 0.4);
  --loading-card-bg: linear-gradient(180deg, rgba(15, 20, 35, 0.98), rgba(22, 29, 46, 0.95));
  --loading-card-border: rgba(0, 240, 255, 0.2);
  --loading-card-shadow: 0 24px 60px rgba(0, 0, 0, 0.4), 0 0 80px rgba(0, 240, 255, 0.08);
  --loading-badge-bg: rgba(0, 240, 255, 0.12);
  --loading-badge-text: var(--accent);
  --loading-bar-bg: rgba(0, 240, 255, 0.08);
  --loading-bar-fill: linear-gradient(90deg, #00f0ff, #a855f7, #00f0ff);
}

/* === 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-ui);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--page-background);
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

/* 全局隐藏原生滚动条 */
::-webkit-scrollbar { display: none; }
* { scrollbar-width: none; }

/* === Animated Grid Background === */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(0, 240, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 240, 255, 0.03) 1px, transparent 1px);
  background-size: 60px 60px;
  pointer-events: none;
  z-index: 0;
  animation: gridDrift 20s linear infinite;
}
@keyframes gridDrift {
  0% { transform: translate(0, 0); }
  100% { transform: translate(60px, 60px); }
}

/* === Scanline Overlay === */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 240, 255, 0.008) 2px,
    rgba(0, 240, 255, 0.008) 4px
  );
  pointer-events: none;
  z-index: 9999;
}

/* === Login === */
.login-overlay {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--login-background);
  z-index: 1000;
}
.login-box {
  text-align: center;
  padding: 48px 36px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  width: 90%;
  max-width: 360px;
  box-shadow: var(--shadow-strong);
  backdrop-filter: blur(20px);
  position: relative;
  overflow: hidden;
}
/* 顶部装饰光线 */
.login-box::before {
  content: '';
  position: absolute;
  top: 0;
  left: 10%;
  right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.4);
}
.login-logo {
  width: 64px; height: 64px;
  margin: 0 auto 16px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: #fff;
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.5);
  animation: logoPulse 3s ease-in-out infinite;
}
.login-logo svg {
  width: 80%; height: 80%;
}
@keyframes logoPulse {
  0%, 100% { box-shadow: 0 0 20px rgba(59, 130, 246, 0.5); }
  50% { box-shadow: 0 0 30px rgba(59, 130, 246, 0.8); }
}
.login-box h2 {
  font-size: 24px;
  margin-bottom: 4px;
  color: var(--text-primary);
  font-weight: 700;
  font-family: var(--font-display);
  letter-spacing: 2px;
}
.login-box p {
  color: var(--text-secondary);
  margin-bottom: 28px;
  font-size: 14px;
}
.login-box input {
  width: 100%;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 15px;
  outline: none;
  margin-bottom: 20px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.login-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 240, 255, 0.1), var(--accent-glow);
}
.login-box button {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  font-family: var(--font-display);
  letter-spacing: 1px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.3s;
  box-shadow: var(--accent-glow);
}
.login-box button:hover {
  transform: translateY(-1px);
  box-shadow: var(--accent-glow-strong);
}

.login-error {
  color: var(--danger);
  margin-top: 12px;
  font-size: 14px;
  text-shadow: 0 0 10px rgba(239, 68, 68, 0.3);
}

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

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, var(--loading-overlay-layer-a), var(--loading-overlay-layer-b)),
    var(--loading-overlay-scrim);
  backdrop-filter: blur(16px);
}

.session-loading-card {
  width: min(440px, 100%);
  padding: 24px 24px 20px;
  border: 1px solid var(--loading-card-border);
  border-radius: 20px;
  background: var(--loading-card-bg);
  box-shadow: var(--loading-card-shadow);
  backdrop-filter: blur(20px);
}

.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(--loading-badge-bg);
  color: var(--loading-badge-text);
  font-size: 11px;
  font-weight: 800;
  font-family: var(--font-display);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.session-loading-title {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: var(--text-primary);
  font-family: var(--font-display);
}

.session-loading-label {
  margin-top: 8px;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.7;
}

.session-loading-bar {
  margin-top: 18px;
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--loading-bar-bg);
}

.session-loading-bar-fill {
  display: block;
  width: 44%;
  height: 100%;
  border-radius: inherit;
  background: var(--loading-bar-fill);
  background-size: 200% 100%;
  animation: session-loading-pulse 1.2s ease-in-out infinite, neonShimmer 2s linear infinite;
  transform-origin: left center;
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.4);
}

@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;
  }
}

@keyframes neonShimmer {
  0% { background-position: 0% 0%; }
  100% { background-position: 200% 0%; }
}

/* === Sidebar === */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
  overflow: hidden;
  position: relative;
}
/* 侧边栏右侧发光线 */
.sidebar::after {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 1px;
  background: linear-gradient(180deg, transparent, rgba(0, 240, 255, 0.3), transparent);
  pointer-events: none;
}
.sidebar-header {
  padding: 12px;
  border-bottom: 1px solid var(--glass-border);
  flex-shrink: 0;
}
.agent-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin-bottom: 10px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
}
.agent-switch-btn {
  appearance: none;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 700;
  padding: 8px 10px;
  cursor: pointer;
  transition: background 0.18s, color 0.18s, box-shadow 0.18s;
}
.agent-switch-btn:hover {
  background: rgba(0, 240, 255, 0.06);
  color: var(--text-primary);
}
.agent-switch-btn.active {
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.2), rgba(168, 85, 247, 0.15));
  color: var(--accent);
  box-shadow: var(--accent-glow);
}
.new-chat-btn {
  width: 100%;
  min-height: 48px;
  padding: 10px;
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.15), rgba(168, 85, 247, 0.1));
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.3s, transform 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  letter-spacing: 0.5px;
}
.new-chat-btn:hover {
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.25), rgba(168, 85, 247, 0.18));
  box-shadow: var(--accent-glow);
  transform: translateY(-1px);
}
.session-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  -webkit-overflow-scrolling: touch;
}
.session-list-empty {
  margin: 12px 6px;
  padding: 16px 14px;
  border: 1px dashed var(--glass-border);
  border-radius: 12px;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.6;
  background: rgba(0, 0, 0, 0.2);
}
.session-item {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  margin-bottom: 2px;
  transition: background 0.15s, box-shadow 0.2s;
  position: relative;
  border: 1px solid transparent;
}
.session-item:hover {
  background: rgba(0, 240, 255, 0.04);
  border-color: rgba(0, 240, 255, 0.08);
}
.session-item.active {
  background: rgba(0, 240, 255, 0.08);
  border-color: rgba(0, 240, 255, 0.2);
  box-shadow: inset 0 0 20px rgba(0, 240, 255, 0.03);
}
.session-item-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.session-item-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  color: var(--text-primary);
}
.session-item.active .session-item-title { color: var(--accent); font-weight: 500; }
.session-item-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(0, 240, 255, 0.1);
  border: 1px solid rgba(0, 240, 255, 0.2);
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  font-family: var(--font-display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.session-item-status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
  animation: pulse 1.1s infinite;
}
.session-item-time {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: 8px;
  flex-shrink: 0;
}
.session-item-actions {
  display: none;
  gap: 2px;
  margin-left: 4px;
  flex-shrink: 0;
}
.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;
}
.session-item-btn:hover { color: var(--accent); background: rgba(0, 240, 255, 0.08); }
.session-item-btn.delete:hover { color: var(--danger); background: rgba(239, 68, 68, 0.1); }
.session-item-edit-input {
  flex: 1;
  padding: 2px 6px;
  border: 1px solid var(--accent);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.3);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  min-width: 0;
  box-shadow: 0 0 8px rgba(0, 240, 255, 0.15);
}
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--glass-border);
  text-align: center;
  flex-shrink: 0;
}
.brand {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-display);
  letter-spacing: 2px;
}

/* === Chat Main === */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
  background: var(--bg-primary);
}
.chat-header {
  height: var(--header-height);
  min-height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid var(--glass-border);
  background: rgba(15, 20, 35, 0.8);
  backdrop-filter: blur(12px);
  gap: 10px;
  flex-shrink: 0;
  position: relative;
}
/* 头部底部发光线 */
.chat-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 5%;
  right: 5%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(0, 240, 255, 0.2), transparent);
}
.menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}
.menu-btn:hover { background: rgba(0, 240, 255, 0.08); }
.chat-title {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  transition: background 0.15s;
}
.chat-title:hover { background: rgba(0, 240, 255, 0.06); }
.chat-agent-btn {
  appearance: none;
  font-size: 11px;
  color: var(--accent);
  background: rgba(0, 240, 255, 0.08);
  border: 1px solid rgba(0, 240, 255, 0.2);
  padding: 2px 22px 2px 10px;
  border-radius: 999px;
  flex-shrink: 0;
  font-weight: 700;
  cursor: pointer;
  position: relative;
  font-family: var(--font-display);
  letter-spacing: 0.5px;
}
.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: rgba(0, 240, 255, 0.15);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.15);
}
.chat-agent-menu {
  position: absolute;
  top: calc(100% - 6px);
  right: 16px;
  min-width: 148px;
  padding: 8px;
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  background: rgba(15, 20, 35, 0.95);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.4), 0 0 30px rgba(0, 240, 255, 0.08);
  backdrop-filter: blur(20px);
  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-primary);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.chat-agent-option:hover {
  background: rgba(0, 240, 255, 0.08);
}
.chat-agent-option.active {
  background: rgba(0, 240, 255, 0.12);
  color: var(--accent);
}
.chat-agent-option.active::after {
  content: '当前';
  font-size: 10px;
  letter-spacing: 0.04em;
  font-family: var(--font-display);
}
.chat-runtime-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(0, 240, 255, 0.1);
  border: 1px solid rgba(0, 240, 255, 0.2);
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  font-family: var(--font-display);
  letter-spacing: 0.06em;
  flex-shrink: 0;
}
.chat-runtime-state::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: pulse 1.1s infinite;
}
.cost-display {
  display: none !important;
}
.cost-display:empty { display: none; }

/* Mode selector */
.mode-select {
  -webkit-appearance: none;
  appearance: none;
  background: rgba(0, 0, 0, 0.3);
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  padding: 4px 24px 4px 10px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-display);
  cursor: pointer;
  flex-shrink: 0;
  outline: none;
  transition: border-color 0.15s, box-shadow 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='%2364748b'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}
.mode-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 8px rgba(0, 240, 255, 0.15);
}
.mode-select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

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

/* Custom scrollbar — neon */
.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: 4px;
  min-height: 30px;
  border-radius: 4px;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(0, 240, 255, 0.4);
  cursor: grab;
  transition: width 0.15s, right 0.15s, background 0.15s;
  pointer-events: all;
}
.custom-scrollbar-thumb:hover,
.custom-scrollbar-thumb.dragging {
  width: 8px;
  right: -2px;
  background: var(--accent);
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.6);
}
.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: 6px;
    right: 6px;
    min-height: 40px;
    border-radius: 4px;
  }
  .custom-scrollbar-thumb:hover,
  .custom-scrollbar-thumb.dragging {
    width: 10px;
    right: 4px;
  }
}

.welcome-msg {
  text-align: center;
  margin: auto;
  padding: 40px 20px;
  color: var(--text-secondary);
}
.welcome-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 12px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: #fff;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.welcome-icon svg {
  width: 80%;
  height: 80%;
}
.welcome-msg h3 {
  font-size: 22px;
  color: var(--accent);
  margin-bottom: 8px;
  font-weight: 700;
  font-family: var(--font-display);
  letter-spacing: 2px;
  text-shadow: 0 0 20px rgba(0, 240, 255, 0.3);
}
.welcome-msg p { font-size: 14px; color: var(--text-muted); }

/* === 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: 32px;
  height: 32px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}
.msg.user .msg-avatar {
  background: linear-gradient(135deg, var(--accent), var(--purple));
  color: #fff;
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.2);
}
.msg.assistant .msg-avatar {
  background: linear-gradient(135deg, var(--success), #059669);
  color: #fff;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.2);
}
.msg-avatar svg { display: block; flex-shrink: 0; width: 60%; height: 60%; }
.msg.assistant.agent-codex .msg-avatar {
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  border: none;
}

.msg-bubble {
  padding: 12px 16px;
  border-radius: 16px;
  line-height: 1.65;
  word-break: break-word;
  min-width: 0;
  max-width: 100%;
}
.msg-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.msg-attachment-label {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(0, 240, 255, 0.08);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.35;
}
.msg.user .msg-bubble {
  background: linear-gradient(135deg, rgba(0, 180, 216, 0.85), rgba(124, 58, 237, 0.85));
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 20px rgba(0, 180, 216, 0.15);
  backdrop-filter: blur(8px);
}
.msg.user .msg-attachment-label {
  background: rgba(255, 255, 255, 0.16);
  color: rgba(255, 255, 255, 0.92);
}
.msg.assistant .msg-bubble {
  background: var(--bg-bubble-assistant);
  border: 1px solid var(--glass-border);
  border-bottom-left-radius: 4px;
  color: var(--text-primary);
  backdrop-filter: blur(8px);
}

/* System messages */
.msg.system {
  align-self: center;
  max-width: 90%;
}
.msg.system .msg-bubble {
  background: rgba(0, 240, 255, 0.04);
  border: 1px dashed var(--glass-border);
  border-radius: 10px;
  color: var(--text-secondary);
  font-size: 13px;
  padding: 10px 16px;
  text-align: center;
  white-space: pre-line;
}

/* Markdown content */
.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-display);
  letter-spacing: 0.5px;
}
.msg-bubble h1 { font-size: 1.3em; color: var(--accent); }
.msg-bubble h2 { font-size: 1.15em; color: var(--accent); }
.msg-bubble h3 { font-size: 1.05em; }
.msg-bubble a { color: var(--accent); text-decoration: none; }
.msg-bubble a:hover { text-decoration: underline; text-shadow: 0 0 8px rgba(0, 240, 255, 0.3); }
.msg-bubble blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 12px;
  color: var(--text-secondary);
  margin: 8px 0;
}
.msg-bubble table {
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 13px;
  width: 100%;
  overflow-x: auto;
  display: block;
}
.msg-bubble th, .msg-bubble td {
  border: 1px solid var(--glass-border);
  padding: 6px 10px;
  text-align: left;
}
.msg-bubble th { background: rgba(0, 240, 255, 0.06); }

/* Inline code */
.msg-bubble code:not(pre code) {
  background: rgba(0, 240, 255, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.88em;
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  color: var(--accent);
  border: 1px solid rgba(0, 240, 255, 0.1);
}
.msg.user .msg-bubble code:not(pre code) {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border-color: rgba(255,255,255,0.2);
}

/* Code blocks */
.code-block-wrapper {
  position: relative;
  margin: 8px 0;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--glass-border);
  max-width: 100%;
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.3);
}
.code-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 12px;
  background: #1a1f2e;
  font-size: 12px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--glass-border);
}
.code-block-actions {
  display: flex;
  gap: 4px;
  align-items: center;
}
.code-copy-btn, .code-preview-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}
.code-copy-btn:hover, .code-preview-btn:hover { color: var(--accent); background: rgba(0, 240, 255, 0.08); }
.code-preview-btn { border: 1px solid rgba(0, 240, 255, 0.15); }
.code-block-wrapper pre {
  margin: 0;
  padding: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
  background: #0d1117;
}
.code-block-wrapper pre code {
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre;
}
/* HTML/SVG preview pane */
.code-preview-pane {
  display: none;
  background: #0d1117;
  border-top: 1px solid var(--glass-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(--glass-border);
  border-radius: 10px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.2);
}
.tool-call.codex-command {
  border-color: rgba(59, 130, 246, 0.24);
}
.tool-call.codex-reasoning {
  border-color: rgba(168, 85, 247, 0.2);
}
.tool-call.codex-file-change {
  border-color: rgba(16, 185, 129, 0.24);
}
.tool-call summary {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  background: rgba(15, 20, 35, 0.6);
  display: flex;
  align-items: flex-start;
  gap: 8px;
  user-select: none;
  list-style: none;
}
.tool-call-summary-main {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}
.tool-call-label {
  display: block;
  width: 100%;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tool-call-subtitle {
  display: block;
  width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
  font-size: 12px;
}
.tool-call-state {
  flex-shrink: 0;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-display);
  letter-spacing: 0.05em;
  background: rgba(100, 116, 139, 0.2);
  color: var(--text-secondary);
}
.tool-call-state.running {
  background: rgba(0, 240, 255, 0.12);
  color: var(--accent);
  box-shadow: 0 0 8px rgba(0, 240, 255, 0.15);
}
.tool-call-state.done {
  background: rgba(16, 185, 129, 0.12);
  color: var(--success);
}
.tool-call-state.error {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
}
.tool-call summary::-webkit-details-marker { display: none; }
.tool-call summary::before {
  content: '▸';
  font-size: 11px;
  transition: transform 0.2s;
  color: var(--accent);
}
.tool-call[open] summary::before { transform: rotate(90deg); }
.tool-call summary:hover { background: rgba(0, 240, 255, 0.04); }
.tool-call-icon {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.tool-call-icon.done { background: var(--success); box-shadow: 0 0 6px rgba(16, 185, 129, 0.4); }
.tool-call-icon.running { background: var(--accent); box-shadow: 0 0 6px rgba(0, 240, 255, 0.4); animation: pulse 1s infinite; }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}
.tool-call-content {
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-secondary);
  background: rgba(0, 0, 0, 0.15);
  max-height: 250px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  font-family: 'SF Mono', monospace;
}
.tool-call-content.reasoning {
  font-family: inherit;
  line-height: 1.7;
  color: var(--text-primary);
  background: linear-gradient(180deg, rgba(168, 85, 247, 0.06), rgba(168, 85, 247, 0.02));
}
.tool-call-content.command,
.tool-call-content.file-change {
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.1));
}
.tool-call-structured {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tool-call-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tool-call-section-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  font-family: var(--font-display);
}
.tool-call-code {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.3);
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 12px;
  line-height: 1.6;
  border: 1px solid rgba(0, 240, 255, 0.06);
}
.tool-call-empty {
  color: var(--text-muted);
  font-style: italic;
}

/* Tool group (auto-fold) */
.tool-group {
  margin: 8px 0;
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  overflow: hidden;
}
.tool-group-summary {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-muted);
  background: rgba(15, 20, 35, 0.6);
  list-style: none;
  user-select: none;
}
.tool-group-summary::-webkit-details-marker { display: none; }
.tool-group-summary::before {
  content: '▸ ';
  font-size: 11px;
  transition: transform 0.2s;
  display: inline-block;
  color: var(--accent);
}
.tool-group[open] > .tool-group-summary::before { transform: rotate(90deg); }
.tool-group-summary:hover { background: rgba(0, 240, 255, 0.04); }
.tool-group-inner {
  padding: 4px 8px;
  background: rgba(0, 0, 0, 0.1);
}
.tool-group-inner .tool-call {
  margin: 4px 0;
}

/* === AskUserQuestion === */
.ask-user-question {
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ask-question-card {
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  background: rgba(15, 20, 35, 0.8);
  padding: 10px;
  backdrop-filter: blur(8px);
}
.ask-question-header {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 6px;
  font-family: var(--font-display);
  letter-spacing: 0.5px;
}
.ask-question-text {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-primary);
  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: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-secondary);
  min-height: 60px;
  transition: background 0.15s;
  white-space: pre-wrap;
  word-break: break-word;
}
.ask-confirm-btn {
  display: none;
  grid-row: 2;
  grid-column: 1 / -1;
  width: 100%;
  padding: 9px 0;
  border: 1.5px solid var(--accent);
  border-radius: 8px;
  background: transparent;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-display);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.ask-confirm-btn:active {
  background: var(--accent);
  color: #000;
}
@media (pointer: coarse) {
  .ask-confirm-btn { display: block; }
}
.ask-option-item {
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.2);
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.2s;
  color: inherit;
}
.ask-option-item:hover {
  background: rgba(0, 240, 255, 0.06);
  border-color: rgba(0, 240, 255, 0.3);
}
.ask-option-item.ask-option-selected {
  background: rgba(0, 240, 255, 0.08);
  border-color: var(--accent);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.1);
}
.ask-option-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}
.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: 7px; height: 7px;
  background: var(--accent);
  border-radius: 50%;
  opacity: 0.5;
  animation: bounce 1.4s infinite;
  box-shadow: 0 0 6px rgba(0, 240, 255, 0.4);
}
.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(-7px); }
}

/* === Slash Command Menu === */
.cmd-menu {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 20, 35, 0.95);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4), 0 0 30px rgba(0, 240, 255, 0.05);
  backdrop-filter: blur(20px);
  padding: 6px;
  min-width: 240px;
  max-width: 320px;
  z-index: 50;
}
.cmd-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s;
}
.cmd-item:hover, .cmd-item.active {
  background: rgba(0, 240, 255, 0.08);
}
.cmd-item-cmd {
  font-weight: 600;
  font-size: 14px;
  color: var(--accent);
  white-space: nowrap;
  font-family: 'SF Mono', monospace;
}
.cmd-item-desc {
  font-size: 13px;
  color: var(--text-secondary);
}

/* === Input Area === */
.input-area {
  padding: 10px 16px;
  padding-bottom: max(14px, var(--safe-bottom));
  background: rgba(10, 14, 23, 0.9);
  border-top: 1px solid var(--glass-border);
  flex-shrink: 0;
  position: relative;
}
/* 输入区顶部发光线 */
.input-area::before {
  content: '';
  position: absolute;
  top: 0;
  left: 10%;
  right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(0, 240, 255, 0.15), transparent);
}
.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(--glass-border);
  border-radius: 12px;
  background: rgba(15, 20, 35, 0.8);
  color: var(--text-primary);
  font-size: 12px;
  line-height: 1.4;
}
.attachment-chip.uploading {
  border-style: dashed;
  border-color: rgba(0, 240, 255, 0.3);
  background: rgba(0, 240, 255, 0.04);
}
.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: rgba(239, 68, 68, 0.1);
}
.attachment-tray-note {
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.2);
  color: var(--warning);
  font-size: 12px;
  line-height: 1.55;
}
.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: rgba(15, 20, 35, 0.7);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  padding: 6px 12px;
  max-width: 800px;
  margin: 0 auto;
  transition: border-color 0.2s, box-shadow 0.2s;
  backdrop-filter: blur(8px);
}
.input-wrapper.drag-active {
  border-color: var(--accent);
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.15);
}
.attach-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  transition: color 0.18s ease;
}
.attach-btn:hover {
  color: var(--accent);
}
.attach-btn:disabled {
  opacity: 0.45;
  cursor: default;
}
.input-wrapper:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 240, 255, 0.08), 0 0 20px rgba(0, 240, 255, 0.1);
}
#msg-input {
  flex: 1;
  background: transparent;
  border: none;
  padding: 5px 0;
  color: var(--text-primary);
  font-size: 15px;
  font-family: inherit;
  line-height: 1.5;
  resize: none;
  outline: none;
  max-height: var(--input-max-height);
  min-height: 0;
  overflow-y: auto;
}
#msg-input::placeholder { color: var(--text-muted); }
.send-btn, .abort-btn {
  width: 32px; height: 32px;
  border: none;
  border-radius: 9px;
  cursor: pointer;
  display: flex;
  align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s, box-shadow 0.2s;
}
.send-btn:active, .abort-btn:active { transform: scale(0.92); }
.send-btn {
  background: linear-gradient(135deg, var(--accent), var(--purple));
  color: #fff;
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.2);
}
.send-btn:hover {
  box-shadow: var(--accent-glow-strong);
}
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }
.abort-btn {
  background: var(--danger);
  color: #fff;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.2);
}
.abort-btn:hover { box-shadow: 0 0 20px rgba(239, 68, 68, 0.3); }

/* === Option Picker === */
.option-picker {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 20, 35, 0.95);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 40px rgba(0, 240, 255, 0.06);
  backdrop-filter: blur(20px);
  padding: 16px;
  min-width: 280px;
  max-width: 380px;
  z-index: 50;
  animation: fadeIn 0.2s ease;
}
.option-picker-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
  padding: 0 4px;
  font-family: var(--font-display);
  letter-spacing: 0.5px;
}
.option-picker-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.12s, box-shadow 0.2s;
  margin-bottom: 4px;
  border: 1px solid transparent;
}
.option-picker-item:last-child { margin-bottom: 0; }
.option-picker-item:hover {
  background: rgba(0, 240, 255, 0.06);
  border-color: rgba(0, 240, 255, 0.1);
}
.option-picker-item.active {
  background: rgba(0, 240, 255, 0.08);
  border-color: var(--accent);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.1);
}
.option-picker-item-info { flex: 1; min-width: 0; }
.option-picker-item-label {
  font-weight: 600;
  font-size: 15px;
  color: var(--text-primary);
}
.option-picker-item-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}
.option-picker-item-check {
  color: var(--accent);
  font-size: 16px;
  font-weight: 700;
  flex-shrink: 0;
  text-shadow: 0 0 8px rgba(0, 240, 255, 0.4);
}

/* === 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(0, 0, 0, 0.6);
    z-index: 99;
  }
  .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; }
  .chat-title {
    font-size: 13px;
  }
  .chat-agent-menu {
    right: 10px;
    min-width: 138px;
  }
  .chat-cwd {
    max-width: 120px;
  }
}

@media (max-width: 480px) {
  .msg-avatar { width: 28px; height: 28px; font-size: 12px; border-radius: 8px; }
  .msg-bubble { padding: 10px 12px; font-size: 14px; border-radius: 14px; }
  .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: 12px; }
  .attach-btn { font-size: 14px; }
  .send-btn, .abort-btn { width: 34px; height: 34px; }
  .new-chat-btn { min-height: 44px; }
}

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

/* === Toast Notification === */
.toast-notification {
  position: fixed;
  top: 16px;
  right: 16px;
  background: linear-gradient(135deg, var(--success), #059669);
  color: #fff;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3), 0 0 20px rgba(16, 185, 129, 0.2);
  z-index: 200;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.3s, transform 0.3s;
  backdrop-filter: blur(8px);
}
.toast-notification.show {
  opacity: 1;
  transform: translateY(0);
}

/* === Session Unread Dot === */
.session-unread-dot {
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
  flex-shrink: 0;
  margin-left: 4px;
  box-shadow: 0 0 6px rgba(0, 240, 255, 0.5);
}

.sidebar-header { position: relative; }

/* === Chat CWD label === */
.chat-cwd {
  font-size: 11px;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.3);
  padding: 2px 8px;
  border-radius: 6px;
  flex-shrink: 0;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: default;
  border: 1px solid rgba(0, 240, 255, 0.06);
  font-family: 'SF Mono', monospace;
  font-size: 10px;
}

/* === Modal Overlay === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 16px;
  backdrop-filter: blur(8px);
}
.modal-panel {
  background: rgba(15, 20, 35, 0.95);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 60px rgba(0, 240, 255, 0.06);
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  backdrop-filter: blur(20px);
}
.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(--glass-border);
  flex-shrink: 0;
}
.modal-title {
  font-weight: 700;
  font-size: 16px;
  color: var(--text-primary);
  font-family: var(--font-display);
  letter-spacing: 1px;
}
.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: rgba(0, 240, 255, 0.08); color: var(--accent); }
.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(--glass-border);
  flex-shrink: 0;
}
.modal-field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.modal-field-row {
  display: flex;
  gap: 8px;
}
.modal-select {
  width: 100%;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.modal-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 8px rgba(0, 240, 255, 0.15);
}
.modal-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.modal-text-input {
  flex: 1;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.modal-text-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 8px rgba(0, 240, 255, 0.15);
}
.modal-btn-primary {
  padding: 9px 20px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  font-family: var(--font-display);
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: box-shadow 0.2s, transform 0.15s;
  box-shadow: var(--accent-glow);
}
.modal-btn-primary:hover {
  box-shadow: var(--accent-glow-strong);
  transform: translateY(-1px);
}
.modal-btn-secondary {
  padding: 9px 20px;
  background: rgba(0, 0, 0, 0.3);
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.modal-btn-secondary:hover {
  background: rgba(0, 240, 255, 0.06);
  border-color: rgba(0, 240, 255, 0.2);
}
.modal-loading, .modal-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 32px 0;
  font-size: 14px;
}

/* === 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);
  padding: 4px 0 8px;
  border-bottom: 1px solid var(--glass-border);
  margin-bottom: 8px;
  word-break: break-all;
  font-family: var(--font-display);
  letter-spacing: 0.5px;
}
