:root {
  --bg: #0a0e14;
  --panel: #111821;
  --panel-hi: #16202c;
  --border: #223246;
  --text: #d2dcec;
  --muted: #8ea0b8;
  --green: #00ff87;
  --red: #ff4d73;
  --amber: #ffbe55;
  --cyan: #34d9ff;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.5);
  --font-ui: "JetBrains Mono", "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --font-mono: "JetBrains Mono", "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --base-font-size: 15px;
  --chat-font-size: 0.9rem;
  --app-height: 100dvh;
  --overview-chrome: 152px;
  --mobile-tabbar-height: 68px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: var(--base-font-size);
  color: var(--text);
  background:
    radial-gradient(900px 460px at 15% 0%, rgba(52, 217, 255, 0.15), transparent 58%),
    radial-gradient(820px 440px at 90% 0%, rgba(0, 255, 135, 0.11), transparent 58%),
    var(--bg);
  min-height: var(--app-height);
}

html,
body {
  overflow-x: hidden;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.08) 2px,
    rgba(0, 0, 0, 0.08) 4px
  );
  opacity: 0.45;
}

.wrap {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 18px 16px 28px;
  height: var(--app-height);
  min-height: var(--app-height);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 8px;
  overflow: hidden;
}

.is-hidden {
  display: none !important;
}

.auth-gate {
  display: grid;
  place-items: center;
  padding: 8px 0;
}

.auth-card {
  width: min(640px, 100%);
}

.auth-copy {
  margin: 0;
  padding: 0 12px 8px;
  color: var(--muted);
  line-height: 1.45;
}

.auth-form {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.auth-business {
  padding: 0 12px 12px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.topbar,
.panel,
.stat {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(17, 24, 33, 0.93), rgba(17, 24, 33, 0.7));
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 0 1 auto;
}

/* ── Brand sigil (replaces static dot) ── */
.brand-sigil {
  position: relative;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.brand-sigil-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1.5px solid rgba(52, 217, 255, 0.5);
  animation: sigilSpinSlow 10s linear infinite;
}

.brand-sigil-ring::before {
  content: "";
  position: absolute;
  top: -1.5px;
  left: 50%;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 6px var(--cyan);
  transform: translateX(-50%);
}

.brand-sigil-core {
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 255, 135, 0.5), rgba(52, 217, 255, 0.2), transparent 70%);
  box-shadow: 0 0 12px rgba(0, 255, 135, 0.3);
  animation: sigilBreathe 3s ease-in-out infinite;
}

.brand-dot {
  display: none; /* replaced by brand-sigil */
}

.brand-name {
  color: var(--green);
  font-weight: 800;
  letter-spacing: 0.06em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topmeta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
  min-width: 0;
  flex: 1 1 auto;
}

.pill {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 0.78rem;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.18);
}

.pill.live {
  color: #dcfff1;
  border-color: rgba(0, 255, 135, 0.36);
  background: rgba(0, 255, 135, 0.14);
}

.pill.live b {
  color: var(--green);
}

.btn-ghost {
  border-color: rgba(52, 217, 255, 0.35);
  background: rgba(52, 217, 255, 0.12);
  color: #dcf7ff;
}

.top-business-switch {
  min-width: 170px;
}

.top-business-switch select {
  min-width: 170px;
  padding: 6px 8px;
}

.tabs-nav {
  margin-top: 0;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tab-btn {
  border: 1px solid #2a3a50;
  background: rgba(0, 0, 0, 0.24);
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tab-btn:hover {
  border-color: rgba(52, 217, 255, 0.35);
  color: #d7f4ff;
}

.tab-btn.is-active {
  color: #dcfff1;
  border-color: rgba(0, 255, 135, 0.4);
  background: linear-gradient(180deg, rgba(0, 255, 135, 0.24), rgba(0, 255, 135, 0.1));
}

.tab-page {
  display: none;
  min-height: 0;
  height: 100%;
  overflow: auto;
}

.tab-page.is-active {
  display: block;
}

#tab-overview {
  overflow: hidden;
}

.overview-shell {
  margin-top: 0;
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  gap: 10px;
  min-height: 0;
  height: 100%;
  max-height: 100%;
  overflow: hidden;
  position: relative;
  transition: grid-template-columns 200ms ease;
}

/* ── Collapsed sidebar state ── */
.overview-shell.is-sidebar-collapsed {
  grid-template-columns: 0px minmax(0, 1fr);
  gap: 0;
}

.overview-shell.is-sidebar-collapsed .overview-history-panel {
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
  width: 0;
  min-width: 0;
  border: 0;
  padding: 0;
}

.overview-shell.is-sidebar-collapsed .sidebar-expand-btn {
  opacity: 1;
  pointer-events: auto;
}

.overview-shell.is-sidebar-collapsed .chat-log {
  padding-top: 48px;
}

.sidebar-expand-btn {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(17, 24, 33, 0.9);
  color: var(--muted);
  border-radius: 8px;
  width: 34px;
  height: 34px;
  padding: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, color 140ms ease, border-color 140ms ease;
  backdrop-filter: blur(6px);
}

.sidebar-expand-btn:hover {
  color: var(--cyan);
  border-color: rgba(52, 217, 255, 0.45);
  background: rgba(52, 217, 255, 0.1);
}

.sidebar-expand-btn svg {
  width: 16px;
  height: 16px;
}

.history-collapse-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  width: 30px;
  height: 30px;
  padding: 0;
  transition: color 140ms ease, border-color 140ms ease;
}

.history-collapse-btn svg {
  width: 14px;
  height: 14px;
}

.history-collapse-btn:hover {
  color: var(--cyan);
  border-color: rgba(52, 217, 255, 0.4);
}

.overview-shell .panel {
  margin-top: 0;
}

.overview-history-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  max-height: 100%;
  overflow: hidden;
}

