@import url("https://fonts.googleapis.com/css2?family=Syne:wght@500;600;700;800&family=Figtree:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap");

/* ── Nodedistro Chat UI v3 ───────────────────────────────────── */

.chat-v2.chat-v3,
.chat-v3 {
  --c-bg: #f3f6f8;
  --c-panel: #ffffff;
  --c-ink: #0c1a22;
  --c-sidebar: #071018;
  --c-sidebar-2: #0d1c26;
  --c-text: #13232d;
  --c-muted: #60707c;
  --c-line: #dce4ea;
  --c-line-strong: #c7d2db;
  --c-accent: #0ea5a0;
  --c-accent-bright: #2dd4bf;
  --c-accent-soft: #e6f8f5;
  --c-accent-deep: #0b7f7a;
  --c-danger: #c23b45;
  --c-green: var(--c-accent);
  --c-green-soft: var(--c-accent-soft);
  --font-ui: "Syne", "Figtree", ui-sans-serif, system-ui, sans-serif;
  --font-body: "Figtree", "Syne", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
  --shadow-soft: 0 12px 40px rgba(7, 16, 24, 0.07);
  --shadow-composer: 0 22px 60px rgba(7, 16, 24, 0.14);
  --radius-lg: 22px;
  --radius-md: 14px;
  height: 100dvh;
  overflow: hidden;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: var(--font-body);
}

.chat-v3 .chat-atmosphere {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(980px 520px at 88% -12%, rgba(14, 165, 160, 0.16), transparent 58%),
    radial-gradient(760px 480px at -8% 108%, rgba(45, 212, 191, 0.1), transparent 55%),
    radial-gradient(640px 360px at 48% 42%, rgba(255, 255, 255, 0.55), transparent 70%),
    linear-gradient(165deg, #eef4f7 0%, #f5f7f9 42%, #e8eef2 100%);
  animation: atmosphere-drift 18s ease-in-out infinite alternate;
}

@keyframes atmosphere-drift {
  from { transform: scale(1) translate3d(0, 0, 0); }
  to { transform: scale(1.04) translate3d(-1.2%, 0.8%, 0); }
}

.chat-v3 button,
.chat-v3 input,
.chat-v3 select,
.chat-v3 textarea {
  font-family: inherit;
  letter-spacing: 0;
}

.chat-v3 .nd-chat-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 288px minmax(0, 1fr);
  height: 100dvh;
  min-height: 0;
  background: transparent;
}

/* ── Sidebar ─────────────────────────────────────────────────── */

.chat-v3 .nd-chat-sidebar {
  z-index: 40;
  min-height: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px 16px 14px;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  background:
    linear-gradient(165deg, rgba(14, 165, 160, 0.18) 0%, transparent 34%),
    linear-gradient(180deg, #071018 0%, #0b1822 55%, #0a151d 100%);
  color: #e7eef4;
  animation: sidebar-in 0.45s ease both;
}

@keyframes sidebar-in {
  from { opacity: 0; transform: translateX(-12px); }
  to { opacity: 1; transform: translateX(0); }
}

.chat-v3 .sidebar-brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 4px 6px;
}

