:root {
  --bg-main: #000000;
  --bg-surface: #121214;
  --bg-surface-elevated: #1c1c1f;
  --bg-input: #212124;
  --border: rgba(255, 255, 255, 0.08);
  --border-light: rgba(255, 255, 255, 0.12);
  --text-main: #f3f4f6;
  --text-muted: #8e8e93;
  --accent: #2f81f7;
  --accent-hover: #388bfd;
  --green: #3fb950;
  --red: #f85149;
  --yellow: #d29922;
  --diff-add-bg: rgba(46, 160, 67, 0.15);
  --diff-add-text: #56d364;
  --diff-del-bg: rgba(248, 81, 73, 0.15);
  --diff-del-text: #f85149;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --android-nav-inset: env(safe-area-inset-bottom, 10px);
}

/* Keyboard active: hide bottom nav and dock chat input bar right on keyboard */
body.keyboard-active .bottom-nav,
#app.keyboard-active .bottom-nav {
  display: none !important;
}

body.keyboard-active .chat-input-bar,
#app.keyboard-active .chat-input-bar {
  padding-bottom: 6px !important;
}

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

html, body {
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font);
  overflow: hidden;
  height: 100%;
  height: 100dvh;
  width: 100vw;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
  position: relative;
}

.view {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  min-height: 0;
  flex: 1 1 0;
  overflow: hidden;
}

#main-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  min-height: 0;
  flex: 1 1 0;
  overflow: hidden;
  position: relative;
}

.hidden {
  display: none !important;
}

/* Header */
.app-header {
  height: 54px;
  flex: 0 0 54px;
  background-color: var(--bg-main);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  z-index: 10;
}

.header-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 68%;
  background: #1c1c1e;
  border-radius: 20px;
  padding: 4px 14px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.header-info .title {
  font-weight: 600;
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  text-align: center;
  color: #ffffff;
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 1px;
}

.tag-ws-pill {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.status-badge {
  font-size: 10.5px;
  font-weight: 500;
}

.status-badge.online {
  color: var(--green);
}

.status-badge.offline {
  color: var(--red);
}

.status-badge.working {
  color: #38bdf8;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.icon-btn {
  background: none;
  border: none;
  color: #8e8e93;
  padding: 8px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
}

.icon-btn:active {
  background-color: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

/* Tabs Container */
.tabs-container {
  flex: 1 1 0;
  min-height: 0;
  width: 100%;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.tab-content {
  display: none;
  height: 100%;
  width: 100%;
  min-height: 0;
  flex: 1 1 0;
  flex-direction: column;
  overflow: hidden;
}

.tab-content.active {
  display: flex;
}

#tab-chat {
  display: none;
  height: 100%;
  width: 100%;
  min-height: 0;
  flex: 1 1 0;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

#tab-chat.active {
  display: flex;
}

/* Chat Tab */
.messages-scroll {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  touch-action: pan-y;
  /* app.js preserves a visible message anchor across streaming/media/keyboard. */
  overflow-anchor: none;
  padding: 12px 14px 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background-color: var(--bg-main);
}

.welcome-card {
  background-color: transparent;
  border: none;
  padding: 24px 16px;
  text-align: center;
  margin: 16px auto;
  max-width: 90%;
}

.welcome-card h3 {
  margin-bottom: 6px;
  font-size: 17px;
  font-weight: 600;
  color: #ffffff;
}

.welcome-card p {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.45;
}

.message-bubble {
  width: auto;
  font-size: 14.5px;
  line-height: 1.55;
  word-break: break-word;
}

.message-bubble.user {
  align-self: flex-end;
  background-color: #212124;
  color: #ffffff;
  border-radius: 20px;
  border-bottom-right-radius: 6px;
  padding: 10px 14px 6px 16px;
  max-width: 85%;
  border: none;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
}

.msg-text-content {
  word-break: break-word;
}

.msg-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  font-size: 10.5px;
  color: rgba(255, 255, 255, 0.45);
  margin-top: 4px;
  align-self: flex-end;
  user-select: none;
}

.msg-time {
  font-feature-settings: "tnum";
}

.msg-status-icon {
  display: inline-flex;
  align-items: center;
  line-height: 1;
}

.msg-status-icon.sending {
  color: rgba(255, 255, 255, 0.4);
}

.msg-status-icon.delivered {
  color: #10b981; /* Telegram green checkmark */
}

.msg-status-icon svg {
  display: block;
}

/* Agent Working / Processing Pill in chat */
.agent-working-card {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  margin: 6px 0 10px 0;
  animation: fadeIn 0.2s ease;
}

.working-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.working-dots span {
  width: 5px;
  height: 5px;
  background: #10b981;
  border-radius: 50%;
  animation: pulseWorkingDot 1.4s infinite ease-in-out both;
}

.working-dots span:nth-child(1) { animation-delay: -0.32s; }
.working-dots span:nth-child(2) { animation-delay: -0.16s; }
.working-dots span:nth-child(3) { animation-delay: 0s; }

.working-label {
  font-size: 13px;
  color: #cbd5e1;
  font-weight: 500;
}

@keyframes pulseWorkingDot {
  0%, 80%, 100% {
    transform: scale(0.6);
    opacity: 0.35;
  }
  40% {
    transform: scale(1.15);
    opacity: 1;
  }
}

.user-attachment-gallery {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
  width: 100%;
}

.user-attachment-card {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  max-width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
  background: #121214;
}

.user-attachment-img {
  width: 100%;
  max-height: 420px;
  object-fit: contain;
  display: block;
  cursor: pointer;
  border-radius: 18px;
}

.user-attachment-doc {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 6px 12px;
  font-size: 12px;
  color: #fff;
  text-decoration: none;
}

.message-bubble.assistant {
  align-self: stretch;
  width: 100%;
  max-width: 100%;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 4px 0 14px 0;
  box-shadow: none;
}

/* System Event Row & Pill (ChatGPT style) */
.system-event-row {
  display: flex;
  justify-content: center;
  margin: 6px 0;
  width: 100%;
}

.system-event-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: none;
  padding: 4px 12px;
  border-radius: 16px;
  font-size: 11.5px;
  color: var(--text-muted);
  max-width: 90%;
}

.system-event-pill .sys-icon {
  font-size: 12px;
  flex-shrink: 0;
}

.system-event-pill .sys-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Thought Accordion & Collapsible details (ChatGPT style) */
.message-bubble.assistant.tool-only,
.message-bubble.assistant.thought-only,
.message-bubble.assistant.system-steps-only {
  padding: 0 !important;
  margin: 0 !important;
}

