:root {
  --sidebar-width: 260px;
  --bg: #212121;
  --bg-sidebar: #171717;
  --bg-hover: #2a2a2a;
  --bg-input: #2f2f2f;
  --bg-user-bubble: #2f2f2f;
  --bg-assistant: transparent;
  --border: #3a3a3a;
  --text: #ececec;
  --text-muted: #9b9b9b;
  --text-dim: #848484;
  --accent: #10a37f;
  --accent-hover: #0e8c6d;
  --user-text: #ececec;
  --tool-bg: #1a1a1a;
  --tool-border: #333;
  --thinking-bg: #1c1c1c;
  --thinking-border: #444;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; width: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", "Noto Sans CJK SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

/* ---------- Layout ---------- */
.app {
  display: flex;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  position: relative;
  background: var(--bg);
}

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100%;
  transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 100;
  overflow: hidden;
  position: relative;
}

/* Sidebar collapsed state on desktop */
.app:not(.sidebar-open) .sidebar {
  margin-left: calc(-1 * var(--sidebar-width));
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  background: var(--bg);
  position: relative;
}

/* ---------- Sidebar Inner ---------- */
.sidebar-top {
  padding: 10px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}
.btn-new {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-start;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  transition: background .15s;
}
.btn-new:hover { background: var(--bg-hover); }

.sidebar-search {
  padding: 0 10px 8px;
  flex-shrink: 0;
}
.sidebar-search input {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 13px;
  outline: none;
}
.sidebar-search input:focus { border-color: var(--text-dim); }

.session-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 8px 16px;
}
.session-item {
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
  transition: background .12s;
  word-break: break-word;
  position: relative;
}
.session-item:hover { background: var(--bg-hover); }
.session-item.active { background: var(--bg-hover); }
.session-item .title {
  flex: 1;
  min-width: 0;
  line-height: 1.35;
}
.session-item .session-item-name {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.session-item .session-item-name > span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.session-running-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  line-height: 1;
  color: var(--accent, #3b82f6);
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.25);
  padding: 2px 5px;
  border-radius: 9999px;
  font-weight: 500;
  flex-shrink: 0;
}
.session-running-badge .spinner-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--accent, #3b82f6);
  animation: pulse-dot 1.2s infinite ease-in-out;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.2); }
}
.session-item .meta {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.btn-delete-session {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-dim);
  border-radius: 6px;
  cursor: pointer;
  opacity: 0;
  flex-shrink: 0;
  transition: opacity 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}
.session-item:hover .btn-delete-session,
.session-item:focus-within .btn-delete-session {
  opacity: 1;
}
.btn-delete-session:hover {
  color: var(--danger, #ef4444);
  background: rgba(239, 68, 68, 0.15);
}

/* Sidebar Resizer */
.sidebar-resizer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 6px;
  cursor: col-resize;
  z-index: 102;
  user-select: none;
  transition: background-color 0.15s ease;
}
.sidebar-resizer::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 2px;
  height: 100%;
  background: transparent;
  transition: background-color 0.15s ease;
}
.sidebar-resizer:hover::after,
.is-resizing .sidebar-resizer::after {
  background: var(--accent);
}
.sidebar-resizer:hover,
.is-resizing .sidebar-resizer {
  background: rgba(16, 163, 127, 0.12);
}

