:root {
  --bg: #080c17;
  --bg-elevated: #0f1629;
  --bg-surface: #151e36;
  --bg-hover: #1c2847;
  --border: rgba(148, 163, 184, 0.16);
  --border-strong: rgba(148, 163, 184, 0.28);
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --accent: #38bdf8;
  --accent-strong: #6366f1;
  --accent-tint: rgba(99, 102, 241, 0.16);
  --accent-border: rgba(99, 102, 241, 0.44);
  --accent-grad: linear-gradient(135deg, #38bdf8 0%, #6366f1 55%, #a855f7 100%);
  --user-bubble: linear-gradient(135deg, #1d4ed8 0%, #4f46e5 100%);
  --assistant-bubble: #111930;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --code-bg: #070b14;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.42);
  --radius: 14px;
  --radius-sm: 10px;
  --sidebar-w: 300px;
}

[data-theme="light"] {
  --bg: #f1f5f9;
  --bg-elevated: #ffffff;
  --bg-surface: #f8fafc;
  --bg-hover: #e2e8f0;
  --border: rgba(15, 23, 42, 0.1);
  --border-strong: rgba(15, 23, 42, 0.2);
  --text: #0f172a;
  --text-muted: #475569;
  --accent: #4f46e5;
  --accent-strong: #4338ca;
  --accent-tint: rgba(79, 70, 229, 0.11);
  --accent-border: rgba(79, 70, 229, 0.4);
  --assistant-bubble: #ffffff;
  --code-bg: #0f172a;
  --shadow: 0 10px 28px rgba(15, 23, 42, 0.12);
}

/* Accent Color Themes (v1.10 Appearance) */
[data-accent="cyan"] {
  --accent: #22d3ee;
  --accent-strong: #0284c7;
  --accent-tint: rgba(34, 211, 238, 0.15);
  --accent-border: rgba(34, 211, 238, 0.44);
  --accent-grad: linear-gradient(135deg, #22d3ee 0%, #0284c7 100%);
  --user-bubble: linear-gradient(135deg, #0369a1 0%, #0284c7 100%);
}
[data-accent="emerald"] {
  --accent: #34d399;
  --accent-strong: #059669;
  --accent-tint: rgba(52, 211, 153, 0.15);
  --accent-border: rgba(52, 211, 153, 0.44);
  --accent-grad: linear-gradient(135deg, #34d399 0%, #059669 100%);
  --user-bubble: linear-gradient(135deg, #047857 0%, #059669 100%);
}
[data-accent="violet"] {
  --accent: #c084fc;
  --accent-strong: #7c3aed;
  --accent-tint: rgba(192, 132, 252, 0.16);
  --accent-border: rgba(192, 132, 252, 0.46);
  --accent-grad: linear-gradient(135deg, #c084fc 0%, #7c3aed 100%);
  --user-bubble: linear-gradient(135deg, #6d28d9 0%, #7c3aed 100%);
}
[data-accent="amber"] {
  --accent: #fbbf24;
  --accent-strong: #d97706;
  --accent-tint: rgba(251, 191, 36, 0.16);
  --accent-border: rgba(251, 191, 36, 0.46);
  --accent-grad: linear-gradient(135deg, #fbbf24 0%, #ea580c 100%);
  --user-bubble: linear-gradient(135deg, #b45309 0%, #d97706 100%);
}
[data-accent="rose"] {
  --accent: #fb7185;
  --accent-strong: #e11d48;
  --accent-tint: rgba(251, 113, 133, 0.16);
  --accent-border: rgba(251, 113, 133, 0.46);
  --accent-grad: linear-gradient(135deg, #fb7185 0%, #e11d48 100%);
  --user-bubble: linear-gradient(135deg, #be123c 0%, #e11d48 100%);
}

/* High-contrast WCAG-readable Accent overrides on Light Theme */
[data-theme="light"][data-accent="cyan"] {
  --accent: #0369a1;
  --accent-strong: #0284c7;
  --accent-tint: rgba(2, 132, 199, 0.11);
  --accent-border: rgba(2, 132, 199, 0.42);
}
[data-theme="light"][data-accent="emerald"] {
  --accent: #047857;
  --accent-strong: #059669;
  --accent-tint: rgba(5, 150, 105, 0.11);
  --accent-border: rgba(5, 150, 105, 0.42);
}
[data-theme="light"][data-accent="violet"] {
  --accent: #6d28d9;
  --accent-strong: #7c3aed;
  --accent-tint: rgba(124, 58, 237, 0.11);
  --accent-border: rgba(124, 58, 237, 0.42);
}
[data-theme="light"][data-accent="amber"] {
  --accent: #b45309;
  --accent-strong: #d97706;
  --accent-tint: rgba(217, 119, 6, 0.12);
  --accent-border: rgba(217, 119, 6, 0.45);
}
[data-theme="light"][data-accent="rose"] {
  --accent: #be123c;
  --accent-strong: #e11d48;
  --accent-tint: rgba(225, 29, 72, 0.11);
  --accent-border: rgba(225, 29, 72, 0.42);
}

/* Font Size Scaling (v1.10 Appearance) */
[data-font-size="sm"] { --app-font-size: 13.5px; }
[data-font-size="md"] { --app-font-size: 15px; }
[data-font-size="lg"] { --app-font-size: 16.5px; }

/* Compact Density Mode (v1.10 Appearance) */
[data-density="compact"] .msg-bubble { padding: 8px 12px; }
[data-density="compact"] .messages-container { gap: 8px; }
[data-density="compact"] .conv-item { padding: 7px 9px; gap: 2px; }
[data-density="compact"] .chat-stream { padding: 10px 12px; }
[data-density="compact"] .composer-bar { padding: 6px 12px calc(6px + env(safe-area-inset-bottom, 0px)); }

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: var(--app-font-size, 15px);
  line-height: 1.5;
}

.hidden { display: none !important; }
.muted { color: var(--text-muted); font-size: 0.88rem; }

/* Buttons & Inputs */
button, input, select, textarea {
  font: inherit;
  color: inherit;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.15s ease, background 0.15s ease;
  white-space: nowrap;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-full { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 0.82rem; }

.btn-primary {
  background: var(--accent-grad);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.32);
}
.btn-primary:hover:not(:disabled) { opacity: 0.94; }

.btn-secondary {
  background: var(--bg-surface);
  border-color: var(--border-strong);
  color: var(--text);
}
.btn-secondary:hover:not(:disabled) { background: var(--bg-hover); }

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-success {
  background: var(--success);
  color: #052e16;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text);
  cursor: pointer;
  font-size: 1rem;
  flex-shrink: 0;
  transition: background 0.15s ease;
}
.icon-btn:hover { background: var(--bg-hover); }
.icon-btn-danger:hover { border-color: var(--danger); color: var(--danger); }

input[type="text"],
input[type="password"],
input[type="number"],
input[type="search"],
select,
textarea {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
}

/* Status Dots */
.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.status-dot.online, .status-dot.idle { background: var(--success); }
.status-dot.offline, .status-dot.error { background: var(--danger); }
.status-dot.running {
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.7);
  animation: pulse-cyan 1.4s infinite;
}
.status-dot.waiting, .status-dot.waiting_for_user {
  background: var(--warning);
  box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.75);
  animation: pulse-amber 1.2s infinite;
}
.status-dot.canceled { background: var(--text-muted); }

@keyframes pulse-cyan {
  0% { box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.75); }
  70% { box-shadow: 0 0 0 8px rgba(56, 189, 248, 0); }
  100% { box-shadow: 0 0 0 0 rgba(56, 189, 248, 0); }
}
@keyframes pulse-amber {
  0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.8); }
  70% { box-shadow: 0 0 0 8px rgba(245, 158, 11, 0); }
  100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

/* App Shell */
.app-shell {
  display: flex;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
  position: relative;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 40;
  transition: transform 0.22s ease;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-icon { width: 32px; height: 32px; border-radius: 8px; }
.brand-text { display: flex; align-items: center; gap: 7px; }
.brand-title { font-weight: 800; font-size: 1.05rem; letter-spacing: -0.01em; }
.version-pill {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.16);
  color: var(--accent);
}

.sidebar-actions { padding: 4px 14px 10px; }

.sidebar-search {
  padding: 0 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-bottom: 1px solid var(--border);
}

.project-filter-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.project-select {
  flex: 1;
  min-width: 0;
  font-size: 0.84rem;
  font-weight: 600;
  padding: 7px 10px;
}
.icon-btn-sm {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  font-size: 0.92rem;
}
.icon-btn-sm.active {
  background: rgba(99, 102, 241, 0.25);
  border-color: var(--accent-strong);
  color: var(--text);
}

.project-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 8px 8px 4px;
  margin-top: 4px;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}
.project-group-header:first-child {
  margin-top: 0;
}
.project-group-name {
  display: flex;
  align-items: center;
  gap: 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.project-group-count {
  font-weight: 600;
  opacity: 0.75;
}
.project-group-add {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  border-radius: 6px;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.88rem;
  flex-shrink: 0;
}
.project-group-add:hover {
  background: var(--bg-surface);
  border-color: var(--border);
  color: var(--accent);
}
.conv-subagent-badge {
  font-size: 0.68rem;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(99, 102, 241, 0.22);
  color: var(--accent);
  flex-shrink: 0;
}

.filter-pills {
  display: flex;
  gap: 6px;
}
.pill {
  flex: 1;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}
.pill.active {
  background: rgba(99, 102, 241, 0.22);
  border-color: var(--accent-strong);
  color: var(--text);
}

.conversation-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.conv-item {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 10px 11px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.conv-item:hover { background: var(--bg-surface); }
.conv-item.active {
  background: rgba(99, 102, 241, 0.16);
  border-color: rgba(99, 102, 241, 0.45);
}

.conv-item-top {
  display: flex;
  align-items: center;
  gap: 8px;
}
.conv-item-title {
  font-weight: 600;
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.conv-item-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.conv-item-ws {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 165px;
}

.sidebar-footer {
  padding: 10px 12px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-elevated);
}
.footer-status-btn {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  cursor: pointer;
  text-align: left;
}
.footer-status-btn:hover { background: var(--bg-hover); }
.footer-status-info { min-width: 0; }
.footer-status-title {
  font-size: 0.82rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.footer-status-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.footer-icon-group { display: flex; gap: 6px; }

/* Main Panel */
.main-panel {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  position: relative;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  min-height: 58px;
  flex-shrink: 0;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}
.chat-heading { min-width: 0; flex: 1; }
.chat-title-row { display: flex; align-items: center; gap: 8px; }
.chat-title {
  font-size: 1rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-subtitle {
  font-size: 0.76rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}

.segmented {
  display: inline-flex;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
}
.seg-btn {
  border: none;
  background: transparent;
  padding: 5px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: 7px;
  cursor: pointer;
}
.seg-btn.active {
  background: var(--accent-strong);
  color: #fff;
}

/* Pending Interaction Banner */
.pending-banner {
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.2), rgba(234, 88, 12, 0.16));
  border-bottom: 1px solid rgba(245, 158, 11, 0.45);
  padding: 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}
.pending-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.pending-info { flex: 1; min-width: 200px; }
.pending-title { font-weight: 700; color: #fbbf24; font-size: 0.9rem; }
.pending-cmd {
  margin-top: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
  background: rgba(0, 0, 0, 0.35);
  padding: 6px 10px;
  border-radius: 7px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}
.pending-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.ask-q-form {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}
.ask-q-item {
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 9px;
  padding: 9px 11px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ask-q-label { font-size: 0.86rem; font-weight: 600; color: var(--text); }
.ask-q-options { display: flex; flex-direction: column; gap: 5px; }
.ask-q-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
}
.ask-q-opt:hover { background: rgba(255, 255, 255, 0.06); }
.ask-q-opt input { width: auto; flex-shrink: 0; }
.ask-q-other {
  font-size: 0.83rem !important;
  padding: 6px 9px !important;
}
.msg-media-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}
.msg-media-img {
  max-width: min(260px, 70vw);
  max-height: 220px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  object-fit: cover;
  cursor: pointer;
}
.msg-media-file {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.24);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
}
.msg-media-file:hover {
  background: rgba(0, 0, 0, 0.42);
}
.attach-chip-icon {
  font-size: 1rem;
  line-height: 1;
}
.composer-bar.drag-over {
  outline: 2px dashed var(--accent);
  outline-offset: -4px;
  background: rgba(56, 189, 248, 0.08);
}

/* Files Changed (giống Antigravity App) */
.files-changed-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  font-size: 0.78rem;
}
.files-changed-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  font-size: 0.85rem;
}
.file-diff-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.file-diff-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.file-diff-card summary {
  list-style: none;
  cursor: pointer;
  padding: 9px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.file-diff-card summary::-webkit-details-marker { display: none; }
.file-diff-main {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}
.file-diff-names {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.file-diff-name {
  font-weight: 700;
  font-size: 0.88rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-diff-path {
  font-size: 0.74rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 5px;
  flex-shrink: 0;
}
.file-badge.created { background: rgba(34, 197, 94, 0.18); color: var(--success); }
.file-badge.edited { background: rgba(56, 189, 248, 0.18); color: var(--accent); }
.file-badge.deleted { background: rgba(239, 68, 68, 0.2); color: var(--danger); }
.file-diff-stats {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  flex-shrink: 0;
}
.diff-stat-add { color: var(--success); font-weight: 700; }
.diff-stat-del { color: var(--danger); font-weight: 700; }
.diff-viewer {
  margin: 0;
  padding: 8px 10px;
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.32);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.76rem;
  line-height: 1.45;
  overflow-x: auto;
  max-height: 320px;
  overflow-y: auto;
}
.diff-line-add {
  display: block;
  background: rgba(34, 197, 94, 0.14);
  color: #86efac;
  padding: 0 4px;
}
.diff-line-del {
  display: block;
  background: rgba(239, 68, 68, 0.16);
  color: #fca5a5;
  padding: 0 4px;
}
.diff-line-ctx {
  display: block;
  color: var(--text-muted);
  padding: 0 4px;
}
[data-theme="light"] .diff-viewer { background: #0f172a; }
.file-diff-toolbar {
  display: flex;
  justify-content: flex-end;
  padding: 5px 10px;
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.14);
}

/* Quota Pill & Reset Time Display (v1.5) */
.quota-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text);
  flex-shrink: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.quota-pill.ok {
  background: rgba(34, 197, 94, 0.14);
  border-color: rgba(34, 197, 94, 0.35);
  color: var(--success);
}
.quota-pill.warn {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.4);
  color: var(--warning);
}
.quota-pill.low {
  background: rgba(239, 68, 68, 0.16);
  border-color: rgba(239, 68, 68, 0.45);
  color: var(--danger);
}
.quota-reset-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px;
  font-size: 0.76rem;
  color: var(--accent);
  margin-top: 4px;
  font-weight: 600;
}
.quota-bar-fill.warn { background: var(--warning); }
.quota-bar-fill.low { background: var(--danger); }

/* Desktop-Parity Settings Sections & Customizations (v1.8) */
.settings-section-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--accent);
  margin-top: 4px;
  margin-bottom: 2px;
}
.settings-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 10px 0;
}
.toggle-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border);
}
.toggle-item {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 0.85rem;
  cursor: pointer;
}
.toggle-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  accent-color: var(--accent-strong);
}
.custom-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--border);
}
.custom-item:last-child { border-bottom: none; }
.custom-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.84rem;
}
.custom-item-desc {
  font-size: 0.76rem;
  color: var(--text-muted);
  line-height: 1.4;
}
.custom-tag {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.16);
  color: var(--accent);
  flex-shrink: 0;
}
.custom-tag.ok { background: rgba(34, 197, 94, 0.16); color: var(--success); }
.custom-tag.err { background: rgba(239, 68, 68, 0.18); color: var(--danger); }
.meta-action-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.72rem;
  cursor: pointer;
  padding: 1px 5px;
  border-radius: 5px;
}
.meta-action-btn:hover {
  color: var(--accent);
  background: rgba(56, 189, 248, 0.12);
}