.message-bubble.assistant.tool-only + .message-bubble.assistant.tool-only,
.message-bubble.assistant.thought-only + .message-bubble.assistant.thought-only,
.message-bubble.assistant.system-steps-only + .message-bubble.assistant.system-steps-only,
.message-bubble.assistant.tool-only + .message-bubble.assistant.thought-only,
.message-bubble.assistant.thought-only + .message-bubble.assistant.tool-only,
.message-bubble.assistant.tool-only + .message-bubble.assistant.system-steps-only,
.message-bubble.assistant.system-steps-only + .message-bubble.assistant.tool-only {
  margin-top: -11px !important;
}

.thought-details {
  background: transparent;
  border: none;
  margin: 1px 0 2px 0;
  font-size: 13px;
}

.thought-summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
  cursor: pointer;
  color: #8e8e93;
  user-select: none;
  font-size: 13px;
  font-weight: 500;
  list-style: none;
  transition: color 0.15s;
}

.thought-summary::-webkit-details-marker,
.thought-summary::marker {
  display: none !important;
  content: "" !important;
}

.thought-summary:hover {
  color: #d1d5db;
}

.thought-chevron {
  font-size: 12px;
  color: #8e8e93;
  transition: transform 0.2s ease;
  display: inline-block;
}

.thought-details[open] > .thought-summary .thought-chevron {
  transform: rotate(90deg);
}

.thought-body {
  padding: 10px 14px;
  color: #9ca3af;
  font-size: 12.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  background: rgba(255, 255, 255, 0.03);
  border-left: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 0 10px 10px 0;
  max-height: 240px;
  overflow-y: auto;
  margin-top: 6px;
}

/* Tool execution steps - Clean mobile styling */
.tool-group-accordion {
  display: none !important;
}

.tool-step-compact {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 8px;
  overflow: hidden;
  font-size: 12px;
  margin: 4px 0;
  transition: background 0.15s, border-color 0.15s;
}

.tool-step-compact:hover,
.tool-step-compact:active {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.12);
}

.tool-step-compact .tool-step-name {
  display: none !important; /* Убираем лишнее заглавие действия (view_file, replace_file_content и т.д.) */
}

.tool-group-summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
  cursor: pointer;
  color: #8e8e93;
  user-select: none;
  font-size: 13px;
  font-weight: 500;
  list-style: none;
  transition: color 0.15s;
}

.tool-group-summary::-webkit-details-marker,
.tool-group-summary::marker {
  display: none !important;
  content: "" !important;
}

.tool-group-summary:hover {
  color: #d1d5db;
}

.tool-group-chevron {
  font-size: 12px;
  color: #8e8e93;
  transition: transform 0.2s ease;
  display: inline-block;
}

.tool-group-accordion[open] > .tool-group-summary .tool-group-chevron {
  transform: rotate(90deg);
}

.tool-group-body {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: #141416;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  margin-top: 6px;
}

.tool-step-compact {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  overflow: hidden;
  font-size: 12px;
}

.tool-step-summary-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  cursor: pointer;
  color: var(--text-main);
  user-select: none;
  list-style: none;
}

.tool-step-summary-bar::-webkit-details-marker,
.tool-step-summary-bar::marker {
  display: none !important;
  content: "" !important;
}

.tool-step-icon {
  font-size: 12px;
  opacity: 0.8;
  flex-shrink: 0;
}

.tool-step-name {
  font-weight: 600;
  color: #93c5fd;
  font-family: var(--font-mono);
  font-size: 11px;
  flex-shrink: 0;
}

.tool-step-desc {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #9ca3af;
  font-size: 12px;
  transition: color 0.15s;
}

.tool-step-compact:hover .tool-step-desc,
.tool-step-compact:active .tool-step-desc {
  color: #f3f4f6;
}

.tool-step-arrow {
  font-size: 11px;
  color: var(--text-muted);
  transition: transform 0.15s;
}

.tool-step-compact[open] > .tool-step-summary-bar .tool-step-arrow {
  transform: rotate(90deg);
}

.tool-step-expanded {
  padding: 8px 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  background: #0d0d0f;
  font-size: 11px;
}

.tool-cmd-box {
  font-family: var(--font-mono);
  font-size: 11px;
  color: #6ee7b7;
  word-break: break-all;
  white-space: pre-wrap;
  margin-bottom: 6px;
}

.tool-result-box {
  font-family: var(--font-mono);
  font-size: 11px;
  color: #d1d5db;
  background: rgba(0, 0, 0, 0.4);
  padding: 8px;
  border-radius: 6px;
  max-height: 180px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  margin: 4px 0 0 0;
}

/* Fallback legacy tool-step for backward compatibility */
.tool-step {
  background: #141416;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 6px 10px;
  margin: 6px 0;
  font-size: 11.5px;
}

.tool-step-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: var(--accent);
}

.tool-step-summary {
  color: var(--text-muted);
  font-size: 11px;
  margin-top: 2px;
}

.tool-step-cmd {
  background: var(--bg-input);
  padding: 4px 8px;
  border-radius: 4px;
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: #56d364;
  white-space: pre-wrap;
  word-break: break-all;
}

/* Markdown response styling */
.reply-text {
  font-size: 15px;
  line-height: 1.6;
  color: #f3f4f6;
  letter-spacing: -0.01em;
}

.reply-text p {
  margin-bottom: 12px;
}

.reply-text p:last-child {
  margin-bottom: 0;
}

.reply-text strong, .reply-text b {
  color: #ffffff;
  font-weight: 600;
}

.reply-text code {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  padding: 2px 6px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: #f9fafb;
}

.reply-text pre {
  background: #141416;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 12px;
  margin: 12px 0;
  overflow-x: auto;
}

.reply-text pre code {
  background: transparent;
  border: none;
  padding: 0;
  color: #e5e7eb;
}

.reply-text ul, .reply-text ol {
  padding-left: 20px;
  margin: 10px 0;
}

.reply-text li {
  margin-bottom: 5px;
}

.reply-text a {
  color: #60a5fa;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Chat Input Bar */
.chat-input-bar {
  flex: 0 0 auto;
  width: 100%;
  padding: 8px 12px 12px 12px;
  background-color: var(--bg-main);
  border-top: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 15;
}

.active-chat-target-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  font-size: 11px;
  color: #8e8e93;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  margin-bottom: 2px;
  overflow: hidden;
  white-space: nowrap;
}