.overview-chat-panel {
  min-height: 0;
  height: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-panel-heading {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.chat-active-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mobile-conversations-btn,
.mobile-history-close,
.mobile-history-backdrop {
  display: none;
}

.top-conversations-btn {
  display: none;
}

.history-phead {
  padding: 10px 10px 6px;
  border-bottom: 0;
}

.history-phead h3 {
  font-size: 0.82rem;
}

.history-meta {
  display: block;
  padding: 0 12px 8px;
  font-size: 0.66rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.history-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.history-new-btn,
.history-delete-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  width: 30px;
  height: 30px;
  padding: 0;
  transition: color 140ms ease, border-color 140ms ease, background 140ms ease;
}

.history-new-btn svg,
.history-delete-btn svg {
  width: 14px;
  height: 14px;
}

.history-new-btn:hover {
  color: var(--green);
  border-color: rgba(0, 255, 135, 0.4);
  background: rgba(0, 255, 135, 0.08);
}

.history-delete-btn:hover {
  color: var(--red);
  border-color: rgba(255, 98, 132, 0.45);
  background: rgba(255, 98, 132, 0.08);
}

.chat-history-list {
  display: grid;
  align-content: start;
  grid-auto-rows: max-content;
  gap: 8px;
  padding: 10px;
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  max-height: none;
  flex: 1 1 auto;
}

.chat-history-item {
  width: 100%;
  text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.26);
  color: #dce8f7;
  padding: 8px 10px;
  display: grid;
  gap: 4px;
  min-height: 78px;
  max-height: 118px;
  overflow: hidden;
}

.chat-history-item .meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.66rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.chat-history-item .meta-left {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.chat-history-item .role-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid transparent;
}

.chat-history-item.user .role-chip {
  border-color: rgba(52, 217, 255, 0.4);
  color: #b8f1ff;
  background: rgba(52, 217, 255, 0.12);
}

.chat-history-item.agent .role-chip,
.chat-history-item.conversation .role-chip {
  border-color: rgba(0, 255, 135, 0.4);
  color: #d2ffe9;
  background: rgba(0, 255, 135, 0.12);
}

.chat-history-item .snippet {
  color: #dce8f7;
  font-size: 0.8rem;
  line-height: 1.35;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  text-overflow: ellipsis;
  word-break: break-word;
}

.chat-history-item .snippet.title {
  font-weight: 600;
}

.chat-history-item .snippet.preview {
  -webkit-line-clamp: 1;
}

.chat-history-item:hover {
  border-color: rgba(52, 217, 255, 0.36);
  transform: translateY(-1px);
}

.chat-history-item.is-linked {
  border-color: rgba(0, 255, 135, 0.52);
  box-shadow: 0 0 0 2px rgba(0, 255, 135, 0.14);
}

.chat-history-item.is-running {
  border-color: rgba(255, 190, 85, 0.5);
}

.chat-history-item.has-ready {
  border-color: rgba(0, 255, 135, 0.52);
}

.conversation-state-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid rgba(161, 181, 202, 0.42);
  padding: 1px 7px;
  font-size: 0.58rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #d7e6f7;
  background: rgba(16, 24, 34, 0.62);
}

.conversation-state-chip.running {
  border-color: rgba(255, 190, 85, 0.58);
  color: #ffe9bf;
  background: rgba(255, 190, 85, 0.16);
}

.conversation-state-chip.ready {
  border-color: rgba(0, 255, 135, 0.58);
  color: #d8ffeb;
  background: rgba(0, 255, 135, 0.14);
}

.layout {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.settings-top-layout {
  grid-template-columns: minmax(280px, 0.78fr) minmax(720px, 1.22fr);
  align-items: start;
}

.settings-browser-column {
  display: grid;
  gap: 12px;
}

.panel {
  margin-top: 12px;
  overflow: hidden;
}

.phead {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.phead h3 {
  margin: 0;
  color: #eaf3ff;
  font-size: 0.9rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.small {
  font-size: 0.74rem;
  color: var(--muted);
}

.stack {
  display: grid;
  gap: 10px;
  padding: 12px;
}

label {
  display: grid;
  gap: 6px;
}

label span {
  color: var(--muted);
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

input,
textarea,
button,
select {
  font: inherit;
}

input,
textarea,
select {
  width: 100%;
  border-radius: 8px;
  border: 1px solid #2a3a50;
  background: rgba(0, 0, 0, 0.2);
  color: #ebf4ff;
  padding: 10px;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 0 2px rgba(52, 217, 255, 0.2);
}

button {
  border: 1px solid rgba(0, 255, 135, 0.35);
  background: linear-gradient(180deg, rgba(0, 255, 135, 0.22), rgba(0, 255, 135, 0.08));
  color: #dfffee;
  border-radius: 8px;
  padding: 9px 11px;
  cursor: pointer;
}

button:hover {
  filter: brightness(1.1);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

#saveOnboardingBtn {
  transition: transform 120ms ease, filter 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}

#saveOnboardingBtn:active,
#saveOnboardingBtn.is-saving {
  transform: translateY(1px) scale(0.992);
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.4);
}

#saveOnboardingBtn.is-saving:disabled {
  opacity: 1;
  cursor: progress;
  filter: brightness(0.92);
  animation: onboarding-save-pulse 0.95s ease-in-out infinite;
}

#saveOnboardingBtn.is-saved {
  border-color: rgba(0, 255, 135, 0.72);
  background: linear-gradient(180deg, rgba(0, 255, 135, 0.35), rgba(0, 255, 135, 0.16));
  color: #ebfff4;
}

.actions-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.actions-row button:nth-child(2) {
  border-color: rgba(52, 217, 255, 0.35);
  background: linear-gradient(180deg, rgba(52, 217, 255, 0.2), rgba(52, 217, 255, 0.08));
}

.btn-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(0, 255, 135, 0.35);
  background: linear-gradient(180deg, rgba(0, 255, 135, 0.22), rgba(0, 255, 135, 0.08));
  color: #dfffee;
  border-radius: 8px;
  padding: 9px 11px;
  text-decoration: none;
  font-size: 0.84rem;
}

.btn-link:hover {
  filter: brightness(1.1);
}

.btn-link-secondary {
  border-color: rgba(52, 217, 255, 0.35);
  background: linear-gradient(180deg, rgba(52, 217, 255, 0.2), rgba(52, 217, 255, 0.08));
}

.btn-link-muted {
  border-color: rgba(161, 181, 202, 0.35);
  background: linear-gradient(180deg, rgba(161, 181, 202, 0.2), rgba(161, 181, 202, 0.08));
  color: #e0e8f2;
}

.btn-link[aria-disabled="true"] {
  pointer-events: none;
  opacity: 0.55;
}

.health-automation-help {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(5, 10, 17, 0.42);
  padding: 8px 10px;
}