/* Chat Stream */
.chat-stream {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.welcome-state {
  max-width: 520px;
  margin: 8vh auto 0;
  text-align: center;
  padding: 28px 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
}
.welcome-logo { width: 64px; height: 64px; margin-bottom: 14px; }
.welcome-state h2 { font-size: 1.35rem; margin-bottom: 10px; }
.welcome-state p { color: var(--text-muted); font-size: 0.94rem; margin-bottom: 20px; }
.welcome-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.messages-container {
  max-width: var(--chat-max-w, 880px);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 24px;
}

.msg-row {
  display: flex;
  flex-direction: column;
  max-width: 100%;
}
.msg-row.user { align-items: flex-end; }
.msg-row.assistant { align-items: flex-start; }
.msg-row.system { align-items: center; }

.msg-bubble {
  max-width: 100%;
  padding: 12px 15px;
  border-radius: var(--radius);
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.msg-row.user .msg-bubble {
  max-width: min(760px, 92%);
  background: var(--user-bubble);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}
.msg-row.assistant .msg-bubble {
  background: var(--assistant-bubble);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  width: 100%;
  max-width: 100%;
}
.msg-row.error .msg-bubble {
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid rgba(239, 68, 68, 0.45);
  color: #fecaca;
}
[data-theme="light"] .msg-row.error .msg-bubble {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(220, 38, 38, 0.38);
  color: #991b1b;
}

.msg-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 4px;
  padding: 0 4px;
}

.slash-tag {
  display: inline-block;
  font-size: 0.74rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.22);
  margin-right: 5px;
  margin-bottom: 4px;
}

