:root {
  color-scheme: dark;
  /* Nocturne design-system tokens (claude.ai/design project e7e52fc2), applied as a single
     accent across all screens rather than per-route rainbow hues. */
  --bg: #161826;
  --bg-accent: #1d2036;
  --panel: rgba(35, 37, 50, 0.7);
  --panel-strong: rgba(35, 37, 50, 0.92);
  --border: rgba(233, 233, 237, 0.16);
  --text: #e9e9ed;
  --muted: #9397ab;
  --accent: #9184d9;
  --accent-strong: #b5abfc;
  --accent-100: #f5f4ff;
  --accent-200: #e7e5fe;
  --accent-300: #d2cefd;
  --accent-400: #b5abfc;
  --accent-500: #968ae0;
  --accent-600: #796cbf;
  --accent-700: #5d5294;
  --accent-800: #423a6a;
  --accent-900: #2b2741;
  --neutral-100: #f3f5fe;
  --neutral-200: #e4e7f5;
  --neutral-300: #cfd3e5;
  --neutral-400: #b2b6ca;
  --neutral-500: #9397ab;
  --neutral-600: #75798c;
  --neutral-700: #595d6c;
  --neutral-800: #3f424d;
  --neutral-900: #292b31;
  --section-glow: #353b80;
  --success: #5fc08a;
  --success-text: #8ed3ab;
  --warning: #968ae0;
  --danger: #e0645c;
  --danger-text: #e79992;
  --shadow: 0 0 0 1px var(--neutral-800), 0 24px 54px rgba(3, 9, 21, 0.5);
  --shadow-sm: 0 0 0 1px var(--neutral-800);
  --radius: 18px;
  --route-accent: var(--accent);
  --route-accent-rgb: 145, 132, 217;
  --route-accent-soft: rgba(145, 132, 217, 0.14);
  --route-tint: rgba(145, 132, 217, 0.08);
}

* {
  box-sizing: border-box;
}

@keyframes sk-pulse {
  0%, 100% { opacity: .35; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.35); }
}

@keyframes sk-drift {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(4%, -3%, 0) scale(1.12); }
  100% { transform: translate3d(0, 0, 0) scale(1); }
}

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

html,
body {
  margin: 0;
  min-height: 100%;
  max-width: 100%;
  overflow-x: hidden;
  /* Stops Chromium/Android WebView's native pull-to-refresh: without this,
     dragging past the top of any inner scroll area (chat-thread, panels)
     chains to the root document and reloads the whole app. */
  overscroll-behavior: none;
  background:
    radial-gradient(120% 90% at 50% -10%, var(--bg-accent) 0%, var(--bg) 55%);
  color: var(--text);
  font-family: "Inter", "Segoe UI", sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

body {
  padding: 24px;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  inset: -20% -10% auto -10%;
  height: 70vh;
  pointer-events: none;
  filter: blur(90px);
  opacity: .38;
  z-index: -1;
  background:
    radial-gradient(38% 60% at 22% 30%, var(--accent-800), transparent 70%),
    radial-gradient(40% 55% at 78% 20%, var(--section-glow), transparent 70%);
  animation: sk-drift 26s ease-in-out infinite;
}

button,
input,
textarea {
  font: inherit;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-thumb {
  background: var(--neutral-800);
  border-radius: 9px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.shell {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 0;
  height: calc(100vh - 48px);
  height: calc(100dvh - 48px);
  min-height: calc(100vh - 48px);
  min-height: calc(100dvh - 48px);
  align-items: stretch;
  min-width: 0;
  max-width: 100%;
}

.panel {
  backdrop-filter: blur(24px);
}

/* backdrop-filter creates a new containing block for position:fixed descendants (CSS
   Filter Effects spec), which breaks the viewport-relative email folder drawer/backdrop.
   Excluded here so those stay anchored to the real viewport. */
#email-page > .panel {
  backdrop-filter: none;
}

.nav-rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 14px 0;
  min-height: 0;
  background: linear-gradient(180deg, color-mix(in srgb, var(--panel) 55%, transparent), transparent);
  border-right: 1px solid color-mix(in srgb, var(--neutral-800) 60%, transparent);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, rgba(var(--route-accent-rgb), 0.95), rgba(var(--route-accent-rgb), 0.25), transparent);
  pointer-events: none;
}

.panel::after {
  content: "";
  position: absolute;
  inset: auto -12% -28% auto;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--route-tint) 0%, rgba(0, 0, 0, 0) 72%);
  pointer-events: none;
}

.panel > * {
  position: relative;
  z-index: 1;
}

.rail-logo {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  margin-bottom: 12px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: linear-gradient(150deg, var(--accent-600), var(--accent-800));
  box-shadow: 0 0 20px color-mix(in srgb, var(--accent) 45%, transparent);
}

.panel-header h3 {
  margin: 0;
  font-weight: 700;
}

.support-copy {
  margin: 6px 0 0;
  color: var(--muted);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(var(--route-accent-rgb), 0.25);
  background: var(--route-accent-soft);
  color: var(--accent-300);
  font-size: 0.85rem;
  gap: 8px;
  white-space: nowrap;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  animation: sk-pulse 2.4s ease-in-out infinite;
}

.status-pill.status-unavailable .status-dot,
.status-pill.status-denied .status-dot,
.status-pill.status-failed .status-dot {
  background: var(--danger);
  animation: none;
}