.chat-v3 .brand {
  min-width: 0;
  padding: 0;
  text-decoration: none;
  color: inherit;
  display: flex;
  align-items: center;
  gap: 12px;
}
.chat-v3 .brand .mark {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 14px;
  background:
    url("/nodedistro-logo.png") center 8% / 180% auto no-repeat,
    linear-gradient(145deg, #2dd4bf, #0b7f7a);
  color: transparent;
  box-shadow:
    0 10px 28px rgba(14, 165, 160, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.chat-v3 .brand div { min-width: 0; display: grid; }
.chat-v3 .brand strong,
.chat-v3 .brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-v3 .brand strong {
  font-family: var(--font-ui);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.04em;
  color: #fff;
}
.chat-v3 .brand span {
  margin-top: 2px;
  color: #7f93a4;
  font-size: 11px;
  font-weight: 500;
}

.chat-v3 .sidebar-close,
.chat-v3 .mobile-menu {
  width: 38px;
  height: 38px;
  display: none;
  place-items: center;
  flex: 0 0 auto;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #8fa3b4;
}
.chat-v3 .sidebar-close:hover,
.chat-v3 .mobile-menu:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.chat-v3 .sidebar-close svg,
.chat-v3 .mobile-menu svg { width: 17px; height: 17px; }

.chat-v3 .sidebar-section {
  order: 0;
  flex: 1;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  gap: 10px;
  min-height: 140px;
}

.chat-v3 .section-head {
  display: block;
  padding: 6px 4px 0;
  color: #6f8496;
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.chat-v3 .new-chat {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(135deg, #2dd4bf 0%, #0ea5a0 55%, #0b7f7a 100%);
  color: #041016;
  padding: 0 16px;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.02em;
  box-shadow: 0 12px 28px rgba(14, 165, 160, 0.32);
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
  cursor: pointer;
}
.chat-v3 .new-chat:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
  box-shadow: 0 16px 34px rgba(14, 165, 160, 0.4);
}
.chat-v3 .new-chat svg { width: 16px; height: 16px; }

.chat-v3 .search { position: relative; display: block; }
.chat-v3 .search > span { display: none; }
.chat-v3 .search svg {
  position: absolute;
  top: 13px;
  left: 13px;
  width: 14px;
  height: 14px;
  color: #7f93a4;
  pointer-events: none;
}
.chat-v3 .search input {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.05);
  padding: 0 12px 0 36px;
  color: #e7eef4;
  font-size: 13px;
  outline: 0;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.chat-v3 .search input::placeholder { color: #6f8496; }
.chat-v3 .search input:focus {
  border-color: rgba(45, 212, 191, 0.5);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 3px rgba(14, 165, 160, 0.18);
}

.chat-v3 .conversation-list {
  align-content: start;
  display: grid;
  grid-auto-rows: min-content;
  gap: 3px;
  padding-right: 2px;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.15) transparent;
}
.chat-v3 .conversation {
  min-height: 52px;
  display: grid;
  gap: 3px;
  border: 0;
  border-radius: 13px;
  padding: 11px 12px;
  color: #d0dbe5;
  background: transparent;
  text-align: left;
  width: 100%;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}
.chat-v3 .conversation:hover { background: rgba(255, 255, 255, 0.06); }
.chat-v3 .conversation.active {
  background: rgba(14, 165, 160, 0.16);
  box-shadow: inset 3px 0 #2dd4bf;
}
.chat-v3 .conversation strong {
  display: block;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 650;
  letter-spacing: -0.02em;
}
.chat-v3 .conversation span { color: #738796; font-size: 11px; }

.chat-v3 .usage-meter {
  order: 1;
  display: grid;
  gap: 8px;
  padding: 12px 13px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
}
.chat-v3 .usage-meter-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.chat-v3 .usage-meter-head span,
.chat-v3 .usage-meter-head strong {
  font-size: 11px;
  color: #d0dbe5;
  font-weight: 650;
}
.chat-v3 .usage-meter-meta {
  display: flex;
  justify-content: space-between;
  color: #738796;
  font-size: 10px;
}
.chat-v3 .usage-meter-track {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}
.chat-v3 .usage-meter-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2dd4bf, #38bdf8);
  transition: width 0.4s ease;
}

.chat-v3 .side-nav {
  order: 2;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding-top: 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.chat-v3 .side-nav a.nav-btn,
.chat-v3 .side-nav button.nav-btn {
  min-height: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 0;
  border-radius: 12px;
  padding: 6px 4px;
  color: #8497a8;
  font-size: 9px;
  font-weight: 650;
  letter-spacing: 0.01em;
  text-decoration: none;
  background: transparent;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.chat-v3 .side-nav a.nav-btn:hover,
.chat-v3 .side-nav button.nav-btn:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.chat-v3 .side-nav a.nav-btn.active {
  background: rgba(14, 165, 160, 0.18);
  color: #fff;
}
.chat-v3 .side-nav svg { width: 15px; height: 15px; flex: 0 0 auto; }

.chat-v3 .sidebar-backdrop { display: none; }

/* ── Main / topbar ───────────────────────────────────────────── */

.chat-v3 .chat-main {
  min-height: 0;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: transparent;
  animation: main-in 0.5s ease both;
}

@keyframes main-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-v3 .nd-chat-topbar {
  min-height: 68px;
  height: auto;
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(280px, auto);
  gap: 16px;
  align-items: center;
  overflow: visible;
  border-bottom: 1px solid rgba(220, 228, 234, 0.85);
  background: rgba(255, 255, 255, 0.62);
  padding: 10px 28px;
  backdrop-filter: blur(18px) saturate(1.2);
}
.chat-v3 .chat-title { max-width: 560px; display: grid; gap: 2px; }
.chat-v3 .chat-title input {
  width: 100%;
  height: 32px;
  border: 0;
  background: transparent;
  color: var(--c-text);
  font-family: var(--font-ui);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.04em;
  outline: 0;
}
.chat-v3 .chat-title span {
  display: block;
  overflow: hidden;
  color: var(--c-muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-v3 .model-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
  position: relative;
  z-index: 2;
}
.chat-v3 .model-controls label { min-width: 128px; margin: 0; position: relative; }
.chat-v3 .model-controls .model-field { min-width: 168px; }
.chat-v3 .model-controls .reasoning-field { min-width: 108px; }
.chat-v3 .model-controls label span {
  position: absolute;
  top: -7px;
  left: 10px;
  z-index: 1;
  padding: 0 5px;
  background: linear-gradient(180deg, rgba(255,255,255,0.9), #fff);
  color: var(--c-muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.chat-v3 .model-controls select,
.chat-v3 .settings-button {
  min-height: 40px;
  height: 40px;
  border: 1px solid var(--c-line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--c-text);
  padding: 0 30px 0 14px;
  font-size: 12px;
  font-weight: 600;
  outline: 0;
  box-shadow: 0 2px 10px rgba(7, 16, 24, 0.04);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.chat-v3 .model-controls select:focus {
  border-color: #5ecfc0;
  box-shadow: 0 0 0 3px rgba(14, 165, 160, 0.14);
}
.chat-v3 .model-controls select:disabled { cursor: not-allowed; opacity: 0.55; }
.chat-v3 .settings-button {
  width: 40px;
  min-width: 40px;
  padding: 0;
  display: grid;
  place-items: center;
}
.chat-v3 .settings-button:hover {
  border-color: #9ad9cf;
  background: #f3fbf9;
  color: var(--c-accent-deep);
}
.chat-v3 .settings-button svg { width: 15px; height: 15px; }
.chat-v3 .mobile-menu { display: none; color: var(--c-text); }

/* ── Workspace / messages ────────────────────────────────────── */

.chat-v3 .chat-workspace.active {
  height: calc(100dvh - 68px);
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}
.chat-v3 .chat-workspace.active.artifacts-open {
  grid-template-columns: minmax(360px, 0.9fr) minmax(440px, 1.1fr);
}

.chat-v3 .chat-pane {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  background: transparent;
}

.chat-v3 .message-stream {
  overflow: auto;
  padding: 40px clamp(18px, 7vw, 120px) 28px;
  scroll-behavior: smooth;
}

.chat-v3 .empty-state {
  width: min(100%, 720px);
  max-width: 720px;
  margin: 8vh auto 0;
  align-content: center;
  text-align: left;
  animation: chat-rise 0.5s ease both;
}
.chat-v3 .empty-state h1 {
  max-width: 560px;
  margin: 0;
  font-family: var(--font-ui);
  font-size: clamp(28px, 4vw, 40px);
  font-weight: 750;
  line-height: 1.12;
  letter-spacing: -0.05em;
  color: var(--c-ink);
}
.chat-v3 .quick-grid {
  width: 100%;
  max-width: 720px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: 22px 0 0;
  gap: 12px;
}
.chat-v3 .quick-grid button {
  min-height: 76px;
  border: 1px solid rgba(220, 228, 234, 0.95);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.78);
  padding: 16px 18px;
  color: var(--c-text);
  font-size: 13px;
  font-weight: 550;
  line-height: 1.45;
  text-align: left;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(8px);
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
  cursor: pointer;
}
.chat-v3 .quick-grid button:hover {
  border-color: #7fd4c7;
  background: #fff;
  box-shadow: 0 16px 36px rgba(14, 165, 160, 0.12);
  transform: translateY(-2px);
}

.chat-v3 .message {
  width: min(100%, 780px);
  max-width: 780px;
  margin: 0 auto 32px;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 14px;
  animation: chat-rise 0.38s ease both;
}
.chat-v3 .message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #13232d, #0c1a22);
  color: #fff;
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 750;
  box-shadow: 0 8px 18px rgba(7, 16, 24, 0.12);
}
.chat-v3 .message.user .message-avatar {
  background: linear-gradient(145deg, #2dd4bf, #0ea5a0);
  color: #041016;
}
.chat-v3 .message-avatar img {
  width: 18px;
  height: 18px;
  display: block;
  filter: invert(1);
  object-fit: contain;
}
.chat-v3 .message-label {
  margin-bottom: 7px;
  color: var(--c-muted);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.02em;
}

.chat-v3 .message-token-budget,
.message-token-budget {
  margin-top: 0.45rem;
  color: var(--muted, #8f96a8);
  font-size: 0.72rem;
  line-height: 1.35;
}
.chat-v3 .bubble {
  font-size: 15.5px;
  line-height: 1.72;
  color: var(--c-text);
}
.chat-v3 .bubble p { margin: 0 0 0.85em; }
.chat-v3 .bubble p:last-child { margin-bottom: 0; }
.chat-v3 .bubble pre,
.chat-v3 .bubble code {
  font-family: var(--font-mono);
}
.chat-v3 .bubble pre {
  overflow: auto;
  margin: 12px 0;
  padding: 14px 16px;
  border-radius: 14px;
  background: #0f1724;
  color: #d7e4f5;
  font-size: 12.5px;
  line-height: 1.65;
}

.chat-v3 .message.welcome { width: min(100%, 780px); max-width: 780px; }
.chat-v3 .message.welcome .bubble {
  padding: 22px 24px;
  border: 1px solid rgba(220, 228, 234, 0.95);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(10px);
}
.chat-v3 .welcome-actions {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}
.chat-v3 .welcome-action {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: start;
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--c-line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--c-text);
  text-align: left;
  font-size: 13.5px;
  line-height: 1.45;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.chat-v3 .welcome-action:hover {
  border-color: #7fd4c7;
  box-shadow: 0 12px 28px rgba(14, 165, 160, 0.12);
  transform: translateY(-1px);
}
.chat-v3 .welcome-action-num {
  font-family: var(--font-ui);
  font-weight: 750;
  color: var(--c-accent-deep);
}

.chat-v3 .message.user .bubble {
  max-width: min(640px, 82vw);
  border: 0;
  border-radius: 18px 18px 18px 6px;
  background: linear-gradient(160deg, #e8f8f5 0%, #dff4f0 100%);
  padding: 13px 16px;
  box-shadow: 0 6px 18px rgba(14, 165, 160, 0.08);
}

.chat-v3 .message-actions { margin-top: 10px; }
.chat-v3 .retry-btn {
  min-height: 32px;
  border: 1px solid var(--c-line);
  border-radius: 999px;
  background: #fff;
  padding: 0 12px;
  color: var(--c-text);
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}
.chat-v3 .retry-btn:hover { border-color: #7fd4c7; background: var(--c-accent-soft); }

.chat-v3 .artifact-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  border: 1px solid var(--c-line);
  border-radius: 14px;
  background: #f7fafb;
  padding: 10px;
}
.chat-v3 .artifact-list > strong {
  flex-basis: 100%;
  color: var(--c-muted);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.chat-v3 .artifact-download {
  min-height: 34px;
  border: 1px solid var(--c-line);
  border-radius: 10px;
  background: #fff;
  color: var(--c-text);
  font-size: 13px;
  font-weight: 650;
  padding: 0 12px;
  cursor: pointer;
}
.chat-v3 .artifact-download:hover { background: #eef4f6; }
.chat-v3 .artifact-project {
  border-color: #8ad9cd;
  background: var(--c-accent-soft);
  color: var(--c-accent-deep);
}

/* Agent progress */
.chat-v3 .agent-progress {
  display: grid;
  gap: 10px;
  padding: 6px 0;
}
.chat-v3 .agent-step {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--c-muted);
  font-size: 13.5px;
  transition: color 0.2s ease;
}
.chat-v3 .agent-step.active { color: var(--c-text); font-weight: 650; }
.chat-v3 .agent-step.done { color: var(--c-accent-deep); }
.chat-v3 .agent-step-icon {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: #edf2f5;
  font-size: 11px;
}
.chat-v3 .agent-step.active .agent-step-icon {
  background: var(--c-accent-soft);
  color: var(--c-accent-deep);
  animation: agent-pulse 1.4s ease-in-out infinite;
}

/* ── Composer ────────────────────────────────────────────────── */

.chat-v3 .chat-composer {
  position: relative;
  width: min(calc(100% - 48px), 780px);
  display: grid;
  gap: 8px;
  margin: 0 auto 24px;
  border: 1px solid rgba(199, 210, 219, 0.95);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-composer);
  padding: 14px 16px 12px;
  backdrop-filter: blur(14px);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
  animation: composer-in 0.55s ease both;
}
.chat-v3 .chat-composer:focus-within {
  border-color: #6ecfbf;
  box-shadow: var(--shadow-composer), 0 0 0 4px rgba(14, 165, 160, 0.12);
  transform: translateY(-1px);
}

@keyframes composer-in {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-v3 .composer-attachments { display: flex; flex-wrap: wrap; gap: 6px; }
.chat-v3 .chat-composer textarea {
  width: 100%;
  min-height: 56px;
  max-height: 220px;
  border: 0;
  background: transparent;
  padding: 4px 4px 2px;
  color: var(--c-text);
  font-size: 15px;
  line-height: 1.5;
  resize: none;
  outline: 0;
}
.chat-v3 .chat-composer textarea::placeholder { color: #8a9aa7; }

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

.chat-v3 .composer-tools {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0;
  min-width: 0;
  overflow-x: auto;
}
.chat-v3 .composer-tools button,
.chat-v3 .file-chip {
  width: 36px;
  height: 36px;
  min-height: 36px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 12px;
  background: transparent;
  padding: 0;
  color: var(--c-muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.chat-v3 .composer-tools button:hover,
.chat-v3 .file-chip:hover {
  background: var(--c-accent-soft);
  color: var(--c-accent-deep);
}
.chat-v3 .composer-tools #liveVoiceBtn.active {
  background: #fee4e2;
  color: #b42318;
  box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.12);
}
.chat-v3 .composer-tools #liveVoiceBtn.active svg { animation: live-pulse 1.25s ease-in-out infinite; }
@keyframes live-pulse { 50% { transform: scale(0.82); opacity: 0.65; } }
.chat-v3 .composer-tools svg { width: 15px; height: 15px; }
.chat-v3 #deleteChatBtn { color: var(--c-danger); }
.chat-v3 #deleteChatBtn:hover { background: #fdecec; }

.chat-v3 .mcp-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  margin-left: 4px;
  padding: 0 10px;
  border: 1px solid var(--c-line);
  border-radius: 999px;
  background: #f7fafb;
  color: var(--c-muted);
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
  text-decoration: none;
}
.chat-v3 .mcp-chip.active {
  border-color: #8ad9cd;
  background: var(--c-accent-soft);
  color: var(--c-accent-deep);
}
.chat-v3 .mcp-chip strong { font-weight: 750; }

.chat-v3 .send-row {
  position: relative;
  min-width: 44px;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}
.chat-v3 .status {
  position: absolute;
  right: 52px;
  bottom: 50%;
  transform: translateY(50%);
  max-width: 160px;
  max-height: 18px;
  overflow: hidden;
  padding: 0;
  color: var(--c-muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}
/* Agent checklist must never render in the composer send row. */
.chat-v3 .status:has(.agent-progress),
.chat-v3 .status:has(.agent-step),
.chat-v3 .status .agent-progress,
.chat-v3 .send-row .agent-progress,
.chat-v3 .composer-footer .agent-progress,
.chat-v3 .chat-composer .agent-progress {
  display: none !important;
  visibility: hidden !important;
  height: 0 !important;
  max-height: 0 !important;
  overflow: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}
.chat-v3 .send-btn {
  width: 42px;
  min-width: 42px;
  height: 42px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(145deg, #2dd4bf, #0ea5a0);
  color: #041016;
  box-shadow: 0 10px 22px rgba(14, 165, 160, 0.3);
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
}
.chat-v3 .send-btn::after { display: none; }
.chat-v3 .send-btn svg { width: 17px; height: 17px; }
.chat-v3 .send-btn:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
}
.chat-v3 .send-btn:disabled {
  background: #c9d2dc;
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
  filter: none;
  color: #fff;
}

.chat-v3 .composer-attachment { border-radius: 10px; font-size: 11px; }
.chat-v3 .file-input { display: none; }

/* ── Artifacts ───────────────────────────────────────────────── */

.chat-v3 .artifact-code-panel {
  min-width: 0;
  overflow: hidden;
  border-left: 1px solid var(--c-line);
  background: var(--c-panel);
  animation: artifact-in 0.28s ease both;
}
.chat-v3 .artifact-code-panel[hidden] { display: none; }
@keyframes artifact-in {
  from { opacity: 0; transform: translateX(12px); }
  to { opacity: 1; transform: translateX(0); }
}
.chat-v3 .artifact-code-header {
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--c-line);
  padding: 0 16px;
}
.chat-v3 .artifact-code-header div { display: flex; align-items: baseline; gap: 9px; min-width: 0; }
.chat-v3 .artifact-code-header strong { font-family: var(--font-ui); font-size: 14px; letter-spacing: -0.02em; }
.chat-v3 .artifact-code-header span {
  overflow: hidden;
  color: var(--c-muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-v3 .artifact-code-header button {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--c-muted);
  cursor: pointer;
}
.chat-v3 .artifact-code-header button:hover { background: var(--c-bg); color: var(--c-text); }
.chat-v3 .artifact-code-header svg { width: 15px; }
.chat-v3 .artifact-code-body {
  height: calc(100% - 54px);
  display: grid;
  grid-template-columns: 176px minmax(0, 1fr);
}
.chat-v3 .artifact-file-list {
  overflow: auto;
  border-right: 1px solid var(--c-line);
  background: #f6f9fb;
  padding: 10px;
}
.chat-v3 .artifact-file-list button {
  width: 100%;
  display: block;
  overflow: hidden;
  border: 0;
  border-radius: 10px;
  background: transparent;
  padding: 9px 10px;
  color: var(--c-muted);
  font: inherit;
  font-size: 12px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}
.chat-v3 .artifact-file-list button:hover { background: rgba(16, 24, 32, 0.05); color: var(--c-text); }
.chat-v3 .artifact-file-list button.active {
  background: var(--c-accent-soft);
  color: var(--c-accent-deep);
  font-weight: 650;
}
.chat-v3 .artifact-code-view { min-width: 0; display: grid; grid-template-rows: 44px minmax(0, 1fr); }
.chat-v3 .artifact-code-view > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--c-line);
  padding: 0 14px;
  color: var(--c-muted);
  font: 12px var(--font-mono);
}
.chat-v3 .artifact-view-actions { display: flex; gap: 8px; }
.chat-v3 .artifact-code-view > header button {
  border: 1px solid var(--c-line);
  border-radius: 10px;
  background: transparent;
  padding: 6px 10px;
  color: var(--c-text);
  font: inherit;
  cursor: pointer;
}
.chat-v3 #playSteamGameBtn[hidden] { display: none; }
.chat-v3 .artifact-play {
  background: var(--c-accent-soft);
  color: var(--c-accent-deep);
  border-color: transparent;
}
.chat-v3 .game-preview-dialog {
  display: flex;
  flex-direction: column;
  width: min(960px, 96vw);
  height: min(720px, 90vh);
  max-width: 96vw;
  max-height: 90vh;
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: 16px;
  background: #102030;
  color: #f7fbff;
  overflow: hidden;
}
.chat-v3 .game-preview-dialog::backdrop { background: rgba(7, 16, 24, 0.72); }
.chat-v3 .game-preview-dialog form { margin: 0; }
.chat-v3 .game-preview-dialog header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  padding: 0 14px;
}
.chat-v3 .game-preview-dialog header button {
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 10px;
  background: transparent;
  color: #f7fbff;
  padding: 6px 10px;
  cursor: pointer;
}
.chat-v3 .game-preview-dialog iframe {
  width: 100%;
  height: calc(100% - 48px);
  flex: 1;
  min-height: 0;
  border: 0;
  background: #102030;
}
.chat-v3 .artifact-code-view pre {
  min-width: 0;
  overflow: auto;
  margin: 0;
  padding: 18px;
  background: #0b121c;
  color: #d7e4f5;
  font: 12.5px/1.65 var(--font-mono);
  tab-size: 2;
}
.chat-v3 .artifact-code-view code { white-space: pre; }

/* ── Settings / MCP / dialogs ────────────────────────────────── */

.chat-v3 .chat-settings-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}
.chat-v3 .chat-settings-actions button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--c-line-strong);
  border-radius: 12px;
  background: #fff;
  color: var(--c-text);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.chat-v3 .chat-settings-actions button:hover {
  background: #f4fbf9;
  border-color: #7fd4c7;
}
.chat-v3 .chat-settings-actions svg { width: 15px; height: 15px; }
.chat-v3 .settings-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid var(--c-line-strong);
  border-radius: 12px;
  background: #fff;
  color: var(--c-text);
  font-size: 13px;
  font-weight: 700;
}
.chat-v3 .settings-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--c-accent);
}
.chat-v3 .settings-toggle:has(input:disabled) { opacity: 0.55; }

.chat-v3 .mcp-settings { display: grid; gap: 12px; }
.chat-v3 .mcp-form {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--c-line);
  border-radius: 16px;
  background: #f7fafb;
}
.chat-v3 .mcp-form label {
  display: grid;
  gap: 6px;
  color: var(--c-muted);
  font-size: 11px;
  font-weight: 650;
}
.chat-v3 .mcp-form input,
.chat-v3 .mcp-form select {
  min-height: 40px;
  border: 1px solid var(--c-line-strong);
  border-radius: 12px;
  background: #fff;
  padding: 0 12px;
  color: var(--c-text);
  font: inherit;
  font-size: 13px;
}
.chat-v3 .mcp-form-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.chat-v3 .mcp-form-actions button {
  min-height: 36px;
  border: 1px solid var(--c-line-strong);
  border-radius: 10px;
  background: #fff;
  padding: 0 12px;
  color: var(--c-text);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.chat-v3 .mcp-form-actions .mcp-primary {
  border-color: var(--c-accent);
  background: var(--c-accent);
  color: #fff;
}
.chat-v3 .mcp-list { display: grid; gap: 10px; }
.chat-v3 .mcp-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--c-line);
  border-radius: 16px;
  background: #fff;
}
.chat-v3 .mcp-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.chat-v3 .mcp-card-head strong {
  display: block;
  font-family: var(--font-ui);
  font-size: 13px;
}
.chat-v3 .mcp-card-head span {
  display: block;
  margin-top: 3px;
  color: var(--c-muted);
  font-size: 11px;
  word-break: break-all;
}
.chat-v3 .mcp-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #eef2f6;
  color: var(--c-muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.chat-v3 .mcp-status.connected {
  background: var(--c-accent-soft);
  color: var(--c-accent-deep);
}
.chat-v3 .mcp-status.error {
  background: #fdecec;
  color: var(--c-danger);
}
.chat-v3 .mcp-tools { display: grid; gap: 6px; }
.chat-v3 .mcp-tool {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--c-muted);
  font-size: 12px;
}
.chat-v3 .mcp-tool code {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--c-text);
}
.chat-v3 .mcp-card-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.chat-v3 .mcp-card-actions button {
  min-height: 32px;
  border: 1px solid var(--c-line);
  border-radius: 8px;
  background: #fff;
  padding: 0 10px;
  color: var(--c-text);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.chat-v3 .mcp-card-actions button.danger {
  border-color: #efb4b8;
  color: var(--c-danger);
}
.chat-v3 #mcpStatus {
  min-height: 16px;
  margin: 0;
  color: var(--c-muted);
  font-size: 12px;
}

.chat-v3 .usage-limit-dialog,
.chat-v3 .confirm-dialog {
  width: min(480px, calc(100vw - 24px));
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--c-line-strong);
  border-radius: 20px;
  background: #fff;
  color: var(--c-text);
  box-shadow: 0 28px 70px rgba(7, 16, 24, 0.24);
}
.chat-v3 .usage-limit-dialog::backdrop,
.chat-v3 .confirm-dialog::backdrop { background: rgba(7, 16, 24, 0.58); }
.chat-v3 .usage-limit-heading,
.chat-v3 .confirm-dialog-heading {
  min-height: 76px;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 34px;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--c-line);
  background: #f7fafb;
}
.chat-v3 .confirm-dialog-heading { background: #fbf6f5; }
.chat-v3 .usage-limit-heading > span,
.chat-v3 .confirm-dialog-heading > span {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: #dff5f1;
  color: var(--c-accent-deep);
}
.chat-v3 .confirm-dialog-heading > span { background: #f4e3e1; color: #9d3833; }
.chat-v3 .usage-limit-heading svg,
.chat-v3 .confirm-dialog-heading svg { width: 18px; height: 18px; }
.chat-v3 .usage-limit-heading p,
.chat-v3 .usage-limit-heading h2,
.chat-v3 .confirm-dialog-heading p,
.chat-v3 .confirm-dialog-heading h2 { margin: 0; }
.chat-v3 .usage-limit-heading p,
.chat-v3 .confirm-dialog-heading p {
  color: var(--c-muted);
  font-size: 10px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.chat-v3 .usage-limit-heading h2,
.chat-v3 .confirm-dialog-heading h2 {
  margin-top: 3px;
  font-family: var(--font-ui);
  font-size: 18px;
  letter-spacing: -0.03em;
}
.chat-v3 .usage-limit-heading button,
.chat-v3 .confirm-dialog-heading button {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--c-muted);
  cursor: pointer;
}
.chat-v3 .usage-limit-heading button:hover,
.chat-v3 .confirm-dialog-heading button:hover { background: #e9ece9; color: var(--c-text); }
.chat-v3 .usage-limit-body,
.chat-v3 .confirm-dialog-body { padding: 18px 16px 8px; }
.chat-v3 .usage-limit-body > p,
.chat-v3 .confirm-dialog-body p {
  margin: 0;
  color: var(--c-muted);
  font-size: 13px;
  line-height: 1.55;
}
.chat-v3 .usage-limit-values {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  margin-top: 16px;
  overflow: hidden;
  border: 1px solid var(--c-line);
  border-radius: 14px;
  background: var(--c-line);
}
.chat-v3 .usage-limit-values > div { padding: 14px; background: #fff; }
.chat-v3 .usage-limit-values span,
.chat-v3 .usage-limit-values strong { display: block; }
.chat-v3 .usage-limit-values span { color: var(--c-muted); font-size: 10px; }
.chat-v3 .usage-limit-values strong { margin-top: 5px; font-size: 18px; font-family: var(--font-ui); }
.chat-v3 .usage-limit-track {
  height: 6px;
  margin-top: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e2e5e2;
}
.chat-v3 .usage-limit-track span {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--c-danger);
}
.chat-v3 .usage-reset-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 15px;
  padding: 11px 0;
}
.chat-v3 .usage-reset-row > svg { width: 18px; height: 18px; color: var(--c-accent); }
.chat-v3 .usage-reset-row span,
.chat-v3 .usage-reset-row strong { display: block; }
.chat-v3 .usage-reset-row span { color: var(--c-muted); font-size: 10px; }
.chat-v3 .usage-reset-row strong { margin-top: 3px; font-size: 12px; }
.chat-v3 .usage-limit-actions,
.chat-v3 .confirm-dialog-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 16px 16px;
}
.chat-v3 .usage-limit-actions button,
.chat-v3 .usage-limit-actions a,
.chat-v3 .confirm-dialog-actions button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--c-line-strong);
  border-radius: 12px;
  padding: 0 14px;
  color: var(--c-text);
  background: #fff;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.chat-v3 .usage-limit-actions a,
.chat-v3 .usage-limit-actions .usage-primary-action {
  border-color: var(--c-accent);
  background: var(--c-accent);
  color: #fff;
}
.chat-v3 .usage-backup-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--c-line);
  border-radius: 12px;
  background: #f4fbf9;
}
.chat-v3 .usage-backup-row span { color: var(--c-muted); font-size: 12px; font-weight: 650; }
.chat-v3 .usage-backup-row strong { font-size: 14px; }
.chat-v3 .usage-limit-extra {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--c-line);
}
.chat-v3 .usage-limit-extra p {
  margin: 0 0 10px;
  color: var(--c-muted);
  font-size: 12px;
  line-height: 1.5;
}
.chat-v3 .usage-credit-packs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.chat-v3 .usage-credit-pack {
  min-height: 38px;
  border: 1px solid var(--c-line-strong);
  border-radius: 10px;
  background: #fff;
  color: var(--c-text);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.chat-v3 .usage-credit-pack.active,
.chat-v3 .usage-credit-pack:hover {
  border-color: var(--c-accent);
  background: var(--c-accent);
  color: #fff;
}
.chat-v3 .usage-custom-amount {
  display: grid;
  gap: 6px;
  margin-top: 10px;
  color: var(--c-muted);
  font-size: 11px;
  font-weight: 650;
}
.chat-v3 .usage-custom-amount input {
  min-height: 36px;
  border: 1px solid var(--c-line-strong);
  border-radius: 10px;
  padding: 0 10px;
  color: var(--c-text);
  font: inherit;
}
.chat-v3 .usage-limit-status {
  min-height: 16px;
  margin: 8px 0 0;
  color: var(--c-muted);
  font-size: 11px;
}
.chat-v3 .confirm-dialog-actions .danger-button {
  border-color: #9d3833;
  background: #9d3833;
  color: #fff;
}
.chat-v3 .confirm-dialog-actions .danger-button:hover { background: #852f2b; }

.chat-v3 #settingsDialog {
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100dvh - 32px);
  overflow: auto;
  border: 1px solid var(--c-line-strong);
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 28px 70px rgba(7, 16, 24, 0.24);
}
.chat-v3 #settingsDialog::backdrop { background: rgba(7, 16, 24, 0.58); }
.chat-v3 .settings-form > header strong { font-family: var(--font-ui); letter-spacing: -0.02em; }
.chat-v3 .settings-form menu button#saveSettingsBtn {
  border-color: var(--c-accent);
  background: var(--c-accent);
}

