:root {
  --bg-primary: #090d16;
  --bg-secondary: #0f172a;
  --bg-card: #1e293b;
  --bg-hover: #273549;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-active: rgba(99, 102, 241, 0.4);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-glow: rgba(99, 102, 241, 0.25);
  --accent-cyan: #06b6d4;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --header-height: 64px;

  /* Font Scaling Variables (Default: md) */
  --chat-font-size: 0.95rem;
  --user-msg-font-size: 0.95rem;
  --thought-font-size: 0.85rem;
  --tool-summary-font-size: 0.82rem;
  --tool-title-font-size: 0.8rem;
  --tool-body-font-size: 0.74rem;
  --code-font-size: 0.88rem;
  --chat-input-font-size: 0.95rem;
}

/* Font Scaling Presets */
[data-font-size="xs"] {
  --chat-font-size: 0.74rem;
  --user-msg-font-size: 0.74rem;
  --thought-font-size: 0.68rem;
  --tool-summary-font-size: 0.66rem;
  --tool-title-font-size: 0.65rem;
  --tool-body-font-size: 0.62rem;
  --code-font-size: 0.70rem;
  --chat-input-font-size: 0.78rem;
}

[data-font-size="sm"] {
  --chat-font-size: 0.84rem;
  --user-msg-font-size: 0.84rem;
  --thought-font-size: 0.76rem;
  --tool-summary-font-size: 0.74rem;
  --tool-title-font-size: 0.72rem;
  --tool-body-font-size: 0.68rem;
  --code-font-size: 0.79rem;
  --chat-input-font-size: 0.86rem;
}

[data-font-size="md"] {
  --chat-font-size: 0.95rem;
  --user-msg-font-size: 0.95rem;
  --thought-font-size: 0.85rem;
  --tool-summary-font-size: 0.82rem;
  --tool-title-font-size: 0.8rem;
  --tool-body-font-size: 0.74rem;
  --code-font-size: 0.88rem;
  --chat-input-font-size: 0.95rem;
}

[data-font-size="lg"] {
  --chat-font-size: 1.12rem;
  --user-msg-font-size: 1.12rem;
  --thought-font-size: 0.96rem;
  --tool-summary-font-size: 0.92rem;
  --tool-title-font-size: 0.9rem;
  --tool-body-font-size: 0.84rem;
  --code-font-size: 1.02rem;
  --chat-input-font-size: 1.08rem;
}

[data-font-size="xl"] {
  --chat-font-size: 1.28rem;
  --user-msg-font-size: 1.28rem;
  --thought-font-size: 1.08rem;
  --tool-summary-font-size: 1.02rem;
  --tool-title-font-size: 1.0rem;
  --tool-body-font-size: 0.94rem;
  --code-font-size: 1.15rem;
  --chat-input-font-size: 1.18rem;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  height: 100dvh;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ================= AUTH SCREEN ================= */
.auth-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px;
  background: radial-gradient(circle at 50% 20%, #1e1b4b 0%, #090d16 65%);
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 40px 32px;
  text-align: center;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), 0 0 40px var(--primary-glow);
}

.brand-badge {
  width: 72px;
  height: 72px;
  margin: 0 auto 20px;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 25px rgba(99, 102, 241, 0.4);
}

.brand-icon {
  color: #fff;
}

.auth-title {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.auth-subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 24px;
}

.security-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: var(--radius-full);
  padding: 8px 16px;
  font-size: 0.85rem;
  color: #c7d2fe;
  margin-bottom: 28px;
}

.google-signin-wrapper {
  display: flex;
  justify-content: center;
  margin-bottom: 24px;
}

.auth-footer {
  font-size: 0.8rem;
  color: var(--text-dim);
  border-top: 1px solid var(--border-color);
  padding-top: 18px;
}

/* ================= APP LAYOUT ================= */
.app-layout {
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100vh;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
  position: relative;
}

/* Top Header - Always visible & sticky */
.app-header {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  height: var(--header-height);
  background: rgba(15, 23, 42, 0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 100;
  flex-shrink: 0;
}

.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.app-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--text-main);
}

.app-logo svg {
  color: var(--primary);
}

.system-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  padding: 4px 12px;
  font-size: 0.82rem;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
}

.live-dot.pulse {
  box-shadow: 0 0 10px var(--success);
  animation: pulse-animation 2s infinite;
}

