/* Theme variables: dark is default, light overrides via data-theme. */
:root,
:root[data-theme="dark"] {
  --bg: #0a0e17;
  --surface: #121826;
  --card: #0d1220;
  --accent: #ff8a1f;
  --accent-ink: #ff8a1f;            /* accent used as text/icon color */
  --accent-soft: rgba(255, 138, 31, 0.12);
  --accent-border: rgba(255, 138, 31, 0.45);
  --on-accent: #0a0e17;             /* text on accent-filled elements */
  --text: #f4f6fa;
  --muted: #98a2b3;
  --border: #232c3f;
  --green: #2fbf71;
  --red: #e5484d;
  --amber: #f0a63a;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  --scrollbar-thumb: #2c3850;
  --scrollbar-track: transparent;
  --scrollbar-thumb-hover: #46546e;
}

:root[data-theme="light"] {
  --bg: #fcfbf9;
  --surface: #f8f3ee;
  --card: #ffffff;
  --accent: #ff8a1f;
  --accent-ink: #c2410c;
  --accent-soft: rgba(194, 65, 12, 0.08);
  --accent-border: rgba(194, 65, 12, 0.35);
  --on-accent: #0a0e17;
  --text: #0a0e17;
  --muted: #6b6f78;
  --border: #eee5dc;
  --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: #080b13;
  border: 1px solid #202636;
  border-radius: 8px;
  padding: 3px;
}
body.page-ai .wake-picker .tab,
body.page-ai .llm-family-btn,
body.page-ai .ai-apps-btn {
  color: #798398;
}
body.page-ai .wake-picker .tab.active,
body.page-ai .llm-family-btn,
body.page-ai .ai-apps-btn {
  background: #0d121f;
  color: #ffbe80;
  box-shadow: inset 0 0 0 1px #293144;
}
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: #080b13;
  border-color: #202636;
}
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: #c2410c;
  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: #ff8a1f;
  background: rgba(255, 138, 31, 0.14);
  background-color: rgba(255, 138, 31, 0.14);
  border: 1px solid rgba(255, 138, 31, 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(255, 138, 31, 0.16);
  background-color: rgba(255, 138, 31, 0.16);
  border: 1px solid rgba(194, 65, 12, 0.35);
  color: #c2410c;
  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(255, 138, 31, 0.14);
    background-color: rgba(255, 138, 31, 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(255, 138, 31, 0.16);
    background-color: rgba(255, 138, 31, 0.16);
    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: #0d111d;
  border: 1px solid #323c58;
  border-radius: 12px;
  box-shadow: 0 20px 56px rgba(0, 0, 0, 0.55);
}
.site-nav-list a {
  color: #dbdfe7;
  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(255, 138, 31, 0.14);
  color: #ff8a1f;
}
.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: #dbdfe7;
  padding: 8px 10px;
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
  font-weight: 650;
}
.site-nav-list > .site-nav-logout:hover {
  background: rgba(255, 138, 31, 0.14);
  color: #ff8a1f;
  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: #ff8a1f;
}
.site-nav-list > .btn.icon.site-nav-theme:hover {
  background: rgba(255, 138, 31, 0.14);
  filter: none;
}
.site-nav-list > .btn.icon.site-nav-theme svg { stroke: #ff8a1f; }
html[data-theme="light"] .site-nav-list {
  background: #ffffff;
  border-color: #dadce0;
  box-shadow: 0 1px 2px rgba(60, 62, 67, 0.12), 0 2px 6px rgba(60, 62, 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(255, 138, 31, 0.16);
  color: #c2410c;
}
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(255, 138, 31, 0.16);
  color: #c2410c;
}
html[data-theme="light"] .site-nav-list > .btn.icon.site-nav-theme {
  background: transparent;
  border: none;
  color: #c2410c;
}
html[data-theme="light"] .site-nav-list > .btn.icon.site-nav-theme:hover {
  background: rgba(255, 138, 31, 0.16);
}
html[data-theme="light"] .site-nav-list > .btn.icon.site-nav-theme svg { stroke: #c2410c; }
.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(255, 138, 31, 0.45);
  background: rgba(255, 138, 31, 0.14);
  color: #ff8a1f;
  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(255, 138, 31, 0.16);
  border: 1px solid rgba(194, 65, 12, 0.35);
  color: #c2410c;
}
.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: 280px;
  display: none;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  background: #080b13;
  border: 1px solid #202636;
  border-radius: 8px;
  z-index: 95;
}
.llm-family-config {
  position: absolute;
  top: calc(100% + 6px);
  left: auto;
  right: 100%;
  margin-right: 6px;
  min-width: 240px;
  display: none;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  background: #080b13;
  border: 1px solid #202636;
  border-radius: 8px;
  z-index: 96;
}
.llm-family-config::after {
  content: "";
  position: absolute;
  top: 0;
  right: -8px;
  width: 8px;
  height: 100%;
}
.llm-family-menu:not(.hidden),
.llm-family-config:not(.hidden),
.ai-apps-menu:not(.hidden) { display: flex; }
.llm-family-group {
  color: #798398;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 6px 8px 2px;
}
.llm-family-menu > .llm-family-group {
  color: #ffffff;
}
.llm-family-menu > .llm-family-empty {
  display: block;
  position: static;
  margin: 0;
  width: 100%;
  box-sizing: border-box;
  color: #ffbe80;
  font-size: 12px;
  line-height: 1.4;
  padding: 8px 10px;
  white-space: normal;
}
.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: #ffbe80;
  border: 0;
  border-radius: 6px;
  padding: 6px 8px;
  cursor: pointer;
}
.llm-family-status.is-disconnected {
  color: #e5484d;
  font-size: 13.333px;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: normal;
}
.ai-apps-status.is-connected {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: inherit;
  font-size: 13.333px;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: normal;
}
.ai-apps-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  flex: 0 0 auto;
}
.llm-family-row:hover,
.llm-family-row:focus,
.ai-apps-row:hover { background: #0d121f; }
.llm-family-row[disabled] { opacity: 0.55; cursor: default; }
.llm-family-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.llm-family-trail {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  margin-left: auto;
}
.llm-family-click {
  display: inline-flex;
  width: 12px;
  height: 12px;
  color: #ffbe80;
  opacity: 0.72;
}
.llm-family-click svg {
  width: 12px;
  height: 12px;
  display: block;
}
.llm-family-row:hover .llm-family-click,
.llm-family-row:focus .llm-family-click { opacity: 1; }
.llm-family-config label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #f4f6fa;
  font-size: 12px;
  padding: 3px 6px;
}
.llm-family-config .llm-family-note {
  color: #798398;
  font-size: 11px;
  padding: 4px 6px;
}
.llm-family-config .llm-family-use {
  background: rgba(240, 166, 58, 0.28);
  border: 1px solid var(--amber);
  color: #f5c36a;
  font-weight: 650;
}
.llm-family-config .llm-family-use:hover,
.llm-family-config .llm-family-use:focus {
  background: rgba(240, 166, 58, 0.42);
  border-color: #f4b45a;
  color: #ffd78a;
  filter: none;
}
.ai-apps-wrap { position: relative; }
.ai-apps-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
}
.ai-apps-item .ai-apps-row { cursor: default; }
.ai-apps-actions { display: flex; gap: 6px; flex-wrap: nowrap; flex-shrink: 0; align-items: center; }
.ai-apps-login {
  margin: 0 8px 6px;
  padding: 6px 8px;
  border-radius: 6px;
  background: rgba(255, 138, 31, 0.06);
  border: 1px solid rgba(255, 138, 31, 0.18);
}
.ai-apps-login pre,
.ai-apps-login .ai-apps-user-code {
  margin: 6px 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 18px;
  letter-spacing: 0.08em;
  line-height: 1.35;
  color: #f7c883;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.ai-apps-menu .btn,
.ai-apps-menu .btn[data-ai-connect] {
  background: rgba(255, 138, 31, 0.14);
  border: 1px solid rgba(255, 138, 31, 0.45);
  color: #ff8a1f;
  border-radius: 8px;
  font-weight: 650;
  padding: 6px 14px;
  font-size: 12px;
}
.ai-apps-menu .btn[data-ai-act="disconnect"] {
  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: #c2410c; }
html[data-theme="light"] .llm-family-menu > .llm-family-group { color: #202124; }
html[data-theme="light"] .llm-family-menu > .llm-family-empty { color: #c2410c; }
html[data-theme="light"] .ai-apps-menu .btn,
html[data-theme="light"] .ai-apps-menu .btn[data-ai-connect] {
  background: rgba(255, 138, 31, 0.16);
  border: 1px solid rgba(194, 65, 12, 0.35);
  color: #c2410c;
}
html[data-theme="light"] .ai-apps-menu .btn[data-ai-act="disconnect"] {
  background: rgba(229, 72, 77, 0.12);
  border-color: rgba(229, 72, 77, 0.45);
  color: #c5221f;
}
html[data-theme="light"] .llm-family-click { color: #c2410c; }
html[data-theme="light"] .llm-family-row:hover,
html[data-theme="light"] .llm-family-row:focus,
html[data-theme="light"] .ai-apps-row:hover { background: rgba(194, 65, 12, 0.06); }
html[data-theme="light"] .llm-family-config .llm-family-use {
  background: rgba(178, 106, 0, 0.16);
  border-color: var(--amber);
  color: #8a5200;
}
html[data-theme="light"] .llm-family-config .llm-family-use:hover,
html[data-theme="light"] .llm-family-config .llm-family-use:focus {
  background: rgba(178, 106, 0, 0.24);
  border-color: #b26a00;
  color: #6b3f00;
}
html[data-theme="light"] .ai-apps-login {
  background: rgba(194, 65, 12, 0.06);
  border-color: rgba(194, 65, 12, 0.18);
}
html[data-theme="light"] .ai-apps-login pre,
html[data-theme="light"] .ai-apps-login .ai-apps-user-code { color: #174ea6; }

.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: #ff8a1f;
  border-color: #ff8a1f;
}
.page-charts #asset-tabs .tab,
.page-charts #tf-tabs .tab {
  color: #ff8a1f;
  border-color: #ff8a1f;
  background: none;
}
.page-charts #asset-tabs .tab.active,
.page-charts #tf-tabs .tab.active {
  color: #0a0e17;
  border-color: #ff8a1f;
  background: #ff8a1f;
}
.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, #9aa2b2); }
.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: #FF8A1F; border-color: #FF8A1F; color: #0a0e17; }
.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: #0a0e17;
  background: #FF8A1F;
  border-color: #FF8A1F;
}
.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(244, 173, 90, 0.14);
  border-color: rgba(244, 173, 90, 0.5);
  color: #f4ad5a;
}
html[data-theme="light"] .btn.secondary,
html[data-theme="light"] .btn.train,
html[data-theme="light"] .btn.archive {
  background: rgba(244, 173, 90, 0.28);
  border-color: rgba(136, 59, 15, 0.4);
  color: #8b3d0f;
}
.btn.sync {
  background: #efe6d2;
  border-color: #efe6d2;
  color: #05070c;
}
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); }
.banner.warn { background: rgba(240, 166, 58, 0.12); border-color: rgba(240, 166, 58, 0.5); color: var(--amber); }
#banner.banner {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  z-index: 9000;
  width: max-content;
  max-width: min(560px, calc(100vw - 32px));
  margin: 0;
  background-color: var(--surface);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}