.is-resizing,
.is-resizing * {
  user-select: none !important;
  cursor: col-resize !important;
}
.is-resizing .sidebar {
  transition: none !important;
}
/* Message Images */
.msg-images {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.msg.user .msg-images {
  justify-content: flex-end;
}
.msg-image-thumb {
  width: 90px;
  height: 90px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.msg-image-thumb:hover {
  transform: scale(1.04);
  opacity: 0.9;
}

/* Image Lightbox */
.image-lightbox {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  cursor: zoom-out;
  animation: fade 0.15s ease;
}
.image-lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  cursor: default;
}
.lightbox-close {
  position: absolute;
  top: 20px;
  right: 24px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #fff;
  font-size: 24px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
}
.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

.sidebar-search-empty {
  color: var(--text-dim);
  font-size: 12.5px;
  padding: 16px 12px;
  text-align: center;
}

.sidebar-bottom {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  padding: 10px 12px;
  padding-bottom: max(10px, env(safe-area-inset-bottom, 10px));
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-sidebar);
}
.sidebar-bottom a { color: var(--text-muted); text-decoration: none; }
.sidebar-bottom a:hover { color: var(--text); }
.sidebar-bottom-meta {
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar-bottom-links {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-link-sep {
  color: var(--text-dim);
  font-size: 11px;
}
.app-version {
  font-size: 11px;
  color: var(--text-muted);
  user-select: none;
}
.conn-status {
  display: inline-flex;
  align-items: center;
  user-select: none;
  transition: opacity 0.15s ease;
}
.conn-status[style*="cursor: pointer"]:hover {
  opacity: 0.85;
}

/* ---------- Sidebar Overlay (mobile-only drawer backdrop) ---------- */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 99;
  backdrop-filter: blur(2px);
  transition: opacity 0.25s ease;
}

/* ---------- Topbar ---------- */
.topbar {
  height: 56px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  background: var(--bg);
  z-index: 20;
  position: sticky;
  top: 0;
  flex-shrink: 0;
}
.topbar .session-name {
  font-size: 15px;
  color: var(--text);
  font-weight: 500;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 4px;
}

.btn-toggle-sidebar {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border-radius: 8px;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.btn-toggle-sidebar:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.model-pill-container {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.model-pill {
  font-size: 12px;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  background: var(--bg-input);
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s, background 0.15s, opacity 0.15s;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.model-pill:hover:not(:disabled) { color: var(--text); border-color: var(--text-dim); }
.model-pill:disabled { opacity: 0.55; cursor: not-allowed; }

.model-pill-name {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-pill-badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.18);
  color: #60a5fa;
  font-weight: 600;
  line-height: 1.3;
  flex-shrink: 0;
}

.thinking-pill {
  font-size: 12px;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 10px;
  cursor: pointer;
  background: var(--bg-input);
  white-space: nowrap;
  transition: all 0.15s ease;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.thinking-pill:hover:not(:disabled) { color: var(--text); border-color: var(--accent); background: var(--bg-hover); }
.thinking-pill:disabled { opacity: 0.55; cursor: not-allowed; }
.thinking-pill .thinking-icon { font-size: 13px; line-height: 1; }
.thinking-pill .thinking-label { font-weight: 500; }

.btn-ghost {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 8px;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }

/* ---------- Chat ---------- */
.chat {
  flex: 1;
  overflow-y: auto;
  scroll-behavior: smooth;
  padding: 24px 0;
}
.chat-inner {
  max-width: 820px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.msg { display: flex; flex-direction: column; gap: 8px; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; } }

.msg.user {
  align-items: flex-end;
}
.msg.user .role-tag {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 600;
  letter-spacing: .3px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
  padding-right: 4px;
}
.msg.user .bubble {
  background: var(--bg-user-bubble);
  color: var(--user-text);
  padding: 12px 18px;
  border-radius: 18px;
  max-width: 85%;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.55;
  font-size: 15px;
}
.msg.user .bubble.steer {
  border: 1px solid var(--accent);
  background: rgba(16, 163, 127, 0.12);
}
.steer-badge {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 4px;
}
.msg.assistant { align-items: stretch; }
.msg.assistant .role-tag {
  font-size: 12px; color: var(--text-dim); font-weight: 600; letter-spacing: .3px;
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 2px;
}
.role-name {
  font-weight: 600;
}
.msg-time {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: 0;
  user-select: none;
}
.msg-duration {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 1px 7px;
  border-radius: 999px;
  user-select: none;
}
.msg-duration.live {
  color: var(--accent);
  background: rgba(16, 163, 127, 0.12);
  border-color: rgba(16, 163, 127, 0.25);
  animation: pulse-live-tag 1.5s infinite ease-in-out;
}
.thinking-time {
  font-size: 11px;
  color: var(--text-muted);
}
.thinking-duration {
  font-size: 11px;
  font-weight: 500;
  color: #c4b5fd;
  background: rgba(167, 139, 250, 0.12);
  border: 1px solid rgba(167, 139, 250, 0.25);
  padding: 1px 8px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  user-select: none;
}
.thinking-duration.live {
  color: var(--accent);
  background: rgba(16, 163, 127, 0.12);
  border-color: rgba(16, 163, 127, 0.3);
  animation: pulse-live-tag 1.5s infinite ease-in-out;
}
.tool-time {
  font-size: 11px;
  color: var(--text-muted);
}
.tool-duration {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-dim);
  background: #252525;
  border: 1px solid var(--border);
  padding: 1px 7px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  user-select: none;
}
.tool-duration.live {
  color: #fbbf24;
  background: rgba(234, 179, 8, 0.12);
  border-color: rgba(234, 179, 8, 0.25);
  animation: pulse-live-tag 1.5s infinite ease-in-out;
}

@keyframes pulse-live-tag {
  0%, 100% { opacity: 0.85; }
  50% { opacity: 1; }
}

.msg.assistant .content {
  font-size: 15px; line-height: 1.65; color: var(--text);
  max-width: 100%; min-width: 0;
}
.msg.assistant .content p {
  margin-bottom: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg.assistant .content p:last-child { margin-bottom: 0; }
.msg.assistant .content pre {
  background: #0d0d0d; border: 1px solid var(--border);
  border-radius: 10px; padding: 14px 16px; overflow-x: auto;
  margin: 12px 0; font-size: 13px; line-height: 1.5;
  font-family: "SF Mono", Menlo, Consolas, monospace;
}
.msg.assistant .content code {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.88em;
  background: #2a2a2a; padding: 2px 6px; border-radius: 4px;
}
.msg.assistant .content pre code { background: transparent; padding: 0; }

/* Code block wrapper and copy button */
.code-block-wrapper {
  position: relative;
  background: #0d0d0d;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin: 12px 0;
  overflow: hidden;
}
.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: #181818;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-dim);
  user-select: none;
}
.code-block-lang {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
  text-transform: lowercase;
  color: var(--text-muted);
}
.code-block-wrapper pre {
  margin: 0 !important;
  border: none !important;
  border-radius: 0 !important;
  background: transparent !important;
  padding: 12px 14px;
  overflow-x: auto;
}

.btn-copy-code, .btn-copy-msg, .btn-copy-tool {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all 0.15s ease;
  user-select: none;
}
.btn-copy-msg, .btn-copy-tool {
  color: var(--text-dim);
}
.btn-copy-msg {
  margin-left: auto;
}
.btn-copy-code:hover, .btn-copy-msg:hover, .btn-copy-tool:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.btn-copy-code.copied, .btn-copy-msg.copied, .btn-copy-tool.copied {
  color: var(--accent);
}
.btn-copy-code svg, .btn-copy-msg svg, .btn-copy-tool svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
.btn-copy-code svg *, .btn-copy-msg svg *, .btn-copy-tool svg * {
  fill: none;
}
.msg.assistant .content ul, .msg.assistant .content ol { margin: 8px 0 12px 24px; }
.msg.assistant .content li { margin: 4px 0; }
.msg.assistant .content h1, .msg.assistant .content h2, .msg.assistant .content h3,
.msg.assistant .content h4, .msg.assistant .content h5, .msg.assistant .content h6 {
  margin: 16px 0 10px; line-height: 1.3;
}
.msg.assistant .content h1 { font-size: 20px; }
.msg.assistant .content h2 { font-size: 18px; }
.msg.assistant .content h3 { font-size: 16px; }
.msg.assistant .content h4 { font-size: 14.5px; }
.msg.assistant .content h5 { font-size: 13.5px; }
.msg.assistant .content h6 { font-size: 12.5px; }
.msg.assistant .content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}
.msg.assistant .content del {
  text-decoration: line-through;
  opacity: 0.7;
}
.msg.assistant .content .task-list-item-checkbox {
  margin-right: 6px;
  vertical-align: -2px;
  accent-color: var(--accent);
}
.msg.assistant .content a { color: #4ea1ff; text-decoration: none; }
.msg.assistant .content a:hover { text-decoration: underline; }
.msg.assistant .content table {
  border-collapse: collapse; margin: 12px 0; font-size: 13px; width: 100%;
}
.msg.assistant .content th, .msg.assistant .content td {
  border: 1px solid var(--border); padding: 8px 12px;
}
.msg.assistant .content blockquote {
  border-left: 3px solid var(--border); padding-left: 14px; color: var(--text-muted);
  margin: 10px 0;
}

/* Tool call blocks */
.tool-block {
  background: var(--tool-bg);
  border: 1px solid var(--tool-border);
  border-radius: 10px;
  margin: 10px 0;
  font-size: 13px;
  overflow: hidden;
}
.tool-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; cursor: pointer; user-select: none;
  background: #1f1f1f;
}
.tool-head .ic { color: var(--accent); font-size: 12px; }
.tool-head .name { font-weight: 600; color: var(--text); }
.tool-head .args { color: var(--text-muted); font-family: monospace; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool-head .state { font-size: 11px; color: var(--text-dim); padding: 2px 8px; background: #2a2a2a; border-radius: 999px; }
.tool-head .state.error { color: var(--danger); background: #3a1a1a; }
.tool-body {
  padding: 12px 14px; border-top: 1px solid var(--tool-border);
  max-height: 380px; overflow-y: auto;
  font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 12px; color: #cfcfcf;
}
.tool-section {
  margin-bottom: 12px;
}
.tool-section:last-child {
  margin-bottom: 0;
}
.tool-section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 6px;
}
.tool-section-title {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--text-muted);
}
.tool-running-pulse {
  font-size: 11px; color: var(--accent);
  animation: pulse-op 1.4s infinite ease-in-out;
}
@keyframes pulse-op {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}
.tool-code-block, .tool-output-block {
  margin: 0; padding: 8px 12px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  white-space: pre-wrap; word-break: break-word;
  font-family: inherit; font-size: 12px; line-height: 1.45;
  color: #e5e5e5;
}
.tool-code-block {
  color: #93c5fd;
  border-left: 2px solid var(--accent);
}
.tool-output-block.is-error {
  color: var(--danger);
  border-left: 2px solid var(--danger);
}

/* Thinking blocks */
.thinking-block {
  background: var(--thinking-bg);
  border: 1px solid var(--thinking-border);
  border-radius: 10px; margin: 10px 0; font-size: 13px; overflow: hidden;
  transition: border-color 0.2s ease;
}
.thinking-block.active {
  border-color: rgba(16, 163, 127, 0.45);
}
.thinking-block.active .thinking-title {
  color: var(--accent);
  font-weight: 500;
}
.thinking-head {
  padding: 10px 14px; cursor: pointer; user-select: none; display: flex; gap: 8px; align-items: center;
  color: var(--text-muted);
}
.thinking-head .thinking-toggle-hint {
  font-size: 11px;
  color: var(--text-dim);
  margin-left: auto;
}
.thinking-body {
  padding: 12px 14px; border-top: 1px solid var(--thinking-border);
  font-style: italic; color: var(--text-muted); max-height: 280px; overflow-y: auto;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Thinking placeholder & animations */
.thinking-placeholder {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 13px;
  padding: 8px 14px;
  background: var(--thinking-bg);
  border: 1px solid var(--thinking-border);
  border-radius: 10px;
  margin: 6px 0;
  animation: pulse-border 1.5s infinite ease-in-out;
}

.thinking-spinner {
  width: 13px;
  height: 13px;
  border: 2px solid var(--text-dim);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
  flex-shrink: 0;
}

.thinking-pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse-dot 0.8s infinite alternate;
  display: inline-block;
  margin-left: 2px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse-border {
  0%, 100% { border-color: var(--thinking-border); }
  50% { border-color: var(--accent); }
}

@keyframes pulse-dot {
  from { opacity: 0.3; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1.25); }
}

.streaming-cursor-row {
  margin-top: 6px;
  line-height: 1;
}
.streaming-cursor-row .typing-cursor::after {
  margin-left: 0;
}
.typing-cursor::after {
  content: "▋"; display: inline-block; margin-left: 2px;
  animation: blink 1s steps(2) infinite; color: var(--accent);
}
@keyframes blink { 0%, 50% { opacity: 1; } 50.01%, 100% { opacity: 0; } }

/* ---------- Empty state ---------- */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100%; text-align: center; color: var(--text-muted);
  gap: 16px; padding: 30px;
}
.empty-state .logo { font-size: 48px; font-weight: bold; color: var(--accent); }
.empty-state h1 { font-size: 32px; font-weight: 500; color: var(--text); }
.empty-state p { font-size: 15px; max-width: 480px; line-height: 1.6; }

/* Empty state model banner */
.empty-model-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  margin: 10px 0 16px;
  width: 100%;
  max-width: 520px;
  box-sizing: border-box;
  gap: 12px;
  text-align: left;
}
.empty-model-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.empty-model-icon {
  font-size: 24px;
  flex-shrink: 0;
  line-height: 1;
}
.empty-model-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.empty-model-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text);
  flex-wrap: wrap;
}
.empty-model-label {
  color: var(--text-muted);
  flex-shrink: 0;
}
.empty-model-name {
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.badge-default {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 500;
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: 4px;
  padding: 1px 6px;
  white-space: nowrap !important;
  flex-shrink: 0;
  line-height: 1.3;
}
.btn-topbar-action {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 8px;
  padding: 5px 9px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}
.btn-topbar-action:hover {
  background: var(--bg-hover);
  color: var(--text);
  border-color: var(--text-dim);
}
.topbar-action-label {
  font-weight: 500;
}
.empty-model-features {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-dim);
  flex-wrap: wrap;
}
.btn-change-model {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-change-model:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
}

