:root {
  --bg-main: #131314;
  --bg-sidebar: #1e1f20;
  --bg-surface: #282a2c;
  --bg-surface-hover: #333537;
  --bg-elevated: #222426;
  --bg-code: #1b1c1f;
  --bg-code-header: #25272b;
  --text-primary: #e3e3e3;
  --text-secondary: #c4c7c5;
  --text-muted: #8e918f;
  --border-subtle: rgba(255, 255, 255, 0.09);
  --border-focus: rgba(138, 180, 248, 0.55);
  --accent: #8ab4f8;
  --accent-bg: rgba(138, 180, 248, 0.14);
  --agent-accent: #c58af9;
  --agent-bg: rgba(197, 138, 249, 0.16);
  --danger: #f28b82;
  --danger-bg: rgba(242, 139, 130, 0.14);
  --success: #81c995;
  --sidebar-width: 284px;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 24px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-main);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

[hidden] {
  display: none !important;
}

button, input, textarea {
  font-family: inherit;
  color: inherit;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* ================= LOGIN PAGE ================= */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  background: radial-gradient(circle at 30% 20%, rgba(66, 133, 244, 0.11), transparent 45%),
              radial-gradient(circle at 75% 80%, rgba(155, 114, 203, 0.11), transparent 45%),
              var(--bg-main);
  overflow: auto;
}

.login-wrapper {
  width: 100%;
  max-width: 400px;
  padding: 20px;
}

.login-card {
  background: var(--bg-sidebar);
  border: 1px solid var(--border-subtle);
  border-radius: 24px;
  padding: 36px 28px 32px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

.login-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 68px;
  height: 68px;
  border-radius: 20px;
  background: var(--bg-surface);
  margin-bottom: 16px;
}

.login-title {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  background: linear-gradient(90deg, #8ab4f8, #c58af9, #f28b82);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.login-subtitle {
  margin: 4px 0 26px;
  font-size: 13px;
  color: var(--text-muted);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.input-group {
  position: relative;
  display: flex;
  align-items: center;
}

.input-group input {
  width: 100%;
  padding: 13px 44px 13px 16px;
  background: var(--bg-main);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}

.input-group input:focus {
  border-color: var(--border-focus);
}

.eye-btn {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: flex;
}
.eye-btn:hover {
  color: var(--text-primary);
}

.login-error {
  color: var(--danger);
  background: var(--danger-bg);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13px;
  text-align: left;
}

.login-submit {
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: 14px;
  background: var(--accent);
  color: #0b192e;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
}
.login-submit:hover {
  opacity: 0.92;
}
.login-submit:active {
  transform: scale(0.99);
}
.login-submit:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ================= APP SHELL ================= */
.app-shell {
  display: flex;
  height: 100dvh;
  width: 100vw;
  overflow: hidden;
  position: relative;
}

/* ================= SIDEBAR ================= */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  padding: 14px 12px 12px;
  transition: margin-left 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
  z-index: 30;
}

.app-shell.sidebar-collapsed .sidebar {
  margin-left: calc(-1 * var(--sidebar-width));
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.58);
  z-index: 25;
  opacity: 0;
  transition: opacity 0.22s ease;
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-name {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.mobile-only {
  display: none;
}

.new-chat-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 11px 16px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.new-chat-btn:hover {
  background: var(--bg-surface-hover);
  border-color: rgba(255, 255, 255, 0.16);
}

.search-box {
  position: relative;
  margin-top: 12px;
  margin-bottom: 10px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  padding: 9px 12px 9px 36px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: var(--bg-main);
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.15s;
}
.search-box input:focus {
  border-color: var(--border-focus);
}
.search-box input::placeholder {
  color: var(--text-muted);
}

.chat-lists {
  flex: 1;
  overflow-y: auto;
  padding-right: 2px;
}

.chat-section {
  margin-bottom: 14px;
}

.chat-section-title {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 6px 10px 6px;
}

.chat-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 8px 9px 12px;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.12s;
  position: relative;
  user-select: none;
}

.chat-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.chat-item.active {
  background: var(--accent-bg);
  color: #d2e3fc;
}

.chat-item-title {
  flex: 1;
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-item-menu-btn {
  opacity: 0;
  background: none;
  border: none;
  color: var(--text-secondary);
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.12s, background 0.12s;
}

.chat-item:hover .chat-item-menu-btn,
.chat-item.active .chat-item-menu-btn,
.chat-item-menu-btn:focus {
  opacity: 1;
}

.chat-item-menu-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
}

.empty-chats-hint {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  padding: 24px 12px;
}

.sidebar-footer {
  border-top: 1px solid var(--border-subtle);
  padding-top: 10px;
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.domain-badge {
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-left: 6px;
}

.logout-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1px solid transparent;
  color: var(--text-secondary);
  font-size: 12.5px;
  padding: 6px 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.logout-btn:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
}

/* ================= MAIN AREA ================= */
.main-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  background: var(--bg-main);
  position: relative;
}