.status-pill.status-failed,
.status-pill.status-paused {
  color: var(--danger-text);
  border-color: rgba(224, 100, 92, 0.3);
  background: rgba(224, 100, 92, 0.12);
}

.status-pill.status-success {
  color: var(--success-text);
  border-color: rgba(95, 192, 138, 0.3);
  background: rgba(95, 192, 138, 0.12);
}

.status-pill.status-running {
  color: var(--accent-300);
}

.workflow-builder {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 18px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--panel) 80%, transparent);
}

.workflow-builder.hidden {
  display: none;
}

.workflow-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.workflow-trigger-interval-field {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.workflow-trigger-interval-field input {
  width: 90px;
}

.workflow-trigger-interval-field.hidden {
  display: none;
}

.workflow-webhook-note.hidden {
  display: none;
}

.workflow-webhook-note code {
  user-select: all;
}

.workflow-steps-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.workflow-step-row {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: color-mix(in srgb, var(--bg-accent) 70%, transparent);
}

.workflow-step-row-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.workflow-step-number {
  font-weight: 600;
  color: var(--muted);
  min-width: 18px;
}

.workflow-step-type-select {
  flex: 0 0 auto;
  width: auto;
}

.workflow-step-name-input {
  flex: 1 1 160px;
  min-width: 0;
}

.workflow-step-row-actions {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.workflow-step-row-actions .icon-button {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.workflow-step-row-actions .icon-button:hover {
  color: var(--text);
  border-color: var(--accent);
}

.workflow-step-config {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.workflow-step-hint {
  margin: 0;
  font-size: 0.78rem;
}

.workflow-step-hint code {
  color: var(--accent-300);
}

.workflow-card-meta-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.workflow-run-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.workflow-run-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
}

.workflow-run-step {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 4px;
}

.form-error {
  color: var(--danger-text);
  font-size: 0.85rem;
  margin: 0;
}

.form-error.hidden {
  display: none;
}

.create-automation-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 16px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 18%, transparent), transparent);
  margin-bottom: 20px;
}

.create-automation-banner h3 {
  margin: 2px 0;
}

.create-automation-banner p {
  margin: 0;
}

.workflow-flow-step {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  background: color-mix(in srgb, var(--bg-accent) 70%, transparent);
}

.workflow-flow-step-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--text);
}

.workflow-flow-step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg);
  font-size: 0.8rem;
}

.workflow-flow-connector {
  width: 2px;
  height: 16px;
  margin: 2px 0 2px 22px;
  background: var(--border);
}

.workflow-step-icon {
  font-size: 16px;
  color: var(--accent-300);
  flex: 0 0 auto;
}

.workflow-step-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.workflow-step-row.collapsed .workflow-step-body {
  display: none;
}

.workflow-step-row.collapsed {
  padding-bottom: 12px;
}

.workflow-step-test-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
}

.workflow-step-test-result {
  flex: 1 1 200px;
  min-width: 0;
  margin: 0;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-family: inherit;
  font-size: 0.78rem;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 160px;
  overflow: auto;
}

.workflow-step-test-result[hidden] {
  display: none;
}

.workflow-step-test-result-success {
  border-color: rgba(95, 192, 138, 0.35);
  background: rgba(95, 192, 138, 0.1);
  color: var(--success-text);
}

.workflow-step-test-result-error {
  border-color: rgba(224, 100, 92, 0.35);
  background: rgba(224, 100, 92, 0.1);
  color: var(--danger-text);
}

.workflow-results-agent-select {
  width: 100%;
  max-width: 320px;
  margin-bottom: 16px;
}

.workflow-result-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.workflow-result-card {
  padding: 12px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid var(--border);
}

.workflow-result-card:first-child {
  border-top: none;
  padding-top: 4px;
}

.workflow-result-card-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.workflow-result-card-header .workflow-step-icon {
  font-size: 18px;
  margin-top: 2px;
}

.workflow-result-card-body {
  font-size: 0.88rem;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.workflow-copilot-card {
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 14px 16px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 14%, transparent), transparent);
  margin-bottom: 4px;
}

.workflow-copilot-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--accent-300);
}

.workflow-copilot-textarea {
  width: 100%;
  resize: vertical;
  min-height: 48px;
}

.workflow-copilot-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
}

.workflow-copilot-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 0.78rem;
  margin: 16px 0;
}

.workflow-copilot-divider::before,
.workflow-copilot-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.chat-home-hero {
  padding: 24px 4px 8px;
  animation: sk-rise 0.3s ease both;
}

.chat-home-hero.hidden {
  display: none;
}

.chat-home-hero h2 {
  margin: 0 0 18px;
  font-size: 1.5rem;
}

.chat-home-sidekick-card {
  margin-bottom: 28px;
}

.chat-home-scratch .section-eyebrow {
  margin-bottom: 10px;
}

.chat-home-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.chat-home-card {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: color-mix(in srgb, var(--panel) 80%, transparent);
  color: var(--text);
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease;
}

.chat-home-card:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
}

.chat-home-card i {
  font-size: 22px;
  color: var(--accent-300);
  flex: 0 0 auto;
}

.chat-home-card div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.chat-home-card strong {
  font-size: 0.92rem;
}

.chat-home-card span {
  font-size: 0.76rem;
  color: var(--muted);
}

.connection-card {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.connection-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 10px;
}

