/* ================================================================
   NabuPilot — Virtual Office & AI Ecosystem HQ
   High-Tech Professional Cyberpunk & Modern SaaS Design System
   Multi-Tenant Business, Layout Studio & NabuDesk Live Sync
   ================================================================ */

@font-face {
  font-family: "Vazirmatn";
  src: url("/vendor/vazirmatn/Vazirmatn-Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Vazirmatn";
  src: url("/vendor/vazirmatn/Vazirmatn-SemiBold.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: "Vazirmatn";
  src: url("/vendor/vazirmatn/Vazirmatn-Bold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "Vazirmatn";
  src: url("/vendor/vazirmatn/Vazirmatn-ExtraBold.woff2") format("woff2");
  font-weight: 800;
  font-display: swap;
}

:root {
  /* Office palette, re-pointed at the NabuXUI tokens pinned dark by
     <html data-theme="dark">. Chrome rules below never use --nx-* directly:
     body.theme-* re-points these same aliases, so every theme follows. */
  --bg: var(--nx-bg);
  --bg-trans: color-mix(in srgb, var(--nx-bg) 88%, transparent);
  --surface: var(--nx-surface);
  --surface-trans: color-mix(in srgb, var(--nx-surface) 92%, transparent);
  --surface2: var(--nx-surface-2);
  --surface3: var(--nx-surface-3);
  --border: var(--nx-border);
  --border-strong: var(--nx-border-strong);
  --border-focus: var(--nx-accent-border);
  --border-glow: var(--nx-accent-soft);

  --text: var(--nx-text);
  --text-muted: var(--nx-text-muted);
  --text-dim: var(--nx-text-subtle);

  --brand1: var(--nx-accent);
  --brand2: var(--nx-violet-500);
  --brand-glow: var(--nx-shadow-glow);

  --accent-cyan: var(--nx-glow);
  --accent-emerald: var(--nx-success);
  --accent-amber: var(--nx-warning);
  --accent-rose: var(--nx-danger);
  --accent-purple: var(--nx-violet-400);
  --accent-blue: var(--nx-chart-4);

  --accent-text: var(--nx-accent-text);
  --info-text: var(--nx-info-text);
  --success-text: var(--nx-success-text);
  --danger-text: var(--nx-danger-text);
  --gold: var(--nx-gold);
  --gold-text: var(--nx-gold-text);
  --gold-soft: var(--nx-gold-soft);

  --glass: var(--nx-glass);
  --glass-border: var(--nx-glass-border);
  --glass-tint: var(--nx-glass-tint);
  --glass-tint-hover: var(--nx-glass-tint-hover);
  --glass-rim-soft: var(--nx-glass-rim-soft);

  --radius-xs: var(--nx-radius-xs);
  --radius-sm: var(--nx-radius-sm);
  --radius-md: var(--nx-radius-md);
  --radius-lg: var(--nx-radius-lg);
  --radius-xl: var(--nx-radius-xl);
  --radius-full: var(--nx-radius-full);

  --shadow-hud: var(--nx-shadow-lg), 0 0 0 1px var(--glass-rim-soft);
  --font-mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Monaco, Consolas, monospace;
}

/* The UA halves the text color for placeholders; say it once, with a token
   (chat inputs included — cpk-input and the 1:1 live chat input both sit on
   var(--bg)). */
input::placeholder, textarea::placeholder { color: var(--text-muted); opacity: 1; }

/* Lighting Modes */
body.theme-neon {
  --bg: #04060b;
  --brand1: #00f2fe;
  --brand2: #4facfe;
  --border-focus: rgba(0, 242, 254, 0.5);
}
body.theme-titanium {
  --bg: #0b0d12;
  --surface: #121620;
  --surface2: #1a202c;
  --brand1: #38bdf8;
  --brand2: #818cf8;
}
body.theme-sunset {
  --bg: #0d080c;
  --brand1: #f43f5e;
  --brand2: #fb923c;
}

body.theme-light {
  /* UA chrome (placeholder tint, scrollbars, selects) follows the theme. */
  color-scheme: light;
  --bg: #fcfbf8;
  --bg-trans: rgba(252, 251, 248, 0.92);
  --surface: #ffffff;
  --surface-trans: rgba(255, 255, 255, 0.94);
  --surface2: #f4f3ef;
  --surface3: #eae8e1;
  --border: #e7e4dc;
  --border-focus: rgba(99, 102, 241, 0.45);
  --border-glow: rgba(99, 102, 241, 0.18);

  --text: #12141f;
  --text-muted: #555a70;
  --text-dim: #6c7088;

  --brand1: #5647e6;
  --brand2: #7c3aed;
  --brand-glow: 0 0 24px rgba(79, 70, 229, 0.22);

  --accent-cyan: #0aa0bb;
  --accent-emerald: #059669;
  --accent-amber: #f59e0b;
  --accent-rose: #dc2626;
  --accent-purple: #7c3aed;
  --accent-blue: #2563eb;

  /* The new aliases, resolved for a light surface: readable text tints, and
     glass that tints dark-on-light (the reverse of nx's white-on-white). */
  --accent-text: #4a3dd6;
  --info-text: #0b7288;
  --success-text: #047857;
  --danger-text: #c02424;
  --gold: #f4a93c;
  --gold-text: #9a5b0f;
  --gold-soft: color-mix(in oklab, #f4a93c 18%, transparent);

  --glass: rgb(255 255 255 / 0.72);
  --glass-border: rgb(15 23 42 / 0.12);
  --glass-tint: rgb(15 23 42 / 0.04);
  --glass-tint-hover: rgb(15 23 42 / 0.08);
  --glass-rim-soft: rgb(15 23 42 / 0.08);

  --shadow-hud: 0 20px 50px rgba(15, 23, 42, 0.12), 0 0 0 1px rgba(15, 23, 42, 0.08);
}

body.theme-light #topbar {
  background: var(--bg-trans);
  box-shadow: 0 4px 30px rgba(15, 23, 42, 0.08);
}

body.theme-light .tbtn {
  background: var(--glass-tint);
  border-color: var(--glass-border);
  color: var(--text);
}

body.theme-light .tbtn:hover {
  background: var(--glass-tint-hover);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.1);
}

body.theme-light .cam-presets,
body.theme-light .quick-icons-group {
  background: rgba(244, 243, 239, 0.85);
}

body.theme-light .biz-dropdown,
body.theme-light .nav-dd-menu {
  background: var(--surface-trans);
  box-shadow: var(--shadow-hud);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Vazirmatn", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.6;
  user-select: none;
}

button, input, select, textarea {
  font-family: inherit;
  color: inherit;
}

/* ================================================================
   TOP COMMAND BAR
   ================================================================ */
#topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  gap: 12px;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-bottom: 1px solid var(--glass-border);
  box-shadow: var(--nx-shadow-md);
  overflow-x: auto;
  scrollbar-width: none;
}
#topbar::-webkit-scrollbar { display: none; }

.topbar-cam-section {
  display: flex;
}

.topbar-section {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.logo {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--brand1), var(--brand2));
  color: var(--nx-accent-contrast);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-hud);
  position: relative;
  overflow: hidden;
}
.logo svg { width: 20px; height: 20px; }

/* Business Switcher */
.biz-selector-wrapper {
  position: relative;
}

.biz-selector-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--glass-tint);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 5px 10px;
  color: var(--text);
  cursor: pointer;
  transition: background-color var(--nx-dur-fast) var(--nx-ease-out),
              border-color var(--nx-dur-fast) var(--nx-ease-out),
              box-shadow var(--nx-dur-fast) var(--nx-ease-out);
  text-align: right;
}

.biz-selector-btn:hover {
  background: var(--glass-tint-hover);
  border-color: var(--border-focus);
}

.biz-avatar {
  font-size: 13px;
  font-weight: 800;
  color: var(--accent-text);
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: color-mix(in oklab, var(--brand1) 18%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.biz-info {
  display: flex;
  flex-direction: column;
}

.biz-name {
  font-size: 12.5px;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
}

.biz-badge {
  font-size: 10px;
  color: var(--text-muted);
}

.biz-arrow {
  width: 13px;
  height: 13px;
  color: var(--text-dim);
  margin-inline-end: 2px;
  transition: transform var(--nx-dur-fast) var(--nx-ease-out);
}

.biz-dropdown {
  position: fixed;
  top: 0;
  inset-inline-start: 0;
  width: 320px;
  max-width: calc(100vw - 16px);
  background: var(--surface-trans);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-hud);
  backdrop-filter: blur(24px);
  padding: 8px;
  display: none;
  flex-direction: column;
  z-index: 1000;
  animation: popIn var(--nx-spring-snappy-duration) var(--nx-spring-snappy);
}
.biz-dropdown.open { display: flex; }

/* Fixed-position popovers dropped from the topbar: they settle toward the
   trigger, never from scale(0), and reduced motion turns this into a fade
   via --nx-motion. */
@keyframes popIn {
  0% { opacity: 0; transform: translateY(calc(-8px * var(--nx-motion))) scale(calc(1 - 0.04 * var(--nx-motion))); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.biz-dropdown-head {
  font-size: 11px;
  font-weight: 800;
  color: var(--text-dim);
  padding: 8px 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.biz-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 240px;
  overflow-y: auto;
}

.biz-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 0;
  color: var(--text);
  cursor: pointer;
  text-align: right;
  transition: background-color var(--nx-dur-fast) var(--nx-ease-out),
              border-color var(--nx-dur-fast) var(--nx-ease-out);
  width: 100%;
}
.biz-item:hover { background: var(--glass-tint-hover); }
.biz-item.active {
  background: var(--surface3);
  border: 1px solid var(--border-focus);
}

.biz-item-main {
  display: flex;
  align-items: center;
  gap: 8px;
}

.biz-item-name { font-weight: 700; font-size: 12.5px; }
.biz-item-plan { font-size: 10.5px; color: var(--text-dim); }
.biz-item-tag {
  font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: var(--radius-full);
  background: color-mix(in oklab, var(--accent-emerald) 15%, transparent); color: var(--success-text);
}

.biz-dropdown-footer {
  padding-top: 8px;
  border-top: 1px solid var(--border);
  margin-top: 6px;
}

/* Live Sync Engine Button */
.sync-status-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: color-mix(in oklab, var(--accent-emerald) 10%, transparent);
  border: 1px solid color-mix(in oklab, var(--accent-emerald) 30%, transparent);
  border-radius: var(--radius-md);
  padding: 5px 9px;
  color: var(--success-text);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color var(--nx-dur-fast) var(--nx-ease-out),
              border-color var(--nx-dur-fast) var(--nx-ease-out),
              box-shadow var(--nx-dur-fast) var(--nx-ease-out);
  white-space: nowrap;
}
.sync-status-btn:hover {
  background: color-mix(in oklab, var(--accent-emerald) 20%, transparent);
  border-color: color-mix(in oklab, var(--accent-emerald) 50%, transparent);
  box-shadow: 0 0 14px color-mix(in oklab, var(--accent-emerald) 25%, transparent);
}

.sync-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
}
.sync-icon { width: 12px; height: 12px; }

/* Camera Presets Switcher */
.cam-presets {
  display: flex;
  align-items: center;
  gap: 3px;
  background: var(--surface2);
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--glass-border);
}

.cam-btn {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color var(--nx-dur-fast) var(--nx-ease-out),
              background-color var(--nx-dur-fast) var(--nx-ease-out),
              box-shadow var(--nx-dur-fast) var(--nx-ease-out);
  white-space: nowrap;
}
.cam-btn:hover { color: var(--text); background: var(--surface3); }
.cam-btn.active {
  /* Solid fill: white label text on brand needs the flat surface, not a
     gradient (4.99:1 dark / 6.11:1 light). */
  background: var(--brand1);
  color: #fff;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--brand1) 40%, transparent), var(--brand-glow);
}

/* Divider between everyday views and technical / immersive modes. */
.cam-sep {
  flex: none;
  width: 1px;
  height: 16px;
  margin: 0 4px;
  background: var(--border);
}

/* Hub buttons are icon-only at every width: their Persian labels plus the
   dropdown arrows were ~440px of a bar that never fit the viewport it sat
   on (2023px of content on a 1440px window — everything past the edge was
   reachable only by the invisible horizontal scroll). The localized titles
   (data-i18n-attr) carry the names; badge-counts stay. */
.tbtn > span[data-i18n] { display: none; }
.tbtn .dd-arrow { display: none; }
.tbtn { padding-inline: 9px; gap: 6px; }

/* Action Buttons */
.tbtn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--glass-border);
  background: var(--glass-tint);
  color: var(--text);
  border-radius: var(--radius-md);
  padding: 6px 10px;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: background-color var(--nx-dur-fast) var(--nx-ease-out),
              border-color var(--nx-dur-fast) var(--nx-ease-out),
              color var(--nx-dur-fast) var(--nx-ease-out),
              box-shadow var(--nx-dur-fast) var(--nx-ease-out),
              transform var(--nx-dur-fast) var(--nx-ease-out),
              scale var(--nx-dur-fast) var(--nx-ease-out);
  position: relative;
  white-space: nowrap;
}

.tbtn:hover {
  background: var(--glass-tint-hover);
  border-color: var(--border-focus);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}
.tbtn:active { transform: translateY(0); scale: calc(1 - 0.04 * var(--nx-motion)); }
.tbtn svg { width: 14px; height: 14px; flex-shrink: 0; }
.tbtn.icon-only { padding: 7px; border-radius: var(--radius-md); }

/* Hover lift only where a hover exists; the colour feedback above is global. */
@media (hover: hover) and (pointer: fine) {
  .tbtn:hover { transform: translateY(-1px); }
}

.tbtn.brand-highlight {
  background: linear-gradient(135deg, color-mix(in oklab, var(--brand1) 22%, transparent), color-mix(in oklab, var(--brand2) 22%, transparent));
  border-color: color-mix(in oklab, var(--brand1) 45%, transparent);
  color: var(--accent-text);
}
.tbtn.brand-highlight:hover {
  background: linear-gradient(135deg, color-mix(in oklab, var(--brand1) 35%, transparent), color-mix(in oklab, var(--brand2) 35%, transparent));
  box-shadow: 0 0 20px color-mix(in oklab, var(--brand1) 30%, transparent);
}

.tbtn.ceo-highlight {
  background: var(--gold-soft);
  border-color: color-mix(in oklab, var(--gold) 35%, transparent);
  color: var(--gold-text);
}
.tbtn.ceo-highlight:hover {
  background: color-mix(in oklab, var(--gold) 26%, transparent);
  border-color: color-mix(in oklab, var(--gold) 50%, transparent);
  box-shadow: 0 0 18px color-mix(in oklab, var(--gold) 25%, transparent);
}

.tbtn.broadcast-btn {
  background: color-mix(in oklab, var(--accent-rose) 12%, transparent);
  border-color: color-mix(in oklab, var(--accent-rose) 35%, transparent);
  color: var(--danger-text);
}
.tbtn.broadcast-btn:hover {
  background: color-mix(in oklab, var(--accent-rose) 22%, transparent);
  box-shadow: 0 0 16px color-mix(in oklab, var(--accent-rose) 30%, transparent);
}