.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%; }
body.page-charts {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: 16px;
}
body.page-charts .desk-v1 {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
body.page-charts #tv-chart-wrap:not(.is-expanded):not(.hidden) {
  flex: 1 1 auto;
  min-height: 0;
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
}
body.page-charts #tv-chart-wrap:not(.is-expanded) #tv-chart,
body.page-charts #tv-chart-wrap:not(.is-expanded) .btc-chart-canvas {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  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: #0d111d;
  border: 1px solid #323c58;
  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.is-close { background: var(--red); }
#tv-collapse,
#world-collapse,
#brain-collapse { background: var(--amber); }
.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,
.scene-win-btn.is-close 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; }
html[data-theme="light"] .scene-win-btn.is-close svg,
html[data-theme="light"] #tv-collapse svg,
html[data-theme="light"] #world-collapse svg,
html[data-theme="light"] #brain-collapse svg { stroke: #111; }
.scene-win-btn:hover { filter: brightness(1.08); }
.scene-win-btn:active { transform: scale(0.94); }
.scene-win-btn:focus-visible {
  outline: 2px solid #f5b768;
  outline-offset: 2px;
}
.scene-win-btn.is-collapse:focus-visible { outline-color: #ff5f57; }
.scene-win-btn.is-close:focus-visible { outline-color: var(--red); }
#tv-collapse:focus-visible,
#world-collapse:focus-visible,
#brain-collapse:focus-visible { outline-color: var(--amber); }
@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(255, 138, 31, 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), #f3973e); }

.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(255, 138, 31, 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(255, 138, 31, 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: #909aae;
  border-radius: 999px;
}
.daily-brief-modal-card .modal-body::-webkit-scrollbar-thumb:hover {
  background: #afb6c5;
}
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;
  font-weight: 700;
  color: #fff;
}
html[data-theme="light"] .engine-reserved-line { color: var(--text); }
.engine-openings-sub.engine-line-white,
.engine-armed-meta.engine-line-white { color: #fff; }
.engine-openings-sub.engine-line-bold { font-weight: 800; }
.engine-portfolio-title {
  font-weight: 800;
  color: var(--amber);
}
html[data-theme="light"] .engine-openings-sub.engine-line-white,
html[data-theme="light"] .engine-armed-meta.engine-line-white { color: var(--text); }
.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-head {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ai-exec-head .ai-exec-title { margin: 0; }
.ai-exec-head .btn { flex: 0 0 auto; }
.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-on .ai-exec-pills .chip {
  color: #fff;
  border-color: #fff;
}
html[data-theme="light"] .ai-exec-on .ai-exec-pills .chip {
  color: #111;
  border-color: #111;
}
.ai-exec-list {
  list-style: none;
  display: grid;
  gap: 12px;
  max-height: 320px;
  margin: 8px 0 0;
  padding: 12px;
  overflow-x: hidden;
  overflow-y: auto;
  background: #12192c;
  border-radius: 10px;
}
.ai-exec-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
}
.ai-exec-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 12px;
  align-items: flex-end;
  margin: 12px 0;
}
.ai-exec-form label {
  display: grid;
  gap: 4px;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.ai-exec-form .hint,
.ai-exec-form .ts {
  flex: 1 1 100%;
  text-transform: none;
  letter-spacing: 0;
}
.ai-exec-scope,
.ai-exec-form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}
.ai-exec-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
  color: var(--text);
}
.ai-exec-row-pills {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.ai-exec-row .chip {
  display: inline-flex;
  align-items: center;
  width: auto;
  min-height: 32px;
  padding: 6px 14px;
}
.ai-exec-row .chip.exec-none {
  color: var(--amber);
  border-color: var(--amber);
  background: transparent;
}
.ai-exec-row .chip.exec-origin {
  color: #ff8a1f;
  border-color: #ff8a1f;
  background: transparent;
}
html[data-theme="light"] .ai-exec-row .chip.exec-origin {
  background: rgba(255, 138, 31, 0.16);
  border: 1px solid rgba(194, 65, 12, 0.35);
  color: #c2410c;
}
.ai-exec-row .chip.exec-long {
  color: var(--green);
  border-color: rgba(47, 191, 113, 0.55);
  background: transparent;
}
.ai-exec-row .chip.exec-short {
  color: var(--red);
  border-color: rgba(229, 72, 77, 0.55);
  background: transparent;
}
html[data-theme="light"] .ai-exec-row .chip.exec-long {
  background: rgba(47, 191, 113, 0.14);
  border: 1px solid rgba(47, 191, 113, 0.45);
  color: var(--green);
}
html[data-theme="light"] .ai-exec-row .chip.exec-short {
  background: rgba(229, 72, 77, 0.12);
  border: 1px solid rgba(229, 72, 77, 0.45);
  color: var(--red);
}
.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; }
.weekend-trading,
.news-pause {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-weight: 700;
}
.weekend-state.is-on,
.news-pause-state.is-on,
.engine-openings-sub.weekend-state.is-on,
.engine-openings-sub.news-pause-state.is-on {
  color: var(--green);
  font-weight: 700;
}
.weekend-state.is-off,
.news-pause-state.is-off,
.engine-openings-sub.weekend-state.is-off,
.engine-openings-sub.news-pause-state.is-off {
  color: var(--red);
  font-weight: 700;
}
.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: #ff8a1f;
  text-decoration: none;
}
.engine-manage-link:visited,
.engine-manage-link:active,
.engine-manage-link:hover {
  color: #ff8a1f;
  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: #798398;
  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 > .guide-toc-title {
  display: block;
  margin: 0 0 10px;
}
.guide-toc.legal-toc {
  position: static;
}
.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,
.foot a:focus {
  color: var(--accent-ink);
  text-decoration: none;
}
.foot a:hover {
  text-decoration: underline;
}

/* ---------- 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: #080b13;
    border-color: #202636;
  }
  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;
  }
  .card[data-tour="mode"] #etoro-venue {
    grid-column: 1 / -1;
    grid-row: 4;
  }
  .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: #f6b96b;
  box-shadow: 0 0 0 10px rgba(246,185,107,0.16), 0 0 56px rgba(246,185,107,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,
.ai-composer-action[data-mode="stop"] .icon-stop { display: block; }
.ai-composer-action .icon-stop {
  fill: #e5484d;
  stroke: none;
}
.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,
  .home-ask-panel .home-ask-body {
    scrollbar-width: thin;
    scrollbar-color: #909aae transparent;
  }
  html[data-theme="light"] .daily-brief-modal-card .modal-body,
  html[data-theme="light"] .home-ask-panel .home-ask-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;
}
#studio-link-spot {
  position: fixed;
  inset: 0;
  z-index: 470;
  cursor: pointer;
}
#studio-link-spot .studio-link-box {
  position: fixed;
  pointer-events: none;
  border: 2px solid var(--accent);
  border-radius: 10px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.28);
}
.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: #ff8a1f;
  border-color: #ff8a1f;
}
.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,
html:not([data-theme="light"]) .ai-exec-list::-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,
html:not([data-theme="light"]) .ai-exec-list::-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,
html:not([data-theme="light"]) .ai-exec-list::-webkit-scrollbar-thumb {
  background: #909aae;
  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,
html:not([data-theme="light"]) .ai-exec-list::-webkit-scrollbar-thumb:hover {
  background: #afb6c5;
}
html[data-theme="light"] .ai-lib-body,
html[data-theme="light"] .ai-lib-notes,
html[data-theme="light"] .ai-exec-list {
  padding-right: 10px;
}
html[data-theme="light"] .ai-exec-list {
  background: #fbf9f7;
}
html[data-theme="light"] .ai-lib-body::-webkit-scrollbar,
html[data-theme="light"] .ai-lib-notes::-webkit-scrollbar,
html[data-theme="light"] .ai-exec-list::-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,
html[data-theme="light"] .ai-exec-list::-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,
html[data-theme="light"] .ai-exec-list::-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,
html[data-theme="light"] .ai-exec-list::-webkit-scrollbar-thumb:hover {
  background: #c4c8cd;
}
html:not([data-theme="light"]) .ai-exec-list::-webkit-scrollbar,
html[data-theme="light"] .ai-exec-list::-webkit-scrollbar {
  width: 2px;
  height: 2px;
}
.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, 152, 160, 0.2);
  border: 1px solid rgba(148, 152, 160, 0.42);
  color: #c5c8cf;
}
.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; }
.ai-lib-card .wf-summary {
  font-size: 11px;
  color: var(--muted);
  margin: 4px 0 6px;
  line-height: 1.35;
}
.ai-lib-card .wf-table-wrap {
  overflow-x: auto;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.12);
}
html[data-theme="light"] .ai-lib-card .wf-table-wrap {
  background: rgba(255, 255, 255, 0.55);
}
.ai-lib-card .wf-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  line-height: 1.3;
}
.ai-lib-card .wf-table th,
.ai-lib-card .wf-table td {
  padding: 4px 6px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
.ai-lib-card .wf-table th {
  color: var(--muted);
  font-weight: 600;
  background: rgba(127, 127, 127, 0.08);
}
.ai-lib-card .wf-table tr:last-child td { border-bottom: none; }
.ai-lib-card .wf-table .wf-pos { color: var(--green); font-weight: 600; }
.ai-lib-card .wf-table .wf-neg { color: var(--red); font-weight: 600; }
.ai-lib-card .wf-summary .wf-pos { color: var(--green); font-weight: 600; }
.ai-lib-card .wf-summary .wf-neg { color: var(--red); font-weight: 600; }

@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-open {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.page-devices .devices-open h3 {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 600;
}
.page-devices .devices-open-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.page-devices .devices-open strong {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
}
.page-devices .devices-open ol {
  margin: 0;
  padding-left: 18px;
}
.page-devices .devices-open li {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}
.page-devices .devices-open li strong {
  display: inline;
  color: var(--text);
  font-size: inherit;
}
.page-devices .devices-note {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.page-devices .devices-note summary {
  cursor: pointer;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}
.page-devices .devices-note p,
.page-devices .devices-note li {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}
.page-devices .devices-note ol {
  margin: 8px 0 14px;
  padding-left: 18px;
}
.page-devices .devices-python-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 12px 0 14px;
}
.page-devices .devices-python-actions .btn {
  min-height: 44px;
  text-align: center;
  text-decoration: none;
}
.page-devices #manual-cmd:empty { display: none; }
.page-devices #manual-cmd {
  margin-top: 12px;
  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;
}
body.page-devices .device-actions .btn.reject {
  background: #c43238;
  border: 1px solid #ff8a8e;
  color: #ffd6d7;
}
html[data-theme="light"] body.page-devices .device-actions .btn.reject {
  background: #f3b8ba;
  border: 1px solid #d02c31;
  color: #9f1c22;
}
.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;
}
.page-devices .device-perm.is-locked input:disabled:checked + span {
  opacity: 1;
  cursor: default;
  border-color: var(--accent-border);
  background: var(--accent-soft);
  color: var(--accent-ink);
}
@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)); }
  .page-devices .devices-python-actions { grid-template-columns: 1fr; }
  .page-devices .devices-open-grid { grid-template-columns: 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-connect-creds {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.ai-expert-training .xt-secret {
  width: 124px;
  min-width: 108px;
  max-width: 124px;
  flex: 0 0 124px;
}
.ai-expert-training .xt-connect-creds .btn {
  flex: 0 0 auto;
  height: 32px;
  padding: 0 12px;
  white-space: nowrap;
}
.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: #FF8A1F;
  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: #FF8A1F;
  border-color: #FF8A1F;
  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: #FF8A1F;
  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(420px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  max-height: min(76vh, 580px);
  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; align-items: center; gap: 6px; flex-shrink: 0; }
.home-ask-clear {
  height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid #e5484d;
  background: rgba(229, 72, 77, 0.14);
  color: #e5484d;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.01em;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
}
.home-ask-clear:hover,
.home-ask-clear:focus-visible {
  background: rgba(229, 72, 77, 0.22);
  border-color: #e5484d;
  color: #ff7b80;
}
.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-form {
  display: flex;
  gap: 6px;
  padding: 10px;
  border-top: 1px solid var(--border);
}
.home-ask-field {
  position: relative;
  flex: 1;
  min-width: 0;
}
.home-ask-form input {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 12px 44px 12px 12px;
  font-size: 13px;
  line-height: 1.35;
}
.home-ask-form input:focus {
  outline: 1px solid var(--accent-border);
}
.home-ask-form input::placeholder { color: var(--muted); font-size: 12px; }
.home-ask-action {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--accent-border);
  background: var(--accent);
  color: var(--on-accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  pointer-events: auto;
}
.home-ask-action svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: none;
}
.home-ask-waves {
  display: none;
  align-items: flex-end;
  justify-content: center;
  gap: 2px;
  height: 14px;
  width: 16px;
}
.home-ask-waves span {
  display: block;
  width: 2px;
  height: 14px;
  border-radius: 1px;
  background: currentColor;
  transform: scaleY(0.18);
  transform-origin: center bottom;
  will-change: transform;
}
.home-ask-action[data-mode="voice"] .icon-mic,
.home-ask-action[data-mode="send"] .icon-send { display: block; }
.home-ask-action.is-recording .icon-mic,
.home-ask-action.is-recording .icon-send { display: none; }
.home-ask-action.is-recording .home-ask-waves { display: inline-flex; }
.home-ask-action.is-recording {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 45%, transparent);
}
.home-ask-action:focus-visible {
  outline: 2px solid var(--accent-border);
  outline-offset: 2px;
}
.home-ask-body {
  flex: 1;
  min-height: 188px;
  overflow: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.home-ask-body::-webkit-scrollbar {
  width: 2px;
  height: 2px;
}
.home-ask-body::-webkit-scrollbar-track {
  background: transparent;
}
.home-ask-body::-webkit-scrollbar-thumb {
  background: #909aae;
  border-radius: 999px;
}
.home-ask-body::-webkit-scrollbar-thumb:hover {
  background: #afb6c5;
}
.home-ask-empty {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}
.home-ask-suggestions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  flex-shrink: 0;
  gap: 6px;
  padding: 8px 12px 2px;
  border-top: 1px solid var(--border);
}
.home-ask-suggest {
  width: 100%;
  max-width: 100%;
  text-align: left;
  min-height: 28px;
  padding: 6px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  line-height: 1.3;
  white-space: nowrap;
  cursor: pointer;
}
@media (max-width: 439px) {
  .home-ask-suggest { white-space: normal; }
}
@media (max-width: 640px) {
  .home-ask[data-state="open"] {
    left: 50%;
    transform: translateX(-50%);
  }
  .home-ask[data-state="open"] .home-ask-panel {
    width: min(420px, calc(100vw - 40px));
    max-width: calc(100vw - 40px);
  }
}
.home-ask-suggest:hover,
.home-ask-suggest:focus-visible {
  border-color: var(--accent-border);
  color: var(--accent-ink);
  outline: none;
}
.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-bubble strong {
  font-weight: 700;
}
.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: #FF8A1F;
  color: var(--on-accent);
  font-size: 12px;
  font-weight: 650;
  text-decoration: none;
}

/* Home only: match AI scene card chrome. Do not restyle chips or primary/reject/approve buttons. */
body.page-home { background: #090c14; }
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: #0d111d;
  border: 1px solid #323c58;
  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: #0d111d;
  border: 1px solid #323c58;
  box-shadow: 0 20px 56px rgba(0, 0, 0, 0.55);
}
body.page-home .toast {
  background: #05070c;
  box-shadow: 0 14px 50px #0005;
}
body.page-home .proposals-panel {
  border-radius: 12px;
  padding: 16px;
}
body.page-home .panel-head h2 { color: #dbdfe7; font-weight: 550; }
body.page-home .empty,
body.page-home .hint,
body.page-home .bt-note,
body.page-home .decided { color: #798398; }
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 .wa-row input,
body.page-home .control-group input:not([type="checkbox"]):not([type="radio"]),
body.page-home .control-group select {
  background: #080b13;
  border-color: #202636;
}
body.page-home .mode-toggle {
  background: #080b13;
  border-color: #323c58;
}
body.page-home .mode-btn + .mode-btn { border-left-color: #323c58; }
body.page-home .mode-btn.locked,
body.page-home .mode-btn:disabled:not(.active) {
  opacity: 1;
  background: transparent;
  color: #dbdfe7;
}
body.page-home .broker-key-form input {
  background: #0d111d;
  border-color: #323c58;
}
body.page-home .engine-asset { border-top-color: #151b2b; }
body.page-home .engine-asset:hover,
body.page-home .engine-asset.selected { background: #080b13; }
body.page-home .tabs {
  background: #080b13;
  border: 1px solid #202636;
  border-radius: 8px;
  padding: 3px;
}
body.page-home .tab { color: #798398; }
body.page-home .tab.active {
  background: #0d121f;
  color: #ffbe80;
  box-shadow: inset 0 0 0 1px #293144;
}
body.page-home .home-ask-head,
body.page-home .home-ask-form,
body.page-home .home-ask-suggestions { border-color: #151b2b; }
body.page-home .home-ask-suggest {
  background: #080b13;
  border-color: #202636;
  color: #dbdfe7;
}
body.page-home .home-ask-suggest:hover,
body.page-home .home-ask-suggest:focus-visible {
  border-color: rgba(255, 138, 31, 0.45);
  color: #ff8a1f;
}
body.page-home .btn:not(.primary):not(.reject):not(.approve):not(.sync):not(.site-nav-theme),
body.page-home .home-ask-icon {
  background: rgba(255, 138, 31, 0.14);
  border: 1px solid rgba(255, 138, 31, 0.45);
  color: #ff8a1f;
  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 .home-ask-clear {
  background: rgba(229, 72, 77, 0.14);
  border: 1px solid #e5484d;
  color: #e5484d;
  border-radius: 8px;
}
body.page-home .home-ask-clear:hover,
body.page-home .home-ask-clear:focus-visible {
  background: rgba(229, 72, 77, 0.22);
  border-color: #e5484d;
  color: #ff7b80;
}
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, 62, 67, 0.12), 0 2px 6px rgba(60, 62, 67, 0.08);
}
html[data-theme="light"] body.page-home .toast { background: #ffffff; box-shadow: 0 1px 2px rgba(60, 62, 67, 0.12), 0 2px 6px rgba(60, 62, 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 .wa-row 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 .broker-key-form input {
  background: #ffffff;
  border-color: #dadce0;
  color: #202124;
}
html[data-theme="light"] body.page-home .mode-toggle {
  background: #f8f9fa;
  border-color: #dadce0;
}
html[data-theme="light"] body.page-home .mode-btn + .mode-btn { border-left-color: #dadce0; }
html[data-theme="light"] body.page-home .mode-btn.locked,
html[data-theme="light"] body.page-home .mode-btn:disabled:not(.active) {
  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: #c2410c;
  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,
html[data-theme="light"] body.page-home .home-ask-suggestions { border-color: #e8eaed; }
html[data-theme="light"] .home-ask-body::-webkit-scrollbar-thumb {
  background: #d5d9de;
}
html[data-theme="light"] .home-ask-body::-webkit-scrollbar-thumb:hover {
  background: #c4c8cd;
}
html[data-theme="light"] body.page-home .home-ask-suggest {
  background: #f8f9fa;
  border-color: #dadce0;
  color: #202124;
}
html[data-theme="light"] body.page-home .home-ask-suggest:hover,
html[data-theme="light"] body.page-home .home-ask-suggest:focus-visible {
  border-color: rgba(194, 65, 12, 0.35);
  color: #c2410c;
}
html[data-theme="light"] body.page-home .home-ask-clear,
html[data-theme="light"] .home-ask-clear {
  background: rgba(208, 44, 49, 0.10);
  border: 1px solid #d02c31;
  color: #d02c31;
}
html[data-theme="light"] body.page-home .home-ask-clear:hover,
html[data-theme="light"] body.page-home .home-ask-clear:focus-visible,
html[data-theme="light"] .home-ask-clear:hover,
html[data-theme="light"] .home-ask-clear:focus-visible {
  background: rgba(208, 44, 49, 0.16);
  border-color: #d02c31;
  color: #b42318;
}
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: #c2410c;
}
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):not(.ai-session-delete),
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(255, 138, 31, 0.16);
  border: 1px solid rgba(194, 65, 12, 0.35);
  color: #c2410c;
}
html[data-theme="light"] body.page-ai .site-nav-list {
  background: #ffffff;
  border-color: #dadce0;
  box-shadow: 0 1px 2px rgba(60, 62, 67, 0.12), 0 2px 6px rgba(60, 62, 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(255, 138, 31, 0.16);
  color: #c2410c;
}
html[data-theme="light"] body.page-ai .ai-lib-banner .chip:not(.ok):not(.warn):not(.err):not(.bad) {
  background: rgba(255, 138, 31, 0.16);
  border: 1px solid rgba(194, 65, 12, 0.35);
  color: #c2410c;
}
html[data-theme="light"] body.page-ai .asset-picks .chip:not(.ok):not(.warn):not(.err):not(.bad) {
  background: rgba(60, 62, 67, 0.14);
  border: 1px solid rgba(60, 62, 67, 0.28);
  color: #3c3e43;
}
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: #c2410c; }
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(255, 138, 31, 0.28); }
html[data-theme="light"] body.page-ai .ai-ws-tabs .tab.active {
  background: rgba(255, 138, 31, 0.16);
  color: #c2410c;
  box-shadow: inset 0 0 0 1px rgba(194, 65, 12, 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: #090c14;
}
body.page-charts .card,
body.page-devices .card,
body.page-guide .card,
body.page-login .card {
  background: #0d111d;
  border: 1px solid #323c58;
  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: #dbdfe7;
  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: #798398;
}
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: #080b13;
  border: 1px solid #202636;
  border-radius: 8px;
  padding: 3px;
}
body.page-charts .tab,
body.page-charts #asset-tabs .tab,
body.page-charts #tf-tabs .tab {
  color: #798398;
  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: #0d121f;
  color: #ffbe80;
  border-color: transparent;
  box-shadow: inset 0 0 0 1px #293144;
}
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: #080b13;
  border-color: #202636;
  color: #dbdfe7;
}
body.page-devices .device-row { border-bottom-color: #151b2b; }
body.page-devices .pair-token { border-top-color: #151b2b; }
body.page-guide .guide-glossary-body,
body.page-guide .guide-toc ol { border-top-color: #151b2b; }
body.page-devices .device-perm input:checked + span {
  background: rgba(255, 138, 31, 0.14);
  border-color: rgba(255, 138, 31, 0.45);
  color: #ff8a1f;
}
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(255, 138, 31, 0.14);
  border: 1px solid rgba(255, 138, 31, 0.45);
  color: #ff8a1f;
  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: #0d111d;
  border-color: #323c58;
  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: #dbdfe7; }
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(255, 138, 31, 0.14);
  color: #ff8a1f;
}
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-devices .chip.platform {
  background: rgba(255, 138, 31, 0.14);
  border-color: rgba(255, 138, 31, 0.45);
  color: #ff8a1f;
}
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: #ff8a1f;
}

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, 62, 67, 0.12), 0 2px 6px rgba(60, 62, 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: #c2410c;
  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(255, 138, 31, 0.16);
  border-color: rgba(194, 65, 12, 0.35);
  color: #c2410c;
}
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(255, 138, 31, 0.16);
  border: 1px solid rgba(194, 65, 12, 0.35);
  color: #c2410c;
}
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,
body.page-ai .ai-composer-action[data-mode="stop"],
body.page-ai .ai-composer-action[data-mode="stop"]:hover,
body.page-ai .ai-composer-action[data-mode="stop"]: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,
html[data-theme="light"] body.page-ai .ai-composer-action[data-mode="stop"],
html[data-theme="light"] body.page-ai .ai-composer-action[data-mode="stop"]:hover,
html[data-theme="light"] body.page-ai .ai-composer-action[data-mode="stop"]:focus {
  background: #FF8A1F;
  border-color: #FF8A1F;
  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,
body.page-ai .ai-composer-action[data-mode="stop"]: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, 62, 67, 0.12), 0 2px 6px rgba(60, 62, 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(255, 138, 31, 0.16);
  color: #c2410c;
}
html[data-theme="light"] body.page-charts #charts-meta.chip {
  color: #c2410c;
  border-color: rgba(194, 65, 12, 0.35);
  background: rgba(255, 138, 31, 0.16);
}
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-devices .chip.platform {
  background: rgba(255, 138, 31, 0.16);
  border-color: rgba(194, 65, 12, 0.35);
  color: #c2410c;
}
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: #c2410c;
}
html[data-theme="light"] body.page-guide .guide-callout {
  background: rgba(255, 138, 31, 0.16);
  border-color: rgba(194, 65, 12, 0.35);
  color: #c2410c;
}
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: #c2410c;
}

/* ---------- AI Desk (persistent Ninja presence) ---------- */
body.page-ai {
  padding-bottom: 16px;
  background: #090c14;
}
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"
    "left composer right";
  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:
    "left tv right"
    "left stage right"
    "left work right"
    "left composer right";
}
.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"
    "left composer right";
}
.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"
    "left composer right";
}
.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"
    "left composer right";
}
.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"
    "left composer right";
}
.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);
  overflow-anchor: none;
}
#job-steps .ai-event > div:first-child,
#activity .ai-event > div:first-child {
  min-height: 1.2em;
  color: #ff8a1f;
}
.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: #ff8a1f; 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, #ff8a1f 28%, transparent);
  stroke-width: 0.16;
  fill: none;
}
.ai-network-lines .ai-pathway.is-on,
.ai-network-lines line.is-on {
  stroke: var(--node, #ff8a1f);
  stroke-width: 0.28;
  filter: drop-shadow(0 0 0.6px var(--node, #ff8a1f));
}
.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 {
  cursor: pointer;
  --orb: #ff8a1f;
  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(255, 138, 31, 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(255, 138, 31, 0.34);
  stroke-width: 1.1;
}
.ai-neural-mid {
  fill: none;
  stroke: rgba(255, 138, 31, 0.18);
  stroke-width: 0.7;
}
.ai-neural-synapses line {
  stroke: rgba(255, 138, 31, 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: #ff8a1f;
  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: #ff8a1f;
  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(255, 138, 31, 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(255, 138, 31, 0.5); }
.ai-neural[data-state="interpreting"] .ai-neural-synapses line {
  stroke: rgba(255, 138, 31, 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(255, 138, 31, 0.34), transparent 74%);
  animation: ai-pulse 1.4s ease-in-out infinite;
}
.ai-neural[data-state="working"] .ai-neural-synapses line {
  stroke: rgba(255, 138, 31, 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: #fdecda;
  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(100%, 720px);
  min-height: 1.35em;
  margin: 10px auto 10px;
  padding: 0 8px;
  text-align: center;
  z-index: 1;
  pointer-events: none;
}
.ai-orb-type {
  display: block;
  min-height: 1.25em;
  color: #f4f6fa;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: 0.04em;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ai-orb-type::after {
  content: "▌";
  margin-left: 3px;
  color: #ff8a1f;
  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: #ff8a1f;
  --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, #ff8a1f 22%, var(--border));
  background: #11141a;
  color: #c8cbd0;
  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: #ff8a1f; }
.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: #ff8a1f;
  border-color: color-mix(in srgb, #ff8a1f 55%, var(--border));
  letter-spacing: 0.22em;
  text-shadow: 0 0 10px rgba(255, 138, 31, 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: #3c3e43;
  box-shadow: 0 1px 2px rgba(60, 62, 67, 0.12);
}
html[data-theme="light"] body.page-ai .ai-node:hover {
  color: #c2410c;
  background: rgba(255, 138, 31, 0.16);
  border-color: rgba(194, 65, 12, 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(194, 65, 12, 0.28);
}
html[data-theme="light"] body.page-ai .ai-ops-brain {
  background: #ffffff;
  border-color: #dadce0;
  box-shadow: 0 1px 2px rgba(60, 62, 67, 0.12), 0 2px 6px rgba(60, 62, 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(255, 138, 31, 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: #3c3e43; }
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: #c2410c; }
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: #c2410c; }
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-world-findings strong { color: #c2410c; }
html[data-theme="light"] body.page-ai .ai-world-findings p { 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, 62, 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: #ff8a1f;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ai-metric-marquee {
  overflow: hidden;
  min-width: 0;
}
.ai-metric-track {
  display: flex;
  width: max-content;
}
.ai-metric-marquee strong {
  overflow: visible;
  text-overflow: unset;
  flex: 0 0 auto;
  padding-right: 2.2em;
}
.ai-metric-marquee.is-scrolling .ai-metric-track {
  animation: ai-metric-marquee 16s linear infinite;
}
@keyframes ai-metric-marquee {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}
@media (prefers-reduced-motion: reduce) {
  .ai-metric-marquee.is-scrolling .ai-metric-track { animation: none; }
}
.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(255, 138, 31, 0.14);
  border: 1px solid rgba(255, 138, 31, 0.45);
  color: #ff8a1f;
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 650;
}
body.page-ai .ai-voice-live #btn-stop-voice {
  background: #FF8A1F;
  border-color: #FF8A1F;
  color: #0a0e17;
}
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(255, 138, 31, 0.16);
  border: 1px solid rgba(194, 65, 12, 0.35);
  color: #c2410c;
}
html[data-theme="light"] body.page-ai .ai-voice-live #btn-stop-voice {
  background: #FF8A1F;
  border-color: #FF8A1F;
  color: #0a0e17;
}
.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: #8b8e93;
  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: #11141a;
  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: #8b8e93;
  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: #e9dfd4;
  background: rgba(255, 138, 31, 0.04);
}
.ai-ws-tabs .tab.active {
  background: rgba(255, 138, 31, 0.09);
  color: #ff8a1f;
  box-shadow: inset 0 0 0 1px rgba(255, 138, 31, 0.32);
}
.ai-ws-tabs .tab.hidden { display: none; }
.is-surface {
  box-shadow: 0 0 0 1px rgba(255, 138, 31, 0.42), 0 0 22px rgba(255, 138, 31, 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(255, 138, 31, 0.32);
}
.ai-ws-panel { display: none; }
.ai-ws-panel.is-on { display: block; }
.ai-desk-chat {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: min(52vh, 520px);
  overflow-x: hidden;
  overflow-y: auto;
  padding-right: 8px;
}
.ai-desk-chat.hidden { display: none; }
.ai-desk-actions { display: flex; justify-content: flex-end; margin-bottom: 6px; }
.ai-session-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 0 12px 8px 26px;
}
body.page-ai .ai-workspace .ai-session-delete.btn,
body.page-ai .ai-workspace .ai-session-delete.btn:hover {
  color: #ff8a8e;
  border: 1px solid #e5484d;
  background: transparent;
  margin: 0;
  width: auto;
  font-size: 11px;
  line-height: 1.2;
  padding: 4px 8px;
}
body.page-ai .ai-workspace .ai-session-delete.btn:hover {
  color: #ffb4b6;
  border-color: #ff5a5f;
}
html[data-theme="light"] body.page-ai .ai-workspace .ai-session-delete.btn,
html[data-theme="light"] body.page-ai .ai-workspace .ai-session-delete.btn:hover {
  color: #c42328;
  border: 1px solid #d02c31;
  background: transparent;
}
body.page-ai .ai-workspace .ai-session-reuse.btn,
body.page-ai .ai-workspace .ai-session-reuse.btn:hover,
html[data-theme="light"] body.page-ai .ai-workspace .ai-session-reuse.btn,
html[data-theme="light"] body.page-ai .ai-workspace .ai-session-reuse.btn:hover {
  color: #ff8a1f;
  background: rgba(255, 138, 31, 0.16);
  border: 1px solid #ff8a1f;
  margin: 0;
  width: auto;
  font-size: 11px;
  line-height: 1.2;
  padding: 4px 8px;
}
.ai-desk-turn {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ai-desk-ask,
.ai-desk-reply,
.ai-desk-note {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.ai-desk-ask {
  color: #ff8a1f;
  font-size: 13px;
}
.ai-desk-reply,
.ai-desk-note {
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}
.ai-desk-reply a {
  color: #8ecbff;
  text-decoration: underline;
  text-underline-offset: 2px;
}
html[data-theme="light"] .ai-desk-reply a {
  color: #3d8fd4;
}
.ai-desk-reply.is-pending { color: var(--muted); }
.ai-desk-chat::-webkit-scrollbar { width: 3px; height: 3px; }
.ai-desk-chat::-webkit-scrollbar-track { background: transparent; }
.ai-desk-chat::-webkit-scrollbar-thumb {
  background: #909aae;
  border-radius: 999px;
}
.ai-desk-chat::-webkit-scrollbar-thumb:hover { background: #afb6c5; }
html[data-theme="light"] .ai-desk-chat::-webkit-scrollbar-thumb { background: #d5d9de; }
html[data-theme="light"] .ai-desk-chat::-webkit-scrollbar-thumb:hover { background: #c4c8cd; }
@supports not selector(::-webkit-scrollbar) {
  .ai-desk-chat { scrollbar-width: thin; scrollbar-color: #909aae transparent; }
  html[data-theme="light"] .ai-desk-chat { scrollbar-color: #d5d9de transparent; }
}
.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-transcript[hidden] { display: none !important; }
.ai-session-history {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: min(52vh, 520px);
  overflow-x: hidden;
  overflow-y: auto;
  padding-right: 4px;
}
.ai-session {
  border: 1px solid #202636;
  border-radius: 10px;
  background: #080b13;
}
.ai-session summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  cursor: pointer;
  list-style: none;
  color: #dbdfe7;
}
.ai-session summary::-webkit-details-marker { display: none; }
.ai-session-arrow {
  flex: none;
  width: 0;
  height: 0;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 5px solid #909aae;
  transition: transform 0.15s ease;
}
.ai-session[open] .ai-session-arrow { transform: rotate(90deg); }
.ai-session-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}
.ai-session-meta {
  margin-left: auto;
  flex: none;
  color: #798398;
  font: 10px ui-monospace, monospace;
}
.ai-session-log {
  max-height: 240px;
  overflow: auto;
  padding: 0 12px 10px 26px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ai-session-turn { display: flex; flex-direction: column; gap: 4px; }
.ai-session-ask { color: #ff8a1f; font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.ai-session-reply { color: var(--text); font-size: 13px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.ai-session-reply a { color: #8ecbff; }
.ai-session-history::-webkit-scrollbar,
.ai-session-log::-webkit-scrollbar { width: 3px; height: 3px; }
.ai-session-history::-webkit-scrollbar-track,
.ai-session-log::-webkit-scrollbar-track { background: transparent; }
.ai-session-history::-webkit-scrollbar-thumb,
.ai-session-log::-webkit-scrollbar-thumb { background: #909aae; border-radius: 999px; }
.ai-session-history::-webkit-scrollbar-thumb:hover,
.ai-session-log::-webkit-scrollbar-thumb:hover { background: #afb6c5; }
html[data-theme="light"] .ai-session { background: #f8f9fa; border-color: #dadce0; }
html[data-theme="light"] .ai-session summary { color: #202124; }
html[data-theme="light"] .ai-desk-ask,
html[data-theme="light"] .ai-session-ask,
html[data-theme="light"] #job-steps .ai-event > div:first-child,
html[data-theme="light"] #activity .ai-event > div:first-child { color: #c2410c; }
html[data-theme="light"] .ai-session-arrow { border-left-color: #5f6368; }
html[data-theme="light"] .ai-session-meta { color: #5f6368; }
html[data-theme="light"] .ai-session-reply a { color: #3d8fd4; }
html[data-theme="light"] .ai-session-history::-webkit-scrollbar-thumb,
html[data-theme="light"] .ai-session-log::-webkit-scrollbar-thumb { background: #d5d9de; }
@supports not selector(::-webkit-scrollbar) {
  .ai-session-history, .ai-session-log { scrollbar-width: thin; scrollbar-color: #909aae transparent; }
  html[data-theme="light"] .ai-session-history,
  html[data-theme="light"] .ai-session-log { scrollbar-color: #d5d9de transparent; }
}
.ai-desk > .ai-composer { margin: 0; }
@media (min-width: 1101px) {
  html:not(.showcase-stage-guest) body.page-ai .ai-desk:has(.ai-ws-panel[data-ws="library"].is-on),
  html:not(.showcase-stage-guest) 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"
      "left composer right" !important;
  }
  html:not(.showcase-stage-guest) body.page-ai .ai-desk[data-tv="on"]:not([data-expand="research"]):not([data-tv-size="full"]):not([data-stage="world"]):not([data-stage="brain"]):has(.ai-ws-panel[data-ws="library"].is-on),
  html:not(.showcase-stage-guest) body.page-ai .ai-desk[data-tv="on"]:not([data-expand="research"]):not([data-tv-size="full"]):not([data-stage="world"]):not([data-stage="brain"]):has(.ai-ws-panel[data-ws="teach"].is-on) {
    grid-template-rows: auto minmax(360px, 1fr) auto minmax(0, auto) auto !important;
    grid-template-areas:
      "left tv right"
      "left stage right"
      "left work right"
      "left stack right"
      "left composer right" !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: #090c14;
    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: auto;
    right: 0;
    z-index: 220;
    min-width: 0;
    width: min(72vw, 240px);
    max-width: min(calc(100vw - 16px), 240px);
    max-height: min(42vh, 280px);
    overflow-x: hidden;
    overflow-y: auto;
    padding: 4px;
    gap: 1px;
    box-sizing: border-box;
  }
  .ai-mobile-bar .llm-family-config {
    left: auto;
    right: 0;
    margin-right: 0;
    z-index: 221;
    min-width: 0;
    width: min(72vw, 240px);
    max-width: min(calc(100vw - 16px), 240px);
    max-height: min(34vh, 220px);
    overflow-x: hidden;
    overflow-y: auto;
    padding: 4px;
    box-sizing: border-box;
  }
  .ai-mobile-bar .llm-family-config::after { display: none; }
  .ai-mobile-bar .llm-family-row {
    padding: 4px 6px;
    gap: 4px;
    font-size: 11px;
    min-height: 0;
  }
  .ai-mobile-bar .llm-family-group {
    font-size: 9px;
    padding: 4px 6px 1px;
  }
  .ai-mobile-bar .llm-family-config label {
    font-size: 11px;
    padding: 2px 4px;
    gap: 6px;
  }
  .ai-mobile-bar .llm-family-config .llm-family-note {
    font-size: 10px;
    padding: 2px 4px;
  }
  .ai-mobile-bar .llm-family-config strong { font-size: 12px; }
  .ai-mobile-bar .llm-family-config .llm-family-use {
    min-height: 0;
    padding: 5px 8px;
    font-size: 11px;
  }
  .ai-mobile-bar .llm-family-click,
  .ai-mobile-bar .llm-family-click svg {
    width: 10px;
    height: 10px;
  }
  .ai-mobile-bar .ai-apps-menu {
    left: auto;
    right: 0;
    z-index: 220;
    overflow-y: auto;
    min-width: 0;
    width: min(92vw, 340px);
    max-width: min(92vw, 340px);
    padding: 4px;
    gap: 2px;
    max-height: min(56vh, 360px);
    border-radius: 6px;
  }
  /* Mobile-only: shrink AI Apps menu ~38px when disconnected (no connected apps). Width only. */
  .ai-mobile-bar .ai-apps-menu:has(.llm-family-status.is-disconnected):not(:has(.ai-apps-status.is-connected)) {
    width: min(calc(92vw - 76px), 264px);
    max-width: min(calc(92vw - 76px), 264px);
  }
  /* Mobile-only: connected state uses the same width as disconnected; content wraps instead of widening. */
  .ai-mobile-bar .ai-apps-menu:has(.ai-apps-status.is-connected) {
    width: min(calc(92vw - 76px), 264px);
    max-width: min(calc(100vw - 24px), 264px);
    box-sizing: border-box;
  }
  .ai-mobile-bar .ai-apps-menu .ai-apps-row { gap: 6px; padding: 4px 6px; min-width: 0; }
  .ai-mobile-bar .ai-apps-menu .ai-apps-row > div:first-child { min-width: 0; flex: 1 1 auto; overflow-wrap: anywhere; font-size: 12px; }
  .ai-mobile-bar .ai-apps-menu .ai-apps-status.is-connected { font-size: 11px; gap: 4px; }
  .ai-mobile-bar .ai-apps-menu .ai-apps-actions { flex-wrap: wrap; flex-shrink: 0; }
  .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(255, 138, 31, 0.08), transparent 42%),
    #060709;
  border: 1px solid rgba(255, 138, 31, 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: #ff8a1f;
  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: #f4f6fa;
  word-break: break-all;
}
.ai-monitor-task {
  margin: 6px 0 0;
  color: #8b8e93;
  font-size: 11px;
}
.ai-monitor-meta,
.ai-tv-meta,
.ai-world-hud-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  color: #8b8e93;
  font-size: 11px;
}
.ai-phase {
  border: 1px solid rgba(255, 138, 31, 0.35);
  color: #ff8a1f;
  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(255, 138, 31, 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(255, 138, 31, 0.05), transparent 46%),
    #060709;
}
.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: #060709;
}
.ai-monitor-standby,
.ai-monitor-fail {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 8px;
  text-align: center;
  padding: 20px;
  color: #e2d5c7;
}
.ai-monitor-standby span,
.ai-monitor-fail strong {
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 12px;
  color: #ff8a1f;
}
.ai-monitor-standby em {
  font-style: normal;
  color: #8b8e93;
  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: #ff8a1f;
}
.ai-monitor-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.ai-monitor-chips span {
  border: 1px solid rgba(255, 138, 31, 0.2);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 10px;
  color: #ff8a1f;
}
.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(255, 138, 31, 0.06), transparent 38%),
    #030406;
  border: 1px solid rgba(255, 138, 31, 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: #f4f6fa;
  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: #8b8e93;
}
.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(7, 8, 12, 0.72);
  border: 1px solid rgba(255, 138, 31, 0.12);
  backdrop-filter: blur(12px);
  color: #e9dfd4;
  font-size: 12px;
}
.ai-world-dock h3 {
  margin: 0 0 6px;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #ff8a1f;
}
.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(3, 4, 6, 0.88));
  color: #e9dfd4;
  font-size: 11px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.ai-world-strip span { color: #8b8e93; }
.ai-world-strip strong { color: #ff8a1f; font-weight: 650; }
.ai-world-feed-state {
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #ff8a1f;
  font-size: 11px;
}
.ai-world-findings {
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 138, 31, 0.16);
  border-radius: 10px;
  background: rgba(12, 14, 17, 0.8);
  position: relative;
  z-index: 2;
}
.ai-world-findings strong {
  color: #ff8a1f;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.ai-world-findings p {
  margin: 6px 0 0;
  max-height: 9.5em;
  overflow: auto;
  white-space: pre-wrap;
  font-size: 13px;
  line-height: 1.45;
  letter-spacing: 0;
  color: #e9dfd4;
}
.ai-ops-brain {
  grid-area: brain;
  display: none;
  position: relative;
  min-height: min(48vh, 520px);
  padding: 8px 12px 0;
  border-radius: 20px;
  background: #030305;
  border: 1px solid rgba(255, 138, 31, 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(7, 8, 12, 0.62);
  border: 1px solid rgba(255, 138, 31, 0.1);
  backdrop-filter: blur(12px);
  color: #e9dfd4;
  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: #8b8e93;
}
.ai-brain-stats strong,
.ai-brain-growth strong { color: #f4f6fa; 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: #e2d5c7;
  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(9, 10, 13, 0.78);
  border: 1px solid rgba(255, 138, 31, 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(255, 138, 31, 0.2);
  background: rgba(10, 12, 15, 0.78);
  color: #e2d5c7;
  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: #ff8a1f;
  border-color: #ff8a1f;
}
.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: #e2d5c7;
}
.ai-brain-empty strong {
  display: block;
  letter-spacing: 0.12em;
  font-size: 13px;
  color: #ff8a1f;
  margin-bottom: 8px;
}
.ai-brain-empty p {
  margin: 0;
  color: #8b8e93;
  font-size: 12px;
  line-height: 1.45;
}
.ai-brain-banner {
  top: 14px;
  letter-spacing: 0.14em;
  font-size: 11px;
  color: #ff8a1f;
  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(9, 10, 13, 0.88);
  border: 1px solid rgba(255, 138, 31, 0.22);
  color: #e9dfd4;
  font-size: 12px;
  pointer-events: none;
}
.ai-brain-hover.hidden { display: none; }
.ai-brain-hover strong { display: block; color: #f4f6fa; }
.ai-brain-hover span { color: #8b8e93; 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(9, 10, 13, 0.82);
  border: 1px solid rgba(255, 138, 31, 0.16);
  backdrop-filter: blur(12px);
  color: #e9dfd4;
  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: #8b8e93;
  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(255, 138, 31, 0.18);
  border-radius: 12px;
  background: #0e0f13;
}
.ai-trail h3 {
  margin: 0 0 8px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #ff8a1f;
}
.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: #8b8e93; 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 #202636;
  background: #080b13;
  color: #dbdfe7;
  border-radius: 8px;
  padding: 8px 12px;
  font: inherit;
}
.control-group .chart-asset-search::placeholder,
#chart-asset-search::placeholder { color: #798398; }
.control-group .chart-asset-search:focus,
#chart-asset-search:focus { outline: 1px solid rgba(255, 138, 31, 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: #0d111d;
    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 #0d111d;
  }
  body.page-charts .chart-toolbar #chart-quick-access {
    box-shadow: 0 0 0 10px #0d111d, 0 20px 56px rgba(0, 0, 0, 0.55);
  }
  body.page-charts .chart-toolbar #btn-chart-refresh {
    background: #222838;
  }
  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, 62, 67, 0.12), 0 2px 6px rgba(60, 62, 67, 0.08);
  }
  html[data-theme="light"] body.page-charts .chart-toolbar #btn-chart-refresh {
    background: #f4e6d7;
  }
}
.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: #0d111d;
  border: 1px solid #323c58;
  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: #0d121f;
  color: #ffbe80;
  box-shadow: inset 0 0 0 1px #293144;
  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: #0d111d;
  border: 1px solid #323c58;
  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: #ffbe80;
  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: #0d121f; }
.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, 62, 67, 0.12), 0 2px 6px rgba(60, 62, 67, 0.08);
}
html[data-theme="light"] .chart-quick-btn {
  background: #ffffff;
  color: #c2410c;
  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, 62, 67, 0.12), 0 2px 6px rgba(60, 62, 67, 0.08);
}
html[data-theme="light"] .chart-quick-pick { color: #c2410c; }
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, #232c3f); 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 {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  max-width: 420px;
  background: #080b13;
  border: 1px solid #202636;
  color: #dbdfe7;
  border-radius: 8px;
  padding: 8px 12px;
  font: inherit;
  font-size: 13px;
}
body.page-ai .ai-expert-training .xt-connect .mini-input {
  box-sizing: border-box;
  width: auto;
  min-width: 0;
  max-width: none;
  flex: 0 0 auto;
  background: #080b13;
  border: 1px solid #202636;
  color: #dbdfe7;
  border-radius: 8px;
  padding: 5px 8px;
  height: 32px;
  font: inherit;
  font-size: 12px;
}
body.page-ai .ai-expert-training .xt-connect .xt-secret {
  width: 124px;
  min-width: 108px;
  max-width: 124px;
  flex: 0 0 124px;
}
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: #798398; }
body.page-ai .lib-asset-search:focus,
body.page-ai .ai-expert-training .xt-connect .mini-input:focus {
  outline: 1px solid rgba(255, 138, 31, 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, #98a2b3); 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(194, 65, 12, 0.35);
}
.chart-search-hits {
  position: absolute;
  z-index: 20;
  background: #171a21;
  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(194, 65, 12, 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; }
.home-help { position: relative; }
.home-help-pop {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 95;
  display: none;
  flex-direction: column;
  gap: 2px;
  min-width: 180px;
  padding: 6px;
  background: #080b13;
  border: 1px solid #202636;
  border-radius: 8px;
}
.home-help-pop:not(.hidden) { display: flex; }
.home-help-pop button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  color: #ffbe80;
  border: 0;
  border-radius: 6px;
  padding: 8px 10px;
  cursor: pointer;
}
.home-help-pop button:hover,
.home-help-pop button:focus { background: #0d121f; }
html[data-theme="light"] .home-help-pop {
  background: #f8f9fa;
  border-color: #dadce0;
}
html[data-theme="light"] .home-help-pop button { color: #c2410c; }
html[data-theme="light"] .home-help-pop button:hover,
html[data-theme="light"] .home-help-pop button:focus { background: rgba(194, 65, 12, 0.08); }
button#btn-news-window.ok {
  background: #188a52;
  border-color: #188a52;
  color: #fff;
}
button#btn-news-window.err {
  background: #d02c31;
  border-color: #d02c31;
  color: #fff;
}
.news-window-badge { margin-left: 6px; font-weight: 700; letter-spacing: 0.04em; }
body.page-news #news-delay,
body.page-news #news-pause { display: block; margin: 2px 0 18px; }
body.page-news .news-filters { margin: 6px 0 18px; flex-wrap: wrap; gap: 12px 16px; }
body.page-news .news-filters .tab {
  background: rgba(255, 138, 31, 0.14);
  border: 1px solid rgba(255, 138, 31, 0.45);
  color: #ff8a1f;
  border-radius: 5px;
  padding: 6px 12px;
  font-size: 12px;
}
body.page-news .news-filters .tab.active {
  background: #ff8a1f;
  border-color: #ff8a1f;
  color: #090c14;
}
html[data-theme="light"] body.page-news .news-filters .tab {
  background: rgba(255, 138, 31, 0.16);
  border: 1px solid rgba(194, 65, 12, 0.35);
  color: #c2410c;
}
html[data-theme="light"] body.page-news .news-filters .tab.active {
  background: #c2410c;
  border-color: #c2410c;
  color: #ffffff;
}
body.page-news .news-list { display: grid; gap: 10px; }
@media (min-width: 1100px) {
  body.page-news .news-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: start;
  }
}
body.page-news .news-card { cursor: pointer; }
body.page-news .news-card h2 { font-size: 16px; margin: 8px 0 4px; font-weight: 600; }
body.page-news .news-sum,
body.page-news .news-macro { margin: 0; color: var(--muted); }
body.page-news .news-top,
body.page-news .news-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
body.page-news .news-top time { margin-left: auto; color: var(--muted); font-size: 12px; }
body.page-news .news-card.impact-high { border-color: rgba(229, 72, 77, 0.65); }
body.page-news .news-card.impact-medium { border-color: rgba(240, 166, 58, 0.65); }
body.page-news .news-open { margin-top: 8px; }
body.page-news .news-open a { color: #ff8a1f; }
.etoro-venue {
  position: relative;
  z-index: 1;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid #76839c;
  border-radius: 12px;
  background: #080b13;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 138, 31, 0.22);
}
html[data-theme="light"] .etoro-venue {
  background: #f8f0e8;
  border-color: #f4a44f;
  box-shadow: 0 8px 18px rgba(60, 62, 67, 0.14), inset 0 1px 0 #ffffff;
}
.etoro-venue.is-live {
  border-color: rgba(229, 72, 77, 0.85);
  background: #3a2226;
}
html[data-theme="light"] .etoro-venue.is-live {
  background: #fdecea;
  border-color: rgba(208, 44, 49, 0.55);
}
.etoro-kicker {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.etoro-state {
  margin-top: 4px;
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
}
.etoro-venue.is-live .etoro-kicker,
.etoro-venue.is-live .etoro-state { color: var(--red); }
.etoro-note { margin: 6px 0 0; color: var(--text); font-size: 13px; }
.etoro-note a,
.ap-alerts a {
  color: #4da3ff;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.etoro-note a:hover,
.ap-alerts a:hover { color: #7cbcff; }
html[data-theme="light"] .etoro-note a,
html[data-theme="light"] .ap-alerts a { color: #1a73e8; }
html[data-theme="light"] .etoro-note a:hover,
html[data-theme="light"] .ap-alerts a:hover { color: #1557b0; }
.route-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 8px 0; }
.route-chips-k { font-size: 11px; color: var(--muted); margin-right: 2px; }
.route-chip { cursor: pointer; }
.route-chip:disabled { opacity: 0.45; cursor: default; }
.route-chip[aria-pressed="true"]::before { content: "✓ "; }
.route-chip.busy { pointer-events: none; opacity: 0.85; }
.route-chip.busy .btn-spinner,
.broker-spin {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 6px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  vertical-align: -2px;
  animation: btn-spin 0.7s linear infinite;
}
.route-chip.busy[aria-pressed="true"]::before { content: none; }
.broker-steps { margin: 8px 0 4px; padding-left: 18px; font-size: 12px; color: var(--muted); }
.broker-steps li { margin: 2px 0; }
.broker-steps b { color: var(--text); }
.broker-card {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.broker-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.broker-card-name {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-size: 15px;
}
.broker-card-logo {
  display: block;
  height: 44px;
  width: auto;
  max-width: 176px;
  object-fit: contain;
  object-position: center;
  border-radius: 4px;
  background: transparent;
}
html[data-theme="light"] .broker-card-logo { background: transparent; }
html[data-theme="light"] .broker-card-logo--bybit { content: url("/img/brokers/bybit-black-fit.PNG"); }
.broker-card-logo--binance {
  height: 52px;
  max-width: 210px;
}

.broker-msg { margin: 8px 0 0; font-size: 13px; min-height: 0; }
.broker-msg:empty { display: none; }
.broker-msg.is-busy { color: var(--muted); }
.broker-msg.is-ok { color: var(--green); }
.broker-msg.is-warn { color: var(--amber); }
.broker-msg.is-error { color: var(--red); }
.broker-balance { margin-top: 10px; }
.broker-balance-k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.broker-balance-v { font-size: 22px; font-weight: 800; font-family: var(--mono); }
.broker-balance-v small { font-size: 12px; font-weight: 700; color: var(--muted); }
.broker-balance-sub { font-size: 12px; color: var(--muted); }
.broker-balance.is-empty { font-size: 12px; color: var(--muted); }
.broker-balance.is-error { font-size: 12px; color: var(--amber); }
.broker-step {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.broker-step-n {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid currentColor;
  font-size: 11px;
}
.broker-key {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
.broker-key-title { font-size: 12px; font-weight: 700; min-width: 64px; }
.broker-key-actions { display: flex; gap: 6px; margin-left: auto; }
.broker-key-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 8px;
  align-items: center;
}
.broker-key-form.hidden { display: none; }
.broker-key-form .broker-key-title { grid-column: 1 / -1; }
.broker-key-form input {
  width: 100%;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 10px;
}
.broker-mode.is-locked { opacity: 0.6; border-style: dashed; }
.broker-mode.is-off[aria-pressed="true"] { border-color: var(--red); color: var(--red); }
@media (max-width: 640px) {
  .broker-key-form { grid-template-columns: 1fr; }
  .broker-key-actions { margin-left: 0; }
}
.account-equity { margin-top: 12px; }
.acct-eq-title { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.acct-eq-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-top: 6px; }
.acct-eq {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.acct-eq.is-live { border-color: rgba(229, 72, 77, 0.7); }
.acct-eq-k { font-size: 12px; font-weight: 700; }
.acct-eq-v { font-size: 16px; font-weight: 800; font-family: var(--mono); }
.acct-eq-v small { font-size: 11px; color: var(--muted); }
.acct-eq-sub { font-size: 11px; color: var(--muted); }
.au-source { margin: 0 0 8px; }
.etoro-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.etoro-account {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 10px;
  align-items: center;
}
.etoro-account-name,
.etoro-account input[data-etoro-api] { grid-column: 1 / -1; }
.etoro-account-name { font-size: 12px; font-weight: 700; }
.etoro-account input {
  width: 100%;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 10px;
}
.etoro-account .etoro-mask { grid-column: 1; }
.etoro-mask { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.wa-alerts {
  margin-top: 12px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}
.wa-alerts summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
}
.alerts-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.alerts-title .unread-badge { margin-left: 0; vertical-align: 0; }
.alerts-tg {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 6px;
  color: #2AABEE;
  text-decoration: none;
  flex: none;
}
.alerts-tg svg { width: 16px; height: 16px; display: block; }
.alerts-tg:hover { background: rgba(42, 171, 238, 0.16); }
.alerts-tg.hidden { display: none !important; }
.wa-summary-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.wa-brand {
  width: 15px;
  height: 15px;
  flex: none;
  color: #25D366;
  pointer-events: none;
}
.wa-alerts summary::-webkit-details-marker { display: none; }
.wa-alerts summary::after {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  margin-top: -4px;
  flex: none;
}
.wa-alerts[open] summary::after {
  transform: rotate(-135deg);
  margin-top: 4px;
}
#wa-numbers { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.wa-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 6px 8px 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--accent-border);
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 13px;
}
.wa-chip-x {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
}
.wa-row { display: flex; gap: 8px; margin-top: 8px; align-items: center; }
.wa-row input {
  flex: 1 1 160px;
  width: auto;
  max-width: 240px;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 10px;
}
.wa-opt { display: flex; gap: 8px; align-items: center; margin: 10px 0; font-size: 13px; }
.wa-actions { display: flex; gap: 8px; flex-wrap: wrap; }
#wa-note { display: block; margin: 14px 0 0; }
#wa-add { margin-top: 8px; min-width: 36px; }
.wa-qr { display: block; width: 180px; height: 180px; margin-top: 10px; background: #fff; border-radius: 8px; }
.wa-qr.hidden { display: none; }



/* eToro Agent Portfolio — dropdown inside eToro broker card (WhatsApp Alerts style) */
.ap-alerts {
  margin-top: 12px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}
.ap-alerts summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
}
.ap-summary-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.ap-alerts summary::-webkit-details-marker { display: none; }
.ap-alerts summary::after {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  margin-top: -4px;
  flex: none;
}
.ap-alerts[open] summary::after {
  transform: rotate(-135deg);
  margin-top: 4px;
}
.ap-summary-label .chip {
  flex: none;
}
.ap-alerts .broker-msg { margin-top: 10px; }
.ap-alerts .ap-confirm-row {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
  min-width: 0;
}
.ap-alerts .ap-confirm-row input[type="checkbox"],
.broker-key-form .ap-confirm-row input[type="checkbox"] {
  width: auto;
  min-width: 16px;
  max-width: 16px;
  height: 16px;
  margin: 0;
  flex: none;
  align-self: center;
  padding: 0;
}
.ap-alerts .ap-confirm-row .ap-confirm-text {
  flex: 1 1 auto;
  min-width: 0;
  white-space: normal;
}
.ap-once-token {
  margin: 8px 0 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--red) 45%, transparent);
  background: color-mix(in srgb, var(--red) 10%, transparent);
}
.ap-once-value {
  display: block;
  margin: 6px 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--text) 6%, transparent);
  font-size: 12px;
  word-break: break-all;
  user-select: all;
}
.ap-create-form input[type="number"] {
  min-width: 0;
}

body.page-news #live-news { margin: 0 0 18px; padding: 14px; }
body.page-news #live-news h2 { font-size: 16px; margin: 0; font-weight: 600; }
body.page-news #live-news-status { margin-top: 14px; }
html[data-theme="light"] body.page-news #live-news { background: #ffffff; }
body.page-news #live-news .btn { margin-left: auto; }
body.page-news #live-news-summary { margin-top: 8px; }
body.page-news #live-news-events {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-top: 8px;
}
body.page-news #live-news-events > .news-meta {
  margin: 0;
  display: block; /* override flex from .news-meta so · separators stay tight */
}
body.page-news #live-news-events .live-sent--bull { color: var(--green); }
body.page-news #live-news-events .live-sent--bear { color: var(--red); }
@media (max-width: 640px) {
  body.page-news #live-news-events {
    grid-template-columns: minmax(0, 1fr);
  }
}

body.page-news #live-news .live-news-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
body.page-news #live-news .live-news-actions .btn { margin-left: 0; }
body.page-news #live-news .live-news-actions { flex-wrap: wrap; }
body.page-news #live-news .live-source.active {
  background: var(--card);
  border-color: var(--border);
  color: var(--text);
}
#live-news-collapse { display: none; background: var(--amber); }
#live-news-collapse:focus-visible { outline-color: var(--amber); }
html[data-theme="light"] #live-news-collapse svg { stroke: #111; }
#live-news.is-expanded #live-news-expand { display: none; }
#live-news.is-expanded #live-news-collapse { display: inline-flex; }
body.page-news.is-live-expanded { overflow: hidden; }
html:has(body.page-news.is-live-expanded) { overflow: hidden; }
#live-news.is-expanded {
  position: fixed;
  inset: 12px;
  z-index: 400;
  margin: 0;
  display: flex;
  flex-direction: column;
  width: auto;
  height: calc(100dvh - 24px);
  max-height: calc(100dvh - 24px);
  min-height: 0;
  overflow: hidden;
  background: #0d111d;
  border: 1px solid #323c58;
  box-shadow: 0 20px 56px rgba(0, 0, 0, 0.55);
}
body.page-news #live-news-player,
body.page-news #live-news-embed { width: 100%; max-height: 360px; margin-top: 10px; background: #000; border-radius: 8px; }
body.page-news #live-news-embed { height: 360px; border: 0; display: block; }
body.page-news a#live-news-embed.live-news-open {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 220px;
  color: #f4f5f8;
  font-weight: 650;
  text-decoration: none;
  background: #111 url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64"/>') center/cover;
}
body.page-news a#live-news-embed.live-news-open[hidden] { display: none; }

body.page-news #live-news-embed[hidden] { display: none; }
#live-news.is-expanded #live-news-player:not([hidden]),
#live-news.is-expanded #live-news-embed:not([hidden]) {
  display: block;
  flex: 1 1 auto;
  width: 100%;
  max-height: none;
  min-height: 0;
  height: auto;
  object-fit: contain;
}
#live-news.is-expanded #live-news-player[hidden],
#live-news.is-expanded #live-news-embed[hidden],
#live-news.is-embed #live-news-player,
#live-news:not(.is-embed) #live-news-embed {
  display: none;
}
body.page-news #live-news-impact { margin-top: 8px; }
@media (max-width: 640px) {
  #live-news.is-expanded {
    inset: 0;
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }
}
html[data-theme="light"] #live-news.is-expanded {
  background: #ffffff;
  border-color: var(--border, #d9d3c7);
  box-shadow: 0 20px 56px rgba(0, 0, 0, 0.18);
}
/* Research findings panel links: match Desk chat link color */
.ai-world-findings a,
.ai-world-findings a:visited,
.ai-world-findings a:hover {
  color: #8ecbff;
  text-decoration: underline;
  text-underline-offset: 2px;
}
html[data-theme="light"] .ai-world-findings a,
html[data-theme="light"] .ai-world-findings a:visited,
html[data-theme="light"] .ai-world-findings a:hover {
  color: #3d8fd4;
}


/* SoSoValue ETF flows card on World Monitor (Markets) */
.ai-world-dock#world-etf .world-etf-connect {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.35rem 0 0.15rem;
}
.ai-world-dock#world-etf .world-etf-connect b {
  font-size: 0.78rem;
  letter-spacing: 0.02em;
}
.ai-world-dock#world-etf .world-etf-connect code {
  font-size: 0.72rem;
  padding: 0.05rem 0.25rem;
  border-radius: 3px;
  background: color-mix(in srgb, var(--chip-bg, #1a1f2b) 80%, transparent);
}
.ai-world-dock#world-etf .world-etf-link {
  font-size: 0.72rem;
  color: var(--accent, #6ea8fe);
  text-decoration: none;
  width: fit-content;
}
.ai-world-dock#world-etf .world-etf-link:hover { text-decoration: underline; }
html[data-theme="light"] .ai-world-dock#world-etf .world-etf-connect code {
  background: color-mix(in srgb, #e8ecf4 90%, #fff);
}
@media (max-width: 720px) {
  .ai-world-dock#world-etf { font-size: 0.9em; }
}
