/* Blackbook Shared Graphite Terminal System
 * Matte graphite surfaces, warm white prose, restrained surgical mint accent, tabular numerals.
 * Zero gradients, zero emoji chrome, accessible focus indicators, dual cues (color + label/shape).
 */
:root {
  --bb-bg: #0e100f;
  --bb-surface: #141716;
  --bb-surface-2: #1a1e1c;
  --bb-surface-3: #222725;
  --bb-border: #262b29;
  --bb-border-strong: #373f3b;
  --bb-ink: #f3f0e8;
  --bb-ink-2: #b4b9b4;
  --bb-dim: #838a85;
  --bb-mint: #4ecfa1;
  --bb-mint-ink: #091510;
  --bb-mint-soft: rgba(78, 207, 161, 0.12);
  --bb-mint-border: rgba(78, 207, 161, 0.36);
  --bb-sell: #e56962;
  --bb-sell-soft: rgba(229, 105, 98, 0.14);
  --bb-sell-border: rgba(229, 105, 98, 0.40);
  --bb-wait: #dca653;
  --bb-wait-soft: rgba(220, 166, 83, 0.13);
  --bb-wait-border: rgba(220, 166, 83, 0.42);
  --bb-info: #62a8e5;
  --bb-sans: "Instrument Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bb-mono: "Geist Mono Variable", "Plex Mono", ui-monospace, Menlo, Consolas, monospace;
}

:where(button, a, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--bb-mint);
  outline-offset: 2px;
}

.bb-num, .num {
  font-family: var(--bb-mono);
  font-variant-numeric: tabular-nums;
}

/* Fix crisp select carets across browsers (prevents wrapping caret underneath text on dark selects) */
select.bb-select,
.tool-row select,
.select-field select {
  appearance: none;
  background-color: var(--bb-surface-2);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='none' stroke='%239ca39d' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' d='M3 4.5L6 7.5L9 4.5'/%3E%3C/svg%3E");
  background-position: right 10px center;
  background-size: 12px 12px;
  background-repeat: no-repeat;
  padding-right: 32px;
}

/* Unified single-row workspace masthead */
.bb-masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 50px;
  padding: 6px 18px;
  background: var(--bb-bg);
  border-bottom: 1px solid var(--bb-border);
  font-family: var(--bb-sans);
  box-sizing: border-box;
}

.bb-masthead .bb-wordmark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: none;
  color: var(--bb-ink);
  font: 600 15px/1 var(--bb-sans);
  letter-spacing: -0.02em;
  text-decoration: none;
}

.bb-masthead .bb-book {
  width: 14px;
  height: 18px;
  border-radius: 2px;
  background: var(--bb-surface-3);
  border: 1px solid var(--bb-border-strong);
  box-shadow: inset 3px 0 0 var(--bb-mint);
}

.bb-masthead .brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  background: var(--bb-surface-2);
  border: 1px solid var(--bb-border-strong);
  font: 700 13px/1 var(--bb-sans);
  letter-spacing: -0.04em;
  color: var(--bb-ink);
}

.bb-masthead .brand-mark > span {
  color: var(--bb-mint);
}

:root:not(.classic) {
  --background: #0e100f;
  --foreground: #f3f0e8;
  --card: #141716;
  --card-foreground: #f3f0e8;
  --popover: #1a1e1c;
  --popover-foreground: #f3f0e8;
  --primary: #4ecfa1;
  --primary-foreground: #091510;
  --secondary: #1a1e1c;
  --muted-foreground: #9ca39d;
  --destructive: #e56962;
  --border: #262b29;
  --input: #373f3b;
  --ring: #4ecfa1;
  --tape-buy: #4ecfa1;
  --tape-wait: #dca653;
}

/* Keep shadcn card-surface --muted scoped to desk/ui.css views so btc.css text --muted stays high contrast */
:root:not(.classic) body:is([data-page="trade"], [data-page="flow"], [data-page="details"], [data-page="simple"], [data-page="settings"]):not(.member-trade):not(.public-trade) {
  --muted: #1a1e1c;
}

.bb-masthead nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-inline-start: auto;
  overflow-x: auto;
  scrollbar-width: none;
}

.bb-masthead nav::-webkit-scrollbar {
  display: none;
}

.bb-masthead nav a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 11px;
  border-radius: 6px;
  color: var(--bb-ink-2);
  font: 500 13px/1 var(--bb-sans);
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.12s, background-color 0.12s;
}

