/* Theme variables: dark is default, light overrides via data-theme. */
:root,
:root[data-theme="dark"] {
  --bg: #25272c;
  --surface: #2d3036;
  --card: #202329;
  --accent: #b8f7e4;
  --accent-ink: #b8f7e4;            /* accent used as text/icon color */
  --accent-soft: rgba(184, 247, 228, 0.12);
  --accent-border: rgba(184, 247, 228, 0.45);
  --on-accent: #25272c;             /* text on accent-filled elements */
  --text: #f2f8f5;
  --muted: #9ca6a2;
  --border: #3a3e45;
  --green: #2fbf71;
  --red: #e5484d;
  --amber: #f0a63a;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  --scrollbar-thumb: #344e57;
  --scrollbar-track: transparent;
  --scrollbar-thumb-hover: #4d6870;
}

:root[data-theme="light"] {
  --bg: #fafbfa;
  --surface: #f1f5f3;
  --card: #ffffff;
  --accent: #b8f7e4;
  --accent-ink: #17795e;
  --accent-soft: rgba(23, 121, 94, 0.08);
  --accent-border: rgba(23, 121, 94, 0.35);
  --on-accent: #25272c;
  --text: #25272c;
  --muted: #68736f;
  --border: #dde5e1;
  --green: #188a52;
  --red: #d02c31;
  --amber: #b26a00;
  --scrollbar-thumb: #d5d9de;
  --scrollbar-track: transparent;
  --scrollbar-thumb-hover: #c4c8cd;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
html::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}
html::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 999px;
}
html::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}
html[data-theme="light"]::-webkit-scrollbar {
  width: 3px;
  height: 3px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  padding: 20px clamp(16px, 4vw, 48px) 40px;
  transition: background 0.2s ease, color 0.2s ease;
}

/* ---------- header ---------- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo { width: 40px; height: 40px; }
.brand h1 { font-size: 18px; font-weight: 650; letter-spacing: 0.2px; }
.subtitle { color: var(--muted); font-size: 12px; }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  justify-content: flex-end;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
body.page-ai .wake-picker,
body.page-ai .llm-family-picker,
body.page-ai .ai-apps-picker {
  position: relative;
  z-index: 80;
}
body.page-ai .wake-picker:has(.asset-picker-menu:not(.hidden)),
body.page-ai .llm-family-picker:has(.llm-family-menu:not(.hidden)),
body.page-ai .llm-family-picker:has(.llm-family-config:not(.hidden)),
body.page-ai .ai-apps-picker:has(.ai-apps-menu:not(.hidden)) {
  z-index: 120;
}
body.page-ai .wake-picker.tabs,
body.page-ai .llm-family-picker.tabs,
body.page-ai .ai-apps-picker.tabs {
  background: #071016;
  border: 1px solid #253238;
  border-radius: 8px;
  padding: 3px;
}
body.page-ai .wake-picker .tab,
body.page-ai .llm-family-btn,
body.page-ai .ai-apps-btn {
  color: #799598;
}
body.page-ai .wake-picker .tab.active,
body.page-ai .llm-family-btn,
body.page-ai .ai-apps-btn {
  background: #0c1c24;
  color: #a9d8cc;
  box-shadow: inset 0 0 0 1px #304247;
}
body.page-ai .wake-picker .asset-picker-btn { display: inline-flex; }
body.page-ai .wake-picker .asset-picker-btn,
body.page-ai .llm-family-btn,
body.page-ai .ai-apps-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
body.page-ai .studio-runtime-tools {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  position: relative;
  z-index: auto;
}
body.page-ai .llm-family-btn,
body.page-ai .ai-apps-btn {
  max-width: 180px;
  min-width: 0;
  padding: 4px 10px;
  font-size: 12px;
  border: 1px solid transparent;
  cursor: pointer;
}
body.page-ai .llm-family-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
body.page-ai .wake-picker .asset-picker-menu {
  background: #071016;
  border-color: #253238;
}
body.page-ai .wake-picker .asset-picker-menu:not(.hidden) { display: flex; }
html[data-theme="light"] body.page-ai .wake-picker.tabs,
html[data-theme="light"] body.page-ai .llm-family-picker.tabs,
html[data-theme="light"] body.page-ai .ai-apps-picker.tabs {
  background: #f8f9fa;
  border-color: #dadce0;
}
html[data-theme="light"] body.page-ai .wake-picker .tab,
html[data-theme="light"] body.page-ai .llm-family-btn,
html[data-theme="light"] body.page-ai .ai-apps-btn { color: #5f6368; }
html[data-theme="light"] body.page-ai .wake-picker .tab.active,
html[data-theme="light"] body.page-ai .llm-family-btn,
html[data-theme="light"] body.page-ai .ai-apps-btn {
  background: #ffffff;
  color: #17795e;
  box-shadow: inset 0 0 0 1px #dadce0;
}
html[data-theme="light"] body.page-ai .wake-picker .asset-picker-menu {
  background: #f8f9fa;
  border-color: #dadce0;
}
@media (min-width: 1101px) {
  body.page-ai #wake-card { display: none; }
  body.page-ai .wake-picker .asset-picker-menu {
    right: 0;
    left: auto;
  }
}
.site-nav { position: relative; flex-shrink: 0; z-index: 80; }
.site-nav summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  pointer-events: auto;
  appearance: none;
  -webkit-appearance: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}
.site-nav summary.btn,
.site-nav summary.btn:hover,
.site-nav summary.btn:focus,
.site-nav summary.btn:focus-visible,
.site-nav summary.btn:active,
.site-nav[open] > summary.btn,
.site-nav[open] summary.btn {
  color: #b8f7e4;
  background: rgba(184, 247, 228, 0.14);
  background-color: rgba(184, 247, 228, 0.14);
  border: 1px solid rgba(184, 247, 228, 0.45);
  border-radius: 5px;
  justify-content: center;
  box-sizing: border-box;
  flex: 0 0 36px;
  width: 36px;
  min-width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  box-shadow: none;
  filter: none;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}
html[data-theme="light"] .site-nav summary.btn,
html[data-theme="light"] .site-nav summary.btn:hover,
html[data-theme="light"] .site-nav summary.btn:focus,
html[data-theme="light"] .site-nav summary.btn:focus-visible,
html[data-theme="light"] .site-nav summary.btn:active,
html[data-theme="light"] .site-nav[open] > summary.btn,
html[data-theme="light"] .site-nav[open] summary.btn {
  background: rgba(184, 247, 228, 0.55);
  background-color: rgba(184, 247, 228, 0.55);
  border: 1px solid rgba(23, 121, 94, 0.35);
  color: #17795e;
  filter: none;
  -webkit-tap-highlight-color: transparent;
}
@media (hover: none), (pointer: coarse) {
  html body .site-nav summary.btn,
  html body .site-nav summary.btn:hover,
  html body .site-nav summary.btn:focus,
  html body .site-nav summary.btn:focus-visible,
  html body .site-nav summary.btn:active,
  html body .site-nav[open] summary.btn {
    background: rgba(184, 247, 228, 0.14);
    background-color: rgba(184, 247, 228, 0.14);
    filter: none;
    -webkit-tap-highlight-color: transparent;
  }
  html[data-theme="light"] body .site-nav summary.btn,
  html[data-theme="light"] body .site-nav summary.btn:hover,
  html[data-theme="light"] body .site-nav summary.btn:focus,
  html[data-theme="light"] body .site-nav summary.btn:focus-visible,
  html[data-theme="light"] body .site-nav summary.btn:active,
  html[data-theme="light"] body .site-nav[open] summary.btn {
    background: rgba(184, 247, 228, 0.55);
    background-color: rgba(184, 247, 228, 0.55);
    filter: none;
  }
}
.site-nav summary .icon-menu {
  display: block;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}
.site-nav summary::-webkit-details-marker { display: none; }
.site-nav-list {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 80;
  min-width: 168px;
  display: grid;
  gap: 2px;
  padding: 8px;
  background: #0f181e;
  border: 1px solid #3a535c;
  border-radius: 12px;
  box-shadow: 0 20px 56px rgba(0, 0, 0, 0.55);
}
.site-nav-list a {
  color: #d9e8e9;
  text-decoration: none;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 650;
}
.site-nav-list a:hover,
.site-nav-list a[aria-current="page"] {
  background: rgba(184, 247, 228, 0.14);
  color: #b8f7e4;
}
.site-nav-list > .site-nav-logout {
  appearance: none;
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  box-shadow: none;
  cursor: pointer;
  color: #d9e8e9;
  padding: 8px 10px;
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
  font-weight: 650;
}
.site-nav-list > .site-nav-logout:hover {
  background: rgba(184, 247, 228, 0.14);
  color: #b8f7e4;
  filter: none;
}
.site-nav-list > .btn.icon.site-nav-theme {
  justify-self: start;
  width: auto;
  height: auto;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 8px 10px;
  background: transparent;
  border: none;
  border-radius: 8px;
  box-shadow: none;
  color: #b8f7e4;
}
.site-nav-list > .btn.icon.site-nav-theme:hover {
  background: rgba(184, 247, 228, 0.14);
  filter: none;
}
.site-nav-list > .btn.icon.site-nav-theme svg { stroke: #b8f7e4; }
html[data-theme="light"] .site-nav-list {
  background: #ffffff;
  border-color: #dadce0;
  box-shadow: 0 1px 2px rgba(60, 64, 67, 0.12), 0 2px 6px rgba(60, 64, 67, 0.08);
}
html[data-theme="light"] .site-nav-list a { color: #202124; }
html[data-theme="light"] .site-nav-list a:hover,
html[data-theme="light"] .site-nav-list a[aria-current="page"] {
  background: rgba(184, 247, 228, 0.55);
  color: #17795e;
}
html[data-theme="light"] .site-nav-list > .site-nav-logout { color: #202124; }
html[data-theme="light"] .site-nav-list > .site-nav-logout:hover {
  background: rgba(184, 247, 228, 0.55);
  color: #17795e;
}
html[data-theme="light"] .site-nav-list > .btn.icon.site-nav-theme {
  background: transparent;
  border: none;
  color: #17795e;
}
html[data-theme="light"] .site-nav-list > .btn.icon.site-nav-theme:hover {
  background: rgba(184, 247, 228, 0.55);
}
html[data-theme="light"] .site-nav-list > .btn.icon.site-nav-theme svg { stroke: #17795e; }
.site-nav-cluster {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
body.page-ai .ai-mobile-bar .site-nav-end {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
body.page-ai .ai-mobile-bar .site-nav:not([open]) .site-nav-list {
  display: none;
}
/* AI Studio only, old phones: Wake/Model/AI Apps on row 1, ? then Menu on row 2. */
@media (max-width: 1100px) {
  html[data-ai-old-nav] body.page-ai .ai-mobile-bar {
    flex-wrap: wrap;
  }
  html[data-ai-old-nav] body.page-ai .ai-mobile-bar .studio-runtime-tools {
    margin-right: 0;
  }
  html[data-ai-old-nav] body.page-ai .ai-mobile-bar .site-nav-end {
    flex: 0 0 100%;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 6px;
  }
  html[data-ai-old-nav] body.page-ai .ai-mobile-bar .site-nav-end .ai-mobile-tour {
    order: -1;
    position: relative;
    z-index: 3;
  }
  html[data-ai-old-nav] body.page-ai .ai-mobile-bar .site-nav-end .site-nav {
    z-index: auto;
  }
  html[data-ai-old-nav] body.page-ai .ai-mobile-bar .site-nav-end .site-nav[open] {
    z-index: 80;
  }
}
@media (max-width: 380px) and (min-height: 820px) {
  body.page-ai .ai-mobile-bar {
    flex-wrap: wrap;
  }
  body.page-ai .ai-mobile-bar .studio-runtime-tools {
    margin-right: 0;
  }
  body.page-ai .ai-mobile-bar .site-nav-end {
    flex: 0 0 100%;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 6px;
  }
  body.page-ai .ai-mobile-bar .site-nav-end .ai-mobile-tour {
    order: -1;
    position: relative;
    z-index: 3;
  }
  body.page-ai .ai-mobile-bar .site-nav-end .site-nav {
    z-index: auto;
  }
  body.page-ai .ai-mobile-bar .site-nav-end .site-nav[open] {
    z-index: 80;
  }
}
.home-lead-row,
.home-logout-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
@media (min-width: 1101px) {
  body.page-home .topbar-right,
  body.page-ai .topbar-right,
  body.page-charts .topbar-right,
  body.page-devices .topbar-right,
  body.page-guide .topbar-right { padding-right: 0; }
  body.page-home .home-logout-row {
    position: relative;
    top: auto;
    right: auto;
    gap: 8px;
    margin: 0;
  }
  body.page-home .site-nav {
    position: relative;
    top: auto;
    right: auto;
    z-index: 80;
  }
  body.page-home .home-logout-row .site-tour,
  body.page-ai .topbar .site-tour,
  body.page-charts .site-tour,
  body.page-devices .site-tour,
  body.page-guide .site-tour { display: flex; }
  body.page-home #ninjaTourRelaunch,
  body.page-ai #ninjaTourRelaunch,
  body.page-charts #ninjaTourRelaunch,
  body.page-devices #ninjaTourRelaunch,
  body.page-guide #ninjaTourRelaunch { display: none !important; }
  body.page-home .home-lead-row > #btn-theme {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    padding: 0;
    box-sizing: border-box;
  }
  body.page-home .home-lead-row > a.btn {
    height: 36px;
    min-height: 36px;
    padding-top: 0;
    padding-bottom: 0;
    box-sizing: border-box;
  }
}
/* Home only: tablet / mid desktop uses the same stacked header as phones. */
@media (max-width: 1100px) {
  body.page-home .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin-bottom: 0;
  }
  body.page-home .brand h1 { font-size: 16px; }
  body.page-home .topbar-right {
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: 0;
    max-width: 100%;
    min-width: 0;
    padding-right: 0;
  }
  body.page-home .rulebook-info {
    position: static;
    flex: 1 1 100%;
    order: 1;
    min-width: 0;
    max-width: none;
    width: 100%;
    overflow: hidden;
    pointer-events: auto;
  }
  body.page-home .topbar-actions {
    flex: 1 1 100%;
    order: 2;
    display: flex;
    width: 100%;
    justify-content: space-between;
    align-items: center;
    flex-wrap: nowrap;
    gap: 5px;
    margin-top: 16px;
    margin-bottom: 16px;
    min-height: 44px;
    box-sizing: border-box;
  }
  body.page-home .site-nav {
    position: relative;
    top: auto;
    right: auto;
  }
  body.page-home .home-logout-row { gap: 8px; }
  body.page-home .topbar-actions .home-lead-row > a.btn {
    flex: 0 1 auto;
    min-width: max-content;
    justify-content: center;
    padding-left: 8px;
    padding-right: 8px;
    text-align: center;
    white-space: nowrap;
  }
  body.page-home .topbar-actions .home-lead-row > .btn.icon {
    flex: 0 0 auto;
    width: 28px;
    height: 36px;
    min-width: 28px;
    min-height: 36px;
    padding: 0;
    border-radius: 8px;
    box-sizing: border-box;
  }
  body.page-home .topbar-actions .home-lead-row > .btn.icon svg {
    width: 14px;
    height: 14px;
  }
  body.page-home .ticker-field { margin-top: 0; }
  body.page-home .chip-marquee {
    mask-image: linear-gradient(90deg, transparent, #000 14px, #000 calc(100% - 6px), transparent);
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 14px, #000 calc(100% - 6px), transparent);
  }
}
.site-tour { display: none; }
.site-tour,
#ninjaTourRelaunch {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(184, 247, 228, 0.45);
  background: rgba(184, 247, 228, 0.14);
  color: #b8f7e4;
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: none;
}
html[data-theme="light"] .site-tour,
html[data-theme="light"] #ninjaTourRelaunch {
  background: rgba(184, 247, 228, 0.55);
  border: 1px solid rgba(23, 121, 94, 0.35);
  color: #17795e;
}
.site-tour:hover,
#ninjaTourRelaunch:hover { filter: brightness(1.08); }
.topbar-actions > .btn,
.topbar-actions > a.btn,
.topbar-actions > .llm-model-wrap { flex-shrink: 0; }

.llm-model-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.llm-model-wrap select {
  max-width: 148px;
  min-width: 108px;
  padding: 5px 8px;
  font-size: 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}
.llm-model-wrap select:focus {
  outline: 1px solid var(--accent-border);
}
.llm-model-wrap select:disabled {
  opacity: 0.65;
}
.llm-family-picker { position: relative; z-index: 90; }
.llm-family-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 220px;
  min-width: 108px;
  padding: 5px 8px;
  font-size: 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}
.llm-family-btn[aria-disabled="true"] { opacity: 0.65; cursor: default; }
.llm-family-menu,
.ai-apps-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 220px;
  display: none;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  background: #071016;
  border: 1px solid #253238;
  border-radius: 8px;
  z-index: 95;
}
.llm-family-config {
  position: absolute;
  top: calc(100% + 6px);
  left: 100%;
  right: auto;
  margin-left: 6px;
  min-width: 240px;
  display: none;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  background: #071016;
  border: 1px solid #253238;
  border-radius: 8px;
  z-index: 96;
}
.llm-family-menu:not(.hidden),
.llm-family-config:not(.hidden),
.ai-apps-menu:not(.hidden) { display: flex; }
.llm-family-group {
  color: #799598;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 6px 8px 2px;
}
.llm-family-menu > .llm-family-group {
  color: #ffffff;
}
.llm-family-row,
.ai-apps-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  text-align: left;
  background: transparent;
  color: #a9d8cc;
  border: 0;
  border-radius: 6px;
  padding: 6px 8px;
  cursor: pointer;
}
.llm-family-row:hover,
.llm-family-row:focus,
.ai-apps-row:hover { background: #0c1c24; }
.llm-family-row[disabled] { opacity: 0.55; cursor: default; }
.llm-family-config label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #f2f8f5;
  font-size: 12px;
  padding: 3px 6px;
}
.llm-family-config .llm-family-note {
  color: #799598;
  font-size: 11px;
  padding: 4px 6px;
}
.ai-apps-wrap { position: relative; }
.ai-apps-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.ai-apps-menu .btn,
.ai-apps-menu .btn[data-ai-connect] {
  background: rgba(184, 247, 228, 0.14);
  border: 1px solid rgba(184, 247, 228, 0.45);
  color: #b8f7e4;
  border-radius: 8px;
  font-weight: 650;
  padding: 6px 14px;
  font-size: 12px;
}
.ai-apps-menu .btn[data-ai-act="disconnect"]:disabled,
.ai-apps-menu .btn[data-ai-act="disconnect"][aria-disabled="true"] {
  opacity: 0.38;
  cursor: not-allowed;
  pointer-events: none;
  background: rgba(121, 149, 152, 0.12);
  border-color: rgba(121, 149, 152, 0.28);
  color: #799598;
}
.ai-apps-menu .btn[data-ai-act="disconnect"]:not(:disabled) {
  background: rgba(229, 72, 77, 0.16);
  border-color: rgba(229, 72, 77, 0.55);
  color: #e5484d;
}
html[data-theme="light"] .llm-family-menu,
html[data-theme="light"] .llm-family-config,
html[data-theme="light"] .ai-apps-menu {
  background: #f8f9fa;
  border-color: #dadce0;
}
html[data-theme="light"] .llm-family-row,
html[data-theme="light"] .ai-apps-row { color: #17795e; }
html[data-theme="light"] .llm-family-menu > .llm-family-group { color: #202124; }
html[data-theme="light"] .ai-apps-menu .btn,
html[data-theme="light"] .ai-apps-menu .btn[data-ai-connect] {
  background: rgba(184, 247, 228, 0.55);
  border: 1px solid rgba(23, 121, 94, 0.35);
  color: #17795e;
}
html[data-theme="light"] .ai-apps-menu .btn[data-ai-act="disconnect"]:disabled,
html[data-theme="light"] .ai-apps-menu .btn[data-ai-act="disconnect"][aria-disabled="true"] {
  background: rgba(121, 149, 152, 0.12);
  border-color: rgba(121, 149, 152, 0.28);
  color: #5f6368;
}
html[data-theme="light"] .ai-apps-menu .btn[data-ai-act="disconnect"]:not(:disabled) {
  background: rgba(229, 72, 77, 0.12);
  border-color: rgba(229, 72, 77, 0.5);
  color: #c62828;
}

.rulebook-info {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

/* Seamless autoplay ticker for header status chips */
.chip-marquee {
  overflow: hidden;
  width: 100%;
}
.chip-track {
  display: flex;
  width: max-content;
  animation: chip-marquee 28s linear infinite;
  will-change: transform;
}
.chip-marquee:hover .chip-track,
.chip-marquee:focus-within .chip-track {
  animation-play-state: paused;
}
.chip-set {
  display: flex;
  gap: 8px;
  padding-right: 8px;
  flex-shrink: 0;
}
.chip {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.chip strong { color: var(--text); font-weight: 600; }
.chip.ok { border-color: rgba(47, 191, 113, 0.5); color: var(--green); }
.chip.warn { border-color: rgba(240, 166, 58, 0.5); color: var(--amber); }
.chip.err { border-color: rgba(229, 72, 77, 0.5); color: var(--red); }

/* ---------- expert alignment ---------- */
.alignment-context,
.alignment-report,
.alignment-signals {
  display: grid;
  gap: 8px;
}
.alignment-context { margin: 10px 0; }
.alignment-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}
.alignment-metrics span {
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
}
.alignment-metrics strong { color: var(--text); }
.alignment-upload {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 10px 0;
}
.alignment-upload input {
  min-width: 0;
  max-width: 100%;
  color: var(--muted);
  font-size: 12px;
}
.alignment-signal {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: var(--surface);
}
.alignment-signal.labeled-take { border-color: rgba(47, 191, 113, 0.5); }
.alignment-signal.labeled-skip { border-color: rgba(229, 72, 77, 0.45); }
#alignment-signals .alignment-label[data-label="take"] {
  border-color: #fff;
}
.alignment-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 6px;
  margin-top: 8px;
}
@media (min-width: 641px) {
  #alignment-signals .alignment-actions {
    grid-template-columns: minmax(0, 1fr) 72px 72px;
  }
  #alignment-signals .alignment-reason {
    max-width: 220px;
    width: 100%;
    justify-self: start;
  }
  #alignment-signals .alignment-label {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }
}
.alignment-reason {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  padding: 6px 8px;
  font-size: 12px;
}

@media (max-width: 640px) {
  .alignment-metrics { grid-template-columns: 1fr; }
  .alignment-actions { grid-template-columns: 1fr 1fr; }
  .alignment-actions .alignment-reason { grid-column: 1 / -1; }
}

