/* Design tokens. Source of truth: DESIGN.md. Fonts load from Google Fonts in the layouts. */
:root {
  color-scheme: light;
  --paper: #f5f2e9;
  --surface: #fffefa;
  --line: #d8dacf;
  --ink: #26382f;
  --muted: #626960;
  --green: #24634b;
  --green-deep: #194b37;
  --green-soft: #e4ede4;
  --graphite: #8a6b3f;
  --success: #286044;
  --success-bg: #e8f1e8;
  --warning: #805218;
  --warning-bg: #faeed9;
  --error: #a13e35;
  --error-bg: #f8e9e5;
  --info: #385e73;
  --info-bg: #e8eff3;
  --on-green: #fff;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Newsreader", Georgia, serif;
  --font-ui: "Source Sans 3", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
  --radius-sm: 6px;
  --radius-md: 10px;
  --menu-shadow: color-mix(in srgb, var(--ink) 10%, transparent);

  /* Old names, kept until later work replaces them */
  --bm-ink: var(--ink);
  --bm-muted: var(--muted);
  --bm-green: var(--green);
  --bm-line: var(--line);
  --bm-paper: var(--paper);
  --font-sans: var(--font-ui);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not(:has(> body[data-theme="light"])) {
    color-scheme: dark;
    --paper: #1c221e;
    --surface: #242b26;
    --line: #38423b;
    --ink: #ede6d6;
    --muted: #a3a89c;
    --green: #5f9a7f;
    --green-deep: #7fb59a;
    --green-soft: #28382f;
    --graphite: #b8976a;
    --success: #7fb59a;
    --success-bg: #25342b;
    --warning: #d1a45b;
    --warning-bg: #3a3022;
    --error: #d1766a;
    --error-bg: #3b2a27;
    --info: #8fb3c7;
    --info-bg: #27343b;
    --on-green: #11180f;
  }
}

:root[data-theme="dark"], :root:has(> body[data-theme="dark"]) {
  color-scheme: dark;
  --paper: #1c221e;
  --surface: #242b26;
  --line: #38423b;
  --ink: #ede6d6;
  --muted: #a3a89c;
  --green: #5f9a7f;
  --green-deep: #7fb59a;
  --green-soft: #28382f;
  --graphite: #b8976a;
  --success: #7fb59a;
  --success-bg: #25342b;
  --warning: #d1a45b;
  --warning-bg: #3a3022;
  --error: #d1766a;
  --error-bg: #3b2a27;
  --info: #8fb3c7;
  --info-bg: #27343b;
  --on-green: #11180f;
}