.connection-picker-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 18px 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: color-mix(in srgb, var(--panel) 80%, transparent);
  color: var(--text);
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease;
}

.connection-picker-card:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
}

.connection-picker-card i {
  font-size: 28px;
  color: var(--accent-300);
}

.connection-picker-card span {
  font-size: 0.85rem;
  font-weight: 600;
}

.connection-picker-hint.hidden {
  display: none;
}

.connection-form.hidden {
  display: none;
}

.connection-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--muted);
}

.oauth-apps-section {
  margin-top: 22px;
}

.oauth-provider-setup {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  margin-top: 14px;
}

.oauth-provider-setup h4 {
  margin: 0 0 8px;
}

.oauth-setup-steps {
  margin: 0 0 12px;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.oauth-setup-steps code {
  color: var(--accent-300);
  word-break: break-all;
}

.chatbot-modal-panel {
  width: min(720px, 100%);
}

.chatbot-modal-list-view .stack-list,
#chatbot-modal-list-view .stack-list {
  margin-top: 14px;
}

.chatbot-card {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
}

.chatbot-card:hover {
  border-color: var(--accent);
}

.chatbot-card-actions {
  display: flex;
  gap: 8px;
}

.chatbot-conversation-thread {
  max-height: 45vh;
  min-height: 200px;
  margin: 14px 0;
}

#chatbot-modal-conversation-view.hidden,
#chatbot-modal-list-view.hidden {
  display: none;
}

.mcp-endpoint-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-accent);
  margin: 8px 0 14px;
}

.mcp-endpoint-row code {
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  white-space: nowrap;
}

.workflow-form-fields-field {
  margin-top: 10px;
}

.workflow-form-fields-field.hidden {
  display: none;
}

.field-label-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--muted);
}

.field-label-block code {
  color: var(--accent-300);
}

.field-label-block textarea {
  width: 100%;
}

.workflow-public-form-note {
  margin-top: 8px;
}

.rail-nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.ghost-button,
.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 16px;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

.ghost-button i,
.primary-button i {
  font-size: 15px;
}

.ghost-button:hover,
.primary-button:hover {
  transform: translateY(-1px);
}

.nav-link {
  width: 60px;
  height: 52px;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 0;
  border-radius: 11px;
  cursor: pointer;
  background: transparent;
  color: var(--neutral-600);
  font: inherit;
  transition: background 180ms ease, color 180ms ease, box-shadow 180ms ease;
}

.nav-link i {
  font-size: 17px;
  flex: 0 0 auto;
}

.nav-link span {
  font-size: 9.5px;
  letter-spacing: 0.03em;
}

.nav-link:hover {
  color: var(--accent-300);
}

.nav-link.active {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent-200);
  box-shadow: 0 0 22px color-mix(in srgb, var(--accent) 30%, transparent), inset 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent);
}

.rail-status {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 0;
}

.rail-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  animation: sk-pulse 2.4s ease-in-out infinite;
}

body[data-ai-status="unavailable"] .rail-status-dot {
  background: var(--danger);
  animation: none;
}

.rail-status-label {
  font-size: 8px;
  letter-spacing: 0.08em;
  color: var(--neutral-600);
  text-transform: uppercase;
}

.main {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  min-height: 0;
  padding: 12px 20px 16px 16px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 8px;
  border-bottom: 1px solid color-mix(in srgb, var(--neutral-800) 55%, transparent);
}

.page-header-copy {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

body:not([data-route="chat"]) #chat-menu-button {
  display: none;
}

.page-header-copy #page-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.section-eyebrow {
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.page {
  display: none;
  gap: 20px;
  min-width: 0;
  max-width: 100%;
}

.page.active {
  display: grid;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

#chat-page.active {
  grid-template-columns: 1fr;
  min-height: 0;
}

#agents-page.active {
  grid-template-columns: 1fr;
}

#results-page.active {
  grid-template-columns: 1fr;
}

/* Same proven pattern as #chat-page > .panel (height:100% off the now-bounded
   .page.active, via grid stretch): every non-chat page scrolls at its own
   .panel, not at .page.active itself. Chat is excluded on purpose — it has no
   page-level scrollbar; only .chat-thread scrolls internally, and the
   activity drawer scrolls itself (position:fixed, outside this flow).
   #email-page > .panel is handled separately further down — it had its own
   pre-existing "overflow: visible" rule (an ID selector, so it would have won
   over this one on specificity regardless of source order) that needed fixing
   in place rather than fighting here. */
#results-page > .panel,
#settings-page > .panel,
#agents-page > .panel {
  height: 100%;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior-y: contain;
}

.panel {
  padding: 14px;
  min-width: 0;
  max-width: 100%;
}

#chat-page > .panel {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
  flex: 0 0 auto;
}

.chat-agent-header {
  margin-top: 20px;
}

.chat-thread,
.stack-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
}

.chat-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(7, 11, 18, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease;
  z-index: 30;
}

.chat-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(340px, 86vw);
  padding: 28px 18px 24px;
  background: linear-gradient(180deg, #1c1f31, var(--bg));
  border-left: 1px solid var(--border);
  box-shadow: -18px 0 40px rgba(0, 0, 0, 0.55);
  transform: translateX(102%);
  transition: transform 180ms ease;
  z-index: 31;
  overflow-y: auto;
  overscroll-behavior-y: contain;
}