@keyframes chip-marquee {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

@media (prefers-reduced-motion: reduce) {
  .chip-track { animation: none; }
  .chip-set[aria-hidden="true"] { display: none; }
  .chip-marquee {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    mask-image: none;
    -webkit-mask-image: none;
  }
  .chip-marquee::-webkit-scrollbar { display: none; }
}

/* ---------- live quotes ticker tape ---------- */
.ticker-field {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 8px 6px 12px;
  margin-bottom: 16px;
  min-width: 0;
}
.ticker-field.hidden { display: none; }
.ticker-field > .btn { flex-shrink: 0; }
.ticker-tv {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 46px;
  overflow: hidden;
}
.ticker-tv .tradingview-widget-container,
.ticker-tv .tradingview-widget-container__widget {
  height: 46px;
}
.ticker-tape {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 28px;
  overflow: hidden;
}
.ticker-tape .chip-track {
  animation: chip-marquee 22s linear infinite;
}
.quote {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  font-size: 12.5px;
  white-space: nowrap;
  flex-shrink: 0;
  padding-right: 22px;
}
.quote .q-sym { color: var(--text); font-weight: 650; letter-spacing: 0.02em; }
.quote .q-px { color: var(--muted); font-variant-numeric: tabular-nums; }
.quote .q-arrow { font-size: 10px; }
.quote .q-pct { font-weight: 600; font-variant-numeric: tabular-nums; }
.quote.up .q-arrow, .quote.up .q-pct { color: var(--green); }
.quote.down .q-arrow, .quote.down .q-pct { color: var(--red); }

/* ---------- charts page ---------- */
#charts-meta.chip {
  color: #b8f7e4;
  border-color: #b8f7e4;
}
.page-charts #asset-tabs .tab,
.page-charts #tf-tabs .tab {
  color: #b8f7e4;
  border-color: #b8f7e4;
  background: none;
}
.page-charts #asset-tabs .tab.active,
.page-charts #tf-tabs .tab.active {
  color: #25272c;
  border-color: #b8f7e4;
  background: #b8f7e4;
}
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.chart-card { padding: 12px 12px 8px; min-width: 0; overflow: hidden; }
.chart-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.chart-title { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.chart-title strong { font-size: 14px; letter-spacing: 0.02em; }
.chart-quote {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.chart-quote .q-px { color: var(--muted); }
.chart-quote .q-arrow.up, .chart-quote .q-pct.up { color: var(--green); }
.chart-quote .q-arrow.down, .chart-quote .q-pct.down { color: var(--red); }
.chart-quote .q-arrow { font-size: 10px; }
.chart-quote .q-pct { font-weight: 600; }
.chart-canvas {
  width: 100%;
  height: 220px;
  max-width: 100%;
  overflow: hidden;
  position: relative;
}

/* theme toggle */
.btn.icon {
  width: 34px; height: 34px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 9px;
}
.btn.icon svg { width: 16px; height: 16px; stroke: var(--accent); fill: none; stroke-width: 2; }
.btn.icon:hover svg { stroke: var(--accent); }
:root[data-theme="light"] .btn.icon svg { stroke: #000; }
:root[data-theme="light"] .btn.icon:hover svg { stroke: #000; }
:root[data-theme="dark"] .icon-moon { display: none; }
:root[data-theme="light"] .icon-sun { display: none; }

/* ---------- cards & layout ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

.controls {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.control-group { display: flex; flex-direction: column; gap: 4px; }
.control-group label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.control-group input:not([type="checkbox"]):not([type="radio"]),
.control-group select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 10px;
  font-size: 13px;
  min-width: 130px;
}
.control-group input:not([type="checkbox"]):not([type="radio"]):focus,
.control-group select:focus { outline: 1px solid var(--accent-border); }
/* Number spinners off; Size % suffix */
#ctrl-equity input::-webkit-outer-spin-button,
#ctrl-equity input::-webkit-inner-spin-button,
#ctrl-position-size input::-webkit-outer-spin-button,
#ctrl-position-size input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
#ctrl-equity input,
#ctrl-position-size input {
  -moz-appearance: textfield;
  appearance: textfield;
}
#ctrl-position-size .size-input-wrap {
  position: relative;
}
#ctrl-position-size .size-input-wrap input {
  width: 100% !important;
  padding-right: 28px;
}
#ctrl-position-size .size-pct-suffix {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 13px;
  pointer-events: none;
  line-height: 1;
}
#ctrl-position-size .size-input-wrap input:placeholder-shown + .size-pct-suffix {
  display: none;
}
#ctrl-playbook #rulebook {
  -webkit-appearance: none;
  appearance: none;
  field-sizing: fixed;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%239aa0a6' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 10px 7px;
  padding-right: 28px;
}

/* Desktop only: shrink Equity / Size / Playbook boxes — nothing else */
@media (min-width: 641px) {
  #ctrl-equity input,
  #ctrl-position-size .size-input-wrap,
  #ctrl-playbook #rulebook {
    width: 96px;
    min-width: 96px;
    max-width: 96px;
    box-sizing: border-box;
  }
  #ctrl-risk,
  .mode-risk {
    flex: 0 0 auto;
    width: auto;
    max-width: none;
  }
  #ctrl-risk input,
  .mode-risk input {
    width: 40px;
    min-width: 40px;
    max-width: 40px;
  }
  #ctrl-position-size .size-input-wrap input {
    min-width: 0 !important;
  }
}
.control-actions { display: flex; gap: 8px; margin-left: auto; }

/* One dashboard, one paper book. */
html[data-desk="v2"] #filter-auto-wrap,
html[data-desk="v2"] #sandbox-book-tabs,
html[data-desk="v2"] .v1-only,
html[data-desk="v2"] #studio-auto-wrap { display: none !important; }
html[data-desk="v1"] .v2-only { display: none !important; }
.v2-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.v2-form input, .v2-form select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 10px;
  min-width: 96px;
}
.v2-form .v2-reason { flex: 1 1 220px; }
.v2-table-wrap { overflow-x: auto; }
.v2-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.v2-table th, .v2-table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); }
.v2-table .skip { color: #d27a7a; }
.v2-table .take { color: #3d8b5a; }
.v2-wallet { display: flex; flex-wrap: wrap; gap: 12px 20px; margin: 12px 0; font-size: 14px; }
.v2-wallet span { color: var(--muted, #9aa6b2); }
.v2-wallet strong { color: var(--text); }
#btn-desk-v2.active {
  border-color: rgba(201, 162, 39, 0.7);
  color: var(--text);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
  transition: filter 0.15s, transform 0.05s;
  line-height: 1.2;
  box-sizing: border-box;
}
.btn:hover { filter: brightness(1.08); }
:root[data-theme="dark"] .btn:hover { filter: brightness(1.25); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: wait; }
.btn.busy {
  position: relative;
  pointer-events: none;
  opacity: 0.85;
  cursor: wait;
}
.btn.busy .btn-label { opacity: 0.85; }
.btn.busy .btn-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 8px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  vertical-align: -2px;
  animation: btn-spin 0.7s linear infinite;
}
@keyframes btn-spin {
  to { transform: rotate(360deg); }
}
.btn.primary { background: #B8F7E4; border-color: #B8F7E4; color: #25272c; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn-chart {
  gap: 6px;
}
.btn-chart .icon-candles {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  display: block;
}
a.btn {
  text-decoration: none;
  color: inherit;
  -webkit-appearance: none;
}
a.btn:hover, a.btn:visited, a.btn:active { text-decoration: none; color: inherit; }
a.btn.primary,
a.btn.primary:hover,
a.btn.primary:visited,
a.btn.primary:active {
  color: #25272c;
  background: #B8F7E4;
  border-color: #B8F7E4;
}
.btn.approve { background: rgba(47, 191, 113, 0.14); border-color: rgba(47, 191, 113, 0.5); color: var(--green); }
.btn.reject { background: rgba(229, 72, 77, 0.12); border-color: rgba(229, 72, 77, 0.5); color: var(--red); }
.btn.secondary,
.btn.train,
.btn.archive {
  background: rgba(142, 217, 208, 0.14);
  border-color: rgba(142, 217, 208, 0.5);
  color: #8ed9d0;
}
html[data-theme="light"] .btn.secondary,
html[data-theme="light"] .btn.train,
html[data-theme="light"] .btn.archive {
  background: rgba(142, 217, 208, 0.28);
  border-color: rgba(26, 125, 116, 0.4);
  color: #1b7f76;
}
.btn.sync {
  background: #efe6d2;
  border-color: #efe6d2;
  color: #04090e;
}
html[data-theme="light"] .btn.sync {
  background: #202124;
  border-color: #202124;
  color: #ffffff;
}

.banner {
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 13px;
  border: 1px solid;
}
.banner.info { background: var(--accent-soft); border-color: var(--accent-border); color: var(--accent-ink); }
.banner.error { background: rgba(229, 72, 77, 0.1); border-color: rgba(229, 72, 77, 0.4); color: var(--red); }
.hidden { display: none; }
.panel-head-actions.hidden,
.tabs.hidden { display: none; }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr);
  gap: 16px;
  align-items: start;
}
.proposals-panel, .side-panel { min-width: 0; }
@media (max-width: 980px) { .layout { grid-template-columns: 1fr; } }

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.panel-head h2 { font-size: 14px; font-weight: 650; letter-spacing: 0.03em; }
.panel-head-actions { display: flex; align-items: center; gap: 8px; }
.hint { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.signal-toggles.compact {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin-top: 6px;
  max-width: 280px;
}
.signal-toggles.compact .sig-chip {
  padding: 0;
  margin: 0;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0;
  align-items: center;
  line-height: 1.2;
}
.signal-toggles.compact .sig-chip input[type="checkbox"] {
  min-width: 0;
  width: 14px;
  height: 14px;
  margin: 0;
  padding: 0;
  flex-shrink: 0;
  accent-color: var(--accent-ink, var(--green));
}

.rules-dropdown {
  position: relative;
}
.rules-dropdown-btn {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 10px;
  font-size: 13px;
  cursor: pointer;
  box-sizing: border-box;
  line-height: 1.2;
}
.rules-dropdown-btn:hover { filter: brightness(1.08); }
.rules-caret {
  width: 10px;
  height: 7px;
  flex-shrink: 0;
  opacity: 0.7;
}
.rules-dropdown.open .rules-caret { transform: rotate(180deg); }
.rules-dropdown-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  min-width: 280px;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  background: var(--card, var(--surface));
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}
.rules-dropdown-panel.hidden { display: none; }
.rules-dropdown-panel .sig-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 2px 0;
  font-size: 12px;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
  cursor: pointer;
}
.rules-dropdown-panel .sig-chip input[type="checkbox"] {
  min-width: 0;
  width: 14px;
  height: 14px;
  margin: 0;
  flex-shrink: 0;
  accent-color: var(--accent-ink, var(--green));
}
.rules-panel { display: none; }
body.engine-btc #ctrl-provider,
body.engine-btc #ctrl-days { display: none; }
.page-charts .btc-chart-canvas { height: min(62vh, 560px); width: 100%; }
.page-charts #btc-chart-wrap,
.page-charts #tv-chart-wrap { margin-bottom: 14px; }
.page-charts #tv-chart { height: min(62vh, 560px); width: 100%; }
#chart-tv-collapse { display: none; }
body.page-charts.is-chart-expanded { overflow: hidden; }
#tv-chart-wrap.is-expanded {
  position: fixed;
  inset: 12px;
  z-index: 300;
  margin: 0;
  display: flex;
  flex-direction: column;
  width: auto;
  height: calc(100dvh - 24px);
  max-height: calc(100dvh - 24px);
  min-height: 0;
  overflow: hidden;
  background: #0f181e;
  border: 1px solid #3a535c;
  box-shadow: 0 20px 56px rgba(0, 0, 0, 0.55);
}
#tv-chart-wrap.is-expanded #chart-tv-expand { display: none; }
#tv-chart-wrap.is-expanded #chart-tv-collapse { display: inline-flex; }
.scene-win-btn {
  appearance: none;
  -webkit-appearance: none;
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  min-width: 22px;
  min-height: 22px;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  line-height: 0;
  box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.22);
}
.scene-win-btn.is-expand { background: #28c840; }
.scene-win-btn.is-collapse { background: #ff5f57; }
.scene-win-btn svg {
  width: 12px;
  height: 12px;
  display: block;
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.scene-win-btn.is-expand svg,
.scene-win-btn.is-collapse svg { stroke: #fff; }
html[data-theme="light"] .scene-win-btn.is-expand svg { stroke: #0b5d1e; }
html[data-theme="light"] .scene-win-btn.is-collapse svg { stroke: #7a1210; }
.scene-win-btn:hover { filter: brightness(1.08); }
.scene-win-btn:active { transform: scale(0.94); }
.scene-win-btn:focus-visible {
  outline: 2px solid #a9dfd2;
  outline-offset: 2px;
}
.scene-win-btn.is-collapse:focus-visible { outline-color: #ff5f57; }
@media (pointer: coarse) {
  .scene-win-btn {
    width: 24px;
    height: 24px;
    min-width: 24px;
    min-height: 24px;
    flex-basis: 24px;
  }
  .scene-win-btn svg {
    width: 13px;
    height: 13px;
  }
}
#tv-chart-wrap.is-expanded #tv-chart,
#tv-chart-wrap.is-expanded .btc-chart-canvas {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  width: 100%;
}
.chart-tv-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}
@media (max-width: 640px) {
  /* Mobile only: Expand fills the screen, same as Studio World / Brain / Research. */
  html:has(body.page-charts.is-chart-expanded) { overflow: hidden; }
  body.page-charts #tv-chart-wrap.is-expanded {
    position: fixed;
    inset: 0;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    min-height: 100dvh;
    border-radius: 0;
    z-index: 400;
    margin: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-sizing: border-box;
  }
  body.page-charts #tv-chart-wrap.is-expanded #tv-chart,
  body.page-charts #tv-chart-wrap.is-expanded .btc-chart-canvas {
    flex: 1 1 0;
    min-height: 0;
    height: 0;
    width: 100%;
  }
  body.page-charts #tv-chart-wrap .panel-head {
    position: relative;
    padding-right: 36px;
    align-items: flex-start;
  }
  body.page-charts #tv-chart-wrap .chart-tv-actions {
    flex: 1 1 100%;
    width: 100%;
    justify-content: flex-start;
  }
  body.page-charts #tv-chart-wrap .chart-tv-actions .scene-win-btn {
    position: absolute;
    top: 0;
    right: 0;
    z-index: 2;
  }
}

.tabs { display: flex; gap: 4px; }
.tab {
  background: none;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--muted);
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}
.tab.active { background: var(--card); border-color: var(--border); color: var(--text); }

/* ---------- proposals ---------- */
.proposals-list { display: flex; flex-direction: column; gap: 12px; }
.empty { color: var(--muted); padding: 24px; text-align: center; font-size: 13px; }

.proposal { padding: 14px 16px; }
.proposal.trade-open {
  background: rgba(184, 247, 228, 0.16);
  border-color: rgba(47, 191, 113, 0.45);
  box-shadow: inset 0 0 0 1px rgba(47, 191, 113, 0.12);
}
:root[data-theme="light"] .proposal.trade-open {
  background: rgba(47, 191, 113, 0.14);
  border-color: rgba(24, 138, 82, 0.38);
  box-shadow: inset 0 0 0 1px rgba(24, 138, 82, 0.08);
}
.proposal-top {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  row-gap: 8px;
}
.proposal-top .chip {
  padding: 5px 12px;
  line-height: 1.25;
  margin: 2px 0 4px;
}
.rank {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}
.symbol { font-size: 18px; font-weight: 700; letter-spacing: 0.03em; }
.px { font-family: var(--mono); color: var(--muted); font-size: 13px; }

.status-badge {
  margin-left: auto;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.status-pending { background: rgba(240, 166, 58, 0.15); color: var(--amber); }
.status-approved { background: rgba(47, 191, 113, 0.15); color: var(--green); }
.status-rejected { background: rgba(229, 72, 77, 0.13); color: var(--red); }

.scorebar {
  height: 5px;
  background: var(--surface);
  border-radius: 4px;
  overflow: hidden;
  margin: 10px 0;
}
.scorebar > div { height: 100%; background: linear-gradient(90deg, var(--accent), #5bc9a0); }

.plan {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px;
  margin-top: 4px;
  margin-bottom: 10px;
}
.plan .cell {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
}
.plan .cell .k { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.plan .cell .k.k-upnl { text-transform: none; letter-spacing: 0.02em; }
.plan .cell .v { font-family: var(--mono); font-size: 13px; }

.why { margin: 0 0 12px; padding-left: 18px; color: var(--muted); font-size: 12.5px; }
.why li { margin-bottom: 2px; }
.why li::marker { color: var(--accent-ink); }

.decision-row { display: flex; gap: 8px; align-items: center; }
.decided { font-size: 12px; color: var(--muted); }

/* ---------- side panel ---------- */
.side-panel { display: flex; flex-direction: column; gap: 16px; }

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
}
.metric {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
}
.metric .k { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.metric .v { font-family: var(--mono); font-size: 15px; font-weight: 600; }
.metric .v.pos { color: var(--green); }
.metric .v.neg { color: var(--red); }
.data-table td.pos { color: var(--green); font-weight: 600; }
.data-table td.neg { color: var(--red); }
.bt-note { color: var(--muted); font-size: 11.5px; margin-top: 10px; }
.bt-period { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.bt-period.bt-thin { opacity: 0.72; }
.bt-period.bt-thin h3 .hint { margin-left: 8px; font-weight: 500; }
.bt-period h3 { font-size: 13px; margin: 0 0 6px; font-weight: 650; }
.bt-period-book { font-family: var(--mono); font-size: 13px; font-weight: 600; margin: 0 0 8px; }
.bt-period-book .pos, .audit-detail .pos { color: var(--green); }
.bt-period-book .neg, .audit-detail .neg { color: var(--red); }
.bt-headline { color: var(--text); font-weight: 600; }
.bt-explore { margin-top: 22px; padding-top: 14px; border-top: 2px dashed var(--border); }
.bt-explore h3 { font-size: 12px; margin: 0 0 4px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.bt-explore .bt-period h3 { text-transform: none; letter-spacing: 0; color: var(--text); }

.unread-badge {
  display: inline-block;
  background: var(--red);
  color: #fff;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  vertical-align: 2px;
  margin-left: 4px;
}
.unread-badge.hidden { display: none !important; }
.section-label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 12px 0 4px;
}
.paper-open-row {
  align-items: center;
  flex-wrap: nowrap;
  background: rgba(184, 247, 228, 0.16);
  border: 1px solid rgba(47, 191, 113, 0.4);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 6px;
}
:root[data-theme="light"] .paper-open-row {
  background: rgba(47, 191, 113, 0.14);
  border-color: rgba(24, 138, 82, 0.35);
}
.paper-open-row .audit-detail,
.paper-open-row .paper-open-detail {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  min-height: 1.2em;
}
.btn-close-paper {
  margin-left: auto;
  flex-shrink: 0;
}
.paper-open-row .btn-close-paper {
  border-color: transparent;
}
.audit-row.unread .audit-detail { color: var(--text); font-weight: 550; }
#alerts .audit-row {
  border-radius: 8px;
  padding: 6px 8px;
  margin-bottom: 4px;
}
#alerts .alert-ok {
  background: rgba(47, 191, 113, 0.12);
  border: 1px solid rgba(47, 191, 113, 0.35);
}
#alerts .alert-ok .audit-detail { color: var(--green); }
#alerts .alert-error {
  background: rgba(229, 72, 77, 0.12);
  border: 1px solid rgba(229, 72, 77, 0.35);
}
#alerts .alert-error .audit-detail { color: var(--red); }
#alerts .alert-warning {
  background: rgba(240, 166, 58, 0.12);
  border: 1px solid rgba(240, 166, 58, 0.4);
}
#alerts .alert-warning .audit-detail { color: var(--amber); }
#alerts .alert-info {
  background: rgba(184, 247, 228, 0.08);
}
.warn-text { color: var(--amber) !important; }
#alerts .audit-detail.warn-text {
  text-overflow: clip;
}
#alerts .alert-marquee {
  display: block;
  overflow: hidden;
  min-width: 0;
  width: 100%;
}
#alerts .alert-marquee-track {
  display: inline-block;
  max-width: none;
  white-space: nowrap;
  will-change: transform;
}
#alerts .alert-marquee.is-overflow .alert-marquee-track {
  animation: alert-text-marquee var(--alert-marquee-duration, 10s) linear infinite alternate;
}
#alerts .alert-marquee.is-overflow:hover .alert-marquee-track,
#alerts .alert-marquee.is-overflow:focus-within .alert-marquee-track {
  animation-play-state: paused;
}
@keyframes alert-text-marquee {
  0%, 14% { transform: translateX(0); }
  86%, 100% { transform: translateX(var(--alert-marquee-shift, 0px)); }
}
@media (prefers-reduced-motion: reduce) {
  #alerts .alert-marquee.is-overflow .alert-marquee-track {
    animation: none;
  }
  #alerts .audit-detail.warn-text {
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
  }
  #alerts .alert-marquee,
  #alerts .alert-marquee-track {
    display: inline;
    white-space: inherit;
    overflow: visible;
  }
}

.audit-body {
  max-height: 340px;
  overflow-x: hidden;
  overflow-y: auto;
}
.audit-body::-webkit-scrollbar {
  width: 8px;
}
#audit::-webkit-scrollbar,
#alerts::-webkit-scrollbar {
  width: 2px;
  height: 2px;
}
#alerts {
  padding-right: 8px;
}
.daily-brief-body { font-size: 13px; }
.daily-brief-meta { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.daily-brief-assets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 10px;
}
.daily-brief-asset {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
}
.daily-brief-asset.up { color: var(--green); border-color: rgba(47, 191, 113, 0.45); }
.daily-brief-asset.down { color: var(--red); border-color: rgba(229, 72, 77, 0.45); }
.daily-brief-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 10px;
  margin: 0 0 10px;
}
.daily-brief-dev { color: var(--text); margin: 0 0 10px; }
.daily-brief-dev strong { display: block; font-size: 11px; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 4px; }
.daily-brief-full h4 { margin: 16px 0 8px; font-size: 13px; }
.daily-brief-table-wrap {
  overflow-x: auto;
  max-width: 100%;
}
.daily-brief-full table,
.daily-brief-full thead,
.daily-brief-full tbody,
.daily-brief-full tr,
.daily-brief-full th,
.daily-brief-full td {
  background: none;
  background-color: transparent;
}
.daily-brief-full table {
  width: 100%;
  min-width: 0;
  border-collapse: collapse;
  font-size: 12px;
  white-space: normal;
}
.daily-brief-full th,
.daily-brief-full td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  overflow: visible;
  vertical-align: top;
  white-space: nowrap;
}
.daily-brief-full th.candle,
.daily-brief-full td.candle {
  white-space: nowrap;
}
.daily-brief-full td.move-pill {
  white-space: nowrap;
}
.daily-brief-full td.move-pill .daily-brief-asset {
  display: inline-flex;
  align-items: center;
}
.daily-brief-market-desktop { display: block; }
.daily-brief-market-list.daily-brief-market-mobile { display: none; gap: 10px; }
@media (max-width: 1100px) {
  .daily-brief-market-desktop { display: none; }
  .daily-brief-market-list.daily-brief-market-mobile { display: grid; }
}
.daily-brief-asset-row {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}
.daily-brief-asset-row header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  margin-bottom: 8px;
}
.daily-brief-asset-row header strong { font-size: 13px; }
.daily-brief-candle {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.daily-brief-asset-row dl {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  gap: 8px 10px;
  margin: 0;
}
.daily-brief-asset-row dt {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.04em;
}
.daily-brief-asset-row dd { margin: 2px 0 0; font-size: 12px; word-break: break-word; }
.audit-body::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}
.audit-body::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 999px;
}
.audit-body::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}
.audit-row {
  display: flex;
  gap: 10px;
  padding: 6px 2px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}
