/* AIchill Hub — Codex / Linear Carbon Polish Layer (non-destructive) */

:root,
html[data-dmh-theme="light"] {
  --dmh-font-sans: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Helvetica Neue", system-ui, sans-serif;
  --dmh-font-mono: "SF Mono", "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  --dmh-canvas: #F8F9FA;
  --dmh-surface: #FFFFFF;
  --dmh-surface-subtle: #F2F4F7;
  --dmh-border: rgba(15, 23, 42, 0.08);
  --dmh-border-strong: rgba(15, 23, 42, 0.14);
  --dmh-shadow-card: 0 1px 2px rgba(15, 23, 42, 0.03), 0 0 0 1px rgba(15, 23, 42, 0.03);
  --dmh-shadow-panel: 0 4px 16px rgba(15, 23, 42, 0.05), 0 1px 2px rgba(15, 23, 42, 0.04);
  --dmh-text-primary: #0F172A;
  --dmh-text-secondary: #525B6B;
  --dmh-text-muted: #7B8494;

  --dmh-cta-bg: #111318;
  --dmh-cta-bg-hover: #1E222B;
  --dmh-cta-fg: #FFFFFF;
  --dmh-cta-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), 0 1px 2px rgba(15, 23, 42, 0.12);

  --dmh-code-bg: #0F1115;
  --dmh-code-border: rgba(255, 255, 255, 0.09);
  --dmh-code-fg: #E6EDF3;
  --dmh-code-muted: #8B949E;

  --dmh-pill-bg: rgba(15, 23, 42, 0.05);
  --dmh-pill-border: rgba(15, 23, 42, 0.09);
  --dmh-pill-fg: #334155;
  --dmh-accent-emerald: #10B981;
  --dmh-scroll-thumb: rgba(15, 23, 42, 0.18);
  --dmh-scroll-thumb-hover: rgba(15, 23, 42, 0.34);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-dmh-theme="light"]) {
    --dmh-canvas: #0B0C0E;
    --dmh-surface: #131519;
    --dmh-surface-subtle: #181B21;
    --dmh-border: rgba(255, 255, 255, 0.08);
    --dmh-border-strong: rgba(255, 255, 255, 0.14);
    --dmh-shadow-card: 0 1px 2px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.04);
    --dmh-shadow-panel: 0 8px 24px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    --dmh-text-primary: #F3F4F6;
    --dmh-text-secondary: #9CA3AF;
    --dmh-text-muted: #6B7280;

    --dmh-cta-bg: #F3F4F6;
    --dmh-cta-bg-hover: #FFFFFF;
    --dmh-cta-fg: #0B0C0E;
    --dmh-cta-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), 0 1px 2px rgba(0, 0, 0, 0.35);

    --dmh-code-bg: #08090C;
    --dmh-code-border: rgba(255, 255, 255, 0.09);
    --dmh-code-fg: #E6EDF3;
    --dmh-code-muted: #8B949E;

    --dmh-pill-bg: rgba(255, 255, 255, 0.06);
    --dmh-pill-border: rgba(255, 255, 255, 0.11);
    --dmh-pill-fg: #D1D5DB;
    --dmh-scroll-thumb: rgba(255, 255, 255, 0.16);
    --dmh-scroll-thumb-hover: rgba(255, 255, 255, 0.30);
  }
}

html[data-dmh-theme="dark"] {
  --dmh-canvas: #0B0C0E;
  --dmh-surface: #131519;
  --dmh-surface-subtle: #181B21;
  --dmh-border: rgba(255, 255, 255, 0.08);
  --dmh-border-strong: rgba(255, 255, 255, 0.14);
  --dmh-shadow-card: 0 1px 2px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  --dmh-shadow-panel: 0 8px 24px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  --dmh-text-primary: #F3F4F6;
  --dmh-text-secondary: #9CA3AF;
  --dmh-text-muted: #6B7280;

  --dmh-cta-bg: #F3F4F6;
  --dmh-cta-bg-hover: #FFFFFF;
  --dmh-cta-fg: #0B0C0E;
  --dmh-cta-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), 0 1px 2px rgba(0, 0, 0, 0.35);

  --dmh-code-bg: #08090C;
  --dmh-code-border: rgba(255, 255, 255, 0.09);
  --dmh-code-fg: #E6EDF3;
  --dmh-code-muted: #8B949E;

  --dmh-pill-bg: rgba(255, 255, 255, 0.06);
  --dmh-pill-border: rgba(255, 255, 255, 0.11);
  --dmh-pill-fg: #D1D5DB;
  --dmh-scroll-thumb: rgba(255, 255, 255, 0.16);
  --dmh-scroll-thumb-hover: rgba(255, 255, 255, 0.30);
}

