/* Perception-Perfect NovaChat for macOS PWA (v16)
 * Direct 1:1 port of github.com/kristoffersodersten/novachat @ 590c56b:
 * - NovaChat/UI/Shared/NovaChatDesignSystem.swift (exact Light & Dark tokens, shadows, atmosphere)
 * - NovaChat/UI/macOS/Chat/ChatView_macOS.swift (r40 center slab, 40px vertical wing inset, 38px peek, 12px underlap)
 * - NovaChat/UI/Shared/Sidebar/SidebarView.swift (r32 outer left, ncSidebarSurface, LiveSearchField, folder/thread rows)
 * - NovaChat/UI/macOS/EditSpaceView.swift (r32 outer right, Working Text + Signal cards, Archive Knowledge button)
 * - NovaChat/UI/macOS/Chat/Components/InputFields_macOS.swift (r18 state-driven interactive surface, 5 SF-style glyphs)
 * - NovaChat/UI/Shared/Chat/Components/EmptyConversaitonView.swift (monastic thin 46px ncBrand NovaChat wordmark)
 * - NovaChat/UI/Shared/Chat/Components/ChatMessages/ChatMessageView.swift (equator-aligned 32px avatars + soft bubbles)
 */

:root {
  /* Exact NovaChatDesignSystem.swift Light Tokens */
  --nc-background: #f4f4f5;
  --nc-gold: #d4af37;
  --nc-dark: #27272a;
  --nc-dark-fg: #fafafa;
  --nc-near-black: #18181b;
  --nc-muted: #71717b;
  --nc-zinc: #f1ede4;
  --nc-border: rgba(216, 206, 191, 0.46);
  --nc-border-strong: rgba(216, 206, 191, 0.72);
  --nc-glow-rgb: 212, 175, 55;
  --nc-bubble-border-user: rgba(232, 222, 206, 0.48);
  --nc-bubble-border-ai: rgba(226, 215, 200, 0.44);
  --nc-search-fill: rgba(0, 0, 0, 0.05);
  --nc-surface: #fffdf9;
  --nc-surface-elevated: rgba(254, 251, 246, 0.97);
  --nc-main-card: #fcfaf5;
  --nc-input-surface: #fffdf8;
  --nc-user-bubble: #fbf8f1;
  --nc-ai-bubble: #f8f5ef;
  --nc-sidebar-surface: #f2f0eb;
  --nc-brand: linear-gradient(90deg, #4285f4 0%, #9b72cb 44%, #d96570 100%);
  --nc-brand-diag: linear-gradient(135deg, #4285f4 0%, #9b72cb 44%, #d96570 100%);

  --nc-top-light: rgba(255, 255, 255, 0.085);
  --nc-gold-wash: rgba(212, 175, 55, 0.055);
  --nc-inner-edge: rgba(255, 255, 255, 0.14);
  --nc-input-top-shade: rgba(0, 0, 0, 0.05);
  --nc-input-top-sheen: rgba(255, 255, 255, 0.22);
  --nc-press-glow: rgba(155, 114, 203, 0.12);
  --nc-press-glow-active: rgba(155, 114, 203, 0.22);
  --nc-card-box-fill: rgba(255, 255, 255, 0.48);

  --state-verified: #2e7d52;
  --state-warning: #b57c1e;
  --state-inhibit: #be433d;

  /* Spatial Geometry Constants (ChatView_macOS.swift) */
  --nc-wing-width: clamp(244px, 17.5vw, 300px);
  --nc-wing-peek: 38px;
  --nc-wing-underlap: 12px;
  --nc-card-radius: 40px;
  --nc-wing-radius: 32px;
  --nc-wing-v-inset: 40px;
  --nc-spring: cubic-bezier(0.22, 1, 0.36, 1);

  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Inter", "Segoe UI", system-ui, sans-serif;
  --font-mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-polarity="light"]) {
    --nc-background: #18181b;
    --nc-dark: #fafafa;
    --nc-dark-fg: #18181b;
    --nc-near-black: #f4f4f5;
    --nc-muted: #a1a1aa;
    --nc-zinc: #27272a;
    --nc-border: rgba(63, 63, 70, 0.45);
    --nc-border-strong: rgba(82, 82, 91, 0.72);
    --nc-glow-rgb: 192, 192, 192;
    --nc-bubble-border-user: rgba(63, 63, 70, 0.80);
    --nc-bubble-border-ai: rgba(63, 63, 70, 0.80);
    --nc-search-fill: rgba(255, 255, 255, 0.07);
    --nc-surface: #18181b;
    --nc-surface-elevated: rgba(28, 28, 30, 0.94);
    --nc-main-card: #1e1e20;
    --nc-input-surface: #27272a;
    --nc-user-bubble: #222225;
    --nc-ai-bubble: #202023;
    --nc-sidebar-surface: #232326;
    --nc-top-light: rgba(255, 255, 255, 0.05);
    --nc-gold-wash: rgba(212, 175, 55, 0.02);
    --nc-inner-edge: rgba(255, 255, 255, 0.06);
    --nc-input-top-shade: rgba(0, 0, 0, 0.24);
    --nc-input-top-sheen: rgba(255, 255, 255, 0.13);
    --nc-card-box-fill: rgba(255, 255, 255, 0.045);
    --state-verified: #5bbd7e;
    --state-warning: #dfb04d;
    --state-inhibit: #e06c66;
  }
}

:root[data-polarity="dark"] {
  --nc-background: #18181b;
  --nc-dark: #fafafa;
  --nc-dark-fg: #18181b;
  --nc-near-black: #f4f4f5;
  --nc-muted: #a1a1aa;
  --nc-zinc: #27272a;
  --nc-border: rgba(63, 63, 70, 0.45);
  --nc-border-strong: rgba(82, 82, 91, 0.72);
  --nc-glow-rgb: 192, 192, 192;
  --nc-bubble-border-user: rgba(63, 63, 70, 0.80);
  --nc-bubble-border-ai: rgba(63, 63, 70, 0.80);
  --nc-search-fill: rgba(255, 255, 255, 0.07);
  --nc-surface: #18181b;
  --nc-surface-elevated: rgba(28, 28, 30, 0.94);
  --nc-main-card: #1e1e20;
  --nc-input-surface: #27272a;
  --nc-user-bubble: #222225;
  --nc-ai-bubble: #202023;
  --nc-sidebar-surface: #232326;
  --nc-top-light: rgba(255, 255, 255, 0.05);
  --nc-gold-wash: rgba(212, 175, 55, 0.02);
  --nc-inner-edge: rgba(255, 255, 255, 0.06);
  --nc-input-top-shade: rgba(0, 0, 0, 0.24);
  --nc-input-top-sheen: rgba(255, 255, 255, 0.13);
  --nc-card-box-fill: rgba(255, 255, 255, 0.045);
  --state-verified: #5bbd7e;
  --state-warning: #dfb04d;
  --state-inhibit: #e06c66;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--nc-background);
  color: var(--nc-near-black);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* NovaAtmosphereBackground (NovaChatDesignSystem.swift l.259-297) */
.nc-atmosphere {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse 65% 42% at 50% 0%, rgba(var(--nc-glow-rgb), 0.10) 0%, transparent 72%),
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.08) 0%, transparent 56%),
    var(--nc-background);
}