.audit-row:last-child { border-bottom: none; }
.audit-row.paper-open-row,
.audit-row.paper-open-row:last-child {
  border: 1px solid rgba(47, 191, 113, 0.4);
}
:root[data-theme="light"] .audit-row.paper-open-row,
:root[data-theme="light"] .audit-row.paper-open-row:last-child {
  border-color: rgba(24, 138, 82, 0.35);
}
#audit .audit-row {
  cursor: pointer;
  border-radius: 6px;
  padding: 6px 8px;
  transition: background 0.12s ease, color 0.12s ease;
}
#audit .audit-row:hover {
  background: var(--accent-soft);
}
#audit .audit-row:hover .audit-detail,
#audit .audit-row:hover .audit-ts {
  color: var(--text);
}
#audit .audit-row:hover .audit-event {
  color: var(--accent-ink);
}
.audit-ts { font-family: var(--mono); color: var(--muted); white-space: nowrap; flex-shrink: 0; }
.audit-event { font-weight: 600; white-space: nowrap; flex-shrink: 0; }
.audit-detail {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1 1 auto;
}

/* ---------- audit detail modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop.hidden { display: none; }
.modal-card {
  width: min(520px, 100%);
  max-height: min(80vh, 640px);
  overflow: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px 18px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}
.modal-card.daily-brief-modal-card {
  width: min(960px, calc(100vw - 24px));
  max-height: min(86vh, 880px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.daily-brief-modal-card .modal-head {
  flex-shrink: 0;
}
.daily-brief-modal-card .modal-body {
  white-space: normal;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding-right: 10px;
}
.daily-brief-modal-card .modal-body::-webkit-scrollbar {
  width: 3px;
  height: 3px;
}
.daily-brief-modal-card .modal-body::-webkit-scrollbar-track {
  background: transparent;
}
.daily-brief-modal-card .modal-body::-webkit-scrollbar-thumb {
  background: #8fa8af;
  border-radius: 999px;
}
.daily-brief-modal-card .modal-body::-webkit-scrollbar-thumb:hover {
  background: #adc2c7;
}
html[data-theme="light"] .daily-brief-modal-card .modal-body::-webkit-scrollbar-thumb {
  background: #d5d9de;
}
html[data-theme="light"] .daily-brief-modal-card .modal-body::-webkit-scrollbar-thumb:hover {
  background: #c4c8cd;
}
.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.modal-head h3 {
  font-size: 15px;
  font-weight: 650;
  line-height: 1.3;
}
.modal-meta {
  color: var(--muted);
  font-size: 12px;
  font-family: var(--mono);
  margin-bottom: 12px;
}
.modal-body {
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  color: var(--text);
}
.modal-body .audit-kv {
  display: grid;
  grid-template-columns: minmax(90px, 34%) 1fr;
  gap: 6px 12px;
  margin: 0;
}
.modal-body .audit-kv dt {
  color: var(--muted);
  font-size: 12px;
}
.modal-body .audit-kv dd {
  margin: 0;
  word-break: break-word;
}

.foot {
  margin-top: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

/* ---------- toasts ---------- */
.toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
  max-width: min(360px, 90vw);
}
.toast {
  background: var(--card);
  border: 1px solid var(--accent-border);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  padding: 10px 14px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
  animation: toast-in 0.25s ease;
}
.toast strong { font-size: 13px; }
.toast span { color: var(--muted); font-size: 12.5px; }
.toast.order { border-left-color: var(--amber); border-color: rgba(240, 166, 58, 0.4); }
@keyframes toast-in { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- engine status (bot heartbeat) ---------- */
.live-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  margin-left: 6px;
  vertical-align: 1px;
}
.engine-stack { display: flex; flex-direction: column; gap: 16px; }
.engine-block { padding-top: 4px; }
.engine-block-title {
  margin: 0 0 8px;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.engine-openings-copy { margin: 6px 0 0; font-size: 13px; }
.engine-openings-sub { margin: 4px 0 0; font-size: 12px; color: var(--muted); }
.engine-reserved { opacity: 0.72; }
.engine-reserved-line { margin: 2px 0; font-size: 13px; }
.engine-reserved-line.muted { color: var(--muted); }
.engine-source { margin: 0 0 10px; }
.engine-source:last-child { margin-bottom: 0; }
.ai-exec-panel { margin-bottom: 16px; }
.ai-exec-panel > .hint { margin: 0 0 14px; }
.ai-exec-title { margin: 0; }
.ai-exec-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 10px;
}
.ai-exec-pills .chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-width: 76px;
  min-height: 34px;
  padding: 8px 16px;
}
.ai-exec-list { list-style: none; display: grid; gap: 8px; margin: 8px 0 0; padding: 0; }
.ai-exec-row { display: grid; gap: 2px; }
.ai-exec-eval { margin: 8px 0; padding: 8px 0; border-top: 1px solid var(--border); }
.engine-armed { display: flex; flex-direction: column; gap: 10px; }
.engine-armed-row {
  padding: 10px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.engine-armed-top { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.engine-armed-meta { margin-top: 4px; font-size: 12px; color: var(--muted); }
.engine-armed-open { margin: 6px 0 0; font-size: 12px; }
.engine-armed-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.engine-armed-manage { margin: 8px 0 0; }
.engine-manage-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 550;
  color: #b8f7e4;
  text-decoration: none;
}
.engine-manage-link:visited,
.engine-manage-link:active,
.engine-manage-link:hover {
  color: #b8f7e4;
  text-decoration: none;
}
.engine-manage-arrow {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-top: 1.5px solid currentColor;
  border-right: 1.5px solid currentColor;
  transform: rotate(45deg);
  transform-origin: 60% 40%;
  transition: transform 0.22s ease;
}
.engine-manage-link:hover .engine-manage-arrow {
  transform: rotate(0deg);
}
@media (prefers-reduced-motion: reduce) {
  .engine-manage-arrow { transition: none; }
}
.engine-approval {
  margin-bottom: 10px;
  padding: 10px 8px;
  border: 1px solid var(--accent-border);
  border-radius: 8px;
}
.engine-books-copy { margin: 0 0 8px; font-size: 12px; color: var(--muted); }
.engine-heartbeat .engine-meta { margin-top: 8px; }
.engine-body { font-size: 13px; }
.engine-asset {
  margin-top: 10px;
  padding: 10px 8px 12px;
  border-top: 1px solid var(--border);
  cursor: pointer;
  border-radius: 8px;
}
.engine-asset:hover { background: var(--surface); }
.engine-asset.selected {
  outline: 1px solid var(--accent-border);
  outline-offset: 0;
  background: var(--surface);
}
.engine-asset:first-of-type { margin-top: 8px; }
#ctrl-position-size label span {
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
  font-weight: 600;
}
.engine-asset-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}
.engine-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 11.5px;
  margin: 4px 0;
}
.engine-rules, .engine-tfs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 8px 0 0;
}
.monitor-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.switch { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13px; cursor: pointer; }
.switch input { accent-color: var(--accent); width: 16px; height: 16px; }
.monitor-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.monitor-every {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}
.monitor-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.mini-input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 3px 6px;
  font-size: 12px;
  width: 56px;
}
select.mini-input { width: auto; }
/* Engine: compact “every N min” field only */
.monitor-every .mini-input,
#eng-interval {
  width: 40px;
  min-width: 40px;
  max-width: 40px;
  box-sizing: border-box;
  -moz-appearance: textfield;
  appearance: textfield;
}
#eng-interval::-webkit-outer-spin-button,
#eng-interval::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.monitor-meta { display: flex; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: 11.5px; margin: 8px 0; }
.monitor-markets { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }

/* ---------- trading mode ---------- */
.trading-mode-body { font-size: 13px; }
.mode-toolbar {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  padding-bottom: 16px;
}
.mode-toolbar .mode-toggle { flex: 0 0 auto; }
.mode-equity {
  margin: 0;
  padding: 0;
  border: none;
  flex: 0 0 108px;
  width: 108px;
}
.mode-equity input {
  width: 108px;
  min-width: 108px;
  max-width: 108px;
  box-sizing: border-box;
}
.mode-risk {
  position: relative;
  margin: 0;
  padding: 0;
  border: none;
  flex: 0 0 auto;
  width: auto;
  min-width: 40px;
}
#ctrl-risk label {
  white-space: nowrap;
}
#ctrl-risk input,
.mode-risk input {
  width: 40px;
  min-width: 40px;
  max-width: 40px;
  box-sizing: border-box;
  padding-left: 4px;
  padding-right: 4px;
}
#ctrl-risk .risk-hint {
  position: absolute;
  left: 0;
  top: calc(100% + 3px);
  margin: 0;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.2;
  white-space: nowrap;
}
#ctrl-risk input::-webkit-outer-spin-button,
#ctrl-risk input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
#ctrl-risk input {
  -moz-appearance: textfield;
  appearance: textfield;
}
.trading-mode-body .engine-meta { margin-top: 10px; }
.mode-toggle {
  display: inline-flex;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}
.mode-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  min-width: 72px;
}
.sandbox-desk { margin-top: 10px; }
.sandbox-section { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }
.sandbox-section:first-child { margin-top: 8px; padding-top: 0; border-top: none; }
.sandbox-desk-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.sandbox-desk-row .mini-input { min-width: 0; flex: 1 1 120px; }
.sandbox-desk-row #sandbox-horizon { flex: 0 0 128px; }
.sandbox-desk-row .btn { flex: 0 0 auto; }
#trades-panel .panel-head { flex-wrap: nowrap; gap: 10px; }
#trades-heading { flex: 0 0 auto; }
#trades-head-tabs {
  display: flex;
  flex-wrap: nowrap;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
#trades-head-tabs::-webkit-scrollbar { display: none; }
#trades-head-tabs .tabs { flex-wrap: nowrap; flex: 0 0 auto; position: relative; }
.asset-picker-btn {
  display: none;
  align-items: center;
  gap: 6px;
}
.asset-picker-caret {
  width: 10px;
  height: 7px;
  flex: 0 0 auto;
}
.asset-picker-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 30;
  min-width: 132px;
  flex-direction: column;
  gap: 2px;
  padding: 3px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.asset-picker-menu:not(.hidden) { display: none; }
.asset-picker-opt { width: 100%; text-align: left; justify-content: flex-start; }
.asset-picker-search {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--border);
  background: transparent;
  color: inherit;
  border-radius: 6px;
  padding: 6px 8px;
  font: inherit;
  font-size: 12px;
}
#trades-head-tabs .trade-tab-dot {
  color: #799598;
  font-size: 18px;
  line-height: 1;
  padding: 0 2px;
  user-select: none;
  flex: 0 0 auto;
}
html[data-theme="light"] #trades-head-tabs .trade-tab-dot { color: #5f6368; }
.engine-slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  padding: 5px 14px;
  min-height: 26px;
  box-sizing: border-box;
}
.engine-slot-news {
  min-width: 76px;
}
.paper-books {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 4px;
}
.paper-book {
  font-size: 11.5px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 8px;
}
.mode-btn + .mode-btn { border-left: 1px solid var(--border); }
.mode-btn.active {
  background: var(--accent);
  color: var(--on-accent);
}
.mode-btn.locked {
  opacity: 0.55;
  cursor: not-allowed;
}
.mode-btn:disabled:not(.locked) { opacity: 0.5; cursor: not-allowed; }
.chip.warn { background: rgba(240, 166, 58, 0.14); color: var(--amber); }
.warn-text { color: var(--amber); }

/* ---------- execution panel (legacy bits) ---------- */
.status-text-filled, .status-text-manual_filled { color: var(--green); }
.status-text-rejected, .status-text-canceled { color: var(--red); }
.status-text-submitted, .status-text-partial, .status-text-manual_pending { color: var(--amber); }

/* ---------- AI brief & assistant ---------- */
.ai-brief {
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12.5px;
  line-height: 1.55;
  margin: 14px 0 16px;
}
.ai-brief .hint { display: block; margin-bottom: 4px; }
.decision-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  row-gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}
.decision-wrap .decision-row { gap: 10px; }
.assistant-form { display: flex; gap: 8px; }
.assistant-form input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 10px;
  font-size: 13px;
  min-width: 0;
}
.assistant-answer {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12.5px;
  margin-bottom: 10px;
  white-space: pre-wrap;
}

/* ---------- rulebook studio ---------- */
.studio-train { margin: 0 0 16px; }
.studio-pref-block { display: grid; gap: 8px; margin: 10px 0 14px; }
.studio-pref-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.studio-pref-row > span {
  width: 64px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.studio-pref.on,
.chip.studio-pref.on {
  border-color: rgba(229, 72, 77, 0.55);
  color: var(--text);
  background: rgba(229, 72, 77, 0.12);
}
.studio-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  gap: 16px;
  align-items: start;
}
@media (max-width: 980px) { .studio-layout { grid-template-columns: 1fr; } }
.studio-textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 13px;
  resize: vertical;
}
.studio-textarea.yaml { font-family: var(--mono); font-size: 12.5px; }
.studio-actions { margin-top: 10px; flex-wrap: wrap; }
.studio-right .studio-replay-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  margin-bottom: 20px;
}
.studio-replay-pair {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.studio-right .studio-replay-row .btn { white-space: nowrap; }
.studio-right .studio-replay-row select.mini-input { min-width: 118px; }
.studio-right #studio-result.assistant-answer {
  margin-top: 0;
  margin-bottom: 16px;
}
.studio-draft-pair {
  display: flex;
  gap: 8px;
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
  flex-wrap: wrap;
}
.studio-draft-pair .btn { flex: 0 1 auto; white-space: nowrap; }
.studio-draft-pair select.mini-input { min-width: 118px; }
.draft-name { width: 140px; flex: 0 0 auto; }
#mode-transcript .bt-note {
  margin-top: 0;
  margin-bottom: 14px;
}
.chat-log {
  max-height: 340px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}
.chat-msg {
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  max-width: 92%;
  white-space: pre-wrap;
}
.chat-msg.user { background: var(--accent-soft); border: 1px solid var(--accent-border); align-self: flex-end; }
.chat-msg.assistant { background: var(--surface); border: 1px solid var(--border); align-self: flex-start; }
.chat-intro {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  max-width: 92%;
  align-self: flex-start;
  padding: 2px 0 6px;
}

/* ---------- user guide ---------- */
.guide-glossary {
  margin: 0 0 16px;
  padding: 0;
  overflow: hidden;
}
.guide-glossary-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  margin: 0;
  padding: 12px 16px;
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
  min-height: 44px;
}
.guide-glossary-toggle:active { filter: brightness(1.08); }
.guide-glossary-toggle-text {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 10px;
  min-width: 0;
}
.guide-glossary-hint {
  font-size: 12px;
  color: var(--muted);
}
.guide-glossary .guide-toc-chevron {
  display: block;
  flex-shrink: 0;
}
.guide-glossary.is-folded .guide-glossary-body { display: none; }
.guide-glossary.is-folded .guide-toc-chevron {
  transform: rotate(-45deg);
  margin-top: 2px;
}
.guide-glossary:not(.is-folded) .guide-toc-chevron {
  transform: rotate(45deg);
  margin-top: -4px;
}
.guide-glossary-body {
  padding: 0 16px 14px;
  border-top: 1px solid var(--border);
}
.guide-glossary dl {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 8px 14px;
  margin: 10px 0 0;
}
.guide-glossary dl > div {
  display: grid;
  grid-template-columns: minmax(88px, 118px) minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}
.guide-glossary dt {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--accent-ink);
  font-family: var(--mono);
}
.guide-glossary dd {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}
.guide-playbook-body {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
}
.guide-playbook-body > p { margin: 10px 0 0; }
.guide-playbook-body h3 {
  margin: 16px 0 6px;
  font-size: 14px;
}
.guide-playbook-body h4 {
  margin: 12px 0 4px;
  font-size: 13px;
  color: var(--accent-ink);
}
.guide-playbook-body ul,
.guide-playbook-body ol {
  margin: 6px 0 0;
  padding-left: 1.2em;
}
.guide-playbook-body li { margin: 4px 0; }
.guide-playbook-body .guide-src {
  display: inline-block;
  margin-left: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
  font-family: var(--mono);
}
.guide-layout {
  display: grid;
  grid-template-columns: minmax(200px, 240px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  margin-bottom: 28px;
}
.guide-toc {
  position: sticky;
  top: 12px;
  padding: 14px 16px;
}
.guide-toc-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  margin: 0 0 10px;
  padding: 0;
  border: none;
  background: transparent;
  color: inherit;
  cursor: default;
  text-align: left;
}
.guide-toc-title {
  font-size: 13px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.guide-toc-chevron {
  display: none;
  width: 10px;
  height: 10px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 0.18s ease;
  flex-shrink: 0;
  margin-top: -4px;
}
.guide-toc ol {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}
.guide-toc a,
.guide-section a,
.guide-text-link {
  color: var(--accent-ink);
  text-decoration: none;
}
.guide-toc a:hover,
.guide-section a:hover,
.guide-text-link:hover { text-decoration: underline; }
.topbar .guide-text-link {
  font-size: 13px;
  font-weight: 550;
  white-space: nowrap;
}
.guide-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}
.guide-section h2 {
  font-size: 17px;
  margin: 0 0 10px;
}
.guide-section h3 {
  font-size: 14px;
  margin: 14px 0 6px;
}
.guide-section p,
.guide-section li {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text);
}
.guide-section p { margin: 0 0 10px; }
.guide-section ul,
.guide-section ol {
  margin: 0 0 10px;
  padding-left: 20px;
}
.guide-section li { margin-bottom: 4px; }
.guide-section code {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
}
.guide-callout {
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--accent-ink);
  margin: 8px 0 0 !important;
}

/* Mobile: foldable sticky Contents bar */
@media (max-width: 860px) {
  .guide-glossary dl { grid-template-columns: 1fr; }
  .guide-layout { grid-template-columns: 1fr; }
  .guide-toc {
    position: sticky;
    top: 0;
    z-index: 30;
    padding: 0;
    overflow: hidden;
  }
  .guide-toc-toggle {
    cursor: pointer;
    padding: 12px 14px;
    margin: 0;
    min-height: 44px;
    box-sizing: border-box;
  }
  .guide-toc-toggle:active { filter: brightness(1.08); }
  .guide-toc-chevron { display: block; }
  .guide-toc ol {
    padding: 0 14px 12px 32px;
    border-top: 1px solid var(--border);
    padding-top: 10px;
  }
  .guide-toc.is-folded ol { display: none; }
  .guide-toc.is-folded .guide-toc-chevron {
    transform: rotate(-45deg);
    margin-top: 2px;
  }
}
.foot a { color: var(--accent-ink); }

/* ---------- login page ---------- */
.login-wrap {
  min-height: calc(100vh - 60px);
  display: grid;
  place-items: center;
}
.login-card {
  width: min(420px, 94vw);
  text-align: center;
  padding: 28px 28px 32px;
}
.login-logo { margin-bottom: 14px; }
.login-logo img { width: min(280px, 78%); display: block; margin: 0 auto; }
:root[data-theme="dark"] .logo-light { display: none; }
:root[data-theme="light"] .logo-dark { display: none; }

.login-title { font-size: 22px; font-weight: 700; letter-spacing: 0.14em; }
.login-tagline {
  color: var(--accent-ink);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  margin: 2px 0 14px;
}
.login-desc { color: var(--muted); font-size: 13px; margin-bottom: 20px; }

#login-form { display: flex; flex-direction: column; gap: 10px; }
#login-form input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 11px 12px;
  font-size: 14px;
  text-align: center;
}
#login-form input:focus { outline: 1px solid var(--accent-border); }
.login-btn { padding: 11px; font-size: 14px; }
#google-login {
  display: none;
  margin-top: 10px;
  gap: 10px;
  width: 100%;
  background: #000;
  background-color: #000;
  border: 1px solid #000;
  border-radius: 8px;
  color: #fff;
  text-decoration: none;
  filter: none;
  box-shadow: none;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}
#google-login:not(.hidden) { display: inline-flex; }
body.page-login #google-login,
body.page-login #google-login:focus,
body.page-login #google-login:focus-visible,
body.page-login #google-login:active,
html[data-theme="light"] body.page-login #google-login,
html[data-theme="light"] body.page-login #google-login:focus,
html[data-theme="light"] body.page-login #google-login:focus-visible,
html[data-theme="light"] body.page-login #google-login:active {
  background: #000;
  background-color: #000;
  border: 1px solid #000;
  color: #fff;
  filter: none;
}
body.page-login #google-login:hover,
html[data-theme="light"] body.page-login #google-login:hover {
  background: #1a1a1a;
  background-color: #1a1a1a;
  border-color: #1a1a1a;
  color: #fff;
  filter: none;
}
#google-login .google-mark {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}
.login-error { color: var(--red); font-size: 13px; margin-top: 12px; }

/* All mobile widths: phones, fold cover + inner, tablets. Assets / Trades pickers. */
@media (max-width: 1024px) {
  #trades-panel .panel-head {
    flex-wrap: wrap;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  #trades-heading { width: 100%; }
  #trades-head-tabs {
    width: 100%;
    max-width: 100%;
    justify-content: flex-start;
    overflow: visible;
  }
  #home-asset-tabs,
  #trade-tabs { overflow: visible; }
  .asset-picker-btn { display: inline-flex; }
  #home-asset-tabs .asset-inline,
  #trade-tabs .status-inline { display: none; }
  .asset-picker-menu:not(.hidden) {
    display: flex;
  }
  body.page-home .asset-picker-menu {
    background: #071016;
    border-color: #253238;
  }
  html[data-theme="light"] body.page-home .asset-picker-menu {
    background: #f8f9fa;
    border-color: #dadce0;
  }
}