.bm-app { margin: 0; color: var(--ink); background: var(--paper); font-family: var(--font-ui); font-size: 16px; line-height: 1.5; }
.bm-app *, .bm-app *::before, .bm-app *::after { box-sizing: border-box; }
.bm-app h1, .bm-app h2, .bm-app h3, .bm-app p { margin: 0; }
.bm-app h1, .bm-app h2 { font-family: var(--font-display); font-weight: 400; letter-spacing: -.02em; font-variation-settings: "SOFT" 30; text-wrap: balance; }
.bm-app h1 { font-size: clamp(2rem, 4vw, 3.375rem); line-height: 1.12; }
.bm-app h2 { font-size: 1.75rem; line-height: 1.2; }
.bm-app h3 { font-weight: 600; }
.bm-app p { text-wrap: pretty; }
.bm-app a { text-decoration: none; }
.bm-app :is(a, button, input, select, textarea, summary):focus-visible { outline: 2px solid var(--green); outline-offset: 4px; }
.bm-mono { font-family: var(--font-mono); font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.bm-note-text { font-family: var(--font-body); font-size: 16px; line-height: 1.6; max-width: 62ch; }
.bm-skip-link { position: fixed; top: -5rem; left: 1rem; z-index: 100; background: var(--surface); color: var(--ink); padding: .75rem 1rem; }
.bm-skip-link:focus { top: 1rem; }
.bm-topbar { min-height: 84px; padding: 1rem 4vw; display: flex; align-items: center; gap: 3rem; border-bottom: 1px solid var(--line); }
.bm-brand { display: inline-flex; align-items: center; gap: .65rem; flex-shrink: 0; font-family: var(--font-display); font-size: 1.35rem; font-weight: 500; letter-spacing: -.02em; font-variation-settings: "SOFT" 30; color: var(--ink); }
.bm-brand-light { font-weight: 300; }
.bm-brand-mark { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 34px; border-radius: 9px 9px 9px 2px; color: var(--on-green); background: var(--green); font-size: 1.5rem; line-height: 1; padding-bottom: 3px; }
.bm-desktop-nav { display: flex; align-items: center; gap: 1.75rem; color: var(--muted); font-weight: 500; }
.bm-desktop-nav a { padding: .5rem 0; }
.bm-desktop-nav a:hover, .bm-desktop-nav [aria-current="page"] { color: var(--green); }
.bm-account { margin-left: auto; display: flex; gap: 1rem; align-items: center; }
.bm-account-email { color: var(--muted); max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.bm-topbar-caption { margin-left: auto !important; color: var(--muted); font-size: .8rem; }
.bm-mobile-nav { display: none; }
.bm-main { isolation: isolate; max-width: 1180px; margin: 0 auto; padding: 64px 32px 80px; min-height: calc(100dvh - 160px); }
.bm-page { display: grid; gap: 36px; }
.bm-page-header { display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap; padding-bottom: 36px; border-bottom: 1px solid var(--line); }
.bm-eyebrow { font-family: var(--font-mono); font-size: .72rem; line-height: 1.6; letter-spacing: .12em; font-weight: 500; color: var(--green); margin-bottom: 12px !important; text-transform: uppercase; }
.bm-intro { color: var(--muted); max-width: 56ch; margin-top: 12px !important; }
.bm-muted { color: var(--muted); font-size: .8rem; }
.bm-button { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: 44px; padding: 7px 15px; border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--ink); background: var(--surface); font: inherit; font-weight: 500; line-height: 1.4; white-space: nowrap; cursor: pointer; transition: background 100ms, border-color 100ms; }
.bm-button::after { content: ""; position: absolute; inset: -5px 0; }
.bm-button:hover { background: var(--green-soft); border-color: var(--green); }
.bm-button-primary { background: var(--green); border-color: var(--green); color: var(--on-green); }
.bm-button-primary:hover { background: var(--green-deep); border-color: var(--green-deep); }
.bm-button-quiet { border-color: transparent; background: transparent; }
.bm-button-danger { color: var(--error); border-color: transparent; background: transparent; }
.bm-button-danger:hover { background: var(--error-bg); border-color: transparent; }
.bm-workspaces { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 20px; }
.bm-workspace { display: flex; flex-direction: column; align-items: flex-start; gap: 20px; padding: 28px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); color: var(--ink); transition: border-color 150ms, background 150ms; }
.bm-workspace:hover { border-color: var(--green); background: var(--green-soft); }
.bm-workspace h2 { font-size: 1.2rem; }
.bm-workspace-open { color: var(--green); font-size: .8rem; }
.bm-avatar { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; width: 42px; height: 42px; background: var(--green-soft); color: var(--green); border-radius: 14px 14px 14px 4px; font-weight: 600; }
.bm-badge { display: inline-flex; align-items: center; padding: 3px 9px; background: var(--green-soft); color: var(--green); border-radius: var(--radius-sm); font-size: .75rem; font-weight: 500; text-transform: capitalize; }
.bm-section { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 40px; padding-bottom: 36px; border-bottom: 1px solid var(--line); }
.bm-section-heading { display: grid; gap: 8px; align-content: start; }
.bm-section-heading p { color: var(--muted); font-size: .82rem; }
.bm-section-body { min-width: 0; display: grid; gap: 20px; align-content: start; }
.bm-form { display: grid; gap: 20px; }
.bm-appearance-options { display: grid; gap: 4px; margin: 0; padding: 0; border: 0; }
.bm-appearance-options legend { margin-bottom: 8px; font-weight: 500; }
.bm-appearance-option { display: flex; align-items: center; gap: 10px; min-height: 44px; width: fit-content; cursor: pointer; }
.bm-appearance-option input { width: 18px; height: 18px; accent-color: var(--green); }
.bm-form-row { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 12px; }
.bm-field { display: grid; gap: 7px; flex: 1; min-width: min(200px, 100%); }
.bm-field label { font-size: .875rem; font-weight: 500; }
.bm-input { width: 100%; min-height: 40px; padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); font: inherit; }
.bm-input::placeholder { color: var(--muted); }
.bm-input:focus { outline: 2px solid var(--green); outline-offset: 2px; border-color: var(--green); }
.bm-list { list-style: none; padding: 0; margin: 0; }
.bm-list-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.bm-list-row:first-child { padding-top: 0; }
.bm-list-row:last-child { border-bottom: 0; padding-bottom: 0; }
.bm-list-row details { font-size: .75rem; color: var(--muted); }
.bm-app summary { cursor: pointer; }
.bm-empty { padding: 24px; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius-md); color: var(--muted); }
.bm-status, .bm-error { padding: 14px 16px; border: 1px solid currentcolor; border-radius: var(--radius-md); }
.bm-status { background: var(--success-bg); color: var(--success); }
.bm-error { background: var(--error-bg); color: var(--error); }
.bm-pagination { display: flex; justify-content: space-between; gap: 20px; font-size: .8rem; color: var(--green); }
.bm-secret { overflow-wrap: anywhere; font-family: var(--font-mono); }
.bm-auth-layout { isolation: isolate; display: grid; grid-template-columns: 1fr 1fr; min-height: calc(100dvh - 160px); }
.bm-auth-story { position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: center; gap: 28px; background: var(--surface); padding: 9vw 7vw; }
.bm-auth-story h2 { font-size: clamp(2.4rem, 4vw, 4rem); line-height: 1.12; }
.bm-story-intro { color: var(--muted); line-height: 1.85; }
.bm-story-lines { display: flex; gap: 7px; padding-top: 24px; }
.bm-story-lines span { height: 5px; width: 45px; border-radius: 4px; background: var(--green); }
.bm-story-lines span:nth-child(2) { width: 30px; opacity: .6; }
.bm-story-lines span:nth-child(3) { width: 15px; opacity: .3; }
.bm-story-footnote { color: var(--muted); font-size: .75rem; letter-spacing: .03em; }
.bm-auth-content { display: flex; align-items: center; justify-content: center; padding: 64px 32px; }
.bm-auth-card { width: 100%; max-width: 320px; display: grid; gap: 24px; }
.bm-auth-card h1 { font-size: 2rem; }
.bm-auth-card .bm-intro { margin-top: 0 !important; }
.bm-auth-card .bm-button-primary { width: 100%; }
.bm-auth-card > a { color: var(--green); }
.bm-footer { display: flex; justify-content: space-between; gap: 20px; padding: 22px 4vw; border-top: 1px solid var(--line); color: var(--muted); font-size: .75rem; }
@media (max-width: 900px) {
  .bm-account-email { display: none; }
  .bm-topbar { gap: 24px; }
  .bm-desktop-nav { gap: 20px; }
  .bm-topbar .bm-desktop-nav, .bm-topbar .bm-account { display: none; }
  .bm-topbar .bm-mobile-nav { display: block; position: relative; margin-left: auto; font-size: .85rem; }
  .bm-topbar .bm-mobile-nav summary { min-height: 44px; display: inline-flex; align-items: center; padding: 10px; }
  .bm-topbar .bm-mobile-nav nav { position: absolute; z-index: 20; right: 0; top: 48px; display: grid; gap: 16px; min-width: 220px; padding: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); box-shadow: 0 12px 28px var(--menu-shadow); }
  .bm-topbar .bm-mobile-nav nav > a { min-height: 44px; display: flex; align-items: center; }
  .bm-section { grid-template-columns: 180px minmax(0, 1fr); gap: 24px; }
}
@media (max-width: 640px) {
  .bm-topbar { min-height: 72px; padding: 18px 24px; }
  .bm-desktop-nav, .bm-account, .bm-topbar-caption { display: none; }
  .bm-mobile-nav { display: block; margin-left: auto; position: relative; font-size: .85rem; }
  .bm-mobile-nav summary { padding: 10px; }
  .bm-mobile-nav nav { position: absolute; z-index: 20; right: 0; top: 48px; display: grid; gap: 16px; min-width: 220px; padding: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); box-shadow: 0 12px 28px var(--menu-shadow); }
  .bm-main { padding: 36px 24px 56px; }
  .bm-page { gap: 28px; }
  .bm-page-header { padding-bottom: 28px; }
  .bm-section { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .bm-form-row { flex-direction: column; align-items: stretch; }
  .bm-auth-layout { grid-template-columns: 1fr; }
  .bm-auth-story { padding: 36px 24px; gap: 16px; }
  .bm-auth-story h2 { font-size: 2.3rem; }
  .bm-story-lines, .bm-story-footnote { display: none; }
  .bm-auth-content { padding: 44px 24px 56px; }
  .bm-footer { padding: 20px 24px; flex-wrap: wrap; }
  .bm-button { font-size: .875rem; }
}
@media (prefers-reduced-motion: reduce) { .bm-app * { transition: none !important; } }