.active-chat-target-bar .target-icon {
  font-size: 12px;
  opacity: 0.8;
}

.active-chat-target-bar .target-label {
  font-weight: 500;
  color: #a1a1aa;
}

.active-chat-target-bar .target-title {
  color: #38bdf8;
  font-weight: 600;
  text-overflow: ellipsis;
  overflow: hidden;
  max-width: 260px;
}

.input-controls-row {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  background: #212124;
  border-radius: 26px;
  padding: 5px 8px 5px 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.input-action-btn {
  background: transparent;
  color: #8e8e93;
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s ease;
  padding: 0;
}

.input-action-btn:hover, .input-action-btn:active {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

/* Microphone Listening & Formatting State */
.input-action-btn.listening {
  background: #da3633 !important;
  color: #fff !important;
  animation: micPulse 1.2s infinite alternate;
  box-shadow: 0 0 12px rgba(248, 81, 73, 0.6);
}

.input-action-btn.formatting {
  background: rgba(47, 129, 247, 0.2) !important;
  color: #58a6ff !important;
  animation: spin 1s infinite linear;
}

#voice-polish-btn {
  font-size: 15px;
  color: #e3b341;
  transition: opacity 0.2s, transform 0.15s;
}

#voice-polish-btn:active {
  transform: scale(0.9);
}

@keyframes micPulse {
  0% { transform: scale(1); box-shadow: 0 0 4px rgba(248, 81, 73, 0.4); }
  100% { transform: scale(1.1); box-shadow: 0 0 16px rgba(248, 81, 73, 0.8); }
}

/* Attachment Previews */
.attachment-previews {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 2px 4px;
  max-height: 120px;
  overflow-y: auto;
}

.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #262629;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 3px 8px 3px 4px;
  font-size: 11px;
  color: var(--text-main);
  max-width: 180px;
}

.attachment-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-input);
}

.attachment-icon {
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
}

.attachment-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.attachment-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  padding: 0 2px;
  line-height: 1;
}

.attachment-remove:hover {
  color: var(--red);
}

.chat-input-bar textarea {
  flex: 1;
  background: transparent;
  border: none;
  padding: 6px 4px;
  color: #ffffff;
  font-size: 15px;
  line-height: 1.35;
  resize: none;
  max-height: 110px;
  outline: none;
  -webkit-appearance: none;
}

.chat-input-bar textarea::placeholder {
  color: #8e8e93;
}

.send-btn {
  background-color: #ffffff;
  color: #000000;
  border: none;
  border-radius: 50%;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.1s, opacity 0.15s, background-color 0.15s;
}

.send-btn:active {
  transform: scale(0.92);
}

.send-btn:disabled {
  background-color: #38383c;
  color: #636366;
  opacity: 0.6;
  cursor: not-allowed;
}

.send-btn svg {
  stroke: currentColor;
}

/* Floating Scroll to Bottom Button */
.scroll-bottom-btn {
  position: absolute;
  right: 16px;
  bottom: 72px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #232326;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  z-index: 18;
  transition: opacity 0.2s, transform 0.2s;
}

.scroll-bottom-btn:active {
  transform: scale(0.9);
}

/* Load More Messages Button */
.load-more-btn {
  align-self: center;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border);
  color: var(--accent);
  font-size: 12px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 14px;
  cursor: pointer;
  margin: 4px auto 8px auto;
  transition: background 0.15s;
}

.load-more-btn:active {
  background: var(--border);
}

.section-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 5px;
  line-height: 1.3;
}

/* Bottom Nav */
.bottom-nav {
  flex: 0 0 calc(54px + var(--android-nav-inset));
  height: calc(54px + var(--android-nav-inset));
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  padding-top: 6px;
  padding-bottom: var(--android-nav-inset);
  justify-content: space-around;
  z-index: 20;
}

.nav-item {
  background: none;
  border: none;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  padding: 6px 12px;
}

.nav-item.active {
  color: var(--accent);
}

/* ==========================================================================
   Queue Tab (Smart Generation Queue Mobile Layout)
   ========================================================================== */
#tab-queue {
  background-color: var(--bg-main);
  flex-direction: column;
}

.queue-header {
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 14px 8px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.queue-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.queue-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.queue-title-group h3 {
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  margin: 0;
}

.queue-sync-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border);
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 11px;
  color: var(--text-muted);
}

.sync-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  display: inline-block;
}

.sync-dot.syncing {
  background: var(--yellow);
  animation: pulse 1s infinite;
}

.queue-btn {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border);
  color: var(--text-main);
  border-radius: 6px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  white-space: nowrap;
}

.queue-btn:active {
  background: var(--border);
  transform: scale(0.97);
}

.queue-btn-refresh {
  color: var(--accent);
  border-color: rgba(47, 129, 247, 0.4);
}

.queue-switches-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -14px;
  padding: 0 14px;
}

.queue-switches-scroll::-webkit-scrollbar {
  display: none;
}

.queue-switches-bar {
  display: flex;
  gap: 6px;
  align-items: center;
  width: max-content;
}

.queue-switch-btn {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 14px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.queue-switch-btn.active {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
}

.queue-switch-btn.paused {
  color: var(--yellow);
  border-color: rgba(210, 153, 34, 0.4);
  background: rgba(210, 153, 34, 0.1);
}

.switch-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--green);
}

.switch-dot.paused {
  background-color: var(--yellow);
}

.queue-filter-bar {
  display: flex;
  gap: 6px;
  background: var(--bg-main);
  padding: 3px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.queue-filter-pill {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  padding: 5px 4px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: all 0.15s;
}

.queue-filter-pill.active {
  background: var(--bg-surface-elevated);
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.pill-badge {
  font-size: 10px;
  background: rgba(255, 255, 255, 0.1);
  padding: 1px 5px;
  border-radius: 8px;
  font-weight: 500;
}

.queue-filter-pill.active .pill-badge {
  background: var(--accent);
  color: #fff;
}

/* Feed & Sections */
.queue-feed {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  padding: 12px 14px 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.queue-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.queue-section.hidden {
  display: none !important;
}

.queue-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px 4px;
}

.sec-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.sec-count {
  font-size: 11px;
  font-weight: 600;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 1px 6px;
  border-radius: 8px;
}

.queue-cards-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.queue-empty-msg {
  text-align: center;
  padding: 14px 10px;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-surface);
  border: 1px dashed var(--border);
  border-radius: 8px;
}

/* Task Cards */
.q-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  transition: border-color 0.15s;
}