/* =========================================================================
 * SPATIAL 3-PANEL OVERLAPPING ARCHITECTURE (ChatView_macOS.swift)
 * Center main card floats at z-index 10 with r40; left & right solid wings
 * sit behind at z-index 2 with 40px vertical inset, peeking 38px when collapsed
 * and gliding smoothly open on hover or click-pin.
 * ========================================================================= */
.nc-spatial-stage {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100dvh;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 10px 12px;
  overflow: hidden;
}

/* Center Floating Slab (ChatView_macOS.swift l.251-274, 438-504) */
.nc-main-card {
  position: relative;
  z-index: 10;
  flex: 1 1 auto;
  max-width: calc(100% - (var(--nc-wing-width) * 2) + (var(--nc-wing-underlap) * 2));
  min-width: 0;
  height: 100%;
  border-radius: var(--nc-card-radius);
  background:
    linear-gradient(180deg, var(--nc-top-light) 0%, transparent 50%),
    linear-gradient(180deg, var(--nc-gold-wash) 0%, transparent 42%),
    radial-gradient(460px 460px at 50% 12%, rgba(var(--nc-glow-rgb), 0.032) 0%, rgba(244, 244, 245, 0.018) 58%, transparent 100%),
    var(--nc-main-card);
  border: 1px solid var(--nc-border);
  box-shadow:
    inset 0 0.5px 0 var(--nc-inner-edge),
    0 7px 18px rgba(0, 0, 0, 0.06),
    0 16px 32px rgba(0, 0, 0, 0.045),
    0 24px 46px rgba(0, 0, 0, 0.09),
    0 0 28px rgba(var(--nc-glow-rgb), 0.055);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 420ms var(--nc-spring);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-polarity="light"]) .nc-main-card {
    box-shadow:
      inset 0 0.5px 0 var(--nc-inner-edge),
      0 7px 18px rgba(0, 0, 0, 0.16),
      0 18px 36px rgba(0, 0, 0, 0.22),
      0 28px 52px rgba(0, 0, 0, 0.30),
      0 0 24px rgba(var(--nc-glow-rgb), 0.04);
  }
}
:root[data-polarity="dark"] .nc-main-card {
  box-shadow:
    inset 0 0.5px 0 var(--nc-inner-edge),
    0 7px 18px rgba(0, 0, 0, 0.16),
    0 18px 36px rgba(0, 0, 0, 0.22),
    0 28px 52px rgba(0, 0, 0, 0.30),
    0 0 24px rgba(var(--nc-glow-rgb), 0.04);
}

.nc-top-glow-band {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 120px;
  background: linear-gradient(180deg, rgba(var(--nc-glow-rgb), 0.05) 0%, transparent 100%);
  pointer-events: none;
  z-index: 0;
}

/* Solid Side Wings (SidebarView.swift & EditSpaceView.swift, z-index 2) */
.nc-wing {
  position: relative;
  z-index: 2;
  width: var(--nc-wing-width);
  flex: 0 0 var(--nc-wing-width);
  margin-top: var(--nc-wing-v-inset);
  margin-bottom: var(--nc-wing-v-inset);
  background: var(--nc-sidebar-surface);
  border: 1px solid var(--nc-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition:
    transform 380ms var(--nc-spring),
    opacity 320ms var(--nc-spring),
    box-shadow 320ms ease;
  will-change: transform, opacity;
}

.nc-wing-left {
  border-radius: var(--nc-wing-radius) 0 0 var(--nc-wing-radius);
  border-right: none;
  box-shadow: -8px 0 18px rgba(0, 0, 0, 0.06);
  /* Collapsed default: peek 38px behind left edge of center card */
  transform: translateX(calc(var(--nc-wing-width) - var(--nc-wing-peek)));
  opacity: 0.58;
}
.nc-wing-right {
  border-radius: 0 var(--nc-wing-radius) var(--nc-wing-radius) 0;
  border-left: none;
  box-shadow: 8px 0 18px rgba(0, 0, 0, 0.06);
  /* Collapsed default: peek 38px behind right edge of center card */
  transform: translateX(calc(-1 * (var(--nc-wing-width) - var(--nc-wing-peek))));
  opacity: 0.58;
}

/* Revealed state (hover or pinned) — glides open with exact 12px underlap under center card */
.nc-wing-left.revealed,
.nc-wing-left.pinned {
  transform: translateX(var(--nc-wing-underlap));
  opacity: 1;
}
.nc-wing-right.revealed,
.nc-wing-right.pinned {
  transform: translateX(calc(-1 * var(--nc-wing-underlap)));
  opacity: 1;
}

/* Subtle veil masking wing text when collapsed into 38px peek (ChatView_macOS.swift l.199-204) */
.nc-wing-veil {
  position: absolute;
  inset: 0;
  background: var(--nc-sidebar-surface);
  opacity: 0.82;
  pointer-events: none;
  z-index: 4;
  transition: opacity 240ms ease;
}
.nc-wing.revealed .nc-wing-veil,
.nc-wing.pinned .nc-wing-veil {
  opacity: 0;
}

/* Inner edge pin hot-zone (PanelPinHotZone) */
.nc-wing-pin-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 24px;
  z-index: 6;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nc-wing-pin-right { right: 0; }
.nc-wing-pin-left { left: 0; }
.nc-pin-indicator {
  width: 2px;
  height: 64px;
  border-radius: 999px;
  background: var(--nc-gold);
  opacity: 0;
  transition: opacity 200ms ease;
}
.nc-wing-pin-zone:hover .nc-pin-indicator {
  opacity: 0.45;
}

.nc-wing-inner {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 20px 22px;
  gap: 12px;
  min-height: 0;
}

.nc-wing-left .nc-wing-inner {
  padding-right: 28px;
}
.nc-wing-right .nc-wing-inner {
  padding-left: 28px;
}

/* Section Labels (NovaChatDesignSystem.swift SectionLabel: 12 semibold, kerning 1.2, uppercase) */
.nc-section-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.nc-section-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--nc-muted);
}
.nc-subsection-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.9px;
  text-transform: uppercase;
  color: var(--nc-muted);
  padding: 2px 10px 4px;
}
.nc-section-actions {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.nc-wing-icon-btn {
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--nc-muted);
  opacity: 0.35;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 140ms ease, background 140ms ease, color 140ms ease;
}
.nc-wing:hover .nc-wing-icon-btn,
.nc-wing-icon-btn[aria-pressed="true"] {
  opacity: 0.78;
}
.nc-wing-icon-btn:hover {
  opacity: 1;
  background: var(--nc-search-fill);
  color: var(--nc-near-black);
}
.nc-wing-icon-btn[aria-pressed="true"] {
  background: var(--nc-zinc);
  color: var(--nc-near-black);
}
.nc-ghost-btn {
  border: 1px solid transparent;
  background: transparent;
  color: var(--nc-muted);
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease;
}
.nc-ghost-btn:hover {
  background: var(--nc-search-fill);
  color: var(--nc-near-black);
}
.nc-ghost-btn[aria-pressed="true"] {
  background: var(--nc-zinc);
  border-color: var(--nc-border);
  color: var(--nc-near-black);
}