/* Generated media */
.generated-image { margin: 12px 0; max-width: 640px; }
.screenshot-attachment { display: grid; grid-template-columns: 72px minmax(0, 1fr); align-items: center; }
.screenshot-attachment img { width: 72px; height: 54px; grid-row: 1 / span 2; border-radius: 8px; object-fit: cover; }
.chat-v3 .screenshot-chip img { width: 28px; height: 28px; border-radius: 6px; object-fit: cover; }
.generated-image img { display: block; width: 100%; height: auto; border-radius: 14px; }
.generated-image figcaption { margin-top: 8px; }
.generated-video { margin: 12px 0; max-width: 720px; }
.generated-video video { display: block; width: 100%; max-height: 70vh; border-radius: 14px; background: #050505; }
.generated-video figcaption { margin-top: 8px; }
.generated-video-status {
  display: grid;
  gap: 8px;
  max-width: 520px;
  margin: 12px 0;
  padding: 14px;
  border: 1px solid var(--c-line);
  border-radius: 14px;
  background: var(--c-panel);
}
.generated-video-status progress { width: 100%; accent-color: var(--c-accent); }
.generated-video-status error,
.generated-video-status.error { color: #b42318; border-color: #f0aaa3; }
.generated-file {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 12px 0;
  padding: 12px 14px;
  border: 1px solid var(--c-line);
  border-radius: 14px;
  background: var(--c-panel);
}
.generated-file a { white-space: nowrap; font-weight: 650; }

@keyframes chat-rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes agent-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

/* ── Responsive ──────────────────────────────────────────────── */

@media (max-width: 560px) {
  .chat-v3 .usage-credit-packs { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 980px) {
  .chat-v3 .nd-chat-shell { grid-template-columns: 248px minmax(0, 1fr); }
  .chat-v3 .nd-chat-topbar { grid-template-columns: minmax(140px, 1fr) auto; padding-inline: 16px; }
  .chat-v3 .model-controls label { min-width: 110px; }
  .chat-v3 .model-controls .model-field { min-width: 140px; }
  .chat-v3 .model-controls .reasoning-field { min-width: 96px; }
  .chat-v3 .chat-workspace.active.artifacts-open {
    grid-template-columns: minmax(300px, 0.8fr) minmax(380px, 1.2fr);
  }
  .chat-v3 .artifact-code-body { grid-template-columns: 132px minmax(0, 1fr); }
}

@media (max-width: 800px) {
  .chat-v3 .nd-chat-topbar { padding: 10px 14px; }
  .chat-v3 .model-controls label { min-width: 0; }
  .chat-v3 .model-controls .model-field { display: flex; min-width: 0; }
  .chat-v3 .message-stream { padding: 28px 16px 22px; }
  .chat-v3 .chat-composer { width: calc(100% - 24px); margin-bottom: 14px; }
  .chat-v3 .empty-state h1 { font-size: 28px; }
}

@media (max-width: 760px) {
  .chat-v3 .nd-chat-shell { display: block; }
  .chat-v3 .nd-chat-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(308px, 88vw);
    display: flex;
    transform: translateX(-102%);
    animation: none;
    transition: transform 0.22s ease;
    box-shadow: 18px 0 48px rgba(7, 16, 24, 0.32);
  }
  .chat-v3.sidebar-open .nd-chat-sidebar { transform: translateX(0); }
  .chat-v3 .sidebar-close { display: grid; }
  .chat-v3 .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 35;
    display: block;
    border: 0;
    border-radius: 0;
    background: rgba(7, 16, 24, 0.52);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
  }
  .chat-v3.sidebar-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }
  .chat-v3 .chat-main { width: 100%; }
  .chat-v3 .nd-chat-topbar {
    height: auto;
    min-height: 0;
    grid-template-columns: 38px minmax(0, 1fr) 38px;
    grid-template-rows: auto auto;
    gap: 8px;
    padding: 10px 12px 12px;
  }
  .chat-v3 .mobile-menu { display: grid; grid-column: 1; grid-row: 1; color: var(--c-text); }
  .chat-v3 .chat-title { grid-column: 2; grid-row: 1; }
  .chat-v3 .chat-title input { font-size: 15px; }
  .chat-v3 .chat-title span { display: none; }
  .chat-v3 .model-controls {
    grid-column: 1 / -1;
    grid-row: 2;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr) minmax(0, 0.8fr) 38px 38px;
    width: 100%;
  }
  .chat-v3 .model-controls label,
  .chat-v3 .model-controls .model-field,
  .chat-v3 .model-controls .reasoning-field { min-width: 0; }
  .chat-v3 .model-controls label span { display: none; }
  .chat-v3 .model-controls select { width: 100%; border-radius: 12px; }
  .chat-v3 .settings-button { position: static; border-radius: 12px; }
  .chat-v3 .chat-workspace.active { height: calc(100dvh - 118px); }
  .chat-v3 .chat-workspace.active.artifacts-open { position: relative; display: block; }
  .chat-v3 .chat-workspace.artifacts-open .chat-pane { display: none; }
  .chat-v3 .artifact-code-panel { width: 100%; height: 100%; border-left: 0; }
  .chat-v3 .message-stream { padding: 22px 14px 18px; }
  .chat-v3 .empty-state { align-content: start; padding-top: 6vh; margin-top: 0; }
  .chat-v3 .empty-state h1 { font-size: 24px; }
  .chat-v3 .quick-grid { grid-template-columns: 1fr 1fr; }
  .chat-v3 .quick-grid button { min-height: 58px; }
  .chat-v3 .message { grid-template-columns: 28px minmax(0, 1fr); gap: 10px; margin-bottom: 24px; }
  .chat-v3 .message-avatar { width: 28px; height: 28px; border-radius: 10px; }
  .chat-v3 .bubble { font-size: 14px; }
  .chat-v3 .chat-composer {
    width: calc(100% - 16px);
    margin-bottom: 10px;
    border-radius: 18px;
    padding: 12px;
  }
  .chat-v3 .composer-tools { max-width: calc(100vw - 88px); }
  .chat-v3 .status { display: none; }
  .chat-v3 .side-nav { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 430px) {
  .chat-v3 .quick-grid { grid-template-columns: 1fr; }
  .chat-v3 .quick-grid button { min-height: 48px; }
  .chat-v3 .model-controls select { padding-right: 20px; font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  .chat-v3 .chat-atmosphere,
  .chat-v3 .nd-chat-sidebar,
  .chat-v3 .chat-main,
  .chat-v3 .sidebar-backdrop,
  .chat-v3 .new-chat,
  .chat-v3 .quick-grid button,
  .chat-v3 .welcome-action,
  .chat-v3 .message,
  .chat-v3 .empty-state,
  .chat-v3 .chat-composer,
  .chat-v3 .artifact-code-panel,
  .chat-v3 .agent-step.active .agent-step-icon { animation: none; transition: none; transform: none; }
}

/* Override conflicting styles.css nd-chat rules when v3 is active */
body.chat-v3.nd-chat-page {
  min-height: 100dvh;
  background: transparent !important;
}
.chat-v3.nd-chat-page .nd-chat-shell {
  display: grid !important;
  grid-template-columns: 288px minmax(0, 1fr) !important;
  height: 100dvh;
}
.chat-v3.nd-chat-page .nd-chat-sidebar {
  display: flex !important;
  background:
    linear-gradient(165deg, rgba(14, 165, 160, 0.18) 0%, transparent 34%),
    linear-gradient(180deg, #071018 0%, #0b1822 55%, #0a151d 100%) !important;
}
.chat-v3.nd-chat-page .chat-composer {
  display: grid !important;
  width: min(calc(100% - 48px), 780px) !important;
  margin: 0 auto 24px !important;
  border: 1px solid rgba(199, 210, 219, 0.95) !important;
  border-radius: var(--radius-lg) !important;
  background: rgba(255, 255, 255, 0.92) !important;
  box-shadow: var(--shadow-composer) !important;
  padding: 14px 16px 12px !important;
  gap: 8px !important;
}
.chat-v3.nd-chat-page .composer-tools {
  order: unset !important;
  margin: 0 !important;
  justify-content: flex-start !important;
}
.chat-v3.nd-chat-page .composer-attachments {
  order: unset !important;
}
.chat-v3.nd-chat-page .chat-composer textarea {
  order: unset !important;
  min-height: 56px !important;
  max-height: 220px !important;
  border: 0 !important;
  background: transparent !important;
  padding: 4px 4px 2px !important;
  resize: none !important;
}
.chat-v3.nd-chat-page .send-row {
  order: unset !important;
  margin-top: 0 !important;
  justify-content: flex-end !important;
  pointer-events: auto !important;
}
.chat-v3.nd-chat-page .status {
  margin-right: 0 !important;
  padding-left: 0 !important;
}
.chat-v3.nd-chat-page .send-btn {
  display: grid !important;
  place-items: center !important;
  min-width: 42px !important;
  width: 42px !important;
  height: 42px !important;
  border-radius: 14px !important;
  background: linear-gradient(145deg, #2dd4bf, #0ea5a0) !important;
  color: #041016 !important;
  pointer-events: auto !important;
  position: relative !important;
}
.chat-v3.nd-chat-page .send-btn::after {
  content: none !important;
  display: none !important;
}
.chat-v3.nd-chat-page .composer-tools button,
.chat-v3.nd-chat-page .file-chip {
  min-height: 36px !important;
  width: 36px !important;
  border: 0 !important;
  border-radius: 12px !important;
  background: transparent !important;
  color: var(--c-muted) !important;
  padding: 0 !important;
}
.chat-v3 .chat-inspector[hidden] { display: none !important; }

@media (max-width: 760px) {
  .chat-v3.nd-chat-page .nd-chat-shell {
    display: block !important;
  }
  .chat-v3.nd-chat-page .nd-chat-sidebar {
    display: flex !important;
  }
  .chat-v3.nd-chat-page .chat-composer {
    width: calc(100% - 16px) !important;
    margin-bottom: 10px !important;
  }
}