.q-card.q-card-active {
  border-color: rgba(210, 153, 34, 0.6);
  background: linear-gradient(180deg, rgba(210, 153, 34, 0.05) 0%, var(--bg-surface) 100%);
}

.q-card.q-card-done {
  border-color: rgba(35, 134, 54, 0.4);
  background: #0d141d;
}

.q-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.q-card-main {
  flex: 1;
  min-width: 0;
}

.q-shot-title {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  line-height: 1.3;
  word-break: break-word;
}

.q-shot-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Engine Badges */
.q-engine-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  white-space: nowrap;
  flex-shrink: 0;
  letter-spacing: 0.3px;
  background: rgba(255, 255, 255, 0.05);
}

.q-engine-hailuo {
  color: #bc8cff;
  border: 1px solid rgba(188, 140, 255, 0.4);
  background: rgba(188, 140, 255, 0.1);
}

.q-engine-kling {
  color: #58a6ff;
  border: 1px solid rgba(88, 166, 255, 0.4);
  background: rgba(88, 166, 255, 0.1);
}

.q-engine-mj {
  color: #ff7b72;
  border: 1px solid rgba(255, 123, 114, 0.4);
  background: rgba(255, 123, 114, 0.1);
}

.q-engine-magnific {
  color: #d29922;
  border: 1px solid rgba(210, 153, 34, 0.4);
  background: rgba(210, 153, 34, 0.1);
}

/* Prompt preview */
.q-prompt-box {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 11px;
  color: var(--text-main);
  line-height: 1.35;
  max-height: 58px;
  overflow-y: auto;
  word-break: break-word;
}

/* Active rendering row */
.q-render-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}

.q-render-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--yellow);
  font-weight: 500;
}

.q-time-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(88, 166, 255, 0.12);
  border: 1px solid rgba(88, 166, 255, 0.3);
  color: #58a6ff;
  white-space: nowrap;
}

.q-time-badge.done {
  background: rgba(63, 185, 80, 0.12);
  border-color: rgba(63, 185, 80, 0.3);
  color: #3fb950;
}

/* Progress Pulse Animation */
.q-progress-bar {
  width: 100%;
  height: 3px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
  margin-top: 2px;
}

.q-progress-bar::after {
  content: '';
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 40%;
  background: linear-gradient(90deg, transparent, var(--yellow), transparent);
  animation: qPulseSlide 1.5s infinite linear;
}

@keyframes qPulseSlide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

/* Actions Row in Queued card */
.q-actions-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.q-btn-group {
  display: flex;
  gap: 4px;
  align-items: center;
}

.q-icon-btn {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border);
  color: #fff;
  border-radius: 4px;
  padding: 4px 7px;
  font-size: 11px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.q-icon-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.q-select {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border);
  color: var(--text-main);
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 11px;
}

.q-btn-danger {
  color: #ff7b72;
  border-color: rgba(255, 123, 114, 0.3);
}

.q-btn-danger:active {
  background: rgba(255, 123, 114, 0.2);
}

/* Done card with Preview */
.q-done-card {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 10px;
  padding: 8px 10px;
}

.q-done-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
}

.q-done-preview {
  position: relative;
  width: 108px;
  min-width: 108px;
  height: 68px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #000;
  flex-shrink: 0;
  align-self: center;
  cursor: pointer;
}

.q-done-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.q-done-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 18px;
  transition: transform 0.15s;
}

.q-done-preview:active .q-done-play {
  transform: scale(1.15);
}

.q-done-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.q-btn-sm {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
}

.tab-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tab-header h3 {
  font-size: 16px;
}

/* Terminal */
.terminal-box {
  flex: 1;
  margin: 16px;
  background-color: #050608;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: #38bdf8;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* Approval Banner */
.approval-card {
  position: absolute;
  bottom: calc(70px + var(--android-nav-inset));
  left: 16px;
  right: 16px;
  background: var(--bg-surface-elevated);
  border: 2px solid var(--yellow);
  border-radius: 12px;
  padding: 16px;
  z-index: 20;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  animation: slideUp 0.25s ease-out;
}

.approval-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.warn-badge {
  color: var(--yellow);
  font-weight: 600;
  font-size: 13px;
}

.code-box {
  background: #000;
  padding: 8px 12px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: #38bdf8;
  margin-bottom: 8px;
  overflow-x: auto;
}

.explanation {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.approval-actions {
  display: flex;
  gap: 10px;
}

.btn-approve {
  flex: 1;
  background: var(--green);
  color: #fff;
  border: none;
  padding: 10px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}

.btn-deny {
  flex: 1;
  background: var(--red);
  color: #fff;
  border: none;
  padding: 10px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}

/* Side Drawer */
.drawer {
  position: absolute;
  top: 0;
  left: -320px;
  bottom: 0;
  width: 320px;
  max-width: 85vw;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  z-index: 30;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px)) 10px;
}

.drawer.open {
  transform: translateX(320px);
}

/* Compact Top Limits Bar */
.drawer-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 4px 8px 4px;
  border-bottom: 1px solid rgba(48, 54, 61, 0.45);
  margin-bottom: 8px;
  gap: 8px;
}

.drawer-limits-container {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
  min-width: 0;
}

.drawer-model-limits-row {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.model-limits-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.2px;
  flex-shrink: 0;
  width: 66px;
}

.model-limits-badge.gemini {
  background: rgba(56, 189, 248, 0.12);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.model-limits-badge.opus {
  background: rgba(217, 119, 6, 0.14);
  color: #f59e0b;
  border: 1px solid rgba(217, 119, 6, 0.35);
}

.model-limits-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  flex-shrink: 0;
}

.model-limits-dot.gemini {
  background: #38bdf8;
  box-shadow: 0 0 5px rgba(56, 189, 248, 0.5);
}

.model-limits-dot.opus {
  background: #f59e0b;
  box-shadow: 0 0 5px rgba(245, 158, 11, 0.5);
}

.model-limits-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.compact-limit-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: rgba(33, 38, 45, 0.7);
  border: 1px solid rgba(48, 54, 61, 0.6);
  border-radius: 6px;
  padding: 2px 5px;
  font-family: var(--font-mono);
  font-size: 11px;
}

.compact-limit-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #3fb950;
  box-shadow: 0 0 5px rgba(63, 185, 80, 0.4);
}