/* LiveSearchField (NovaChatDesignSystem.swift l.733-788: r12, 12x10, ncSearchFill, 14 regular) */
.nc-search-field {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 12px;
  background: var(--nc-search-fill);
  border: 0.8px solid rgba(216, 206, 191, 0.28);
  transition: border-color 160ms ease;
}
.nc-search-field:focus-within {
  border-color: rgba(212, 175, 55, 0.55);
}
.nc-search-icon {
  color: var(--nc-muted);
  flex-shrink: 0;
}
.nc-search-field input {
  border: none;
  background: transparent;
  color: var(--nc-near-black);
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 400;
  width: 100%;
  outline: none;
  caret-color: var(--nc-gold);
}
.nc-search-field input::placeholder {
  color: var(--nc-muted);
  opacity: 0.85;
}
.nc-search-clear {
  border: none;
  background: transparent;
  color: var(--nc-muted);
  padding: 0;
  display: inline-flex;
  cursor: pointer;
}

.nc-wing-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  scrollbar-width: none;
}
.nc-wing-scroll::-webkit-scrollbar { display: none; }

/* Project & Thread Rows (SidebarView.swift l.239-273, 405-454) */
.nc-project-list, .nc-thread-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.nc-project-row {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  height: 41px;
  padding: 0 12px;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: var(--nc-muted);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 140ms ease, color 140ms ease;
}
.nc-project-row:hover {
  background: rgba(0, 0, 0, 0.03);
  color: var(--nc-near-black);
}
.nc-project-row.active {
  background: var(--nc-zinc);
  color: var(--nc-near-black);
}
.nc-row-icon {
  flex-shrink: 0;
  opacity: 0.78;
}
.nc-project-row.active .nc-row-icon {
  opacity: 1;
}
.nc-row-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nc-row-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--nc-muted);
}

.nc-wing-divider {
  height: 0.75px;
  background: var(--nc-border);
  margin: 6px 6px 4px;
  flex-shrink: 0;
}

.nc-thread-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--nc-muted);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 140ms ease, color 140ms ease;
}
.nc-thread-row:hover {
  background: rgba(0, 0, 0, 0.03);
  color: var(--nc-near-black);
}
.nc-thread-row.active {
  background: var(--nc-zinc);
  color: var(--nc-near-black);
}
.nc-thread-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nc-wing-status {
  margin-top: auto;
  padding-top: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--nc-muted);
  opacity: 0.72;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* =========================================================================
 * EDIT SPACE CARDS (Exact EditSpaceView.swift l.250-481)
 * ========================================================================= */
.nc-edit-items-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.nc-edit-empty {
  padding: 12px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.025);
  border: 0.8px solid var(--nc-border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.nc-edit-empty-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--nc-muted);
}
.nc-edit-empty-sub {
  font-size: 11px;
  line-height: 1.45;
  color: var(--nc-muted);
  opacity: 0.82;
}

.nc-edit-card {
  padding: 10px 9px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.022);
  border: 0.7px solid var(--nc-border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 180ms ease;
}
.nc-edit-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.06);
}
.nc-edit-card.saved {
  opacity: 0.82;
}
.nc-edit-card.flash-highlight {
  border-color: rgba(212, 175, 55, 0.68);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.14);
}
.nc-edit-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.nc-edit-accent {
  width: 2px;
  height: 22px;
  border-radius: 999px;
  background: var(--nc-gold);
  opacity: 0.62;
  flex-shrink: 0;
}
.nc-edit-card.saved .nc-edit-accent {
  background: var(--nc-muted);
  opacity: 0.36;
}
.nc-edit-meta {
  flex: 1;
  min-width: 0;
}
.nc-edit-role {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--nc-muted);
}
.nc-edit-sub {
  font-size: 9.5px;
  color: var(--nc-muted);
  opacity: 0.78;
}
.nc-trash-btn {
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 8px;
  background: var(--nc-card-box-fill);
  color: var(--nc-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.nc-trash-btn:hover {
  color: var(--state-inhibit);
}
.nc-edit-field-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--nc-muted);
  margin-bottom: 4px;
}
.nc-edit-textarea {
  width: 100%;
  min-height: 68px;
  max-height: 128px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 0.7px solid var(--nc-border);
  background: var(--nc-card-box-fill);
  color: var(--nc-near-black);
  font-family: var(--font-sans);
  font-size: 12px;
  line-height: 1.45;
  resize: none;
  outline: none;
  caret-color: var(--nc-gold);
  scrollbar-width: thin;
  scrollbar-color: var(--nc-border-strong) transparent;
}
.nc-edit-textarea::-webkit-scrollbar,
.nc-edit-code::-webkit-scrollbar {
  width: 4px;
}
.nc-edit-textarea::-webkit-scrollbar-thumb,
.nc-edit-code::-webkit-scrollbar-thumb {
  background: var(--nc-border-strong);
  border-radius: 999px;
}
.nc-edit-textarea::-webkit-scrollbar-track,
.nc-edit-code::-webkit-scrollbar-track {
  background: transparent;
}
.nc-edit-textarea.signal {
  min-height: 46px;
  font-weight: 500;
}
.nc-edit-code {
  margin: 0;
  padding: 8px;
  border-radius: 8px;
  background: var(--nc-card-box-fill);
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 1.4;
  color: var(--nc-muted);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 160px;
  overflow-y: auto;
}

/* Bottom Archive Knowledge Button (EditSpaceView.swift l.141-165) */
.nc-archive-btn {
  margin-top: auto;
  width: 100%;
  padding: 8px 12px;
  border-radius: 10px;
  border: 0.8px solid var(--nc-border);
  background: var(--nc-search-fill);
  color: var(--nc-muted);
  font-family: var(--font-sans);
  font-size: 11.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease, opacity 150ms ease;
}
.nc-archive-btn:hover:not(:disabled) {
  background: var(--nc-surface-elevated);
  border-color: rgba(212, 175, 55, 0.55);
  color: var(--nc-near-black);
}
.nc-archive-btn:disabled {
  opacity: 0.54;
  cursor: default;
}

/* =========================================================================
 * MAIN CARD HEADER & SETTINGS POPOVER
 * ========================================================================= */