/* Thinking & Activity Cards */
.thinking-box {
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(99, 102, 241, 0.06);
  overflow: hidden;
}
.thinking-box summary {
  padding: 7px 11px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}
.thinking-content {
  padding: 0 11px 10px;
  font-size: 0.82rem;
  color: var(--text-muted);
  white-space: pre-wrap;
  max-height: 260px;
  overflow-y: auto;
}

.activity-card {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  overflow: hidden;
}
.activity-card summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.83rem;
  list-style: none;
}
.activity-card summary::-webkit-details-marker { display: none; }
.activity-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--bg-surface);
  color: var(--accent);
  flex-shrink: 0;
}
.activity-summary-text {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.activity-status {
  font-size: 0.72rem;
  color: var(--text-muted);
  flex-shrink: 0;
}
.activity-output {
  margin: 0;
  padding: 10px 12px;
  background: var(--code-bg);
  color: #cbd5e1;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  overflow-x: auto;
  max-height: 280px;
  white-space: pre-wrap;
  border-top: 1px solid var(--border);
}

.running-indicator {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 9px 14px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.32);
  color: var(--accent);
  font-size: 0.84rem;
  font-weight: 600;
  align-self: flex-start;
}

/* Markdown Styling */
.md-p { margin: 0 0 8px; }
.md-p:last-child { margin-bottom: 0; }
.md-h1, .md-h2, .md-h3, .md-h4 { margin: 12px 0 6px; font-weight: 700; line-height: 1.3; }
.md-h1 { font-size: 1.25rem; }
.md-h2 { font-size: 1.12rem; }
.md-h3 { font-size: 1.02rem; }
.md-list { margin: 6px 0 10px 20px; }
.md-list li { margin-bottom: 3px; }
.md-quote {
  border-left: 3px solid var(--accent);
  padding: 4px 12px;
  margin: 8px 0;
  color: var(--text-muted);
  background: rgba(56, 189, 248, 0.06);
  border-radius: 0 8px 8px 0;
}
.md-hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }
.md-link { color: var(--accent); text-decoration: underline; }
.md-file-ref {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.84em;
  background: rgba(99, 102, 241, 0.18);
  padding: 1px 6px;
  border-radius: 5px;
}
.md-inline-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.86em;
  background: rgba(148, 163, 184, 0.18);
  padding: 1px 5px;
  border-radius: 5px;
}
.md-code-block {
  margin: 10px 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--code-bg);
}
.md-code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 10px;
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.75rem;
  color: #94a3b8;
}
.md-copy-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #e2e8f0;
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 0.72rem;
  cursor: pointer;
}
.md-copy-btn:hover { background: rgba(255, 255, 255, 0.18); }
.md-code-block pre {
  padding: 11px 12px;
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
  line-height: 1.45;
  color: #e2e8f0;
}
.md-table-wrap { overflow-x: auto; margin: 10px 0; }
.md-table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
.md-table th, .md-table td {
  border: 1px solid var(--border);
  padding: 6px 9px;
  text-align: left;
}
.md-table th { background: var(--bg-surface); }

