/*
 * css/tokens.css: BrainDev design tokens (plan3 "Graphite Ledger", copper replaced by green) + fonts + base reset.
 * Every stylesheet takes its colours from here. Owner: studio builder (SPEC sections 2 and 8).
 */
@font-face {
  font-family: "Geist";
  src: url("../fonts/geist-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Geist Mono";
  src: url("../fonts/geist-mono-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;
  /* neutrals: exactly plan3 */
  --background: #12110f;
  --foreground: #f2ede2;
  --card: #1d1b18;
  --card-foreground: #f2ede2;
  --popover: #24211d;
  --popover-foreground: #f2ede2;
  --secondary: #2a2722;
  --secondary-foreground: #f2ede2;
  --muted: #26231f;
  --muted-foreground: #aaa294;
  --border: #3a352f;
  --input: #443d35;
  --sidebar: #171613;
  --sidebar-foreground: #ded8cd;
  --sidebar-accent: #29251f;
  --sidebar-accent-foreground: #f2ede2;
  --sidebar-border: #35312b;
  --canvas: #151411;
  --canvas-grid: rgba(242, 237, 226, .045);
  --surface-raised: #25221e;
  --surface-soft: #201e1a;
  --teal: #42b59a;
  --teal-soft: #193a32;
  --ochre: #c8ae62;
  --brick: #d76c5c;
  --destructive: #d76c5c;
  --radius: .625rem;

  /* copper -> green */
  --green: #3fbf6e;
  --green-soft: #2c4a36;
  --green-hover: #5fd38a;
  --green-bright: #8fe0ad;
  --green-muted: #8fb59c;
  --green-wash: #1f3022;
  --primary: #3fbf6e;
  --primary-foreground: #0b130e;
  --ring: #7fdca2;
  --accent: #232e27;
  --accent-foreground: #dcefe2;
  --sidebar-primary: #3fbf6e;
  --sidebar-primary-foreground: #0b130e;
  --sidebar-ring: #7fdca2;
  --chart-1: #4fcf7f;
  --chart-2: #42b59a;
  --chart-3: #c8ae62;
  --chart-4: #bf6556;
  --chart-5: #7c8cbf;

  /* studio surface shades used by plan3's studio.css */
  --studio-bg: #151411;
  --studio-header: #12110f;
  --studio-toolbar: #191714;
  --studio-line: #322e27;
  --studio-edge: #3b352c;
  --studio-field: #3b362f;
  --studio-panel: #1a1815;
  --studio-block-head: #211e1a;
  --studio-hover: #2c2923;
  --studio-dim: #8f897e;
  --studio-label: #beb6a8;
  --studio-scroll: #3c4a40;
  --studio-scroll-track: #191714;

  --font-sans: "Geist", Arial, Helvetica, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --font-plan-mono: var(--font-mono);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01" 0;
}
h1, h2, h3, h4, p, ul, ol, figure, pre { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img, svg, canvas { display: block; }
img { max-width: 100%; }
a { color: inherit; }
[hidden] { display: none !important; }
::selection { background: var(--green-soft); color: var(--foreground); }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.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;
}
.eyebrow { color: var(--muted-foreground); font: 650 11px/1 var(--font-mono); letter-spacing: .11em; text-transform: uppercase; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.tabular { font-variant-numeric: tabular-nums; }
.is-positive { color: var(--teal); }
.is-negative { color: var(--brick); }

/* stock logo disc (js/ui/logo.js): round, letter fallback when a file is missing */
.bd-logo {
  --size: 20px;
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  overflow: hidden;
  background: #2a2722;
  box-shadow: inset 0 0 0 1px rgba(242, 237, 226, .08);
  color: var(--sidebar-foreground);
  font: 650 calc(var(--size) * .42)/1 var(--font-sans);
  letter-spacing: 0;
}
.bd-logo img { width: 100%; height: 100%; object-fit: cover; }
.bd-logo[data-fallback] { background: var(--accent); color: var(--green-bright); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* ==================================================================================================
 * Shared UI components (js/ui/**): buttons, notice, menus, bottom sheets, dialogs, wallet login, stock picker.
 * Used by the studio and the landing. Plan3 geometry: 5-7 px radii, 1 px warm borders, 12-13 px type.
 * ================================================================================================== */
.bd-icon { width: 16px; height: 16px; flex-shrink: 0; }
@keyframes bd-spin { to { transform: rotate(360deg); } }
.is-spinning { animation: bd-spin .9s linear infinite; }

.bd-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 36px; padding: 7px 12px; border: 1px solid var(--studio-edge); border-radius: 6px;
  background: transparent; color: var(--foreground); font-size: 13px; font-weight: 550; cursor: pointer;
  transition: background-color 100ms ease-out, border-color 100ms ease-out;
}
.bd-btn:hover:not(:disabled) { background: var(--studio-hover); }
.bd-btn:disabled { opacity: .4; cursor: default; }
.bd-btn-primary { background: var(--green); border-color: var(--green); color: var(--primary-foreground); font-weight: 650; }
.bd-btn-primary:hover:not(:disabled) { background: var(--green-hover); border-color: var(--green-hover); }
.bd-btn-danger { background: var(--brick); border-color: var(--brick); color: #1a0f0d; font-weight: 650; }
.bd-btn-danger:hover:not(:disabled) { background: #e5806f; }

/* notice (plan3 .studio-notice) */
.bd-notice {
  position: fixed; z-index: 90; bottom: 52px; left: 80px; max-width: min(580px, calc(100vw - 100px));
  display: flex; align-items: center; gap: 14px; padding: 10px 10px 10px 14px;
  border: 1px solid #2f5a40; background: #1c2a21; color: var(--foreground);
  box-shadow: 0 6px 24px #0006; border-radius: 6px; font-size: 12px; line-height: 1.5;
  animation: bd-rise 160ms ease-out;
}
.bd-notice > span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.bd-notice button { flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; min-height: 30px; min-width: 30px; padding: 4px 8px; border: 1px solid transparent; border-radius: 5px; background: transparent; color: inherit; font-size: 12px; cursor: pointer; }
.bd-notice button:hover { background: #2a3d30; }
.bd-notice .bd-notice-action { border-color: #3a6a4c; color: var(--green-bright); font-weight: 600; }
.bd-notice svg { width: 14px; height: 14px; }
@keyframes bd-rise { from { transform: translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }

/* popover menu */
.bd-menu-pop {
  position: fixed; z-index: 95; min-width: 220px; max-width: min(340px, calc(100vw - 16px)); max-height: min(70vh, 520px);
  overflow-y: auto; padding: 5px; border: 1px solid var(--studio-edge); border-radius: 8px;
  background: var(--popover); box-shadow: 0 18px 50px rgba(0, 0, 0, .42); outline: none;
  scrollbar-width: thin; scrollbar-color: var(--studio-scroll) transparent;
}
.bd-menu { display: flex; flex-direction: column; gap: 1px; }
.bd-menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 36px; padding: 7px 9px;
  border: 0; border-radius: 5px; background: transparent; color: var(--foreground); text-align: left; font-size: 13px; cursor: pointer;
}
.bd-menu-item:hover:not(:disabled), .bd-menu-item:focus-visible { background: var(--studio-hover); outline: none; }
.bd-menu-item:disabled { opacity: .4; cursor: default; }
.bd-menu-item > svg { width: 15px; height: 15px; color: var(--muted-foreground); }
.bd-menu-item.is-danger { color: #e8897a; }
.bd-menu-item.is-danger > svg { color: currentColor; }
.bd-menu-item.is-checked { background: var(--accent); }
.bd-menu-item .bd-menu-check { margin-left: auto; color: var(--green); }
.bd-menu-label { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.bd-menu-label, .bd-menu-label small { white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.bd-menu-label small { color: var(--muted-foreground); font-size: 11px; }
.bd-menu-gap { width: 15px; flex-shrink: 0; }
.bd-menu-item kbd { margin-left: auto; color: var(--studio-dim); font: 10px var(--font-mono); }
.bd-menu-sep { height: 1px; margin: 4px 2px; background: var(--studio-line); }
.bd-menu-heading { padding: 8px 9px 4px; color: var(--studio-dim); font: 650 10px/1.3 var(--font-mono); letter-spacing: .1em; text-transform: uppercase; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bd-menu-note { margin: 4px 9px 6px; color: var(--muted-foreground); font-size: 12px; line-height: 1.5; }

/* bottom sheet */
.bd-sheet-backdrop {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(0, 0, 0, 0); transition: background-color 160ms ease-out;
}
.bd-sheet-backdrop.is-open { background: rgba(0, 0, 0, .58); }
.bd-sheet-backdrop.is-closing { background: rgba(0, 0, 0, 0); }
.bd-sheet {
  position: relative; display: flex; flex-direction: column; width: 100%; max-width: 640px; max-height: 88vh; max-height: 88dvh;
  border: 1px solid var(--studio-edge); border-bottom: 0; border-radius: 14px 14px 0 0; background: var(--studio-panel);
  box-shadow: 0 -16px 40px rgba(0, 0, 0, .45); outline: none; padding-bottom: var(--safe-bottom);
  transform: translateY(100%); transition: transform 200ms cubic-bezier(.2, .8, .2, 1);
}
.bd-sheet-backdrop.is-open .bd-sheet { transform: none; }
.bd-sheet-backdrop.is-closing .bd-sheet { transform: translateY(100%); }
.bd-sheet-handle { display: grid; place-items: center; height: 22px; flex-shrink: 0; cursor: grab; touch-action: none; }
.bd-sheet-handle i { width: 40px; height: 4px; border-radius: 4px; background: #4a443b; }
.bd-sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 2px 12px 12px 18px; border-bottom: 1px solid var(--studio-line); }
.bd-sheet-head h2 { margin: 6px 0 0; font-size: 17px; font-weight: 550; letter-spacing: -.02em; }
.bd-sheet-head .eyebrow { font-size: 10px; color: var(--green-muted); }
.bd-sheet-close { display: inline-grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 6px; background: transparent; color: var(--muted-foreground); cursor: pointer; flex-shrink: 0; }
.bd-sheet > .bd-sheet-close { position: absolute; top: 4px; right: 6px; }
.bd-sheet-close:hover { background: var(--studio-hover); color: var(--foreground); }
.bd-sheet-close svg { width: 18px; height: 18px; }
.bd-sheet-body { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 8px 10px 14px; }
.bd-menu-in-sheet .bd-menu-item { min-height: 48px; font-size: 15px; padding: 10px 12px; }
.bd-menu-in-sheet .bd-menu-label small { font-size: 12px; }

/* dialogs (plan3 share dialog) */
.bd-modal {
  position: fixed; inset: 0; margin: auto; width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); overflow: auto;
  display: flex; flex-direction: column; gap: 16px; padding: 30px; border: 1px solid #3a5444; border-radius: 10px;
  background: #211e1a; color: var(--foreground); box-shadow: 0 30px 80px rgba(0, 0, 0, .5);
}
.bd-modal:not([open]) { display: none; }
.bd-modal::backdrop { background: rgb(0 0 0 / 65%); }
.bd-modal h2 { margin: 0; font-size: 25px; line-height: 1.2; letter-spacing: -.04em; font-weight: 550; }
.bd-modal .eyebrow { font-size: 10px; color: var(--green-muted); }
.bd-modal-small { width: min(440px, calc(100vw - 32px)); padding: 26px; }
.bd-modal-small h2 { font-size: 21px; }
.bd-modal-close { position: absolute; top: 8px; right: 8px; display: inline-grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 6px; background: transparent; color: var(--muted-foreground); cursor: pointer; }
.bd-modal-close:hover { background: var(--studio-hover); color: var(--foreground); }
.bd-modal-close svg { width: 16px; height: 16px; }
.bd-modal-lead { margin: 0; color: var(--muted-foreground); font-size: 13px; line-height: 1.65; }
.bd-modal-foot { margin: 0; color: var(--studio-dim); font: 11px var(--font-mono); letter-spacing: .02em; }
.bd-modal-form { display: flex; flex-direction: column; gap: 14px; }
.bd-modal label { display: flex; flex-direction: column; gap: 7px; color: var(--studio-label); font-size: 12px; }
.bd-modal label small { color: var(--studio-dim); font-size: 11px; }
.bd-modal input:not([type="checkbox"]) { width: 100%; min-width: 0; border: 1px solid var(--studio-field); background: var(--studio-bg); color: var(--foreground); border-radius: 5px; padding: 10px; font: inherit; font-size: 14px; }
.bd-modal-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.bd-modal-error { margin: 0; color: var(--destructive); font-size: 13px; }
.bd-modal-error:empty { display: none; }

/* wallet login */
.bd-wallet-list { display: flex; flex-direction: column; gap: 8px; }
.bd-wallet-row {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 54px; padding: 10px 12px;
  border: 1px solid var(--studio-edge); border-radius: 8px; background: var(--card); color: var(--foreground);
  text-align: left; cursor: pointer; transition: border-color 100ms ease-out, background-color 100ms ease-out;
}
.bd-wallet-row:hover:not(:disabled) { border-color: var(--green); background: #1f241f; }
.bd-wallet-row:disabled { opacity: .55; cursor: progress; }
.bd-wallet-icon { width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0; object-fit: contain; }
.bd-wallet-icon.is-generic { display: inline-grid; place-items: center; background: var(--accent); color: var(--green-bright); }
.bd-wallet-icon.is-generic svg { width: 17px; height: 17px; }
.bd-wallet-name { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; font-size: 14px; font-weight: 550; }
.bd-wallet-name small { color: var(--muted-foreground); font-size: 11px; font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bd-wallet-go { width: 16px; height: 16px; color: var(--studio-dim); }
.bd-wallet-status { margin: 2px 0 0; color: var(--muted-foreground); font-size: 12px; line-height: 1.55; }
.bd-wallet-status:empty { display: none; }
.bd-wallet-chain { display: flex; flex-direction: column; gap: 10px; padding: 16px; border: 1px solid #5a4a2a; border-radius: 8px; background: #241f16; text-align: left; }
.bd-wallet-chain-ic { color: var(--ochre); }
.bd-wallet-chain-ic svg { width: 20px; height: 20px; }
.bd-wallet-chain strong { font-size: 15px; font-weight: 600; }
.bd-wallet-chain p { margin: 0; color: var(--muted-foreground); font-size: 13px; line-height: 1.6; }
.bd-wallet-chain-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* stock picker */
.bd-asset-btn {
  display: inline-flex; align-items: center; gap: 7px; min-width: 0; max-width: 100%; min-height: 32px; padding: 4px 8px 4px 6px;
  border: 1px solid var(--studio-field); border-radius: 5px; background: var(--studio-bg); color: var(--foreground);
  font: 500 13px var(--font-mono); letter-spacing: .02em; cursor: pointer; text-align: left;
}
.bd-asset-btn:hover:not(:disabled) { border-color: #5a5247; }
.bd-asset-btn:disabled { opacity: .55; cursor: default; }
.bd-asset-btn .bd-asset-sym { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bd-asset-btn .bd-asset-chev { width: 13px; height: 13px; margin-left: auto; color: var(--muted-foreground); }
.bd-asset-btn .bd-asset-linkic { width: 13px; height: 13px; color: var(--green); }
.bd-asset-pop {
  position: fixed; z-index: 95; display: flex; flex-direction: column; overflow: hidden;
  border: 1px solid var(--studio-edge); border-radius: 8px; background: var(--popover); box-shadow: 0 18px 50px rgba(0, 0, 0, .42);
}
.bd-asset-pop-body { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.bd-asset-searchrow { display: flex !important; flex-direction: row !important; align-items: center; gap: 8px !important; padding: 10px 12px; border-bottom: 1px solid var(--studio-line); color: var(--muted-foreground); }
.bd-asset-searchrow svg { width: 15px; height: 15px; }
.bd-asset-search { flex: 1; min-width: 0; border: 0 !important; outline: 0; background: transparent !important; color: var(--foreground); font: 14px var(--font-sans); padding: 4px 0 !important; }
.bd-asset-holder { min-height: 0; overflow-y: auto; flex: 1; scrollbar-width: thin; scrollbar-color: var(--studio-scroll) transparent; }
.bd-asset-list { display: flex; flex-direction: column; padding: 4px; }
.bd-asset-group { padding: 10px 8px 4px; color: var(--studio-dim); font: 650 10px var(--font-mono); letter-spacing: .1em; text-transform: uppercase; }
.bd-asset-opt { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 6px 8px; border: 0; border-radius: 5px; background: transparent; color: var(--foreground); text-align: left; cursor: pointer; }
.bd-asset-opt:hover, .bd-asset-opt:focus-visible { background: var(--studio-hover); outline: none; }
.bd-asset-opt.is-current { background: var(--accent); }
.bd-asset-opt-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.bd-asset-opt-text strong { font: 600 13px var(--font-mono); letter-spacing: .02em; }
.bd-asset-opt-text small { color: var(--muted-foreground); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bd-asset-feed { flex-shrink: 0; padding: 3px 6px; border-radius: 99px; background: var(--teal-soft); color: var(--teal); font: 600 9px/1 var(--font-mono); letter-spacing: .06em; text-transform: uppercase; }
.bd-asset-empty { margin: 0; padding: 18px 12px; color: var(--muted-foreground); font-size: 13px; }
.bd-logo-link { background: var(--accent) !important; color: var(--green) !important; }
.bd-logo-link svg { width: 12px; height: 12px; }
.bd-asset-sheet .bd-sheet-body { padding: 0; display: flex; flex-direction: column; min-height: 50vh; }
.bd-asset-sheet .bd-asset-search { font-size: 16px; }
.bd-asset-sheet .bd-asset-opt { min-height: 48px; }

@media (max-width: 760px) {
  .bd-notice { left: 12px; right: 12px; max-width: none; bottom: calc(66px + var(--safe-bottom)); }
  .bd-modal { padding: 24px 20px; }
  .bd-modal h2 { font-size: 22px; }
  .bd-modal input:not([type="checkbox"]) { font-size: 16px; }
}
.bd-menu-heading.is-plain { text-transform: none; letter-spacing: 0; font-weight: 500; font-size: 11px; color: var(--muted-foreground); }