.nc-card-header {
  position: relative;
  z-index: 4;
  height: 48px;
  padding: 12px 24px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.nc-header-left, .nc-header-right {
  display: flex;
  align-items: center;
  gap: 6px;
}
.nc-thread-crumb {
  font-size: 12px;
  font-weight: 500;
  color: var(--nc-muted);
  letter-spacing: 0.01em;
}
.nc-mobile-nav-btn {
  display: none;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--nc-muted);
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.nc-quiet-icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--nc-near-black);
  opacity: 0.28;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 160ms ease, background 160ms ease;
}
.nc-quiet-icon-btn:hover,
.nc-quiet-icon-btn[aria-expanded="true"],
.nc-quiet-icon-btn[aria-pressed="true"] {
  opacity: 0.88;
  background: var(--nc-search-fill);
}
.nc-quiet-pill {
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--nc-border);
  background: var(--nc-surface-elevated);
  color: var(--nc-muted);
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.nc-quiet-pill[aria-pressed="true"],
.nc-quiet-pill:hover {
  border-color: rgba(212, 175, 55, 0.6);
  color: var(--nc-near-black);
}

/* Settings Popover */
.nc-popover {
  position: absolute;
  top: 52px;
  right: 22px;
  width: 300px;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--nc-surface-elevated);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border: 1px solid var(--nc-border);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.14);
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 11px;
}
.nc-popover-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nc-popover-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.9px;
  text-transform: uppercase;
  color: var(--nc-muted);
}
.nc-popover-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12.5px;
  color: var(--nc-near-black);
}
.nc-popover-row select {
  background: var(--nc-search-fill);
  color: var(--nc-near-black);
  border: 1px solid var(--nc-border);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 12px;
  font-family: var(--font-sans);
}
.nc-seg-group {
  display: inline-flex;
  background: var(--nc-search-fill);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
}
.nc-seg-btn {
  border: none;
  background: transparent;
  color: var(--nc-muted);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  cursor: pointer;
}
.nc-seg-btn.active {
  background: var(--nc-input-surface);
  color: var(--nc-near-black);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}
.nc-switch { position: relative; display: inline-block; width: 36px; height: 20px; }
.nc-switch input { opacity: 0; width: 0; height: 0; }
.nc-slider { position: absolute; cursor: pointer; inset: 0; background: var(--nc-border-strong); border-radius: 999px; transition: 150ms; }
.nc-slider::before { position: absolute; content: ""; height: 14px; width: 14px; left: 3px; bottom: 3px; background: var(--nc-input-surface); border-radius: 50%; transition: 150ms; }
.nc-switch input:checked + .nc-slider { background: var(--nc-gold); }
.nc-switch-danger input:checked + .nc-slider { background: var(--state-inhibit); }
.nc-switch input:checked + .nc-slider::before { transform: translateX(16px); }
.nc-popover-divider { height: 1px; background: var(--nc-border); }
.nc-popover-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.nc-popover-action-btn {
  border: 1px solid var(--nc-border);
  background: var(--nc-search-fill);
  color: var(--nc-near-black);
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 500;
  padding: 6px 8px;
  border-radius: 9px;
  cursor: pointer;
}
.nc-popover-action-btn:hover {
  border-color: rgba(212, 175, 55, 0.55);
  background: var(--nc-input-surface);
}

/* =========================================================================
 * MAIN VIEWPORT & MONASTIC EMPTY WORDMARK (EmptyConversaitonView.swift)
 * ========================================================================= */
.nc-viewport {
  position: relative;
  z-index: 2;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 12px clamp(24px, 4.5%, 64px) 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Living Sanctuary Aura & Sovereign Shield Pulse (v17) */
@keyframes ncAuraBreath {
  0%, 100% { opacity: 0.72; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.03); }
}
@keyframes ncShieldPulse {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50% { transform: scale(1.35); opacity: 0.35; }
}
@keyframes ncVaultShimmer {
  0% { box-shadow: inset 0 1px 0 var(--nc-input-top-sheen), 0 0 0 0 rgba(46, 125, 82, 0.28); }
  100% { box-shadow: inset 0 1px 0 var(--nc-input-top-sheen), 0 10px 28px rgba(0, 0, 0, 0.06), 0 0 28px rgba(46, 125, 82, 0.08); }
}

.nc-shield-btn {
  position: relative;
}
.nc-shield-pulse {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--state-verified);
  box-shadow: 0 0 6px var(--state-verified);
  animation: ncShieldPulse 3.6s ease-in-out infinite;
}
.nc-integrity-popover {
  right: 58px;
  width: 288px;
}
.nc-live-pill {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  color: var(--state-verified);
  background: color-mix(in srgb, var(--state-verified) 14%, transparent);
}
.nc-trust-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.nc-trust-tile {
  padding: 9px 10px;
  border-radius: 11px;
  background: var(--nc-search-fill);
  border: 0.8px solid var(--nc-border);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.nc-trust-k {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--nc-muted);
}
.nc-trust-v {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--nc-near-black);
}
.nc-enclave-footnote {
  padding-top: 8px;
  border-top: 0.7px solid var(--nc-border);
  font-size: 10.5px;
  font-weight: 500;
  color: var(--nc-muted);
  text-align: center;
  letter-spacing: 0.01em;
}
.nc-quick-row {
  position: relative;
  z-index: 1;
  margin-top: 22px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  max-width: 560px;
}
.nc-quick-pill {
  padding: 6px 12px;
  border-radius: 999px;
  border: 0.8px solid var(--nc-border);
  background: color-mix(in srgb, var(--nc-input-surface) 74%, transparent);
  color: var(--nc-muted);
  font-family: var(--font-sans);
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease, transform 140ms ease;
}
.nc-quick-pill:hover {
  background: var(--nc-input-surface);
  border-color: rgba(212, 175, 55, 0.5);
  color: var(--nc-near-black);
  transform: translateY(-1px);
}

.nc-empty-surface {
  position: relative;
  margin: auto 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 0;
  user-select: none;
}
.nc-empty-surface::before {
  content: "";
  position: absolute;
  width: 260px;
  height: 110px;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(155, 114, 203, 0.075) 0%, rgba(212, 175, 55, 0.045) 45%, transparent 74%);
  pointer-events: none;
  animation: ncAuraBreath 8s ease-in-out infinite;
}

.nc-composer.pii-sealed {
  border-color: color-mix(in srgb, var(--state-verified) 38%, var(--nc-border));
  animation: ncVaultShimmer 700ms ease-out forwards;
}