.suggestions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 12px; }
.suggestions .chip {
  border: 1px solid var(--border); border-radius: 999px; padding: 10px 18px;
  font-size: 13px; color: var(--text-muted); background: var(--bg-input); cursor: pointer;
  transition: all .15s;
}
.suggestions .chip:hover { border-color: var(--text-dim); color: var(--text); }

/* ---------- Composer & Image Upload ---------- */
.sr-only-file-input {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.composer {
  padding: 12px 24px 20px;
  background: var(--bg);
}
.image-preview-bar {
  max-width: 820px;
  margin: 0 auto 8px auto;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 0;
}
.image-preview-item {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #111;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.image-preview-item:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}
.image-preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.image-preview-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  line-height: 1;
  padding: 0;
  transition: background 0.15s, transform 0.1s;
  z-index: 2;
}
.image-preview-remove:hover {
  background: var(--danger, #ef4444);
  transform: scale(1.1);
}

.composer-inner {
  max-width: 820px; margin: 0 auto;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 6px 8px 6px 8px;
  display: flex; align-items: flex-end; gap: 8px;
  transition: border-color .15s, box-shadow .15s;
}
.composer-inner.drag-over {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(16, 163, 127, 0.3);
}
.composer-inner:focus-within { border-color: var(--text-dim); }
.composer-inner.aborting {
  border-color: var(--danger);
  box-shadow: 0 0 0 1px var(--danger);
}
.composer .attach-btn {
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: color 0.15s ease, background 0.15s ease, transform 0.1s ease;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
}
.composer .attach-btn:hover {
  color: var(--text);
  background: var(--bg-hover);
}
.composer .attach-btn:active {
  transform: scale(0.92);
}
.composer textarea {
  flex: 1; background: transparent; border: none; outline: none; resize: none;
  color: var(--text); font-family: inherit; font-size: 15px; line-height: 20px;
  padding: 6px 0; max-height: 200px; min-height: 32px;
}
.composer .send-btn {
  width: 32px; height: 32px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 16px; font-weight: 600; line-height: 1;
  transition: background .15s, opacity .15s, transform .1s;
}
.composer .send-btn:disabled { background: #3a3a3a; color: #6f6f6f; cursor: not-allowed; }
.composer .send-btn.stop { background: var(--danger); }
.composer .send-btn.stop:hover:not(:disabled) { background: #f87171; }
.composer .send-btn.stop:active:not(:disabled) { transform: scale(0.95); }
.composer .send-btn.stop:empty::after {
  content: "";
  width: 12px;
  height: 12px;
  background: #fff;
  border-radius: 2px;
  display: block;
}
.composer .steer-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 32px;
  border-radius: 16px;
  border: none;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 500;
  flex-shrink: 0;
  transition: background .15s, opacity .15s, transform .1s;
  user-select: none;
}
.composer .steer-btn:hover {
  background: var(--accent-hover);
}
.composer .steer-btn:disabled {
  background: #3a3a3a;
  color: #6f6f6f;
  cursor: not-allowed;
}
.composer .steer-btn svg {
  width: 13px;
  height: 13px;
}
.composer-hint {
  text-align: center; color: var(--text-dim); font-size: 11px; margin-top: 10px; max-width: 820px; margin-left: auto; margin-right: auto;
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #3a3a3a; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #4a4a4a; }
::-webkit-scrollbar-track { background: transparent; }

/* Modal overlay and card */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}
.modal {
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 90%;
  max-width: 520px;
  padding: 20px 24px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  gap: 16px;
  transform: translateY(-10px);
  transition: transform 0.2s ease;
}
.modal-overlay.open .modal {
  transform: translateY(0);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
}
.btn-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  border-radius: 6px;
}
.btn-close:hover { color: var(--text); background: var(--bg-hover); }

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.modal-desc {
  font-size: 13px;
  color: var(--text-muted);
}
.input-group {
  display: flex;
  gap: 8px;
  width: 100%;
  box-sizing: border-box;
}
.input-group input {
  flex: 1;
  min-width: 0;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  color: var(--text);
  font-size: 13px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  outline: none;
  box-sizing: border-box;
}
.input-group input:focus {
  border-color: var(--text-dim);
}
.btn-primary {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
  flex-shrink: 0;
  box-sizing: border-box;
}
.btn-primary:hover { background: var(--accent-hover); }

.modal-error {
  color: var(--danger);
  font-size: 12px;
  display: none;
}

.quick-dirs {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}
.quick-label {
  font-size: 12px;
  color: var(--text-dim);
}
.quick-dirs .chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.quick-dirs .chip {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  transition: all 0.15s;
}
.quick-dirs .chip:hover {
  border-color: var(--text-dim);
  color: var(--text);
  background: var(--bg-hover);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #2a2a2a;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  z-index: 600;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Mobile toolbar reveal / scroll-to-top FAB */
.mobile-toolbar-fab {
  position: fixed;
  right: 16px;
  bottom: 90px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  cursor: pointer;
  z-index: 50;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease, background 0.15s ease;
}
.mobile-toolbar-fab.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.mobile-toolbar-fab:active {
  background: var(--bg-hover);
}

/* Model selector dropdown */
.model-menu {
  position: absolute; top: 52px; right: 16px;
  background: var(--bg-sidebar); border: 1px solid var(--border);
  border-radius: 14px; padding: 0; width: 380px; max-height: 480px;
  box-shadow: 0 12px 32px rgba(0,0,0,.5); z-index: 200; display: none;
  flex-direction: column; overflow: hidden;
}
.model-menu.open { display: flex; }

.model-search-wrap {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-sidebar);
  position: relative;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.model-search-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px;
  padding-right: 28px;
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s ease;
}
.model-search-input:focus {
  border-color: var(--accent);
}
.btn-clear-model-search {
  position: absolute;
  right: 18px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
  padding: 2px;
}
.btn-clear-model-search:hover {
  color: var(--text);
}

.model-menu-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 6px;
  max-height: 400px;
}
.model-menu-list .group-label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  padding: 8px 8px 3px;
  font-weight: 600;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.model-menu-list .opt {
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.12s;
  position: relative;
}
.model-menu-list .opt:hover,
.model-menu-list .opt.focused { background: var(--bg-hover); }
.model-menu-list .opt.active { background: var(--bg-hover); color: var(--accent); }
.model-menu-list .opt .check { color: var(--accent); width: 14px; flex-shrink: 0; font-size: 12px; }
.model-menu-list .opt .model-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.model-menu-list .opt .model-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.model-menu-list .opt .model-name {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.model-menu-list .opt .model-id-sub {
  font-size: 11px;
  color: var(--text-dim);
  font-family: "SF Mono", Menlo, Consolas, monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.model-menu-list .opt .badge-feature {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-muted);
  white-space: nowrap;
}
.model-menu-list .opt .badge-default-tag {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(59, 130, 246, 0.18);
  color: #60a5fa;
  font-weight: 600;
  white-space: nowrap;
}
.btn-set-default {
  opacity: 0;
  padding: 3px 8px;
  font-size: 11px;
  border-radius: 6px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.model-menu-list .opt:hover .btn-set-default,
.model-menu-list .opt.focused .btn-set-default {
  opacity: 1;
}
.btn-set-default:hover {
  background: var(--bg-hover);
  color: #60a5fa;
  border-color: #60a5fa;
}

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

/* Thinking selector dropdown */
.thinking-menu {
  position: absolute; top: 52px; right: 16px;
  background: var(--bg-sidebar); border: 1px solid var(--border);
  border-radius: 12px; padding: 6px; width: 220px;
  box-shadow: 0 12px 32px rgba(0,0,0,.5); z-index: 210; display: none;
  flex-direction: column; gap: 2px;
}
.thinking-menu.open { display: flex; }
.thinking-menu-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  padding: 4px 8px 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.thinking-opt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s;
}
.thinking-opt:hover { background: var(--bg-hover); }
.thinking-opt.active { background: var(--bg-hover); color: var(--accent); font-weight: 500; }
.thinking-opt .level-desc { font-size: 11px; color: var(--text-dim); }

/* System notice divider */
.system-notice-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 12px 0;
  animation: fade .18s ease;
}
.system-notice-text {
  font-size: 12px;
  color: var(--text-dim);
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  padding: 3px 12px;
  border-radius: 999px;
  letter-spacing: 0.2px;
}


/* ==========================================================================
   Responsive Mobile Web Design (< 768px)
   ========================================================================== */
/* Desktop: the drawer overlay must NEVER be shown, even if a stale
   `sidebar-open` class lingers after a viewport resize. The sidebar is
   inline on desktop, not a drawer, so there is nothing to dim. */
@media (min-width: 769px) {
  .sidebar-overlay { display: none !important; }
}

@media (max-width: 768px) {
  /* Layout adjustments */
  .app {
    flex-direction: row; /* Sits next to, but we shift it off-screen */
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px; /* Wider and more usable drawer on mobile */
    height: 100%;
    height: 100vh;
    height: 100dvh;
    max-height: 100dvh;
    margin-left: 0 !important; /* Cancel desktop margin-left sliding */
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 25px rgba(0, 0, 0, 0.5);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 105;
  }

  .sidebar-resizer {
    display: none !important;
  }

  .btn-delete-session {
    opacity: 0.7;
    width: 30px;
    height: 30px;
  }

  .sidebar-bottom {
    flex-shrink: 0;
    padding: 12px 14px;
    padding-bottom: max(16px, calc(10px + env(safe-area-inset-bottom, 0px)));
    background: var(--bg-sidebar);
  }

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

  .sidebar-overlay {
    display: none;
    opacity: 0;
  }

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

  /* Topbar Mobile Adjustments — fixed, taller, shadowed so it is always findable */
  .topbar {
    height: 50px;
    padding: 0 8px;
    gap: 6px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 101;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: center;
  }

  .main {
    padding-top: 50px;
  }

  .topbar .session-name {
    display: none !important;
  }

  .btn-toggle-sidebar {
    width: 36px;
    height: 36px;
    padding: 0;
    color: var(--text);
    background: var(--bg-hover);
    flex-shrink: 0;
  }
  .btn-toggle-sidebar svg {
    width: 20px;
    height: 20px;
  }

  #cwdPillWrap {
    padding: 4px 7px;
    font-size: 11px;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .model-pill-container {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
    min-width: 0;
  }

  .model-pill {
    padding: 4px 8px;
    font-size: 11px;
    max-width: 125px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-shrink: 1;
    min-width: 0;
    gap: 4px;
  }
  .model-pill-name {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .model-pill-badge {
    display: none !important;
  }

  .thinking-pill {
    padding: 4px 7px;
    font-size: 11px;
    flex-shrink: 0;
    white-space: nowrap;
    gap: 3px;
    display: inline-flex;
    align-items: center;
  }
  .thinking-pill .thinking-icon {
    font-size: 12px;
  }
  .thinking-pill .thinking-label {
    font-size: 11px;
    font-weight: 500;
  }

  .btn-topbar-action {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }
  .topbar-action-label {
    display: none !important;
  }

  @media (max-width: 360px) {
    .topbar {
      padding: 0 4px;
      gap: 4px;
    }
    #cwdPillWrap {
      max-width: 60px;
      padding: 4px 5px;
    }
    .model-pill {
      max-width: 95px;
    }
    .thinking-pill {
      padding: 4px 5px;
    }
  }

  /* Model & Thinking Dropdown Menu Mobile Adjustments */
  .model-menu, .thinking-menu {
    position: fixed;
    top: 54px;
    left: 8px;
    right: 8px;
    width: auto;
    max-height: calc(100dvh - 70px);
    border-radius: 12px;
  }
  .model-menu-list {
    max-height: calc(100dvh - 130px);
  }
  .btn-set-default {
    opacity: 1;
    font-size: 10px;
    padding: 2px 6px;
  }

  .empty-model-banner {
    padding: 12px 14px;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }
  .empty-model-left {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    flex: 1;
    min-width: 0;
  }
  .empty-model-icon {
    font-size: 22px;
    margin-top: 1px;
    flex-shrink: 0;
  }
  .empty-model-info {
    flex: 1;
    min-width: 0;
    gap: 4px;
  }
  .empty-model-title-row {
    flex-wrap: wrap;
    gap: 4px 6px;
    font-size: 12.5px;
    line-height: 1.4;
  }
  .empty-model-name {
    font-weight: 600;
    word-break: break-all;
    white-space: normal;
  }
  .btn-change-model {
    align-self: center;
    padding: 6px 10px;
    font-size: 11.5px;
    flex-shrink: 0;
  }

  .mobile-toolbar-fab {
    display: flex;
  }

  /* Chat area mobile adjustments */
  .chat {
    padding: 16px 0;
  }

  .chat-inner {
    padding: 0 16px;
    gap: 18px;
  }

  /* Chat bubble mobile adjustments */
  .msg.user .bubble {
    max-width: 90%;
    font-size: 14px;
    padding: 10px 14px;
    border-radius: 16px;
  }

  .msg.user .role-tag,
  .msg.assistant .role-tag {
    font-size: 11px;
  }

  .msg-time {
    font-size: 10px;
  }

  .msg.assistant .content {
    font-size: 14px;
    line-height: 1.6;
  }

  .msg.assistant .content pre {
    padding: 10px 12px;
    font-size: 12px;
    margin: 8px 0;
    border-radius: 8px;
  }

  .msg.assistant .content code {
    font-size: 0.85em;
    padding: 1px 4px;
  }

  /* Empty state mobile adjustments */
  .empty-state {
    padding: 20px 14px;
    gap: 12px;
  }

  .empty-state .logo {
    font-size: 38px;
  }

  .empty-state h1 {
    font-size: 22px;
  }

  .empty-state p {
    font-size: 13.5px;
    line-height: 1.5;
  }

  .suggestions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .suggestions .chip {
    padding: 8px 12px;
    font-size: 12px;
    line-height: 1.35;
    text-align: center;
    border-radius: 18px;
    max-width: 100%;
    box-sizing: border-box;
    white-space: normal;
  }

  /* Composer input mobile adjustments */
  .composer {
    padding: 8px 12px;
    padding-bottom: max(12px, calc(8px + env(safe-area-inset-bottom, 0px)));
  }

  .image-preview-bar {
    gap: 8px;
    margin-bottom: 6px;
    padding: 2px 4px;
  }

  .image-preview-item {
    width: 60px;
    height: 60px;
  }

  .image-preview-remove {
    width: 22px;
    height: 22px;
    font-size: 14px;
    top: 2px;
    right: 2px;
    background: rgba(0, 0, 0, 0.85);
  }

  .composer-inner {
    padding: 5px 8px 5px 8px;
    border-radius: 22px;
    gap: 6px;
  }

  .composer .attach-btn {
    width: 32px;
    height: 32px;
  }

  .composer textarea {
    padding: 6px 0;
    font-size: 15px;
    line-height: 20px;
    min-height: 28px;
    max-height: 160px;
  }

  .composer .send-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
  }

  /* CWD Modal Mobile Adjustments */
  .modal {
    width: 92%;
    max-width: 440px;
    padding: 16px;
    border-radius: 14px;
    gap: 12px;
    box-sizing: border-box;
  }
  .modal-header h3 {
    font-size: 15px;
  }
  .modal-desc {
    font-size: 12px;
  }
  .input-group {
    display: flex;
    flex-direction: row;
    gap: 6px;
    width: 100%;
    box-sizing: border-box;
  }
  .input-group input {
    font-size: 13px;
    padding: 9px 10px;
    min-width: 0;
  }
  .btn-primary {
    padding: 0 14px;
    font-size: 12px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }
  .quick-dirs .chips .chip {
    font-size: 11px;
    padding: 5px 8px;
    word-break: break-all;
  }

  @media (max-width: 380px) {
    .input-group {
      flex-direction: column;
      gap: 8px;
    }
    .btn-primary {
      width: 100%;
    }
  }

  .composer-hint {
    font-size: 10px;
    margin-top: 6px;
    padding: 0 4px;
    line-height: 1.4;
  }
}