#chat-page.drawer-open .chat-drawer-backdrop {
  opacity: 1;
  pointer-events: auto;
}

#chat-page.drawer-open .chat-drawer {
  transform: translateX(0);
}

.chat-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.sidebar-subsection + .sidebar-subsection {
  margin-top: 18px;
}

.sidebar-subsection > .collapsible-summary {
  padding-bottom: 4px;
}

.sidebar-subsection > .collapsible-body {
  margin-top: 12px;
}

.chat-thread {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  padding-right: 4px;
}

.message {
  border-radius: 14px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  min-width: 0;
  max-width: 100%;
}

.message.user {
  background: linear-gradient(135deg, rgba(var(--route-accent-rgb), 0.16), rgba(83, 178, 255, 0.08));
}

.message.pending {
  border-style: dashed;
  opacity: 0.84;
}

.message-role {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
  font-size: 0.76rem;
  color: var(--muted);
}

.message-role-copy {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  min-width: 0;
}

.message-time {
  flex-shrink: 0;
  text-transform: none;
  letter-spacing: normal;
  font-size: 0.74rem;
  color: var(--neutral-600);
}

.message-avatar-shell {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 10px;
  background: linear-gradient(150deg, var(--accent-600), var(--accent-800));
  border: 1px solid rgba(var(--route-accent-rgb), 0.28);
  box-shadow: 0 0 0 0 rgba(var(--route-accent-rgb), 0.28);
  animation: sidekick-avatar-float 3.2s ease-in-out infinite, sidekick-avatar-pulse 2.6s ease-out infinite;
}

.message-avatar-pending {
  animation-duration: 1.8s, 1.4s;
}

.message-avatar {
  width: 18px;
  height: 18px;
  border-radius: 6px;
}

@keyframes sidekick-avatar-float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-2px);
  }
}

@keyframes sidekick-avatar-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(var(--route-accent-rgb), 0.28);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(var(--route-accent-rgb), 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(var(--route-accent-rgb), 0);
  }
}

.message-body {
  white-space: pre-wrap;
  line-height: 1.45;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.composer,
.memory-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 18px;
}

.composer {
  flex: 0 0 auto;
  padding-top: 14px;
  border-top: 1px solid rgba(var(--route-accent-rgb), 0.16);
  background: linear-gradient(180deg, rgba(10, 17, 32, 0), rgba(10, 17, 32, 0.18));
}

textarea,
input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 16px;
  color: var(--text);
  background: rgba(5, 11, 24, 0.36);
}

textarea {
  resize: vertical;
}

.composer-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.chat-attachment-button {
  text-decoration: none;
}

.chat-composer-buttons {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.chat-attachment-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
}

.chat-attachment-list.is-empty {
  display: none;
}

.chat-attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(var(--route-accent-rgb), 0.28);
  background: rgba(var(--route-accent-rgb), 0.12);
  color: var(--text);
  font-size: 0.84rem;
  max-width: 100%;
  overflow: hidden;
}

.chat-attachment-chip {
  white-space: nowrap;
  text-overflow: ellipsis;
}

.chat-attachment-remove {
  border: 0;
  background: transparent;
  color: var(--route-accent);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
}

.ghost-button {
  padding: 11px 14px;
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(var(--route-accent-rgb), 0.2);
  color: var(--text);
}

.results-filter-button {
  padding: 7px 12px;
  font-size: 0.78rem;
}

.results-filter-button.active {
  border-color: rgba(var(--route-accent-rgb), 0.6);
  background: var(--route-accent-soft);
  color: var(--accent-200);
}

.results-filter-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 10px;
  background: color-mix(in srgb, var(--neutral-700) 30%, transparent);
  color: var(--neutral-400);
}

.results-filter-button.active .results-filter-count {
  background: color-mix(in srgb, var(--accent) 26%, transparent);
  color: var(--accent-200);
}

.results-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.results-filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.results-sort-select {
  width: auto;
  min-width: 0;
  padding: 7px 30px 7px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(var(--route-accent-rgb), 0.2);
}

.inline-link-button {
  text-decoration: none;
}

.primary-button {
  padding: 11px 16px;
  background: linear-gradient(135deg, rgba(var(--route-accent-rgb), 0.96), rgba(var(--route-accent-rgb), 0.72));
  color: var(--accent-100);
  font-weight: 700;
}

.task-item,
.memory-item,
.capability-item,
.artifact-item {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: color-mix(in srgb, var(--panel) 80%, transparent);
  box-shadow: var(--shadow-sm);
  padding: 14px 16px;
  animation: sk-rise .3s ease both;
  transition: background 160ms ease, transform 160ms ease;
}

.task-item:hover,
.memory-item:hover,
.capability-item:hover,
.artifact-item:hover {
  background: color-mix(in srgb, var(--panel) 100%, transparent);
}

.agent-compact {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: color-mix(in srgb, var(--panel) 80%, transparent);
  box-shadow: var(--shadow-sm);
  padding: 14px 16px;
  animation: sk-rise .3s ease both;
}

.watch-item {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: color-mix(in srgb, var(--panel) 80%, transparent);
  box-shadow: var(--shadow-sm);
  min-width: 0;
  max-width: 100%;
  animation: sk-rise .3s ease both;
}

.section-intro {
  margin: 0 0 16px;
}

.agents-subheader {
  margin-top: 20px;
}

.collapsible-section {
  overflow: hidden;
}

