/* BrainOff workspace header controls — shared, compact surface system. */
#appShell .top-actions {
  --workspace-header-control-height: 44px;
  align-items: center;
  gap: 6px;
}

#appShell .top-actions :is(.currency-picker-button, #updatedAt, #refreshBtn) {
  min-height: var(--workspace-header-control-height);
  border: 1px solid var(--workspace-line);
  border-radius: 8px;
  background: var(--workspace-surface);
  box-shadow: none;
}

#appShell .top-actions .currency-picker-button {
  height: var(--workspace-header-control-height);
  padding: 6px 10px;
  border-color: var(--workspace-line-strong);
}

#appShell .sidebar-status {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 3px;
}

#appShell .sidebar-state-pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: start;
  gap: 12px;
}

#appShell .sidebar-state-pair :is(#modeBadge, #apiBadge) {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 6px;
  min-width: 0;
  min-height: 20px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #b7c8bf;
  font: 500 11px/1.5 var(--workspace-font);
  white-space: normal;
  text-align: left;
}

#appShell .sidebar-state-pair :is(#modeBadge, #apiBadge)::before {
  content: "";
  width: 5px;
  height: 5px;
  flex: 0 0 5px;
  margin-top: 6px;
  border-radius: 50%;
  background: currentColor;
}

#appShell .sidebar-state-pair :is(#modeBadge, #apiBadge).good { color: #a6d3b9; }
#appShell .sidebar-state-pair :is(#modeBadge, #apiBadge).warn { color: #d7bf89; }
#appShell .sidebar-state-pair :is(#modeBadge, #apiBadge):is(.bad, .danger) { color: #e3a29b; }

#appShell .sidebar-status #logoutBtn {
  justify-self: end;
}


#appShell .top-actions #updatedAt {
  display: inline-flex;
  align-items: center;
  align-self: center;
  height: var(--workspace-header-control-height);
  padding: 6px 11px;
  color: var(--workspace-muted);
  font-family: var(--workspace-font);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  line-height: 1.25;
  white-space: nowrap;
}

#appShell .top-actions #refreshBtn {
  display: inline-grid;
  place-items: center;
  align-self: center;
  flex: 0 0 var(--workspace-header-control-height);
  width: var(--workspace-header-control-height);
  height: var(--workspace-header-control-height);
  padding: 0;
  color: var(--workspace-ink);
  font: inherit;
  font-size: 18px;
  line-height: 1;
}

#appShell .top-actions #refreshBtn:hover:not(:disabled) {
  border-color: var(--workspace-line-strong);
  background: var(--workspace-soft);
}

#appShell .top-actions #refreshBtn:disabled {
  cursor: not-allowed;
  opacity: .5;
}

#appShell #refreshBtn svg { width: 18px; height: 18px; }

#appShell .top-actions .currency-picker-menu {
  z-index: 70;
}

#appShell .mobile-updated { display: none; }
#appShell .top-actions #currencyPicker { display: none; }

#appShell .capital-card-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-width: 0;
  min-height: 20px;
  gap: 6px;
  color: var(--workspace-muted);
  font: 500 13px/1.45 var(--workspace-font);
}
#appShell .capital-card-heading > span { align-self: center; }
#appShell .capital-card-heading > span:first-child { font: inherit; }

@media (max-width: 860px) {
  #appShell {
    --workspace-mobile-toolbar-height: 56px;
    --workspace-mobile-toolbar-top: env(safe-area-inset-top, 0px);
    --workspace-mobile-gutter: 16px;
  }
  html:has(#appShell:not([hidden])) {
    scroll-padding-top: calc(56px + env(safe-area-inset-top, 0px) + 12px);
  }
  #appShell .main {
    padding-top: calc(var(--workspace-mobile-toolbar-height) + var(--workspace-mobile-toolbar-top));
    padding-left: max(var(--workspace-mobile-gutter), env(safe-area-inset-left, 0px));
    padding-right: max(var(--workspace-mobile-gutter), env(safe-area-inset-right, 0px));
  }
  #appShell .topbar { width: auto; max-width: none; gap: 0; padding-bottom: 16px; margin-bottom: 16px; }
  #appShell .topbar { padding-top: 14px; }
  #appShell .topbar::before {
    content: "";
    position: fixed;
    z-index: 1;
    inset: 0 0 auto;
    height: calc(var(--workspace-mobile-toolbar-height) + var(--workspace-mobile-toolbar-top));
    border-bottom: 1px solid var(--workspace-line);
    background: rgb(244 243 238 / 96%);
    backdrop-filter: blur(12px);
    pointer-events: none;
  }
  #appShell .topbar-heading { grid-template-columns: minmax(0, 1fr); }
  #appShell .topbar-heading :is(.eyebrow, .page-title-row) { padding-right: 0; }
  #appShell .mobile-menu-btn {
    position: fixed;
    z-index: 2;
    top: calc(var(--workspace-mobile-toolbar-top) + 6px);
    left: max(12px, env(safe-area-inset-left, 0px));
  }
  #appShell .top-actions {
    position: fixed;
    z-index: 2;
    top: calc(var(--workspace-mobile-toolbar-top) + 6px);
    right: max(12px, env(safe-area-inset-right, 0px));
    display: block;
    width: 44px;
    height: 44px;
    margin: 0;
  }
  #appShell .top-actions #updatedAt {
    position: absolute;
    display: block;
    width: 1px;
    height: 1px;
    min-height: 0;
    padding: 0;
    margin: -1px;
    border: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  #appShell #updatedAtFull { display: inline; }
  #appShell .mobile-updated { display: none; }
  #appShell .top-actions #refreshBtn {
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
    border: 0;
    background: transparent;
    color: var(--workspace-muted);
    font-size: 18px;
  }
  #appShell .capital-card-heading { font-size: 13px; gap: 4px; }
  #appShell .capital-card-heading > span:first-child { min-width: 0; }
  #appShell .capital-card-heading:lang(zh) > span:first-child { white-space: nowrap; }
  #appShell .sidebar {
    --workspace-sidebar-left: max(16px, env(safe-area-inset-left, 0px));
    padding-top: 0;
    padding-left: var(--workspace-sidebar-left);
    scroll-padding-top: calc(72px + env(safe-area-inset-top, 0px));
  }
  #appShell .sidebar > .brand {
    position: sticky;
    top: 0;
    z-index: 2;
    min-height: calc(72px + env(safe-area-inset-top, 0px));
    margin-left: calc(-1 * var(--workspace-sidebar-left));
    margin-right: -16px;
    padding: calc(18px + env(safe-area-inset-top, 0px)) 24px 0 calc(var(--workspace-sidebar-left) + 8px);
    background: var(--workspace-green);
  }
}