.health-automation-help > summary {
  cursor: pointer;
  color: #d8e8fa;
  font-size: 0.82rem;
}

.health-automation-steps {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.chat-log {
  order: 1;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 12px 12px;
  background:
    linear-gradient(180deg, rgba(8, 14, 21, 0.78), rgba(8, 14, 21, 0.62)),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 24px,
      rgba(52, 217, 255, 0.04) 24px,
      rgba(52, 217, 255, 0.04) 25px
    );
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1 1 auto;
}

.chat-item {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(3, 7, 12, 0.56);
  animation: none;
  transition: border-color 180ms ease, background-color 180ms ease, box-shadow 180ms ease;
  max-width: 100%;
}

.chat-item.user {
  border-color: rgba(52, 217, 255, 0.4);
  background: rgba(7, 21, 32, 0.55);
}

.chat-item.agent {
  border-color: rgba(0, 255, 135, 0.36);
  background: rgba(8, 24, 18, 0.5);
}

.chat-item.agent.is-thinking {
  position: relative;
  border-color: rgba(130, 243, 255, 0.18);
  background:
    linear-gradient(180deg, rgba(8, 24, 18, 0.72), rgba(5, 16, 24, 0.78)),
    radial-gradient(circle at top right, rgba(52, 217, 255, 0.14), transparent 42%);
  box-shadow:
    0 0 0 1px rgba(79, 219, 255, 0.08),
    0 18px 44px rgba(0, 0, 0, 0.34),
    0 0 24px rgba(52, 217, 255, 0.1);
  overflow: hidden;
}

.chat-item.agent.is-thinking::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background:
    linear-gradient(
      118deg,
      rgba(52, 217, 255, 0.08) 0%,
      rgba(52, 217, 255, 0.92) 22%,
      rgba(129, 255, 229, 0.72) 40%,
      rgba(52, 217, 255, 0.08) 58%,
      rgba(52, 217, 255, 0.78) 76%,
      rgba(52, 217, 255, 0.08) 100%
    );
  background-size: 220% 220%;
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  mask-composite: exclude;
  opacity: 0.8;
  animation: chatThinkingBorderBreathe 3.8s ease-in-out infinite;
  pointer-events: none;
}

.chat-item.agent.is-thinking::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    radial-gradient(circle at var(--thinking-x, 12%) 0%, rgba(52, 217, 255, 0.16), transparent 28%);
  opacity: 0.85;
  animation: chatThinkingGlow 4.8s ease-in-out infinite;
  pointer-events: none;
}

.chat-item.agent.has-thinking-status .text {
  position: relative;
  z-index: 1;
}

.chat-item.status {
  border: 0;
  border-radius: 0;
  border-left: 2px solid rgba(52, 217, 255, 0.42);
  background: transparent;
  padding: 2px 0 2px 10px;
}

.chat-item.status .role {
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  color: #8faac6;
  margin-bottom: 2px;
}

.chat-item.status .text {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: #bed6ec;
}

.chat-item.status .text p {
  margin: 0;
}

.chat-item.status.tone-ok {
  border-left-color: rgba(0, 255, 135, 0.72);
}

.chat-item.status.tone-warn {
  border-left-color: rgba(255, 190, 85, 0.84);
}

.chat-item.status.tone-error {
  border-left-color: rgba(255, 77, 115, 0.92);
}

.chat-item.is-linked {
  border-color: rgba(52, 217, 255, 0.55);
  box-shadow: 0 0 0 2px rgba(52, 217, 255, 0.16);
}

.chat-item .role {
  font-size: 0.68rem;
  color: #cae7ff;
  margin-bottom: 5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  font-family: var(--font-mono);
}

.chat-item-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 5px;
  max-width: 100%;
}

.chat-item-head .role {
  margin-bottom: 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-item-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
  flex-wrap: wrap;
  min-width: 0;
}

.chat-copy-btn {
  border: 1px solid rgba(52, 217, 255, 0.45);
  background: rgba(52, 217, 255, 0.12);
  color: #d3f6ff;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.chat-copy-btn:hover:not(:disabled) {
  background: rgba(52, 217, 255, 0.2);
}

.chat-delete-btn {
  border: 1px solid rgba(255, 98, 132, 0.45);
  background: rgba(255, 98, 132, 0.12);
  color: #ffd6df;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.chat-delete-btn:hover:not(:disabled) {
  background: rgba(255, 98, 132, 0.2);
}

.chat-item .text {
  line-height: 1.48;
  overflow-wrap: anywhere;
  word-break: break-word;
  font-size: var(--chat-font-size);
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.chat-item .text > * {
  max-width: 100%;
}

.chat-item .text p {
  margin: 0 0 8px;
}

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

.chat-item .text h1,
.chat-item .text h2,
.chat-item .text h3,
.chat-item .text h4,
.chat-item .text h5,
.chat-item .text h6 {
  margin: 0 0 8px;
  line-height: 1.25;
  color: #e8f6ff;
  font-size: 1rem;
}

.chat-item .text ul,
.chat-item .text ol {
  margin: 0 0 8px;
  padding-left: 18px;
}

.chat-item .text code {
  font-family: var(--font-mono);
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 1px 5px;
  font-size: 0.85em;
}

.chat-item .text pre {
  margin: 8px 0 0;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid rgba(52, 217, 255, 0.2);
  background: rgba(0, 0, 0, 0.36);
  overflow: auto;
}

.chat-item .text pre code {
  border: 0;
  background: transparent;
  padding: 0;
}

.chat-thinking-status {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 6px;
  margin: 2px 0 10px;
  padding: 10px 12px;
  overflow: hidden;
  border: 1px solid rgba(126, 244, 220, 0.16);
  border-radius: 10px;
  background: rgba(6, 16, 24, 0.76);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.chat-thinking-status::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background:
    conic-gradient(
      from 0deg,
      rgba(126, 244, 220, 0.05) 0deg,
      rgba(126, 244, 220, 0.05) 112deg,
      rgba(126, 244, 220, 0.9) 148deg,
      rgba(52, 217, 255, 0.96) 178deg,
      rgba(126, 244, 220, 0.08) 212deg,
      rgba(126, 244, 220, 0.05) 360deg
    );
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  mask-composite: exclude;
  pointer-events: none;
  opacity: 0.88;
  animation: chatThinkingBorderBreathe 3.2s ease-in-out infinite;
}

.chat-thinking-status.is-compact {
  margin-bottom: 12px;
  padding: 9px 11px;
}

.chat-thinking-badge {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid rgba(52, 217, 255, 0.24);
  color: #d9f8ff;
  background: rgba(52, 217, 255, 0.08);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.chat-thinking-badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(129, 255, 229, 1), rgba(52, 217, 255, 0.92));
  box-shadow: 0 0 12px rgba(52, 217, 255, 0.6);
}