.collapsible-section > summary {
  list-style: none;
}

.collapsible-section > summary::-webkit-details-marker {
  display: none;
}

.collapsible-summary {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  cursor: pointer;
}

.summary-trailing {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.collapsible-chevron {
  width: 12px;
  height: 12px;
  margin-top: 6px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 140ms ease;
}

.collapsible-section[open] > .collapsible-summary .collapsible-chevron {
  transform: rotate(-135deg);
}

.collapsible-body {
  margin-top: 14px;
}

.watch-edit-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
}

.watch-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 10px;
}

.watch-title {
  font-weight: 700;
}

.watch-meta {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.listing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
  margin-top: 14px;
  min-width: 0;
  max-width: 100%;
}

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

.agent-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px 14px;
  margin-bottom: 14px;
}

.checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.checkbox-row input {
  width: auto;
}

.artifact-upload-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.artifact-upload-button {
  cursor: pointer;
}

.artifact-filter-panel {
  padding: 16px;
  border: 1px solid rgba(var(--route-accent-rgb), 0.24);
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(var(--route-accent-rgb), 0.09), rgba(255,255,255,0.02));
}

.email-shell {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
}

.email-appbar {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px 44px;
  gap: 10px;
  align-items: center;
}

.email-icon-button,
.email-account-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(var(--route-accent-rgb), 0.18);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 16px;
}

.email-account-chip {
  font-weight: 700;
  background: linear-gradient(150deg, var(--accent-600), var(--accent-800));
  color: var(--accent-100);
}

.email-search-pill {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  min-height: 52px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid rgba(var(--route-accent-rgb), 0.14);
  background: rgba(255, 255, 255, 0.045);
  color: var(--muted);
}

.email-search-pill i {
  color: var(--neutral-500);
}

.email-drawer-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent-300);
}

.email-overview-compact {
  min-width: 0;
  display: contents;
}

.email-overview-card-surface {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(var(--route-accent-rgb), 0.05));
  padding: 14px 16px;
}

.email-overview-copy,
.email-overview-trailing {
  display: inline-block;
  vertical-align: top;
}

.email-overview-copy {
  width: calc(100% - 110px);
}

.email-overview-trailing {
  width: 100px;
  text-align: right;
}

.email-overview-folder {
  font-size: 1rem;
  font-weight: 700;
}

.email-overview-account,
.email-overview-meta {
  color: var(--muted);
  font-size: 0.9rem;
}

.email-folder-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(7, 11, 18, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease;
  z-index: 30;
}

.email-folder-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(320px, 82vw);
  padding: 28px 18px 24px;
  background: linear-gradient(180deg, #1c1f31, var(--bg));
  border-right: 1px solid var(--border);
  box-shadow: 18px 0 40px rgba(0, 0, 0, 0.55);
  transform: translateX(-102%);
  transition: transform 180ms ease;
  z-index: 31;
  overflow-y: auto;
}

#email-page.drawer-open .email-folder-backdrop {
  opacity: 1;
  pointer-events: auto;
}

#email-page.drawer-open .email-folder-drawer {
  transform: translateX(0);
}

.email-drawer-header {
  margin-bottom: 18px;
}

.email-folder-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.email-folder-button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 18px;
  background: transparent;
  color: var(--text);
  padding: 12px 14px;
}

.email-folder-button.active {
  background: var(--route-accent-soft);
  color: var(--accent-200);
  font-weight: 600;
}

.email-folder-icon {
  width: 20px;
  text-align: center;
  color: var(--muted);
}

.email-message-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
}

.email-list-item {
  width: 100%;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 28px;
  gap: 12px;
  align-items: start;
  text-align: left;
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 12px;
  background: rgba(255,255,255,0.03);
  padding: 14px 12px;
  color: var(--text);
  transition: background 160ms ease;
}

.email-list-item:hover {
  background: color-mix(in srgb, var(--panel) 90%, transparent);
}

.email-list-item.unread {
  background: rgba(255,255,255,0.065);
  border-color: rgba(var(--route-accent-rgb), 0.14);
}

.email-list-item.read {
  opacity: 0.8;
}

.email-list-item.active {
  background: var(--route-accent-soft);
  border-color: rgba(var(--route-accent-rgb), 0.25);
}

.email-sender-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(150deg, var(--accent-600), var(--accent-800));
  color: var(--accent-100);
  font-weight: 800;
}

.thread-avatar {
  flex-shrink: 0;
}

.email-list-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.email-list-topline {
  display: flex;
  gap: 8px;
  align-items: baseline;
}

.email-list-sender,
.email-list-subject {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.email-list-sender {
  flex: 1;
  font-weight: 700;
}

.email-list-item.read .email-list-sender,
.email-list-item.read .email-list-subject {
  font-weight: 500;
  color: rgba(232, 237, 247, 0.86);
}

.email-list-item.unread .email-list-sender,
.email-list-item.unread .email-list-subject,
.email-list-item.unread .email-list-time {
  font-weight: 700;
  color: var(--neutral-100);
}

.email-list-time {
  color: var(--muted);
  font-size: 0.84rem;
}

.email-list-subject {
  font-size: 0.92rem;
}

.email-list-snippet {
  color: var(--muted);
  font-size: 0.84rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.email-list-meta {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding-top: 4px;
}

.email-unread-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-300);
  box-shadow: 0 0 0 4px rgba(var(--route-accent-rgb), 0.14);
}