.tbtn.tbtn-telegram {
  background: linear-gradient(135deg, color-mix(in oklab, var(--accent-cyan) 22%, transparent), color-mix(in oklab, var(--brand1) 22%, transparent));
  border-color: color-mix(in oklab, var(--accent-cyan) 45%, transparent);
  color: var(--info-text);
}
.tbtn.tbtn-telegram:hover {
  background: linear-gradient(135deg, color-mix(in oklab, var(--accent-cyan) 35%, transparent), color-mix(in oklab, var(--brand1) 35%, transparent));
  box-shadow: 0 0 18px color-mix(in oklab, var(--accent-cyan) 35%, transparent);
}

.dd-arrow {
  width: 12px;
  height: 12px;
  margin-inline-end: 2px;
  color: var(--text-dim);
  transition: transform var(--nx-dur-fast) var(--nx-ease-out);
}

/* Nav Dropdown Popovers */
.nav-dd-wrapper {
  position: relative;
}

.nav-dd-menu {
  position: fixed;
  top: 0;
  inset-inline-start: 0;
  min-width: 250px;
  max-width: calc(100vw - 16px);
  background: var(--surface-trans);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-hud);
  backdrop-filter: blur(24px);
  padding: 6px;
  display: none;
  flex-direction: column;
  gap: 2px;
  z-index: 1000;
  animation: popIn var(--nx-spring-snappy-duration) var(--nx-spring-snappy);
}
.nav-dd-menu.open { display: flex; }

.nav-dd-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: background-color var(--nx-dur-fast) var(--nx-ease-out),
              color var(--nx-dur-fast) var(--nx-ease-out);
}
.nav-dd-item:hover {
  background: var(--glass-tint-hover);
  color: var(--text);
}

/* Language Switcher Dropdown */
.lang-selector-wrapper {
  position: relative;
}
.lang-dropdown {
  position: fixed;
  top: 0;
  inset-inline-start: auto;
  width: max-content;
  background: var(--surface-trans);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 6px;
  min-width: 145px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow-hud);
  display: none;
  flex-direction: column;
  gap: 4px;
  z-index: 1000;
}
.lang-dropdown.open {
  display: flex;
}
.lang-item {
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  transition: background-color var(--nx-dur-fast) var(--nx-ease-out),
              color var(--nx-dur-fast) var(--nx-ease-out);
  white-space: nowrap;
}
.lang-item:hover {
  background: var(--glass-tint-hover);
  color: var(--text);
}
.lang-item.active {
  background: var(--surface3);
  border: 1px solid var(--border-focus);
  color: var(--accent-text);
  font-weight: 700;
}

/* Quick tool icons: square icon buttons; the language switcher is a wider
   text pill (flag + code), hence the modifier. */
.icon-tool-btn {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--glass-tint);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  cursor: pointer;
  transition: background-color var(--nx-dur-fast) var(--nx-ease-out),
              border-color var(--nx-dur-fast) var(--nx-ease-out),
              color var(--nx-dur-fast) var(--nx-ease-out),
              scale var(--nx-dur-fast) var(--nx-ease-out);
}
.icon-tool-btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.icon-tool-btn:hover {
  background: var(--glass-tint-hover);
  border-color: var(--border-focus);
  color: var(--text);
}
.icon-tool-btn:active { scale: calc(1 - 0.04 * var(--nx-motion)); }
.icon-tool-btn:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

.icon-tool-btn.lang-pill {
  width: auto;
  padding: 2px 8px;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 700;
  border-radius: var(--radius-full);
}

/* Topbar clock: a monospace pill so the digits never reflow. */
.clock {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--glass-tint);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-full);
  padding: 4px 10px;
  white-space: nowrap;
}

/* Counter on a hub button (pending tasks). */
.badge-count {
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background: var(--accent-rose);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
}

/* Desk-count stepper in the layout HUD: a small segmented control. */
.counter-control {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: var(--surface2);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 2px;
}
.counter-btn {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-xs);
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  transition: color var(--nx-dur-fast) var(--nx-ease-out),
              background-color var(--nx-dur-fast) var(--nx-ease-out),
              scale var(--nx-dur-fast) var(--nx-ease-out);
}
.counter-btn:hover { color: var(--text); background: var(--glass-tint-hover); }
.counter-btn:active { scale: calc(1 - 0.04 * var(--nx-motion)); }
.counter-value {
  min-width: 22px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 800;
  color: var(--text);
}

/* LTR Typography Optimization */
html[dir="ltr"] body {
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
}
html[dir="rtl"] body {
  font-family: "Vazirmatn", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}


/* ================================================================
   OFFICE FLOOR LAYOUT CUSTOMIZER HUD (BOTTOM TOOLBAR)
   ================================================================ */
.layout-hud {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(calc(160px * var(--nx-motion)));
  opacity: 0;
  pointer-events: none;
  z-index: 45;
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 14px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  box-shadow: var(--shadow-hud), 0 0 35px color-mix(in oklab, var(--brand1) 35%, transparent);
  transition: transform var(--nx-spring-gentle-duration) var(--nx-spring-gentle),
              opacity var(--nx-dur-base) var(--nx-ease-out);
  max-width: 95vw;
}

.layout-hud.active, .layout-hud.open {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.hud-main-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.hud-title-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
  font-size: 13px;
  color: var(--gold-text);
  background: var(--gold-soft);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid color-mix(in oklab, var(--gold) 35%, transparent);
  white-space: nowrap;
}

.hud-icon { display: inline-flex; align-items: center; }
.hud-icon svg { width: 16px; height: 16px; flex-shrink: 0; }

.hud-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hud-label {
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 700;
  white-space: nowrap;
}

.hud-select {
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  background: var(--surface2);
  color: var(--text);
  font-size: 12px;
  padding: 6px 10px;
  outline: none;
  cursor: pointer;
  transition: border-color var(--nx-dur-fast) var(--nx-ease-out),
              box-shadow var(--nx-dur-fast) var(--nx-ease-out);
}
.hud-select:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px var(--border-glow); }

.segc {
  display: flex;
  align-items: center;
  background: var(--surface2);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
}
.segc button {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: color var(--nx-dur-fast) var(--nx-ease-out),
              background-color var(--nx-dur-fast) var(--nx-ease-out);
}
.segc button:hover { color: var(--text); }
.segc button.active {
  background: var(--brand1);
  color: #fff;
}

.hud-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-inline-end: auto;
}

.hud-sub-tip {
  font-size: 11px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  padding-top: 6px;
  line-height: 1.5;
}

/* ================================================================
   3D SCENE & OVERLAYS
   ================================================================ */
#scene { position: fixed; inset: 0; z-index: 1; }
#scene canvas { display: block; width: 100% !important; height: 100% !important; outline: none; }

#hint {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-trans);
  border: 1px solid var(--glass-border);
  padding: 7px 18px;
  border-radius: var(--radius-full);
  backdrop-filter: blur(14px);
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-hud);
  transition: opacity var(--nx-dur-base) var(--nx-ease-out);
}
.hint-sep { opacity: 0.4; }

/* Keyboard controls hint (WASD/T/R) — token-based chrome, was inline hex. */
.kbd-hint {
  position: absolute; bottom: 80px; right: 20px;
  background: var(--surface-trans); padding: 8px 12px;
  border-radius: var(--radius-sm); color: var(--text-muted);
  font-size: 12px; pointer-events: none;
  backdrop-filter: blur(4px); z-index: 10;
}

/* A keycap, wherever JS renders one (hotkeys modal). One look, one token
   set — the old per-key inline colors are gone. */
.kbd {
  background: var(--surface2); padding: 3px 8px;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  color: var(--info-text); font-weight: 700; font-family: var(--font-mono);
}

/* FPS-mode crosshair — was an inline-styled dot. */
.crosshair {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none; z-index: 20; opacity: 0.5;
}
.crosshair i {
  display: block; width: 4px; height: 4px;
  background: var(--text); border-radius: var(--radius-full);
  box-shadow: 0 0 4px rgb(0 0 0 / 0.8);
}

#activityTicker {
  position: fixed;
  bottom: 20px;
  /* Inline-start, not end: in the RTL root the end corner is bottom-LEFT —
     exactly under the chat launcher/panel column. The start lane (right)
     keeps the transient toast clear of the dock, and it may briefly sit
     over an open panel but never under one. */
  inset-inline-start: 20px;
  /* Ladder: floating panels 8900/9000 < toast 9400 < modal 9500. */
  z-index: 9400;
  background: var(--surface-trans);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 7px 14px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  backdrop-filter: blur(12px);
  max-width: 380px;
  box-shadow: var(--shadow-hud);
}
.ticker-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-cyan);
  box-shadow: 0 0 8px var(--accent-cyan);
  flex-shrink: 0;
}
.ticker-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Lite-client offer banner — the styles used to live inline on the markup.
   [hidden] guard: display:flex on the class would otherwise beat the
   hidden attribute and the dismiss button would look broken. */
.lite-offer {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 60;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--surface2); border-top: 1px solid var(--border);
  color: var(--text); font-size: 13px;
  display: flex; gap: 12px; align-items: center;
}
.lite-offer[hidden] { display: none; }
.lite-offer-text {
  flex: 1; min-width: 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.lite-offer-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* Broadcast Banner */
#broadcastBanner {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%) translateY(-30px);
  background: linear-gradient(135deg, color-mix(in oklab, var(--accent-rose) 95%, transparent), color-mix(in oklab, var(--accent-rose) 72%, #000));
  border: 1px solid color-mix(in oklab, var(--accent-rose) 45%, #fff);
  color: #fff;
  font-weight: 800;
  font-size: 13.5px;
  padding: 12px 24px;
  border-radius: var(--radius-full);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  box-shadow: 0 10px 40px color-mix(in oklab, var(--accent-rose) 50%, transparent);
  display: flex;
  align-items: center;
  gap: 10px;
  transition: transform var(--nx-spring-snappy-duration) var(--nx-spring-snappy),
              opacity var(--nx-dur-base) var(--nx-ease-out);
  max-width: 90vw;
  text-align: center;
}
#broadcastBanner.active {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ================================================================
   3D CSS2D LABELS & HOLOGRAPHIC FLOATING DESK CARDS
   ================================================================ */
.holo-desk-card {
  pointer-events: auto;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--agent-color, color-mix(in oklab, var(--brand1) 45%, transparent));
  border-radius: var(--radius-md);
  padding: 8px 12px;
  box-shadow: var(--shadow-hud), 0 0 20px var(--agent-color, color-mix(in oklab, var(--brand1) 20%, transparent));
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  text-align: right;
  min-width: 170px;
  /* Viewport-capped so a card at the platform edge never runs past the
     right side of the viewport. */
  max-width: min(220px, 44vw);
  display: flex;
  flex-direction: column;
  gap: 5px;
  transform: translateY(-8px);
  transition: transform var(--nx-spring-gentle-duration) var(--nx-spring-gentle),
              box-shadow var(--nx-dur-base) var(--nx-ease-out);
  user-select: none;
}

.holo-desk-card:hover {
  transform: translateY(-12px) scale(1.03);
  box-shadow: var(--shadow-hud), 0 0 28px var(--agent-color, color-mix(in oklab, var(--brand1) 35%, transparent));
}

.holo-desk-card.free {
  border: 1px dashed color-mix(in oklab, var(--accent-emerald) 50%, transparent);
  background: color-mix(in srgb, var(--surface) 75%, transparent);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
}
.holo-desk-card.free:hover {
  border-color: var(--accent-emerald);
  background: color-mix(in oklab, var(--accent-emerald) 12%, transparent);
}
.holo-desk-name {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-muted);
}
.holo-free-btn {
  font-size: 11px;
  font-weight: 800;
  color: var(--success-text);
  margin-top: 2px;
}

.holo-header {
  display: flex;
  align-items: center;
  gap: 6px;
}
.holo-avatar {
  /* A chip with the office's identity color, so an agent without a custom
     icon still reads as someone (5.20:1 light / 7.48:1 dark). Same pattern
     as .m-agent-avatar. */
  width: 28px; height: 28px; flex-shrink: 0;
  border-radius: var(--radius-sm);
  background: color-mix(in oklab, var(--brand1) 15%, transparent);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 800; color: var(--accent-text);
}
.holo-name {
  font-size: 12.5px;
  font-weight: 800;
  color: var(--text);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.holo-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
.holo-dot.active { background: var(--accent-emerald); box-shadow: 0 0 6px var(--accent-emerald); }
.holo-dot.typing { background: var(--accent-blue); box-shadow: 0 0 6px var(--accent-blue); animation: pulseDot 1s infinite; }
.holo-dot.sleeping { background: var(--text-dim); }

.holo-role {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.holo-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--glass-border);
  padding-top: 4px;
  font-size: 11px;
}
.holo-model {
  font-family: var(--font-mono);
  color: var(--info-text);
  font-weight: 700;
}
.holo-shift {
  color: var(--text-dim);
}

.holo-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}
.holo-btn {
  flex: 1;
  border: 0;
  background: var(--glass-tint);
  border-radius: var(--radius-xs);
  color: var(--text);
  font-size: 10px;
  font-weight: 700;
  padding: 3px 6px;
  cursor: pointer;
  transition: background-color var(--nx-dur-fast) var(--nx-ease-out),
              color var(--nx-dur-fast) var(--nx-ease-out);
}
.holo-btn:hover {
  background: var(--agent-color, var(--brand1));
  color: #fff;
}

/* Compact chip mode — default; full card only on hover or when camera is near */
.holo-desk-card.mini {
  min-width: 0;
  /* Replace (not extend) the card's 44vw cap: chips stay chips, but they
     still cannot run past the viewport edge. */
  max-width: 34vw;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  flex-direction: row;
  align-items: center;
  gap: 6px;
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  box-shadow: var(--shadow-hud), 0 0 12px var(--agent-color, color-mix(in oklab, var(--brand1) 15%, transparent));
}
.holo-desk-card.mini .holo-role,
.holo-desk-card.mini .holo-meta,
.holo-desk-card.mini .holo-actions { display: none; }
.holo-desk-card.mini .holo-name {
  font-size: 10.5px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; min-width: 0;
}

.holo-desk-card.mini:hover {
  flex-direction: column;
  align-items: stretch;
  border-radius: var(--radius-md);
  padding: 8px 12px;
  min-width: 170px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
}
.holo-desk-card.mini:hover .holo-role { display: block; }
.holo-desk-card.mini:hover .holo-meta,
.holo-desk-card.mini:hover .holo-actions { display: flex; }

/* Free-desk chip stays a tiny CTA pill */
.holo-desk-card.free.mini { padding: 4px 10px; }
.holo-desk-card.free.mini .holo-desk-name { font-size: 10px; }
.holo-desk-card.free.mini .holo-free-btn { font-size: 11px; margin-top: 0; }

/* Hide all floating 3D labels (keyboard: T) */
body.labels-hidden .label-renderer-canvas { display: none !important; }