/* ---------- responsive: phones ---------- */
@media (max-width: 640px) {
  body { padding: 12px 12px 32px; }

  /* header stacks; status tape full width, action buttons centered below it */
  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin-bottom: 0;
  }
  /* Studio / Charts / Guide: restore space under header actions before content */
  .topbar:not(:has(.topbar-actions)) {
    margin-bottom: 20px;
  }
  .brand h1 { font-size: 16px; }
  .topbar-right {
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: 0;
    max-width: 100%;
    min-width: 0;
  }
  /* Studio / Charts / Guide header chips + buttons need breathing room */
  .topbar:not(:has(.topbar-actions)) .topbar-right {
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
  }
  .page-charts .topbar-right,
  .page-devices .topbar-right,
  .page-guide .topbar-right {
    justify-content: flex-end;
  }
  .page-charts .topbar-right > .site-nav,
  .page-guide .topbar-right > .site-nav {
    order: 1;
    margin-left: auto;
  }
  .page-devices .topbar-actions {
    width: auto;
    flex: 0 0 auto;
    margin-left: auto;
    margin-top: 0;
    margin-bottom: 0;
    justify-content: flex-end;
  }
  .page-charts .site-nav-cluster {
    width: 100%;
    min-width: 0;
    flex-wrap: nowrap;
    justify-content: flex-end;
  }
  .page-charts #charts-meta.chip {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 4px 10px;
  }
  .rulebook-info {
    position: static;
    flex: 1 1 100%;
    order: 1;
    min-width: 0;
    max-width: none;
    width: 100%;
    overflow: hidden;
    pointer-events: auto;
  }
  .topbar-actions {
    flex: 1 1 100%;
    order: 2;
    display: flex;
    width: 100%;
    justify-content: space-between;
    align-items: center;
    flex-wrap: nowrap;
    gap: 5px;
    /* equal air above/below so buttons sit between status tape and symbol ticker */
    margin-top: 16px;
    margin-bottom: 16px;
    min-height: 44px;
    box-sizing: border-box;
  }
  .topbar-actions > .site-nav { flex: 0 1 auto; }
  .topbar-actions > .btn,
  .topbar-actions > a.btn,
  .topbar-actions .home-lead-row > a.btn {
    flex: 0 1 auto;
    min-width: max-content;
    justify-content: center;
    padding-left: 8px;
    padding-right: 8px;
    text-align: center;
    white-space: nowrap;
  }
  /* theme toggle: compact width, same height as Guide / Studio / Logout */
  .topbar-actions > .btn.icon,
  .topbar-actions .home-lead-row > .btn.icon {
    flex: 0 0 auto;
    width: 28px;
    height: 36px;
    min-width: 28px;
    min-height: 36px;
    padding: 0;
    border-radius: 8px;
    box-sizing: border-box;
  }
  .topbar-actions > .btn.icon svg,
  .topbar-actions .home-lead-row > .btn.icon svg {
    width: 14px;
    height: 14px;
  }
  /* model select: wide enough for ASTRA / OPUS / KIMI */
  .topbar-actions > .llm-model-wrap {
    flex: 0 0 auto;
    width: 70px;
    min-width: 70px;
  }
  .llm-model-wrap select {
    width: 70px;
    height: 36px;
    min-width: 70px;
    max-width: 70px;
    min-height: 36px;
    padding: 0 5px;
    font-size: 10px;
    font-weight: 650;
    letter-spacing: -0.02em;
    line-height: 1.2;
    text-align: center;
    text-align-last: center;
    border-radius: 8px;
    box-sizing: border-box;
    appearance: none;
    -webkit-appearance: none;
    background-image: none;
  }
  .ticker-field { margin-top: 0; }
  .ticker-tape {
    margin-top: 0;
  }
  .chip-marquee {
    mask-image: linear-gradient(90deg, transparent, #000 14px, #000 calc(100% - 6px), transparent);
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 14px, #000 calc(100% - 6px), transparent);
  }

  /* controls become a 2-column grid with full-width action buttons */
  .controls { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .control-group input:not([type="checkbox"]):not([type="radio"]),
  .control-group select { width: 100%; min-width: 0; }
  #ctrl-equity,
  #ctrl-position-size,
  #ctrl-playbook,
  #ctrl-rules {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    max-width: none;
  }
  #ctrl-equity input,
  #ctrl-position-size .size-input-wrap,
  #ctrl-playbook #rulebook,
  #ctrl-rules .rules-dropdown,
  #ctrl-rules .rules-dropdown-btn {
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
  }
  #ctrl-equity.mode-equity,
  .mode-equity {
    flex: 0 0 108px;
    width: 108px;
    max-width: 108px;
  }
  #ctrl-equity.mode-equity input {
    width: 108px !important;
    min-width: 108px !important;
    max-width: 108px !important;
  }
  #ctrl-risk,
  #ctrl-risk.mode-risk,
  .mode-risk {
    flex: 0 0 auto;
    width: auto;
    max-width: none;
  }
  #ctrl-risk input,
  .mode-risk input {
    width: 40px !important;
    min-width: 40px !important;
    max-width: 40px !important;
  }
  /* Phones: Equity under Kill. Paper/Live stay on that same row, compact. */
  .card[data-tour="mode"] {
    display: grid;
    grid-template-columns: max-content 1fr auto;
    align-items: start;
    column-gap: 10px;
    row-gap: 8px;
  }
  .card[data-tour="mode"] .panel-head {
    display: contents;
  }
  .card[data-tour="mode"] .panel-head h2 {
    grid-column: 1 / 3;
    grid-row: 1;
    align-self: center;
  }
  .card[data-tour="mode"] #btn-kill {
    grid-column: 3;
    grid-row: 1;
    justify-self: end;
    align-self: center;
  }
  .card[data-tour="mode"] .mode-toolbar {
    display: contents;
  }
  .card[data-tour="mode"] #mode-toggle {
    grid-column: 1;
    grid-row: 2;
    justify-self: start;
    align-self: end;
    width: max-content;
    max-width: max-content;
    flex: 0 0 auto;
  }
  .card[data-tour="mode"] #mode-toggle .mode-btn {
    flex: 0 0 auto;
    width: auto;
    min-width: 0;
    padding-left: 12px;
    padding-right: 12px;
  }
  .card[data-tour="mode"] #ctrl-equity {
    grid-column: 3;
    grid-row: 2;
    justify-self: end;
    align-self: end;
  }
  .card[data-tour="mode"] #ctrl-risk {
    grid-column: 2;
    grid-row: 2;
    justify-self: end;
    align-self: end;
  }
  .card[data-tour="mode"] #trading-mode {
    grid-column: 1 / -1;
    grid-row: 3;
    padding-top: 14px;
  }
  .control-group #rulebook { max-width: none; width: 100% !important; }
  /* swap History (days) ↔ Rulebook; Size up / Playbook down — phones only */
  .controls > .control-group:nth-child(1) { order: 1; } /* provider */
  .controls > .control-group:nth-child(2) { order: 6; } /* history */
  .controls > .control-group:nth-child(3) { order: 3; } /* equity */
  .controls > .control-group:nth-child(4) { order: 2; } /* position size — up */
  .controls > .control-group:nth-child(5) { order: 4; } /* playbook — down */
  .controls > .control-group:nth-child(6) { order: 5; } /* rules */
  .controls > .control-actions { order: 7; }
  .control-actions { grid-column: 1 / -1; margin-left: 0; }
  .control-actions .btn { flex: 1; padding: 12px; }
  /* selected provider label: slightly smaller on phones (short name is applied in JS) */
  #provider,
  #rulebook { font-size: 13px !important; }

  /* engine heartbeat controls */
  .monitor-row { gap: 12px; align-items: stretch; }
  .monitor-controls {
    width: 100%;
    gap: 12px;
  }
  .monitor-every { gap: 8px; }
  .monitor-actions {
    width: 100%;
    gap: 10px;
  }
  .monitor-actions .btn { flex: 1; }

  /* prevent iOS focus auto-zoom: inputs must be >= 16px */
  input, select { font-size: 16px !important; }

  .panel-head { flex-wrap: wrap; gap: 6px; }
  .studio-train .panel-head-actions { flex-wrap: wrap; }
  .tabs { overflow-x: auto; max-width: 100%; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  body.page-ai .wake-picker.tabs,
  body.page-ai .llm-family-picker.tabs,
  body.page-ai .ai-apps-picker.tabs,
  body.page-charts .chart-quick-picker.tabs {
    overflow: visible;
  }
  body.page-charts .chart-quick-group {
    width: max-content;
  }
  body.page-charts .chart-quick-picker {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
  }
  body.page-charts .chart-quick-btn {
    width: 100%;
    min-width: 0;
    max-width: none;
    box-sizing: border-box;
    justify-content: space-between;
    padding: 4px 6px;
  }
  body.page-charts .chart-quick-menu {
    min-width: 0;
    width: 188px;
  }
  .tab { white-space: nowrap; }

  /* proposal cards: badge stays on the title row, details drop below */
  .proposal-top .status-badge { order: 3; }
  .proposal-top .px { order: 4; width: 100%; }
  .symbol { font-size: 16px; }
  .plan { grid-template-columns: repeat(2, 1fr); }
  .decision-row .btn { flex: 1; padding: 12px; }
  .studio-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
  .studio-actions > #btn-validate,
  .studio-actions > #btn-load-live {
    flex: 1 1 calc(50% - 4px);
  }
  .studio-right .studio-replay-row {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin-bottom: 22px;
  }
  .studio-right .studio-replay-row .draft-name {
    width: 100%;
    flex: none;
    order: 0;
    text-align: left;
  }
  .studio-right .studio-replay-pair {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
    gap: 8px;
    width: 100%;
  }
  .studio-right .studio-replay-row .btn,
  .studio-right .studio-replay-row select.mini-input {
    width: 100%;
    min-width: 0;
    flex: none;
  }
  .studio-right .studio-replay-row .btn {
    padding: 12px 10px;
    font-size: 14px;
  }
  /* Ask AI + Capture: smaller placeholder text only (field size unchanged) */
  #assistant-q::placeholder,
  #chat-input::placeholder,
  #transcript::placeholder {
    font-size: 11px;
  }
  .studio-actions .studio-draft-pair .btn {
    flex: 1 1 0;
    min-width: 0;
    padding: 12px 8px;
    font-size: 12px;
  }
  /* extra breathing room around AI brief + action buttons on touch screens */
  .ai-brief { margin: 16px 0 18px; }
  .decision-wrap { margin-top: 16px; gap: 12px; }
  .decision-wrap > .btn { width: 100%; }

  .metrics { grid-template-columns: repeat(2, 1fr); }

  /* audit/alert rows wrap instead of truncating on small screens */
  .audit-row { flex-wrap: wrap; row-gap: 2px; min-width: 0; }
  .audit-detail {
    white-space: normal;
    overflow: visible;
    overflow-wrap: anywhere;   /* long JSON tokens must not widen the page */
    word-break: break-word;
    max-width: 100%;
  }
  #alerts .alert-marquee,
  #alerts .alert-marquee-track {
    display: inline;
    white-space: inherit;
    animation: none;
    transform: none;
  }
  .paper-open-row.audit-row { flex-wrap: nowrap; }
  .paper-open-row .paper-open-detail {
    white-space: nowrap;
    overflow: hidden;
    overflow-wrap: normal;
    word-break: normal;
  }

  .login-card { padding: 22px 18px 26px; }
  .login-logo img { width: min(240px, 82%); }

  .charts-grid { grid-template-columns: 1fr; gap: 10px; }
  .chart-card {
    padding: 12px 12px 16px;
    overflow: hidden; /* keep candlesticks / price scale inside the outline */
  }
  .chart-canvas {
    height: 200px;
    max-width: 100%;
    overflow: hidden;
  }

  /* theme toggle: compact width, same height as text header buttons */
  .topbar-actions > .btn.icon,
  .topbar-actions .home-lead-row > .btn.icon {
    width: 28px;
    height: 36px;
    min-width: 28px;
    min-height: 36px;
    padding: 0;
    border-radius: 8px;
    box-sizing: border-box;
  }
}

/* comfortable touch targets on touch devices */
@media (pointer: coarse) {
  .btn { min-height: 42px; }
  .btn.small { min-height: 36px; }
  .btn.icon { width: 42px; height: 42px; }
  .tab { padding: 8px 12px; }
  body.page-ai .ai-mobile-bar .wake-picker .tab,
  body.page-ai .ai-mobile-bar .llm-family-btn,
  body.page-ai .ai-mobile-bar .ai-apps-btn {
    padding: 4px 10px;
    font-size: 12px;
    min-height: 0;
  }
}
/* phones: theme toggle matches sibling button height */
@media (pointer: coarse) and (max-width: 640px) {
  .topbar-actions > .btn.icon,
  .topbar-actions .home-lead-row > .btn.icon {
    width: 28px;
    height: 36px;
    min-width: 28px;
    min-height: 36px;
    padding: 0;
    border-radius: 8px;
  }
  .topbar-actions > .btn.icon svg,
  .topbar-actions .home-lead-row > .btn.icon svg {
    width: 14px;
    height: 14px;
  }
  .topbar-actions .llm-model-wrap {
    width: 70px;
    min-width: 70px;
  }
  .topbar-actions .llm-model-wrap select {
    width: 70px;
    min-width: 70px;
    max-width: 70px;
    height: 36px;
    min-height: 36px;
  }
}

/* ---------- BTC Timing page ---------- */
.btc-live-quote {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
  margin-right: 8px;
  font-variant-numeric: tabular-nums;
}
.btc-live-quote .btc-sym { color: var(--muted); font-size: 12px; font-weight: 600; }
.btc-live-quote strong { font-size: 18px; letter-spacing: -0.02em; line-height: 1.2; }
.btc-live-quote .chip {
  padding: 5px 11px;
  line-height: 1.25;
}
.btc-controls { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; margin-bottom: 14px; }
.btc-controls .btc-meta { flex: 1 1 100%; color: var(--muted); font-size: 12px; line-height: 1.45; }
.btc-controls .chk { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); padding-top: 18px; }
.btc-data-mode { min-width: 0; }
.btc-data-mode #data-mode-label { line-height: 1.35; }
.btc-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(260px, 0.9fr);
  gap: 14px;
  align-items: start;
}
.btc-layout .span { grid-column: 1 / -1; }
.btc-chart-card { min-width: 0; }
.btc-chart-canvas { height: min(52vh, 480px); width: 100%; }
.btc-side { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.btc-bias-row, .btc-signal-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  row-gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.btc-bias-row:last-child, .btc-signal-row:last-child { border-bottom: 0; }
.btc-bias-row .chip,
.btc-signal-row .chip,
.btc-paper-row .chip,
.btc-wallet-row .chip {
  padding: 5px 11px;
  line-height: 1.25;
}
.btc-signal-list, .btc-bias-list { max-height: 280px; overflow: auto; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.data-table th, .data-table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); }
.data-table th { color: var(--muted); font-weight: 600; }
.chip.bad { border-color: rgba(229, 72, 77, 0.5); color: var(--red); }
.btc-paper-open { display: flex; flex-direction: column; gap: 12px; }
.btc-paper-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  row-gap: 8px;
}
.btc-paper-fills {
  margin: 0;
  padding-top: 6px;
  line-height: 1.45;
}
.btc-paper-stats { margin-top: 10px; line-height: 1.45; }
.btc-paper-wallet {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.btc-wallet-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.btc-equity {
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.chk.tight { font-size: 12px; color: var(--muted); gap: 6px; display: inline-flex; align-items: center; }
.btc-overlay-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  padding: 0 0 10px;
}
.btc-chart-canvas.adx-pane { height: 90px; margin-top: 8px; }
.btc-chart-canvas.adx-pane.hidden { display: none; }
.page-btc .panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 12px;
}
.page-btc .panel-head .hint {
  min-width: 0;
  line-height: 1.4;
}
@media (max-width: 900px) {
  .btc-layout { grid-template-columns: 1fr; }
  .btc-chart-canvas { height: 280px; }
  .btc-live-quote { width: 100%; order: 3; margin-right: 0; }
  /* Keep TF tabs compact; put Live/Synthetic on its own row so it doesn't wrap into a 80px column */
  .page-btc .btc-data-mode {
    flex: 1 1 100%;
    width: 100%;
  }
  .page-btc .btc-data-mode .chk {
    padding-top: 0;
    width: 100%;
  }
  .page-btc .btc-data-mode #data-mode-label {
    white-space: nowrap;
  }
  .page-btc .panel-head .hint {
    flex: 1 1 100%;
    word-break: break-word;
  }
  .page-btc .btc-controls .control-actions {
    display: flex;
    flex-direction: column;
    width: 100%;
    margin-left: 0;
    gap: 8px;
  }
  .page-btc .btc-controls .control-actions .btn {
    flex: none;
    width: 100%;
    white-space: nowrap;
  }
}
@media (max-width: 640px) {
  body.page-btc {
    padding-bottom: calc(28px + env(safe-area-inset-bottom, 0px));
  }
}

/* ---------- AI Studio / Devices ---------- */
body.page-ai { padding-bottom: 28px; }
.ai-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 340px);
  grid-template-areas:
    "main side"
    "below side";
  gap: 14px;
  align-items: start;
}
.ai-main { grid-area: main; }
.ai-shell > aside { grid-area: side; }
.ai-below {
  grid-area: below;
  display: grid;
  gap: 14px;
  min-width: 0;
}
.ai-below > .card { margin-bottom: 0; }
.ai-main, .ai-side, .ai-below { min-width: 0; }
.ai-main {
  display: flex;
  flex-direction: column;
}
.ai-main > #runtime-note {
  margin: -4px 0 10px;
  text-transform: none;
  letter-spacing: 0.02em;
}
.ai-voice-stage {
  max-height: 0;
  margin: 0;
  padding: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  flex-shrink: 0;
  transform: translateY(-6px);
  transition:
    max-height 0.45s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.35s ease,
    margin 0.35s ease,
    padding 0.35s ease,
    transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}
.ai-main[data-voice="on"] .ai-voice-stage,
.ai-voice-stage.is-live {
  max-height: 320px;
  margin: 0 0 12px;
  padding: 4px 0 16px;
  opacity: 1;
  overflow: visible;
  pointer-events: auto;
  transform: none;
  border-bottom: 1px solid var(--border);
}
.ai-orb-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.ai-orb-stage {
  display: grid;
  place-items: center;
}
.ai-voice-live {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}
.ai-main[data-voice="off"] .ai-voice-live { display: none; }
.ai-orb {
  --orb: var(--accent);
  width: 132px;
  height: 132px;
  border-radius: 50%;
  position: relative;
  background:
    radial-gradient(circle at 35% 30%, #fff 0 8%, transparent 9%),
    radial-gradient(circle at 50% 45%, var(--orb) 0 38%, #1a1d22 72%);
  box-shadow:
    0 0 0 8px var(--accent-soft),
    0 0 42px color-mix(in srgb, var(--accent) 35%, transparent);
  transition: box-shadow 0.25s ease, transform 0.25s ease;
}
.ai-orb::after {
  content: "";
  position: absolute;
  inset: 18%;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.18);
}
.ai-orb[data-state="listening"] {
  --orb: #7ee0ff;
  box-shadow: 0 0 0 10px rgba(126,224,255,0.16), 0 0 56px rgba(126,224,255,0.45);
}
.ai-orb[data-state="speaking"] {
  --orb: #9ef0c8;
  box-shadow: 0 0 0 10px rgba(158,240,200,0.16), 0 0 56px rgba(158,240,200,0.42);
  animation: ai-pulse 1s ease-in-out infinite;
}
.ai-orb[data-state="working"] {
  --orb: var(--amber);
  animation: ai-pulse 1.2s ease-in-out infinite;
}
.ai-orb[data-state="waiting_approval"] {
  --orb: var(--amber);
  box-shadow: 0 0 0 10px rgba(240,166,58,0.18), 0 0 48px rgba(240,166,58,0.4);
}
.ai-orb[data-state="error"] {
  --orb: var(--red);
}
@keyframes ai-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}
.ai-orb-label { text-align: center; color: var(--muted); font-size: 12px; }
.ai-orb-label strong { display: block; color: var(--text); font-size: 14px; margin-bottom: 2px; }
.ai-main[data-voice="on"] .ai-transcript {
  min-height: 240px;
  max-height: 48vh;
}
.ai-transcript {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 360px;
  max-height: 62vh;
  overflow: auto;
  padding: 4px 2px 12px;
}
.ai-line { padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); }
.ai-line.expert { border-color: var(--accent-border); }
.ai-line.agent { background: var(--accent-soft); }
.ai-line .who { font-size: 11px; color: var(--muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.04em; }
.ai-line pre { white-space: pre-wrap; font-family: inherit; font-size: 13px; }
.ai-composer {
  display: block;
}
.ai-composer-field {
  position: relative;
  border-radius: 10px;
  border: 1px solid var(--accent-border);
  background: var(--bg);
  box-shadow: 0 0 0 1px var(--accent-soft), 0 0 18px color-mix(in srgb, var(--accent) 22%, transparent);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.ai-composer-field:focus-within {
  border-color: color-mix(in srgb, var(--accent-border) 42%, var(--border));
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--accent-soft) 45%, transparent),
    0 0 10px color-mix(in srgb, var(--accent) 10%, transparent);
}
.ai-composer textarea {
  display: block;
  width: 100%;
  min-height: 56px;
  resize: vertical;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  padding: 10px 48px 10px 12px;
  font: inherit;
  box-shadow: none;
  pointer-events: auto;
}
.ai-composer textarea:focus,
.ai-composer textarea:focus-visible {
  outline: none;
  box-shadow: none;
}
.ai-composer-action {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: 50%;
  color: var(--accent-ink);
  cursor: pointer;
}
.ai-composer-action svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: none;
}
.ai-composer-action[data-mode="voice"] .icon-wave,
.ai-composer-action[data-mode="send"] .icon-send { display: block; }
.ai-composer-action[data-mode="send"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}
.ai-composer-action:focus-visible {
  outline: 2px solid var(--accent-border);
  outline-offset: 2px;
}
.ai-composer-action:active {
  transform: translateY(-50%);
}
@media (pointer: coarse) {
  .ai-composer textarea { padding-right: 52px; }
  .ai-composer-action {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
  }
}
.ai-activity, .ai-approvals, .ai-browser, .ai-lib { margin-bottom: 12px; }
.ai-activity {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.ai-activity-scroll {
  max-height: min(42vh, 360px);
  overflow: auto;
  overscroll-behavior: contain;
  padding-right: 2px;
}
.ai-activity-scroll::-webkit-scrollbar {
  width: 2px;
}
.ai-activity-scroll::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}
.ai-activity-scroll::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 999px;
}
.ai-activity-scroll::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}
#audit::-webkit-scrollbar,
#alerts::-webkit-scrollbar,
.ai-activity-scroll::-webkit-scrollbar {
  width: 2px;
  height: 2px;
}
@supports not selector(::-webkit-scrollbar) {
  html,
  .audit-body,
  .ai-activity-scroll {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
  }
  .daily-brief-modal-card .modal-body {
    scrollbar-width: thin;
    scrollbar-color: #8fa8af transparent;
  }
  html[data-theme="light"] .daily-brief-modal-card .modal-body {
    scrollbar-width: thin;
    scrollbar-color: #d5d9de transparent;
  }
}
.ai-event {
  font-size: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.ai-event .ts { color: var(--muted); font-size: 11px; }
.ai-lib #library {
  display: grid;
  gap: 18px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
}
.ai-lib #library > .ai-empty {
  margin: 0;
}
.ai-lib > .hint { margin: 0 0 14px; }
.ai-lib-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0 16px;
}
.ai-lib-filters .chip {
  cursor: pointer;
  margin-left: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-width: 96px;
  min-height: 34px;
  padding: 8px 16px;
}
.ai-lib-filters .chip.ok {
  border-color: rgba(47, 191, 113, 0.5);
  color: var(--green);
}
.ai-lib-band-label {
  margin: 0 0 8px;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.ai-lib-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  grid-auto-rows: 400px;
  gap: 16px;
  align-items: stretch;
}
.ai-lib-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  max-height: 100%;
  padding: 0;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--border) 65%, var(--text) 35%);
  border-radius: 12px;
  background: var(--surface);
}
.ai-lib-banner {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 12px 14px;
  flex: 0 0 auto;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.ai-lib-banner h3 {
  margin: 0;
  min-width: 0;
  flex: 1 1 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
  overflow: hidden;
}
.ai-lib-title {
  display: block;
  overflow: hidden;
  min-width: 0;
  width: 100%;
}
.ai-lib-title-track {
  display: inline-block;
  font-weight: 700;
  white-space: nowrap;
  will-change: transform;
}
.ai-lib-title.is-overflow .ai-lib-title-track {
  animation: ai-lib-title-marquee var(--ai-lib-title-duration, 8s) linear infinite alternate;
}
.ai-lib-title.is-overflow:hover .ai-lib-title-track,
.ai-lib-title.is-overflow:focus-within .ai-lib-title-track {
  animation-play-state: paused;
}
@keyframes ai-lib-title-marquee {
  0%, 12% { transform: translateX(0); }
  88%, 100% { transform: translateX(var(--ai-lib-title-shift, 0px)); }
}
@media (prefers-reduced-motion: reduce) {
  .ai-lib-title.is-overflow .ai-lib-title-track { animation: none; }
}
.ai-lib-banner-chips {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  position: relative;
  z-index: 1;
}
.ai-lib-banner .chip {
  margin-left: 0;
  flex: 0 0 auto;
  background: var(--surface);
  white-space: nowrap;
}
.ai-lib-banner .chip.draft {
  color: #b8f7e4;
  border-color: #b8f7e4;
}
.ai-lib-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  padding: 12px 14px 14px;
  overflow-x: hidden;
  overflow-y: auto;
}
.ai-lib-body .asset-picks {
  max-height: none;
  overflow: visible;
}
.ai-lib-notes {
  display: grid;
  gap: 2px;
  min-width: 0;
  max-width: 100%;
  max-height: none;
  overflow: visible;
  overflow-wrap: anywhere;
  word-break: break-word;
  flex-shrink: 0;
}
.ai-lib-notes .ts {
  min-width: 0;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}