.email-star-glyph {
  color: var(--neutral-700);
  font-size: 1rem;
}

.email-star-glyph.starred {
  color: var(--accent-300);
}

.email-thread-pane {
  display: none;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
}

#email-page.thread-open .email-thread-pane {
  display: flex;
}

#email-page.thread-open .email-message-list,
#email-page.thread-open .email-overview-compact {
  display: none;
}

.email-thread-toolbar {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.email-thread-title {
  font-size: 1rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.email-thread-message {
  min-height: auto;
}

.email-thread-message-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}

.email-thread-message-copy {
  flex: 1;
  min-width: 0;
}

.email-thread-message-copy .memory-title,
.email-thread-address,
.email-thread-date,
.email-thread-message-copy .task-meta {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.email-thread-date {
  margin-top: 2px;
}

.email-thread-subject {
  margin-bottom: 10px;
}

.email-reply-form.hidden {
  display: none;
}

.email-compose-fab {
  position: fixed;
  right: max(16px, env(safe-area-inset-right, 0px) + 12px);
  left: auto;
  top: auto;
  bottom: calc(94px + env(safe-area-inset-bottom, 0px));
  transform: none;
  min-width: 124px;
  min-height: 52px;
  border-radius: 18px;
  border: 1px solid rgba(var(--route-accent-rgb), 0.55);
  background: color-mix(in srgb, var(--accent-800) 92%, transparent);
  color: var(--accent-100);
  font-weight: 700;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.55), 0 0 24px rgba(var(--route-accent-rgb), 0.35);
  z-index: 20;
}

#email-page.thread-open .email-compose-fab,
#email-page.drawer-open .email-compose-fab {
  display: none;
}

#email-page,
#email-page .panel,
#email-page .message-body,
#email-page textarea,
#email-page input,
#email-page button,
#email-page article {
  max-width: 100%;
}

#email-page .message-body,
#email-page .task-meta,
#email-page .memory-title {
  min-width: 0;
}

#email-page {
  overflow: hidden;
}

#email-page > .panel {
  height: 100%;
  min-height: 0;
  overflow-y: auto;
}

.settings-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  margin-bottom: 16px;
  border-radius: 11px;
  background: color-mix(in srgb, var(--panel) 45%, transparent);
}

.settings-tab {
  flex: 1 1 110px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  font-weight: 400;
  color: var(--neutral-500);
  background: transparent;
  transition: background 160ms ease, color 160ms ease;
}

.settings-tab:hover {
  color: var(--accent-300);
}

.settings-tab.active {
  font-weight: 600;
  color: var(--accent-200);
  background: color-mix(in srgb, var(--accent) 18%, transparent);
}

.settings-panel {
  display: none;
}

.settings-panel.active {
  display: block;
}

.permission-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  max-width: 100%;
}

.permission-item {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: color-mix(in srgb, var(--panel) 80%, transparent);
  box-shadow: var(--shadow-sm);
  padding: 12px 14px;
  min-width: 0;
  animation: sk-rise .3s ease both;
  transition: background 160ms ease;
}

.permission-item:hover {
  background: color-mix(in srgb, var(--panel) 100%, transparent);
}

.permission-icon-wrap {
  flex: 0 0 31px;
  width: 31px;
  height: 31px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  font-size: 15px;
  color: var(--neutral-600);
  background: color-mix(in srgb, var(--neutral-800) 40%, transparent);
  transition: background 160ms ease, color 160ms ease;
}

.permission-icon-wrap.is-on {
  color: var(--accent-200);
  background: color-mix(in srgb, var(--accent) 18%, transparent);
}

.permission-body {
  flex: 1;
  min-width: 0;
}

.permission-label {
  font-weight: 700;
  text-transform: capitalize;
}

.permission-desc {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.permission-status {
  margin-top: 4px;
  color: var(--neutral-600);
  font-size: 0.76rem;
  text-transform: capitalize;
}

.permission-toggle {
  position: relative;
  flex: 0 0 40px;
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: var(--neutral-800);
  transition: background 200ms ease;
}

.permission-toggle.is-on {
  background: color-mix(in srgb, var(--accent) 55%, transparent);
  box-shadow: 0 0 14px color-mix(in srgb, var(--accent) 45%, transparent);
}

.permission-toggle-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--neutral-500);
  transition: left 200ms ease, background 200ms ease;
}

.permission-toggle.is-on .permission-toggle-knob {
  left: 21px;
  background: var(--accent-100);
}

.notification-diagnostics-actions {
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.artifact-filter-header {
  margin-bottom: 12px;
}

.artifact-filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  align-items: end;
  min-width: 0;
  max-width: 100%;
}

.listing-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  background: color-mix(in srgb, var(--panel) 78%, transparent);
  box-shadow: var(--shadow-sm);
  min-width: 0;
  max-width: 100%;
  animation: sk-rise .3s ease both;
  transition: background 160ms ease, transform 160ms ease;
}

.listing-card:hover {
  background: color-mix(in srgb, var(--panel) 100%, transparent);
  transform: translateY(-2px);
}

.listing-card a {
  color: var(--accent);
  text-decoration: none;
}

.listing-photos {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.listing-photos a {
  font-size: 0.84rem;
}

.results-watch,
.run-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: color-mix(in srgb, var(--panel) 78%, transparent);
  box-shadow: var(--shadow-sm);
  min-width: 0;
  max-width: 100%;
  animation: sk-rise .3s ease both;
}