/* Scroll bottom pill */
.scroll-bottom-btn {
  position: absolute;
  right: 22px;
  bottom: 148px;
  z-index: 20;
  background: var(--bg-elevated);
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 6px 13px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  box-shadow: var(--shadow);
  cursor: pointer;
}

/* Composer */
.composer-bar {
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  padding: 8px 14px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  flex-shrink: 0;
}
.quick-chips {
  max-width: var(--chat-max-w, 880px);
  margin: 0 auto 7px;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}
.quick-chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 11px;
  font-size: 0.78rem;
  color: var(--text-muted);
  cursor: pointer;
}
.chip:hover { border-color: var(--accent); color: var(--text); }

.attachment-bar {
  max-width: var(--chat-max-w, 880px);
  margin: 0 auto 7px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.attach-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  font-size: 0.78rem;
}
.attach-chip img { width: 26px; height: 26px; object-fit: cover; border-radius: 4px; }
.attach-remove { background: none; border: none; color: var(--danger); cursor: pointer; font-weight: 700; }

.composer-form {
  max-width: var(--chat-max-w, 880px);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.composer-controls-top {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.model-select {
  max-width: 310px;
  min-width: 0;
  padding: 6px 10px !important;
  font-size: 0.82rem !important;
}
.attach-btn { width: 32px; height: 32px; font-size: 0.92rem; }

.composer-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
#messageInput {
  flex: 1;
  resize: none;
  max-height: 150px;
  min-height: 42px;
  line-height: 1.4;
}
.send-btn { height: 42px; padding: 0 18px; }

/* Modals */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  z-index: 100;
}
.modal-card {
  width: 100%;
  max-width: 520px;
  max-height: 90dvh;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-card.modal-lg { max-width: 680px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.modal-body {
  padding: 16px 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
}
.modal-footer-inline { display: flex; justify-content: flex-end; margin-top: 8px; }

.modal-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  padding: 0 14px;
  gap: 4px;
  overflow-x: auto;
}
.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 11px 12px;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
}
.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.tab-pane { display: flex; flex-direction: column; gap: 14px; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 0.84rem; font-weight: 600; color: var(--text-muted); }
.field-grid { display: grid; grid-template-columns: 1fr 140px; gap: 10px; }
.inline-row { display: flex; gap: 8px; }