.chat-thinking-line {
  font-size: 0.79rem;
  line-height: 1.42;
  color: #b8d6ea;
}

.chat-thinking-line.tone-ok {
  color: #bff9de;
}

.chat-thinking-line.tone-warn {
  color: #ffe2a6;
}

.chat-thinking-line.tone-error {
  color: #ffc2d0;
}

.chat-item.agent.is-loading .chat-thinking-status {
  margin: 4px 0 0;
}

@keyframes chatThinkingBorderBreathe {
  0%,
  100% {
    opacity: 0.48;
    filter: brightness(0.9);
  }
  50% {
    opacity: 0.98;
    filter: brightness(1.15);
  }
}

@keyframes chatThinkingGlow {
  0%,
  100% {
    opacity: 0.38;
    transform: translateX(-12%);
  }
  50% {
    opacity: 0.92;
    transform: translateX(12%);
  }
}

@keyframes chatThinkingPulse {
  0%,
  100% {
    transform: scale(0.9);
    opacity: 0.72;
  }
  50% {
    transform: scale(1.18);
    opacity: 1;
  }
}

.chat-item .text blockquote {
  margin: 8px 0;
  padding: 6px 10px;
  border-left: 3px solid rgba(52, 217, 255, 0.45);
  background: rgba(52, 217, 255, 0.07);
}

.chat-item .text a {
  color: #8de7ff;
}

.chat-item .text img {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  margin-top: 6px;
}

.chat-item .text img.inline-url-image {
  display: inline-block;
  max-width: min(260px, 100%);
  max-height: 160px;
  object-fit: cover;
  vertical-align: middle;
  margin-top: 4px;
}

.chat-item .text table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
}

.chat-item .text table th,
.chat-item .text table td {
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 6px 8px;
  font-size: 0.8rem;
}

.chat-item .media-grid {
  margin-top: 8px;
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

.chat-item .media-grid a {
  display: block;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.35);
}

.chat-item .media-grid img {
  width: 100%;
  height: 124px;
  object-fit: cover;
  display: block;
}

.chat-compose {
  order: 3;
  border-top: 1px solid rgba(0, 255, 135, 0.1);
  padding: 10px 12px 12px;
  display: grid;
  gap: 6px;
  background:
    radial-gradient(400px 80px at 50% 0%, rgba(0, 255, 135, 0.06), transparent),
    linear-gradient(180deg, rgba(9, 16, 24, 0.86), rgba(8, 12, 17, 0.7));
  flex-shrink: 0;
}

.chat-compose-bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  border: 1px solid rgba(0, 255, 135, 0.25);
  border-radius: 14px;
  padding: 8px 8px 8px 10px;
  background:
    linear-gradient(180deg, rgba(8, 12, 17, 0.94), rgba(8, 12, 17, 0.82));
  box-shadow:
    inset 0 0 0 1px rgba(0, 255, 135, 0.06),
    0 0 24px rgba(0, 255, 135, 0.04);
  transition: border-color 200ms ease, box-shadow 200ms ease;
}

.chat-compose-bar:focus-within {
  border-color: rgba(0, 255, 135, 0.5);
  box-shadow:
    inset 0 0 0 1px rgba(0, 255, 135, 0.12),
    0 0 28px rgba(0, 255, 135, 0.1),
    0 0 60px rgba(52, 217, 255, 0.04);
}

.chat-compose-bar textarea {
  flex: 1 1 auto;
  border: 0;
  background: transparent;
  color: #ebf4ff;
  padding: 6px 4px;
  min-height: 24px;
  max-height: 140px;
  resize: none;
  font-size: 0.88rem;
  line-height: 1.4;
  outline: none;
  box-shadow: none;
}

.chat-compose-bar textarea::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

.chat-compose-bar textarea:focus {
  outline: none;
  border: 0;
  box-shadow: none;
}

.chat-bar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  width: 34px;
  height: 34px;
  min-width: 34px;
  min-height: 34px;
  padding: 0;
  margin: 0;
  flex-shrink: 0;
  transition: color 140ms ease, border-color 140ms ease, background 140ms ease;
}

.chat-bar-btn:hover {
  color: #d8f4ff;
  border-color: rgba(52, 217, 255, 0.45);
  background: rgba(52, 217, 255, 0.1);
}

.chat-bar-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.chat-send-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(0, 255, 135, 0.5);
  background: linear-gradient(180deg, rgba(0, 255, 135, 0.3), rgba(0, 255, 135, 0.12));
  color: #dfffee;
  border-radius: 999px;
  width: 34px;
  height: 34px;
  min-width: 34px;
  min-height: 34px;
  padding: 0;
  margin: 0;
  flex-shrink: 0;
  transition: filter 140ms ease, box-shadow 140ms ease;
}

.chat-send-btn:hover:not(:disabled) {
  filter: brightness(1.15);
  box-shadow: 0 0 12px rgba(0, 255, 135, 0.25);
}

.chat-send-btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
}

.chat-file-input {
  display: none;
}

.chat-mic-btn.is-recording {
  border-color: rgba(255, 98, 132, 0.55) !important;
  background: linear-gradient(180deg, rgba(255, 98, 132, 0.26), rgba(255, 98, 132, 0.1)) !important;
  color: #ffe6ec !important;
  box-shadow: 0 0 0 2px rgba(255, 98, 132, 0.2);
}

.chat-mic-btn.is-processing {
  border-color: rgba(0, 255, 135, 0.46) !important;
  background: linear-gradient(180deg, rgba(0, 255, 135, 0.24), rgba(0, 255, 135, 0.1)) !important;
  color: #dffff0 !important;
}

.danger-btn {
  border-color: rgba(255, 98, 132, 0.5);
  background: linear-gradient(180deg, rgba(255, 98, 132, 0.28), rgba(255, 98, 132, 0.12));
  color: #ffe7ee;
}