/* ================= TOPBAR ================= */
.topbar {
  height: 60px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(19, 19, 20, 0.9);
  backdrop-filter: blur(10px);
  z-index: 15;
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
}

/* Model Picker */
.model-picker {
  position: relative;
}

.model-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 13px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-primary);
  font-size: 14.5px;
  font-weight: 500;
  cursor: pointer;
  max-width: 240px;
  transition: background 0.15s, border-color 0.15s;
}
.model-btn span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.model-btn:hover {
  background: var(--bg-surface);
}
.model-btn[aria-expanded="true"] {
  background: var(--bg-surface);
  border-color: var(--border-subtle);
}

.model-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 310px;
  max-width: calc(100vw - 32px);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 6px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
  z-index: 40;
}

.model-option {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 10px 12px;
  border-radius: 11px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: background 0.12s;
}
.model-option:hover {
  background: var(--bg-surface-hover);
}
.model-option.selected {
  background: var(--accent-bg);
}
.model-option-name {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.model-option.selected .model-option-name {
  color: var(--accent);
}
.model-option-desc {
  font-size: 11.5px;
  color: var(--text-muted);
}

/* Mode Switcher */
.mode-switch {
  display: inline-flex;
  background: var(--bg-sidebar);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}

.mode-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 13px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.mode-btn:hover {
  color: var(--text-primary);
}
.mode-btn.active[data-mode="chat"] {
  background: var(--accent-bg);
  color: var(--accent);
}
.mode-btn.active[data-mode="agent"] {
  background: var(--agent-bg);
  color: var(--agent-accent);
}

/* ================= VIEWPORT & WELCOME ================= */
.chat-viewport {
  flex: 1;
  overflow-y: auto;
  position: relative;
  padding: 20px 16px 24px;
  scroll-behavior: smooth;
}

.welcome-screen {
  max-width: 740px;
  margin: 6vh auto 0;
  text-align: center;
  padding: 0 8px;
}

.welcome-spark {
  margin-bottom: 14px;
}

.welcome-heading {
  margin: 0;
  font-size: clamp(26px, 4.5vw, 40px);
  font-weight: 500;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, #4285f4 0%, #9b72cb 50%, #d96570 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.welcome-sub {
  margin: 10px 0 32px;
  color: var(--text-muted);
  font-size: 14.5px;
}

.suggestion-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  text-align: left;
}

.suggestion-card {
  background: var(--bg-sidebar);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 16px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: background 0.15s, border-color 0.15s, transform 0.12s;
}
.suggestion-card:hover {
  background: var(--bg-surface);
  border-color: rgba(255, 255, 255, 0.16);
  transform: translateY(-1px);
}
.suggestion-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}
.suggestion-desc {
  font-size: 12.5px;
  color: var(--text-muted);
}

/* ================= MESSAGES ================= */
.messages-container {
  max-width: 820px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding-bottom: 16px;
}

.msg-row {
  display: flex;
  gap: 14px;
  animation: fadeIn 0.18s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg-row.user {
  justify-content: flex-end;
}

.msg-user-bubble {
  max-width: min(82%, 640px);
  background: var(--bg-surface);
  color: var(--text-primary);
  padding: 12px 18px;
  border-radius: 22px 22px 6px 22px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 15px;
}

.msg-row.assistant {
  align-items: flex-start;
}

.msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}

.msg-avatar.spinning svg {
  animation: spinSpark 2.2s linear infinite;
}

@keyframes spinSpark {
  0% { transform: rotate(0deg) scale(1); }
  50% { transform: rotate(180deg) scale(1.08); }
  100% { transform: rotate(360deg) scale(1); }
}