.bb-masthead nav a:hover {
  color: var(--bb-ink);
  background: var(--bb-surface-2);
}

.bb-masthead nav a[aria-current="page"] {
  color: var(--bb-mint);
  background: var(--bb-mint-soft);
  box-shadow: inset 0 -2px 0 var(--bb-mint);
}

.bb-masthead nav a.public-cta {
  color: var(--bb-mint-ink);
  background: var(--bb-mint);
  font-weight: 600;
}

.bb-masthead nav a.public-cta:hover {
  background: #67ddb3;
  color: var(--bb-mint-ink);
}

/* Status pills with shape/text dual cue */
.bb-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  padding: 2px 9px;
  border-radius: 5px;
  border: 1px solid var(--bb-border-strong);
  background: var(--bb-surface-2);
  color: var(--bb-ink-2);
  font: 600 11.5px/1.25 var(--bb-mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.bb-pill[data-tone="long"],
.bb-pill[data-tone="buy"],
.bb-pill[data-tone="fresh"],
.bb-pill[data-tone="pass"] {
  background: var(--bb-mint-soft);
  border-color: var(--bb-mint-border);
  color: var(--bb-mint);
}

.bb-pill[data-tone="short"],
.bb-pill[data-tone="sell"],
.bb-pill[data-tone="fail"],
.bb-pill[data-tone="losing"] {
  background: var(--bb-sell-soft);
  border-color: var(--bb-sell-border);
  color: var(--bb-sell);
}

.bb-pill[data-tone="wait"],
.bb-pill[data-tone="warn"] {
  background: var(--bb-wait-soft);
  border-color: var(--bb-wait-border);
  color: var(--bb-wait);
}

.bb-pill[data-tone="stale"],
.bb-pill[data-tone="unavailable"] {
  background: var(--bb-surface-2);
  border-color: var(--bb-border);
  color: var(--bb-dim);
}

.is-stale-value {
  opacity: 0.56;
}

@media (max-width: 720px) {
  .bb-masthead {
    padding: 8px 12px;
    gap: 8px;
    flex-wrap: wrap;
    height: auto;
  }
  .bb-masthead nav {
    width: 100%;
    flex-wrap: wrap;
    gap: 4px;
    margin-inline-start: 0;
    overflow: visible;
  }
  .bb-masthead nav a {
    min-height: 36px;
    padding: 4px 9px;
    font-size: 12px;
  }
}

@media (pointer: coarse) {
  .bb-masthead nav a {
    min-height: 40px;
  }
}

/* Shared Matte Graphite shell overlay for workspace, intelligence, context & auth routes */
body[data-bb-shell="1"] {
  --bg: #0e100f;
  --panel: #141716;
  --raised: #1a1e1c;
  --line: #262b29;
  --soft-line: #1f2422;
  --border: #262b29;
  --text: #f3f0e8;
  --ink: #f3f0e8;
  --muted: #9ca39d;
  --dim: #737b76;
  --accent: #4ecfa1;
  --accent-soft: #2e8466;
  --teal: #4ecfa1;
  --gold: #4ecfa1;
  --gold-soft: #2e8466;
  --warn: #dca653;
  --bad: #e56962;
  background: var(--bg);
  background-image: none;
  color: var(--ink);
  font-family: var(--bb-sans);
}

body[data-bb-shell="1"] :is(.panel, .market-card, .plan-panel, .app-preview, .period-section, .ea-preview, .card, .card.selected, .movement, .welcome-card, .login, .primary, .primary-button, .button.primary, .ea-button) {
  background-image: none;
}

body[data-bb-shell="1"] :is(.panel, .card, .app-preview, .period-section, .ea-preview, .login, .brief-section, .signout-panel, .notice) {
  background-color: var(--panel);
  border-color: var(--line);
}

body[data-bb-shell="1"] :is(.button.primary, button.primary, .primary-button, .ea-button) {
  background-color: var(--bb-mint);
  border-color: var(--bb-mint);
  color: var(--bb-mint-ink);
}

body[data-bb-shell="1"] :is(.site-header, .ea-header, .login-header) {
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  min-height: 54px;
  gap: 16px;
}

body[data-bb-shell="1"] select {
  -webkit-appearance: none !important;
  appearance: none !important;
  background-color: var(--raised);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='none' stroke='%239ca39d' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' d='M3 4.5L6 7.5L9 4.5'/%3E%3C/svg%3E") !important;
  background-position: right 10px center !important;
  background-size: 12px 12px !important;
  background-repeat: no-repeat !important;
  padding: 8px 32px 8px 12px !important;
  line-height: 1.3 !important;
  white-space: nowrap;
}

body[data-bb-shell="1"] select::picker-icon {
  display: none !important;
  content: "" !important;
}

.bb-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  overflow-x: auto;
  scrollbar-width: none;
}