@keyframes pulse-animation {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

.system-name {
  font-weight: 600;
  color: #e2e8f0;
}

.system-metrics {
  color: var(--text-dim);
  font-size: 0.78rem;
  font-family: var(--font-mono);
}

.header-center {
  flex: 1;
  min-width: 0;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 16px;
}

.current-task-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
  display: inline-block;
}

.user-pill {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  padding: 4px 14px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-main);
}

#toggleCollapseBtn.active {
  background: rgba(99, 102, 241, 0.2);
  color: #a5b4fc;
}

.sidebar-collapse-btn {
  margin-top: 8px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 0.82rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.sidebar-collapse-btn:hover {
  background: var(--bg-hover);
  color: var(--text-main);
  border-color: rgba(99, 102, 241, 0.3);
}

.sidebar-collapse-btn.active {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.4);
  color: #c7d2fe;
}

/* Font Size Switcher Button & Toast Popup */
.font-size-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 9px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  border: 1px solid transparent;
  transition: all 0.15s ease;
  user-select: none;
  cursor: pointer;
}

.font-size-btn:hover {
  background: var(--bg-hover);
  color: var(--text-main);
  border-color: var(--border-color);
}

.font-size-btn.active {
  background: rgba(99, 102, 241, 0.2);
  border-color: rgba(99, 102, 241, 0.4);
  color: #c7d2fe;
}

.font-size-btn svg {
  flex-shrink: 0;
}

.font-size-badge {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  background: rgba(99, 102, 241, 0.2);
  color: #c7d2fe;
  border: 1px solid rgba(99, 102, 241, 0.35);
  padding: 2px 5px;
  border-radius: 4px;
  min-width: 14px;
  text-align: center;
}

.font-size-toast {
  position: fixed;
  top: calc(var(--header-height) + 8px);
  right: 16px;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid rgba(99, 102, 241, 0.45);
  color: #f8fafc;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6), 0 0 20px var(--primary-glow);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 1000;
  opacity: 0;
  transform: translateY(-8px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1), transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 290px;
  max-width: calc(100vw - 32px);
}

.font-size-toast.show {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.font-size-toast-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 600;
  color: #c7d2fe;
  padding: 0 2px;
}

.font-size-options {
  display: flex;
  gap: 5px;
  background: rgba(0, 0, 0, 0.25);
  padding: 3px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.font-size-opt-btn {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px 3px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.font-size-opt-btn small {
  font-family: var(--font-sans);
  font-size: 0.6rem;
  font-weight: 500;
  color: var(--text-dim);
  margin-top: 2px;
  white-space: nowrap;
}

.font-size-opt-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.font-size-opt-btn.active {
  background: var(--primary);
  border-color: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
}

.font-size-opt-btn.active small {
  color: #e0e7ff;
}

.mobile-only {
  display: none;
}

/* ================= WORKSPACE PANELS ================= */
.app-main {
  display: flex;
  flex: 1;
  min-height: 0;
  height: calc(100vh - var(--header-height));
  height: calc(100dvh - var(--header-height));
  overflow: hidden;
}

/* Sidebar */
.app-sidebar {
  width: 320px;
  min-width: 320px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
}

.sidebar-top {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.primary-btn {
  background: linear-gradient(135deg, var(--primary), #818cf8);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  padding: 10px 18px;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.3);
}

.primary-btn:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.secondary-btn {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 18px;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
}

.search-box svg {
  color: var(--text-dim);
}

.search-box input {
  background: none;
  border: none;
  color: var(--text-main);
  outline: none;
  width: 100%;
  font-size: 0.88rem;
}

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

.conv-item {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid transparent;
}

.conv-item:hover {
  background: var(--bg-hover);
}

.conv-item.active {
  background: rgba(99, 102, 241, 0.12);
  border-color: var(--border-active);
}

.conv-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.conv-item-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conv-item-time {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.conv-item-preview {
  font-size: 0.8rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conv-item-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.conv-item-project {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(99, 102, 241, 0.14);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.25);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conv-item-status-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
}

.header-project-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.15);
  color: #c7d2fe;
  border: 1px solid rgba(99, 102, 241, 0.3);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-select {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-input, rgba(15, 23, 42, 0.8));
  color: var(--text-main);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  cursor: pointer;
}

.project-select:focus {
  border-color: var(--primary);
}

.conv-loading {
  text-align: center;
  padding: 30px 10px;
  color: var(--text-dim);
  font-size: 0.9rem;
}

/* ================= CHAT VIEWPORT ================= */
.chat-viewport {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  position: relative;
  overflow: hidden;
}

.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  color: var(--text-dim);
  gap: 12px;
}

.empty-state h2 {
  font-size: 1.3rem;
  color: var(--text-main);
}

.empty-state p {
  font-size: 0.95rem;
  max-width: 400px;
}

/* Message Bubbles */
.message-row {
  display: flex;
  flex-direction: column;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
}

.message-row.user {
  align-items: flex-end;
}

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

/* Interaction Meta Badge (Úvodné zadanie / Interakcia #X) */
.interaction-tag {
  align-self: flex-end;
  display: inline-flex;
  align-items: center;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #a5b4fc;
  margin-bottom: 5px;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.25);
  user-select: none;
}

.interaction-tag.initial {
  color: #38bdf8;
  background: rgba(6, 182, 212, 0.15);
  border-color: rgba(6, 182, 212, 0.3);
}

.user-bubble {
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  color: #fff;
  padding: 14px 20px;
  border-radius: 18px 18px 4px 18px;
  max-width: 80%;
  font-size: var(--user-msg-font-size, 0.95rem);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
  white-space: pre-wrap;
  word-break: break-word;
}

.assistant-container {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 18px 18px 18px 4px;
  padding: 14px 18px;
  width: 100%;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  transition: padding 0.15s ease, background 0.15s ease;
}

.assistant-collapse-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 10px 10px 0 0;
  margin: -14px -18px 14px -18px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s ease;
}