/* Exact EmptyConversaitonView.swift: 46pt .thin, horizontal ncBrand gradient */
.nc-wordmark {
  position: relative;
  z-index: 1;
  margin: 0;
  font-size: 46px;
  font-weight: 200;
  letter-spacing: -0.02em;
  line-height: 1.1;
  background: var(--nc-brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* =========================================================================
 * AUTHENTIC NOVACHAT FLOATING COMPOSER (InputFields_macOS.swift)
 * State-driven surface: idle (55% fill, 0.03 shadow) -> hover (78%, -2px)
 * -> focus (95%, gold rim, soft glow) -> typing (100%, stronger gold rim).
 * ========================================================================= */
.nc-composer-wrap {
  position: relative;
  z-index: 3;
  padding: 4px clamp(24px, 4.5%, 64px) clamp(20px, 3vh, 34px);
  flex-shrink: 0;
}

.nc-composer {
  position: relative;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.12) 0%, transparent 40%),
    linear-gradient(180deg, var(--nc-input-top-shade) 0%, transparent 28%),
    color-mix(in srgb, var(--nc-input-surface) 78%, transparent);
  backdrop-filter: blur(20px) saturate(120%);
  -webkit-backdrop-filter: blur(20px) saturate(120%);
  border: 1px solid var(--nc-border);
  box-shadow:
    inset 0 1px 0 var(--nc-input-top-sheen),
    0 8px 24px rgba(0, 0, 0, 0.045);
  display: flex;
  flex-direction: column;
  transition:
    transform 150ms ease-out,
    background 160ms ease-out,
    border-color 160ms ease-out,
    box-shadow 160ms ease-out;
}
.nc-composer:hover {
  transform: translateY(-2px) scale(1.003);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.14) 0%, transparent 40%),
    linear-gradient(180deg, var(--nc-input-top-shade) 0%, transparent 28%),
    color-mix(in srgb, var(--nc-input-surface) 90%, transparent);
  box-shadow:
    inset 0 1px 0 var(--nc-input-top-sheen),
    0 10px 26px rgba(0, 0, 0, 0.07),
    0 0 36px rgba(212, 175, 55, 0.025);
}
.nc-composer:focus-within {
  transform: translateY(-2px) scale(1.005);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.14) 0%, transparent 40%),
    linear-gradient(180deg, var(--nc-input-top-shade) 0%, transparent 28%),
    var(--nc-input-surface);
  border-color: rgba(212, 175, 55, 0.36);
  box-shadow:
    inset 0 1px 0 var(--nc-input-top-sheen),
    0 10px 28px rgba(0, 0, 0, 0.08),
    0 0 54px rgba(212, 175, 55, 0.05);
}
.nc-composer.sla-glow::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 18px;
  background: radial-gradient(240px 120px at 50% 90%, rgba(var(--nc-glow-rgb), 0.065), transparent 72%);
  pointer-events: none;
}

/* Normal-flow Top Meta Strip (zero overlap with textarea, IntentMembrane, or mobile OCR chips) */
.nc-composer-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 20px 0;
  position: relative;
  z-index: 3;
}
.nc-composer-meta-row + .nc-intent-membrane {
  margin-top: 8px;
}
.nc-composer-meta-row:not(.hidden) ~ textarea {
  padding-top: 12px;
}

/* RuntimeTruthMembraneChip (InputFields_macOS.swift l.801-850) */
.nc-membrane-chip {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(var(--nc-glow-rgb), 0.24);
  background: color-mix(in srgb, var(--nc-surface-elevated) 78%, transparent);
  color: var(--nc-near-black);
  font-family: var(--font-sans);
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 140ms ease, background 140ms ease;
}
.nc-membrane-chip:hover {
  border-color: rgba(212, 175, 55, 0.55);
  background: var(--nc-surface-elevated);
}
.nc-membrane-dot {
  width: 5.5px;
  height: 5.5px;
  border-radius: 50%;
  background: var(--state-verified);
  box-shadow: 0 0 6px var(--state-verified);
}
.nc-membrane-dot.inhibit {
  background: var(--state-inhibit);
  box-shadow: 0 0 6px var(--state-inhibit);
}

/* Collapsible Scrub 1 & 5-Slot Content Matrix Inspection Drawer (IntentClosureMembrane style) */
.nc-intent-membrane {
  margin: 14px 20px 0;
  padding: 12px 14px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--nc-input-surface) 78%, var(--nc-search-fill));
  border: 1px solid rgba(212, 175, 55, 0.28);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.nc-intent-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.nc-intent-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--nc-muted);
}
.nc-matrix-score {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--nc-near-black);
}
.nc-matrix-slots {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.nc-matrix-slot {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  padding: 2.5px 8px;
  border-radius: 999px;
  border: 1px solid var(--nc-border);
  background: var(--nc-search-fill);
  color: var(--nc-muted);
}
.nc-matrix-slot.fulfilled {
  border-color: color-mix(in srgb, var(--state-verified) 45%, transparent);
  background: color-mix(in srgb, var(--state-verified) 12%, transparent);
  color: var(--state-verified);
}
.nc-scrub-preview {
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.45;
  color: var(--nc-near-black);
  word-break: break-word;
}
.nc-intent-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.nc-chitchat-note {
  font-size: 11.5px;
  color: var(--nc-muted);
  line-height: 1.4;
}

.nc-ocr-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
  flex: 1 1 auto;
}
.nc-ocr-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--nc-zinc);
  border: 1px solid rgba(212, 175, 55, 0.4);
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--nc-near-black);
}
.nc-ocr-chip-rm {
  border: none;
  background: transparent;
  color: var(--nc-muted);
  cursor: pointer;
  font-weight: 700;
  padding: 0 2px;
}

/* Composer Textarea (InputFields_macOS.swift l.396-426: min-height 96px, 15px regular, 28px horizontal, 24px top) */
.nc-composer textarea {
  width: 100%;
  min-height: 92px;
  max-height: 180px;
  padding: 22px 26px 4px;
  border: none;
  background: transparent;
  color: var(--nc-near-black);
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 400;
  line-height: 1.5;
  resize: none;
  outline: none;
  caret-color: var(--nc-gold);
}
.nc-composer textarea::placeholder {
  color: var(--nc-muted);
  opacity: 0.6;
}

/* Exact 5-Icon Bottom Toolbar (InputFields_macOS.swift l.429-512) */
.nc-composer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 16px 12px;
  position: relative;
  z-index: 2;
}
.nc-bar-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Exact GlowIconButton (38x38 circle, subtle hover fill + brand press glow) */
.nc-icon-btn {
  position: relative;
  width: 38px;
  height: 38px;
  border: 0.8px solid transparent;
  border-radius: 50%;
  background: transparent;
  color: var(--nc-near-black);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition:
    background 140ms ease,
    transform 120ms ease,
    box-shadow 140ms ease,
    border-color 140ms ease,
    opacity 140ms ease;
}
.nc-icon-btn:hover {
  background: color-mix(in srgb, var(--nc-zinc) 55%, transparent);
  box-shadow: 0 0 8px var(--nc-press-glow);
}
.nc-icon-btn:active {
  transform: scale(0.96);
  box-shadow: 0 0 10px var(--nc-press-glow-active);
}
.nc-icon-btn.active {
  background: color-mix(in srgb, var(--nc-zinc) 76%, transparent);
}
.nc-icon-btn.listening {
  background: color-mix(in srgb, var(--state-inhibit) 16%, transparent);
  color: var(--state-inhibit);
  box-shadow: 0 0 12px rgba(190, 67, 61, 0.25);
}
.nc-icon-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.nc-icon-badge {
  position: absolute;
  bottom: 2px;
  right: 1px;
  font-family: var(--font-mono);
  font-size: 8.5px;
  font-weight: 700;
  line-height: 1;
  padding: 1.5px 3px;
  border-radius: 4px;
  background: var(--nc-input-surface);
  border: 0.7px solid var(--nc-border-strong);
  color: var(--nc-near-black);
}

/* =========================================================================
 * CHAT MESSAGE THREAD (ChatMessageView.swift: equator avatars + soft bubbles)
 * ========================================================================= */