/* Global Typography, Box-Sizing & Zero Horizontal Overflow */
html,
body {
  font-family: var(--dmh-font-sans);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  max-width: 100vw;
  overflow-x: hidden;
  box-sizing: border-box;
}

#root {
  max-width: 100vw;
  overflow-x: hidden;
  box-sizing: border-box;
}

html[data-dmh-theme="light"] {
  background-color: var(--dmh-canvas) !important;
}
html[data-dmh-theme="dark"] {
  background-color: var(--dmh-canvas) !important;
}

code,
pre,
kbd,
samp,
[data-dmh-code="1"] {
  font-family: var(--dmh-font-mono) !important;
  font-variant-numeric: tabular-nums;
}

/* Crisp Minimal Scrollbars */
::-webkit-scrollbar {
  width: 7px !important;
  height: 7px !important;
}
::-webkit-scrollbar-track {
  background: transparent !important;
}
::-webkit-scrollbar-thumb {
  background: var(--dmh-scroll-thumb) !important;
  border-radius: 999px !important;
  border: 1px solid transparent !important;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--dmh-scroll-thumb-hover) !important;
}

/* De-clutter upstream sponsor / donation nags cleanly (non-destructive) */
[data-testid="settings-plan-supporter"],
[data-testid="session-supporter-ask"],
[data-testid="plan-supporter-block"],
[data-dmh-hidden="1"] {
  display: none !important;
}

/* Welcome Screen Split Shell: prevent any right-edge clipping at 1280/1440 */
[data-testid="unauth-shell-brand-pane"],
[data-testid="unauth-shell-workflow-pane"],
[data-testid="unauth-shell-workflow-scroll"] {
  box-sizing: border-box !important;
  min-width: 0 !important;
  max-width: 100% !important;
}

[data-testid="unauth-shell-workflow-pane"] {
  border-left: 1px solid var(--dmh-border) !important;
  background-color: var(--dmh-canvas) !important;
  overflow-x: hidden !important;
}

[data-testid="welcome-decision-panel"] {
  background-color: var(--dmh-surface) !important;
  border: 1px solid var(--dmh-border) !important;
  box-shadow: var(--dmh-shadow-panel) !important;
  border-radius: 16px !important;
  padding: 28px 24px !important;
  box-sizing: border-box !important;
  width: 100% !important;
  max-width: 100% !important;
  overflow: hidden !important;
}

[data-testid="welcome-footer-relay-host"] {
  font-family: var(--dmh-font-mono) !important;
  font-variant-numeric: tabular-nums;
}

/* Welcome Screen Brand Wordmark Replacement (clean geometric mark + AIchill Hub) */
[data-testid="brand-wordmark"] {
  width: auto !important;
  height: auto !important;
  overflow: visible !important;
  display: inline-flex !important;
  flex-direction: row !important;
  align-items: center !important;
}

[data-testid="brand-wordmark"] img {
  display: none !important;
}

.dmh-welcome-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  user-select: none;
}

.dmh-welcome-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--dmh-cta-bg);
  color: var(--dmh-cta-fg);
  box-shadow: var(--dmh-cta-shadow);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.dmh-welcome-wordmark {
  font-family: var(--dmh-font-sans);
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.025em;
  color: var(--dmh-text-primary);
  line-height: 1;
}

/* Sidebar Brand Chrome & Dual-Mac E2EE Pill */
[data-testid="desktop-sidebar-title-text"] {
  font-family: var(--dmh-font-sans) !important;
  font-weight: 600 !important;
  letter-spacing: -0.02em !important;
}

.dmh-brand-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--dmh-pill-bg);
  border: 1px solid var(--dmh-pill-border);
  color: var(--dmh-pill-fg);
  font-family: var(--dmh-font-mono);
  font-size: 10.5px;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0.01em;
  vertical-align: middle;
  white-space: nowrap;
  flex-shrink: 0;
  user-select: none;
}

.dmh-e2ee-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--dmh-accent-emerald);
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.18);
  flex-shrink: 0;
}

/* Refined Surfaces, Hairlines & Density */
[data-testid="navigation-sidebar"],
[data-testid="page-layout-sidebar-left"] {
  border-right: 1px solid var(--dmh-border) !important;
}

[data-testid="desktop-route-header-content"] {
  border-bottom: 1px solid var(--dmh-border) !important;
}