.lbl { pointer-events: none; text-align: center; transform: translateY(-8px); transition: transform 0.2s ease; }
.lbl .name { font-size: 12px; font-weight: 800; color: #fff; text-shadow: 0 2px 10px rgba(0,0,0,0.9); white-space: nowrap; max-width: 180px; display: inline-block; overflow: hidden; text-overflow: ellipsis; }
.lbl .role {
  display: inline-flex; align-items: center; gap: 5px; margin-top: 3px; font-size: 10px; font-weight: 700;
  padding: 2px 9px; border-radius: var(--radius-full); color: #fff; box-shadow: 0 4px 12px rgba(0,0,0,0.4); white-space: nowrap;
}
.lbl .role.free { background: color-mix(in oklab, var(--accent-emerald) 25%, transparent); color: var(--success-text); border: 1px dashed color-mix(in oklab, var(--accent-emerald) 50%, transparent); }
.lbl.ceo .name { color: var(--gold-text); }
.lbl.core .name { color: var(--info-text); }

.emp-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
  font-weight: 800;
  background: var(--surface-trans);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  color: var(--text);
  box-shadow: var(--shadow-hud);
  pointer-events: none;
  white-space: nowrap;
}
.emp-status-badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
.emp-status-badge .dot.active { background: var(--accent-emerald); box-shadow: 0 0 6px var(--accent-emerald); }
.emp-status-badge .dot.typing { background: var(--accent-blue); box-shadow: 0 0 6px var(--accent-blue); animation: pulseDot 1s infinite; }
.emp-status-badge .dot.sleeping { background: var(--text-dim); }

.agent-speech-bubble {
  position: relative;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border: 1px solid var(--border-focus);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  font-size: 11.5px;
  color: var(--text);
  max-width: 220px;
  text-align: center;
  box-shadow: var(--shadow-hud), 0 0 20px color-mix(in oklab, var(--brand1) 30%, transparent);
  backdrop-filter: blur(12px);
  animation: popBubble 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform: translateY(-24px);
  pointer-events: none;
}
.agent-speech-bubble::after {
  content: ""; position: absolute; bottom: -6px; left: 50%; transform: translateX(-50%);
  border-inline-start: 6px solid transparent; border-inline-end: 6px solid transparent; border-top: 6px solid var(--border-focus);
}
@keyframes popBubble { 0% { transform: translateY(-10px) scale(0.6); opacity: 0; } 100% { transform: translateY(-24px) scale(1); opacity: 1; } }

/* ================================================================
   RIGHT DRAWER PANEL
   ================================================================ */
#drawerOverlay {
  position: fixed; inset: 0; z-index: 60; background: rgba(4, 6, 11, 0.55);
  backdrop-filter: blur(4px); opacity: 0; pointer-events: none; transition: opacity 0.25s ease;
}
#drawerOverlay.open { opacity: 1; pointer-events: auto; }

#drawer {
  position: fixed; top: 0; right: 0; height: 100%; width: 440px; max-width: 95vw;
  z-index: 70; background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(24px);
  border-inline-start: 1px solid var(--glass-border); transform: translateX(105%);
  transition: transform var(--nx-spring-gentle-duration) var(--nx-spring-gentle); display: flex;
  flex-direction: column; box-shadow: var(--shadow-hud);
}
#drawer.open { transform: translateX(0); }

.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--surface2) 60%, transparent);
}
.drawer-title { font-weight: 800; font-size: 16px; display: flex; align-items: center; gap: 8px; }

.x {
  width: 32px; height: 32px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface2); color: var(--text-muted); cursor: pointer; display: flex;
  align-items: center; justify-content: center;
  transition: color var(--nx-dur-fast) var(--nx-ease-out),
              border-color var(--nx-dur-fast) var(--nx-ease-out),
              background-color var(--nx-dur-fast) var(--nx-ease-out);
}
.x:hover { color: var(--text); border-color: var(--border-focus); background: var(--surface3); }
.x svg { width: 15px; height: 15px; }

.drawer-body { flex: 1; overflow-y: auto; padding: 20px; }
.drawer-body::-webkit-scrollbar { width: 6px; }
.drawer-body::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: var(--radius-full); }

/* ================================================================
   MODAL WINDOW & SYNC TERMINAL
   ================================================================ */
.modal-overlay {
  /* Above every floating dock (the legacy chat panel sits at z-index 900);
     below only the auth gate (9998). A dialog must own the screen. */
  position: fixed; inset: 0; z-index: 9500; background: rgba(4, 6, 12, 0.75);
  backdrop-filter: blur(12px); opacity: 0; pointer-events: none; transition: opacity 0.25s ease;
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }

.modal-window {
  width: 860px; max-width: 96vw; max-height: 90vh; background: color-mix(in srgb, var(--surface) 94%, transparent);
  border: 1px solid var(--glass-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-hud);
  backdrop-filter: blur(28px); display: flex; flex-direction: column; overflow: hidden;
  transform: scale(0.96) translateY(calc(12px * var(--nx-motion)));
  transition: transform var(--nx-spring-snappy-duration) var(--nx-spring-snappy);
}
.modal-overlay.open .modal-window { transform: scale(1) translateY(0); }

.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--surface2) 70%, transparent);
}
.modal-title-group { display: flex; flex-direction: column; }
/* The close buttons had no style of their own and rendered as a bare white
   browser button on the dark header. */
.modal-close, .drawer-close {
  flex-shrink: 0; width: 36px; height: 36px; border-radius: var(--radius-md);
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--glass-tint); border: 1px solid var(--glass-border);
  color: var(--text); font-size: 15px; line-height: 1; cursor: pointer;
  transition: background-color var(--nx-dur-fast) var(--nx-ease-out),
              border-color var(--nx-dur-fast) var(--nx-ease-out),
              transform var(--nx-dur-fast) var(--nx-ease-out);
}
.modal-close:hover, .drawer-close:hover { background: var(--glass-tint-hover); transform: rotate(90deg); }
.modal-title { font-weight: 800; font-size: 17px; color: var(--text); }
.modal-sub, .modal-subtitle { font-size: 12px; color: var(--text-muted); }
.modal-body { flex: 1; overflow-y: auto; padding: 24px; }
.modal-body::-webkit-scrollbar { width: 8px; }
.modal-body::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: var(--radius-full); }

/* Common UI Elements */
.card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 12px;
}
.section-t {
  font-size: 12px; font-weight: 800; color: var(--text-dim); text-transform: uppercase;
  letter-spacing: 0.5px; margin: 16px 0 8px 0;
}
.sub { font-size: 12.5px; color: var(--text-muted); margin-bottom: 14px; }
.muted { color: var(--text-muted); }
.font-11 { font-size: 11px; }
.font-12 { font-size: 12px; }

.row { display: flex; align-items: center; gap: 8px; }
.row.between { justify-content: space-between; }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 11.5px; font-weight: 700; color: var(--text-muted); margin-bottom: 5px; }
.field input[type="text"], .field input[type="time"], .field select, .field textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 12px; font-size: 12.5px; color: var(--text); outline: none;
  transition: border-color var(--nx-dur-fast) var(--nx-ease-out),
              box-shadow var(--nx-dur-fast) var(--nx-ease-out);
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--border-glow);
}
.field textarea { resize: vertical; min-height: 60px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-sm); font-size: 12px; font-weight: 700;
  cursor: pointer; border: 0;
  transition: background-color var(--nx-dur-fast) var(--nx-ease-out),
              border-color var(--nx-dur-fast) var(--nx-ease-out),
              box-shadow var(--nx-dur-fast) var(--nx-ease-out),
              filter var(--nx-dur-fast) var(--nx-ease-out);
}
/* Solid brand fill: small white label text needs the flat surface, not a
   gradient (4.99:1 dark / 6.11:1 light). */
.btn.brand { background: var(--brand1); color: #fff; }
.btn.brand:hover { box-shadow: var(--brand-glow); filter: brightness(1.1); }
.btn.ghost { background: var(--surface3); color: var(--text); border: 1px solid var(--border); }
.btn.ghost:hover { background: var(--glass-tint-hover); border-color: var(--border-focus); }
.btn.danger { background: color-mix(in oklab, var(--accent-rose) 20%, transparent); color: var(--danger-text); border: 1px solid color-mix(in oklab, var(--accent-rose) 40%, transparent); }
.btn.danger:hover { background: color-mix(in oklab, var(--accent-rose) 35%, transparent); }
.btn.small { padding: 5px 10px; font-size: 11px; }

.emp-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.emp-head .avatar {
  width: 44px; height: 44px; border-radius: var(--radius-md); display: flex; align-items: center;
  justify-content: center; font-size: 20px; flex-shrink: 0;
}
.emp-head .n { font-size: 15px; font-weight: 800; }
.emp-head .r { font-size: 11.5px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }

.status-dot { width: 6px; height: 6px; border-radius: 50%; }
.status-dot.active { background: var(--accent-emerald); box-shadow: 0 0 6px var(--accent-emerald); }
.status-dot.typing, .status-dot.busy { background: var(--accent-blue); box-shadow: 0 0 6px var(--accent-blue); }
.status-dot.sleeping { background: var(--text-dim); }

/* ================================================================
   LIVE 1:1 CHAT (drawer)
   The drawer markup this styles used to carry its chrome as inline
   cssText with raw hexes; it speaks tokens now, like the rest.
   ================================================================ */
.lc-head {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 12px; margin-bottom: 12px;
}
.lc-head .n { font-size: 15px; font-weight: 800; }
.lc-head .r { font-size: 11.5px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.lc-head-main { flex: 1; min-width: 0; }
/* Role tint arrives as a custom property (--agent-color) — data, not style;
   the chrome stays token-based. */
.lc-avatar {
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  background: color-mix(in oklab, var(--agent-color, var(--brand1)) 15%, transparent);
  color: var(--accent-text); font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.lc-live { background: var(--surface3); color: var(--success-text); font-size: 11px; }
.lc-chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 10px; scrollbar-width: none; }
.lc-feed {
  flex: 1; min-height: 280px; max-height: 420px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 10px; padding: 12px;
  background: var(--surface-trans); border: 1px solid var(--border);
  border-radius: var(--radius-md); margin-bottom: 12px;
}
.lc-msg { display: flex; flex-direction: column; align-items: flex-start; }
.lc-msg--bot { align-items: flex-end; }
.lc-meta { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--text-muted); margin-bottom: 3px; }
.lc-latency { color: var(--info-text); }
.lc-bubble--user, .lc-bubble--bot {
  max-width: 85%; padding: 8px 12px; font-size: 12px; line-height: 1.6;
  word-break: break-word; color: var(--text);
}
.lc-bubble--user {
  background: color-mix(in oklab, var(--brand1) 15%, transparent);
  border: 1px solid var(--border-focus);
  border-radius: var(--radius-md) var(--radius-md) var(--radius-md) 3px;
}
.lc-bubble--bot {
  background: var(--surface3); border: 1px solid var(--border-strong);
  border-radius: var(--radius-md) var(--radius-md) 3px var(--radius-md);
}
.lc-error {
  align-self: center; max-width: 90%; padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid color-mix(in oklab, var(--accent-rose) 45%, transparent);
  background: color-mix(in oklab, var(--accent-rose) 8%, transparent);
  color: var(--danger-text); font-size: 11px;
}

/* Typing indicator — one chip shared by the 1:1 drawer and the copilot
   panel. Text for screen readers (aria-label), dots for eyes; the pulse
   color is the info token the old #38bdf8 text carried. */
.typing-dots {
  display: inline-flex; align-items: center; gap: 4px; margin-bottom: 8px;
  padding: 6px 10px; background: var(--surface3);
  border: 1px solid var(--border-strong); border-radius: var(--radius-md);
}
.typing-dots i {
  width: 6px; height: 6px; border-radius: var(--radius-full);
  background: var(--info-text); animation: pulseDot 1.2s infinite;
}
.typing-dots i:nth-child(2) { animation-delay: 0.2s; }
.typing-dots i:nth-child(3) { animation-delay: 0.4s; }
/* display:inline-flex above would eat the UA's [hidden]; guard it. */
.typing-dots[hidden] { display: none; }
/* pulseDot was referenced (typing dots in desk cards and status badges) but
   never defined — this lights both dead references up. */
@keyframes pulseDot { 0%, 100% { opacity: .35; transform: scale(.85); } 50% { opacity: 1; transform: scale(1); } }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.stat { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px; text-align: center; }
.stat .v { font-size: 16px; font-weight: 800; color: var(--text); font-family: var(--font-mono); }
.stat .k { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.cost-total { background: linear-gradient(135deg, color-mix(in oklab, var(--brand1) 15%, transparent), color-mix(in oklab, var(--brand2) 15%, transparent)); border: 1px solid var(--border-focus); border-radius: var(--radius-md); padding: 18px; text-align: center; margin-bottom: 14px; }
.cost-total .v { font-size: 28px; font-weight: 800; color: var(--text); font-family: var(--font-mono); }
.cost-total .k { font-size: 12px; color: var(--text-muted); }

/* Color dot picker */
.color-picker-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.color-dot { width: 24px; height: 24px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; transition: scale var(--nx-dur-fast) var(--nx-ease-out), border-color var(--nx-dur-fast) var(--nx-ease-out), box-shadow var(--nx-dur-fast) var(--nx-ease-out); }
.color-dot:hover { transform: scale(1.15); }
.color-dot.active { border-color: var(--text); box-shadow: 0 0 10px color-mix(in srgb, var(--text) 60%, transparent); }

/* Permissions Grid */
.permissions-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.perm-card { display: flex; align-items: flex-start; gap: 8px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px; cursor: pointer; }
.perm-title { font-size: 11.5px; font-weight: 700; }
.perm-desc { font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); }

/* Recruiter Grid */
.recruiter-prompt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; margin-bottom: 14px; }
.recruiter-chip { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 12px; cursor: pointer; transition: background-color var(--nx-dur-fast) var(--nx-ease-out), border-color var(--nx-dur-fast) var(--nx-ease-out), transform var(--nx-dur-fast) var(--nx-ease-out); }
.recruiter-chip:hover { background: var(--surface3); border-color: var(--border-focus); transform: translateY(-2px); }
.recruiter-chip-title { font-size: 12.5px; font-weight: 800; margin-bottom: 4px; }
.recruiter-chip-desc { font-size: 11px; color: var(--text-muted); line-height: 1.5; }