/* ── Agent status bar ── */
.agent-status-bar {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(0, 255, 135, 0.3);
  border-radius: 999px;
  padding: 5px 12px 5px 10px;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: #d2ffe9;
  background: rgba(0, 255, 135, 0.08);
}

.agent-status-pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px rgba(0, 255, 135, 0.6);
  animation: statusPulse 2.4s ease-in-out infinite;
}

@keyframes statusPulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 8px rgba(0, 255, 135, 0.6); }
  50% { opacity: 0.5; box-shadow: 0 0 4px rgba(0, 255, 135, 0.3); }
}

/* ── Welcome state — command center feel ── */
.chat-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 24px;
  flex: 1 1 auto;
  min-height: 200px;
  gap: 16px;
  animation: welcomeFadeIn 600ms ease both;
}

.chat-welcome-sigil {
  position: relative;
  width: 72px;
  height: 72px;
  margin-bottom: 4px;
}

.sigil-ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid;
}

.sigil-ring-outer {
  inset: 0;
  border-color: rgba(52, 217, 255, 0.35);
  animation: sigilSpinSlow 12s linear infinite;
  box-shadow: 0 0 20px rgba(52, 217, 255, 0.1);
}

.sigil-ring-outer::before {
  content: "";
  position: absolute;
  top: -2px;
  left: 50%;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 10px var(--cyan);
  transform: translateX(-50%);
}

.sigil-ring-inner {
  inset: 12px;
  border-color: rgba(0, 255, 135, 0.3);
  animation: sigilSpinSlow 8s linear infinite reverse;
  box-shadow: 0 0 16px rgba(0, 255, 135, 0.08);
}

.sigil-ring-inner::before {
  content: "";
  position: absolute;
  bottom: -2px;
  left: 50%;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  transform: translateX(-50%);
}

.sigil-core {
  position: absolute;
  inset: 24px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(52, 217, 255, 0.25), rgba(0, 255, 135, 0.15), transparent 70%);
  animation: sigilBreathe 3s ease-in-out infinite;
}

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

@keyframes sigilBreathe {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.15); }
}

.chat-welcome-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--green);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-shadow: 0 0 20px rgba(0, 255, 135, 0.25);
}

.chat-welcome-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
  max-width: 400px;
}

.chat-welcome-commands {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 12px;
  max-width: 420px;
  width: 100%;
}

.chat-command {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(52, 217, 255, 0.2);
  border-radius: 12px;
  padding: 12px 14px;
  background:
    radial-gradient(80px 50px at 0% 0%, rgba(52, 217, 255, 0.08), transparent),
    rgba(8, 14, 22, 0.6);
  color: #d0eaf8;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-align: left;
  transition: border-color 180ms ease, background 180ms ease, box-shadow 180ms ease, transform 120ms ease;
}

.chat-command:hover {
  border-color: rgba(52, 217, 255, 0.5);
  background:
    radial-gradient(100px 60px at 0% 0%, rgba(52, 217, 255, 0.16), transparent),
    rgba(8, 14, 22, 0.7);
  box-shadow: 0 0 16px rgba(52, 217, 255, 0.1);
  transform: translateY(-1px);
  color: #e8f8ff;
}

.chat-command-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 8px;
  border: 1px solid rgba(0, 255, 135, 0.2);
  background: rgba(0, 255, 135, 0.06);
  color: var(--green);
}

.chat-command-icon svg {
  width: 16px;
  height: 16px;
}

.chat-command-label {
  font-weight: 600;
}

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

/* ── Status strip (above compose bar) ── */
.chat-status-strip {
  display: none;
  order: 2;
  flex-shrink: 0;
}

.chat-status-strip.is-active {
  display: block;
}

.status-strip-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  margin: 0 2px;
  border: 1px solid rgba(52, 217, 255, 0.2);
  border-bottom: 0;
  border-radius: 10px 10px 0 0;
  background:
    linear-gradient(90deg, rgba(52, 217, 255, 0.06), rgba(0, 255, 135, 0.04), rgba(52, 217, 255, 0.06));
  background-size: 200% 100%;
  animation: statusStripShimmer 3s ease-in-out infinite;
  position: relative;
  overflow: hidden;
}

.status-strip-inner::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  height: 1px;
  width: 100%;
  background: linear-gradient(90deg, transparent, rgba(0, 255, 135, 0.5), rgba(52, 217, 255, 0.5), transparent);
  background-size: 200% 100%;
  animation: statusStripScan 2s linear infinite;
}

@keyframes statusStripShimmer {
  0%, 100% { background-position: 0% 0%; }
  50% { background-position: 100% 0%; }
}

@keyframes statusStripScan {
  0% { background-position: -100% 0%; }
  100% { background-position: 100% 0%; }
}

.status-strip-spinner {
  width: 14px;
  height: 14px;
  min-width: 14px;
  border: 2px solid rgba(52, 217, 255, 0.2);
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: statusSpinnerSpin 0.8s linear infinite;
}

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

.status-strip-text {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: #c6e0f4;
  letter-spacing: 0.06em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Persistent quick-action bar ── */
.chat-quickbar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.qbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(52, 217, 255, 0.18);
  border-radius: 999px;
  padding: 5px 12px 5px 8px;
  background: rgba(52, 217, 255, 0.05);
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.qbar-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  stroke: var(--green);
  opacity: 0.7;
  transition: opacity 160ms ease;
}

.qbar-btn:hover {
  border-color: rgba(52, 217, 255, 0.45);
  background: rgba(52, 217, 255, 0.12);
  color: #d8f4ff;
  box-shadow: 0 0 10px rgba(52, 217, 255, 0.08);
}

.qbar-btn:hover svg {
  opacity: 1;
}

/* ── Compose bar terminal feel ── */
.compose-prompt {
  font-family: var(--font-mono);
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--green);
  opacity: 0.7;
  flex-shrink: 0;
  padding-left: 4px;
  animation: cursorBlink 1.2s step-end infinite;
  user-select: none;
}

@keyframes cursorBlink {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 0.25; }
}

.compose-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

/* All tabs visible by default — hide with .hide-extra-tabs on body or ?tabs=minimal */
body.hide-extra-tabs .tab-btn-more {
  display: none;
}

