/* Product-wide visual contract: three type sizes and seven palette colors. */
:root,
[data-theme="dark"] {
  --palette-bg: #0b1113;
  --palette-surface: #10191c;
  --palette-surface-alt: #1c2a2f;
  --palette-text: #edf4f2;
  --palette-muted: #95abae;
  --palette-accent: #21efad;
  --palette-status: #ffac9b;

  --bg: var(--palette-bg);
  --surface: var(--palette-surface);
  --surface-2: var(--palette-surface-alt);
  --surface-3: var(--palette-surface-alt);
  --line: var(--palette-surface-alt);
  --text: var(--palette-text);
  --muted: var(--palette-muted);
  --accent: var(--palette-accent);
  --accent-text: var(--palette-bg);
  --accent-soft: var(--palette-surface-alt);
  --danger: var(--palette-status);
  --shadow: 0 16px 65px color-mix(in srgb, var(--palette-bg) 30%, transparent);

  --font-title: 28px;
  --font-body: 14px;
  --font-meta: 12px;
}

[data-theme="light"] {
  --palette-bg: #f4f7f7;
  --palette-surface: #ffffff;
  --palette-surface-alt: #e5efec;
  --palette-text: #152b26;
  --palette-muted: #4e6a62;
  --palette-accent: #087a57;
  --palette-status: #ac3021;
}

[data-theme="warm"] {
  --palette-bg: #f3eee6;
  --palette-surface: #fffbf4;
  --palette-surface-alt: #e8dbca;
  --palette-text: #3d3025;
  --palette-muted: #6d5945;
  --palette-accent: #935124;
  --palette-status: #a93830;
}

/* Typography roles: title, body, and metadata only. */
body,
button,
input,
select,
textarea,
body p,
body .btn,
body .nav-item,
body .data-table,
body .dv-card,
body .chat-message,
body .field,
body .notice,
body .config-section,
body .catalog-card {
  font-size: var(--font-body) !important;
}

h1,
h2,
.view-title h1,
.view-title h2,
.hero h1,
.chat-heading h1,
.stat strong,
.code-box,
.modal h2,
.widget-panel h2 {
  font-size: var(--font-title) !important;
}

h3,
h4,
.panel-head h3,
.nerd-card h3,
.cards-grid .nerd-card h3,
.sync-node h3,
.catalog-card h3 {
  font-size: var(--font-body) !important;
}

small,
code,
pre,
kbd,
.eyebrow,
.pill,
.badge,
.field-note,
.status-line,
.breadcrumb,
.dv-count,
.item-badge,
.footnotes,
.step-number,
.activity-row time,
.hero-art-note,
.terminal-label {
  font-size: var(--font-meta) !important;
}

/* Keep utility/status surfaces inside the same seven-color palette. */
.brand b span,
.hero .eyebrow,
.notice .icon,
.empty .icon,
.activity-dot,
.step-number.done,
.sync-node .icon,
.sync-link,
.plan-step .icon,
.layout-grid .choice .icon,
.suggestion:hover,
.thumb-badge-net,
.thumb-badge-sub,
.thumb-latency,
.mcp-chip {
  color: var(--accent) !important;
}

.activity-dot,
.step-number.done,
.thumb-pill-200,
.mcp-chip {
  background: var(--accent-soft) !important;
}

.desktop-preview {
  background: var(--surface-2) !important;
  color: var(--muted) !important;
}

.desktop-preview .window-bar,
.terminal-label {
  background: var(--surface-3) !important;
  color: var(--muted) !important;
}

.desktop-preview pre,
.terminal-label {
  color: var(--muted) !important;
}

.theme-sample.dark,
.theme-sample.light,
.theme-sample.warm {
  background: var(--bg) !important;
}

.theme-sample.dark i,
.theme-sample.light i,
.theme-sample.warm i {
  background: var(--accent) !important;
}

.form-error,
.btn.danger,
.logout-btn,
.toast.error {
  color: var(--danger) !important;
}

.entity-editor form[data-form="entity"] {
  position: relative;
}

.form-edge-actions {
  display: flex;
  justify-content: flex-end;
  margin: -10px -10px 12px;
}

@media (max-width: 760px) {
  .form-edge-actions {
    margin: -6px -6px 10px;
  }
}