/* Update Panel (TinhToanThuChi Style) */
.update-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.stat-box {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
}
.stat-label { font-size: 0.74rem; color: var(--text-muted); }
.stat-value { font-size: 1.05rem; font-weight: 700; margin-top: 3px; }
.update-actions-row { display: flex; gap: 10px; flex-wrap: wrap; }

.packages-box {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.84rem;
}
.pkg-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  border-bottom: 1px dashed var(--border);
}
.pkg-row:last-child { border-bottom: none; }

.log-wrapper {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--code-bg);
}
.log-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 12px;
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.8rem;
  font-weight: 600;
}
.badge-live {
  background: rgba(34, 197, 94, 0.2);
  color: #4ade80;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
}
.log-terminal {
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  line-height: 1.45;
  color: #e2e8f0;
  max-height: 260px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.diag-details {
  font-size: 0.82rem;
  color: var(--text-muted);
}
.diag-details summary { cursor: pointer; font-weight: 600; }
.scanned-paths {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.76rem;
}

/* Quota bars */
.quota-group {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.quota-bar-track {
  height: 8px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.2);
  overflow: hidden;
}
.quota-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent-grad);
}

/* PIN Overlay */
.pin-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.pin-card {
  width: 100%;
  max-width: 360px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  padding: 28px 22px;
  text-align: center;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.pin-logo { width: 56px; height: 56px; margin: 0 auto; }
.pin-form { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.form-error { color: #f87171; font-size: 0.84rem; font-weight: 600; }

/* Toasts */
.toast-container {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(360px, calc(100vw - 28px));
}
.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-left: 4px solid var(--accent);
  color: var(--text);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-size: 0.86rem;
}
.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--success); }

