/* Last-layer integration for legacy modules loaded within page bodies. */
:root {
  --bg: #0b1114;
  --card: #121c21;
  --field: #19262c;
  --line: #26363e;
  --text: #edf5f5;
  --muted: #90a6ae;
  --accent: #63e3ca;
  --accent-ink: #06251f;
  --positive: #50d6aa;
  --negative: #f58691;
  --trade-ink: #06251f;
}
:root[data-theme="light"] {
  --bg: #f3f7f7;
  --card: #fff;
  --field: #edf3f4;
  --line: #dce6e8;
  --text: #112a32;
  --muted: #607a83;
  --accent: #0c806f;
  --accent-ink: #fff;
  --positive: #087d61;
  --negative: #c83f57;
  --trade-ink: #fff;
}
#siteCopilotFab {
  background: var(--accent) !important;
  color: var(--accent-ink) !important;
  border: 1px solid color-mix(in srgb, var(--accent) 65%, var(--line)) !important;
  right: 24px !important;
  bottom: 24px !important;
  padding: 12px 18px !important;
  border-radius: 12px !important;
  font-size: 13px !important;
  box-shadow: var(--shadow) !important;
}
#siteCopilotDrawer {
  background: var(--card) !important;
  color: var(--text) !important;
  border: 1px solid var(--line) !important;
  border-radius: 18px !important;
  box-shadow: var(--shadow) !important;
  max-width: calc(100vw - 32px) !important;
}
#siteCopilotDrawer input,
#siteCopilotDrawer select {
  background: var(--field) !important;
  color: var(--text) !important;
  border-color: var(--line) !important;
}
#siteCopilotDrawer [style*="background:#"],
#siteCopilotDrawer [style*="background: #"] {
  background: var(--field) !important;
}
#siteCopilotDrawer [style*="color:#"],
#siteCopilotDrawer [style*="color: #"] {
  color: var(--text) !important;
}
#siteCopilotDrawer .button.primary {
  background: var(--accent) !important;
  color: var(--accent-ink) !important;
}
.governance .card,
.governance .form-card,
.governance .help-card,
.governance .legal-card {
  background: var(--card);
  border-color: var(--line);
  box-shadow: none;
}
@media (max-width: 800px) {
  .header .public-nav:not(.navigation-open) {
    display: none !important;
  }
  .header .public-nav.navigation-open {
    display: flex !important;
    grid-template-columns: none !important;
  }
  .header .public-nav a {
    justify-content: flex-start !important;
  }
  .app-shell #siteCopilotFab {
    bottom: 88px !important;
    right: 14px !important;
  }
  .app-shell #siteCopilotDrawer {
    inset: 84px 10px 150px !important;
    height: auto !important;
    width: auto !important;
    max-height: none !important;
    max-width: none !important;
  }
  .public-shell #siteCopilotFab {
    right: 14px !important;
    bottom: 16px !important;
  }
  .public-shell #siteCopilotDrawer {
    inset: 84px 10px 76px !important;
    max-width: none !important;
    width: auto !important;
    height: auto !important;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
  }
}

/* Navigation integration with legacy header breakpoints. */
.header .public-nav {
  order: 0;
  width: auto;
  flex-shrink: 0;
}
.app-sidebar {
  overflow-y: auto;
  overscroll-behavior: contain;
}
.app-sidebar > .wordmark,
.app-sidebar > .sidebar-caption,
.app-sidebar > .sidebar-nav,
.sidebar-bottom {
  flex-shrink: 0;
}
@media (max-width: 800px) {
  .app-sidebar {
    visibility: hidden;
    pointer-events: none;
  }
  .app-sidebar.navigation-open {
    visibility: visible;
    pointer-events: auto;
  }
  .header .public-nav.navigation-open {
    width: auto;
  }
}
/* Keep shared controls consistent when a feature reloads the legacy UI sheet. */
#theme-toggle .theme-sun {
  display: block !important;
}
#theme-toggle .theme-moon {
  display: none !important;
}
:root[data-theme="light"] #theme-toggle .theme-sun {
  display: none !important;
}
:root[data-theme="light"] #theme-toggle .theme-moon {
  display: block !important;
}
.form-card .password-reveal {
  width: 62px;
  right: 6px;
  font-size: 10px;
}
.form-card .password-field input {
  padding-right: 73px !important;
}
#workspace #chartMarketSwitch,
#workspace #chartQuoteSwitch,
#workspace #chartSymbolSelector {
  display: none !important;
}
#workspace .okx-ticket-market-context {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  font-size: 12px;
  min-width: 0;
}
#workspace .okx-ticket-market-context__label { color: var(--muted); }
#workspace .okx-ticket-market-context strong { color: var(--text); white-space: nowrap; }
#workspace .okx-ticket-market-context p {
  min-width: 0;
  margin: 0;
  color: var(--muted);
  line-height: 1.4;
}
@media (max-width: 640px) {
  #workspace .okx-ticket-market-context {
    grid-template-columns: 1fr auto;
    gap: 4px 8px;
  }
  #workspace .okx-ticket-market-context p { grid-column: 1 / -1; }
}
#workspace .okx-cust-header {
  padding-top: 13px;
  padding-bottom: 13px;
}
@media (max-width: 800px) {
  .app-shell .header-actions .account-link {
    display: flex !important;
  }
  .app-shell .header-actions .language-switch {
    margin-left: auto;
  }
  #workspace .workspace-tabs {
    overflow-x: auto !important;
    overflow-y: hidden !important;
    white-space: nowrap !important;
    scrollbar-width: thin;
  }
  #workspace .workspace-tabs button {
    white-space: nowrap !important;
    flex-shrink: 0;
  }
  .app-shell .header-actions {
    gap: 10px;
  }
}
/* Neutral analytical panels must adapt with the rest of the workspace. */
#workspace :is(#okxBotAdvisorCard, #okxOrderPnlPreviewCard) {
  background: var(--field) !important;
  border-color: var(--line) !important;
  border-radius: 11px !important;
  padding: 14px !important;
}
#workspace #okxBotAdvisorCard [style*="background:rgba(15,23,42"],
#workspace #okxBotAdvisorCard [style*="background:rgba(30,41,59"] {
  background: var(--card) !important;
}
#workspace #okxBotAdvisorMarketFit {
  color: var(--accent) !important;
  background: var(--accent-soft) !important;
  border: 1px solid var(--line);
}
#workspace .okx-advisor-pill {
  color: var(--muted) !important;
  background: transparent !important;
  min-height: 35px;
}
#workspace .okx-advisor-pill.active {
  color: var(--accent) !important;
  background: var(--card) !important;
}
#workspace #btnToggleAutotrade {
  color: var(--accent-ink) !important;
  min-height: 36px;
  border-radius: 8px !important;
}