@media (max-width: 760px) {
  :root,
  [data-theme="dark"],
  [data-theme="light"],
  [data-theme="warm"] {
    --font-title: 24px;
    --font-body: 14px;
    --font-meta: 12px;
  }
}

/* Session/mode colors override theme and saved appearance accents.
   AUTO is yellow, DEMO/anonymous is blue, authenticated USER is green. */
[data-mode="user"][data-auth="in"] {
  --palette-accent: #21efad !important;
  --accent: #21efad !important;
  --accent-text: #063426 !important;
  --accent-soft: rgba(33, 239, 173, 0.16) !important;
  --accent-border: #6ee7b7 !important;
}

[data-theme="light"][data-mode="user"][data-auth="in"],
[data-theme="warm"][data-mode="user"][data-auth="in"] {
  --palette-accent: #087a57 !important;
  --accent: #087a57 !important;
  --accent-text: #ffffff !important;
  --accent-soft: #e0f4e9 !important;
  --accent-border: #065f46 !important;
}

[data-mode="auto"] {
  --palette-accent: #facc15 !important;
  --accent: #facc15 !important;
  --accent-text: #1a1202 !important;
  --accent-soft: rgba(250, 204, 21, 0.18) !important;
  --accent-border: #eab308 !important;
}

[data-theme="light"][data-mode="auto"],
[data-theme="warm"][data-mode="auto"] {
  --palette-accent: #facc15 !important;
  --accent: #a16207 !important;
  --accent-text: #ffffff !important;
  --accent-soft: #fef9c3 !important;
  --accent-border: #854d0e !important;
}

[data-mode="demo"],
[data-auth="out"]:not([data-mode="auto"]) {
  --palette-accent: #22d3ee !important;
  --accent: #22d3ee !important;
  --accent-text: #062530 !important;
  --accent-soft: rgba(34, 211, 238, 0.16) !important;
  --accent-border: #67e8f9 !important;
}

[data-theme="light"][data-mode="demo"],
[data-theme="warm"][data-mode="demo"],
[data-theme="light"][data-auth="out"]:not([data-mode="auto"]),
[data-theme="warm"][data-auth="out"]:not([data-mode="auto"]) {
  --palette-accent: #0284c7 !important;
  --accent: #0284c7 !important;
  --accent-text: #ffffff !important;
  --accent-soft: #e0f2fe !important;
  --accent-border: #0369a1 !important;
}

/* Distinct visual style for AUTO mode toggle button */
.mode-switch button[data-value="auto"].active,
.mode-switch button.mode-auto-active {
  background: #facc15 !important;
  color: #1a1202 !important;
  font-weight: 700 !important;
  border-color: #eab308 !important;
  box-shadow: 0 0 12px rgba(250, 204, 21, 0.5) !important;
  animation: pulse-auto-indicator 2s infinite ease-in-out;
}

@keyframes pulse-auto-indicator {
  0%, 100% {
    box-shadow: 0 0 6px rgba(250, 204, 21, 0.35);
  }
  50% {
    box-shadow: 0 0 16px rgba(250, 204, 21, 0.8);
  }
}

[data-mode="auto"] .agent-banner {
  border-left: 3px solid #facc15 !important;
  background: rgba(250, 204, 21, 0.08) !important;
}

[data-mode="auto"] .agent-status.live {
  border-color: #facc15 !important;
  box-shadow: 0 0 16px rgba(250, 204, 21, 0.12) !important;
}

[data-mode="auto"] .status-ping {
  background: #facc15 !important;
  box-shadow: 0 0 8px #facc15 !important;
}