/* Sync Grid */
.sync-meta-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.sync-card { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 14px; text-align: center; }
.sync-val { font-size: 22px; font-weight: 800; color: var(--success-text); font-family: var(--font-mono); }
.sync-lbl { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* A terminal is dark on purpose, in every theme — its light-on-dark text is
   fixed with it, so it never follows the office aliases. */
.sync-log-terminal {
  background: #05070d; border: 1px solid var(--border); border-radius: var(--radius-md); padding: 14px;
  font-family: var(--font-mono); font-size: 11.5px; color: #38bdf8; max-height: 240px; overflow-y: auto; line-height: 1.7; white-space: pre-wrap;
}

/* Voice Waveform animation */
.voice-wave-container.active .v-bar {
  animation: wavePulse 0.8s infinite ease-in-out alternate;
}
.voice-wave-container.active .v-bar:nth-child(1) { animation-delay: 0.1s; }
.voice-wave-container.active .v-bar:nth-child(2) { animation-delay: 0.3s; }
.voice-wave-container.active .v-bar:nth-child(3) { animation-delay: 0.5s; }
.voice-wave-container.active .v-bar:nth-child(4) { animation-delay: 0.2s; }
.voice-wave-container.active .v-bar:nth-child(5) { animation-delay: 0.4s; }
.voice-wave-container.active .v-bar:nth-child(6) { animation-delay: 0.6s; }

@keyframes wavePulse {
  0% { transform: scaleY(0.3); }
  100% { transform: scaleY(1.3); }
}

/* Meeting Dialogue Feed */
.meeting-dialogues-feed { display: flex; flex-direction: column; gap: 10px; max-height: 260px; overflow-y: auto; }
.meeting-dialogue-card { background: var(--glass-tint); border: 1px solid var(--border); border-inline-end: 3px solid var(--agent-color, var(--accent-blue)); border-radius: var(--radius-sm); padding: 10px 14px; }
.meeting-agent-meta { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.meeting-agent-name { font-weight: 800; font-size: 12.5px; }
.meeting-agent-role { font-size: 11px; color: var(--text-dim); }
.meeting-text { font-size: 12px; line-height: 1.6; color: var(--text); }

/* ================================================================
   RESPONSIVE MOBILE & TABLET MEDIA QUERIES
   ================================================================ */

@media (max-width: 1200px) {
  .tbtn {
    padding: 5px 8px;
    font-size: 11px;
  }
  .biz-name {
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .cam-btn {
    padding: 4px 7px;
    font-size: 11px;
  }
}

@media (max-width: 1900px) {
  .biz-name { max-width: 150px; }
}

@media (max-width: 992px) {
  .sync-meta-grid { grid-template-columns: repeat(2, 1fr); }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .cam-presets { gap: 2px; }
  .cam-sep { display: none; }
  .sync-text { display: none; }
  .biz-badge { display: none; }
  .biz-name { max-width: 140px; }
}

@media (max-width: 1200px) {
  #topbar {
    height: 52px;
    padding: 0 8px;
    gap: 6px;
    -webkit-overflow-scrolling: touch;
  }
  
  .tbtn {
    padding: 5px 8px;
    font-size: 11px;
    min-height: 38px;
  }
  .tbtn span { font-size: 11px; }

  #camPresets {
    bottom: 56px;
    padding: 4px;
    gap: 4px;
    max-width: 96vw;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .cam-btn {
    padding: 5px 8px;
    font-size: 10.5px;
    min-height: 38px;
  }

  #activityTicker {
    bottom: 10px;
    max-width: 92vw;
    padding: 6px 12px;
    font-size: 11px;
  }

  /* Bottom sheet drawer for mobile */
  #drawer {
    top: auto;
    bottom: 0;
    right: 0;
    left: 0;
    width: 100% !important;
    max-width: 100% !important;
    max-height: 85vh;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    border-inline-end: 0;
    border-top: 1px solid var(--border-glow);
    transform: translateY(100%);
  }
  #drawer.open {
    transform: translateY(0);
  }

  /* Modals on mobile */
  .modal-window {
    width: 95vw !important;
    max-width: 95vw !important;
    max-height: 90vh !important;
    padding: 14px;
    border-radius: var(--radius-lg);
    margin: auto;
  }
  .modal-head {
    margin-bottom: 12px;
    padding-bottom: 10px;
  }
  .modal-title { font-size: 15px; }

  /* Input sizing on mobile to prevent iOS auto-zoom */
  .field input[type="text"],
  .field input[type="time"],
  .field select,
  .field textarea {
    font-size: 16px !important;
    padding: 10px 12px;
  }

  .btn {
    min-height: 44px;
    font-size: 13px;
  }

  .sync-meta-grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
  .recruiter-prompt-grid { grid-template-columns: 1fr; }
  .holo-desk-card {
    min-width: 120px;
    padding: 6px;
    font-size: 10px;
  }
}

@media (max-width: 480px) {
  #topbar {
    height: 48px;
    gap: 4px;
  }
  .biz-selector-btn .biz-name {
    max-width: 100px;
    font-size: 11px;
  }
  .biz-selector-btn .biz-badge {
    display: none;
  }
  .tbtn span {
    display: none;
  }
  .tbtn svg {
    margin: 0 auto;
  }
}

/* Mobile Bottom Navigation Bar */
#mobileBottomNav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: rgba(6, 8, 14, 0.92);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-top: 1px solid var(--border);
  z-index: 55;
  align-items: center;
  justify-content: space-around;
  padding: 0 4px;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.5);
}

.mob-nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: transparent;
  border: 0;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  flex: 1;
  height: 100%;
  transition: color var(--nx-dur-fast) var(--nx-ease-out),
              background-color var(--nx-dur-fast) var(--nx-ease-out);
}

.mob-nav-btn.active, .mob-nav-btn:active {
  color: var(--accent-cyan);
}

.mob-nav-btn .mob-icon {
  font-size: 18px;
}
.mob-nav-btn .mob-icon svg { width: 18px; height: 18px; }

@media (max-width: 1200px) {
  #mobileBottomNav {
    display: flex;
  }
  #activityTicker {
    bottom: 68px !important;
  }
  #hint {
    bottom: 104px !important;
  }
}

/* Focus and Accessibility Standards */
:focus-visible {
  outline: 2px solid var(--border-focus) !important;
  outline-offset: 2px !important;
}

/* Tabular Numerals for metrics, timers, and badges */
.sync-val, .badge-count, .clock, .stat .v, .cost-total .v, .counter-value {
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

/* Prefers Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}




/* Global Loader */
.global-loader {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.6s ease, visibility 0.6s;
}
.global-loader.hidden {
  opacity: 0;
  visibility: hidden;
}
.loader-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid color-mix(in oklab, var(--accent-emerald) 20%, transparent);
  border-top-color: var(--brand1);
  border-radius: 50%;
  animation: spin-loader 1s linear infinite;
  margin: 0 auto 16px;
}
@keyframes spin-loader { 100% { transform: rotate(360deg); } }
.loader-text {
  font-size: 14px;
  color: var(--text-muted);
  font-family: inherit;
}

@media (max-width: 1200px) {
  #topbar {
    justify-content: flex-start;
  }
  .topbar-cam-section {
    position: fixed;
    bottom: 70px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 50;
    width: max-content;
    max-width: 95vw;
  }
  #camPresets {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    background: rgba(14, 18, 29, 0.85);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    border-radius: var(--radius-xl);
  }
}

/* ================================================================
   FLOATING HUD PANELS
   Shared shell for the always-around mission-control panels (server
   room, CopilotKit chat). The shell lives here once; each module's
   geometry comes from the compound selectors (.float-panel.sr-panel,
   .float-panel.cpk-panel) so declaration order never decides who wins.
   ================================================================ */
.float-panel {
  /* Above every floating dock (the legacy chat panel sits at z-index 900,
     see the MODAL note); below the modal overlay (9500) and auth gate. */
  position: fixed; bottom: 24px; right: 16px; z-index: 8900;
  display: flex; flex-direction: column; overflow: hidden;
  font-size: 12.5px;
  background: color-mix(in srgb, var(--surface) 95%, transparent);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-hud); /* no border: the 1px ring rides in the shadow */
  /* Closed. Exits are softer than enters: 220ms ease-out vs the 425ms spring. */
  opacity: 0; visibility: hidden; pointer-events: none;
  scale: 0.96; translate: 0 calc(8px * var(--nx-motion));
  transition: opacity var(--nx-dur-base) var(--nx-ease-out),
              scale var(--nx-dur-base) var(--nx-ease-out),
              translate var(--nx-dur-base) var(--nx-ease-out),
              visibility 0s linear var(--nx-dur-base);
}
.float-panel.is-open {
  opacity: 1; visibility: visible; pointer-events: auto;
  scale: 1; translate: 0 0;
  /* Same language as .modal-window; visibility flips instantly on open. */
  transition: opacity var(--nx-spring-snappy-duration) var(--nx-spring-snappy),
              scale var(--nx-spring-snappy-duration) var(--nx-spring-snappy),
              translate var(--nx-spring-snappy-duration) var(--nx-spring-snappy);
}
/* Physical left placement. right:auto is the point: with left+right+width
   all set, a fixed box in the RTL root (index.html dir="rtl") drops the
   left edge and the chat panel landed on the server room's corner. */
.float-panel[data-place="left"] { left: 16px; right: auto; }

.float-panel-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  background: var(--surface2); flex: none;
}
.float-panel-icon { font-size: 16px; line-height: 1; flex: none; display: inline-flex; align-items: center; }
.float-panel-icon svg { width: 16px; height: 16px; }
.float-panel-titles { flex: 1; min-width: 0; }
.float-panel-title { display: block; font-size: 12.5px; }
.float-panel-sub { display: block; font-size: 10.5px; opacity: .65; }
.float-panel-actions { display: flex; align-items: center; gap: 4px; flex: none; }

.float-panel-btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); color: var(--text-muted);
  border-radius: var(--radius-sm); padding: 4px 8px;
  background: none; cursor: pointer;
  transition: color var(--nx-dur-fast) var(--nx-ease-out),
              background-color var(--nx-dur-fast) var(--nx-ease-out),
              border-color var(--nx-dur-fast) var(--nx-ease-out),
              scale var(--nx-dur-fast) var(--nx-ease-out);
}
.float-panel-btn:hover { color: var(--text); background: var(--surface3); border-color: var(--border-focus); }
.float-panel-btn:active { scale: calc(1 - 0.04 * var(--nx-motion)); }
.float-panel-btn:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; }
.float-panel-btn svg { width: 14px; height: 14px; }

.float-panel-x {
  width: 26px; height: 26px;
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: 0; color: var(--text-muted);
  border-radius: var(--radius-sm); cursor: pointer;
  transition: color var(--nx-dur-fast) var(--nx-ease-out),
              background-color var(--nx-dur-fast) var(--nx-ease-out),
              transform var(--nx-dur-fast) var(--nx-ease-out),
              scale var(--nx-dur-fast) var(--nx-ease-out);
}
.float-panel-x:hover { color: var(--text); background: var(--surface3); transform: rotate(90deg); }
.float-panel-x:active { scale: calc(1 - 0.04 * var(--nx-motion)); }
.float-panel-x:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; }
.float-panel-x svg { width: 14px; height: 14px; }

.float-panel-body {
  flex: 1; overflow-y: auto; padding: 12px;
  display: flex; flex-direction: column; gap: 12px;
}
.float-panel-body::-webkit-scrollbar { width: 6px; }
.float-panel-body::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: var(--radius-full); }
/* display:flex on the shell would eat the browser's [hidden]; guard it. */
.float-panel [hidden] { display: none !important; }

/* Shared meters, pills and stat lines (server room + companies gallery). */
.hud-meter { height: 7px; border-radius: var(--radius-full); background: var(--surface3); overflow: hidden; }
.hud-meter--thin { height: 5px; }
.hud-meter-fill {
  height: 100%; border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--brand1), var(--brand2));
  transition: width var(--nx-dur-base) var(--nx-ease-out);
}
.meter-head { display: flex; justify-content: space-between; gap: 8px; font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.tag-dashed {
  font-size: 10px; padding: 1px 7px; border-radius: var(--radius-full);
  border: 1px dashed var(--border-focus); color: var(--accent-text);
  white-space: nowrap;
}
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.num-ltr { direction: ltr; unicode-bidi: embed; white-space: nowrap; }
.stat-inline { font-size: 11px; color: var(--text-muted); }
.stat-inline b { color: var(--text); }

/* --- server room ------------------------------------------------ */
.float-panel.sr-panel { width: min(340px, calc(100vw - 32px)); max-height: 68vh; }
.sr-section { border-top: 1px solid var(--border); padding-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.sr-agents { display: flex; flex-direction: column; gap: 6px; }
.sr-agent-row { display: flex; align-items: center; gap: 8px; }
.sr-agent-name { flex: 1; }
.sr-agent-meter { width: 90px; flex: none; }
.sr-strong { color: var(--text); font-weight: 700; }
.sr-ok { color: var(--success-text); }
.sr-fail { color: var(--danger-text); }
.sr-note { font-size: 11px; color: var(--text-muted); }
.sr-note--center { text-align: center; font-size: 10px; opacity: .65; }
.sr-meter-foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 4px; font-size: 11px; color: var(--text-muted); }
.sr-cp-stats { display: flex; gap: 6px; flex-wrap: wrap; }

/* --- copilot chat ----------------------------------------------- */
/* A modern dark chat window in the reference chat apps' grammar: a flat
   near-black island centered over the office, a gradient orb for the bot,
   avatar-led answers with markdown, quiet user bubbles on the opposite
   side and a pill composer. The window is its own theme — the office's
   lighting modes stop at its border. One panel, two tabs: the read-only
   agent feed and the assistant conversation with its composer (the old
   separate #aiChatPanel overlapped here once; one level, one geometry). */
.float-panel.cpk-panel {
  /* The chat's private dark palette. */
  --g-bg: #131316;
  --g-surface: #1a1a1f;
  --g-surface-2: #222228;
  --g-border: rgba(255, 255, 255, 0.07);
  --g-border-strong: rgba(255, 255, 255, 0.13);
  --g-text: #f4f4f6;
  --g-muted: #9d9da7;
  --g-green: #34d399;

  /* Centered app window instead of a corner dock. transform composes with
     the base's translate/scale properties, so the spring open/close
     animation survives unchanged. */
  left: 50%; right: auto; top: 0; bottom: 0; margin-block: auto;
  transform: translateX(-50%);
  width: min(560px, calc(100vw - 24px));
  height: min(740px, 100vh);
  height: min(740px, 100dvh);
  z-index: 9000; font-size: 13.5px;
  background: var(--g-bg);
  backdrop-filter: none; -webkit-backdrop-filter: none;
  border: 1px solid var(--g-border);
  border-radius: var(--radius-xl);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(0, 0, 0, 0.4);
  color: var(--g-text);
}
/* The dim veil under the window: click it and the chat closes. */
.cpk-veil {
  position: fixed; inset: 0; z-index: 8900;
  background: rgba(8, 8, 12, 0.45);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity var(--nx-dur-base) var(--nx-ease-out),
              visibility 0s linear var(--nx-dur-base);
}
.cpk-veil.is-open {
  opacity: 1; visibility: visible; pointer-events: auto;
  transition: opacity var(--nx-dur-base) var(--nx-ease-out);
}
/* Header: the orb, the name, a live status line. */
.float-panel.cpk-panel .float-panel-head {
  padding: 13px 14px; gap: 11px;
  background: var(--g-surface); border-bottom: 1px solid var(--g-border);
}
.float-panel.cpk-panel .float-panel-icon {
  width: 38px; height: 38px; border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--brand1), var(--brand2));
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; box-shadow: 0 4px 14px color-mix(in srgb, var(--brand1) 45%, transparent);
}
.float-panel.cpk-panel .float-panel-icon svg { width: 19px; height: 19px; }
/* The header's character portrait; the gradient orb behind it is the
   fallback when the asset is missing. */