.msg-assistant-body {
  flex: 1;
  min-width: 0;
}

/* Agent Activity Steps */
.agent-steps {
  margin-bottom: 10px;
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.025);
  overflow: hidden;
}

.agent-steps-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 12.5px;
  color: var(--text-secondary);
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.agent-steps-summary::-webkit-details-marker {
  display: none;
}

.step-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--agent-accent);
  flex-shrink: 0;
}
.step-dot.active {
  animation: pulseDot 1.1s ease-in-out infinite;
}
.step-dot.done {
  background: var(--success);
}

@keyframes pulseDot {
  0%, 100% { opacity: 0.35; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1.15); }
}

.agent-steps-list {
  border-top: 1px solid var(--border-subtle);
  padding: 6px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.agent-step-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.agent-step-label {
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap;
}

.agent-step-detail {
  font-family: var(--font-mono);
  font-size: 11.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Typing placeholder */
.thinking-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 0;
  color: var(--text-muted);
  font-size: 13.5px;
}
.thinking-dots {
  display: inline-flex;
  gap: 4px;
}
.thinking-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: bounceDot 1.2s infinite ease-in-out;
}
.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounceDot {
  0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

/* ================= MARKDOWN CONTENT ================= */
.markdown-body {
  font-size: 15px;
  line-height: 1.65;
  color: var(--text-primary);
  word-break: break-word;
}

.markdown-body > *:first-child { margin-top: 0; }
.markdown-body > *:last-child { margin-bottom: 0; }

.markdown-body p {
  margin: 0 0 12px;
}

.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 {
  margin: 20px 0 10px;
  font-weight: 600;
  line-height: 1.3;
  color: #f1f3f4;
}
.markdown-body h1 { font-size: 1.45em; }
.markdown-body h2 { font-size: 1.25em; }
.markdown-body h3 { font-size: 1.1em; }

.markdown-body ul, .markdown-body ol {
  margin: 0 0 12px;
  padding-left: 24px;
}
.markdown-body li {
  margin: 4px 0;
}

.markdown-body blockquote {
  margin: 12px 0;
  padding: 8px 16px;
  border-left: 3px solid var(--accent);
  background: rgba(138, 180, 248, 0.06);
  border-radius: 0 10px 10px 0;
  color: var(--text-secondary);
}

.markdown-body a {
  color: var(--accent);
  text-decoration: none;
}
.markdown-body a:hover {
  text-decoration: underline;
}

.markdown-body hr {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: 18px 0;
}

.markdown-body code:not(pre code) {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 6px;
  border-radius: 6px;
  color: #e8eaed;
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  font-size: 13.5px;
  display: block;
  overflow-x: auto;
}
.markdown-body th, .markdown-body td {
  border: 1px solid var(--border-subtle);
  padding: 8px 12px;
  text-align: left;
}
.markdown-body th {
  background: var(--bg-sidebar);
  font-weight: 600;
}

/* Code Blocks */
.code-block {
  margin: 14px 0;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  background: var(--bg-code);
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--bg-code-header);
  font-size: 12px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
}

.code-lang {
  font-family: var(--font-mono);
  text-transform: lowercase;
}

.copy-code-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.copy-code-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}
.copy-code-btn.copied {
  color: var(--success);
}

.code-block pre {
  margin: 0;
  padding: 14px 16px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.55;
  color: #e6edf3;
}