.results-watch > .collapsible-summary,
.run-card > .collapsible-summary,
.watch-item > .collapsible-summary {
  padding: 16px;
}

.results-watch > .collapsible-body,
.run-card > .collapsible-body,
.watch-item > .collapsible-body {
  padding: 0 16px 16px;
  margin-top: 0;
}

.results-run-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.removed-listings-block {
  margin-top: 14px;
  border: 1px dashed rgba(224, 100, 92, 0.28);
  border-radius: 16px;
  background: rgba(224, 100, 92, 0.05);
}

.removed-summary {
  padding: 14px 16px;
}

.removed-listings-block > .collapsible-body {
  padding: 0 16px 16px;
}

.change-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  margin-bottom: 12px;
}

.change-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  border: 1px solid var(--border);
}

.change-new {
  background: rgba(95, 192, 138, 0.14);
  color: var(--success-text);
}

.change-changed {
  background: var(--route-accent-soft);
  color: var(--accent-300);
}

.change-unchanged {
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
}

.change-removed {
  background: rgba(224, 100, 92, 0.14);
  color: var(--danger-text);
}

.results-listing-grid {
  margin-top: 0;
}

.result-listing-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: color-mix(in srgb, var(--panel) 80%, transparent);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease;
  animation: sk-rise 0.3s ease both;
}

.result-listing-card:hover,
.result-listing-card:focus-visible {
  background: color-mix(in srgb, var(--panel) 100%, transparent);
  transform: translateY(-2px);
}

.result-listing-card.deep-link-focus {
  border-color: rgba(95, 192, 138, 0.85);
  box-shadow: 0 0 0 2px rgba(95, 192, 138, 0.22), 0 22px 46px rgba(0, 0, 0, 0.28);
}

.listing-new {
  border-color: rgba(95, 192, 138, 0.35);
}

.listing-changed {
  border-color: rgba(var(--route-accent-rgb), 0.35);
}

.listing-removed {
  border-color: rgba(224, 100, 92, 0.35);
}

.listing-photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 10px;
  min-width: 0;
  max-width: 100%;
}

.listing-photo-tile {
  display: block;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.04);
}

.listing-photo-tile img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.upload-preview {
  margin-top: 12px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
}

.upload-preview img {
  display: block;
  width: 100%;
  height: auto;
}

.task-title-row,
.memory-title-row,
.capability-title-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.artifact-toggle {
  cursor: pointer;
}

.artifact-toggle .memory-title {
  flex: 1;
}

.artifact-chevron {
  flex: 0 0 auto;
  font-size: 13px;
  color: var(--neutral-600);
}

.task-title,
.memory-title,
.capability-title {
  font-weight: 700;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.capability-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.capability-title i {
  color: var(--accent-400);
  font-size: 15px;
}

.task-meta,
.memory-meta,
.capability-meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.watch-meta,
.task-title-row,
.memory-title-row,
.capability-title-row,
.watch-header,
.panel-header,
.inline-actions,
.composer-actions {
  min-width: 0;
}

.panel a,
.task-meta a,
.memory-meta a,
.capability-meta a,
.watch-meta a,
.message-body a {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.capability-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  min-width: 0;
  max-width: 100%;
}

.status-planned {
  color: var(--accent-200);
  background: rgba(var(--route-accent-rgb), 0.2);
  border-color: rgba(var(--route-accent-rgb), 0.34);
}

.status-granted,
.status-available,
.status-completed,
.status-active {
  color: var(--success-text);
  background: rgba(95, 192, 138, 0.14);
  border-color: rgba(95, 192, 138, 0.28);
}

.status-denied,
.status-unavailable,
.status-failed,
.status-error {
  color: var(--danger-text);
  background: rgba(224, 100, 92, 0.14);
  border-color: rgba(224, 100, 92, 0.28);
}

.empty-state {
  border: 1px dashed var(--border);
  border-radius: 18px;
  padding: 18px;
  color: var(--muted);
}

.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;
}

.listing-card-media {
  position: relative;
  aspect-ratio: 4 / 3;
  background: rgba(255, 255, 255, 0.04);
  min-width: 0;
}

.listing-card-media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.listing-card-media-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 30px;
  color: var(--neutral-600);
  background: linear-gradient(150deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.015));
}

.listing-card-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: capitalize;
  backdrop-filter: blur(6px);
}

.badge-new {
  background: rgba(95, 192, 138, 0.88);
  color: #0d1f16;
}

.badge-changed {
  background: rgba(var(--route-accent-rgb), 0.9);
  color: #1c1730;
}

.badge-removed {
  background: rgba(224, 100, 92, 0.88);
  color: #2b0e0b;
}

.listing-card-price {
  position: absolute;
  bottom: 8px;
  right: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  background: rgba(7, 11, 18, 0.72);
  color: var(--text);
  backdrop-filter: blur(6px);
}