.compact-limit-dot.warning {
  background: #d29922;
  box-shadow: 0 0 5px rgba(210, 153, 34, 0.4);
}

.compact-limit-dot.danger {
  background: #f85149;
  box-shadow: 0 0 5px rgba(248, 81, 73, 0.5);
}

.compact-limit-val {
  font-size: 11.5px;
  font-weight: 700;
  color: #f0f6fc;
}

.compact-limit-lbl {
  font-size: 9.5px;
  color: #8b949e;
  font-weight: 600;
  text-transform: uppercase;
}

.compact-limit-sep {
  color: #484f58;
  font-size: 10px;
}

.drawer-top-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  padding-left: 2px;
}

.compact-refresh-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #8b949e;
  font-size: 14px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  transition: transform 0.2s, color 0.15s, background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  min-height: 24px;
}

.compact-refresh-btn:active {
  transform: rotate(180deg);
  color: #58a6ff;
  background: rgba(88, 166, 255, 0.15);
}

.compact-icon-btn {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ef4444;
  opacity: 0.85;
  min-width: 28px;
  min-height: 24px;
}

.compact-icon-btn:active {
  opacity: 1;
  background: rgba(239, 68, 68, 0.2);
}

/* Custom Dark Project Dropdown */
.drawer-section {
  margin-bottom: 10px;
}

.drawer-section.project-section {
  margin-bottom: 10px;
}

.custom-dropdown {
  position: relative;
  width: 100%;
}

.custom-dropdown-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  color: #f0f6fc;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  user-select: none;
  transition: border-color 0.15s, background 0.15s;
}

.custom-dropdown-trigger:hover,
.custom-dropdown-trigger:active {
  border-color: rgba(88, 166, 255, 0.4);
  background: rgba(33, 38, 45, 0.9);
}

.dropdown-trigger-icon {
  font-size: 14px;
  flex-shrink: 0;
}

.dropdown-trigger-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dropdown-trigger-arrow {
  font-size: 11px;
  color: #8b949e;
  transition: transform 0.2s;
  flex-shrink: 0;
}

.custom-dropdown.open .dropdown-trigger-arrow {
  transform: rotate(180deg);
}

.custom-dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
  z-index: 50;
  padding: 6px;
  max-height: 250px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.custom-dropdown-menu.hidden {
  display: none;
}

.custom-dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  color: #c9d1d9;
  font-size: 13px;
  user-select: none;
  transition: background 0.15s, color 0.15s;
}

.custom-dropdown-item:hover,
.custom-dropdown-item:active {
  background: rgba(88, 166, 255, 0.12);
  color: #f0f6fc;
}

.custom-dropdown-item.active {
  background: rgba(88, 166, 255, 0.18);
  color: #58a6ff;
  font-weight: 600;
}

.dropdown-item-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow: hidden;
}

.dropdown-item-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dropdown-item-path {
  font-size: 10px;
  color: #8b949e;
  font-family: var(--font-mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dropdown-item-check {
  font-size: 13px;
  color: #58a6ff;
  flex-shrink: 0;
}

.drawer-section.chats-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin-bottom: 0;
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.section-title-row h4, .drawer-section h4 {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  font-weight: 600;
}

.badge {
  font-size: 10px;
  background: var(--bg-surface-elevated);
  color: var(--text-muted);
  padding: 1px 6px;
  border-radius: 8px;
  font-family: var(--font-mono);
}

.chats-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.compact-refresh-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
  user-select: none;
}

.compact-refresh-btn:hover, .compact-refresh-btn:active {
  color: #fff;
  border-color: var(--accent);
  background: rgba(47, 129, 247, 0.15);
}

.compact-refresh-btn.spinning {
  animation: spin 0.6s linear infinite;
}

.workspace-pills-bar {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 8px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.workspace-pills-bar::-webkit-scrollbar {
  display: none;
}

.ws-pill {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 14px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 11.5px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.ws-pill:hover, .ws-pill:active {
  background: #252a36;
  color: var(--text-main);
}

.ws-pill.active {
  background: rgba(47, 129, 247, 0.18);
  border-color: var(--accent);
  color: #58a6ff;
  font-weight: 600;
}

.ws-pill-count {
  font-size: 10px;
  opacity: 0.8;
  background: rgba(255, 255, 255, 0.08);
  padding: 0 4px;
  border-radius: 6px;
}

.ws-pill.active .ws-pill-count {
  background: rgba(47, 129, 247, 0.35);
  color: #fff;
}

.tag-desktop-active {
  background: rgba(46, 204, 113, 0.15);
  color: #2ecc71;
  border: 1px solid rgba(46, 204, 113, 0.3);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 9.5px;
  font-weight: 500;
}

.subagents-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  margin: 0 0 8px 0;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 8px;
  user-select: none;
}

.subagents-checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 11.5px;
  color: #adbac7;
  font-weight: 500;
  flex: 1;
}

.subagents-checkbox {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.custom-checkbox-indicator {
  width: 15px;
  height: 15px;
  border-radius: 4px;
  border: 1.5px solid rgba(255, 255, 255, 0.28);
  background: rgba(0, 0, 0, 0.2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.subagents-checkbox:checked + .custom-checkbox-indicator {
  background: #38bdf8;
  border-color: #38bdf8;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.5);
}

.subagents-checkbox:checked + .custom-checkbox-indicator::after {
  content: '✓';
  color: #0d1117;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
}

.subagents-label-text {
  line-height: 1.2;
}

.subagents-count-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
  background: rgba(168, 85, 247, 0.15);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.3);
  flex-shrink: 0;
}

.tag-subagent {
  font-size: 9.5px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 5px;
  background: rgba(168, 85, 247, 0.15);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.35);
  white-space: nowrap;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.search-input {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-main);
  font-size: 13px;
  margin-bottom: 10px;
  outline: none;
}

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

.dropdown {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-main);
  font-size: 13px;
  outline: none;
}

.sessions-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 4px;
}

.loading-state, .empty-chats {
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  padding: 20px 0;
}

.session-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 10px 12px;
  border-radius: 9px;
  background: var(--bg-surface-elevated);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
}

.session-item:hover, .session-item:active {
  background: #252a36;
}

.session-item.active {
  border-color: var(--accent);
  background: rgba(47, 129, 247, 0.1);
}

.session-item-top {
  display: flex;
  align-items: center;
  gap: 7px;
}

.chat-color-marker {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1.5px dashed rgba(255, 255, 255, 0.28);
  background: transparent;
  box-sizing: border-box;
}