.nc-message-thread {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 6px 0 12px;
}
.nc-msg-row {
  display: flex;
  align-items: center; /* BubbleEquator alignment */
  gap: 12px;
}
.nc-msg-row.user {
  flex-direction: row-reverse;
}
.nc-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.3px;
  box-shadow: 0 1.5px 4px rgba(0, 0, 0, 0.12);
}
.nc-avatar.ai {
  background: #27272a;
  color: #f4f4f5;
  border: 0.9px solid rgba(216, 206, 191, 0.52);
  font-family: var(--font-sans);
  font-weight: 600;
  letter-spacing: 0.04em;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-polarity="light"]) .nc-avatar.ai {
    background: #3f3f46;
    color: #fafafa;
    border-color: rgba(161, 161, 170, 0.36);
  }
}
:root[data-polarity="dark"] .nc-avatar.ai {
  background: #3f3f46;
  color: #fafafa;
  border-color: rgba(161, 161, 170, 0.36);
}
.nc-avatar.user {
  background: var(--nc-zinc);
  color: var(--nc-near-black);
  border: 0.8px solid var(--nc-border);
}
.nc-msg-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 82%;
  min-width: 0;
}
.nc-msg-row.user .nc-msg-body {
  align-items: flex-end;
}
.nc-msg-bubble {
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14.5px;
  line-height: 1.58;
  white-space: pre-wrap;
  word-break: break-word;
  transition: transform 140ms ease;
}
.nc-msg-row.user .nc-msg-bubble {
  background: var(--nc-user-bubble);
  border: 1px solid var(--nc-bubble-border-user);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.045), 0 6px 12px rgba(0, 0, 0, 0.025);
}
.nc-msg-row.assistant .nc-msg-bubble {
  background: var(--nc-ai-bubble);
  border: 1px solid var(--nc-bubble-border-ai);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.045), 0 6px 12px rgba(0, 0, 0, 0.025);
}
.nc-msg-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-family: var(--font-sans);
  font-size: 11px;
  color: var(--nc-muted);
  opacity: 0.65;
  transition: opacity 150ms ease;
}
.nc-msg-row:hover .nc-msg-meta {
  opacity: 1;
}
.nc-msg-action {
  border: 1px solid var(--nc-border);
  background: transparent;
  color: var(--nc-muted);
  font-family: var(--font-sans);
  font-size: 10.5px;
  font-weight: 500;
  padding: 2.5px 9px;
  border-radius: 999px;
  cursor: pointer;
}
.nc-msg-action:hover {
  border-color: rgba(212, 175, 55, 0.55);
  color: var(--nc-near-black);
  background: var(--nc-surface-elevated);
}
.rehydrated-span {
  background: color-mix(in srgb, var(--state-verified) 14%, transparent);
  border-bottom: 1.5px solid var(--state-verified);
  padding: 0 3px;
  border-radius: 3px;
}
.pii-token {
  display: inline-block;
  padding: 0 5px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--nc-gold) 18%, transparent);
  border: 1px solid color-mix(in srgb, var(--nc-gold) 45%, transparent);
  font-family: var(--font-mono);
  font-size: 11px;
}

/* Referee Single-Parameter Gate (70% SLA) & Source Referral Block (90% SLA) */
.nc-referee-gate,
.nc-source-referrals {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 0.8px solid var(--nc-border);
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.nc-referee-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--nc-muted);
}
.nc-referee-opts {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.nc-referee-opt-btn {
  padding: 6px 12px;
  border-radius: 10px;
  border: 1px solid rgba(212, 175, 55, 0.55);
  background: var(--nc-input-surface);
  color: var(--nc-near-black);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, transform 120ms ease;
}
.nc-referee-opt-btn:hover {
  background: var(--nc-zinc);
  border-color: var(--nc-gold);
  transform: translateY(-1px);
}
.nc-source-item {
  padding: 7px 10px;
  border-radius: 9px;
  background: var(--nc-search-fill);
  border: 0.8px solid var(--nc-border);
  font-size: 11.5px;
  line-height: 1.4;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nc-source-item code {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--state-verified);
}

/* =========================================================================
 * DUAL-PASS X-RAY, CONCURRENT PROCESSES & 3D SEMANTIC ZOOM PANELS
 * (On-demand living-material surfaces matching NovaChat tokens)
 * ========================================================================= */
.nc-xray-panel,
.nc-processes-panel,
.nc-z3d-panel {
  border-radius: 20px;
  background: var(--nc-surface-elevated);
  border: 1px solid var(--nc-border);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.06);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 11px;
}
.nc-panel-topbar,
.nc-xray-header,
.nc-z3d-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.nc-panel-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nc-panel-sub {
  font-size: 11.5px;
  color: var(--nc-muted);
}
.nc-xray-phase {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 600;
}
.nc-phase-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--nc-gold);
}
.nc-phase-dot.verified { background: var(--state-verified); }
.nc-phase-dot.inhibit { background: var(--state-inhibit); }
.nc-xray-metrics {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--nc-muted);
}
.nc-xray-head-right {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.nc-view-switch {
  display: inline-flex;
  background: var(--nc-search-fill);
  border: 0.8px solid var(--nc-border);
  border-radius: 9px;
  padding: 2px;
  gap: 2px;
}
.nc-view-btn {
  border: none;
  background: transparent;
  color: var(--nc-muted);
  font-family: var(--font-sans);
  font-size: 10.5px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease;
}
.nc-view-btn.active {
  background: var(--nc-input-surface);
  color: var(--nc-near-black);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Side-by-Side 3D Executive Committee Stage + Technical X-Ray (v18) */
.nc-xray-split {
  display: grid;
  grid-template-columns: minmax(0, 1.04fr) minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
}
.nc-xray-panel[data-view="split"] .nc-breakdown-grid {
  grid-template-columns: 1fr;
}
.nc-xray-panel[data-view="3d"] .nc-xray-split {
  grid-template-columns: 1fr;
}
.nc-xray-panel[data-view="3d"] .nc-tech-col {
  display: none;
}
.nc-xray-panel[data-view="xray"] .nc-xray-split {
  grid-template-columns: 1fr;
}
.nc-xray-panel[data-view="xray"] .nc-stage3d-col {
  display: none;
}
@media (max-width: 980px) {
  .nc-xray-split {
    grid-template-columns: 1fr;
  }
}

.nc-stage3d-col,
.nc-tech-col {
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-width: 0;
}
.nc-stage3d-canvas-wrap {
  position: relative;
  height: 214px;
  border-radius: 14px;
  background:
    radial-gradient(ellipse 80% 70% at 50% 42%, rgba(155, 114, 203, 0.08) 0%, rgba(212, 175, 55, 0.04) 48%, transparent 100%),
    var(--nc-search-fill);
  border: 1px solid var(--nc-border);
  overflow: hidden;
  touch-action: none;
}
.nc-xray-panel[data-view="3d"] .nc-stage3d-canvas-wrap {
  height: 264px;
}
.nc-stage3d-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}
.nc-stage3d-canvas:active {
  cursor: grabbing;
}
.nc-stage3d-badge {
  position: absolute;
  top: 9px;
  right: 10px;
  padding: 3px 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--nc-surface-elevated) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 0.8px solid color-mix(in srgb, var(--state-verified) 45%, var(--nc-border));
  font-size: 10px;
  font-weight: 700;
  color: var(--state-verified);
  letter-spacing: 0.02em;
  pointer-events: none;
}
.nc-stage3d-badge.shield {
  border-color: color-mix(in srgb, #7c5cbf 50%, var(--nc-border));
  color: #7c5cbf;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-polarity="light"]) .nc-stage3d-badge.shield { color: #a78bfa; border-color: rgba(167, 139, 250, 0.48); }
}
:root[data-polarity="dark"] .nc-stage3d-badge.shield { color: #a78bfa; border-color: rgba(167, 139, 250, 0.48); }

.nc-story-card {
  flex: 1;
  border-radius: 12px;
  background: var(--nc-input-surface);
  border: 1px solid var(--nc-border);
  padding: 11px 13px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.nc-story-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.nc-story-step {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--nc-muted);
}
.nc-story-zone {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 1.5px 7px;
  border-radius: 999px;
  background: var(--nc-search-fill);
  color: var(--nc-near-black);
}
.nc-story-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--nc-near-black);
  letter-spacing: -0.01em;
}
.nc-story-body {
  margin: 0;
  font-size: 12.2px;
  line-height: 1.48;
  color: var(--nc-near-black);
  opacity: 0.88;
}
.nc-story-contrast {
  margin-top: auto;
  padding-top: 5px;
  font-size: 11px;
  font-weight: 500;
  color: var(--state-verified);
  border-top: 0.7px solid var(--nc-border);
}