/* The existing currency hooks are shared by desktop, mobile and the sidebar. */
  #appShell .mobile-funding-picker {
    display: inline-flex;
    position: relative;
    flex: 0 0 60px;
    width: 60px;
    height: 44px;
    margin-block: -8px;
    align-items: center;
    color: var(--workspace-ink);
  }
  #appShell .mobile-funding-picker::before {
    content: attr(data-currency);
    position: absolute;
    display: flex;
    align-items: center;
    padding-left: 7px;
    inset: 7px 0;
    border: 1px solid var(--workspace-line-strong);
    border-radius: 6px;
    background: rgb(252 252 249 / 55%);
    font: 500 12px/1 var(--workspace-font);
    pointer-events: none;
  }
  #appShell .mobile-funding-picker::after {
    content: "";
    position: absolute;
    right: 8px;
    width: 5px;
    height: 5px;
    margin-top: -3px;
    border-right: 1px solid currentColor;
    border-bottom: 1px solid currentColor;
    transform: rotate(45deg);
    pointer-events: none;
  }
  #appShell .mobile-funding-picker select {
    appearance: none;
    position: relative;
    z-index: 1;
    display: block;
    opacity: 0;
    width: 100%;
    min-width: 0;
    height: 44px;
    min-height: 44px;
    padding: 0 19px 0 7px;
    margin: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    box-shadow: none;
    color: inherit;
    font: 500 16px/1 var(--workspace-font);
    cursor: pointer;
  }
  #appShell .mobile-funding-picker:focus-within::before { outline: 2px solid var(--workspace-mint-deep); outline-offset: 1px; }
  #appShell .mobile-funding-picker option { background: var(--workspace-surface); color: var(--workspace-ink); }

  /* Match the card label's line box while retaining a full touch target. */
  #appShell .capital-card-heading .mobile-funding-picker {
    flex-basis: 64px;
    width: 64px;
    height: 28px;
    margin: 0;
    font: inherit;
    color: #355746;
  }
  #appShell .capital-card-heading .mobile-funding-picker::before {
    inset: 0;
    border-color: #adc2b3;
    background: #dfe9df;
    font: inherit;
  }
  #appShell .capital-card-heading .mobile-funding-picker::after {
    top: 50%;
    margin-top: -4px;
  }
  #appShell .capital-card-heading .mobile-funding-picker select {
    position: absolute;
    top: -8px;
    left: 0;
  }
  #appShell .nav-currency-row { display: flex; align-items: center; gap: 4px; }
  #appShell .nav-currency-row > .nav-item { flex: 1; min-width: 0; }
  #appShell .mobile-funding-picker-sidebar { margin: 0 8px 0 0; color: #d5e4d7; }
  #appShell .mobile-funding-picker-sidebar::before { border-color: #476052; background: #1d3328; }

@media (min-width: 861px) {
  #appShell .capital-card-heading { justify-content: flex-start; gap: 10px; }
  #appShell .capital-card-heading > span:first-child { min-width: 0; }
  #appShell .capital-card-heading .mobile-funding-picker { margin-block: -4px; }
}

@media (max-width: 420px) {
  #appShell { --workspace-mobile-gutter: 12px; }
}

@media (max-width: 360px) {
  #appShell .capital-card-heading { font-size: 12px; }
  #appShell .capital-card-heading .mobile-funding-picker { flex-basis: 60px; width: 60px; }
  #appShell .capital-card-heading:lang(en) { flex-wrap: wrap; row-gap: 2px; }
  #appShell .capital-card-heading:lang(en) > span:first-child { flex: 0 0 100%; }
  #appShell .capital-card-heading:lang(en) .mobile-funding-picker { margin-block: -4px; }
}