/* Collapsible details for host and record parameters without page reload */
.record-details-fold {
  margin: 14px 0;
  border: 1px solid var(--line, #30363d);
  border-radius: 8px;
  background: var(--surface-2, rgba(255, 255, 255, 0.02));
  overflow: hidden;
  transition: border-color 0.15s ease;
}
.record-details-fold[open] {
  border-color: var(--line-active, #58a6ff);
}
.more-toggle-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
  list-style: none;
  font-size: 13px;
  background: transparent;
}
.more-toggle-summary::-webkit-details-marker {
  display: none;
}
.more-toggle-summary:hover {
  background: var(--surface-3, rgba(255, 255, 255, 0.04));
}
.more-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  color: var(--muted, #8b949e);
  transition: transform 0.2s ease;
}
.more-icon svg {
  width: 16px;
  height: 16px;
}
.record-details-fold[open] > .more-toggle-summary .more-icon {
  transform: rotate(90deg);
  color: var(--text, #c9d1d9);
}
.more-badge {
  display: inline-block;
  font-family: var(--font-mono, monospace);
  font-size: 12px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 4px;
  background: var(--accent-subtle, rgba(88, 166, 255, 0.12));
  color: var(--accent, #58a6ff);
  border: 1px solid var(--accent-border, rgba(88, 166, 255, 0.25));
}
.more-label {
  color: var(--muted, #8b949e);
  font-size: 13px;
}
.record-details-fold > .detail-grid {
  padding: 12px 14px;
  margin: 0;
  border-top: 1px solid var(--line, #30363d);
  background: var(--surface-1, transparent);
}
.detail-heading {
  align-items: center;
  gap: 12px;
}
.detail-switcher {
  display: inline-flex;
  align-items: center;
}
.table-legend {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 12px 16px;
  margin-top: 12px;
  background: var(--surface-2, rgba(255,255,255,0.03));
  border: 1px solid var(--line, rgba(255,255,255,0.08));
  border-radius: 10px;
  font-size: 12.5px;
  color: var(--muted, #8b949e);
}
.legend-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text, #c9d1d9);
  font-weight: 600;
  font-size: 12px;
}
.legend-title .icon {
  width: 15px;
  height: 15px;
  color: var(--accent, #58a6ff);
}
.legend-items {
  display: flex;
  align-items: center;
  gap: 16px;
  list-style: none;
  margin: 0;
  padding: 0;
  flex-wrap: wrap;
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.legend-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--surface, rgba(0,0,0,0.2));
  border: 1px solid var(--line, rgba(255,255,255,0.1));
  color: var(--accent, #58a6ff);
}
.legend-icon .icon {
  width: 14px;
  height: 14px;
}
.legend-text {
  font-size: 12px;
  color: var(--text, #c9d1d9);
}
.top-actions .lang-select {
  font-size: 12px;
  padding: 6px 8px;
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  border: var(--hairline);
  min-height: 32px;
  cursor: pointer;
}

/* Compact topbar API button */
.api-palette-btn.compact {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  min-height: 32px;
}
.api-palette-btn.compact .palette-btn-text {
  font-weight: 600;
  font-size: 12px;
}

/* Sidebar bottom navigation footer */
.side-footer-links {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line, rgba(255, 255, 255, 0.08));
}
.side-footer-btn,
.side-footer-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--muted, #95abae);
  background: transparent;
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  width: 100%;
  box-sizing: border-box;
  font-family: inherit;
  font-size: var(--font-body, 13px);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.side-footer-btn:hover,
.side-footer-link:hover {
  color: var(--text, #edf4f2);
  background: var(--surface-2, rgba(255, 255, 255, 0.05));
}
.side-footer-btn .nav-icon,
.side-footer-link .nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--accent, #21efad);
}
.side-footer-btn .nav-icon svg,
.side-footer-link .nav-icon svg {
  width: 18px;
  height: 18px;
}
.side-footer-btn .kbd {
  margin-left: auto;
  font-size: 11px;
}
.side-footer-link .nav-ext {
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
  opacity: 0.7;
}
.side-footer-btn .nav-text,
.side-footer-link .nav-text {
  flex: 1;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-shell.menu-collapsed > .left-dock > .sidebar .side-footer-btn .nav-text,
.app-shell.menu-collapsed > .left-dock > .sidebar .side-footer-btn .kbd,
.app-shell.menu-collapsed > .left-dock > .sidebar .side-footer-link .nav-text,
.app-shell.menu-collapsed > .left-dock > .sidebar .side-footer-link .nav-ext {
  display: none !important;
}
.app-shell.menu-collapsed > .left-dock > .sidebar .side-footer-btn,
.app-shell.menu-collapsed > .left-dock > .sidebar .side-footer-link {
  justify-content: center;
  padding: 8px 0;
}