.nc-viz-stage {
  border-radius: 14px;
  background: var(--nc-search-fill);
  border: 1px solid var(--nc-border);
  padding: 6px 4px;
}
.nc-viz-svg { width: 100%; height: auto; display: block; }
.nc-viz-lane { font-size: 8.6px; fill: var(--nc-muted); letter-spacing: 0.06em; font-family: var(--font-mono); font-weight: 600; }
.viz-node-label { font-size: 10px; fill: var(--nc-near-black); font-family: var(--font-sans); font-weight: 600; pointer-events: none; }
.viz-node-ms { font-size: 9px; fill: var(--nc-muted); font-family: var(--font-mono); pointer-events: none; }
.viz-node-group { cursor: pointer; }

.nc-step-pills {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 5px;
}
@media (max-width: 720px) {
  .nc-step-pills { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.step-pill-btn {
  border: 1px solid var(--nc-border);
  background: transparent;
  color: var(--nc-muted);
  border-radius: 9px;
  padding: 5px 3px;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.step-pill-btn .sp-num { font-family: var(--font-mono); font-size: 9px; opacity: 0.8; }
.step-pill-btn.reached { border-color: color-mix(in srgb, var(--state-verified) 45%, var(--nc-border)); }
.step-pill-btn.active { background: var(--nc-zinc); border-color: var(--nc-gold); color: var(--nc-near-black); }
.step-pill-btn.inhibit { border-color: var(--state-inhibit); color: var(--state-inhibit); }

.nc-scrubber-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}
.nc-scrubber-bar input[type="range"] {
  flex: 1 1 130px;
  height: 4px;
  accent-color: var(--nc-gold);
  cursor: pointer;
}
.nc-scrub-counter {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--nc-muted);
  min-width: 62px;
  text-align: right;
}

.nc-action-btn {
  height: 30px;
  padding: 0 11px;
  border-radius: 9px;
  border: 1px solid var(--nc-border);
  background: var(--nc-input-surface);
  color: var(--nc-near-black);
  font-family: var(--font-sans);
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
}
.nc-action-btn:hover:not(:disabled) {
  border-color: rgba(212, 175, 55, 0.6);
}
.nc-action-primary {
  background: var(--nc-dark);
  border-color: var(--nc-dark);
  color: var(--nc-dark-fg);
}
.nc-action-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.nc-step-card {
  border-radius: 12px;
  background: var(--nc-search-fill);
  border: 1px solid var(--nc-border);
  padding: 11px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.nc-step-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.nc-step-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
}
.nc-step-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--nc-input-surface);
  border: 1px solid var(--nc-border);
  color: var(--nc-near-black);
}
.nc-step-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--nc-muted);
}
.nc-step-card-meta code {
  background: var(--nc-input-surface);
  border: 1px solid var(--nc-border);
  padding: 2px 6px;
  border-radius: 6px;
  color: var(--nc-near-black);
}
.nc-step-summary {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.48;
  color: var(--nc-near-black);
}
.nc-breakdown-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
@media (max-width: 720px) {
  .nc-breakdown-grid { grid-template-columns: 1fr; }
}
.nc-breakdown-box {
  border-radius: 9px;
  background: var(--nc-input-surface);
  border: 1px solid var(--nc-border);
  padding: 8px 9px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.nc-breakdown-label {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--nc-muted);
}
.nc-breakdown-val {
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.42;
  color: var(--nc-near-black);
  word-break: break-word;
  white-space: pre-wrap;
}

.nc-dual-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.dual-compare-summary {
  grid-column: 1 / -1;
  border-radius: 10px;
  background: var(--nc-input-surface);
  border: 1px solid var(--nc-border);
  padding: 8px 11px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--nc-muted);
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.dual-compare-summary strong { color: var(--nc-near-black); }
.compare-card {
  border-radius: 10px;
  background: var(--nc-search-fill);
  border: 1px solid var(--nc-border);
  padding: 9px 11px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--nc-muted);
  line-height: 1.48;
  cursor: pointer;
}
.compare-card.active-pass {
  background: var(--nc-input-surface);
  border-color: var(--nc-gold);
  color: var(--nc-near-black);
}
.compare-title {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  color: var(--nc-near-black);
  display: flex;
  justify-content: space-between;
  margin-bottom: 3px;
}
@media (max-width: 640px) { .nc-dual-compare { grid-template-columns: 1fr; } }