html:not([data-theme="light"]) .ai-lib-body::-webkit-scrollbar,
html:not([data-theme="light"]) .ai-lib-notes::-webkit-scrollbar {
  width: 3px;
  height: 3px;
}
html:not([data-theme="light"]) .ai-lib-body::-webkit-scrollbar-track,
html:not([data-theme="light"]) .ai-lib-notes::-webkit-scrollbar-track {
  background: transparent;
}
html:not([data-theme="light"]) .ai-lib-body::-webkit-scrollbar-thumb,
html:not([data-theme="light"]) .ai-lib-notes::-webkit-scrollbar-thumb {
  background: #8fa8af;
  border-radius: 999px;
}
html:not([data-theme="light"]) .ai-lib-body::-webkit-scrollbar-thumb:hover,
html:not([data-theme="light"]) .ai-lib-notes::-webkit-scrollbar-thumb:hover {
  background: #adc2c7;
}
html[data-theme="light"] .ai-lib-body,
html[data-theme="light"] .ai-lib-notes {
  padding-right: 10px;
}
html[data-theme="light"] .ai-lib-body::-webkit-scrollbar,
html[data-theme="light"] .ai-lib-notes::-webkit-scrollbar,
html[data-theme="light"] .daily-brief-modal-card .modal-body::-webkit-scrollbar {
  width: 3px;
  height: 3px;
}
html[data-theme="light"] .ai-lib-body::-webkit-scrollbar-track,
html[data-theme="light"] .ai-lib-notes::-webkit-scrollbar-track {
  background: transparent;
}
html[data-theme="light"] .ai-lib-body::-webkit-scrollbar-thumb,
html[data-theme="light"] .ai-lib-notes::-webkit-scrollbar-thumb {
  background: #d5d9de;
  border-radius: 999px;
}
html[data-theme="light"] .ai-lib-body::-webkit-scrollbar-thumb:hover,
html[data-theme="light"] .ai-lib-notes::-webkit-scrollbar-thumb:hover {
  background: #c4c8cd;
}
.ai-lib-label {
  margin-top: 2px;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.asset-picks {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 0;
  min-width: 0;
  max-width: 100%;
}
.asset-picks .chip {
  cursor: pointer;
  margin-left: 0;
  flex: 0 0 auto;
  max-width: 100%;
  box-sizing: border-box;
  white-space: normal;
}
body.page-ai .asset-picks .chip:not(.ok):not(.warn):not(.err):not(.bad) {
  background: rgba(148, 157, 160, 0.2);
  border: 1px solid rgba(148, 157, 160, 0.42);
  color: #c5cccf;
}
.ai-lib-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  margin-top: 4px;
  padding-top: 8px;
  flex-shrink: 0;
}
.ai-lib-actions .btn {
  flex: 0 0 auto;
  width: auto;
  max-width: 100%;
  white-space: nowrap;
}
.ai-lib-for {
  flex: 1 1 100%;
  color: var(--muted);
  font-size: 11px;
}
.ai-lib-card .wf-out { margin-top: 0; }
@media (max-width: 640px) {
  .ai-lib-grid { grid-auto-rows: 360px; }
  .ai-lib-card,
  .ai-lib-body,
  .ai-lib-notes,
  .lib-asset-tools {
    overflow-x: hidden;
    max-width: 100%;
  }
  .ai-lib-body {
    overflow-y: auto;
  }
  .ai-lib-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .ai-lib-actions .btn {
    width: 100%;
  }
  .ai-lib-for {
    flex: 0 0 auto;
    width: 100%;
  }
}
.engine-lane-note { margin: 0 0 10px; }
.ai-empty { color: var(--muted); font-size: 12px; }
.ai-extract {
  max-height: 220px;
  overflow: auto;
  font-size: 12px;
  white-space: pre-wrap;
  color: var(--muted);
}
.perm-grid { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; }
.perm-grid label { display: flex; gap: 8px; align-items: center; font-size: 13px; }
.pair-token { word-break: break-all; font-family: var(--mono); font-size: 12px; }