.float-panel.cpk-panel .float-panel-icon img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  border-radius: var(--radius-full);
  object-fit: cover;
}
.float-panel.cpk-panel .float-panel-icon { position: relative; }
.float-panel.cpk-panel .float-panel-title { font-size: 14.5px; font-weight: 800; color: var(--g-text); }
.float-panel.cpk-panel .float-panel-sub {
  font-size: 10.5px; color: var(--g-muted); opacity: 1;
  display: flex; align-items: center; gap: 6px;
}
/* The pulsing green dot before the status text — "online". */
.float-panel.cpk-panel .float-panel-sub::before {
  content: ''; width: 7px; height: 7px; border-radius: var(--radius-full);
  background: var(--g-green); flex: none;
  animation: cpkPulse 2.4s var(--nx-ease-out) infinite;
}
@keyframes cpkPulse {
  0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.45); }
  70% { box-shadow: 0 0 0 7px rgba(52, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}
.float-panel.cpk-panel .float-panel-x { color: var(--g-muted); }
.float-panel.cpk-panel .float-panel-x:hover { color: var(--g-text); background: var(--g-surface-2); }
.float-panel.cpk-panel .float-panel-body { padding: 0; gap: 0; background: var(--g-bg); }

/* Segmented tab pills under the header. */
.cpk-tabs {
  display: flex; gap: 4px; padding: 4px; flex: none;
  background: var(--g-surface); border: 1px solid var(--g-border);
  border-radius: var(--radius-full); margin: 10px 12px 0;
}
.cpk-tab {
  flex: 1; min-height: 30px; border: 0; background: transparent;
  color: var(--g-muted); border-radius: var(--radius-full);
  font: inherit; font-size: 12px; font-weight: 700; cursor: pointer;
  transition: color var(--nx-dur-fast) var(--nx-ease-out),
              background-color var(--nx-dur-fast) var(--nx-ease-out),
              box-shadow var(--nx-dur-fast) var(--nx-ease-out);
}
.cpk-tab:hover { color: var(--g-text); }
.cpk-tab.is-active {
  background: var(--g-surface-2); color: var(--g-text);
  box-shadow: inset 0 0 0 1px var(--g-border-strong);
}
.cpk-tab:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; }
/* Unread dot on the quiet tab while dialogue lands elsewhere. */
.cpk-tab.has-unread::after {
  content: ''; width: 6px; height: 6px;
  border-radius: var(--radius-full); background: var(--brand1);
  display: inline-block; margin-inline-start: 6px;
}

/* The conversation. */
.cpk-msgs {
  flex: 1; overflow-y: auto; padding: 14px 12px 8px;
  display: flex; flex-direction: column; gap: 14px;
}
.cpk-msgs::-webkit-scrollbar, .cpk-public::-webkit-scrollbar { width: 6px; }
.cpk-msgs::-webkit-scrollbar-thumb, .cpk-public::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14); border-radius: var(--radius-full);
}
.cpk-msg { display: flex; gap: 9px; max-width: 100%; }
.cpk-msg-meta {
  display: flex; align-items: baseline; gap: 7px; margin-bottom: 4px;
  font-size: 10.5px; color: var(--g-muted);
}
.cpk-msg-name { font-weight: 700; color: var(--g-muted); }
.cpk-msg--assistant { flex-direction: row; align-items: flex-end; }
.cpk-msg-col { flex: 1; min-width: 0; }
/* The user speaks from the panel's start edge (right in the RTL office),
   in one quiet brand-tinted bubble; the flat corner points at the speaker. */
.cpk-msg--user { flex-direction: column; align-items: flex-start; max-width: 88%; }
.cpk-msg--user .cpk-msg-body {
  background: color-mix(in srgb, var(--brand1) 20%, var(--g-surface-2));
  border: 1px solid color-mix(in srgb, var(--brand1) 32%, transparent);
  border-radius: 14px 4px 14px 14px;
  padding: 9px 13px; white-space: pre-wrap;
}
/* The assistant answers from the far side, avatar outermost. */
.cpk-msg--assistant .cpk-msg-body {
  background: var(--g-surface); border: 1px solid var(--g-border);
  border-radius: 4px 14px 14px 14px;
  padding: 10px 13px;
}
.cpk-msg-body { line-height: 1.85; color: var(--g-text); font-size: 13px; }
.cpk-avatar, .cpk-orb {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-full); flex: none;
  background: linear-gradient(135deg, var(--brand1), var(--brand2));
  color: #fff;
}
.cpk-avatar { width: 30px; height: 30px; box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35); position: relative; overflow: hidden; }
.cpk-avatar svg, .cpk-orb svg { width: 15px; height: 15px; }
/* The mascot portrait covers its host (orb or initials) and simply
   disappears if the deployment ships without the assets. */
.cpk-mascot-img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  border-radius: inherit; object-fit: cover;
}
.cpk-pub-ava { position: relative; overflow: hidden; }
/* The character reacts to the run: a gentle bob while the answer streams,
   a content little tilt when it lands. */
.cpk-avatar .cpk-mascot-img, .cpk-hero-orb .cpk-mascot-img {
  transition: transform 0.3s var(--nx-ease-out);
}
.float-panel.cpk-panel.is-working .cpk-avatar .cpk-mascot-img,
.float-panel.cpk-panel.is-working .cpk-hero-orb .cpk-mascot-img {
  animation: cpkBob 2s ease-in-out infinite;
}
.float-panel.cpk-panel.is-complete .cpk-avatar .cpk-mascot-img,
.float-panel.cpk-panel.is-complete .cpk-hero-orb .cpk-mascot-img {
  transform: rotate(-3deg);
}
@keyframes cpkBob { 50% { transform: translateY(-5px); } }
.cpk-msg-body.typing-dots {
  display: inline-flex; align-items: center; gap: 4px;
  min-height: 20px; padding: 12px 14px;
}

/* Tool-call status pills. */
.cpk-tool {
  align-self: center;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 12px; border-radius: var(--radius-full);
  background: var(--g-surface); border: 1px solid var(--g-border);
  font-size: 11px; color: var(--g-muted);
}
.cpk-tool-spin {
  width: 11px; height: 11px; border-radius: var(--radius-full);
  border: 2px solid var(--g-border-strong); border-top-color: var(--brand1);
  animation: cpkSpin 0.8s linear infinite; flex: none;
}
@keyframes cpkSpin { to { transform: rotate(1turn); } }
.cpk-tool.is-done { color: var(--g-green); border-color: color-mix(in srgb, var(--g-green) 32%, transparent); }
.cpk-tool-check { color: var(--g-green); display: inline-flex; flex: none; }
.cpk-tool.is-failed { color: #fda4af; border-color: color-mix(in srgb, #f43f5e 40%, transparent); }
.cpk-tool-x { color: #f43f5e; display: inline-flex; flex: none; }
/* A gated action holding for a person: amber clock, plus a way in to the
   approval queue that holds its draft card. */
.cpk-tool.is-waiting { color: #fcd34d; border-color: color-mix(in srgb, #f59e0b 38%, transparent); }
.cpk-tool-clock { color: #fbbf24; display: inline-flex; flex: none; }
.cpk-tool-queue {
  margin-inline-start: 2px; padding: 2px 8px;
  font-size: 10px; font-family: inherit; line-height: 1.5;
  color: #fcd34d; background: color-mix(in srgb, #f59e0b 14%, transparent);
  border: 1px solid color-mix(in srgb, #f59e0b 34%, transparent);
  border-radius: var(--radius-full); cursor: pointer;
}
.cpk-tool-queue:hover { background: color-mix(in srgb, #f59e0b 24%, transparent); }
.cpk-tool-queue:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; }
/* "Try again" under a refused run (402 quota / 503 not configured). */
.cpk-retry {
  align-self: flex-start; margin-top: 8px; padding: 4px 12px;
  font-size: 11px; font-family: inherit;
  color: var(--g-text); background: var(--g-surface-2);
  border: 1px solid var(--g-border-strong); border-radius: var(--radius-full);
  cursor: pointer;
}
.cpk-retry:hover { border-color: color-mix(in srgb, var(--brand1) 45%, transparent); color: #fff; }
.cpk-retry:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; }

/* Empty state, in the reference app's entry grammar: the character greets
   first (tilted, twinkling, captioned), then the name, the line about what
   it can do, and the starters — a beat apart, like someone settling in. */
.cpk-hero {
  margin: auto 0; padding: 16px 10px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  text-align: center;
}
.cpk-hero-stage { position: relative; width: 132px; height: 140px; flex: none; }
.cpk-hero-orb {
  width: 116px; height: 116px; border-radius: var(--radius-full);
  display: inline-flex; align-items: center; justify-content: center;
  position: absolute; top: 0; right: 8px;
  background: linear-gradient(135deg, var(--brand1), var(--brand2));
  color: #fff; transform: rotate(3deg);
  box-shadow: 0 10px 34px color-mix(in srgb, var(--brand1) 40%, transparent);
}
.cpk-hero-orb svg { width: 30px; height: 30px; }
.cpk-hero-orb .cpk-mascot-img { animation: cpkIdleFloat 3.6s ease-in-out infinite; }
@keyframes cpkIdleFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}
/* Hand-cut paper stars around the character, twinkling out of phase. */
.cpk-spark {
  position: absolute; color: #8f9ac0; opacity: 0.55; z-index: 1;
  animation: cpkTwinkle 2.8s ease-in-out infinite;
}
.cpk-spark svg { display: block; }
.cpk-spark--one { width: 17px; top: 30px; left: 0; transform: rotate(-14deg); }
.cpk-spark--two { width: 23px; bottom: 14px; right: 0; transform: rotate(12deg); animation-delay: 1.4s; }
@keyframes cpkTwinkle {
  0%, 100% { opacity: 0.25; scale: 0.85; }
  50% { opacity: 0.9; scale: 1.05; }
}
/* The small tilted caption under the character — a handwritten margin note. */
.cpk-hero-caption {
  position: absolute; bottom: -4px; right: 26px;
  font-size: 9.5px; letter-spacing: 0.2px;
  color: var(--g-muted);
  transform: rotate(-3deg);
}
/* The entry stagger: each row settles in a beat after the previous one. */
.cpk-hero > * { animation: cpkFadeUp 0.55s var(--nx-ease-out) both; }
.cpk-hero > *:nth-child(2) { animation-delay: 0.09s; }
.cpk-hero > *:nth-child(3) { animation-delay: 0.18s; }
.cpk-hero > *:nth-child(4) { animation-delay: 0.27s; }
@keyframes cpkFadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.cpk-hero-title { font-size: 17px; font-weight: 800; color: var(--g-text); }
.cpk-hero-sub { font-size: 12px; color: var(--g-muted); line-height: 1.9; max-width: 42ch; }
.cpk-hero-chips { display: flex; flex-direction: column; gap: 8px; width: min(330px, 100%); margin-top: 6px; }
.cpk-suggest {
  text-align: start; cursor: pointer;
  background: var(--g-surface); color: var(--g-text);
  border: 1px solid var(--g-border); border-radius: var(--radius-md);
  padding: 10px 13px; font: inherit; font-size: 12.5px; line-height: 1.7;
  transition: border-color var(--nx-dur-fast) var(--nx-ease-out),
              background-color var(--nx-dur-fast) var(--nx-ease-out),
              scale var(--nx-dur-fast) var(--nx-ease-out);
}
.cpk-suggest:hover { background: var(--g-surface-2); border-color: color-mix(in srgb, var(--brand1) 45%, transparent); }
.cpk-suggest:active { scale: calc(1 - 0.04 * var(--nx-motion)); }
.cpk-suggest:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; }

/* The composer: one pill, attach on one end, round gradient send on the other. */
.cpk-composer {
  flex: none; display: flex; flex-direction: column; gap: 6px;
  padding: 10px 12px calc(14px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--g-border); background: var(--g-bg);
}
.cpk-composer-pill {
  display: flex; align-items: flex-end; gap: 7px;
  background: var(--g-surface-2); border: 1px solid var(--g-border);
  border-radius: 24px; padding: 7px;
  transition: border-color var(--nx-dur-fast) var(--nx-ease-out),
              box-shadow var(--nx-dur-fast) var(--nx-ease-out);
}
.cpk-composer-pill:focus-within {
  border-color: color-mix(in srgb, var(--brand1) 55%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand1) 16%, transparent);
}
.cpk-input {
  flex: 1; resize: none; max-height: 120px; min-width: 0;
  background: transparent; border: 0; outline: none;
  color: var(--g-text); padding: 7px 6px;
  font: inherit; font-size: 13px; line-height: 1.7;
}
.cpk-attach, .cpk-send {
  width: 36px; height: 36px; flex: none; border-radius: var(--radius-full);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; align-self: flex-end;
  transition: filter var(--nx-dur-fast) var(--nx-ease-out),
              background-color var(--nx-dur-fast) var(--nx-ease-out),
              color var(--nx-dur-fast) var(--nx-ease-out),
              scale var(--nx-dur-fast) var(--nx-ease-out);
}
.cpk-attach { background: transparent; border: 1px solid var(--g-border); color: var(--g-muted); }
.cpk-attach:hover { color: var(--g-text); background: rgba(255, 255, 255, 0.06); }
.cpk-attach:active { scale: calc(1 - 0.06 * var(--nx-motion)); }
.cpk-attach svg, .cpk-send svg { width: 17px; height: 17px; }
.cpk-send {
  background: linear-gradient(135deg, var(--brand1), var(--brand2));
  color: #fff; border: 0;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--brand1) 40%, transparent);
}
.cpk-send:hover { filter: brightness(1.08); }
.cpk-send:active { scale: calc(1 - 0.06 * var(--nx-motion)); }
.cpk-send:disabled { opacity: 0.45; cursor: default; box-shadow: none; filter: none; }
.cpk-attach:focus-visible, .cpk-send:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; }
.cpk-composer-hint { text-align: center; font-size: 10px; color: var(--g-muted); opacity: 0.75; }
.cpk-note {
  align-self: center;
  background: var(--g-surface-2); border: 1px solid var(--g-border);
  color: var(--g-text); border-radius: var(--radius-full);
  font-size: 11px; padding: 4px 12px;
}

/* markdown-lite output inside an answer card. */
.cpk-md { display: flex; flex-direction: column; gap: 8px; }
.cpk-md p { margin: 0; }
.cpk-md h4, .cpk-md h5, .cpk-md h6 { margin: 2px 0; color: var(--g-text); }
.cpk-md h4 { font-size: 14.5px; }
.cpk-md h5 { font-size: 13.5px; }
.cpk-md h6 { font-size: 12.5px; }
.cpk-md ul, .cpk-md ol {
  margin: 0; padding-inline-start: 18px;
  display: flex; flex-direction: column; gap: 4px;
}
.cpk-md blockquote {
  margin: 0; padding-inline-start: 10px;
  border-inline-start: 3px solid var(--brand1); color: var(--g-muted);
}
.cpk-md hr { border: 0; border-top: 1px solid var(--g-border); margin: 4px 0; }
.cpk-md a {
  color: var(--brand1); text-decoration: underline;
  text-underline-offset: 3px; word-break: break-word;
}
.cpk-md code {
  font-family: var(--font-mono); font-size: 0.92em;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 6px; padding: 1px 6px;
  direction: ltr; unicode-bidi: embed;
}
.cpk-md-code {
  background: #0d0d10; border: 1px solid var(--g-border);
  border-radius: 12px; overflow: hidden;
}
.cpk-md-code-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 5px 6px 5px 12px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--g-border);
}
.cpk-md-code-lang { font-family: var(--font-mono); font-size: 10px; color: var(--g-muted); }
.cpk-md-copy {
  border: 0; background: transparent; color: var(--g-muted);
  font: inherit; font-size: 10.5px; cursor: pointer;
  padding: 3px 9px; border-radius: var(--radius-full);
  transition: color var(--nx-dur-fast) var(--nx-ease-out),
              background-color var(--nx-dur-fast) var(--nx-ease-out);
}
.cpk-md-copy:hover { color: var(--g-text); background: rgba(255, 255, 255, 0.08); }
.cpk-md-code pre {
  margin: 0; padding: 10px 12px; overflow-x: auto;
  direction: ltr; text-align: left;
}
.cpk-md-code pre code {
  font-family: var(--font-mono); font-size: 11.5px; line-height: 1.7;
  color: #e4e4e7; white-space: pre; background: none; padding: 0; border-radius: 0;
}