.chat-color-marker:hover, .chat-color-marker:active {
  transform: scale(1.3);
  border-color: rgba(255, 255, 255, 0.7);
}

.chat-color-marker.has-color {
  border: 1px solid rgba(0, 0, 0, 0.35);
}

.session-item .item-title {
  flex: 1;
  min-width: 0;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

/* Chat Status Indicators (Desktop Style) */
.chat-status-pill {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 4.5px;
  padding: 1.5px 7px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.3;
  user-select: none;
  margin-left: auto;
}

.chat-status-pill.running {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.35);
}

.chat-status-pill.waiting {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.4);
  animation: pulseAmber 1.6s infinite ease-in-out;
}

.status-spinner-svg {
  animation: spin 0.9s linear infinite;
  display: inline-block;
  flex-shrink: 0;
}

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

/* Antigravity Desktop-style Unread / Completed Task Indicator */
.chat-unread-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #38bdf8;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.95);
  flex-shrink: 0;
  display: inline-block;
  margin-left: auto;
  animation: pulseCyan 2s infinite ease-in-out;
}

@keyframes pulseCyan {
  0%, 100% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(1.3); opacity: 1; box-shadow: 0 0 12px rgba(56, 189, 248, 1); }
}

.pulse-spin {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #60a5fa;
  box-shadow: 0 0 6px #60a5fa;
  animation: pulseDot 1s infinite alternate;
}

@keyframes pulseDot {
  0% { transform: scale(0.7); opacity: 0.5; }
  100% { transform: scale(1.3); opacity: 1; }
}

@keyframes pulseAmber {
  0%, 100% { opacity: 0.85; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.04); }
}

.session-item .item-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
}

.tag-workspace {
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 6px;
  border-radius: 4px;
  color: #a8c7fa;
  font-family: var(--font-mono);
  font-size: 10px;
}

.backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 25;
}

/* Pairing View */
.pairing-card {
  margin: auto;
  max-width: 340px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px 24px;
  text-align: center;
}

.logo-badge {
  width: 50px;
  height: 50px;
  background: #1f6feb;
  color: #fff;
  font-weight: 800;
  font-size: 20px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px auto;
}

.pairing-card h2 {
  font-size: 18px;
  margin-bottom: 8px;
}

.pairing-card .subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 24px;
  line-height: 1.4;
}

.input-group {
  text-align: left;
  margin-bottom: 20px;
}

.input-group label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.input-group input {
  width: 100%;
  padding: 12px;
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  letter-spacing: 4px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: #fff;
  outline: none;
}

.primary-btn {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.apk-download-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border);
  color: #a8c7fa;
  padding: 10px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.apk-download-btn:active {
  background: #252a36;
}

.danger-btn {
  width: 100%;
  background: transparent;
  border: 1px solid var(--red);
  color: var(--red);
  padding: 8px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
}

@keyframes pulse {
  0% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(1.1); }
  100% { opacity: 1; transform: scale(1); }
}

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

/* Media galleries and rich cards */
.chat-media-gallery {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
  width: 100%;
}

.chat-media-card {
  background: #141416;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  margin: 10px 0;
  max-width: 100%;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.chat-media-card.video-card {
  border-color: rgba(255, 255, 255, 0.1);
}

.chat-media-card.audio-card {
  border-color: rgba(255, 255, 255, 0.1);
}

.chat-media-img {
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 400px;
  object-fit: contain;
  display: block;
  cursor: pointer;
  background: #08090b;
  transition: opacity 0.2s;
  border-radius: 16px 16px 0 0;
}

.chat-media-img:active {
  opacity: 0.85;
}

.video-container {
  position: relative;
  width: 100%;
  background: #000;
  display: flex;
  justify-content: center;
}

.chat-media-video {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: contain;
  max-height: 360px;
  background: #000;
  display: block;
  outline: none;
}

.chat-media-audio {
  width: 100%;
  padding: 8px 12px;
  outline: none;
  background: #141416;
}

.compact-limit-dot.unknown {
  background: var(--text-muted);
  box-shadow: none;
}

.msg-status-icon.indeterminate,
.msg-status-icon.failed {
  color: #fbbf24;
}

.ide-errors-panel {
  flex: 0 1 auto;
  min-height: 0;
  max-height: min(32dvh, 270px);
  overflow-y: auto;
  overflow-anchor: none;
  overscroll-behavior: contain;
  padding: 8px 12px;
  border-top: 1px solid #775126;
  background: #241d16;
  color: #f3ddbd;
  font-size: 13px;
  line-height: 1.4;
}
.ide-error-card + .ide-error-card { margin-top: 10px; padding-top: 10px; border-top: 1px solid #59452e; }
.ide-error-title { margin: 0 0 5px; font-size: 13px; font-weight: 600; }
.ide-error-message { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.ide-error-state { margin: 5px 0; color: #cfbcaa; font-size: 12px; }
.ide-error-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; align-items: center; }
.ide-error-button, .ide-error-help {
  appearance: none;
  min-height: 36px;
  padding: 6px 9px;
  border: 1px solid #806342;
  border-radius: 8px;
  background: #3a2d20;
  color: #fff1df;
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}
.ide-error-button:disabled { opacity: .5; cursor: default; }
.ide-error-button.primary { background: #624421; border-color: #b98645; }
.ide-error-copy-fallback { width: 100%; min-height: 90px; margin-top: 7px; color: #fff; background: #171717; font: inherit; }

.chat-media-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  font-size: 11.5px;
  color: var(--text-muted);
  background: #141416;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.chat-media-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 70%;
  font-weight: 500;
  color: #d1d5db;
}

.chat-media-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-media-btn {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: var(--text-main);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.chat-media-btn:active {
  background: rgba(255, 255, 255, 0.2);
}

.chat-media-dl {
  color: var(--accent);
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(47, 129, 247, 0.15);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Links, Chips & Rich Formatting */
.chat-link {
  color: #58a6ff;
  text-decoration: underline;
  text-underline-offset: 3px;
  word-break: break-all;
}

.chat-link:active {
  color: #79c0ff;
}

.chat-file-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(47, 129, 247, 0.12);
  border: 1px solid rgba(47, 129, 247, 0.3);
  padding: 2px 8px;
  border-radius: 6px;
  color: #a8c7fa;
  font-size: 11.5px;
  font-family: var(--font-mono);
  text-decoration: none;
  margin: 2px 2px;
  word-break: break-all;
  vertical-align: middle;
}

.chat-file-chip:active {
  background: rgba(47, 129, 247, 0.25);
}

.chat-conv-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(163, 113, 247, 0.12);
  border: 1px solid rgba(163, 113, 247, 0.3);
  padding: 2px 8px;
  border-radius: 6px;
  color: #d2a8ff;
  font-size: 11.5px;
  text-decoration: none;
  margin: 2px 2px;
  vertical-align: middle;
}

.chat-conv-chip:active {
  background: rgba(163, 113, 247, 0.25);
}

.chat-file-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 6px;
  color: #a8c7fa;
  font-size: 12px;
  text-decoration: none;
  margin: 2px 0;
}

/* Enhanced Markdown styling */
.reply-text h1, .reply-text h2, .reply-text h3 {
  margin: 12px 0 6px 0;
  font-weight: 600;
  color: #fff;
}
.reply-text h1 { font-size: 17px; }
.reply-text h2 { font-size: 15px; }
.reply-text h3 { font-size: 14px; }

.reply-text ul, .reply-text ol {
  padding-left: 20px;
  margin: 6px 0;
}

.reply-text li {
  margin-bottom: 4px;
}

.reply-text blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 10px;
  margin: 8px 0;
  color: var(--text-muted);
  font-style: italic;
}

.reply-text table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 12px;
  overflow-x: auto;
  display: block;
}

.reply-text th, .reply-text td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
}