#workspace #advRecBreakeven {
  color: var(--accent) !important;
}
:root[data-theme="light"] #workspace #advRecTp {
  color: var(--positive) !important;
}
:root[data-theme="light"] #workspace #advRecSl {
  color: var(--negative) !important;
}
.account-workspace .copilot-intro {
  background: var(--card);
  border: 1px solid var(--line);
  padding: 30px;
  gap: 40px;
}
.account-workspace .copilot-intro h2 {
  font-size: 31px;
  line-height: 1.25;
  letter-spacing: -1px;
}
.account-workspace .copilot-intro-preview {
  background: var(--field);
  border-color: var(--line);
}
.journal-entry-card {
  margin-bottom: 24px;
}
.journal-entry-card[open] > summary {
  margin-bottom: 20px;
}
.journal-entry-card[open] > summary > span {
  transform: rotate(45deg);
}
.journal-empty {
  padding: 55px 24px;
}
.journal-empty-icon {
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  margin: 0 auto 25px;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--accent);
  background: var(--accent-soft);
}
.journal-empty-icon .ui-icon {
  width: 27px;
  height: 27px;
}
.journal-empty > .eyebrow {
  margin-bottom: 13px;
  font-size: 10px;
}
.journal-empty h2 {
  font-size: 25px;
}
.journal-empty > p:not(.eyebrow) {
  font-size: 14px;
  max-width: 390px;
}
.journal-empty > .button {
  margin-top: 24px;
}
.table-card {
  min-width: 0;
}
.table-scroll {
  width: 100%;
  min-width: 0;
  overflow-x: auto;
}
@media (max-width: 600px) {
  .journal-empty {
    padding: 36px 22px;
  }
  .journal-empty h2 {
    font-size: 22px;
  }
  .journal-empty > p:not(.eyebrow) {
    font-size: 13px;
  }
  .journal-entry-card summary {
    font-size: 14px;
  }
}
#siteCopilotFab .copilot-mark {
  background: transparent;
  border: 0;
  box-shadow: none;
  color: inherit;
}
@media (max-width: 800px) {
  .mobile-dock {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
  .mobile-dock button {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 5px;
    min-height: 53px;
    font-size: 10px;
    padding: 6px 2px;
    border: 0;
    background: transparent;
    border-radius: 9px;
    line-height: 1.4;
    color: var(--muted);
  }
  .mobile-dock button:hover {
    color: var(--accent);
    background: var(--accent-soft);
  }
  .app-shell #siteCopilotFab {
    display: none !important;
  }
  .app-shell #siteCopilotDrawer {
    inset: 84px 10px 82px !important;
  }
  .public-shell #siteCopilotFab {
    padding: 11px !important;
    width: 46px;
    height: 46px;
    justify-content: center;
  }
  .public-shell #siteCopilotFab > span:last-child {
    display: none;
  }
  .public-shell #siteCopilotFab .copilot-mark {
    width: 22px;
    height: 22px;
  }
}

/* Leave room for the floating Copilot button so it never covers the footer links. */
@media (min-width: 900px) {
  .site-footer {
    padding-bottom: 84px;
  }
}