/* Lightweight syntax highlight tokens */
.tok-kw { color: #c58af9; }
.tok-str { color: #81c995; }
.tok-com { color: #7e858c; font-style: italic; }
.tok-num { color: #f6ad55; }
.tok-fn { color: #8ab4f8; }
.tok-key { color: #7ee787; }

/* Message Footer Meta */
.msg-footer {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.msg-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.msg-action-btn:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
}

.msg-stopped-badge {
  color: #f6ad55;
}

/* Scroll to bottom FAB */
.scroll-bottom-btn {
  position: sticky;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  z-index: 10;
}
.scroll-bottom-btn:hover {
  background: var(--bg-surface-hover);
}

/* ================= COMPOSER ================= */
.composer-wrap {
  flex-shrink: 0;
  padding: 8px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--bg-main);
}

.composer-box {
  max-width: 820px;
  margin: 0 auto;
  background: var(--bg-sidebar);
  border: 1px solid var(--border-subtle);
  border-radius: 26px;
  padding: 12px 14px 10px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.18s, box-shadow 0.18s;
}

.composer-box:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 1px rgba(138, 180, 248, 0.18);
}

.composer-box.agent-mode:focus-within {
  border-color: rgba(197, 138, 249, 0.6);
  box-shadow: 0 0 0 1px rgba(197, 138, 249, 0.18);
}

.composer-box textarea {
  width: 100%;
  border: none;
  background: transparent;
  resize: none;
  outline: none;
  font-size: 15px;
  line-height: 1.5;
  max-height: 200px;
  overflow-y: auto;
  padding: 2px 0;
}
.composer-box textarea::placeholder {
  color: var(--text-muted);
}

.composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.composer-mode-tag {
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--accent-bg);
  color: var(--accent);
}
.composer-mode-tag.agent {
  background: var(--agent-bg);
  color: var(--agent-accent);
}

.send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #0b192e;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  margin-left: auto;
}
.send-btn:hover:not(:disabled) {
  opacity: 0.9;
}
.send-btn:active:not(:disabled) {
  transform: scale(0.95);
}
.send-btn:disabled {
  background: var(--bg-surface);
  color: var(--text-muted);
  cursor: not-allowed;
}

.stop-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid rgba(242, 139, 130, 0.35);
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  margin-left: auto;
  transition: background 0.15s;
}
.stop-btn:hover {
  background: rgba(242, 139, 130, 0.24);
}

.composer-hint {
  max-width: 820px;
  margin: 6px auto 0;
  text-align: center;
  font-size: 11.5px;
  color: var(--text-muted);
}

/* ================= CONTEXT MENU & MODAL ================= */
.context-menu {
  position: fixed;
  min-width: 175px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 5px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  z-index: 60;
}

.context-menu-item {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--text-primary);
  cursor: pointer;
  display: block;
}
.context-menu-item:hover {
  background: var(--bg-surface-hover);
}
.context-menu-item.danger {
  color: var(--danger);
}
.context-menu-item.danger:hover {
  background: var(--danger-bg);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 70;
}

.modal-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  padding: 22px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}

.modal-title {
  margin: 0 0 14px;
  font-size: 17px;
  font-weight: 600;
}

.modal-input {
  width: 100%;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-main);
  font-size: 14.5px;
  outline: none;
}
.modal-input:focus {
  border-color: var(--border-focus);
}

.modal-text {
  margin: 0;
  color: var(--text-secondary);
  font-size: 14px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

.modal-btn {
  padding: 8px 16px;
  border-radius: 10px;
  border: none;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
}
.modal-btn.secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
}
.modal-btn.secondary:hover {
  background: var(--bg-surface-hover);
}
.modal-btn.primary {
  background: var(--accent);
  color: #0b192e;
}
.modal-btn.danger {
  background: var(--danger);
  color: #2b0b0a;
}

/* ================= RESPONSIVE (MOBILE) ================= */
@media (max-width: 768px) {
  .mobile-only {
    display: inline-flex;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(84vw, 300px);
    min-width: 0;
    transform: translateX(-100%);
    margin-left: 0 !important;
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.5);
  }

  .app-shell.mobile-sidebar-open .sidebar {
    transform: translateX(0);
  }

  .app-shell.mobile-sidebar-open .sidebar-backdrop {
    display: block;
    opacity: 1;
  }

  .chat-item-menu-btn {
    opacity: 0.85;
  }

  .topbar {
    padding: 0 10px;
    gap: 6px;
  }

  .model-btn {
    padding: 6px 8px;
    font-size: 13.5px;
    max-width: 155px;
  }

  .mode-btn {
    padding: 5px 9px;
    font-size: 12px;
  }

  .suggestion-grid {
    grid-template-columns: 1fr;
  }

  .welcome-screen {
    margin-top: 2vh;
  }

  .msg-row {
    gap: 10px;
  }

  .msg-avatar {
    width: 26px;
    height: 26px;
  }

  .msg-user-bubble {
    max-width: 90%;
    padding: 10px 14px;
  }

  .composer-hint {
    display: none;
  }
}