.assistant-collapse-header:hover {
  background: rgba(255, 255, 255, 0.06);
}

.assistant-collapse-left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #a5b4fc;
}

.assistant-collapse-title {
  color: #cbd5e1;
}

.assistant-tool-badge {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  background: rgba(99, 102, 241, 0.18);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.assistant-collapse-right {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.74rem;
  color: var(--text-dim);
}

.assistant-collapse-chevron {
  transition: transform 0.2s ease;
  display: inline-block;
  font-size: 0.7rem;
}

.assistant-container.collapsed {
  padding: 0;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.6);
}

.assistant-container.collapsed .assistant-collapse-header {
  margin: 0;
  padding: 9px 14px;
  border-bottom: none;
  border-radius: 10px;
}

.assistant-container.collapsed .assistant-collapse-chevron {
  transform: rotate(-90deg);
}

.assistant-container.collapsed .assistant-body {
  display: none;
}

/* Thought Accordion */
.thought-box {
  background: rgba(0, 0, 0, 0.25);
  border-left: 3px solid #818cf8;
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: var(--thought-font-size, 0.85rem);
}

.thought-box summary {
  cursor: pointer;
  font-weight: 600;
  color: #a5b4fc;
  user-select: none;
  outline: none;
}

.thought-content {
  margin-top: 10px;
  color: #cbd5e1;
  font-style: italic;
  white-space: pre-wrap;
  max-height: 250px;
  overflow-y: auto;
}

/* Tool Calls Block (Consolidated) */
.tool-block {
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  margin-bottom: 14px;
  overflow: hidden;
  backdrop-filter: blur(8px);
}

.tool-block-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  cursor: pointer;
  user-select: none;
  font-size: var(--tool-summary-font-size, 0.82rem);
  font-weight: 600;
  color: #94a3b8;
  transition: background 0.15s, color 0.15s;
}

.tool-block-summary:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #f1f5f9;
}

.tool-block-summary::-webkit-details-marker {
  display: none;
}

.tool-block-summary-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tool-block-icon {
  color: var(--accent-cyan);
  flex-shrink: 0;
}

.tool-block-title {
  letter-spacing: 0.2px;
}

.tool-count-badge {
  background: rgba(99, 102, 241, 0.2);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.3);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 10px;
  margin-left: 4px;
}

.tool-block-chevron {
  font-size: 0.7rem;
  color: #64748b;
  transition: transform 0.2s ease;
}

.tool-block[open] .tool-block-chevron {
  transform: rotate(180deg);
}

.tool-list {
  display: flex;
  flex-direction: column;
  max-height: 380px;
  overflow-y: auto;
  padding: 2px 0;
}

.tool-list::-webkit-scrollbar {
  width: 6px;
}
.tool-list::-webkit-scrollbar-track {
  background: transparent;
}
.tool-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 3px;
}
.tool-list::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Individual Tool Row */
.tool-row {
  border-bottom: 1px solid rgba(255, 255, 255, 0.035);
}
.tool-row:last-child {
  border-bottom: none;
}