.chat-attachment-list {
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chat-ingest-toggle {
  margin-top: 4px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border: 1px solid rgba(0, 255, 135, 0.24);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(0, 255, 135, 0.1), rgba(0, 255, 135, 0.04));
  color: #d6ffeb;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.chat-ingest-toggle input {
  margin: 0;
  accent-color: #00ff87;
}

.chat-ingest-toggle[hidden] {
  display: none;
}

.chat-attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(52, 217, 255, 0.35);
  border-radius: 999px;
  padding: 4px 8px;
  background: rgba(9, 20, 30, 0.75);
  color: #cfe7fa;
  max-width: 100%;
}

.chat-attachment-chip .name {
  font-size: 0.72rem;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 180px;
}

.chat-attachment-chip .remove {
  border: 0;
  background: transparent;
  color: #ff9ab0;
  padding: 0;
  margin: 0;
  font-size: 0.76rem;
  line-height: 1;
}

.chat-runtime-feed {
  display: none;
  padding: 0 12px 8px;
}

.chat-runtime-feed.is-visible {
  display: block;
}

.chat-run-status {
  border: 1px solid rgba(52, 217, 255, 0.26);
  border-radius: 10px;
  padding: 10px 12px;
  min-height: 44px;
  background:
    linear-gradient(180deg, rgba(6, 14, 24, 0.78), rgba(5, 10, 17, 0.72)),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 14px,
      rgba(52, 217, 255, 0.03) 14px,
      rgba(52, 217, 255, 0.03) 15px
    );
  display: grid;
  gap: 5px;
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.chat-run-status::after {
  content: none;
}

.chat-run-line {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  line-height: 1.45;
  min-height: 1.2em;
  color: #c6ddf1;
  animation: status-fade-in 220ms ease both;
  position: relative;
  z-index: 2;
}

.chat-run-line::before {
  content: "> ";
  color: rgba(52, 217, 255, 0.9);
}

.chat-run-line.tone-ok::before {
  color: rgba(0, 255, 135, 0.95);
}

.chat-run-line.tone-warn::before {
  color: rgba(255, 190, 85, 0.95);
}

.chat-run-line.tone-error {
  color: #ffd3dc;
}

.chat-run-line.tone-error::before {
  color: rgba(255, 77, 115, 0.95);
}

.chat-item.is-loading {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  display: grid;
  grid-template-rows: auto 1fr;
  border: 1px solid rgba(52, 217, 255, 0.2);
  background: linear-gradient(180deg, rgba(8, 24, 18, 0.42), rgba(7, 17, 24, 0.46));
  min-height: 158px;
  max-height: 158px;
  box-shadow:
    inset 0 0 0 1px rgba(52, 217, 255, 0.08),
    0 0 0 1px rgba(0, 255, 135, 0.04);
  animation: none;
}

.chat-item.is-loading::before {
  content: none;
}

.chat-item.is-loading .chat-item-head,
.chat-item.is-loading .text {
  position: relative;
  z-index: 1;
}

.chat-item.is-loading::after {
  content: none;
}

.chat-loading-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  max-height: 100%;
  overflow-y: hidden;
  overflow-x: hidden;
  padding-right: 2px;
  padding-bottom: 2px;
  font-size: 0.78rem;
  line-height: 1.26;
  justify-content: flex-start;
}

.chat-loading-line {
  margin: 0 !important;
  color: #e2f7ff;
  line-height: 1.26;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  max-width: 100%;
  width: 100%;
  min-width: 0;
  display: block;
  flex: 0 0 auto;
  font-size: 0.78rem;
}

.chat-loading-line.tone-ok {
  color: rgba(204, 255, 227, 0.96);
}

.chat-loading-line.tone-warn {
  color: rgba(255, 238, 198, 0.96);
}

.chat-loading-line.tone-error {
  color: #ffd3dc;
}

.agent-status-board {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.agent-status-card {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.26);
  display: grid;
  gap: 5px;
  position: relative;
  overflow: hidden;
}

.agent-status-card::after {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  opacity: 0.9;
}

.agent-status-name {
  color: var(--muted);
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-family: var(--font-mono);
}

.agent-status-value {
  color: #eaf8ff;
  font-size: 0.76rem;
  line-height: 1.35;
}

.status-active::after {
  background: var(--green);
  box-shadow: 0 0 16px rgba(0, 255, 135, 0.65);
}

.status-busy::after {
  background: var(--amber);
  box-shadow: 0 0 16px rgba(255, 190, 85, 0.55);
}

.status-idle::after {
  background: var(--cyan);
  box-shadow: 0 0 16px rgba(52, 217, 255, 0.5);
}