.listing-card-body {
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.listing-card-title {
  font-weight: 700;
  font-size: 0.94rem;
  line-height: 1.3;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.listing-card-address {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-listing-card.listing-removed {
  opacity: 0.72;
}

body.modal-open {
  overflow: hidden;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(7, 11, 18, 0.6);
}

.modal-overlay.hidden {
  display: none;
}

.modal-panel {
  position: relative;
  width: min(640px, 100%);
  max-height: min(85vh, 800px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--panel-strong);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.modal-close-button {
  position: sticky;
  top: 0;
  float: right;
  margin-left: 12px;
  z-index: 1;
}

.mobile-bottom-nav {
  display: none;
}

body[data-route="chat"] #chat-page > .panel > .panel-header,
body[data-route="agents"] #agents-page > .panel > .panel-header:first-of-type,
body[data-route="results"] #results-page > .panel > .panel-header:first-of-type,
body[data-route="settings"] #settings-page > .panel > .panel-header:first-of-type {
  display: none;
}

body[data-route="agents"] #agents-page .section-intro {
  display: none;
}

@media (max-width: 980px) {
  body {
    padding: 12px;
    overflow-x: hidden;
    padding-bottom: calc(96px + env(safe-area-inset-bottom));
  }

  .shell {
    grid-template-columns: 1fr;
    gap: 14px;
    /* Desktop's height:calc(100dvh - 48px) assumes desktop body's 24px+24px
       padding; mobile body padding is 12px top + (96px + safe-area) bottom
       for the floating nav, so the desktop formula undercounts by ~60px+
       and leaves .shell (and everything sized from it, incl. #chat-page's
       flex layout) taller than the visible area. */
    height: calc(100vh - 12px - 96px - env(safe-area-inset-bottom));
    height: calc(100dvh - 12px - 96px - env(safe-area-inset-bottom));
    min-height: 0;
  }

  .nav-rail {
    display: none;
  }

  .main {
    order: 1;
    gap: 14px;
    padding: 0;
  }

  .panel {
    border-radius: 20px;
  }

  .panel {
    padding: 14px;
  }

  .page-header {
    padding-bottom: 12px;
    flex-wrap: nowrap;
    gap: 8px;
  }

  .page-header #chat-menu-button {
    flex-shrink: 0;
  }

  .page-header-copy {
    flex-shrink: 1;
    overflow: hidden;
  }

  .page-header-copy #page-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .page-header .status-pill {
    flex-shrink: 0;
    padding: 0 10px;
  }

  .page-header .status-pill-label,
  .page-header .refresh-button-version {
    display: none;
  }

  #page-refresh-button {
    flex-shrink: 0;
    padding: 11px;
  }

  body[data-route="email"] .page-header {
    display: none;
  }

  .page.active,
  #chat-page.active,
  #email-page.active,
  #agents-page.active,
  #results-page.active {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-width: 0;
    max-width: 100%;
  }

  #chat-page.active {
    grid-template-columns: 1fr;
  }

  /* The floating .mobile-bottom-nav is position:fixed and sits outside the
     layout flow, so it doesn't reserve space -- without this, the last
     item in any scrollable panel (e.g. an expanded "Activity history"
     block on Results) ends up hidden behind it. */
  #results-page > .panel,
  #settings-page > .panel,
  #agents-page > .panel {
    padding-bottom: calc(96px + env(safe-area-inset-bottom));
  }

  .panel {
    width: 100%;
  }

  .panel-header {
    margin-bottom: 12px;
  }

  .composer {
    margin-top: 14px;
  }

  .composer-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .chat-composer-buttons {
    width: 100%;
    gap: 8px;
  }

  .chat-attachment-button,
  .chat-composer-buttons .primary-button {
    flex: 1 1 0;
    text-align: center;
    justify-content: center;
  }

  .artifact-filter-grid,
  .results-filter-group,
  .inline-actions {
    grid-template-columns: 1fr;
  }

  .listing-grid,
  .capability-grid {
    grid-template-columns: 1fr;
  }

  .email-appbar {
    grid-template-columns: 40px minmax(0, 1fr) 40px 40px;
  }

  #email-page .panel {
    padding: 12px;
  }

  .email-shell {
    gap: 10px;
  }

  .email-thread-toolbar {
    grid-template-columns: 40px minmax(0, 1fr);
  }

  .email-thread-toolbar .ghost-button {
    grid-column: 1 / -1;
  }

  textarea,
  input,
  select {
    max-width: 100%;
  }

  .listing-grid,
  .capability-grid,
  .artifact-filter-grid,
  .results-run-stack,
  .stack-list,
  .watch-item,
  .results-watch,
  .run-card,
  .listing-card,
  .panel,
  .page,
  .main {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  .mobile-bottom-nav {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    z-index: 50;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
    padding: 8px;
    border: 1px solid rgba(var(--route-accent-rgb), 0.24);
    border-radius: 20px;
    background: var(--panel-strong);
    box-shadow: 0 24px 48px rgba(3, 9, 21, 0.42);
    backdrop-filter: blur(24px);
  }

  .mobile-nav-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-width: 0;
    border: 1px solid transparent;
    border-radius: 12px;
    background: transparent;
    color: var(--muted);
    min-height: 48px;
    padding: 8px 4px;
    font: inherit;
    font-size: 0.68rem;
    line-height: 1.15;
    text-align: center;
    transition: background 160ms ease, color 160ms ease;
  }

  .mobile-nav-link i {
    font-size: 18px;
  }

  .mobile-nav-link.active {
    background: var(--route-accent-soft);
    color: var(--accent-200);
    font-weight: 600;
    box-shadow: 0 0 18px rgba(var(--route-accent-rgb), 0.3), inset 0 0 0 1px rgba(var(--route-accent-rgb), 0.45);
  }
}