.tool-row-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 14px;
  cursor: pointer;
  user-select: none;
  font-size: var(--tool-title-font-size, 0.8rem);
  transition: background 0.12s ease;
}

.tool-row-summary:hover {
  background: rgba(255, 255, 255, 0.04);
}

.tool-row-summary::-webkit-details-marker {
  display: none;
}

.tool-badge {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  flex-shrink: 0;
  background: rgba(6, 182, 212, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(6, 182, 212, 0.25);
}

.tool-badge-cmd {
  background: rgba(129, 140, 248, 0.15);
  color: #a5b4fc;
  border-color: rgba(129, 140, 248, 0.3);
}

.tool-badge-file {
  background: rgba(56, 189, 248, 0.15);
  color: #7dd3fc;
  border-color: rgba(56, 189, 248, 0.3);
}

.tool-badge-edit {
  background: rgba(52, 211, 153, 0.15);
  color: #6ee7b7;
  border-color: rgba(52, 211, 153, 0.3);
}

.tool-badge-search {
  background: rgba(251, 191, 36, 0.15);
  color: #fde68a;
  border-color: rgba(251, 191, 36, 0.3);
}

.tool-title {
  color: #e2e8f0;
  font-family: var(--font-sans);
  font-size: var(--tool-title-font-size, 0.8rem);
  font-weight: 500;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool-chevron {
  font-size: 0.85rem;
  color: #64748b;
  flex-shrink: 0;
  transition: transform 0.15s ease;
  margin-left: auto;
}

.tool-row[open] .tool-chevron {
  transform: rotate(90deg);
}

.tool-row-body {
  padding: 6px 14px 10px 14px;
  background: rgba(0, 0, 0, 0.25);
  border-top: 1px solid rgba(255, 255, 255, 0.03);
}

.tool-row-body pre {
  margin: 0;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: var(--tool-body-font-size, 0.74rem);
  color: #cbd5e1;
  max-height: 200px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* Markdown Rendering */
.markdown-body {
  color: var(--text-main);
  font-size: var(--chat-font-size, 0.95rem);
  line-height: 1.65;
}

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

.markdown-body p:last-child {
  margin-bottom: 0;
}

.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 {
  margin-top: 18px;
  margin-bottom: 10px;
  color: #f1f5f9;
}

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

.markdown-body li {
  margin-bottom: 4px;
}

.markdown-body code {
  font-family: var(--font-mono);
  background: rgba(0, 0, 0, 0.35);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: var(--code-font-size, 0.88rem);
  color: #e2e8f0;
}

.markdown-body pre {
  background: #0f172a !important;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 14px;
  overflow-x: auto;
  margin: 14px 0;
}

.markdown-body pre code {
  padding: 0;
  background: none;
  font-size: calc(var(--code-font-size, 0.88rem) * 0.96);
}

.markdown-body a {
  color: #818cf8;
  text-decoration: none;
}

.markdown-body a:hover {
  text-decoration: underline;
}

/* Activity Banner */
.agent-activity-bar {
  background: rgba(99, 102, 241, 0.15);
  border-top: 1px solid rgba(99, 102, 241, 0.3);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.88rem;
  color: #c7d2fe;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(99, 102, 241, 0.3);
  border-top-color: #a5b4fc;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Chat Input Bar */
.chat-input-area {
  padding: 16px 32px 24px;
  background: var(--bg-primary);
  border-top: 1px solid var(--border-color);
}

.input-form {
  max-width: 900px;
  margin: 0 auto;
}

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  transition: border-color 0.2s;
}

.input-wrapper:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-glow);
}

.input-wrapper textarea {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-main);
  outline: none;
  font-family: var(--font-sans);
  font-size: var(--chat-input-font-size, 0.95rem);
  line-height: 1.4;
  resize: none;
  max-height: 180px;
}

.send-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.send-btn:hover {
  background: var(--primary-hover);
  transform: scale(1.05);
}

.attach-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  flex-shrink: 0;
}

.attach-btn:hover {
  color: var(--primary);
  background: rgba(99, 102, 241, 0.12);
}

.attach-btn:active {
  transform: scale(0.95);
}

/* Attachment Preview Bar */
.attachment-preview-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  max-width: 900px;
  margin: 0 auto 10px auto;
  padding: 4px 2px;
}

.attachment-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 0.85rem;
  color: var(--text-main);
  max-width: 260px;
  position: relative;
  transition: border-color 0.2s, background 0.2s;
  animation: fadeIn 0.2s ease-out;
}