/* 5 Concurrent Processes Grid & 3D Semantic Zoom */
.nc-processes-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}
@media (max-width: 960px) {
  .nc-processes-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
}
.proc-card {
  border-radius: 16px;
  padding: 10px;
  background: var(--nc-input-surface);
  border: 1px solid var(--nc-border);
  display: flex;
  flex-direction: column;
  gap: 7px;
  cursor: pointer;
  transition: opacity 200ms ease, transform 180ms ease, border-color 180ms ease;
}
.proc-card.healthy-semi { opacity: 0.68; }
.proc-card.healthy-semi:hover { opacity: 1; transform: translateY(-2px); border-color: rgba(212, 175, 55, 0.45); }
.proc-card.struggling-loop { opacity: 1; border-color: color-mix(in srgb, var(--state-warning) 55%, var(--nc-border)); transform: translateY(-1px); }
.proc-card.struggling-error { opacity: 1; border-color: color-mix(in srgb, var(--state-verified) 55%, var(--nc-border)); transform: translateY(-1px); }
.proc-card-head { display: flex; justify-content: space-between; align-items: center; gap: 4px; }
.proc-id-tag { font-family: var(--font-mono); font-size: 9.5px; font-weight: 700; color: var(--nc-muted); }
.proc-state-pill { font-family: var(--font-mono); font-size: 8.8px; font-weight: 700; padding: 2px 6px; border-radius: 999px; }
.proc-state-pill.working { color: var(--state-verified); background: color-mix(in srgb, var(--state-verified) 14%, transparent); }
.proc-state-pill.looping { color: var(--state-warning); background: color-mix(in srgb, var(--state-warning) 16%, transparent); }
.proc-state-pill.error { color: var(--state-verified); background: color-mix(in srgb, var(--state-verified) 14%, transparent); }
.proc-mini-canvas-wrap { width: 100%; height: 68px; border-radius: 10px; background: var(--nc-search-fill); overflow: hidden; }
.proc-mini-canvas { width: 100%; height: 100%; display: block; }
.proc-title { font-size: 12px; font-weight: 600; color: var(--nc-near-black); }
.proc-sub { font-family: var(--font-mono); font-size: 9.5px; color: var(--nc-muted); }

.nc-z3d-title-block { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.nc-status-pill { font-family: var(--font-mono); font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--nc-search-fill); }
.nc-z3d-controls { display: flex; align-items: center; gap: 8px; }
.nc-zoom-scrubber { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 11px; color: var(--nc-muted); }
.nc-zoom-scrubber input[type="range"] { width: 92px; accent-color: var(--nc-gold); }
.nc-z3d-canvas-wrap { width: 100%; height: 310px; border-radius: 14px; background: var(--nc-search-fill); border: 1px solid var(--nc-border); overflow: hidden; touch-action: none; }
.nc-z3d-canvas { width: 100%; height: 100%; display: block; cursor: grab; }
.nc-z3d-hud { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-family: var(--font-mono); font-size: 10px; color: var(--nc-muted); padding: 0 2px; }
.nc-z3d-diag { border-radius: 12px; background: var(--nc-search-fill); border: 1px solid var(--nc-border); padding: 11px 12px; display: flex; flex-direction: column; gap: 8px; }
.nc-z3d-diag-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; }
.nc-node-state { font-family: var(--font-mono); font-size: 10.5px; font-weight: 700; }
.nc-node-desc { margin: 0; font-size: 12px; line-height: 1.5; color: var(--nc-muted); }
.nc-z3d-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* =========================================================================
 * MEDIUM / NARROW DESKTOP & SIDE-PANE (641px–1080px):
 * Preserves 100% authentic NovaChat macOS 3-panel spatial geometry —
 * wings stay BEHIND the center card (z-index 2 < 10) with OUTWARD rounded
 * corners and NEVER cover the chat workspace.
 * ========================================================================= */
@media (max-width: 1080px) and (min-width: 641px) {
  :root {
    --nc-wing-width: clamp(188px, 22vw, 240px);
    --nc-wing-peek: 28px;
    --nc-wing-underlap: 12px;
    --nc-card-radius: 32px;
    --nc-wing-radius: 26px;
    --nc-wing-v-inset: 28px;
  }
  .nc-spatial-stage {
    padding: 8px 8px;
  }
  .nc-wing-inner {
    padding: 16px 16px;
  }
  .nc-wing-left .nc-wing-inner {
    padding-right: 22px;
  }
  .nc-wing-right .nc-wing-inner {
    padding-left: 22px;
  }
  .nc-viewport {
    padding: 10px 20px 12px;
  }
  .nc-composer-wrap {
    padding: 4px 20px 20px;
  }
}

/* =========================================================================
 * PHONE MOBILE (<= 640px):
 * Spatial Push-Reveal — wings stay BEHIND the workspace (z-index 2 < 10)
 * with outward-facing corners; opening a wing slides the center workspace
 * card aside instead of covering the chat with an inward-rounded drawer.
 * ========================================================================= */
.nc-mobile-scrim {
  position: fixed;
  inset: 0;
  background: transparent;
  z-index: 25;
}

@media (max-width: 640px) {
  :root {
    --nc-mobile-drawer-w: min(78vw, 286px);
  }
  .nc-spatial-stage {
    padding: 0;
    background: var(--nc-background);
  }
  .nc-main-card {
    position: relative;
    z-index: 10;
    max-width: 100%;
    width: 100%;
    border-radius: 0;
    border: none;
    box-shadow: none;
    transition: transform 340ms var(--nc-spring), border-radius 340ms var(--nc-spring), box-shadow 340ms ease;
  }
  .nc-spatial-stage.mobile-left-open .nc-main-card {
    transform: translateX(var(--nc-mobile-drawer-w));
    border-radius: 28px;
    border: 1px solid var(--nc-border);
    box-shadow: -14px 0 36px rgba(0, 0, 0, 0.14);
  }
  .nc-spatial-stage.mobile-right-open .nc-main-card {
    transform: translateX(calc(-1 * var(--nc-mobile-drawer-w)));
    border-radius: 28px;
    border: 1px solid var(--nc-border);
    box-shadow: 14px 0 36px rgba(0, 0, 0, 0.14);
  }
  .nc-mobile-nav-btn {
    display: inline-flex;
  }
  .nc-wing {
    position: fixed;
    top: 16px;
    bottom: 16px;
    margin: 0;
    width: calc(var(--nc-mobile-drawer-w) + 12px);
    z-index: 2;
    opacity: 0;
    pointer-events: none;
    transform: none;
    border: 1px solid var(--nc-border);
    transition: opacity 220ms ease;
  }
  .nc-wing-veil, .nc-wing-pin-zone { display: none; }
  .nc-wing-left {
    left: 6px;
    border-radius: 24px 0 0 24px;
    border-right: none;
  }
  .nc-wing-right {
    right: 6px;
    border-radius: 0 24px 24px 0;
    border-left: none;
  }
  .nc-wing-left.revealed, .nc-wing-left.pinned,
  .nc-wing-right.revealed, .nc-wing-right.pinned {
    transform: none;
    opacity: 1;
    pointer-events: auto;
  }
  .nc-wing-left .nc-wing-inner {
    padding: 18px 24px 18px 16px;
  }
  .nc-wing-right .nc-wing-inner {
    padding: 18px 16px 18px 24px;
  }
  .nc-spatial-stage.mobile-left-open .nc-mobile-scrim {
    left: var(--nc-mobile-drawer-w);
    right: 0;
  }
  .nc-spatial-stage.mobile-right-open .nc-mobile-scrim {
    left: 0;
    right: var(--nc-mobile-drawer-w);
  }
  .nc-viewport {
    padding: 8px 16px 10px;
  }
  .nc-composer-wrap {
    padding: 4px 14px 16px;
  }
  .nc-composer textarea {
    min-height: 76px;
    padding: 18px 18px 4px;
  }
}

.hidden { display: none !important; }
button:focus-visible, select:focus-visible { outline: 2px solid var(--nc-gold); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