/* Read-only agent_dialogue feed (public tab), in the same language. */
.cpk-public {
  flex: 1; overflow-y: auto; padding: 12px;
  display: flex; flex-direction: column; gap: 10px;
}
.cpk-pub {
  display: flex; flex-direction: column; gap: 5px;
  background: var(--g-surface); border: 1px solid var(--g-border);
  border-radius: 14px; padding: 10px 12px;
}
.cpk-pub-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cpk-pub-ava {
  width: 24px; height: 24px; border-radius: var(--radius-full); flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800; color: #fff;
  background: linear-gradient(135deg, var(--brand2), var(--brand1));
}
.cpk-pub-name { color: var(--g-text); font-weight: 700; font-size: 12px; }
.cpk-pub-to { color: var(--g-muted); font-weight: 400; font-size: 11px; }
.cpk-pub-topic {
  background: rgba(255, 255, 255, 0.06); color: var(--g-muted);
  font-size: 10.5px; padding: 2px 8px; border-radius: var(--radius-full); flex: none;
}
.cpk-pub-text { font-size: 12.5px; line-height: 1.8; color: var(--g-text); opacity: 0.92; white-space: pre-wrap; }

/* The launcher: a gradient pill with the orb, waiting at the office floor. */
.office-roster {
  position: fixed;
  z-index: 24;
  inset-block-end: 78px;
  inset-inline-start: 16px;
  width: min(280px, calc(100vw - 32px));
  max-height: 38vh;
  overflow: auto;
  padding: 10px 12px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--surface, #0f172a) 88%, transparent);
  border: 1px solid var(--glass-border, rgba(148, 163, 184, .25));
  backdrop-filter: blur(16px);
  color: var(--text, #e2e8f0);
  box-shadow: 0 10px 30px rgba(2, 6, 23, .35);
}
.office-roster-title { font-size: 12px; font-weight: 700; margin-bottom: 8px; }
.office-roster ul, #officeRosterList { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.office-roster-main {
  width: 100%;
  text-align: start;
  background: transparent;
  border: 0;
  color: inherit;
  cursor: pointer;
  padding: 6px 4px;
  border-radius: 8px;
}
.office-roster-main:hover { background: rgba(148, 163, 184, .12); }
.office-roster-name, .emp-plate-name { display: block; font-weight: 700; font-size: 13px; }
.office-roster-role, .emp-plate-role { display: block; font-size: 11px; opacity: .75; }
.office-roster-status, .emp-plate-status { display: block; font-size: 11px; margin-top: 2px; }
.office-roster-status.is-working, .emp-plate-status.is-working { color: #34d399; }
.office-roster-status.is-waiting, .emp-plate-status.is-waiting { color: #fbbf24; }
.office-roster-status.is-idle, .emp-plate-status.is-idle { color: #94a3b8; }
.office-roster-empty { font-size: 12px; opacity: .75; }
.emp-plate {
  pointer-events: auto;
  min-width: 140px;
  padding: 6px 8px;
  border-radius: 10px;
  background: rgba(15, 23, 42, .88);
  color: #e2e8f0;
  border: 1px solid rgba(148, 163, 184, .35);
  text-align: center;
}
.emp-plate-actions { display: flex; gap: 4px; justify-content: center; margin-top: 4px; }
.emp-plate-actions button {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid rgba(148, 163, 184, .4);
  background: rgba(30, 41, 59, .9);
  color: #e2e8f0;
  cursor: pointer;
}
.cpk-launcher {
  position: fixed; bottom: 24px; left: 16px; z-index: 9000;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 15px; border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--brand1), var(--brand2));
  color: #fff; border: 1px solid rgba(255, 255, 255, 0.18);
  cursor: pointer; font-size: 12.5px; font-weight: 800;
  box-shadow: 0 8px 24px color-mix(in srgb, var(--brand1) 40%, transparent);
  transition: filter var(--nx-dur-fast) var(--nx-ease-out),
              scale var(--nx-dur-fast) var(--nx-ease-out);
}
.cpk-launcher:hover { filter: brightness(1.08); }
.cpk-launcher:active { scale: calc(1 - 0.04 * var(--nx-motion)); }
.cpk-launcher:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; }
.cpk-launcher .cpk-orb { width: 20px; height: 20px; box-shadow: none; }
.cpk-launcher .cpk-orb svg { width: 12px; height: 12px; }

/* --- companies gallery ------------------------------------------- */
.gallery-toolbar { display: flex; justify-content: flex-end; margin-bottom: 10px; }
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
/* Unlayered, so both beat the layered nx-card: the press stays 0.96 but on
   a fast ease-out — nx-card's 763ms springgentle scale made a frequent tap
   feel like wobbling jelly — while hover keeps its exact properties. */
.gallery-card {
  transition:
    translate var(--nx-spring-gentle-duration) var(--nx-spring-gentle),
    scale var(--nx-dur-fast) var(--nx-ease-out),
    box-shadow var(--nx-dur-slow) var(--nx-ease-out),
    border-color var(--nx-dur-base) var(--nx-ease-out);
}
.gallery-card:active { scale: calc(1 - 0.04 * var(--nx-motion)); }
.gallery-card-head { display: flex; align-items: center; gap: 10px; }
.gallery-card-avatar { font-size: 26px; line-height: 1; }
.gallery-card-id { flex: 1; min-width: 0; }
.gallery-card-name { font-weight: 800; font-size: 13.5px; }
.gallery-card-cat { font-size: 11px; color: var(--text-muted); }
.gallery-stats { display: flex; gap: 7px; flex-wrap: wrap; font-size: 11.5px; color: var(--text-muted); }
.gallery-foot-active { font-size: 11px; font-weight: 800; color: var(--accent-text); }
.gallery-foot-switch { font-size: 11px; color: var(--text-muted); }

/* ================================================================
   PHONE SHELL
   The office on a phone: a slim header with a menu button, a bottom
   sheet holding every menu, bottom tabs that are always reachable, and
   modals that take the whole screen. Desktop-only chrome — the mouse
   and keyboard hints, the hub buttons, the always-open chat panel — is
   put away rather than squeezed in.
   ================================================================ */

/* One menu everywhere: the hamburger is a first-class topbar citizen now —
   five hub buttons plus seven tool icons were more chrome than the bar (and
   the user) could carry. Everything lives in the sheet below. */
.mobile-menu-btn {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 42px; height: 42px; border-radius: var(--radius-md); cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
}
.mobile-menu-btn svg { width: 20px; height: 20px; }

/* The top bar keeps only what a CEO hits hourly: business, cameras,
   companies, identity, language, menu. The rest is one tap deeper. */
#wrapPlatformsHub, #wrapOpsHub, #wrapWorkforceHub, #wrapCeoHub,
#btnEcosystem, .sync-status-btn, #clock,
#btnToggleHud, #btnLighting, #btnAudio, #btnOpenSetupWizard {
  display: none !important;
}

/* The menu sheet: bottom sheet on narrow viewports, right drawer on wide. */
.m-sheet-overlay {
  display: flex; position: fixed; inset: 0; z-index: 85;
  background: rgba(4, 6, 12, 0.6);
  opacity: 0; pointer-events: none; transition: opacity 0.2s ease;
}
.m-sheet-overlay.open { opacity: 1; pointer-events: auto; }
.m-sheet {
  width: 100%; max-height: 86dvh; display: flex; flex-direction: column;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  border-top: 1px solid var(--border-glow);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  transform: translateY(100%); transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  padding-bottom: env(safe-area-inset-bottom);
}
.m-sheet-overlay.open .m-sheet { transform: translateY(0); }
.m-sheet-grip { width: 38px; height: 4px; border-radius: var(--radius-xs); background: color-mix(in srgb, var(--text-muted) 45%, transparent); margin: 8px auto 2px; }
.m-sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 16px 10px; border-bottom: 1px solid var(--border); }
.m-sheet-head b { font-size: 15px; }
@media (min-width: 1201px) {
  .m-sheet-overlay { align-items: stretch; justify-content: flex-start; direction: ltr; }
  .m-sheet {
    width: min(420px, 92vw); max-height: none; height: 100dvh;
    margin: 0 0 0 auto;               /* RTL app: the drawer slides from the right */
    border: 0; border-left: 1px solid var(--border-glow);
    border-radius: var(--radius-xl) 0 0 var(--radius-xl);
    transform: translateX(100%); transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    direction: rtl;
    padding-bottom: 0;
  }
  .m-sheet-overlay.open .m-sheet { transform: translateX(0); }
  .m-sheet-grip { display: none; }
}

/* Touch devices of any width: no mouse, no keyboard, no crosshair. */
@media (pointer: coarse) {
  #hint, #controlsHint, #crosshair { display: none !important; }
  button, .nav-dd-item, .mob-nav-btn, .m-sheet-item, .m-chip { touch-action: manipulation; }
}