.attachment-chip.uploading {
  opacity: 0.75;
  border-style: dashed;
}

.attachment-chip-thumb {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  object-fit: cover;
  background: #000;
  flex-shrink: 0;
}

.attachment-chip-icon {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  background: rgba(99, 102, 241, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  flex-shrink: 0;
}

.attachment-chip-meta {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex: 1;
  min-width: 0;
}

.attachment-chip-name {
  font-weight: 500;
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.attachment-chip-size {
  font-size: 0.72rem;
  color: var(--text-dim);
}

.attachment-chip-remove {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
  transition: color 0.15s, background 0.15s;
}

.attachment-chip-remove:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.15);
}

/* Drag & Drop Overlay */
.drop-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(9, 13, 22, 0.9);
  backdrop-filter: blur(8px);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px dashed var(--primary);
  border-radius: var(--radius-md);
  margin: 12px;
  pointer-events: none;
  animation: fadeIn 0.15s ease-out;
}

.drop-overlay-box {
  text-align: center;
  color: #c7d2fe;
}

.drop-overlay-box svg {
  color: var(--primary);
  margin-bottom: 12px;
  animation: bounce 1.2s infinite;
}

.drop-overlay-box h3 {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: #fff;
}

.drop-overlay-box p {
  font-size: 0.9rem;
  color: var(--text-muted);
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Image Lightbox Modal */
.image-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(10px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.image-modal-content {
  max-width: 90vw;
  max-height: 90vh;
  position: relative;
  display: flex;
  flex-direction: column;
  background: #0f172a;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.6);
}

.image-modal-content img {
  max-width: 100%;
  max-height: calc(90vh - 70px);
  object-fit: contain;
  background: #090d16;
}

.image-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(0, 0, 0, 0.6);
  border: none;
  color: #fff;
  font-size: 24px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  z-index: 10;
}

.image-modal-close:hover {
  background: var(--danger);
}

.image-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: #0f172a;
  border-top: 1px solid var(--border-color);
  font-size: 0.88rem;
  color: var(--text-muted);
}

/* Chat Bubble Attachments */
.user-bubble-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.user-attached-image-wrapper {
  position: relative;
  cursor: pointer;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: transform 0.2s, box-shadow 0.2s;
  max-width: 300px;
}

.user-attached-image-wrapper:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.user-attached-image {
  display: block;
  width: 100%;
  max-height: 240px;
  object-fit: cover;
  background: #000;
}

.user-image-label {
  display: block;
  padding: 4px 8px;
  font-size: 0.72rem;
  background: rgba(0, 0, 0, 0.65);
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-attached-file-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  color: #fff;
  text-decoration: none;
  font-size: 0.82rem;
  transition: background 0.2s;
}

.user-attached-file-badge:hover {
  background: rgba(255, 255, 255, 0.25);
  text-decoration: none;
}

/* ================= MODAL ================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}

.modal-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  padding: 28px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

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

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
}

.modal-close {
  font-size: 1.5rem;
  line-height: 1;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.form-group input, .form-group textarea {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus, .form-group textarea:focus {
  border-color: var(--primary);
}

.model-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.model-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.2s;
}

.model-option:hover {
  border-color: rgba(99, 102, 241, 0.4);
}

.model-option input {
  width: auto;
  margin-top: 3px;
}

.model-info strong {
  display: block;
  font-size: 0.9rem;
  color: var(--text-main);
}

.model-info small {
  display: block;
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 2px;
}

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

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

  .system-badge, .system-metrics, .user-email, .user-pill {
    display: none !important;
  }

  .app-header {
    height: 56px;
    padding: 0 10px;
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 100;
    flex-shrink: 0;
  }

  .header-left, .header-right {
    gap: 6px;
    flex-shrink: 0;
  }

  .header-center {
    min-width: 0;
    padding: 0 4px;
  }

  .current-task-title {
    font-size: 0.86rem;
    max-width: 170px;
  }

  .font-size-btn {
    padding: 6px 6px;
  }

  .font-size-toast {
    right: 8px;
    left: 8px;
    top: 60px;
    min-width: 0;
    max-width: none;
    padding: 8px 10px;
  }

  .app-sidebar {
    position: absolute;
    top: 56px;
    bottom: 0;
    left: 0;
    z-index: 30;
    transform: translateX(-100%);
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
  }

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

  .messages-container {
    padding: 14px 12px;
  }

  .chat-input-area {
    padding: 10px 12px 14px;
  }

  .model-picker {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .app-logo span {
    display: none;
  }

  .header-center {
    padding: 0 4px;
  }

  .current-task-title {
    max-width: 120px;
    font-size: 0.82rem;
  }

  .font-size-opt-btn small {
    display: none;
  }

  .font-size-opt-btn {
    padding: 8px 4px;
    font-size: 0.85rem;
  }
}

/* ============================================================
   DATA USAGE TELEMETRY & SIDEBAR FOOTER (Hamburger Menu)
   ============================================================ */