@keyframes chat-rise {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes status-scan {
  from {
    transform: translateX(-120%);
  }
  to {
    transform: translateX(360%);
  }
}

@keyframes status-fade-in {
  from {
    opacity: 0;
    transform: translateY(2px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes chat-loading-pulse {
  0%,
  100% {
    box-shadow:
      inset 0 0 0 1px rgba(52, 217, 255, 0.18),
      0 0 0 1px rgba(0, 255, 135, 0.08),
      0 0 0 0 rgba(0, 255, 135, 0.12);
  }
  50% {
    box-shadow:
      inset 0 0 0 1px rgba(52, 217, 255, 0.28),
      0 0 0 1px rgba(0, 255, 135, 0.16),
      0 0 0 6px rgba(0, 255, 135, 0.05);
  }
}

@keyframes chat-loading-glow {
  0%,
  100% {
    box-shadow:
      inset 0 0 0 1px rgba(52, 217, 255, 0.12),
      0 0 0 1px rgba(0, 255, 135, 0.08),
      0 0 10px rgba(0, 255, 135, 0.06);
  }
  50% {
    box-shadow:
      inset 0 0 0 1px rgba(52, 217, 255, 0.22),
      0 0 0 1px rgba(0, 255, 135, 0.14),
      0 0 16px rgba(52, 217, 255, 0.1);
  }
}

@keyframes chat-loading-border-sweep {
  0% {
    background-position: 0 0, 0% 50%;
  }
  100% {
    background-position: 0 0, 240% 50%;
  }
}

@keyframes chat-loading-border-glisten {
  0%,
  100% {
    border-color: rgba(52, 217, 255, 0.34);
    box-shadow:
      0 0 0 1px rgba(0, 255, 135, 0.08),
      0 0 8px rgba(52, 217, 255, 0.06),
      inset 0 0 8px rgba(52, 217, 255, 0.04);
  }
  50% {
    border-color: rgba(52, 217, 255, 0.64);
    box-shadow:
      0 0 0 1px rgba(0, 255, 135, 0.14),
      0 0 14px rgba(52, 217, 255, 0.12),
      inset 0 0 10px rgba(0, 255, 135, 0.06);
  }
}

@keyframes chat-loading-inner {
  0%,
  100% {
    opacity: 0.44;
  }
  50% {
    opacity: 0.78;
  }
}

@keyframes chat-loading-scan {
  from {
    transform: translateX(0) skewX(-12deg);
  }
  to {
    transform: translateX(340%) skewX(-12deg);
  }
}

@keyframes chat-loading-outline {
  0%,
  100% {
    opacity: 0.33;
    border-color: rgba(52, 217, 255, 0.3);
  }
  50% {
    opacity: 0.58;
    border-color: rgba(52, 217, 255, 0.52);
  }
}

@keyframes onboarding-save-pulse {
  0%,
  100% {
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.4), 0 0 0 0 rgba(0, 255, 135, 0.18);
  }
  50% {
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.44), 0 0 0 5px rgba(0, 255, 135, 0.06);
  }
}

.table-wrap {
  overflow: auto;
}

.secrets-table-wrap {
  overflow-x: auto;
}

.secrets-table {
  width: 100%;
  min-width: 980px;
}

.secrets-table th,
.secrets-table td {
  white-space: nowrap;
}

.secrets-table td:last-child {
  min-width: 132px;
}

.secrets-card-section {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.secrets-card-list {
  display: grid;
  gap: 12px;
}

.secret-connection-card {
  border: 1px solid rgba(52, 217, 255, 0.24);
  border-radius: 12px;
  padding: 14px;
  background: rgba(5, 13, 21, 0.72);
  display: grid;
  gap: 10px;
}

.secret-browser-panel {
  border: 1px solid rgba(52, 217, 255, 0.24);
  border-radius: 12px;
  padding: 14px;
  background: rgba(5, 13, 21, 0.72);
  display: grid;
  gap: 12px;
}

.secret-browser-lane-card {
  border: 1px solid rgba(52, 217, 255, 0.24);
  border-radius: 12px;
  padding: 14px;
  background: rgba(5, 13, 21, 0.72);
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
}

.secret-browser-lane-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.secret-browser-lane-copy {
  display: grid;
  gap: 6px;
}

.secret-browser-lane-summary {
  font-size: 0.96rem;
  color: #e5f2ff;
}

.secret-browser-lane-toolbar {
  align-items: center;
}

.secret-browser-lane-pill {
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 0.76rem;
  background: rgba(255, 255, 255, 0.05);
  color: #d9ebff;
}

.secret-browser-lane-pill.is-connected {
  border-color: rgba(0, 255, 135, 0.36);
  background: rgba(0, 255, 135, 0.14);
  color: #dcfff1;
}

.secret-browser-lane-pill.is-warning {
  border-color: rgba(255, 190, 85, 0.3);
  background: rgba(255, 190, 85, 0.1);
  color: #ffe7bf;
}

.secret-browser-lane-pill.is-offline {
  border-color: rgba(255, 77, 115, 0.28);
  background: rgba(255, 77, 115, 0.1);
  color: #ffd9e2;
}

.secret-browser-lane-details {
  line-height: 1.45;
}

.secret-browser-command-grid {
  display: grid;
  gap: 10px;
}

.secret-browser-command {
  display: grid;
  gap: 6px;
}

.secret-browser-command > span {
  font-size: 0.78rem;
  color: var(--muted);
}

.secret-browser-command-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.secret-browser-command-row input {
  flex: 1 1 460px;
  min-width: 220px;
 }

.secret-browser-actions {
  align-items: stretch;
  gap: 10px;
  flex-wrap: wrap;
}

.secret-browser-actions input {
  min-width: 240px;
  flex: 1 1 320px;
}

.secret-browser-actions button {
  flex: 0 0 auto;
  white-space: nowrap;
}

.secret-browser-hint {
  margin-top: -2px;
}

.secret-browser-meta {
  line-height: 1.45;
}

.secret-browser-frame {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  overflow: hidden;
  background: #02060a;
  min-height: 700px;
  max-height: min(84vh, 1180px);
  overflow: auto;
}

.secret-browser-frame img {
  display: block;
  width: 100%;
  height: auto;
  cursor: crosshair;
}

.settings-browser-sites {
  margin-top: 0;
}

.secret-connection-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.secret-connection-title {
  display: grid;
  gap: 4px;
}

.secret-connection-title strong {
  font-size: 0.98rem;
}

.secret-connection-key {
  font-size: 0.74rem;
  opacity: 0.82;
}

.secret-connection-flags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.secret-connection-flag {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 0.72rem;
  color: #d8ebff;
  background: rgba(255, 255, 255, 0.04);
}

.secret-connection-flag.is-sensitive {
  border-color: rgba(255, 196, 115, 0.3);
  background: rgba(255, 184, 77, 0.08);
  color: #ffd69b;
}

.secret-connection-meta {
  display: grid;
  gap: 6px;
}

.secret-connection-meta-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 10px;
  align-items: start;
}

.secret-connection-meta-row span:first-child {
  color: var(--muted);
  font-size: 0.8rem;
}

.secret-connection-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.secret-open-btn {
  min-width: 128px;
  font-weight: 700;
}

.secret-site-login {
  border: 1px solid rgba(52, 217, 255, 0.24);
  border-radius: 10px;
  padding: 12px;
  background: rgba(5, 13, 21, 0.55);
}

.secret-site-login-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.secret-grid-span-2 {
  grid-column: span 2;
}

.secret-gog-setup textarea {
  min-height: 108px;
  resize: vertical;
}

@media (max-width: 820px) {
  .secret-grid-span-2 {
    grid-column: span 1;
  }
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

th,
td {
  text-align: left;
  padding: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.muted {
  color: var(--muted);
}

.action-chip {
  display: inline-flex;
  border: 1px solid rgba(52, 217, 255, 0.3);
  border-radius: 999px;
  padding: 3px 8px;
  margin-right: 5px;
  margin-bottom: 5px;
  font-size: 0.7rem;
  color: #c8f4ff;
  background: rgba(52, 217, 255, 0.09);
}

.mono {
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
}

@media (max-width: 980px) {
  :root {
    --base-font-size: 14px;
    --chat-font-size: 0.86rem;
    --overview-chrome: 136px;
    --mobile-tabbar-height: 60px;
  }

  .wrap {
    padding-bottom: max(env(safe-area-inset-bottom), 2px);
  }

  .topbar {
    display: grid;
    grid-template-columns: minmax(0, auto) minmax(0, 1fr);
    padding: 8px 10px;
    gap: 8px;
  }

  .brand {
    gap: 6px;
  }

  .brand-name {
    font-size: 0.72rem;
    letter-spacing: 0.04em;
  }

  #siteName,
  #authUserPill {
    display: none !important;
  }

  .topmeta {
    flex-wrap: nowrap;
    gap: 6px;
    min-width: 0;
    overflow: hidden;
  }

  .top-business-switch {
    min-width: 0;
    width: auto;
    max-width: min(52vw, 240px);
    flex: 1 1 auto;
  }

  .top-business-switch select {
    min-width: 0;
    width: 100%;
    padding: 6px 8px;
    font-size: 0.72rem;
  }

  .topmeta .pill.live {
    font-size: 0.66rem;
    padding: 4px 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: min(56vw, 300px);
  }

  #authLogoutBtn {
    padding: 6px 10px;
    font-size: 0.68rem;
  }

  .tabs-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: -2px;
    z-index: 58;
    margin: 0;
    padding: 6px 8px max(env(safe-area-inset-bottom), 6px);
    gap: 5px;
    border-top: 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    border-radius: 0;
    background: linear-gradient(180deg, rgba(7, 14, 22, 0.96), rgba(7, 14, 22, 0.88));
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.5);
    grid-template-columns: repeat(7, minmax(0, 1fr));
    display: grid;
    backdrop-filter: blur(8px);
  }

  .tab-btn {
    min-height: 40px;
    border-radius: 10px;
    padding: 6px 4px;
    font-size: 0.6rem;
    letter-spacing: 0.06em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    line-height: 1.05;
  }

  .chat-item {
    width: 100%;
    min-width: 0;
  }

  .chat-item-head {
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
    gap: 6px;
  }

  .chat-item-actions {
    justify-content: flex-start;
    max-width: 100%;
  }

  .chat-copy-btn,
  .chat-delete-btn {
    font-size: 0.58rem;
    padding: 3px 7px;
  }

  .overview-shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr);
    min-height: 0;
    height: calc(var(--app-height) - var(--overview-chrome));
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .overview-history-panel {
    position: fixed;
    left: 0;
    top: 0;
    width: min(88vw, 360px);
    height: var(--app-height);
    z-index: 65;
    border-radius: 0 14px 14px 0;
    transform: translateX(-110%);
    transition: transform 180ms ease;
    overflow: hidden;
  }

  .overview-history-panel.is-mobile-open {
    transform: translateX(0);
  }

  .mobile-history-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 60;
    border: 0;
    background: rgba(2, 8, 14, 0.68);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
  }

  .mobile-history-backdrop.is-visible {
    opacity: 1;
    pointer-events: auto;
  }

  .mobile-conversations-btn,
  .mobile-history-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  .mobile-conversations-btn {
    border-color: rgba(52, 217, 255, 0.45);
    background: linear-gradient(180deg, rgba(52, 217, 255, 0.22), rgba(52, 217, 255, 0.08));
    color: #d6f3ff;
  }

  .mobile-history-close {
    border-color: rgba(52, 217, 255, 0.35);
    background: rgba(52, 217, 255, 0.12);
    color: #d3f0ff;
  }

  #chatInput {
    font-size: 14px;
  }

  .chat-bar-btn {
    width: 30px;
    height: 30px;
    min-width: 30px;
    min-height: 30px;
  }

  .chat-send-btn {
    width: 30px;
    height: 30px;
    min-width: 30px;
    min-height: 30px;
  }

  .chat-compose-bar {
    gap: 6px;
    padding: 6px 6px 6px 2px;
  }

  .chat-welcome {
    padding: 32px 16px;
  }

  .chat-welcome-title {
    font-size: 0.95rem;
  }

  .chat-welcome-commands {
    grid-template-columns: 1fr;
    max-width: 280px;
  }

  .agent-status-bar {
    display: none;
  }

  /* On mobile with hide-extra-tabs, still show them in the bottom bar */
  body.hide-extra-tabs .tab-btn-more {
    display: inline-flex;
  }

  body.mobile-history-open {
    overflow: hidden;
  }

  .overview-chat-panel {
    min-height: 0;
    height: 100%;
  }

  .history-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .chat-history-list {
    max-height: calc(var(--app-height) - 78px);
  }

  .chat-log {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    touch-action: pan-y;
    padding-bottom: calc(12px + var(--mobile-tabbar-height) + env(safe-area-inset-bottom));
  }

  .agent-status-board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .actions-row {
    flex-direction: column;
  }
}