.reply-text th {
  background: var(--bg-surface-elevated);
  color: #fff;
}

/* Lightbox Modal */
.lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100dvh;
  background: rgba(0, 0, 0, 0.95);
  z-index: 100;
  display: flex;
  flex-direction: column;
}

.lightbox-toolbar {
  height: 52px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(22, 25, 31, 0.8);
  backdrop-filter: blur(10px);
}

.lightbox-title {
  font-size: 13px;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 70%;
}

.lightbox-actions {
  display: flex;
  gap: 12px;
}

.lightbox-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  text-decoration: none;
}

.lightbox-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  overflow: hidden;
  touch-action: none;
  position: relative;
  user-select: none;
}

.lightbox-content img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 6px;
  touch-action: none;
  user-select: none;
  -webkit-user-drag: none;
  transform-origin: center center;
  transition: transform 0.05s ease-out;
  cursor: grab;
}

.lightbox-content img.zoomed {
  cursor: grabbing;
}

.lightbox-content video {
  max-width: 100%;
  max-height: 100%;
  border-radius: 6px;
}

/* --- Drawer AI Usage Limits Card --- */
.drawer-limits-card {
  margin: 10px 14px 12px 14px;
  background: linear-gradient(145deg, rgba(22, 27, 34, 0.95), rgba(13, 17, 23, 0.95));
  border: 1px solid rgba(48, 54, 61, 0.8);
  border-radius: 10px;
  padding: 10px 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.limits-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.limits-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #8b949e;
  text-transform: uppercase;
}

.limits-refresh-btn {
  background: transparent;
  border: none;
  color: #8b949e;
  font-size: 15px;
  cursor: pointer;
  padding: 0 4px;
  border-radius: 4px;
  transition: transform 0.2s, color 0.15s;
}

.limits-refresh-btn:active {
  transform: rotate(180deg);
  color: #58a6ff;
}

.limits-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.limit-box {
  background: rgba(33, 38, 45, 0.7);
  border: 1px solid rgba(48, 54, 61, 0.6);
  border-radius: 8px;
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: border-color 0.2s, background 0.2s;
}

.limit-box-top {
  display: flex;
  align-items: center;
  gap: 5px;
}

.limit-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #3fb950;
  box-shadow: 0 0 6px rgba(63, 185, 80, 0.4);
  transition: background 0.3s, box-shadow 0.3s;
}

.limit-dot.warning {
  background: #d29922;
  box-shadow: 0 0 6px rgba(210, 153, 34, 0.4);
}

.limit-dot.danger {
  background: #f85149;
  box-shadow: 0 0 6px rgba(248, 81, 73, 0.5);
}

.limit-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: #8b949e;
}

.limit-val-row {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.limit-value {
  font-size: 16px;
  font-weight: 700;
  color: #f0f6fc;
  font-family: ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, monospace;
}

.limit-sub {
  font-size: 9px;
  color: #8b949e;
  text-transform: lowercase;
}

/* --- Mobile Queue Pull to Refresh Indicator --- */
.queue-pull-indicator {
  height: 0;
  overflow: hidden;
  opacity: 0;
  transition: height 0.15s ease-out, opacity 0.15s ease-out;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(13, 17, 23, 0.6);
  border-radius: 8px;
  margin: 0 0 6px 0;
}

.queue-pull-indicator.pulling,
.queue-pull-indicator.refreshing {
  opacity: 1;
}

.pull-content {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #8b949e;
  font-weight: 500;
  padding: 6px 12px;
}

.pull-arrow {
  display: inline-block;
  font-size: 14px;
  font-weight: bold;
  color: #58a6ff;
  transition: transform 0.2s ease;
}

.pull-arrow.ready {
  transform: rotate(180deg);
  color: #3fb950;
}

.pull-spinner {
  display: none;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(88, 166, 255, 0.3);
  border-top-color: #58a6ff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.queue-pull-indicator.refreshing .pull-arrow {
  display: none;
}

.queue-pull-indicator.refreshing .pull-spinner {
  display: inline-block;
}

.queue-pull-indicator.refreshing .pull-text {
  color: #58a6ff;
}

/* --- Header AI Limits Chip --- */
.header-limits-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: rgba(88, 166, 255, 0.12);
  border: 1px solid rgba(88, 166, 255, 0.3);
  color: #79c0ff;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 12px;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  transition: all 0.2s ease;
}

.header-limits-badge:hover,
.header-limits-badge:active {
  background: rgba(88, 166, 255, 0.22);
  border-color: rgba(88, 166, 255, 0.5);
}

.header-limits-badge.warning {
  background: rgba(210, 153, 34, 0.15);
  border-color: rgba(210, 153, 34, 0.4);
  color: #e3b341;
}

.header-limits-badge.danger {
  background: rgba(248, 81, 73, 0.15);
  border-color: rgba(248, 81, 73, 0.4);
  color: #f85149;
}

/* ==========================================================================
   Model Selector Chips & Bottom Sheet Modal
   ========================================================================== */
.input-bar-top-shelf {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 4px 4px 4px;
}