.sidebar-footer {
  padding: 10px 12px;
  border-top: 1px solid var(--border-color);
  background: rgba(15, 23, 42, 0.4);
  margin-top: auto;
}

.sidebar-footer-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

.sidebar-footer-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--primary-color);
}

.sidebar-footer-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-footer-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-color);
}

.sidebar-footer-text {
  display: flex;
  flex-direction: column;
}

.sidebar-footer-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: #f1f5f9;
}

.sidebar-footer-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: var(--font-mono, monospace);
}

.sidebar-footer-badge {
  font-size: 0.72rem;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
  font-weight: 600;
  font-family: var(--font-mono, monospace);
  border: 1px solid rgba(99, 102, 241, 0.3);
}

/* Data Usage Modal */
.data-usage-modal-card {
  max-width: 580px;
  width: 95%;
}

.data-usage-modal-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 12px;
}

.data-usage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}

.data-usage-card {
  background: var(--bg-surface, #1e293b);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.data-usage-card-label {
  font-size: 0.73rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.data-usage-card-val {
  font-size: 1.35rem;
  font-weight: 700;
  color: #fff;
  font-family: var(--font-mono, monospace);
}

.data-usage-card-val.highlight {
  color: #38bdf8;
}

.data-usage-card-split {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.data-usage-card-split strong {
  color: #e2e8f0;
}

.data-usage-section {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px 14px;
}

.data-usage-section-title {
  margin: 0 0 10px 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: #e2e8f0;
}

.data-usage-breakdown-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.breakdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.03);
}

.breakdown-info {
  display: flex;
  flex-direction: column;
}

.breakdown-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: #f1f5f9;
}

.breakdown-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.breakdown-val {
  font-size: 0.85rem;
  font-weight: 600;
  color: #a5b4fc;
  font-family: var(--font-mono, monospace);
}

.data-usage-meta-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.25);
  color: #34d399;
  font-size: 0.75rem;
}

/* ==============================================================
   MODEL SELECTOR & DUAL QUOTA (5H & WEEKLY) STYLES
   ============================================================== */

/* --- Header Model Selector --- */
.header-model-picker {
  position: relative;
  display: inline-block;
}

.header-model-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.35);
  color: #e0e7ff;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.header-model-btn:hover {
  background: rgba(99, 102, 241, 0.22);
  border-color: rgba(99, 102, 241, 0.6);
  color: #ffffff;
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.3);
}

.model-sparkle {
  font-size: 0.9rem;
  color: #fbbf24;
}

.header-model-label {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chevron-down {
  opacity: 0.7;
  transition: transform 0.2s ease;
}

.header-model-picker.open .chevron-down {
  transform: rotate(180deg);
}

/* Header Model Dropdown */
.header-model-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 320px;
  max-width: 90vw;
  background: rgba(15, 23, 42, 0.96);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(99, 102, 241, 0.35);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.05);
  z-index: 1000;
  overflow: hidden;
  animation: dropdownFadeIn 0.18s ease-out;
}

@keyframes dropdownFadeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.hmd-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--border-color);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}

.hmd-tier-pill {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #34d399;
}

.hmd-models-list {
  max-height: 360px;
  overflow-y: auto;
  padding: 6px;
}

.hmd-model-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-main);
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
}

.hmd-model-item:hover {
  background: rgba(99, 102, 241, 0.1);
  border-color: rgba(99, 102, 241, 0.25);
}

.hmd-model-item.active {
  background: rgba(99, 102, 241, 0.18);
  border-color: rgba(99, 102, 241, 0.5);
}

.hmd-model-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.hmd-model-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.83rem;
  font-weight: 600;
  color: #f8fafc;
}

.hmd-tag-pill {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.08);
  color: #94a3b8;
}

.hmd-tag-pill.pro {
  background: rgba(147, 51, 234, 0.18);
  color: #c084fc;
  border: 1px solid rgba(147, 51, 234, 0.3);
}