@media (max-width: 620px) {
  :root {
    --base-font-size: 13px;
    --chat-font-size: 0.8rem;
    --overview-chrome: 124px;
    --mobile-tabbar-height: 58px;
  }

  .wrap {
    padding: 8px 8px max(env(safe-area-inset-bottom), 2px);
  }

  .topbar {
    align-items: center;
    padding: 7px 8px;
  }

  .topmeta {
    max-width: 100%;
  }

  .top-business-switch {
    max-width: min(48vw, 190px);
  }

  .topmeta .pill.live {
    max-width: min(58vw, 220px);
    font-size: 0.62rem;
  }

  .brand-name {
    font-size: 0.66rem;
    letter-spacing: 0.03em;
  }

  .tabs-nav {
    left: 0;
    right: 0;
    bottom: -2px;
    padding: 5px 7px max(env(safe-area-inset-bottom), 4px);
    gap: 4px;
  }

  .tab-btn {
    min-height: 38px;
    font-size: 0.56rem;
    padding: 6px 2px;
    letter-spacing: 0.05em;
  }

  .agent-status-board {
    grid-template-columns: 1fr;
  }

  .overview-shell {
    min-height: max(620px, calc(var(--app-height) - var(--overview-chrome)));
  }

  .chat-item {
    padding: 8px 10px;
  }

  .chat-item-head {
    gap: 5px;
  }

  .overview-history-panel {
    width: min(92vw, 340px);
  }
}