.shelf-working-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: 14px;
  padding: 3px 9px;
  font-size: 11px;
  color: #34d399;
  font-weight: 500;
  transition: all 0.2s ease;
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shelf-working-indicator.hidden {
  display: none !important;
}

.shelf-working-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
}

.model-select-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 3px 9px;
  color: #e6edf3;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
}

.model-select-chip:active {
  transform: scale(0.96);
  background: rgba(255, 255, 255, 0.12);
}

.model-chip-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #38bdf8;
  box-shadow: 0 0 6px #38bdf8;
  flex-shrink: 0;
}

.model-chip-dot.claude {
  background: #d97706;
  box-shadow: 0 0 6px #d97706;
}

.model-chip-dot.opus {
  background: #a855f7;
  box-shadow: 0 0 8px #a855f7;
}

.model-chip-dot.oss {
  background: #eab308;
  box-shadow: 0 0 6px #eab308;
}

.model-chip-arrow {
  font-size: 9px;
  opacity: 0.6;
}

.header-model-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 10px;
  padding: 2px 7px;
  color: #38bdf8;
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  user-select: none;
  transition: all 0.15s ease;
}

.header-model-chip:active {
  transform: scale(0.96);
}

.header-model-chip .header-model-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #38bdf8;
  box-shadow: 0 0 5px #38bdf8;
  flex-shrink: 0;
}

.header-model-chip .header-model-dot.opus {
  background: #a855f7;
  box-shadow: 0 0 6px #a855f7;
}

.header-model-chip.opus {
  background: rgba(168, 85, 247, 0.14);
  border-color: rgba(168, 85, 247, 0.35);
  color: #c084fc;
}

.header-model-chip .header-model-dot.claude {
  background: #f59e0b;
  box-shadow: 0 0 5px #f59e0b;
}

.header-model-chip.claude {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.35);
  color: #fbbf24;
}

/* Modal Sheet */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 10000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  transition: opacity 0.2s ease;
}

.modal-backdrop.hidden {
  display: none !important;
}

.model-picker-sheet {
  width: 100%;
  max-width: 540px;
  background: #16181d;
  border-top-left-radius: 22px;
  border-top-right-radius: 22px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  padding: 12px 16px calc(24px + env(safe-area-inset-bottom, 16px)) 16px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  animation: sheetPopUp 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.85);
}

@keyframes sheetPopUp {
  from { transform: translateY(100%); opacity: 0.6; }
  to { transform: translateY(0); opacity: 1; }
}

.sheet-drag-handle {
  width: 40px;
  height: 4px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 2px;
  margin: 0 auto 14px auto;
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sheet-title-group h3 {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  margin: 0 0 3px 0;
}

.sheet-subtitle {
  font-size: 11px;
  color: #8b949e;
}

.sheet-close-btn {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: #c9d1d9;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: background 0.15s ease;
}

.sheet-close-btn:active {
  background: rgba(255, 255, 255, 0.18);
}

.models-list-container {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 2px;
  padding-bottom: 54px;
  max-height: 70vh;
}

.model-option-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
}

.model-option-card:active {
  transform: scale(0.98);
}

.model-option-card.active {
  background: rgba(56, 189, 248, 0.12);
  border-color: rgba(56, 189, 248, 0.45);
}

.model-option-card.active.opus {
  background: rgba(168, 85, 247, 0.14);
  border-color: rgba(168, 85, 247, 0.5);
}

.model-option-card.active.sonnet {
  background: rgba(245, 158, 11, 0.14);
  border-color: rgba(245, 158, 11, 0.5);
}

.model-option-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.model-option-name {
  font-size: 14px;
  font-weight: 600;
  color: #f3f4f6;
  display: flex;
  align-items: center;
  gap: 8px;
}

.model-option-desc {
  font-size: 11px;
  color: #8b949e;
}

.model-option-tag {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 8px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.tag-thinking {
  background: rgba(168, 85, 247, 0.2);
  color: #c084fc;
}

.tag-fast {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
}

.tag-pro {
  background: rgba(46, 204, 113, 0.15);
  color: #2ecc71;
}

.tag-oss {
  background: rgba(234, 179, 8, 0.15);
  color: #facc15;
}

.model-option-check {
  font-size: 16px;
  color: #38bdf8;
  font-weight: bold;
}

.model-option-card.active.opus .model-option-check {
  color: #c084fc;
}

.model-option-card.active.sonnet .model-option-check {
  color: #fbbf24;
}

/* ==========================================================================
   Tag Color Palette Modal (macOS Finder / Antigravity Desktop Style)
   ========================================================================== */
.tag-palette-card {
  width: 92%;
  max-width: 320px;
  background: #181a20;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 18px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.85);
  margin: auto;
  animation: popScale 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes popScale {
  from { transform: scale(0.9); opacity: 0.5; }
  to { transform: scale(1); opacity: 1; }
}

.palette-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.palette-header h4 {
  font-size: 13.5px;
  font-weight: 600;
  color: #fff;
  margin: 0;
}

.palette-colors-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 8px 0;
}

.palette-color-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease;
  flex-shrink: 0;
}

.palette-color-btn:active {
  transform: scale(1.25);
}

.palette-clear-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #8b949e;
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
}

.palette-clear-btn:active {
  background: rgba(248, 81, 73, 0.15);
  color: #f85149;
  border-color: rgba(248, 81, 73, 0.4);
}

/* ── Thinking-in-progress bubble ─────────────────────── */
.thinking-in-progress-bubble {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  margin: 4px 12px 4px auto;
  max-width: 200px;
  background: rgba(139, 92, 246, 0.10);
  border: 1px solid rgba(139, 92, 246, 0.25);
  border-radius: 18px 18px 4px 18px;
  color: #a78bfa;
  font-size: 13px;
  font-weight: 500;
}

.thinking-brain {
  font-size: 16px;
  flex-shrink: 0;
}

.thinking-pulse-text {
  display: flex;
  align-items: baseline;
  gap: 1px;
}

.thinking-dots {
  display: inline-flex;
  gap: 2px;
  margin-left: 1px;
}

.thinking-dots span {
  animation: thinkDot 1.2s infinite ease-in-out;
  opacity: 0;
}
.thinking-dots span:nth-child(1) { animation-delay: 0s; }
.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes thinkDot {
  0%, 80%, 100% { opacity: 0; }
  40% { opacity: 1; }
}

/* ── Thought details — bigger tap target on mobile ─── */
.thought-summary {
  padding: 5px 0;
  min-height: 36px;
}