.hmd-tag-pill.flash {
  background: rgba(6, 182, 212, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(6, 182, 212, 0.3);
}

.hmd-tag-pill.claude {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.hmd-model-sub {
  font-size: 0.72rem;
  color: var(--text-dim);
}

.hmd-model-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  flex-shrink: 0;
}

.hmd-quota-badge {
  font-size: 0.75rem;
  font-weight: 700;
  font-family: var(--font-mono, monospace);
  color: #10b981;
}

.hmd-quota-badge.warning {
  color: #f59e0b;
}

.hmd-quota-badge.danger {
  color: #ef4444;
}

.hmd-reset-time {
  font-size: 0.68rem;
  color: var(--text-dim);
}

.hmd-footer {
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.2);
  border-top: 1px solid var(--border-color);
  text-align: center;
}

.hmd-footer-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  color: #a5b4fc;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: color 0.15s ease;
}

.hmd-footer-link:hover {
  color: #ffffff;
  text-decoration: underline;
}

/* --- Header Quota Pills (5h & Weekly) --- */
.quota-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.quota-pill-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.3);
}

.quota-5h-pill {
  border-color: rgba(6, 182, 212, 0.25);
  background: rgba(6, 182, 212, 0.06);
}

.quota-5h-pill:hover {
  background: rgba(6, 182, 212, 0.12);
  border-color: rgba(6, 182, 212, 0.45);
}

.quota-weekly-pill {
  border-color: rgba(16, 185, 129, 0.25);
  background: rgba(16, 185, 129, 0.06);
}

.quota-weekly-pill:hover {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.45);
}

.quota-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.quota-dot-green {
  background: #10b981;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
}

.quota-dot-yellow {
  background: #f59e0b;
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.6);
}

.quota-dot-red {
  background: #ef4444;
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.6);
}

.quota-pill-label {
  color: var(--text-muted);
  font-size: 0.74rem;
}

.quota-pill-val {
  font-family: var(--font-mono, monospace);
  font-size: 0.8rem;
  font-weight: 700;
  color: #f8fafc;
}

.quota-pill-timer {
  color: var(--text-dim);
  font-size: 0.7rem;
}

/* --- Chat Input Toolbar (Above Textarea) --- */
.chat-input-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 12px;
  margin-bottom: 6px;
  border-radius: var(--radius-sm);
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

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

.cit-model-wrapper {
  position: relative;
}

.cit-model-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: #c7d2fe;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.cit-model-btn:hover {
  background: rgba(99, 102, 241, 0.22);
  border-color: rgba(99, 102, 241, 0.5);
  color: #ffffff;
}

.cit-model-sparkle {
  font-size: 0.75rem;
  color: #fbbf24;
}

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

.cit-model-dropdown {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  width: 290px;
  max-width: 88vw;
  background: rgba(15, 23, 42, 0.98);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(99, 102, 241, 0.4);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.7);
  z-index: 1000;
  overflow: hidden;
}

.cit-dropdown-header {
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--border-color);
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-muted);
}

.cit-dropdown-list {
  max-height: 280px;
  overflow-y: auto;
  padding: 4px;
}

.conv-model-pill {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-dim);
  white-space: nowrap;
}

.cit-right {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.cit-quota-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.74rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

.cit-quota-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
}

.cit-q-badge strong {
  font-family: var(--font-mono, monospace);
  color: #34d399;
}

.cit-q-sep {
  color: var(--text-dim);
  font-size: 0.65rem;
}