.bb-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 10px;
  border-radius: 6px;
  color: var(--bb-ink-2);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}

.bb-nav a:hover {
  color: var(--bb-ink);
  background: var(--bb-surface-2);
}

.bb-nav a[aria-current="page"] {
  color: var(--bb-mint);
  background: var(--bb-mint-soft);
}

.bb-mt-draft {
  border-color: var(--bb-mint-border) !important;
  background: var(--bb-surface) !important;
}

.bb-mt-draft .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.bb-chart-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 12px;
  color: var(--bb-mint);
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
}

.bb-chart-link:hover {
  text-decoration: underline;
}

@media (max-width: 720px) {
  body[data-bb-shell="1"] .site-header {
    flex-wrap: wrap;
    padding: 10px 14px;
    height: auto;
    gap: 8px;
  }
  .bb-nav {
    width: 100%;
    order: 3;
    flex-wrap: wrap;
    gap: 2px 4px;
    padding-top: 6px;
    border-top: 1px solid var(--bb-border);
    overflow: visible;
  }
  .bb-nav a {
    padding: 4px 8px;
    font-size: 12px;
    min-height: 36px;
  }
}

/* ==========================================================================
   Page 5b Product-Wide Route Density & Graphite Harmony
   Covers /btc-context, /flow, /login, /register, /early-access, /app,
   /account, /support, legal docs, and /details /simple /settings cleanly
   ========================================================================== */

/* 1. Shared route-level variables & header compacting where .site-header is used */
html body:has(.perspective, .saved-plan, #plan-select, .login-footer, .ea-footer, .support-nav, .doc-toc) {
  background: #0e100f;
  color: #f3f0e8;
  font-feature-settings: "tnum" 1, "cv05" 1;
}

html body:has(.perspective, .saved-plan, #plan-select, .login-footer, .ea-footer, .support-nav, .doc-toc) .site-header {
  min-height: 52px;
  height: auto;
  max-width: 1360px;
  padding: 6px 20px;
  border-bottom: 1px solid #242a27;
}

/* 2. /btc-context: Context Review Desk */
html body:has(.perspective, .saved-plan, #plan-select) main {
  max-width: 1360px;
  padding: 14px 20px 28px;
}

html body:has(.perspective, .saved-plan, #plan-select) h1 {
  font-size: clamp(20px, 1.8vw, 24px);
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

html body:has(.perspective, .saved-plan, #plan-select) h2 {
  font-size: 16px;
  letter-spacing: -0.015em;
}

html body:has(.perspective, .saved-plan, #plan-select) :is(section, .panel, .card, .saved-plan, .empty, .perspective) {
  background: #141716;
  border-color: #242a27;
  border-radius: 8px;
}

html body:has(.perspective, .saved-plan, #plan-select) .perspective {
  padding: 14px 16px;
  margin-top: 14px;
}

html body:has(.perspective, .saved-plan, #plan-select) .button.primary {
  background: #4ecfa1;
  color: #0b1410;
  border-radius: 6px;
  min-height: 36px;
}

html body:has(.perspective, .saved-plan, #plan-select) select {
  background-color: #181c1a;
  border-color: #2f3733;
  border-radius: 6px;
  min-height: 36px;
}

/* 3. /flow & /details & /simple & /settings (Calm + UI shell routes) */
html body[data-page="flow"],
html:not(.classic) body:is([data-page="details"], [data-page="simple"], [data-page="settings"]) {
  --bg: #0e100f;
  --background: #0e100f;
  --panel: #141716;
  --card: #141716;
  --raised: #1a1e1c;
  --line: #242a27;
  --border: #242a27;
  --ink: #f3f0e8;
  --foreground: #f3f0e8;
  --mute: #9ca39d;
  --muted-foreground: #9ca39d;
  --dim: #9ca39d;
  --accent: #4ecfa1;
  background: #0e100f;
  color: #f3f0e8;
}

html body[data-page="flow"] main,
html:not(.classic) body:is([data-page="details"], [data-page="simple"], [data-page="settings"]) .wrap {
  max-width: 1360px;
  padding: 14px 20px 28px;
  gap: 12px;
}

html:not(.classic) body:is([data-page="details"], [data-page="simple"], [data-page="settings"]) .col {
  gap: 12px;
}

html body[data-page="flow"] :is(.ui-card, .panel),
html:not(.classic) body:is([data-page="details"], [data-page="simple"], [data-page="settings"]) .panel {
  background: #141716;
  border: 1px solid #242a27;
  border-radius: 8px;
}

html:not(.classic) body:is([data-page="details"], [data-page="simple"], [data-page="settings"]) .head {
  padding: 10px 14px;
  border-bottom-color: #242a27;
}

html:not(.classic) body[data-page="settings"] .inputs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px 14px;
  padding: 12px 14px;
}