@media (max-width: 1200px) {
  html, body {
    overscroll-behavior: none;
    -webkit-tap-highlight-color: transparent;
  }
  /* Floating panels and the chat launcher must clear the bottom tab bar
     (~60px + safe area); the mission-control panel opens from the mobile
     camera sheet, so this is a real path, not a desktop corner case. */
  .float-panel.sr-panel { bottom: calc(76px + env(safe-area-inset-bottom)); max-height: 60vh; }
  /* The chat window drops its desktop centering and becomes a near
     full-screen sheet above the tab bar. */
  .float-panel.cpk-panel {
    left: 8px; right: 8px; top: auto;
    bottom: calc(70px + env(safe-area-inset-bottom));
    margin: 0; transform: none; width: auto;
    height: min(76vh, 640px); max-height: none;
  }
  .cpk-launcher { bottom: calc(64px + env(safe-area-inset-bottom)); }
  #hint, #controlsHint, #crosshair { display: none !important; }

  /* Header: logo, the business, live status, menu. Nothing scrolls sideways. */
  #topbar {
    height: calc(52px + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) 10px 0;
    gap: 8px;
    overflow: visible;
    justify-content: space-between;
  }
  .topbar-actions-section,
  .topbar-cam-section { display: none !important; }
  .topbar-brand-section { flex: 1; min-width: 0; gap: 6px; }
  .biz-selector-wrapper { flex: 1; min-width: 0; }
  .biz-selector-btn { width: 100%; min-width: 0; min-height: 40px; }
  .biz-selector-btn .biz-info { min-width: 0; flex: 1; }
  .biz-selector-btn .biz-name { max-width: none !important; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .sync-status-btn { padding: 0 10px; min-height: 40px; }
  .sync-status-btn .sync-icon, .sync-status-btn .sync-text { display: none; }
  .mobile-menu-btn {
    display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
    width: 42px; height: 42px; border-radius: var(--radius-md); cursor: pointer;
    background: var(--surface); border: 1px solid var(--border); color: var(--text);
  }
  .mobile-menu-btn svg { width: 20px; height: 20px; }

  /* Bottom tabs, above the home indicator. */
  #mobileBottomNav {
    height: calc(60px + env(safe-area-inset-bottom));
    padding: 0 4px env(safe-area-inset-bottom);
    z-index: 70;
  }
  .mob-nav-btn { min-height: 52px; position: relative; }
  .mob-nav-btn .mob-label { font-size: 10.5px; }
  .mob-nav-btn.active::before {
    content: ''; position: absolute; top: 0; left: 28%; right: 28%; height: 3px;
    border-radius: 0 0 var(--radius-full) var(--radius-full); background: var(--accent-cyan);
  }

  #activityTicker {
    bottom: calc(68px + env(safe-area-inset-bottom)) !important;
    inset-inline-start: 10px; inset-inline-end: 10px;
    max-width: none; font-size: 11px;
  }
  #activityTicker .ticker-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }

  /* The lite-client offer sat on top of the tab bar, where it swallowed every
     tap meant for a tab. It is a compact card under the header instead.
     Placement, padding and type only — surface, border, flex and the [hidden]
     guard all come from the base class, so no !important wars. */
  .lite-offer {
    inset: calc(58px + env(safe-area-inset-top)) 10px auto 10px;
    padding: 10px 12px;
    font-size: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  }

  /* The old public chat panel became a tab of the copilot panel; the menu's
     chat entry opens that dock on the public tab. */

  /* Modals take the screen, like any app page; the header stays put. */
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal-window {
    width: 100vw !important; max-width: 100vw !important;
    height: calc(100dvh - env(safe-area-inset-top) - 8px);
    max-height: none !important;
    padding: 0;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    margin: 0;
  }
  .modal-head {
    margin: 0; padding: 12px 14px;
    position: sticky; top: 0; z-index: 2;
  }
  .modal-close, .drawer-close { width: 40px; height: 40px; }
  .modal-body { padding: 14px 14px calc(18px + env(safe-area-inset-bottom)); -webkit-overflow-scrolling: touch; }

  /* The business and language pickers open as sheets, not as popovers
     positioned against a header button. */
  .biz-dropdown, .lang-dropdown {
    top: auto !important; bottom: 0 !important;
    left: 0 !important; right: 0 !important; inset-inline-start: 0 !important;
    width: 100% !important; max-width: 100% !important;
    max-height: 70vh; overflow-y: auto;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0 !important;
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 90 !important;
  }
  .biz-dropdown .biz-list { max-height: none; }

  /* Desk labels: the name only; the hire button is the desk itself. */
  .holo-desk-card.free.mini { padding: 3px 9px; }
  .holo-desk-card.free.mini .holo-free-btn { display: none; }
  .holo-desk-card.mini .holo-desk-name, .holo-desk-card.mini .holo-name { font-size: 10px; }

  /* The sheet. */
  .m-sheet-overlay {
    display: flex; position: fixed; inset: 0; z-index: 85;
    align-items: flex-end;
    background: rgba(4, 6, 12, 0.6);
    opacity: 0; pointer-events: none; transition: opacity 0.2s ease;
  }
  .m-sheet-overlay.open { opacity: 1; pointer-events: auto; }
  .m-sheet {
    width: 100%; max-height: 86dvh; display: flex; flex-direction: column;
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
    border-top: 1px solid var(--border-glow);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    transform: translateY(100%); transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .m-sheet-overlay.open .m-sheet { transform: translateY(0); }
  .m-sheet-grip { width: 38px; height: 4px; border-radius: var(--radius-xs); background: color-mix(in srgb, var(--text-muted) 45%, transparent); margin: 8px auto 2px; }
  .m-sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 16px 10px; border-bottom: 1px solid var(--border); }
  .m-sheet-head b { font-size: 15px; }
  .m-sheet-close { width: 38px; height: 38px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: transparent; color: var(--text); font-size: 15px; cursor: pointer; }
  .m-sheet-body { overflow-y: auto; padding: 10px 12px 16px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
  .m-sheet-group { margin-bottom: 14px; }
  .m-sheet-group-title { font-size: 11.5px; font-weight: 700; color: var(--text-muted); margin: 4px 6px 6px; }
  .m-sheet-item {
    display: flex; align-items: center; width: 100%; min-height: 48px; padding: 10px 12px;
    background: var(--glass-tint); border: 1px solid var(--border); border-radius: var(--radius-md);
    color: var(--text); font: inherit; font-size: 13.5px; text-align: start; text-decoration: none;
    margin-bottom: 6px; cursor: pointer;
  }
  .m-sheet-item:active, .m-chip:active, .m-agent:active { background: color-mix(in oklab, var(--accent-cyan) 12%, transparent); }
  .m-chips { display: flex; flex-wrap: wrap; gap: 6px; }
  /* Flush variant for sheets whose next block already carries its own
     spacing — was an inline margin-bottom on the markup. */
  .m-chips--flush { margin-bottom: 12px; }
  .m-chip {
    min-height: 40px; padding: 8px 12px; border-radius: var(--radius-full); cursor: pointer;
    background: var(--glass-tint); border: 1px solid var(--border); color: var(--text);
    font: inherit; font-size: 12.5px;
  }
  .m-chip.on { background: var(--brand1); border-color: var(--brand1); color: #fff; font-weight: 700; }
  .m-agent {
    display: flex; align-items: center; gap: 10px; width: 100%; min-height: 58px; padding: 8px 12px;
    background: var(--glass-tint); border: 1px solid var(--border); border-radius: var(--radius-md);
    color: var(--text); font: inherit; text-align: start; margin-bottom: 6px; cursor: pointer;
  }
  .m-agent-avatar { font-size: 15px; font-weight: 800; color: var(--accent-text); width: 38px; height: 38px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); background: color-mix(in oklab, var(--brand1) 15%, transparent); flex-shrink: 0; }
  .m-agent-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
  .m-agent-text b { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .m-agent-text small { font-size: 11.5px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* ================================================================
   WOOCOMMERCE HUB
   A full-viewport console, not a floating panel: an icon rail, a header
   and one scrolling view, with the order drawer sliding over it.
   The hub renders a matte light theme of its own: every color lives in
   --woo-* variables scoped to .woo-hub, so the office's dark tokens are
   untouched and the light skin disappears the moment the hub closes.
   Logical properties throughout so the LTR mirror falls out for free.
   ================================================================ */
/* The office's floating copilot launcher (z 9000) must not float over a
   screen the hub owns — the hub has its own copilot panel. */
body.woo-hub-open .cpk-launcher { display: none; }
/* Nor sit under its own panel: the launcher's left column is the panel's
   column, so while the panel is open the launcher steps aside (and returns
   on close). */
body.cpk-open .cpk-launcher { display: none; }

.woo-hub {
  /* Surfaces */
  --woo-shell:   #efecf1;   /* the hub's backdrop */
  --woo-panel:   #fffffa;   /* cards, sidebars, drawers */
  --woo-panel-2: #faf7f0;   /* row/item hover */
  --woo-hair:    #eee;      /* table hairlines */
  --woo-edge:    #e4e0e7;   /* control borders (input/select/search) */
  /* Ink */
  --woo-ink:        #3a3540;  /* body text */
  --woo-ink-strong: #141118;  /* metric values / 20px heading */
  --woo-ink-muted:  #635d6e;  /* labels, subtext, chart ticks */
  /* Accents */
  --woo-cta:       #ffefd1;   /* cream — the "active/brand" signal */
  --woo-cta-hover: #ffe6b0;
  --woo-olive:     #717558;   /* olive — chart line, avatars */
  --woo-green-hi:  #cfe5c4;   /* gradient top of chart bars */
  --woo-ok-bg:     #e7f1d6;  --woo-ok-ink:    #1f6b28;
  --woo-warn-bg:   #fff3d6;  --woo-warn-ink:  #8a5a00;
  --woo-danger-bg: #fbe3dc;  --woo-danger-ink: #a1543f;
  --woo-danger-ink-strong: #9a3f2c;
  --woo-info-bg:   #e5e9f6;  --woo-info-ink:  #4a5a8a;
  --woo-focus:     #b9a44a;  /* focus ring, olive family, visible on both surfaces */
  --woo-shadow:    0 1px 2px rgba(26, 20, 35, 0.06), 0 4px 16px rgba(26, 20, 35, 0.05);
  --woo-thumb:     #dcd7e0;  /* light scrollbars */

  position: fixed; inset: 0; z-index: 500;
  display: flex; flex-direction: row;
  color: var(--woo-ink);
  background: var(--woo-shell);
  animation: wooHubIn var(--nx-spring-snappy-duration) var(--nx-spring-snappy);
}
@keyframes wooHubIn { from { opacity: 0; transform: scale(0.985); } to { opacity: 1; transform: scale(1); } }

/* The retry button only ever renders inside the hub's view, so it is scoped
   to the hub and paints with the hub's own variables. */
.woo-hub .woo-retry {
  margin-top: 10px; padding: 7px 18px; border-radius: var(--radius-full);
  border: 1px solid var(--woo-edge); background: var(--woo-panel);
  color: var(--woo-ink); font: inherit; font-size: 12px; cursor: pointer;
}
.woo-hub .woo-retry:hover { background: var(--woo-panel-2); }
.woo-hub .woo-retry:active { scale: 0.96; }

/* The icon rail — 4 sections and, at the bottom, the way out. */
.woo-rail {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  width: 56px; padding: 12px 0 10px; flex-shrink: 0;
  background: var(--woo-panel);
  border-inline-end: 1px solid var(--woo-hair);
}
.woo-rail-gap { flex: 1; }
.woo-rail-btn {
  width: 42px; height: 42px; padding: 0; border-radius: var(--radius-md);
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid transparent;
  color: var(--woo-ink-muted); cursor: pointer;
  transition: color var(--nx-dur-fast) var(--nx-ease-out),
              background-color var(--nx-dur-fast) var(--nx-ease-out),
              border-color var(--nx-dur-fast) var(--nx-ease-out);
}
.woo-rail-btn svg { width: 18px; height: 18px; }
.woo-rail-btn:hover { color: var(--woo-ink); background: var(--woo-panel-2); }
.woo-rail-btn.active {
  color: #141118; background: var(--woo-cta);
  border-color: transparent;
}
.woo-rail-close { color: var(--woo-ink-muted); }
.woo-rail-close:hover { color: var(--woo-danger-ink-strong); border-color: transparent; background: var(--woo-danger-bg); }

/* Header + the scrolling view it stands over. */
.woo-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.woo-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 18px; flex-shrink: 0;
  border-bottom: 1px solid var(--woo-hair);
  background: var(--woo-panel);
}
.woo-head-titles { display: flex; flex-direction: column; min-width: 0; }
.woo-head-title { font-size: 20px; font-weight: 600; color: var(--woo-ink-strong); }
.woo-head-sub { font-size: 11.5px; color: var(--woo-ink-muted); }
.woo-head-actions { display: flex; align-items: center; gap: 10px; min-width: 0; }
.woo-status { font-size: 11.5px; color: var(--woo-ink-muted); max-width: 40vw; }
.woo-status--err { color: var(--woo-danger-ink-strong); }
.woo-view { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 18px 24px; }
.woo-view::-webkit-scrollbar { width: 8px; }
.woo-view::-webkit-scrollbar-thumb { background: var(--woo-thumb); border-radius: var(--radius-full); }

/* Buttons — the hub's own small set. The light theme's brand is the cream
   pill; plain buttons are panels with a hairline edge. */
.woo-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--radius-md);
  border: 1px solid var(--woo-edge); background: var(--woo-panel); color: var(--woo-ink);
  font: inherit; font-size: 12px; cursor: pointer; white-space: nowrap;
  transition: background-color var(--nx-dur-fast) var(--nx-ease-out),
              border-color var(--nx-dur-fast) var(--nx-ease-out);
}
.woo-btn:hover { border-color: var(--woo-edge); background: var(--woo-panel-2); }
.woo-btn--brand {
  background: var(--woo-cta); border: none; border-radius: var(--radius-full);
  color: #141118; font-weight: 700;
}
.woo-btn--brand:hover { background: var(--woo-cta-hover); }
.woo-btn--xs { padding: 3px 10px; font-size: 11px; }

/* One focus ring for every hub control — olive, visible on panel and cream. */
.woo-hub .woo-rail-btn:focus-visible,
.woo-hub .woo-btn:focus-visible,
.woo-hub .woo-tab:focus-visible,
.woo-hub .woo-chip:focus-visible,
.woo-hub .woo-inbox-item:focus-visible,
.woo-hub .woo-chat-row:focus-visible,
.woo-hub .woo-drawer-x:focus-visible {
  outline: 2px solid var(--woo-focus); outline-offset: 1px;
}

/* Empty / loading states. */
.woo-empty {
  height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px;
  text-align: center; color: var(--woo-ink-muted); font-size: 13px;
}
.woo-empty-icon { font-size: 40px; opacity: 0.8; }
.woo-empty-hint { font-size: 11.5px; color: var(--woo-ink-muted); max-width: 420px; }
.woo-quiet { color: var(--woo-ink-muted); font-size: 12px; padding: 8px 0; }

/* Dashboard: metric cards, chart panel, live-chat widget. Simple white
   cards on the shell — the number is the colour, not a side bar. */
.woo-cards {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 16px; margin-bottom: 12px;
}
.woo-card {
  display: flex; flex-direction: column; gap: 4px;
  padding: 20px 24px; border-radius: var(--radius-lg);
  background: var(--woo-panel);
  box-shadow: var(--woo-shadow);
}
.woo-card-label { font-size: 13px; color: var(--woo-ink-muted); }
.woo-card-value { font-size: 24px; font-weight: 700; color: var(--woo-ink-strong); line-height: 1.2; }
.woo-card-unit { font-size: 10.5px; color: var(--woo-ink-muted); }