/* --- Quota & Limits Detail Modal --- */
.quota-modal-card {
  max-width: 680px;
  width: 95%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.quota-modal-body {
  overflow-y: auto;
  padding-right: 4px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.quota-tier-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(6, 182, 212, 0.12));
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.qtb-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.qtb-badge {
  font-size: 0.95rem;
  font-weight: 800;
  color: #f8fafc;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.qtb-desc {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.qtb-credits {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.qtb-credits-val {
  font-family: var(--font-mono, monospace);
  font-size: 1.25rem;
  font-weight: 800;
  color: #38bdf8;
}

.qtb-credits-lbl {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.quota-windows-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

.quota-window-card {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.qwc-title-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.qwc-title-wrap h4 {
  font-size: 0.88rem;
  font-weight: 700;
  color: #f8fafc;
}

.qwc-timer-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.06);
  color: #94a3b8;
}

.qwc-metric {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.qwc-percent {
  font-family: var(--font-mono, monospace);
  font-size: 1.8rem;
  font-weight: 800;
  color: #10b981;
}

.qwc-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.qwc-progress-track {
  width: 100%;
  height: 8px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.qwc-progress-bar {
  height: 100%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, #10b981, #06b6d4);
  transition: width 0.4s ease;
}

.qwc-progress-bar.warning {
  background: linear-gradient(90deg, #f59e0b, #ef4444);
}

.qwc-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.qwc-expl {
  font-size: 0.72rem;
  color: var(--text-dim);
  line-height: 1.35;
  margin-top: 2px;
}

/* Official Antigravity IDE Quota Groups (View Usage) */
.quota-ide-groups-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.quota-ide-groups-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.quota-ide-group-card {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color 0.2s ease;
}

.quota-ide-group-card:hover {
  border-color: rgba(255, 255, 255, 0.18);
}

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

.quota-ide-group-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: #f8fafc;
}

.quota-ide-group-desc {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: -6px;
}

.quota-ide-buckets-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.quota-ide-bucket-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.quota-ide-bucket-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.quota-ide-bucket-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: #e2e8f0;
}

.quota-ide-bucket-pct {
  font-family: var(--font-mono, monospace);
  font-size: 0.84rem;
  font-weight: 700;
}

.quota-ide-bucket-track {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}

.quota-ide-bucket-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #3b82f6, #06b6d4);
  transition: width 0.35s ease;
}

.quota-ide-bucket-fill.warning {
  background: linear-gradient(90deg, #f59e0b, #ef4444);
}

.quota-ide-bucket-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-dim);
}

/* Models breakdown section */
.quota-models-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.qms-header h4 {
  font-size: 0.88rem;
  font-weight: 700;
  color: #f8fafc;
}

.qms-subtitle {
  font-size: 0.74rem;
  color: var(--text-dim);
}

.qms-models-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
}

.qm-model-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all 0.15s ease;
}

.qm-model-card:hover {
  background: rgba(99, 102, 241, 0.08);
  border-color: rgba(99, 102, 241, 0.35);
}

.qm-model-card.active {
  background: rgba(99, 102, 241, 0.16);
  border-color: rgba(99, 102, 241, 0.6);
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.2);
}

.qm-card-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.qm-card-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #f8fafc;
}

.qm-active-badge {
  font-size: 0.65rem;
  font-weight: 700;
  color: #818cf8;
  background: rgba(99, 102, 241, 0.2);
  padding: 1px 6px;
  border-radius: var(--radius-full);
}

.qm-card-desc {
  font-size: 0.7rem;
  color: var(--text-dim);
}

.qm-card-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.qm-card-pct {
  font-family: var(--font-mono, monospace);
  font-size: 0.82rem;
  font-weight: 700;
  color: #10b981;
}

.qm-card-timer {
  font-size: 0.68rem;
  color: var(--text-dim);
}

/* Dynamic Model Picker in New Task Modal */
.dynamic-model-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
  padding: 2px;
}

.dynamic-model-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all 0.15s ease;
}

.dynamic-model-option:hover {
  background: rgba(99, 102, 241, 0.08);
  border-color: rgba(99, 102, 241, 0.3);
}

.dynamic-model-option input[type="radio"]:checked ~ .dmo-body .dmo-title {
  color: #818cf8;
}

.dynamic-model-option:has(input[type="radio"]:checked) {
  background: rgba(99, 102, 241, 0.14);
  border-color: rgba(99, 102, 241, 0.5);
}

.dmo-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.dmo-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.83rem;
  font-weight: 600;
  color: #f8fafc;
}

.dmo-sub {
  font-size: 0.71rem;
  color: var(--text-dim);
}

.tier-pill-small {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #34d399;
}

/* Mobile responsive rules */
@media (max-width: 768px) {
  .header-model-label {
    max-width: 90px;
    font-size: 0.75rem;
  }
  .quota-pill-label .qpl-text, .quota-pill-timer {
    display: none;
  }
  .quota-pill-label {
    display: inline-flex;
    align-items: center;
  }
  .quota-pill-btn {
    padding: 4px 7px;
    font-size: 0.72rem;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }
  .header-model-btn {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }
  .chat-input-toolbar {
    padding: 4px 8px;
  }
  .cit-model-name {
    max-width: 100px;
  }
  .quota-windows-grid {
    grid-template-columns: 1fr;
  }
  .qms-models-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  #toggleCollapseBtn, #headerDataUsageBtn {
    display: none !important;
  }
  .current-task-title {
    display: none;
  }
  .header-model-label {
    max-width: 75px;
  }
}