.page-devices .devices-shell {
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(0, 1.6fr);
  gap: 16px;
  align-items: stretch;
  width: 100%;
}
.page-devices .devices-pair-card,
.page-devices .devices-list-card {
  min-width: 0;
  min-height: 100%;
  height: 100%;
  padding: 22px;
}
.page-devices .devices-list-card {
  display: flex;
  flex-direction: column;
}
.page-devices .devices-pair-card .panel-head,
.page-devices .devices-list-card .panel-head {
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  margin-bottom: 18px;
}
.page-devices .devices-pair-card h2,
.page-devices .devices-list-card h2 {
  font-size: 16px;
}
.page-devices .panel-head .hint {
  line-height: 1.45;
  max-width: none;
}
.page-devices .devices-pair-form {
  display: grid;
  gap: 14px;
}
.page-devices .devices-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.page-devices .devices-field[for="dev-platform"] {
  min-width: 0;
}
.page-devices .devices-field span {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.page-devices .devices-field input {
  width: 100%;
  min-width: 0;
  min-height: 46px;
  padding: 12px 14px;
  font-size: 15px;
  line-height: 1.3;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.page-devices .devices-field input:focus {
  outline: 1px solid var(--accent-border);
  border-color: var(--accent-border);
}
.page-devices .devices-pair-form .btn {
  min-height: 46px;
  width: 100%;
  font-size: 14px;
}
.page-devices .pair-token:empty { display: none; }
.page-devices .pair-token {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
}
.page-devices .pair-token strong { color: var(--text); font-weight: 600; }
.page-devices .pair-cmd { margin-top: 10px; }
.page-devices .pair-cmd summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
}
.page-devices .pair-cmd pre {
  margin-top: 10px;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--text);
}
.page-devices .devices-list {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  gap: 0;
}
.page-devices .devices-empty {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  min-height: 160px;
}
.page-devices .devices-empty strong {
  font-size: 15px;
  font-weight: 650;
}
.page-devices .devices-empty .hint {
  line-height: 1.45;
  max-width: 36em;
}
.page-devices .device-row {
  padding: 18px 0;
  border-bottom: 1px solid var(--border);
}
.page-devices .device-row:first-child { padding-top: 0; }
.page-devices .device-row:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}
.page-devices .device-row.is-revoked { opacity: 0.62; }
.page-devices .device-row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  flex-wrap: wrap;
}
.page-devices .device-identity {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}
.page-devices .device-identity strong {
  font-size: 16px;
  font-weight: 650;
}
.page-devices .device-idline {
  margin: 8px 0 0;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.page-devices .device-identity .chip {
  margin: 0;
  padding: 5px 12px;
  font-size: 12px;
}
.page-devices .device-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.page-devices .device-actions .btn {
  min-height: 34px;
  padding: 7px 14px;
  font-size: 13px;
}
.page-devices .device-meta {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}
.page-devices .device-meta-cell {
  min-width: 0;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.page-devices .device-meta-cell span {
  display: block;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}
.page-devices .device-meta-cell strong {
  display: block;
  font-size: 14px;
  font-weight: 550;
  color: var(--text);
  overflow-wrap: anywhere;
  line-height: 1.35;
}
.page-devices .device-meta-cell.mono strong {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 450;
}
.page-devices .device-perms {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.page-devices .device-perm {
  position: relative;
  display: inline-flex;
  margin: 0;
  cursor: pointer;
}
.page-devices .device-perm input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.page-devices .device-perm span {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.2;
}
.page-devices .device-perm input:checked + span {
  border-color: var(--accent-border);
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.page-devices .device-perm input:focus-visible + span {
  outline: 1px solid var(--accent-border);
}
.page-devices .device-perm input:disabled + span {
  opacity: 0.45;
  cursor: not-allowed;
}
@media (min-width: 901px) {
  .page-devices .devices-pair-card .panel-head {
    gap: 12px;
    margin-bottom: 28px;
  }
  .page-devices .devices-pair-form {
    gap: 26px;
  }
  .page-devices .devices-pair-card .devices-field {
    gap: 8px;
  }
}
@media (max-width: 900px) {
  .page-devices .devices-shell {
    grid-template-columns: 1fr;
    align-items: start;
  }
  .page-devices .devices-pair-card,
  .page-devices .devices-list-card {
    height: auto;
    min-height: 0;
  }
  .page-devices .device-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .ai-shell {
    grid-template-columns: 1fr;
    grid-template-areas:
      "main"
      "side"
      "below";
  }
}
@media (prefers-reduced-motion: reduce) {
  .ai-voice-stage, .ai-orb, .ai-composer textarea {
    transition-duration: 0.01ms !important;
    animation: none !important;
  }
}
.ai-expert-training .xt-venue-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  margin: 0 0 8px;
}
.ai-expert-training .xt-venue-head .chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: max-content;
  min-width: 8.5em;
  min-height: 26px;
  padding: 5px 14px;
  line-height: 1.2;
  white-space: nowrap;
}
.ai-expert-training .xt-connect {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 10px 0;
}
.ai-expert-training .xt-secret {
  width: 140px;
  min-width: 120px;
}
.xt-sources {
  display: grid;
  gap: 8px;
  margin: 8px 0;
}

/* ---------- Home floating Ask AI ---------- */
.home-ask {
  position: fixed;
  left: 20px;
  bottom: 20px;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  pointer-events: none;
}
.home-ask-fab,
.home-ask-panel { pointer-events: auto; }
.home-ask-fab {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--accent-border);
  background: #B8F7E4;
  color: var(--on-accent);
  font-size: 14px;
  font-weight: 650;
  letter-spacing: 0.01em;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
  cursor: pointer;
}
.home-ask-fab:hover,
body.page-home .btn-chart:hover { filter: brightness(1.04); }
body.page-home .btn-chart {
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
}
body.page-home .btn-chart:visited,
body.page-home .btn-chart:active {
  background: #B8F7E4;
  border-color: #B8F7E4;
  color: var(--on-accent);
  text-decoration: none;
}
body.page-home .btn-chart:active { transform: none; }
html[data-theme="light"] body.page-home .btn-chart,
html[data-theme="light"] body.page-home .btn-chart:hover,
html[data-theme="light"] body.page-home .btn-chart:visited,
html[data-theme="light"] body.page-home .btn-chart:active,
html[data-theme="light"] body.page-home .btn-chart:focus,
html[data-theme="light"] body.page-home .home-ask-fab,
html[data-theme="light"] body.page-home .home-ask-fab:hover,
html[data-theme="light"] body.page-home .home-ask-fab:focus {
  border-color: #B8F7E4;
  outline: none;
}
.home-ask[data-state="open"] .home-ask-fab { display: none; }

/* Z Fold cover only (~344×882). Regular phones keep ? next to Menu. */
@media (max-width: 380px) and (min-height: 820px) {
  body.page-home .home-logout-row .site-tour {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 40;
    display: flex;
    width: 44px;
    height: 44px;
    margin: 0;
  }
  body.page-home:has(.home-ask[data-state="open"]) .home-logout-row .site-tour {
    display: none;
  }
}
/* Explicit old phones only: S8+/S9/Note 8–9, iPhone XR-era, iPhone 16. Not modern Android. */
html[data-tour-fab] body.page-home .home-logout-row .site-tour {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 40;
  display: flex;
  width: 44px;
  height: 44px;
  margin: 0;
}
html[data-tour-fab] body.page-home:has(.home-ask[data-state="open"]) .home-logout-row .site-tour {
  display: none;
}
.home-ask-panel {
  width: min(380px, calc(100vw - 32px));
  max-height: min(70vh, 520px);
  background: var(--card);
  border: 1px solid var(--accent-border);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}
.home-ask-panel[hidden] { display: none; }
.home-ask-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.home-ask-head h2 {
  font-size: 14px;
  font-weight: 650;
}
.home-ask-head-actions { display: flex; gap: 4px; }
.home-ask-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.home-ask-icon:hover { border-color: var(--accent-border); color: var(--accent-ink); }
.home-ask-body {
  flex: 1;
  min-height: 160px;
  overflow: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.home-ask-empty {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}
.home-ask-msg { display: grid; gap: 4px; }
.home-ask-msg.is-user { justify-items: end; }
.home-ask-who {
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.home-ask-bubble {
  max-width: 92%;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 13px;
  white-space: pre-wrap;
}
.home-ask-msg.is-user .home-ask-bubble {
  background: var(--accent-soft);
  border-color: var(--accent-border);
}
.home-ask-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 4px;
  padding: 6px 10px;
  border-radius: 8px;
  background: #B8F7E4;
  color: var(--on-accent);
  font-size: 12px;
  font-weight: 650;
  text-decoration: none;
}
.home-ask-form {
  display: flex;
  gap: 6px;
  padding: 10px;
  border-top: 1px solid var(--border);
}
.home-ask-form input {
  flex: 1;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 10px;
  font-size: 13px;
}
.home-ask-form input:focus {
  outline: 1px solid var(--accent-border);
}
.home-ask-form input::placeholder { color: var(--muted); font-size: 12px; }

/* Home only: match AI scene card chrome. Do not restyle chips or primary/reject/approve buttons. */
body.page-home { background: #0b1015; }
body.page-home .card,
body.page-home .proposals-panel,
body.page-home .ticker-field,
body.page-home .modal-card,
body.page-home .home-ask-panel {
  background: #0f181e;
  border: 1px solid #3a535c;
  box-shadow: 0 20px 56px rgba(0, 0, 0, 0.55);
}
body.page-home #daily-brief-card,
body.page-home .modal-card.daily-brief-modal-card,
body.page-home #audit-modal .modal-card,
body.page-home .home-ask-panel {
  background: #0f181e;
  border: 1px solid #3a535c;
  box-shadow: 0 20px 56px rgba(0, 0, 0, 0.55);
}
body.page-home .toast {
  background: #04090e;
  box-shadow: 0 14px 50px #0005;
}
body.page-home .proposals-panel {
  border-radius: 12px;
  padding: 16px;
}
body.page-home .panel-head h2 { color: #d9e8e9; font-weight: 550; }
body.page-home .empty,
body.page-home .hint,
body.page-home .bt-note,
body.page-home .decided { color: #799598; }
body.page-home .metric,
body.page-home .plan .cell,
body.page-home .home-ask-bubble,
body.page-home .home-ask-form input,
body.page-home .llm-model-wrap select,
body.page-home .mini-input,
body.page-home .control-group input:not([type="checkbox"]):not([type="radio"]),
body.page-home .control-group select {
  background: #071016;
  border-color: #253238;
}
body.page-home .engine-asset { border-top-color: #19272d; }
body.page-home .engine-asset:hover,
body.page-home .engine-asset.selected { background: #071016; }
body.page-home .tabs {
  background: #071016;
  border: 1px solid #253238;
  border-radius: 8px;
  padding: 3px;
}
body.page-home .tab { color: #799598; }
body.page-home .tab.active {
  background: #0c1c24;
  color: #a9d8cc;
  box-shadow: inset 0 0 0 1px #304247;
}
body.page-home .home-ask-head,
body.page-home .home-ask-form { border-color: #19272d; }
body.page-home .btn:not(.primary):not(.reject):not(.approve):not(.sync):not(.site-nav-theme),
body.page-home .home-ask-icon {
  background: rgba(184, 247, 228, 0.14);
  border: 1px solid rgba(184, 247, 228, 0.45);
  color: #b8f7e4;
  border-radius: 5px;
}
body.page-home .btn.icon:not(.site-nav-theme) { border-radius: 9px; }
body.page-home .home-ask-icon { border-radius: 8px; }
body.page-home .rulebook-info .chip.ok {
  background: rgba(47, 191, 113, 0.14);
  border-color: rgba(47, 191, 113, 0.5);
  color: var(--green);
}
body.page-home .rulebook-info .chip.warn {
  background: rgba(240, 166, 58, 0.14);
  border-color: rgba(240, 166, 58, 0.5);
  color: var(--amber);
}
body.page-home .rulebook-info .chip.err,
body.page-home .rulebook-info .chip.bad {
  background: rgba(229, 72, 77, 0.12);
  border-color: rgba(229, 72, 77, 0.5);
  color: var(--red);
}

/* Home + AI light only: Chrome-white canvas, not the old mint-white. */
html[data-theme="light"] body.page-home,
html[data-theme="light"] body.page-ai {
  background: #f1f3f4;
  color: #202124;
}
html[data-theme="light"] body.page-home .card,
html[data-theme="light"] body.page-home .proposals-panel,
html[data-theme="light"] body.page-home .ticker-field,
html[data-theme="light"] body.page-home .modal-card,
html[data-theme="light"] body.page-home .home-ask-panel,
html[data-theme="light"] body.page-home #daily-brief-card,
html[data-theme="light"] body.page-home .modal-card.daily-brief-modal-card,
html[data-theme="light"] body.page-home #audit-modal .modal-card {
  background: #ffffff;
  border: 1px solid #dadce0;
  box-shadow: 0 1px 2px rgba(60, 64, 67, 0.12), 0 2px 6px rgba(60, 64, 67, 0.08);
}
html[data-theme="light"] body.page-home .toast { background: #ffffff; box-shadow: 0 1px 2px rgba(60, 64, 67, 0.12), 0 2px 6px rgba(60, 64, 67, 0.08); }
html[data-theme="light"] body.page-home .panel-head h2 { color: #202124; font-weight: 550; }
html[data-theme="light"] body.page-home .empty,
html[data-theme="light"] body.page-home .hint,
html[data-theme="light"] body.page-home .bt-note,
html[data-theme="light"] body.page-home .decided { color: #5f6368; }
html[data-theme="light"] body.page-home .metric,
html[data-theme="light"] body.page-home .plan .cell,
html[data-theme="light"] body.page-home .home-ask-bubble,
html[data-theme="light"] body.page-home .home-ask-form input,
html[data-theme="light"] body.page-home .llm-model-wrap select,
html[data-theme="light"] body.page-home .mini-input,
html[data-theme="light"] body.page-home .control-group input:not([type="checkbox"]):not([type="radio"]),
html[data-theme="light"] body.page-home .control-group select {
  background: #f8f9fa;
  border-color: #dadce0;
  color: #202124;
}
html[data-theme="light"] body.page-home .engine-asset { border-top-color: #e8eaed; }
html[data-theme="light"] body.page-home .engine-asset:hover,
html[data-theme="light"] body.page-home .engine-asset.selected { background: #f8f9fa; }
html[data-theme="light"] body.page-home .tabs {
  background: #f8f9fa;
  border: 1px solid #dadce0;
}
html[data-theme="light"] body.page-home .tab { color: #5f6368; }
html[data-theme="light"] body.page-home .tab.active {
  background: #ffffff;
  color: #17795e;
  box-shadow: inset 0 0 0 1px #dadce0;
}
html[data-theme="light"] body.page-home .home-ask-head,
html[data-theme="light"] body.page-home .home-ask-form { border-color: #e8eaed; }
html[data-theme="light"] body.page-home .engine-manage-link,
html[data-theme="light"] body.page-home .engine-manage-link:visited,
html[data-theme="light"] body.page-home .engine-manage-link:active,
html[data-theme="light"] body.page-home .engine-manage-link:hover {
  color: #17795e;
}
html[data-theme="light"] body.page-home .btn:not(.primary):not(.reject):not(.approve):not(.sync):not(.site-nav-theme),
html[data-theme="light"] body.page-home .home-ask-icon,
html[data-theme="light"] body.page-ai .site-nav summary.btn,
html[data-theme="light"] body.page-ai .ai-mobile-bar .site-nav summary.btn,
html[data-theme="light"] body.page-ai .ai-rail-card .btn:not(.primary):not(.reject):not(.approve),
html[data-theme="light"] body.page-ai .ai-workspace .btn:not(.primary):not(.reject):not(.approve):not(.train):not(.sync):not(.archive):not(.secondary),
html[data-theme="light"] body.page-ai .ai-lib-card .btn:not(.primary):not(.reject):not(.approve):not(.archive):not(.secondary),
html[data-theme="light"] body.page-ai .ai-teach .btn:not(.primary):not(.reject):not(.approve):not(.train):not(.sync):not(.secondary),
html[data-theme="light"] body.page-ai .ai-expert-training .btn:not(.primary):not(.reject):not(.approve):not(.train):not(.sync):not(.secondary) {
  background: rgba(184, 247, 228, 0.55);
  border: 1px solid rgba(23, 121, 94, 0.35);
  color: #17795e;
}
html[data-theme="light"] body.page-ai .site-nav-list {
  background: #ffffff;
  border-color: #dadce0;
  box-shadow: 0 1px 2px rgba(60, 64, 67, 0.12), 0 2px 6px rgba(60, 64, 67, 0.08);
}
html[data-theme="light"] body.page-ai .site-nav-list a,
html[data-theme="light"] body.page-ai .site-nav-list > .site-nav-logout { color: #202124; }
html[data-theme="light"] body.page-ai .site-nav-list a:hover,
html[data-theme="light"] body.page-ai .site-nav-list a[aria-current="page"],
html[data-theme="light"] body.page-ai .site-nav-list > .site-nav-logout:hover {
  background: rgba(184, 247, 228, 0.55);
  color: #17795e;
}
html[data-theme="light"] body.page-ai .ai-lib-banner .chip:not(.ok):not(.warn):not(.err):not(.bad) {
  background: rgba(184, 247, 228, 0.55);
  border: 1px solid rgba(23, 121, 94, 0.35);
  color: #17795e;
}
html[data-theme="light"] body.page-ai .asset-picks .chip:not(.ok):not(.warn):not(.err):not(.bad) {
  background: rgba(60, 64, 67, 0.14);
  border: 1px solid rgba(60, 64, 67, 0.28);
  color: #3c4043;
}
html[data-theme="light"] body.page-ai .ai-lib-banner .chip.ok,
html[data-theme="light"] body.page-ai .asset-picks .chip.ok {
  background: rgba(24, 138, 82, 0.12);
  border-color: rgba(24, 138, 82, 0.45);
  color: var(--green);
}
html[data-theme="light"] body.page-ai .ai-lib-banner .chip.warn,
html[data-theme="light"] body.page-ai .asset-picks .chip.warn {
  background: rgba(178, 106, 0, 0.12);
  border-color: rgba(178, 106, 0, 0.4);
  color: var(--amber);
}
html[data-theme="light"] body.page-home .btn.icon svg { stroke: #17795e; }
html[data-theme="light"] body.page-home .rulebook-info .chip.ok {
  background: rgba(24, 138, 82, 0.12);
  border-color: rgba(24, 138, 82, 0.45);
  color: var(--green);
}
html[data-theme="light"] body.page-home .rulebook-info .chip.warn {
  background: rgba(178, 106, 0, 0.12);
  border-color: rgba(178, 106, 0, 0.4);
  color: var(--amber);
}
html[data-theme="light"] body.page-home .rulebook-info .chip.err,
html[data-theme="light"] body.page-home .rulebook-info .chip.bad {
  background: rgba(208, 44, 49, 0.1);
  border-color: rgba(208, 44, 49, 0.4);
  color: var(--red);
}
html[data-theme="light"] body.page-ai .ai-orb-type,
html[data-theme="light"] body.page-ai .panel-head h2 { color: #202124; }
html[data-theme="light"] body.page-ai .ai-ops-footnote,
html[data-theme="light"] body.page-ai .empty,
html[data-theme="light"] body.page-ai .hint { color: #5f6368; }
html[data-theme="light"] body.page-ai .ai-ws-tabs {
  background: #f8f9fa;
  border-color: #dadce0;
}
html[data-theme="light"] body.page-ai .ai-ws-tabs .tab { color: #5f6368; }
html[data-theme="light"] body.page-ai .ai-ws-tabs .tab:hover { color: #202124; background: rgba(184, 247, 228, 0.28); }
html[data-theme="light"] body.page-ai .ai-ws-tabs .tab.active {
  background: rgba(184, 247, 228, 0.55);
  color: #17795e;
  box-shadow: inset 0 0 0 1px rgba(23, 121, 94, 0.35);
}

/* Charts / Devices / Guide / login: same Home+AI chrome.
   Do not restyle generic chips or .btn.primary / .reject / .approve. */
body.page-charts,
body.page-devices,
body.page-guide,
body.page-login {
  background: #0b1015;
}
body.page-charts .card,
body.page-devices .card,
body.page-guide .card,
body.page-login .card {
  background: #0f181e;
  border: 1px solid #3a535c;
  box-shadow: 0 20px 56px rgba(0, 0, 0, 0.55);
}
body.page-charts .panel-head h2,
body.page-devices .panel-head h2,
body.page-guide .guide-section h2,
body.page-guide .guide-playbook-body h3 {
  color: #d9e8e9;
  font-weight: 550;
}
body.page-charts .empty,
body.page-charts .hint,
body.page-charts .subtitle,
body.page-devices .empty,
body.page-devices .hint,
body.page-devices .subtitle,
body.page-devices .device-idline,
body.page-devices .devices-field span,
body.page-devices .device-meta-cell span,
body.page-devices .pair-token,
body.page-devices .pair-cmd summary,
body.page-guide .subtitle,
body.page-guide .hint,
body.page-guide .guide-glossary-hint,
body.page-guide .guide-glossary dd,
body.page-guide .guide-toc-title,
body.page-login .login-desc {
  color: #799598;
}
body.page-charts .topbar {
  position: relative;
  z-index: 280;
}
body.page-charts .site-nav,
body.page-charts .site-nav[open],
body.page-charts .site-nav-list {
  z-index: 280;
}
body.page-charts .tabs {
  background: #071016;
  border: 1px solid #253238;
  border-radius: 8px;
  padding: 3px;
}
body.page-charts .tab,
body.page-charts #asset-tabs .tab,
body.page-charts #tf-tabs .tab {
  color: #799598;
  border-color: transparent;
  background: none;
}
body.page-charts .tab.active,
body.page-charts #asset-tabs .tab.active,
body.page-charts #tf-tabs .tab.active {
  background: #0c1c24;
  color: #a9d8cc;
  border-color: transparent;
  box-shadow: inset 0 0 0 1px #304247;
}
body.page-devices .devices-field input,
body.page-devices .pair-cmd pre,
body.page-devices .device-meta-cell,
body.page-devices .device-perm span,
body.page-guide .guide-glossary dl > div,
body.page-guide .guide-section code,
body.page-login #login-form input {
  background: #071016;
  border-color: #253238;
  color: #d9e8e9;
}
body.page-devices .device-row { border-bottom-color: #19272d; }
body.page-devices .pair-token { border-top-color: #19272d; }
body.page-guide .guide-glossary-body,
body.page-guide .guide-toc ol { border-top-color: #19272d; }
body.page-devices .device-perm input:checked + span {
  background: rgba(184, 247, 228, 0.14);
  border-color: rgba(184, 247, 228, 0.45);
  color: #b8f7e4;
}
body.page-charts .btn:not(.primary):not(.reject):not(.approve),
body.page-devices .btn:not(.primary):not(.reject):not(.approve),
body.page-guide .btn:not(.primary):not(.reject):not(.approve),
body.page-login .btn:not(.primary):not(.reject):not(.approve):not(#google-login) {
  background: rgba(184, 247, 228, 0.14);
  border: 1px solid rgba(184, 247, 228, 0.45);
  color: #b8f7e4;
  border-radius: 5px;
}
body.page-home .site-nav-list,
body.page-charts .site-nav-list,
body.page-devices .site-nav-list,
body.page-guide .site-nav-list {
  background: #0f181e;
  border-color: #3a535c;
  box-shadow: 0 20px 56px rgba(0, 0, 0, 0.55);
}
body.page-home .site-nav-list a,
body.page-home .site-nav-list > .site-nav-logout,
body.page-charts .site-nav-list a,
body.page-charts .site-nav-list > .site-nav-logout,
body.page-devices .site-nav-list a,
body.page-devices .site-nav-list > .site-nav-logout,
body.page-guide .site-nav-list a,
body.page-guide .site-nav-list > .site-nav-logout { color: #d9e8e9; }
body.page-home .site-nav-list a:hover,
body.page-home .site-nav-list a[aria-current="page"],
body.page-home .site-nav-list > .site-nav-logout:hover,
body.page-charts .site-nav-list a:hover,
body.page-charts .site-nav-list a[aria-current="page"],
body.page-charts .site-nav-list > .site-nav-logout:hover,
body.page-devices .site-nav-list a:hover,
body.page-devices .site-nav-list a[aria-current="page"],
body.page-devices .site-nav-list > .site-nav-logout:hover,
body.page-guide .site-nav-list a:hover,
body.page-guide .site-nav-list a[aria-current="page"],
body.page-guide .site-nav-list > .site-nav-logout:hover {
  background: rgba(184, 247, 228, 0.14);
  color: #b8f7e4;
}
body.page-charts .chip.ok,
body.page-devices .chip.ok,
body.page-guide .chip.ok {
  background: rgba(47, 191, 113, 0.14);
  border-color: rgba(47, 191, 113, 0.5);
  color: var(--green);
}
body.page-charts .chip.warn,
body.page-devices .chip.warn,
body.page-guide .chip.warn {
  background: rgba(240, 166, 58, 0.14);
  border-color: rgba(240, 166, 58, 0.5);
  color: var(--amber);
}
body.page-charts .chip.err,
body.page-charts .chip.bad,
body.page-devices .chip.err,
body.page-devices .chip.bad,
body.page-guide .chip.err,
body.page-guide .chip.bad {
  background: rgba(229, 72, 77, 0.12);
  border-color: rgba(229, 72, 77, 0.5);
  color: var(--red);
}
body.page-guide .guide-toc a,
body.page-guide .guide-section a,
body.page-guide .guide-text-link,
body.page-guide .guide-glossary dt,
body.page-guide .guide-playbook-body h4,
body.page-guide .foot a,
body.page-charts .foot a {
  color: #b8f7e4;
}

html[data-theme="light"] body.page-charts,
html[data-theme="light"] body.page-devices,
html[data-theme="light"] body.page-guide,
html[data-theme="light"] body.page-login {
  background: #f1f3f4;
  color: #202124;
}
html[data-theme="light"] body.page-charts .card,
html[data-theme="light"] body.page-devices .card,
html[data-theme="light"] body.page-guide .card,
html[data-theme="light"] body.page-login .card,
html[data-theme="light"] #tv-chart-wrap.is-expanded {
  background: #ffffff;
  border: 1px solid #dadce0;
  box-shadow: 0 1px 2px rgba(60, 64, 67, 0.12), 0 2px 6px rgba(60, 64, 67, 0.08);
}
html[data-theme="light"] body.page-charts .panel-head h2,
html[data-theme="light"] body.page-devices .panel-head h2,
html[data-theme="light"] body.page-guide .guide-section h2,
html[data-theme="light"] body.page-guide .guide-playbook-body h3 {
  color: #202124;
  font-weight: 550;
}
html[data-theme="light"] body.page-charts .empty,
html[data-theme="light"] body.page-charts .hint,
html[data-theme="light"] body.page-charts .subtitle,
html[data-theme="light"] body.page-devices .empty,
html[data-theme="light"] body.page-devices .hint,
html[data-theme="light"] body.page-devices .subtitle,
html[data-theme="light"] body.page-devices .device-idline,
html[data-theme="light"] body.page-devices .devices-field span,
html[data-theme="light"] body.page-devices .device-meta-cell span,
html[data-theme="light"] body.page-devices .pair-token,
html[data-theme="light"] body.page-devices .pair-cmd summary,
html[data-theme="light"] body.page-guide .subtitle,
html[data-theme="light"] body.page-guide .hint,
html[data-theme="light"] body.page-guide .guide-glossary-hint,
html[data-theme="light"] body.page-guide .guide-glossary dd,
html[data-theme="light"] body.page-guide .guide-toc-title,
html[data-theme="light"] body.page-login .login-desc {
  color: #5f6368;
}
html[data-theme="light"] body.page-charts .tabs {
  background: #f8f9fa;
  border: 1px solid #dadce0;
}
html[data-theme="light"] body.page-charts .tab,
html[data-theme="light"] body.page-charts #asset-tabs .tab,
html[data-theme="light"] body.page-charts #tf-tabs .tab { color: #5f6368; }
html[data-theme="light"] body.page-charts .tab.active,
html[data-theme="light"] body.page-charts #asset-tabs .tab.active,
html[data-theme="light"] body.page-charts #tf-tabs .tab.active {
  background: #ffffff;
  color: #17795e;
  box-shadow: inset 0 0 0 1px #dadce0;
}
html[data-theme="light"] body.page-devices .devices-field input,
html[data-theme="light"] body.page-devices .pair-cmd pre,
html[data-theme="light"] body.page-devices .device-meta-cell,
html[data-theme="light"] body.page-devices .device-perm span,
html[data-theme="light"] body.page-guide .guide-glossary dl > div,
html[data-theme="light"] body.page-guide .guide-section code,
html[data-theme="light"] body.page-login #login-form input {
  background: #f8f9fa;
  border-color: #dadce0;
  color: #202124;
}
html[data-theme="light"] body.page-devices .device-row { border-bottom-color: #e8eaed; }
html[data-theme="light"] body.page-devices .pair-token { border-top-color: #e8eaed; }
html[data-theme="light"] body.page-guide .guide-glossary-body,
html[data-theme="light"] body.page-guide .guide-toc ol { border-top-color: #e8eaed; }
html[data-theme="light"] body.page-devices .device-perm input:checked + span {
  background: rgba(184, 247, 228, 0.55);
  border-color: rgba(23, 121, 94, 0.35);
  color: #17795e;
}
html[data-theme="light"] body.page-charts .btn:not(.primary):not(.reject):not(.approve),
html[data-theme="light"] body.page-devices .btn:not(.primary):not(.reject):not(.approve),
html[data-theme="light"] body.page-guide .btn:not(.primary):not(.reject):not(.approve),
html[data-theme="light"] body.page-login .btn:not(.primary):not(.reject):not(.approve):not(#google-login) {
  background: rgba(184, 247, 228, 0.55);
  border: 1px solid rgba(23, 121, 94, 0.35);
  color: #17795e;
}
body.page-ai .site-nav-list .btn.icon.site-nav-theme,
body.page-home .site-nav-list .btn.icon.site-nav-theme,
body.page-charts .site-nav-list .btn.icon.site-nav-theme,
body.page-devices .site-nav-list .btn.icon.site-nav-theme,
body.page-guide .site-nav-list .btn.icon.site-nav-theme,
html[data-theme="light"] body.page-ai .site-nav-list .btn.icon.site-nav-theme,
html[data-theme="light"] body.page-home .site-nav-list .btn.icon.site-nav-theme,
html[data-theme="light"] body.page-charts .site-nav-list .btn.icon.site-nav-theme,
html[data-theme="light"] body.page-devices .site-nav-list .btn.icon.site-nav-theme,
html[data-theme="light"] body.page-guide .site-nav-list .btn.icon.site-nav-theme {
  justify-self: start;
  width: auto;
  height: auto;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 8px 10px;
  background: transparent;
  border: none;
  border-radius: 8px;
  box-shadow: none;
}
body.page-ai .ai-composer-action[data-mode="voice"],
body.page-ai .ai-composer-action[data-mode="voice"]:hover,
body.page-ai .ai-composer-action[data-mode="voice"]:focus,
html[data-theme="light"] body.page-ai .ai-composer-action[data-mode="voice"],
html[data-theme="light"] body.page-ai .ai-composer-action[data-mode="voice"]:hover,
html[data-theme="light"] body.page-ai .ai-composer-action[data-mode="voice"]:focus {
  background: #B8F7E4;
  border-color: #B8F7E4;
  color: var(--on-accent);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
  outline: none;
}
body.page-ai .ai-composer-action[data-mode="voice"]:hover {
  filter: brightness(1.04);
}
html[data-theme="light"] body.page-home .site-nav-list,
html[data-theme="light"] body.page-charts .site-nav-list,
html[data-theme="light"] body.page-devices .site-nav-list,
html[data-theme="light"] body.page-guide .site-nav-list {
  background: #ffffff;
  border-color: #dadce0;
  box-shadow: 0 1px 2px rgba(60, 64, 67, 0.12), 0 2px 6px rgba(60, 64, 67, 0.08);
}
html[data-theme="light"] body.page-home .site-nav-list a,
html[data-theme="light"] body.page-home .site-nav-list > .site-nav-logout,
html[data-theme="light"] body.page-charts .site-nav-list a,
html[data-theme="light"] body.page-charts .site-nav-list > .site-nav-logout,
html[data-theme="light"] body.page-devices .site-nav-list a,
html[data-theme="light"] body.page-devices .site-nav-list > .site-nav-logout,
html[data-theme="light"] body.page-guide .site-nav-list a,
html[data-theme="light"] body.page-guide .site-nav-list > .site-nav-logout { color: #202124; }
html[data-theme="light"] body.page-home .site-nav-list a:hover,
html[data-theme="light"] body.page-home .site-nav-list a[aria-current="page"],
html[data-theme="light"] body.page-home .site-nav-list > .site-nav-logout:hover,
html[data-theme="light"] body.page-charts .site-nav-list a:hover,
html[data-theme="light"] body.page-charts .site-nav-list a[aria-current="page"],
html[data-theme="light"] body.page-charts .site-nav-list > .site-nav-logout:hover,
html[data-theme="light"] body.page-devices .site-nav-list a:hover,
html[data-theme="light"] body.page-devices .site-nav-list a[aria-current="page"],
html[data-theme="light"] body.page-devices .site-nav-list > .site-nav-logout:hover,
html[data-theme="light"] body.page-guide .site-nav-list a:hover,
html[data-theme="light"] body.page-guide .site-nav-list a[aria-current="page"],
html[data-theme="light"] body.page-guide .site-nav-list > .site-nav-logout:hover {
  background: rgba(184, 247, 228, 0.55);
  color: #17795e;
}
html[data-theme="light"] body.page-charts #charts-meta.chip {
  color: #17795e;
  border-color: rgba(23, 121, 94, 0.35);
  background: rgba(184, 247, 228, 0.55);
}
html[data-theme="light"] body.page-charts .chip.ok,
html[data-theme="light"] body.page-devices .chip.ok,
html[data-theme="light"] body.page-guide .chip.ok {
  background: rgba(24, 138, 82, 0.12);
  border-color: rgba(24, 138, 82, 0.45);
  color: var(--green);
}
html[data-theme="light"] body.page-charts .chip.warn,
html[data-theme="light"] body.page-devices .chip.warn,
html[data-theme="light"] body.page-guide .chip.warn {
  background: rgba(178, 106, 0, 0.12);
  border-color: rgba(178, 106, 0, 0.4);
  color: var(--amber);
}
html[data-theme="light"] body.page-charts .chip.err,
html[data-theme="light"] body.page-charts .chip.bad,
html[data-theme="light"] body.page-devices .chip.err,
html[data-theme="light"] body.page-devices .chip.bad,
html[data-theme="light"] body.page-guide .chip.err,
html[data-theme="light"] body.page-guide .chip.bad {
  background: rgba(208, 44, 49, 0.1);
  border-color: rgba(208, 44, 49, 0.4);
  color: var(--red);
}
html[data-theme="light"] body.page-guide .guide-toc a,
html[data-theme="light"] body.page-guide .guide-section a,
html[data-theme="light"] body.page-guide .guide-text-link,
html[data-theme="light"] body.page-guide .guide-glossary dt,
html[data-theme="light"] body.page-guide .guide-playbook-body h4,
html[data-theme="light"] body.page-guide .foot a,
html[data-theme="light"] body.page-charts .foot a,
html[data-theme="light"] body.page-login .login-tagline {
  color: #17795e;
}
html[data-theme="light"] body.page-guide .guide-callout {
  background: rgba(184, 247, 228, 0.55);
  border-color: rgba(23, 121, 94, 0.35);
  color: #17795e;
}
html[data-theme="light"] body.page-charts .btn.icon svg,
html[data-theme="light"] body.page-devices .btn.icon svg,
html[data-theme="light"] body.page-guide .btn.icon svg {
  stroke: #17795e;
}

/* ---------- AI Desk (persistent Ninja presence) ---------- */
body.page-ai {
  padding-bottom: 16px;
  background: #0b1015;
}
body.page-ai .topbar { margin-bottom: 12px; }
.ai-desk {
  display: grid;
  grid-template-columns: minmax(172px, 196px) minmax(0, 1fr) minmax(192px, 224px);
  grid-template-rows: minmax(360px, 1fr) auto auto;
  grid-template-areas:
    "left stage right"
    "left work right"
    "composer composer composer";
  grid-auto-flow: row;
  grid-auto-columns: minmax(0, 1fr);
  gap: 12px 14px;
  align-items: start;
  align-content: stretch;
  min-height: calc(100vh - 120px);
}
.ai-desk[data-stage="research"]:not([data-tv="on"]),
.ai-desk[data-tv="on"]:not([data-stage="world"]):not([data-stage="brain"]) {
  grid-template-rows: auto minmax(360px, 1fr) auto auto;
  grid-template-areas:
    "tv tv tv"
    "left stage right"
    "left work right"
    "composer composer composer";
}
.ai-desk[data-stage="world"]:not([data-tv="on"]) {
  grid-template-rows: auto minmax(360px, 1fr) auto auto;
  grid-template-areas:
    "world world world"
    "left stage right"
    "left work right"
    "composer composer composer";
}
.ai-desk[data-tv="on"][data-stage="world"] {
  grid-template-rows: auto auto minmax(360px, 1fr) auto auto;
  grid-template-areas:
    "tv tv tv"
    "world world world"
    "left stage right"
    "left work right"
    "composer composer composer";
}
.ai-desk[data-stage="brain"]:not([data-tv="on"]) {
  grid-template-rows: auto minmax(360px, 1fr) auto auto;
  grid-template-areas:
    "brain brain brain"
    "left stage right"
    "left work right"
    "composer composer composer";
}
.ai-desk[data-tv="on"][data-stage="brain"] {
  grid-template-rows: auto auto minmax(360px, 1fr) auto auto;
  grid-template-areas:
    "tv tv tv"
    "brain brain brain"
    "left stage right"
    "left work right"
    "composer composer composer";
}
.ai-rail-left { grid-area: left; }
.ai-stage { grid-area: stage; }
.ai-rail-right { grid-area: right; }
.ai-workspace { grid-area: work; }
.ai-desk > .ai-composer { grid-area: composer; }
.ai-rail {
  display: grid;
  gap: 10px;
  align-content: start;
  min-width: 0;
}
.ai-rail-card {
  background: #1a1d22;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  min-width: 0;
  overflow-wrap: anywhere;
}
.ai-rail-card .panel-head { margin-bottom: 8px; }
.ai-rail-card .ai-activity-scroll { max-height: min(32vh, 280px); }
.ai-kv {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  padding: 4px 0;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}
.ai-kv:last-child { border-bottom: 0; }
.ai-kv span { color: var(--muted); min-width: 0; }
.ai-kv strong { color: var(--text); font-weight: 650; text-align: right; min-width: 0; overflow-wrap: anywhere; }
.ai-approvals.is-empty #approvals { display: none; }
.ai-approvals:not(.is-empty) #approvals {
  display: block;
  max-height: min(32vh, 280px);
  overflow-x: hidden;
  overflow-y: auto;
}
.ai-wake-opts {
  border: 0;
  display: grid;
  gap: 6px;
  margin: 0 0 8px;
  padding: 0;
  color: var(--text);
  font-size: 12px;
}
.ai-wake-opts label { display: flex; gap: 8px; align-items: center; cursor: pointer; min-width: 0; }
.ai-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  min-height: 360px;
  padding: 8px 8px 4px;
}
.ai-network {
  position: relative;
  width: min(100%, 520px, 52vh);
  aspect-ratio: 1;
  height: auto;
  max-height: min(52vh, 520px);
  margin: 0 auto;
  overflow: visible;
  flex: 0 0 auto;
}
.ai-network-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.ai-network-lines line,
.ai-network-lines .ai-pathway {
  stroke: color-mix(in srgb, #b8f7e4 28%, transparent);
  stroke-width: 0.16;
  fill: none;
}
.ai-network-lines .ai-pathway.is-on,
.ai-network-lines line.is-on {
  stroke: var(--node, #b8f7e4);
  stroke-width: 0.28;
  filter: drop-shadow(0 0 0.6px var(--node, #b8f7e4));
}
.ai-path-pulse { pointer-events: none; }
.ai-orb-wrap {
  position: absolute;
  inset: 20%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 2;
}
.ai-orb-stage { display: grid; place-items: center; }
.ai-stage .ai-orb {
  --orb: #b8f7e4;
  width: min(39vw, 267px);
  height: min(34.5vw, 230px);
  max-width: 267px;
  max-height: 230px;
  border-radius: 0;
  position: relative;
  background: none;
  box-shadow: none;
  transition: transform 0.28s ease, filter 0.28s ease;
}
.ai-stage .ai-orb::after { display: none; }
.ai-neural-field {
  position: absolute;
  inset: 6%;
  border-radius: 46% 50% 48% 52%;
  background:
    radial-gradient(ellipse 58% 52% at 50% 48%, rgba(184, 247, 228, 0.26), transparent 70%);
  pointer-events: none;
  animation: ai-breathe 5.6s ease-in-out infinite;
}
.ai-neural-svg {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.ai-neural-shell {
  fill: rgba(11, 13, 16, 0.72);
  stroke: rgba(184, 247, 228, 0.34);
  stroke-width: 1.1;
}
.ai-neural-mid {
  fill: none;
  stroke: rgba(184, 247, 228, 0.18);
  stroke-width: 0.7;
}
.ai-neural-synapses line {
  stroke: rgba(184, 247, 228, 0.38);
  stroke-width: 0.55;
}
.ai-neural[data-state="idle"] .ai-neural-synapses line {
  animation: ai-neural-fire 2.6s ease-in-out infinite;
  animation-delay: calc(var(--i, 0) * 70ms);
}
.ai-neural-synapses line:nth-child(3n) { --i: 1; }
.ai-neural-synapses line:nth-child(3n+1) { --i: 2; }
.ai-neural-synapses line:nth-child(3n+2) { --i: 3; }
.ai-neural-node {
  fill: #b8f7e4;
  opacity: 0.5;
  animation: ai-neural-idle 3.4s ease-in-out infinite;
  animation-delay: calc(var(--i, 0) * 70ms);
}
.ai-neural-node.n-core {
  fill: #fff;
  opacity: 0.72;
}
.ai-neural-dot {
  fill: #b8f7e4;
  opacity: 0;
  animation: ai-neural-sparkle 2.8s ease-in-out infinite;
  animation-delay: calc(var(--i, 0) * 280ms);
}
.ai-neural-spark {
  fill: #fff;
  opacity: 0;
  transform-origin: 100px 78px;
}
.ai-neural[data-state="idle"] .ai-neural-field { animation-duration: 5.6s; }
.ai-neural[data-state="listening"] {
  transform: scale(1.04);
}
.ai-neural[data-state="listening"] .ai-neural-field {
  background:
    radial-gradient(ellipse 64% 56% at 50% 48%, rgba(184, 247, 228, 0.28), transparent 72%);
  animation-duration: 2.4s;
}
.ai-neural[data-state="listening"] .ai-neural-node { opacity: 0.78; }
.ai-neural[data-state="listening"] .ai-neural-synapses line { stroke: rgba(184, 247, 228, 0.5); }
.ai-neural[data-state="interpreting"] .ai-neural-synapses line {
  stroke: rgba(184, 247, 228, 0.62);
  animation: ai-neural-fire 1.1s linear infinite;
}
.ai-neural[data-state="interpreting"] .ai-neural-node {
  opacity: 0.86;
  animation-duration: 1.6s;
}
.ai-neural[data-state="working"] .ai-neural-field {
  background:
    radial-gradient(ellipse 68% 58% at 50% 48%, rgba(184, 247, 228, 0.34), transparent 74%);
  animation: ai-pulse 1.4s ease-in-out infinite;
}
.ai-neural[data-state="working"] .ai-neural-synapses line {
  stroke: rgba(184, 247, 228, 0.78);
  animation: ai-neural-fire 0.7s linear infinite;
}
.ai-neural[data-state="working"] .ai-neural-node { opacity: 0.95; }
.ai-neural[data-state="speaking"] .ai-neural-field {
  animation: ai-pulse 0.9s ease-in-out infinite;
}
.ai-neural[data-state="speaking"] .n-core {
  fill: #d8fff3;
  opacity: 1;
}
.ai-neural[data-state="waiting_approval"] .ai-neural-field {
  background:
    radial-gradient(ellipse 58% 52% at 50% 48%, rgba(240, 166, 58, 0.18), transparent 70%);
  animation: none;
}
.ai-neural[data-state="waiting_approval"] .n-core { fill: var(--amber); }
.ai-neural[data-state="error"] .ai-neural-shell { stroke: rgba(229, 72, 77, 0.45); }
.ai-neural[data-state="error"] .n-core { fill: var(--red); }
.ai-neural.is-wake .ai-neural-spark {
  animation: ai-wake 0.7s ease-out 1;
}
.ai-neural.is-wake .ai-neural-node {
  animation: ai-neural-ignite 0.9s ease-out both;
  animation-delay: calc(var(--i, 0) * 22ms);
}
.ai-neural.is-wake .ai-neural-field {
  animation: ai-neural-bloom 0.95s ease-out 1;
}
.ai-neural.is-paused,
.ai-neural.is-paused * {
  animation-play-state: paused !important;
}
@keyframes ai-breathe {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50% { transform: scale(1.03); opacity: 1; }
}
@keyframes ai-spin { to { transform: rotate(360deg); } }
@keyframes ai-wake {
  0% { transform: scale(0.4); opacity: 0.95; }
  100% { transform: scale(3.4); opacity: 0; }
}
@keyframes ai-neural-idle {
  0%, 100% { opacity: 0.42; }
  50% { opacity: 0.9; }
}
@keyframes ai-neural-sparkle {
  0%, 62%, 100% { opacity: 0; }
  78% { opacity: 0.95; }
}
@keyframes ai-neural-fire {
  0% { stroke-opacity: 0.28; }
  50% { stroke-opacity: 1; }
  100% { stroke-opacity: 0.28; }
}
@keyframes ai-neural-ignite {
  0% { opacity: 0.15; }
  40% { opacity: 1; }
  100% { opacity: 0.86; }
}
@keyframes ai-neural-bloom {
  0% { opacity: 0.2; transform: scale(0.86); }
  45% { opacity: 1; transform: scale(1.08); }
  100% { opacity: 0.85; transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .ai-neural-field,
  .ai-neural-node,
  .ai-neural-dot,
  .ai-neural-spark,
  .ai-neural-synapses line { animation: none !important; }
  .ai-neural-dot { display: none; }
}
.ai-stage .ai-orb-label {
  position: relative;
  box-sizing: border-box;
  width: min(58%, 220px);
  min-height: 2.6em;
  margin: 10px auto 10px;
  padding: 0 8px;
  text-align: center;
  z-index: 1;
  pointer-events: none;
}
.ai-orb-type {
  display: inline-block;
  min-height: 1.25em;
  color: #f2f8f5;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: 0.04em;
  line-height: 1.25;
  white-space: normal;
}
.ai-orb-type::after {
  content: "▌";
  margin-left: 3px;
  color: #b8f7e4;
  animation: ai-orb-caret 0.8s step-end infinite;
}
@keyframes ai-orb-caret {
  50% { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .ai-orb-type::after { animation: none; }
}
.ai-node {
  --r: 38%;
  --node: #b8f7e4;
  --node-glow: color-mix(in srgb, var(--node) 55%, transparent);
  position: absolute;
  left: calc(50% + cos(var(--deg)) * var(--r));
  top: calc(50% + sin(var(--deg)) * var(--r));
  transform: translate(-50%, -50%);
  min-width: 78px;
  padding: 5px 8px;
  border-radius: 999px;
  --node-hot: var(--node);
  border: 1px solid color-mix(in srgb, #b8f7e4 22%, var(--border));
  background: #14171b;
  color: #c8d0cc;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  white-space: nowrap;
  cursor: pointer;
  z-index: 5;
  transition: color 0.25s ease, background 0.25s ease, border-color 0.25s ease,
    letter-spacing 0.35s ease, text-shadow 0.25s ease, box-shadow 0.25s ease;
}
.ai-node[data-domain="MARKET"] { --node-hot: #5ec8ff; }
.ai-node[data-domain="STRATEGY"] { --node-hot: #b8f7e4; }
.ai-node[data-domain="QUANT"] { --node-hot: #c4b5fd; }
.ai-node[data-domain="RISK"] { --node-hot: #f0a63a; }
.ai-node[data-domain="EXECUTION"] { --node-hot: #34d399; }
.ai-node[data-domain="JOURNAL"] { --node-hot: #818cf8; }
.ai-node[data-domain="TEACH"] { --node-hot: #fb7185; }
.ai-node[data-domain="RESEARCH"] { --node-hot: #22d3ee; }
.ai-node[data-domain="BRAIN"] { --node-hot: #e9d5ff; }
.ai-node:hover {
  color: #b8f7e4;
  border-color: color-mix(in srgb, #b8f7e4 55%, var(--border));
  letter-spacing: 0.22em;
  text-shadow: 0 0 10px rgba(184, 247, 228, 0.4);
  animation: ai-node-text 0.7s ease;
}
.ai-node.is-on,
.ai-node.is-done {
  --node-glow: color-mix(in srgb, var(--node-hot) 55%, transparent);
  color: #121417;
  background: var(--node-hot);
  border-color: var(--node-hot);
  box-shadow: 0 0 16px var(--node-glow);
}
.ai-node.is-on:hover,
.ai-node.is-done:hover {
  color: #121417;
  text-shadow: 0 0 8px rgba(18, 20, 23, 0.25);
}
@keyframes ai-node-text {
  0% { letter-spacing: 0.08em; }
  45% { letter-spacing: 0.26em; }
  100% { letter-spacing: 0.22em; }
}
@media (prefers-reduced-motion: reduce) {
  .ai-node,
  .ai-node:hover { animation: none; transition-duration: 0.01ms; }
}
.ai-node.is-done { opacity: 0.78; }
html[data-theme="light"] body.page-ai .ai-node {
  background: #ffffff;
  border: 1px solid #dadce0;
  color: #3c4043;
  box-shadow: 0 1px 2px rgba(60, 64, 67, 0.12);
}
html[data-theme="light"] body.page-ai .ai-node:hover {
  color: #17795e;
  background: rgba(184, 247, 228, 0.45);
  border-color: rgba(23, 121, 94, 0.35);
  text-shadow: none;
}
html[data-theme="light"] body.page-ai .ai-node.is-on,
html[data-theme="light"] body.page-ai .ai-node.is-done {
  color: #202124;
  background: var(--node-hot);
  border-color: var(--node-hot);
}
html[data-theme="light"] body.page-ai .ai-network-lines .ai-pathway,
html[data-theme="light"] body.page-ai .ai-network-lines line {
  stroke: rgba(23, 121, 94, 0.28);
}
html[data-theme="light"] body.page-ai .ai-ops-brain {
  background: #ffffff;
  border-color: #dadce0;
  box-shadow: 0 1px 2px rgba(60, 64, 67, 0.12), 0 2px 6px rgba(60, 64, 67, 0.08);
}
html[data-theme="light"] body.page-ai .ai-monitor-screen,
html[data-theme="light"] body.page-ai .ai-tv-screen {
  background: radial-gradient(circle at 50% 0%, rgba(184, 247, 228, 0.18), transparent 46%), #f8f9fa;
}
html[data-theme="light"] body.page-ai .ai-monitor-standby,
html[data-theme="light"] body.page-ai .ai-monitor-fail { color: #3c4043; }
html[data-theme="light"] body.page-ai .ai-monitor-standby span,
html[data-theme="light"] body.page-ai .ai-monitor-fail strong,
html[data-theme="light"] body.page-ai .ai-monitor-rail h3 { color: #17795e; }
html[data-theme="light"] body.page-ai .ai-monitor-standby em { color: #5f6368; }
html[data-theme="light"] body.page-ai .ai-world-title strong { color: #202124; }
html[data-theme="light"] body.page-ai .ai-world-title em { color: #5f6368; }
html[data-theme="light"] body.page-ai .ai-world-dock {
  background: transparent;
  border-color: #e8eaed;
  color: #202124;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  box-shadow: none;
}
html[data-theme="light"] body.page-ai .ai-world-strip {
  background: #f8f9fa;
  color: #202124;
}
html[data-theme="light"] body.page-ai .ai-world-strip span { color: #5f6368; }
html[data-theme="light"] body.page-ai .ai-world-strip strong { color: #17795e; }
html[data-theme="light"] body.page-ai .ai-world-findings {
  background: #f8f9fa;
  border-color: #dadce0;
  color: #202124;
}
html[data-theme="light"] body.page-ai .ai-brain-hover {
  background: #ffffff;
  border-color: #dadce0;
  color: #202124;
  box-shadow: 0 1px 2px rgba(60, 64, 67, 0.12);
}
html[data-theme="light"] body.page-ai .ai-brain-hover strong { color: #202124; }
html[data-theme="light"] body.page-ai .ai-brain-hover span { color: #5f6368; }
.ai-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  width: min(100%, 640px);
  margin: 4px auto 0;
}
.ai-stage #runtime-note {
  box-sizing: border-box;
  width: min(100%, 640px);
  margin: 16px auto 0;
  padding: 0 2px;
  text-align: center;
  text-transform: none;
  letter-spacing: 0.03em;
  line-height: 1.45;
  white-space: normal;
}
.ai-metric {
  background: #1a1d22;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  min-width: 0;
}
.ai-metric .k {
  display: block;
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 2px;
}
.ai-metric strong {
  display: block;
  font-size: 13px;
  color: #b8f7e4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ai-wake-status {
  margin: 4px 0 0;
  font-size: 11px;
  color: var(--muted);
}
.ai-stage .ai-voice-live { display: none; margin-top: 8px; }
.ai-stage[data-voice="on"] .ai-voice-live { display: flex; }
body.page-ai .ai-voice-live .btn {
  background: rgba(184, 247, 228, 0.14);
  border: 1px solid rgba(184, 247, 228, 0.45);
  color: #b8f7e4;
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 650;
}
body.page-ai .ai-voice-live #btn-stop-voice {
  background: #B8F7E4;
  border-color: #B8F7E4;
  color: #25272c;
}
body.page-ai .ai-voice-live #btn-mute {
  gap: 6px;
}
body.page-ai .ai-voice-live #btn-mute svg {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: none;
}
body.page-ai .ai-voice-live #btn-mute[data-muted="0"] .icon-mute {
  display: block;
  color: #e5484d;
  stroke: #e5484d;
}
body.page-ai .ai-voice-live #btn-mute[data-muted="1"] .icon-unmute {
  display: block;
  color: #ffffff;
  stroke: #ffffff;
}
html[data-theme="light"] body.page-ai .ai-voice-live .btn {
  background: rgba(184, 247, 228, 0.55);
  border: 1px solid rgba(23, 121, 94, 0.35);
  color: #17795e;
}
html[data-theme="light"] body.page-ai .ai-voice-live #btn-stop-voice {
  background: #B8F7E4;
  border-color: #B8F7E4;
  color: #25272c;
}
.ai-desk[data-tv="on"] .ai-stage .ai-orb,
.ai-desk[data-stage="research"] .ai-stage .ai-orb,
.ai-desk[data-stage="world"] .ai-stage .ai-orb,
.ai-desk[data-stage="brain"] .ai-stage .ai-orb {
  width: min(39vw, 267px);
  height: min(34.5vw, 230px);
  max-width: 267px;
  max-height: 230px;
}
.ai-desk[data-stage="research"] .ai-workspace,
.ai-desk[data-stage="world"] .ai-workspace,
.ai-desk[data-stage="brain"] .ai-workspace {
  background: transparent;
  border: none;
  padding: 0;
}
.ai-desk[data-stage="research"] .ai-ws-panel[data-ws="research"],
.ai-desk[data-stage="world"] .ai-ws-panel[data-ws="world"],
.ai-desk[data-stage="brain"] .ai-ws-panel[data-ws="brain"] {
  display: none;
}
.ai-ops-footnote {
  color: #8b938f;
  font-size: 12px;
  margin: 0;
}
.ai-workspace {
  min-width: 0;
  background: #1a1d22;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}
.ai-ws-tabs {
  display: flex;
  flex-wrap: nowrap;
  gap: 3px;
  margin-bottom: 12px;
  padding: 4px;
  background: #14171b;
  border: 1px solid var(--border);
  border-radius: 12px;
}
.ai-ws-tabs .tab,
.ai-ws-tabs .tab.active {
  flex: 1 1 0;
  background: transparent;
  border: 0;
  color: #8b938f;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  min-height: 36px;
}
.ai-ws-tabs .tab:hover {
  color: #d7e0dc;
  background: rgba(184, 247, 228, 0.04);
}
.ai-ws-tabs .tab.active {
  background: rgba(184, 247, 228, 0.09);
  color: #b8f7e4;
  box-shadow: inset 0 0 0 1px rgba(184, 247, 228, 0.32);
}
.ai-ws-tabs .tab.hidden { display: none; }
.is-surface {
  box-shadow: 0 0 0 1px rgba(184, 247, 228, 0.42), 0 0 22px rgba(184, 247, 228, 0.08);
  transition: box-shadow 0.35s ease;
}
.ai-workspace[data-surface="quant"] .ai-lib-actions {
  box-shadow: 0 0 0 1px rgba(196, 181, 253, 0.4);
  border-radius: 10px;
}
.ai-desk[data-surface="journal"] #desk-metrics,
.ai-desk[data-surface="market"] #market-pulse,
.ai-desk[data-surface="execution"] [data-tour="activity"],
.ai-desk[data-surface="risk"] #approvals-card {
  box-shadow: 0 0 0 1px rgba(184, 247, 228, 0.32);
}
.ai-ws-panel { display: none; }
.ai-ws-panel.is-on { display: block; }
.ai-desk[data-stage="research"] .ai-ws-panel[data-ws="research"],
.ai-desk[data-stage="world"] .ai-ws-panel[data-ws="world"],
.ai-desk[data-stage="brain"] .ai-ws-panel[data-ws="brain"] {
  display: none;
}
.ai-workspace .ai-transcript {
  min-height: 180px;
  max-height: 42vh;
}
.ai-desk > .ai-composer { margin: 0; }
@media (min-width: 1101px) {
  body.page-ai .ai-desk:has(.ai-ws-panel[data-ws="library"].is-on),
  body.page-ai .ai-desk:has(.ai-ws-panel[data-ws="teach"].is-on) {
    grid-template-rows: minmax(360px, 1fr) auto minmax(0, auto) auto !important;
    grid-template-areas:
      "left stage right"
      "left work right"
      "left stack right"
      "composer composer composer" !important;
  }
}
.page-ai #asset-tabs .tab,
.page-ai #tf-tabs .tab { color: inherit; }
.ai-mobile-bar { display: none; }
@media (max-width: 1100px) {
  .ai-desk {
    grid-template-columns: 1fr;
    grid-template-areas:
      "stage"
      "work"
      "composer"
      "left"
      "right";
  }
  .ai-desk[data-stage="research"]:not([data-tv="on"]),
  .ai-desk[data-tv="on"]:not([data-stage="world"]):not([data-stage="brain"]) {
    grid-template-areas:
      "tv"
      "stage"
      "work"
      "composer"
      "left"
      "right";
  }
  .ai-desk[data-stage="world"]:not([data-tv="on"]) {
    grid-template-areas:
      "world"
      "stage"
      "work"
      "composer"
      "left"
      "right";
  }
  .ai-desk[data-tv="on"][data-stage="world"] {
    grid-template-areas:
      "tv"
      "world"
      "stage"
      "work"
      "composer"
      "left"
      "right";
  }
  .ai-desk[data-stage="brain"]:not([data-tv="on"]) {
    grid-template-areas:
      "brain"
      "stage"
      "work"
      "composer"
      "left"
      "right";
  }
  .ai-desk[data-tv="on"][data-stage="brain"] {
    grid-template-areas:
      "tv"
      "brain"
      "stage"
      "work"
      "composer"
      "left"
      "right";
  }
  .ai-stage .ai-orb {
    width: min(100%, 210px);
    height: min(86%, 181px);
    max-width: 100%;
    max-height: 100%;
  }
  .ai-orb-stage {
    width: 100%;
    height: 100%;
  }
  .ai-node {
    --r: 46%;
    min-width: 68px;
  }
  .ai-network-lines {
    overflow: visible;
  }
  .ai-network-lines .ai-pathway {
    stroke-width: 1.2px;
    vector-effect: non-scaling-stroke;
  }
  .ai-network-lines .ai-pathway.is-on,
  .ai-network-lines line.is-on {
    stroke-width: 1.7px;
  }
  .ai-ws-tabs {
    flex-wrap: wrap;
  }
  .ai-ws-tabs .tab,
  .ai-ws-tabs .tab.active {
    flex: 1 1 calc(33% - 4px);
    min-width: 88px;
  }
  .ai-neural-dot { display: none; }
  .ai-stage .ai-orb-label {
    margin: 4px auto 14px;
  }
  .ai-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ai-network {
    width: min(100%, 520px, 68vh);
    max-height: min(68vh, 460px);
  }
  .ai-desk > .ai-composer {
    position: sticky;
    bottom: 0;
    z-index: 20;
    background: #0b1015;
    padding: 8px 0 calc(10px + env(safe-area-inset-bottom, 0px));
  }
  html[data-theme="light"] body.page-ai .ai-desk > .ai-composer { background: #f1f3f4; }
  body.page-ai .topbar-actions { display: none; }
  body.page-ai .topbar {
    flex-direction: column;
    align-items: stretch;
  }
  body.page-ai .topbar-right {
    width: 100%;
    max-width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 8px;
    overflow: visible;
  }
  body.page-ai .studio-asset-context {
    flex: 0 0 auto;
    width: auto;
    position: relative;
    z-index: 240;
    display: flex;
    align-items: center;
    gap: 8px;
  }
  body.page-ai .studio-au-entry {
    flex: none;
  }
  #wake-card { display: none; }
  .ai-mobile-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 12px;
    position: relative;
    z-index: 200;
    overflow: visible;
  }
  .ai-mobile-bar .wake-picker,
  .ai-mobile-bar .studio-runtime-tools,
  .ai-mobile-bar .llm-family-picker,
  .ai-mobile-bar .ai-apps-picker {
    overflow: visible;
  }
  .ai-mobile-bar .wake-picker {
    flex: 0 0 auto;
    margin-right: 0;
  }
  .ai-mobile-bar .studio-runtime-tools {
    flex: 1 1 auto;
    min-width: 0;
    margin-right: auto;
    overflow: visible;
  }
  .ai-mobile-bar .wake-picker .asset-picker-btn,
  .ai-mobile-bar .llm-family-btn,
  .ai-mobile-bar .ai-apps-btn {
    padding: 4px 10px;
    font-size: 12px;
    min-height: 0;
    line-height: 1.25;
    box-sizing: border-box;
  }
  .ai-mobile-bar .llm-family-btn {
    max-width: 120px;
  }
  .ai-mobile-bar .llm-family-menu {
    left: 0;
    right: auto;
    z-index: 220;
    max-height: min(70vh, 420px);
    overflow-y: auto;
  }
  .ai-mobile-bar .llm-family-config {
    left: 100%;
    right: auto;
    margin-left: 6px;
    z-index: 221;
    max-height: min(70vh, 420px);
    overflow-y: auto;
  }
  .ai-mobile-bar .ai-apps-menu {
    left: 0;
    right: auto;
    z-index: 220;
    overflow-y: auto;
    min-width: 0;
    width: max-content;
    max-width: min(168px, calc(100vw - 24px));
    padding: 4px;
    gap: 2px;
    max-height: min(46vh, 240px);
    border-radius: 6px;
  }
  .ai-mobile-bar .ai-apps-menu .btn,
  .ai-mobile-bar .ai-apps-menu .btn[data-ai-connect] {
    min-height: 0;
    padding: 4px 8px;
    font-size: 11px;
    border-radius: 6px;
  }
  .ai-mobile-bar .wake-picker .asset-picker-menu {
    left: 0;
    right: auto;
    z-index: 220;
  }
  .ai-mobile-tour {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 18px;
    font-weight: 700;
    line-height: 1;
  }
  .site-tour { display: flex; }
  body.page-ai .topbar-right,
  body.page-charts .topbar-right,
  body.page-devices .topbar-right,
  body.page-guide .topbar-right,
  body.page-home .topbar-right { padding-right: 0; }
  body.page-ai #ninjaTourRelaunch,
  body.page-charts #ninjaTourRelaunch,
  body.page-devices #ninjaTourRelaunch,
  body.page-guide #ninjaTourRelaunch,
  body.page-home #ninjaTourRelaunch { display: none !important; }
}

.ai-ops-research,
.ai-surface-tv {
  grid-area: tv;
  display: none;
  flex-direction: column;
  position: relative;
  min-width: 0;
  max-width: 100%;
  z-index: 2;
  padding: 10px 12px 0;
  border-radius: 20px;
  background:
    radial-gradient(circle at 50% 42%, rgba(184, 247, 228, 0.08), transparent 42%),
    #070809;
  border: 1px solid rgba(184, 247, 228, 0.16);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}
.ai-desk[data-tv="on"] .ai-ops-research,
.ai-desk[data-stage="research"] .ai-ops-research,
.ai-desk[data-expand="research"] .ai-ops-research,
.ai-ops-research.is-on {
  display: flex;
  align-self: start;
  min-height: 0;
}
.ai-tv-kicker,
.ai-ops-kicker {
  display: block;
  font-size: 10px;
  letter-spacing: 0.16em;
  color: #b8f7e4;
  font-weight: 700;
}
.ai-ops-research[data-mode="device"] .ai-tv-kicker { color: #e8d7a8; }
.ai-monitor-head strong,
.ai-world-hud strong {
  display: block;
  font-size: 14px;
  color: #f2f8f5;
  word-break: break-all;
}
.ai-monitor-task {
  margin: 6px 0 0;
  color: #8b938f;
  font-size: 11px;
}
.ai-monitor-meta,
.ai-tv-meta,
.ai-world-hud-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  color: #8b938f;
  font-size: 11px;
}
.ai-phase {
  border: 1px solid rgba(184, 247, 228, 0.35);
  color: #b8f7e4;
  border-radius: 999px;
  padding: 2px 8px;
  letter-spacing: 0.1em;
  font-size: 10px;
  font-weight: 700;
}
.ai-ops-research[data-phase="FAILED"] .ai-phase {
  border-color: rgba(251, 113, 133, 0.5);
  color: #fb7185;
}
.ai-ops-research[data-phase="NAVIGATING"] .ai-phase,
.ai-ops-research[data-phase="SEARCHING"] .ai-phase,
.ai-ops-research[data-phase="READING"] .ai-phase,
.ai-ops-research[data-phase="SCROLLING"] .ai-phase,
.ai-ops-research[data-phase="EXTRACTING"] .ai-phase {
  box-shadow: 0 0 12px rgba(184, 247, 228, 0.25);
}
.ai-tv-arena {
  position: relative;
  flex: 1 1 auto;
  min-height: min(28vh, 280px);
  height: auto;
  margin: 8px -12px 0;
}
.ai-desk[data-tv="on"] .ai-tv-arena,
.ai-desk[data-stage="research"] .ai-tv-arena,
.ai-desk[data-tv="on"][data-stage="world"] .ai-tv-arena,
.ai-desk[data-tv="on"][data-stage="brain"] .ai-tv-arena {
  min-height: 0;
}
.ai-desk[data-expand="research"] .ai-tv-arena,
.ai-desk[data-tv-size="full"] .ai-tv-arena {
  min-height: 0;
}
.ai-monitor-screen,
.ai-tv-screen {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: inherit;
  overflow: hidden;
  border-radius: 0 0 20px 20px;
  background:
    radial-gradient(circle at 50% 0%, rgba(184, 247, 228, 0.05), transparent 46%),
    #070809;
}
.ai-tv-arena .ai-world-dock {
  max-width: min(280px, 36%);
}
.ai-monitor-screen img {
  display: block;
  width: 100%;
  height: 100%;
  max-height: inherit;
  object-fit: contain;
  background: #070809;
}
.ai-monitor-standby,
.ai-monitor-fail {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 8px;
  text-align: center;
  padding: 20px;
  color: #c9d4ce;
}
.ai-monitor-standby span,
.ai-monitor-fail strong {
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 12px;
  color: #b8f7e4;
}
.ai-monitor-standby em {
  font-style: normal;
  color: #8b938f;
  font-size: 12px;
}
.ai-monitor-fail-actions { display: flex; gap: 8px; justify-content: center; }
.ai-monitor-standby.hidden,
.ai-monitor-fail.hidden { display: none; }
.ai-monitor-rail,
.ai-tv-arena #tv-rail {
  max-height: min(42%, 220px);
  overflow: auto;
}
.ai-monitor-rail h3 {
  margin: 0 0 8px;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #b8f7e4;
}
.ai-monitor-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.ai-monitor-chips span {
  border: 1px solid rgba(184, 247, 228, 0.2);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 10px;
  color: #b8f7e4;
}
.ai-ops-world {
  grid-area: world;
  display: none;
  position: relative;
  min-height: min(48vh, 520px);
  padding: 10px 12px 0;
  border-radius: 20px;
  background:
    radial-gradient(circle at 50% 46%, rgba(184, 247, 228, 0.06), transparent 38%),
    #040506;
  border: 1px solid rgba(184, 247, 228, 0.16);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}
.ai-desk[data-stage="world"] .ai-ops-world,
.ai-desk[data-expand="world"] .ai-ops-world { display: block; }
.ai-desk[data-expand="world"]:not([data-tv="on"]) .ai-ops-world { min-height: min(62vh, 680px); }
.ai-desk[data-tv="on"][data-stage="world"] .ai-ops-world,
.ai-desk[data-tv="on"][data-expand="world"] .ai-ops-world {
  min-height: min(56vh, 560px);
}
.ai-world-hud {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  position: relative;
  z-index: 2;
}
.ai-world-arena {
  position: relative;
  min-height: min(42vh, 460px);
  margin: 6px -12px 0;
}
.ai-desk[data-expand="world"]:not([data-tv="on"]) .ai-world-arena { min-height: min(54vh, 600px); }
.ai-desk[data-tv="on"][data-stage="world"] .ai-world-arena,
.ai-desk[data-tv="on"][data-expand="world"] .ai-world-arena {
  min-height: min(44vh, 440px);
}
#world-globe {
  display: block;
  width: 100%;
  height: min(42vh, 460px);
  cursor: grab;
}
.ai-desk[data-expand="world"]:not([data-tv="on"]) #world-globe { height: min(54vh, 600px); }
.ai-desk[data-tv="on"][data-stage="world"] #world-globe,
.ai-desk[data-tv="on"][data-expand="world"] #world-globe {
  height: min(44vh, 440px);
}
.ai-world-title {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none;
  z-index: 2;
}
.ai-world-title strong {
  display: block;
  font-size: clamp(22px, 3vw, 34px);
  letter-spacing: 0.04em;
  color: #f2f8f5;
  line-height: 1.05;
}
.ai-world-title em {
  display: block;
  margin-top: 4px;
  font-style: normal;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #8b938f;
}
.ai-world-rail {
  position: absolute;
  top: 52px;
  bottom: 46px;
  width: min(220px, 22%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 3;
  pointer-events: none;
}
.ai-world-rail .ai-world-dock { pointer-events: auto; }
.ai-world-rail-w { left: 10px; }
.ai-world-rail-e { right: 10px; text-align: right; }
.ai-world-dock {
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(8, 10, 12, 0.72);
  border: 1px solid rgba(184, 247, 228, 0.12);
  backdrop-filter: blur(12px);
  color: #d7e0dc;
  font-size: 12px;
}
.ai-world-dock h3 {
  margin: 0 0 6px;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #b8f7e4;
}
.ai-world-strip {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  display: flex;
  gap: 18px;
  overflow: auto;
  padding: 8px 16px 10px;
  background: linear-gradient(180deg, transparent, rgba(4, 5, 6, 0.88));
  color: #d7e0dc;
  font-size: 11px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.ai-world-strip span { color: #8b938f; }
.ai-world-strip strong { color: #b8f7e4; font-weight: 650; }
.ai-world-feed-state {
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #b8f7e4;
  font-size: 11px;
}
.ai-world-findings {
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid rgba(184, 247, 228, 0.16);
  border-radius: 10px;
  background: rgba(14, 16, 18, 0.8);
  position: relative;
  z-index: 2;
}
.ai-ops-brain {
  grid-area: brain;
  display: none;
  position: relative;
  min-height: min(48vh, 520px);
  padding: 8px 12px 0;
  border-radius: 20px;
  background: #030405;
  border: 1px solid rgba(184, 247, 228, 0.12);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}
.ai-desk[data-stage="brain"] .ai-ops-brain,
.ai-desk[data-expand="brain"] .ai-ops-brain { display: block; }
.ai-desk[data-expand="brain"]:not([data-tv="on"]) .ai-ops-brain { min-height: min(58vh, 640px); }
.ai-desk[data-tv="on"][data-stage="brain"] .ai-ops-brain,
.ai-desk[data-tv="on"][data-expand="brain"] .ai-ops-brain {
  min-height: min(42vh, 440px);
}
.ai-brain-arena {
  position: relative;
  min-height: min(42vh, 460px);
  margin: 4px -12px 0;
}
.ai-desk[data-expand="brain"]:not([data-tv="on"]) .ai-brain-arena { min-height: min(50vh, 560px); }
.ai-desk[data-tv="on"][data-stage="brain"] .ai-brain-arena,
.ai-desk[data-tv="on"][data-expand="brain"] .ai-brain-arena {
  min-height: min(32vh, 340px);
}
#brain-canvas {
  display: block;
  width: 100%;
  height: min(42vh, 460px);
  cursor: grab;
  background: transparent;
}
#brain-canvas.is-drag { cursor: grabbing; }
.ai-desk[data-expand="brain"]:not([data-tv="on"]) #brain-canvas { height: min(50vh, 560px); }
.ai-desk[data-tv="on"][data-stage="brain"] #brain-canvas,
.ai-desk[data-tv="on"][data-expand="brain"] #brain-canvas {
  height: min(32vh, 340px);
}
.ai-brain-float {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  justify-content: center;
  max-width: min(720px, 70%);
  z-index: 3;
}
.ai-brain-stats,
.ai-brain-growth {
  position: absolute;
  z-index: 3;
  width: min(200px, 22%);
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(8, 10, 12, 0.62);
  border: 1px solid rgba(184, 247, 228, 0.1);
  backdrop-filter: blur(12px);
  color: #d7e0dc;
  font-size: 12px;
}
.ai-brain-stats { left: 12px; top: 58px; }
.ai-brain-growth { right: 12px; bottom: 18px; text-align: right; }
.ai-brain-stats .ai-brain-metric,
.ai-brain-growth .ai-brain-metric {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 3px 0;
  color: #8b938f;
}
.ai-brain-stats strong,
.ai-brain-growth strong { color: #f2f8f5; font-size: 18px; }
.ai-brain-legend {
  display: grid;
  gap: 4px;
  margin-top: 10px;
}
.ai-brain-legend button {
  display: flex;
  justify-content: space-between;
  width: 100%;
  background: transparent;
  border: 0;
  color: #c9d4ce;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
  padding: 2px 0;
}
.ai-brain-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 6px;
}
.ai-brain-float input,
.ai-brain-float select {
  background: rgba(10, 12, 14, 0.78);
  border: 1px solid rgba(184, 247, 228, 0.18);
  color: #e8eee9;
  border-radius: 8px;
  padding: 6px 8px;
  font: inherit;
  font-size: 12px;
  backdrop-filter: blur(10px);
}
.ai-brain-float input[type="search"] { min-width: 160px; }
.ai-brain-more,
.ai-brain-clusters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  width: 100%;
}
.ai-brain-more.hidden,
.ai-brain-clusters.hidden { display: none; }
.ai-brain-chip {
  border: 1px solid rgba(184, 247, 228, 0.2);
  background: rgba(12, 14, 16, 0.78);
  color: #c9d4ce;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
}
.ai-brain-chip.is-on {
  color: #06110c;
  background: #b8f7e4;
  border-color: #b8f7e4;
}
.ai-brain-empty,
.ai-brain-banner {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  z-index: 2;
  pointer-events: none;
}
.ai-brain-empty {
  top: 28%;
  width: min(420px, 80%);
  color: #c9d4ce;
}
.ai-brain-empty strong {
  display: block;
  letter-spacing: 0.12em;
  font-size: 13px;
  color: #b8f7e4;
  margin-bottom: 8px;
}
.ai-brain-empty p {
  margin: 0;
  color: #8b938f;
  font-size: 12px;
  line-height: 1.45;
}
.ai-brain-banner {
  top: 14px;
  letter-spacing: 0.14em;
  font-size: 11px;
  color: #b8f7e4;
  font-weight: 700;
}
.ai-brain-empty.hidden,
.ai-brain-banner.hidden { display: none; }
.ai-brain-hover {
  position: absolute;
  z-index: 4;
  min-width: 160px;
  max-width: 240px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(10, 12, 14, 0.88);
  border: 1px solid rgba(184, 247, 228, 0.22);
  color: #d7e0dc;
  font-size: 12px;
  pointer-events: none;
}
.ai-brain-hover.hidden { display: none; }
.ai-brain-hover strong { display: block; color: #f2f8f5; }
.ai-brain-hover span { color: #8b938f; font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; }
.ai-brain-inspect {
  position: absolute;
  top: 12px;
  right: 12px;
  width: min(280px, 36%);
  max-height: calc(100% - 24px);
  overflow: auto;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(10, 12, 14, 0.82);
  border: 1px solid rgba(184, 247, 228, 0.16);
  backdrop-filter: blur(12px);
  color: #d7e0dc;
  font-size: 12px;
  z-index: 4;
}
.ai-brain-inspect.hidden { display: none; }
.ai-brain-inspect h3 { margin: 0 8px 6px 0; font-size: 14px; }
.ai-brain-inspect .chip { margin-right: 4px; }
.ai-brain-inspect-close {
  position: absolute;
  top: 8px;
  right: 8px;
  background: transparent;
  border: 0;
  color: #8b938f;
  cursor: pointer;
  font-size: 14px;
}
.ai-brain-float .btn,
.ai-brain-chip,
.ai-brain-inspect-close,
.ai-brain-inspect .btn { cursor: pointer; }
@media (max-width: 1100px) {
  .ai-monitor-body { grid-template-columns: 1fr; }
  .ai-world-rail { position: relative; top: auto; bottom: auto; left: auto; right: auto; width: auto; max-width: none; pointer-events: auto; }
  .ai-world-title { position: relative; transform: none; left: auto; }
  .ai-world-strip { position: relative; }
  .ai-brain-stats,
  .ai-brain-growth { position: relative; width: auto; left: auto; right: auto; top: auto; bottom: auto; margin: 8px 12px; }
}

.ai-trail {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(184, 247, 228, 0.18);
  border-radius: 12px;
  background: #101214;
}
.ai-trail h3 {
  margin: 0 0 8px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #b8f7e4;
}
.ai-trail-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 0;
  border-top: 1px solid rgba(255,255,255,0.04);
  font-size: 12px;
  cursor: pointer;
}
.ai-trail-row span { color: #8b938f; font-size: 10px; letter-spacing: 0.04em; }
@media (max-width: 1100px) {
  .ai-brain-inspect { position: relative; width: auto; max-width: none; right: auto; top: auto; margin: 8px 12px 12px; }
  .ai-brain-float { max-width: calc(100% - 24px); }
}
.control-group .chart-asset-search,
#chart-asset-search {
  width: 160px;
  min-width: 160px;
  max-width: 160px;
  box-sizing: border-box;
  border: 1px solid #253238;
  background: #071016;
  color: #d9e8e9;
  border-radius: 8px;
  padding: 8px 12px;
  font: inherit;
}
.control-group .chart-asset-search::placeholder,
#chart-asset-search::placeholder { color: #799598; }
.control-group .chart-asset-search:focus,
#chart-asset-search:focus { outline: 1px solid rgba(184, 247, 228, 0.45); }
body.page-ai .studio-asset-context {
  position: relative;
  flex-shrink: 0;
  z-index: 240;
  display: flex;
  align-items: center;
  gap: 8px;
}
.chart-toolbar { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; margin-bottom: 14px; overflow: visible; position: relative; z-index: 230; }
.chart-toolbar-tape { display: none; }
@media (min-width: 901px) {
  body.page-charts .chart-toolbar { isolation: isolate; align-items: center; }
  body.page-charts .chart-toolbar-tape {
    display: block;
    position: absolute;
    left: 16px;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    height: 46px;
    min-height: 46px;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
  }
  body.page-charts .chart-toolbar::before,
  body.page-charts .chart-toolbar::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    width: 32px;
    background: #0f181e;
    z-index: 1;
    pointer-events: none;
  }
  body.page-charts .chart-toolbar::before { left: 0; border-radius: 12px 0 0 12px; }
  body.page-charts .chart-toolbar::after { right: 0; border-radius: 0 12px 12px 0; }
  body.page-charts .chart-toolbar > .control-group,
  body.page-charts .chart-toolbar > .control-actions {
    position: relative;
    z-index: 2;
  }
  /* Opaque field plate under Refresh / Search / Assets — same cover as Home Charts on the tape. */
  body.page-charts .chart-toolbar #chart-quick-access,
  body.page-charts .chart-toolbar #chart-asset-search,
  body.page-charts .chart-toolbar #btn-chart-refresh {
    position: relative;
    z-index: 3;
    box-shadow: 0 0 0 10px #0f181e;
  }
  body.page-charts .chart-toolbar #chart-quick-access {
    box-shadow: 0 0 0 10px #0f181e, 0 20px 56px rgba(0, 0, 0, 0.55);
  }
  body.page-charts .chart-toolbar #btn-chart-refresh {
    background: #27373a;
  }
  html[data-theme="light"] body.page-charts .chart-toolbar::before,
  html[data-theme="light"] body.page-charts .chart-toolbar::after {
    background: #ffffff;
  }
  html[data-theme="light"] body.page-charts .chart-toolbar #chart-quick-access,
  html[data-theme="light"] body.page-charts .chart-toolbar #chart-asset-search,
  html[data-theme="light"] body.page-charts .chart-toolbar #btn-chart-refresh {
    box-shadow: 0 0 0 10px #ffffff;
  }
  html[data-theme="light"] body.page-charts .chart-toolbar #chart-quick-access {
    box-shadow: 0 0 0 10px #ffffff, 0 1px 2px rgba(60, 64, 67, 0.12), 0 2px 6px rgba(60, 64, 67, 0.08);
  }
  html[data-theme="light"] body.page-charts .chart-toolbar #btn-chart-refresh {
    background: #d7f4ea;
  }
}
.chart-search-wrap { position: relative; flex: 0 0 auto; width: auto; }
.chart-quick { display: flex; flex-wrap: wrap; gap: 6px; max-width: min(720px, 100%); }
.chart-quick-picker {
  position: relative;
  z-index: 240;
  overflow: visible;
  background: #0f181e;
  border: 1px solid #3a535c;
  border-radius: 8px;
  padding: 3px;
  box-shadow: 0 20px 56px rgba(0, 0, 0, 0.55);
}
.chart-quick-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 108px;
  max-width: 180px;
  padding: 4px 10px;
  font-size: 12px;
  border: 0;
  border-radius: 7px;
  background: #0c1c24;
  color: #a9d8cc;
  box-shadow: inset 0 0 0 1px #304247;
  cursor: pointer;
}
.chart-quick-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chart-quick-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 220px;
  display: none;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  background: #0f181e;
  border: 1px solid #3a535c;
  border-radius: 8px;
  box-shadow: 0 20px 56px rgba(0, 0, 0, 0.55);
  z-index: 250;
}
.chart-quick-menu:not(.hidden) { display: flex; }
.chart-quick-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.chart-quick-pick {
  flex: 1 1 auto;
  min-width: 0;
  text-align: left;
  background: transparent;
  color: #a9d8cc;
  border: 0;
  border-radius: 6px;
  padding: 6px 8px;
  cursor: pointer;
}
.chart-quick-row.is-on .chart-quick-pick,
.chart-quick-pick:hover,
.chart-quick-pick:focus { background: #0c1c24; }
.chart-quick-remove {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 6px;
  background: rgba(229, 72, 77, 0.12);
  border: 1px solid rgba(229, 72, 77, 0.5);
  color: var(--red, #e5484d);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
html[data-theme="light"] .chart-quick-picker {
  background: #ffffff;
  border-color: #dadce0;
  box-shadow: 0 1px 2px rgba(60, 64, 67, 0.12), 0 2px 6px rgba(60, 64, 67, 0.08);
}
html[data-theme="light"] .chart-quick-btn {
  background: #ffffff;
  color: #17795e;
  box-shadow: inset 0 0 0 1px #dadce0;
}
html[data-theme="light"] .chart-quick-menu {
  background: #ffffff;
  border-color: #dadce0;
  box-shadow: 0 1px 2px rgba(60, 64, 67, 0.12), 0 2px 6px rgba(60, 64, 67, 0.08);
}
html[data-theme="light"] .chart-quick-pick { color: #17795e; }
html[data-theme="light"] .chart-quick-row.is-on .chart-quick-pick,
html[data-theme="light"] .chart-quick-pick:hover,
html[data-theme="light"] .chart-quick-pick:focus { background: #ffffff; }
.chart-unavailable { margin: 12px 0; padding: 12px; border: 1px solid var(--border, #3a3e45); border-radius: 8px; }
.lib-asset-tools {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  min-width: 0;
  width: 100%;
}
.lib-asset-field {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
}
body.page-ai .lib-asset-tools .lib-asset-search {
  width: 100%;
  max-width: none;
}
body.page-ai .lib-asset-search,
body.page-ai .ai-expert-training .xt-connect .mini-input {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  max-width: 420px;
  background: #071016;
  border: 1px solid #253238;
  color: #d9e8e9;
  border-radius: 8px;
  padding: 8px 12px;
  font: inherit;
  font-size: 13px;
}
body.page-ai .ai-expert-training .xt-connect select.mini-input {
  width: auto;
  min-width: 120px;
  max-width: none;
}
body.page-ai .lib-asset-search::placeholder,
body.page-ai .ai-expert-training .xt-connect .mini-input::placeholder { color: #799598; }
body.page-ai .lib-asset-search:focus,
body.page-ai .ai-expert-training .xt-connect .mini-input:focus {
  outline: 1px solid rgba(184, 247, 228, 0.45);
}
.lib-asset-hits {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  z-index: 5;
  width: auto;
  max-width: none;
}
.lib-asset-hits button { display: block; width: 100%; text-align: left; background: none; border: 0; color: inherit; padding: 6px 8px; cursor: pointer; }
.au-hint { font-size: 10px; color: var(--muted, #9ca6a2); margin-left: 4px; }
html:not([data-theme="light"]) body.page-ai .asset-picks .chip.ok .au-hint {
  color: inherit;
}
.home-manage-assets { text-decoration: none; }
.teach-asset-picker {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  margin: 12px 0;
}
.teach-asset-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  width: 100%;
}
body.page-ai .lib-find-asset,
body.page-ai .teach-find-asset {
  display: inline-flex;
  width: auto;
  min-width: 148px;
  padding: 8px 14px;
  white-space: nowrap;
  flex: 0 0 auto;
}
html[data-theme="light"] body.page-ai .lib-asset-search,
html[data-theme="light"] body.page-ai .ai-expert-training .xt-connect .mini-input {
  background: #f8f9fa;
  border-color: #dadce0;
  color: #202124;
}
html[data-theme="light"] body.page-ai .lib-asset-search::placeholder,
html[data-theme="light"] body.page-ai .ai-expert-training .xt-connect .mini-input::placeholder { color: #5f6368; }
html[data-theme="light"] body.page-ai .lib-asset-search:focus,
html[data-theme="light"] body.page-ai .ai-expert-training .xt-connect .mini-input:focus {
  outline-color: rgba(23, 121, 94, 0.35);
}
.chart-search-hits {
  position: absolute;
  z-index: 20;
  background: #1b1e22;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 6px;
  margin-top: 4px;
  max-height: 220px;
  overflow: auto;
}
html[data-theme="light"] .control-group .chart-asset-search,
html[data-theme="light"] #chart-asset-search {
  background: #f8f9fa;
  border-color: #dadce0;
  color: #202124;
}
html[data-theme="light"] .control-group .chart-asset-search::placeholder,
html[data-theme="light"] #chart-asset-search::placeholder { color: #5f6368; }
html[data-theme="light"] .control-group .chart-asset-search:focus,
html[data-theme="light"] #chart-asset-search:focus { outline-color: rgba(23, 121, 94, 0.35); }
html[data-theme="light"] .chart-search-hits {
  background: #ffffff;
  border-color: #dadce0;
}
.chart-search-hits button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  color: inherit;
  padding: 6px 8px;
  cursor: pointer;
}
.chart-asset-status, .studio-asset-card {
  margin: 8px 0 0;
  font-size: 13px;
}
.cap-badge { display: inline-block; margin: 2px 4px 2px 0; font-size: 10px; letter-spacing: 0.04em; padding: 2px 6px; border-radius: 999px; background: rgba(255,255,255,0.06); }
.cap-available { color: #8fe3a7; }
.cap-unavailable { color: #c98a8a; }
.cap-unverified, .cap-degraded { color: #f0c36a; }