.empty-hint {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.86rem;
  padding: 20px 12px;
}

/* =========================================================
   DESKTOP-PARITY SETTINGS MODAL & MOBILE BOTTOM-SHEET (v1.10)
   ========================================================= */
.modal-card.modal-settings {
  max-width: 920px;
  height: min(86dvh, 740px);
}
.sheet-handle {
  width: 40px;
  height: 4px;
  border-radius: 999px;
  background: var(--border-strong);
  margin: 8px auto 0;
  flex-shrink: 0;
}
.settings-modal-header {
  gap: 10px;
  flex-shrink: 0;
}
.settings-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.settings-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.settings-search-input {
  width: 190px !important;
  padding: 6px 10px !important;
  font-size: 0.82rem !important;
}
.settings-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--accent);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
}
.settings-back-btn:hover { background: var(--bg-hover); }

.settings-shell {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.settings-nav {
  width: 248px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.14);
  overflow-y: auto;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
[data-theme="light"] .settings-nav {
  background: var(--bg-surface);
}
.settings-nav-group-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 6px 10px 4px;
}
.settings-nav-divider {
  border-top: 1px solid var(--border);
  margin: 8px 6px;
}
.settings-nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: background 0.14s ease, border-color 0.14s ease;
}
.settings-nav-item:hover {
  background: var(--bg-surface);
}
.settings-nav-item.active {
  background: var(--accent-tint);
  border-color: var(--accent-border);
}
.snav-icon {
  font-size: 1.05rem;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  flex-shrink: 0;
}
.settings-nav-item.active .snav-icon {
  color: var(--accent);
}
.snav-icon svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.snav-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.snav-title {
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.25;
}
.snav-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.snav-chevron {
  color: var(--text-muted);
  font-size: 1.15rem;
  line-height: 1;
  opacity: 0.65;
  flex-shrink: 0;
}