.woo-dash-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; }
.woo-panel {
  display: flex; flex-direction: column; gap: 8px;
  padding: 14px 16px; border-radius: var(--radius-lg);
  background: var(--woo-panel);
  box-shadow: var(--woo-shadow);
}
.woo-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.woo-panel-head b { font-size: 12.5px; color: var(--woo-ink); }
.woo-chart-switch { display: flex; gap: 4px; }
.woo-chip {
  padding: 3px 10px; border-radius: var(--radius-full); cursor: pointer;
  background: var(--woo-panel); border: 1px solid var(--woo-edge);
  color: var(--woo-ink-muted); font: inherit; font-size: 11px;
}
.woo-chip:hover { background: var(--woo-panel-2); color: var(--woo-ink); }
.woo-chip.on { background: var(--woo-cta); border-color: transparent; color: #141118; font-weight: 700; }

.woo-chart { width: 100%; }
.woo-chart-svg { width: 100%; height: auto; display: block; }
/* The bars take the vertical olive→light gradient defined (as SVG <defs>)
   in _chartSvg — a CSS gradient cannot fill an SVG rect. */
.woo-chart-bar { fill: url(#wooBarGrad); }
.woo-chart-bar:hover { filter: brightness(0.95); }
.woo-chart-grid { stroke: #eceade; stroke-width: 1; stroke-dasharray: 2 4; }
.woo-chart-line { stroke: var(--woo-olive); stroke-width: 1.6; stroke-linejoin: round; opacity: 0.9; }
.woo-chart-tick { fill: var(--woo-ink-muted); font-size: 9px; font-family: var(--font-mono); }

.woo-live-chat { gap: 6px; }
.woo-chat-widget { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.woo-chat-row {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 7px 8px; border-radius: var(--radius-md); cursor: pointer;
  background: transparent; border: 1px solid transparent;
  color: var(--woo-ink); font: inherit; text-align: start;
}
.woo-chat-row:hover { border-color: var(--woo-hair); background: var(--woo-panel-2); }
.woo-chat-avatar {
  width: 30px; height: 30px; flex-shrink: 0; border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--woo-ok-bg);
  color: var(--woo-olive); font-size: 13px; font-weight: 700;
}
.woo-chat-row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.woo-chat-row-text b { font-size: 12px; }
.woo-chat-row-text span { font-size: 11px; color: var(--woo-ink-muted); }
.woo-unread-dot {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--radius-full);
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--woo-danger-bg); color: var(--woo-danger-ink-strong); font-size: 10px; font-weight: 700;
}
.woo-unread-pill {
  padding: 2px 8px; border-radius: var(--radius-full); font-size: 10.5px;
  background: var(--woo-danger-bg);
  color: var(--woo-danger-ink-strong);
}

/* Toolbar: status tabs + search. */
.woo-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap; margin-bottom: 10px;
}
.woo-tabs { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.woo-tab {
  padding: 5px 11px; border-radius: var(--radius-full); cursor: pointer;
  background: var(--woo-panel); border: 1px solid var(--woo-edge);
  color: var(--woo-ink-muted); font: inherit; font-size: 11.5px;
  transition: color var(--nx-dur-fast) var(--nx-ease-out),
              border-color var(--nx-dur-fast) var(--nx-ease-out),
              background-color var(--nx-dur-fast) var(--nx-ease-out);
}
.woo-tab:hover { color: var(--woo-ink); background: var(--woo-panel-2); }
.woo-tab.active { background: var(--woo-cta); border-color: transparent; color: #141118; font-weight: 700; }
.woo-tab-count { font-size: 10px; opacity: 0.85; }
.woo-search {
  min-width: 200px; flex: 0 1 260px; padding: 7px 12px;
  border-radius: var(--radius-md); border: 1px solid var(--woo-edge);
  background: var(--woo-panel);
  color: var(--woo-ink); font: inherit; font-size: 12px;
}
.woo-search:focus { outline: none; border-color: var(--woo-focus); }
.woo-search:focus-visible { outline: 2px solid var(--woo-focus); outline-offset: -1px; }

/* Tables — light, sticky-headed, horizontally scrollable when narrow. */
.woo-table-wrap {
  border: none; border-radius: var(--radius-lg);
  overflow: auto; background: var(--woo-panel);
  box-shadow: var(--woo-shadow);
}
.woo-table { width: 100%; border-collapse: collapse; font-size: 13px; color: var(--woo-ink); }
.woo-table th {
  position: sticky; top: 0; z-index: 1;
  padding: 9px 12px; text-align: start; white-space: nowrap;
  font-size: 12px; font-weight: 700; color: var(--woo-ink-muted);
  background: var(--woo-panel);
  border-bottom: 1px solid var(--woo-hair);
}
.woo-table td {
  padding: 9px 12px; border-bottom: 1px solid var(--woo-hair);
  vertical-align: middle;
}
.woo-table tbody tr:last-child td { border-bottom: none; }
.woo-table--tight th, .woo-table--tight td { padding: 6px 8px; font-size: 11.5px; }
.woo-order-row, .woo-product-row, .woo-customer-row { cursor: default; }
.woo-order-row:hover td { background: var(--woo-panel-2); }
.woo-table-empty { text-align: center; color: var(--woo-ink-muted); padding: 26px 12px !important; }
.woo-sub { display: block; font-size: 10.5px; color: var(--woo-ink-muted); }
.woo-strong { font-weight: 700; color: var(--woo-ink-strong); }
.num { direction: ltr; unicode-bidi: isolate; }
.woo-ltr { direction: ltr; unicode-bidi: isolate; }
.woo-sku { font-family: var(--font-mono); font-size: 10.5px; color: var(--woo-ink-muted); }

/* Status chips — one hue per WooCommerce status, in the hub's palette. */
.woo-st {
  display: inline-flex; align-items: center; padding: 2px 9px;
  border-radius: var(--radius-full); font-size: 10.5px; font-weight: 700; white-space: nowrap;
}
.woo-st--pending { background: var(--woo-warn-bg); color: var(--woo-warn-ink); }
.woo-st--processing { background: var(--woo-info-bg); color: var(--woo-info-ink); }
.woo-st--onhold { background: var(--woo-panel-2); color: var(--woo-ink-muted); }
.woo-st--completed { background: var(--woo-ok-bg); color: var(--woo-ok-ink); }
.woo-st--cancelled { background: var(--woo-danger-bg); color: var(--woo-danger-ink-strong); }

/* The order drawer — over the view, from the right, like the office's own.
   The `right: 0` + `translateX(105%)` pair is physical on purpose: X runs
   physically rightwards in both directions, so it slides correctly in RTL
   too. Only colors changed in the light theme. */
.woo-drawer {
  position: absolute; top: 0; bottom: 0; right: 0; z-index: 5;
  width: min(430px, 100%);
  display: flex; flex-direction: column;
  background: var(--woo-panel);
  border-left: 1px solid var(--woo-hair);
  box-shadow: 0 12px 40px rgba(26, 20, 35, 0.12);
  transform: translateX(105%);
  transition: transform var(--nx-spring-gentle-duration) var(--nx-spring-gentle);
}
.woo-drawer.open { transform: translateX(0); }
.woo-drawer-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 14px 16px; border-bottom: 1px solid var(--woo-hair); flex-shrink: 0;
}
.woo-drawer-head b { color: var(--woo-ink-strong); }
.woo-drawer-x {
  width: 32px; height: 32px; padding: 0; border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--woo-panel); border: 1px solid var(--woo-edge);
  color: var(--woo-ink-muted); cursor: pointer;
}
.woo-drawer-x:hover { color: var(--woo-ink); background: var(--woo-panel-2); }
.woo-drawer-x svg { width: 14px; height: 14px; }
.woo-drawer-body { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }
.woo-drawer-body::-webkit-scrollbar { width: 6px; }
.woo-drawer-body::-webkit-scrollbar-thumb { background: var(--woo-thumb); border-radius: var(--radius-full); }
.woo-drawer-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12.5px; }
.woo-drawer-sec { margin-top: 10px; font-size: 11.5px; color: var(--woo-ink-muted); }
.woo-address { font-style: normal; font-size: 12px; line-height: 1.8; color: var(--woo-ink); }
.woo-totals { margin: 0; display: flex; flex-direction: column; gap: 4px; }
.woo-totals div { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-size: 12px; }
.woo-totals dt { color: var(--woo-ink-muted); }
.woo-totals dd { margin: 0; font-variant-numeric: tabular-nums; }
.woo-totals--grand { margin-top: 4px; padding-top: 6px; border-top: 1px solid var(--woo-hair); }
.woo-totals--grand dt { color: var(--woo-ink); font-weight: 700; }
.woo-totals--grand dd { font-weight: 700; color: var(--woo-ok-ink); }
.woo-totals--grand small { color: var(--woo-ink-muted); font-weight: 400; }
.woo-note {
  margin: 0; padding: 8px 10px; border-radius: var(--radius-md);
  background: var(--woo-warn-bg);
  color: var(--woo-ink);
  font-size: 11.5px; line-height: 1.7;
}
.woo-status-label { margin-top: 12px; font-size: 11.5px; color: var(--woo-ink-muted); }
.woo-select {
  width: 100%; padding: 8px 10px; margin-top: 4px;
  border-radius: var(--radius-md); border: 1px solid var(--woo-edge);
  background: var(--woo-panel);
  color: var(--woo-ink); font: inherit; font-size: 12.5px;
}
.woo-select:focus { outline: none; border-color: var(--woo-focus); }

/* The three-panel copilot: inbox · thread · customer side. Three white
   panels on the shell; "active" is cream everywhere in the hub. */
.woo-chat {
  display: grid; grid-template-columns: minmax(0, 260px) minmax(0, 1fr) minmax(0, 240px);
  gap: 12px; height: 100%; min-height: 0;
}
.woo-inbox, .woo-side {
  display: flex; flex-direction: column; gap: 4px; min-height: 0;
  padding: 10px; border-radius: var(--radius-lg);
  background: var(--woo-panel);
  box-shadow: var(--woo-shadow); overflow-y: auto;
}
.woo-inbox::-webkit-scrollbar, .woo-side::-webkit-scrollbar { width: 6px; }
.woo-inbox::-webkit-scrollbar-thumb, .woo-side::-webkit-scrollbar-thumb { background: var(--woo-thumb); border-radius: var(--radius-full); }
.woo-inbox-title { font-size: 11.5px; color: var(--woo-ink-muted); padding: 0 4px 4px; }
.woo-inbox-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 7px 8px; border-radius: var(--radius-md); cursor: pointer;
  background: transparent; border: 1px solid transparent;
  color: var(--woo-ink); font: inherit; text-align: start;
}
.woo-inbox-item:hover { background: var(--woo-panel-2); }
.woo-inbox-item.active { background: var(--woo-cta); border-color: transparent; color: #141118; }
.woo-inbox-item.active .woo-chat-row-text span { color: rgba(20, 17, 24, 0.65); }

.woo-thread {
  display: flex; flex-direction: column; min-height: 0;
  border-radius: var(--radius-lg);
  background: var(--woo-panel);
  box-shadow: var(--woo-shadow);
}
.woo-thread-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  padding: 10px 14px; border-bottom: 1px solid var(--woo-hair); flex-shrink: 0;
}
.woo-thread-head b { color: var(--woo-ink); }
.woo-msgs {
  flex: 1; min-height: 0; overflow-y: auto; padding: 12px;
  display: flex; flex-direction: column; gap: 8px;
}
.woo-msgs::-webkit-scrollbar { width: 6px; }
.woo-msgs::-webkit-scrollbar-thumb { background: var(--woo-thumb); border-radius: var(--radius-full); }
.woo-bubble {
  max-width: 78%; padding: 8px 12px; border-radius: var(--radius-lg);
  display: flex; flex-direction: column; gap: 3px;
  font-size: 12px; line-height: 1.7;
}
.woo-bubble--customer {
  align-self: flex-start;
  background: var(--woo-panel-2); color: var(--woo-ink);
  border-start-start-radius: var(--radius-sm);
}
.woo-bubble--ai {
  align-self: flex-start;
  background: var(--woo-panel); color: var(--woo-ink);
  border: 1px solid var(--woo-edge);
  border-start-start-radius: var(--radius-sm);
}
.woo-bubble--operator {
  align-self: flex-end;
  background: var(--woo-cta); color: #141118;
  border-start-end-radius: var(--radius-sm);
}
.woo-bubble--pending { opacity: 0.6; }
.woo-bubble-who { font-size: 10px; font-weight: 700; color: var(--woo-ink-muted); }
.woo-bubble--operator .woo-bubble-who { color: rgba(20, 17, 24, 0.65); }
.woo-bubble-order {
  font-size: 10.5px; color: var(--woo-info-ink);
  border-top: 1px solid var(--woo-hair); padding-top: 4px;
}
.woo-tool-chip {
  align-self: flex-start;
  font-size: 10.5px; color: var(--woo-ink-muted);
  background: var(--woo-panel-2);
  border: 1px dashed var(--woo-edge);
  border-radius: var(--radius-full);
  padding: 3px 10px; opacity: .9;
}
.woo-composer {
  display: flex; align-items: flex-end; gap: 8px; flex-shrink: 0;
  padding: 10px 12px; border-top: 1px solid var(--woo-hair);
}
.woo-composer-input {
  flex: 1; resize: none; max-height: 110px;
  padding: 8px 12px; border-radius: var(--radius-md);
  border: 1px solid var(--woo-edge);
  background: var(--woo-panel);
  color: var(--woo-ink); font: inherit; font-size: 12px; line-height: 1.6;
}
.woo-composer-input:focus { outline: none; border-color: var(--woo-focus); }

.woo-side-card {
  display: flex; flex-direction: column; gap: 3px;
  padding: 10px 12px; border-radius: var(--radius-md);
  background: var(--woo-panel-2); border: 1px solid var(--woo-hair);
  color: var(--woo-ink);
}
.woo-side-sec { margin-top: 8px; font-size: 11.5px; color: var(--woo-ink-muted); }
.woo-side-order {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  padding: 6px 8px; margin-top: 4px; border-radius: var(--radius-sm);
  background: var(--woo-panel-2); font-size: 11px;
}

/* The hub on a phone: the rail moves to the bottom, the chat stacks, the
   customer side panel folds away. Nothing overlaps the shell's tab bar. */
@media (max-width: 768px) {
  .woo-hub { flex-direction: column; }
  .woo-rail {
    order: 2; flex-direction: row; width: auto; height: 54px;
    padding: 0 10px calc(env(safe-area-inset-bottom) * 0.6);
    border-inline-end: none; border-block-start: 1px solid var(--woo-hair);
  }
  .woo-main { order: 1; min-height: 0; }
  .woo-head { padding: 9px 12px; }
  .woo-head-actions .woo-btn--ghost { display: none; } /* the rail's ✕ is the way out */
  .woo-view { padding: 12px 10px 16px; }
  .woo-dash-grid { grid-template-columns: minmax(0, 1fr); }
  .woo-toolbar { align-items: stretch; flex-direction: column; }
  .woo-search { flex: 1 1 auto; min-width: 0; }
  .woo-chat { grid-template-columns: minmax(0, 1fr); }
  .woo-side { display: none; }
  .woo-inbox { max-height: 132px; }
  .woo-bubble { max-width: 92%; }
}

/* ================================================================
   JS-RENDERED CHROME, TOKENIZED
   Surfaces main.js used to build with inline hex styles: the no-business
   gate, the agent-goal trace and the ecosystem badge. Colors and radii
   come from the root aliases only.
   ================================================================ */
/* No-business gate (z 9999 — top of the ladder, with auth). */
.gate-overlay {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(6px);
}
.gate-card {
  max-width: 420px; padding: 28px;
  border-radius: var(--radius-lg);
  background: var(--surface); color: var(--text);
  font-family: inherit; text-align: center;
  border: 1px solid var(--border-strong);
}
.gate-card h2 { margin: 0 0 12px; font-size: 18px; }
.gate-card p { margin: 0 0 16px; font-size: 13px; line-height: 1.9; color: var(--text-muted); }

/* Agent-goal trace (brain run panel). */
.trace-step { border-inline-start: 2px solid var(--accent-blue); padding: 6px 8px; margin: 6px 0; }
.trace-final {
  padding: 10px; background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-md); margin-top: 8px; line-height: 1.8;
}
.trace-final b { color: var(--info-text); }
.trace-action { color: var(--info-text); }
.trace-thought { color: var(--text-muted); }
.trace-live { color: var(--success-text); }
.trace-result { font-size: 11px; }
.trace-result.ok { color: var(--success-text); }
.trace-result.warn { color: var(--accent-amber); }
.trace-offline { color: var(--danger-text); }
.trace-error {
  color: var(--danger-text); padding: 8px;
  border: 1px solid color-mix(in srgb, var(--danger-text) 40%, transparent);
  border-radius: var(--radius-sm);
}

/* Ecosystem "all online" badge. */
.badge-count.badge-online { background: var(--accent-emerald); }

/* Ecosystem matrix service glyph: a two-letter monogram chip in the service
   color — a designed mark instead of an emoji standing in for an icon. */
.voice-live { display: flex; flex-direction: column; gap: 10px; }
.voice-live-status { margin: 0; font-weight: 700; }
.voice-live-transcript {
  min-block-size: 72px;
  max-block-size: 240px;
  overflow: auto;
  padding-block: 8px;
  padding-inline: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-align: start;
}
.voice-live-transcript p { margin: 0 0 6px; }
.voice-live-error {
  margin: 0;
  color: var(--danger-text, #fca5a5);
  text-align: start;
}

.eco-glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  border-radius: var(--radius-sm, 8px);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  direction: ltr;
}

/* Spaces library. Logical properties so the same layout works in RTL and LTR. */
.spaces-panel { display: flex; flex-direction: column; gap: 10px; text-align: start; }
.spaces-tabs { display: flex; gap: 8px; }
.spaces-note { margin: 0; }
.spaces-layout { display: flex; gap: 12px; align-items: flex-start; }
.spaces-list { flex: 0 0 34%; min-width: 0; max-height: 480px; overflow: auto; display: flex; flex-direction: column; gap: 6px; }
.spaces-main, .spaces-skills { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.spaces-skills { max-height: 520px; overflow: auto; }
.spaces-item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  width: 100%; text-align: start;
  padding: 8px 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: transparent; color: inherit;
  cursor: pointer;
}
.spaces-item.is-active { border-color: var(--border-focus); background: var(--surface2, rgba(255,255,255,0.04)); }
.spaces-label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.spaces-input {
  width: 100%; box-sizing: border-box;
  text-align: start; unicode-bidi: plaintext;
  background: var(--surface2, #0b1020); color: inherit;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 10px; font: inherit;
}
.spaces-main textarea { min-height: 180px; resize: vertical; }
.spaces-short { min-height: 64px; }
.spaces-preview {
  max-height: 160px; overflow: auto; text-align: start;
  padding: 8px 10px; border: 1px dashed var(--border); border-radius: var(--radius-sm);
}
.spaces-preview h1, .spaces-preview h2, .spaces-preview h3 { margin: 0.4em 0; font-size: 1em; }
.spaces-preview p { margin: 0.3em 0; }
.spaces-preview ul { margin: 0.3em 0; padding-inline-start: 1.2em; }
.spaces-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.spaces-skill { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.spaces-skill-head { display: flex; gap: 8px; align-items: center; }
@media (max-width: 720px) {
  .spaces-layout { flex-direction: column; }
  .spaces-list { flex-basis: auto; width: 100%; max-height: 200px; }
}