html:not(.classic) body[data-page="settings"] .inputs .row {
  grid-column: 1 / -1;
}

/* 4. /login & /register */
html body:has(> .login-footer) main {
  max-width: 520px;
  padding: 24px 18px 28px;
}

html body:has(> .login-footer) h1 {
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

html body:has(> .login-footer) form {
  background: #141716;
  border: 1px solid #242a27;
  border-radius: 8px;
  padding: 18px 20px;
}

html body:has(> .login-footer) input:not([type="checkbox"]) {
  background-color: #181c1a;
  border: 1px solid #2f3733;
  border-radius: 6px;
  min-height: 38px;
  color: #f3f0e8;
}

html body:has(> .login-footer) button.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  width: 100%;
  background: #4ecfa1;
  color: #0b1410;
  border-radius: 6px;
  min-height: 40px;
  font-weight: 600;
}

/* 5. /early-access & /app */
html body:has(.ea-footer, .ea-values, .app-instructions) main {
  max-width: 1240px;
  padding: 16px 20px 28px;
}

html body:has(.ea-footer, .ea-values, .app-instructions) h1 {
  font-size: clamp(24px, 2.4vw, 32px);
  line-height: 1.16;
  letter-spacing: -0.025em;
}

html body:has(.ea-footer, .ea-values, .app-instructions) h2 {
  font-size: clamp(17px, 1.6vw, 21px);
  line-height: 1.25;
}

html body:has(.ea-footer, .ea-values, .app-instructions) :is(.ea-preview, .ea-values article, .ea-form, .ea-facts, .app-ios, .app-methods article, .app-access) {
  background: #141716;
  border: 1px solid #242a27;
  border-radius: 8px;
  padding: 16px 18px;
  box-shadow: none;
}

html body:has(.ea-footer, .ea-values, .app-instructions) :is(.ea-button, .app-alert-note) {
  border-radius: 6px;
}

html body:has(.ea-footer, .ea-values, .app-instructions) .ea-button {
  background: #4ecfa1;
  color: #0b1410;
  min-height: 38px;
}

html body:has(.ea-footer, .ea-values, .app-instructions) :is(input:not([type="checkbox"]), select) {
  background-color: #181c1a;
  border-color: #2f3733;
  border-radius: 6px;
  min-height: 38px;
}

/* 6. /account, /support & legal docs */
html body:has(.support-nav, .doc-toc) main {
  max-width: 1120px;
  padding: 16px 20px 28px;
}

html body:has(.support-nav, .doc-toc) h1 {
  font-size: clamp(22px, 2vw, 26px);
  line-height: 1.2;
  letter-spacing: -0.02em;
}

html body:has(.support-nav, .doc-toc) h2 {
  font-size: 16px;
  margin-top: 16px;
}

html body:has(.support-nav, .doc-toc) :is(.doc-toc, .panel, .card, .account-card) {
  background: #141716;
  border: 1px solid #242a27;
  border-radius: 8px;
  padding: 14px 16px;
}

html body:has(.support-nav, .doc-toc) .support-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

html body:has(.support-nav, .doc-toc) .support-nav a {
  border-radius: 6px;
  border: 1px solid #242a27;
  background: #141716;
  padding: 6px 10px;
  font-size: 12px;
}

/* Preserve 44px touch targets on narrow/coarse screens across unified routes */
@media (max-width: 899px) {
  html body:has(.perspective, .saved-plan, #plan-select, .login-footer, .ea-footer, .support-nav, .doc-toc) :is(button, .button, .ea-button, select, input:not([type="checkbox"])) {
    min-height: 44px;
  }
}