.settings-content {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 16px 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.settings-pane-head {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.settings-pane-head h4 {
  font-size: 1.12rem;
  font-weight: 700;
}
.settings-form-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.settings-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 14px;
  display: flex;
  flex-direction: column;
  gap: 11px;
}
.settings-action-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
.field-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.field-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

/* Account Summary Card */
.account-summary-card {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
.account-summary-info {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}
.account-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent-grad);
  color: #fff;
  font-weight: 800;
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.account-name {
  font-weight: 700;
  font-size: 0.92rem;
}

/* Toggle Switch Rows (Desktop/iOS style) */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-top: 1px dashed var(--border);
}
.switch-row:first-child,
.settings-section-title + .switch-row {
  border-top: none;
  padding-top: 2px;
}
.switch-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.switch-label {
  font-size: 0.87rem;
  font-weight: 600;
  color: var(--text);
}
.switch-desc {
  font-size: 0.76rem;
  color: var(--text-muted);
  line-height: 1.35;
}
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
  cursor: pointer;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.switch-slider {
  position: absolute;
  inset: 0;
  background: rgba(148, 163, 184, 0.32);
  border-radius: 999px;
  transition: background 0.18s ease;
}
.switch-slider::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: #ffffff;
  transition: transform 0.18s ease;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}
.switch input:checked + .switch-slider {
  background: var(--accent-strong);
}
.switch input:checked + .switch-slider::before {
  transform: translateX(20px);
}

/* Appearance Choice Cards & Accent Swatches */
.theme-card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.choice-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.12s ease;
}
.choice-card:hover { background: var(--bg-hover); }
.choice-card.active {
  border-color: var(--accent);
  background: var(--accent-tint);
  box-shadow: 0 0 0 1px var(--accent);
}
.choice-icon { font-size: 1.35rem; }
.choice-title { font-size: 0.86rem; font-weight: 700; }
.choice-sub { font-size: 0.72rem; color: var(--text-muted); }

.accent-swatch-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.accent-swatch {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}
.accent-swatch.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
  background: var(--accent-tint);
}
.swatch-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

/* Shortcuts List & Recorder */
.shortcuts-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.shortcut-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}
.shortcut-info {
  min-width: 0;
  flex: 1;
}
.shortcut-name {
  font-size: 0.86rem;
  font-weight: 600;
}
.shortcut-desc {
  font-size: 0.74rem;
  color: var(--text-muted);
}
.shortcut-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.shortcut-key-btn {
  min-width: 92px;
  padding: 5px 10px;
  border-radius: 7px;
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
}
.shortcut-key-btn.recording {
  border-color: var(--warning);
  color: var(--warning);
  background: rgba(245, 158, 11, 0.14);
}
.shortcut-clear-btn {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.76rem;
}
.shortcut-clear-btn:hover { color: var(--danger); border-color: var(--danger); }