[data-dmh-card="1"] {
  background-color: var(--dmh-surface) !important;
  border: 1px solid var(--dmh-border) !important;
  box-shadow: var(--dmh-shadow-card) !important;
  border-radius: 10px !important;
  box-sizing: border-box !important;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

[data-dmh-card="1"]:hover {
  border-color: var(--dmh-border-strong) !important;
}

/* Refined Inline/Block Code Pills */
pre:not(.dmh-cmd-pre) {
  background-color: var(--dmh-code-bg) !important;
  color: var(--dmh-code-fg) !important;
  border: 1px solid var(--dmh-code-border) !important;
  border-radius: 8px !important;
  padding: 10px 12px !important;
}

/* Jailed Dual-Mac Setup Card (replaces unsafe bare curl/CLI empty state) */
.dmh-setup-card {
  margin: 12px 10px 16px;
  padding: 14px 14px 13px;
  background: var(--dmh-surface);
  border: 1px solid var(--dmh-border);
  border-radius: 12px;
  box-shadow: var(--dmh-shadow-card);
  color: var(--dmh-text-primary);
  font-family: var(--dmh-font-sans);
  box-sizing: border-box;
  max-width: calc(100% - 20px);
}

.dmh-setup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.dmh-setup-title {
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--dmh-text-primary);
  margin: 0;
}

.dmh-setup-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.24);
  color: #059669;
  font-family: var(--dmh-font-mono);
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}

html[data-dmh-theme="dark"] .dmh-setup-badge {
  color: #34D399;
  background: rgba(16, 185, 129, 0.14);
  border-color: rgba(52, 211, 153, 0.28);
}

.dmh-setup-desc {
  font-size: 12px;
  line-height: 1.5;
  color: var(--dmh-text-secondary);
  margin: 0 0 11px;
}

.dmh-step {
  margin-bottom: 9px;
}

.dmh-step:last-of-type {
  margin-bottom: 0;
}

.dmh-step-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 500;
  color: var(--dmh-text-secondary);
  margin-bottom: 4px;
}

.dmh-cmd-box {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  background: var(--dmh-code-bg);
  border: 1px solid var(--dmh-code-border);
  border-radius: 8px;
}

.dmh-cmd-pre {
  margin: 0;
  padding: 0;
  font-family: var(--dmh-font-mono);
  font-size: 11px;
  line-height: 1.45;
  color: var(--dmh-code-fg);
  white-space: pre-wrap;
  word-break: break-all;
  flex: 1;
  user-select: all;
}

.dmh-copy-btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #E6EDF3;
  border-radius: 6px;
  padding: 3px 8px;
  font-family: var(--dmh-font-sans);
  font-size: 10.5px;
  font-weight: 500;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 120ms ease, border-color 120ms ease;
}

.dmh-copy-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.24);
}

.dmh-copy-btn[data-copied="1"] {
  background: rgba(16, 185, 129, 0.22);
  border-color: rgba(52, 211, 153, 0.45);
  color: #6EE7B7;
}

.dmh-setup-foot {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--dmh-border);
  font-size: 11px;
  line-height: 1.45;
  color: var(--dmh-text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* v20261203d: Sidebar non-truncation, single-line cmd scroll, Settings hero header */
[data-testid="desktop-sidebar-title-text"] {
  flex-shrink: 0 !important;
  white-space: nowrap !important;
  overflow: visible !important;
  text-overflow: clip !important;
  font-size: 14px !important;
}

.dmh-sidebar-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 5px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--dmh-pill-bg);
  border: 1px solid var(--dmh-pill-border);
  color: var(--dmh-pill-fg);
  font-family: var(--dmh-font-mono);
  font-size: 9.5px;
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
  flex-shrink: 0;
  user-select: none;
}

.dmh-cmd-box {
  align-items: center !important;
}

.dmh-cmd-pre {
  white-space: pre !important;
  word-break: normal !important;
  overflow-x: auto !important;
  scrollbar-width: none;
  padding-bottom: 1px !important;
}
.dmh-cmd-pre::-webkit-scrollbar {
  display: none !important;
}

.dmh-settings-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 10px 18px;
  box-sizing: border-box;
  user-select: none;
}

.dmh-settings-hero-left {
  display: flex;
  align-items: center;
  gap: 11px;
}

.dmh-settings-hero-title {
  font-family: var(--dmh-font-sans);
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.02em;
  color: var(--dmh-text-primary);
  line-height: 1.25;
}

.dmh-settings-hero-sub {
  font-family: var(--dmh-font-mono);
  font-size: 11px;
  color: var(--dmh-text-secondary);
  margin-top: 2px;
}