/* Notification Permission Card */
.notify-perm-card {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}
input[type="range"] {
  width: 100%;
  accent-color: var(--accent-strong);
  cursor: pointer;
}

/* Models Catalog */
.models-catalog-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.model-cat-item {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.model-cat-item.is-hidden-model { opacity: 0.62; }
.model-cat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.model-cat-title {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 0.87rem;
  font-weight: 700;
}
.model-cat-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Feedback Star Rating & History */
.rating-stars {
  display: inline-flex;
  gap: 4px;
  padding: 4px 0;
}
.star-btn {
  background: none;
  border: none;
  font-size: 1.45rem;
  color: var(--border-strong);
  cursor: pointer;
  line-height: 1;
  transition: transform 0.1s ease, color 0.12s ease;
}
.star-btn:hover { transform: scale(1.12); }
.star-btn.active { color: #fbbf24; }

.feedback-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
}
.feedback-item:last-child { border-bottom: none; }
.feedback-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

/* Responsive Mobile Drawer & Desktop Sidebar Collapse */
@media (min-width: 821px) {
  .app-shell.sidebar-collapsed .sidebar {
    width: 0;
    min-width: 0;
    border-right: none;
    overflow: hidden;
  }
}
.mobile-only { display: none; }
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.6);
  z-index: 35;
}

@media (max-width: 820px) {
  .mobile-only { display: inline-flex; }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(85vw, 320px);
    transform: translateX(-105%);
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }
  .topbar {
    padding: 8px 10px;
    flex-wrap: wrap;
    gap: 6px 8px;
  }
  .topbar-left { flex: 1 1 100%; }
  .topbar-right {
    width: 100%;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 6px;
  }
  .chat-stream { padding: 12px 10px; }
  .composer-bar { padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px)); }
  .update-summary-grid { grid-template-columns: 1fr; }
  .field-grid,
  .field-grid-2,
  .field-grid-3 { grid-template-columns: 1fr; }
  .composer-controls-top { gap: 6px; }
  .model-select { max-width: none; flex: 1 1 180px; }
  .quota-pill {
    order: 3;
    flex: 1 1 100%;
    justify-content: center;
    padding: 5px 8px;
    font-size: 0.74rem;
    white-space: normal;
    text-align: center;
    line-height: 1.3;
  }
  .scroll-bottom-btn { right: 12px; bottom: 196px; }

  /* Mobile Settings Bottom-Sheet Drill-Down (Matching Desktop Mobile Screenshot) */
  .modal.modal-sheet {
    align-items: flex-end;
    padding: 0;
  }
  .modal-card.modal-settings {
    max-width: 100%;
    height: 92dvh;
    max-height: 92dvh;
    border-radius: 22px 22px 0 0;
    border-bottom: none;
  }
  .settings-modal-header {
    padding: 10px 14px 12px;
  }
  .settings-search-input { display: none; }
  .settings-nav {
    width: 100%;
    border-right: none;
    background: transparent;
    padding: 8px 12px calc(18px + env(safe-area-inset-bottom, 0px));
    gap: 2px;
  }
  .settings-nav-item {
    padding: 13px 12px;
    border-radius: 12px;
    border: none;
    background: transparent;
  }
  .settings-nav-item.active {
    background: transparent;
    border-color: transparent;
  }
  .settings-nav-item:active {
    background: var(--bg-surface);
  }
  .snav-title { font-size: 1rem; font-weight: 500; }
  .snav-sub { font-size: 0.76rem; }
  .snav-chevron { font-size: 1.35rem; }

  .settings-shell:not(.detail-open) .settings-content {
    display: none;
  }
  .settings-shell.detail-open .settings-nav {
    display: none;
  }
  .settings-content {
    padding: 12px 14px calc(24px + env(safe-area-inset-bottom, 0px));
  }
  .theme-card-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .choice-card { padding: 10px 4px; }
}
