/* Bandwagon UI kit: components. Needs tokens.css first. Docs: docs/app/UI.md
   Sections: base, type, buttons, fields, choices, chips, rates and stepper, code input,
   dropzone and progress, badges and stamps, cards and notices, tables, week calendar,
   empty states, toasts, dialog, loaders, avatars, app shell, onboarding layout, utilities. */

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; overflow-x: clip; }
body {
  background: var(--bw-cream);
  color: var(--bw-ink);
  font: 400 var(--bw-t-15)/var(--bw-lh-body) var(--bw-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}
img, svg, video { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; }
h1, h2, h3, h4 { text-wrap: balance; }
p { text-wrap: pretty; }
::selection { background: var(--bw-ox-tint); color: var(--bw-wax); }
:focus-visible { outline: 2px solid var(--bw-oxblood); outline-offset: 2px; }
[hidden] { display: none !important; }

.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.i-sm { width: 16px; height: 16px; }
.i-lg { width: 22px; height: 22px; }

/* ---------- Type ---------- */
.h1, .h2, .h3 { font-family: var(--bw-display); font-weight: var(--bw-display-weight); color: var(--bw-ink); letter-spacing: var(--bw-display-track); }
.h1 { font-size: var(--bw-t-36); line-height: 1.02; }
.h2 { font-size: var(--bw-t-26); line-height: 1.15; }
.h3 { font-size: 24px; line-height: 1.15; }
.lead { font-size: var(--bw-t-17); color: var(--bw-muted); max-width: 62ch; }
.muted { color: var(--bw-muted); }
.small { font-size: var(--bw-t-13); }
.num { font-variant-numeric: tabular-nums; }
.mono { font: var(--bw-label-weight) var(--bw-t-12)/1.2 var(--bw-label); letter-spacing: .06em; text-transform: uppercase; }
.link { color: var(--bw-oxblood); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; text-decoration-color: rgba(140, 28, 19, .35); transition: text-decoration-color var(--bw-d-150) var(--bw-out); }
.link:hover { text-decoration-color: currentColor; }
kbd { font: 600 12px/1 var(--bw-body); border: 1px solid var(--bw-line); border-bottom-width: 2px; border-radius: 4px; padding: 2px 5px; background: var(--bw-sheet); }

/* ---------- Buttons ---------- */
.btn {
  --btn-h: 44px;
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--btn-h); padding: 0 18px;
  border-radius: var(--bw-r-sm); border: 1px solid transparent;
  font: 600 var(--bw-t-15)/1 var(--bw-body); letter-spacing: -.005em;
  text-decoration: none; white-space: nowrap; cursor: pointer; user-select: none; touch-action: manipulation;
  transition: background-color var(--bw-d-150) var(--bw-out), border-color var(--bw-d-150) var(--bw-out), color var(--bw-d-150) var(--bw-out), transform var(--bw-d-100) var(--bw-out), box-shadow var(--bw-d-150) var(--bw-out);
}
.btn:active { transform: scale(.97); }
.btn .i { margin: 0 -2px; }
.btn-primary { background: var(--bw-oxblood); color: #fff8f0; box-shadow: 0 1px 0 var(--bw-wax), inset 0 1px 0 rgba(255, 255, 255, .08); }
.btn-primary:hover { background: var(--bw-wax); }
.btn-secondary { background: var(--bw-sheet); color: var(--bw-ink); border-color: var(--bw-line); box-shadow: var(--bw-sh-1); }
.btn-secondary:hover { border-color: #c8b79b; background: #fff; }
.btn-ghost { background: transparent; color: var(--bw-ink); }
.btn-ghost:hover { background: var(--bw-ink-wash); }
.btn-ink { background: var(--bw-ink); color: var(--bw-cream); }
.btn-ink:hover { background: #000; }
.btn-danger { background: var(--bw-sheet); color: var(--bw-oxblood); border-color: #e3bdb5; }
.btn-danger:hover { background: var(--bw-bad-bg); }
.btn-sm { --btn-h: 36px; padding: 0 12px; font-size: var(--bw-t-14); gap: 6px; }
.btn-lg { --btn-h: 52px; padding: 0 24px; font-size: 16px; }
.btn-block { width: 100%; }
.btn-icon { padding: 0; width: var(--btn-h); }
.btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
/* Loading: the label stays, a spinner takes the icon's place. Clicks are ignored by ui.js */
.btn.is-loading { cursor: progress; }
.btn.is-loading > .i { display: none; }
.btn.is-loading::before {
  content: ""; width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: bw-spin 700ms linear infinite; opacity: .9;
}
.btn-primary.is-loading { background: #a4463e; box-shadow: none; }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--bw-s-3); align-items: center; }

.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--bw-r-sm);
  color: var(--bw-muted); touch-action: manipulation; transition: background-color var(--bw-d-150) var(--bw-out), color var(--bw-d-150) var(--bw-out);
}
.icon-btn:hover { background: var(--bw-ink-wash); color: var(--bw-ink); }
@media (pointer: coarse) { .icon-btn { width: 44px; height: 44px; } }

/* ---------- Fields ---------- */
.field { display: grid; gap: 6px; min-width: 0; }
.label { font-size: var(--bw-t-14); font-weight: 600; color: var(--bw-ink); }
.label .opt { font-weight: 400; color: var(--bw-muted); margin-left: 4px; }
.hint { font-size: var(--bw-t-13); color: var(--bw-muted); }
.field-error { display: none; align-items: flex-start; gap: 6px; font-size: var(--bw-t-13); font-weight: 500; color: var(--bw-bad); }
.field-error .i { width: 15px; height: 15px; margin-top: 2px; }
.field.is-invalid .field-error { display: flex; animation: bw-fade-down var(--bw-d-150) var(--bw-out); }
.field.is-invalid > .hint { display: none; } /* errors replace hints */
.field.is-invalid .consent { border-color: var(--bw-oxblood); }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--bw-s-4); }

.input, .select, .textarea, .input-wrap {
  width: 100%; min-height: 44px;
  background: var(--bw-sheet); color: var(--bw-ink);
  border: 1px solid var(--bw-line); border-radius: var(--bw-r-sm);
  font-size: var(--bw-t-15);
  transition: border-color var(--bw-d-150) var(--bw-out), box-shadow var(--bw-d-150) var(--bw-out);
}
.input, .select, .textarea { padding: 10px 12px; }
.input::placeholder, .textarea::placeholder { color: var(--bw-faint); }
.input:hover, .select:hover, .textarea:hover, .input-wrap:hover { border-color: #cbbb9f; }
.input:focus, .select:focus, .textarea:focus, .input-wrap:focus-within { outline: none; border-color: var(--bw-oxblood); box-shadow: var(--bw-focus); }
.textarea { min-height: 96px; resize: vertical; line-height: 1.5; field-sizing: content; }
.select {
  appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b6259' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 10l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 18px;
}
.input-wrap { display: flex; align-items: center; padding: 0 12px; gap: 8px; }
.input-wrap > .input { border: 0; box-shadow: none; background: transparent; padding: 10px 0; min-height: 42px; }
.input-wrap > .input:focus { box-shadow: none; }
.affix { color: var(--bw-muted); font-size: var(--bw-t-15); white-space: nowrap; display: inline-flex; align-items: center; }
.input-wrap .state-icon { display: none; color: var(--bw-ok); }
.field.is-valid .input-wrap .state-icon { display: block; animation: bw-pop var(--bw-d-200) var(--bw-out); }
.field.is-invalid .input, .field.is-invalid .select, .field.is-invalid .textarea, .field.is-invalid .input-wrap { border-color: var(--bw-oxblood); background: #fffaf8; }
.field.is-invalid .input-wrap .input { background: transparent; }
.input:disabled, .select:disabled, .textarea:disabled, .input[readonly] { background: var(--bw-paper); color: var(--bw-muted); cursor: not-allowed; }

/* ---------- Checkbox, radio, consent and choice cards ---------- */
.check { display: inline-flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: var(--bw-t-15); line-height: 1.45; }
.check input, .chip input, .choice input, .seg input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.box, .chip-box {
  position: relative; flex: none; width: 18px; height: 18px; margin-top: 1px;
  border: 1.5px solid #bfae90; border-radius: 4px; background: var(--bw-sheet);
  transition: background-color var(--bw-d-150) var(--bw-out), border-color var(--bw-d-150) var(--bw-out);
}
.box::after, .chip-box::after {
  content: ""; position: absolute; left: 5px; top: 1.5px; width: 5px; height: 9px;
  border: solid #fff8f0; border-width: 0 2px 2px 0;
  transform: rotate(45deg) scale(.4); opacity: 0;
  transition: transform var(--bw-d-150) var(--bw-out), opacity var(--bw-d-100) var(--bw-out);
}
.check input:checked + .box, .chip input:checked + .chip-box, .choice input:checked + .box { background: var(--bw-oxblood); border-color: var(--bw-oxblood); }
.check input:checked + .box::after, .chip input:checked + .chip-box::after, .choice input:checked + .box::after { transform: rotate(45deg) scale(1); opacity: 1; }
.check input:focus-visible + .box, .chip input:focus-visible + .chip-box, .choice input:focus-visible + .box { outline: 2px solid var(--bw-oxblood); outline-offset: 2px; }
.box.is-radio { border-radius: 50%; }
.box.is-radio::after { left: 4px; top: 4px; width: 7px; height: 7px; border: 0; border-radius: 50%; background: #fff8f0; transform: scale(.4); }
.check input:checked + .box.is-radio::after, .choice input:checked + .box.is-radio::after { transform: scale(1); }

/* Consent card: a checkbox in a box that tints once ticked ("I recorded this on my own X account") */
.consent {
  display: flex; gap: 12px; padding: 16px; border: 1px solid var(--bw-line); border-radius: var(--bw-r-md);
  background: var(--bw-sheet); cursor: pointer; line-height: 1.5;
  transition: background-color var(--bw-d-150) var(--bw-out), border-color var(--bw-d-150) var(--bw-out);
}
.consent input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.consent:has(input:checked) { background: var(--bw-ox-tint); border-color: #e2b9b0; }
.consent input:checked + .box { background: var(--bw-oxblood); border-color: var(--bw-oxblood); }
.consent input:checked + .box::after { transform: rotate(45deg) scale(1); opacity: 1; }
.consent input:focus-visible + .box { outline: 2px solid var(--bw-oxblood); outline-offset: 2px; }
.consent .hint { display: block; margin-top: 4px; }

/* Choice cards: pick one way ("Post it for me" / "I will post it") */
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--bw-s-3); }
.choice {
  position: relative; display: flex; gap: 12px; padding: 16px; cursor: pointer;
  border: 1px solid var(--bw-line); border-radius: var(--bw-r-md); background: var(--bw-sheet);
  transition: border-color var(--bw-d-150) var(--bw-out), box-shadow var(--bw-d-150) var(--bw-out), background-color var(--bw-d-150) var(--bw-out);
}
@media (hover: hover) { .choice:hover { border-color: #c8b79b; } }
.choice:has(input:checked) { border-color: var(--bw-oxblood); box-shadow: inset 0 0 0 1px var(--bw-oxblood); background: #fffaf7; }
.choice b { display: block; font-weight: 600; }
.choice span.hint { display: block; margin-top: 2px; }

/* Segmented control (Week / Month, filters). Radios, no JS */
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: var(--bw-r-sm); background: var(--bw-ink-wash); }
.seg label { position: relative; }
.seg input + span { display: inline-flex; align-items: center; gap: 8px; min-height: 32px; padding: 0 12px; border-radius: 4px; font-size: var(--bw-t-14); font-weight: 500; color: var(--bw-muted); cursor: pointer; transition: background-color var(--bw-d-150) var(--bw-out), color var(--bw-d-150) var(--bw-out); }
.seg input:checked + span { background: var(--bw-sheet); color: var(--bw-ink); box-shadow: var(--bw-sh-1); font-weight: 600; }
.seg input:focus-visible + span { outline: 2px solid var(--bw-oxblood); outline-offset: 1px; }

/* Tabs: links or buttons with aria-current / aria-selected */
.tabs { display: flex; gap: var(--bw-s-6); border-bottom: 1px solid var(--bw-line); overflow-x: auto; scrollbar-width: none; }
.tab { position: relative; display: inline-flex; align-items: center; gap: 8px; padding: 12px 0; font-weight: 500; color: var(--bw-muted); text-decoration: none; white-space: nowrap; }
.tab:hover { color: var(--bw-ink); }
.tab::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--bw-oxblood); transform: scaleX(0); transition: transform var(--bw-d-200) var(--bw-out); }
.tab[aria-current], .tab[aria-selected="true"] { color: var(--bw-ink); font-weight: 600; }
.tab[aria-current]::after, .tab[aria-selected="true"]::after { transform: scaleX(1); }
.count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--bw-r-pill); background: var(--bw-ink-wash); font-size: 12px; font-weight: 600; color: var(--bw-muted); font-variant-numeric: tabular-nums; }

/* ---------- Checkbox chips (topic picker) ---------- */
.chips { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--bw-s-2); }
@media (max-width: 640px) { .chips { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.chip {
  position: relative; display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 8px 12px;
  border: 1px solid var(--bw-line); border-radius: var(--bw-r-sm); background: var(--bw-sheet);
  font-size: var(--bw-t-14); font-weight: 500; cursor: pointer; user-select: none;
  transition: border-color var(--bw-d-150) var(--bw-out), background-color var(--bw-d-150) var(--bw-out), box-shadow var(--bw-d-150) var(--bw-out), transform var(--bw-d-100) var(--bw-out);
}
@media (hover: hover) { .chip:hover { border-color: #c8b79b; } }
.chip:active { transform: scale(.98); }
.chip-box { border-radius: 50%; margin-top: 0; }
.chip-box::after { left: 4.5px; top: 1.5px; }
.chip:has(input:checked) { border-color: var(--bw-oxblood); background: var(--bw-ox-tint); box-shadow: inset 0 0 0 1px var(--bw-oxblood); color: var(--bw-wax); font-weight: 600; }
.chips-inline { display: flex; flex-wrap: wrap; }
.chips-inline .chip { min-height: 36px; padding: 6px 12px 6px 10px; border-radius: var(--bw-r-pill); }

/* ---------- Rates and the price stepper ---------- */
.rates { border: 1px solid var(--bw-line); border-radius: var(--bw-r-md); background: var(--bw-sheet); overflow: hidden; }
.rates-head { display: flex; justify-content: space-between; padding: 10px 16px; background: var(--bw-paper); border-bottom: 1px solid var(--bw-line-soft); font: var(--bw-label-weight) var(--bw-t-12)/1.2 var(--bw-label); letter-spacing: .06em; text-transform: uppercase; color: var(--bw-muted); }
.rates-head small { font: 400 var(--bw-t-13) var(--bw-body); letter-spacing: 0; text-transform: none; margin-left: 8px; }
.rate { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 6px 16px; padding: 12px 16px; border-bottom: 1px solid var(--bw-line-soft); }
.rate:last-child { border-bottom: 0; }
.rate .check b { font-weight: 600; }
.rate .check .hint { margin-left: 6px; }
.rate .stepper-note { grid-column: 2; justify-self: end; }
.rate.is-off .stepper { opacity: .4; pointer-events: none; }
.rate.is-off .stepper-note { visibility: hidden; }
@media (max-width: 560px) {
  .rate { grid-template-columns: 1fr; }
  .rate .stepper { justify-self: start; margin-left: 28px; }
  .rate .stepper-note { grid-column: 1; justify-self: start; margin-left: 28px; }
}

.stepper { display: inline-flex; align-items: stretch; height: 40px; border: 1px solid var(--bw-line); border-radius: var(--bw-r-sm); background: var(--bw-sheet); transition: border-color var(--bw-d-150) var(--bw-out), box-shadow var(--bw-d-150) var(--bw-out), opacity var(--bw-d-150) var(--bw-out); }
.stepper:focus-within { border-color: var(--bw-oxblood); box-shadow: var(--bw-focus); }
.stepper-btn { width: 40px; touch-action: manipulation; display: grid; place-items: center; color: var(--bw-muted); transition: background-color var(--bw-d-150) var(--bw-out), color var(--bw-d-150) var(--bw-out); }
.stepper-btn:hover { background: var(--bw-ink-wash); color: var(--bw-ink); }
/* The ring sits inside each button, so keyboard users see which of minus, price or plus has focus */
.stepper-btn:focus-visible { outline: 2px solid var(--bw-oxblood); outline-offset: -3px; animation: none; }
.stepper-btn:active .i { transform: scale(.85); }
.stepper-btn .i { width: 16px; height: 16px; transition: transform var(--bw-d-100) var(--bw-out); }
.stepper-btn:first-child { border-right: 1px solid var(--bw-line-soft); border-radius: var(--bw-r-sm) 0 0 var(--bw-r-sm); }
.stepper-btn:last-child { border-left: 1px solid var(--bw-line-soft); border-radius: 0 var(--bw-r-sm) var(--bw-r-sm) 0; }
.stepper-field { display: flex; align-items: center; gap: 2px; padding: 0 10px; cursor: text; }
.stepper-field span { color: var(--bw-muted); font-size: var(--bw-t-15); }
.stepper-input { width: 4.5ch; align-self: stretch; border: 0; background: transparent; padding: 0; font-weight: 600; font-variant-numeric: tabular-nums; text-align: left; }
.stepper-input:focus { outline: none; }
.stepper-note { display: inline-flex; align-items: center; gap: 6px; min-height: 20px; font-size: var(--bw-t-13); color: var(--bw-muted); }
.stepper-note .i { width: 15px; height: 15px; }
.stepper-note.is-ok { color: var(--bw-ok); }
.stepper-note.is-ok .i { animation: bw-pop var(--bw-d-200) var(--bw-out); }
.stepper-note.is-bad { color: var(--bw-bad); }
.stepper-note.is-checking::before { content: ""; width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid currentColor; border-right-color: transparent; animation: bw-spin 700ms linear infinite; }

/* ---------- Code input (6 digits) ---------- */
.code { display: inline-flex; align-items: center; gap: 8px; }
.code-cell {
  width: 46px; height: 54px; text-align: center; padding: 0;
  font: var(--bw-label-weight) 22px/1 var(--bw-label); color: var(--bw-ink);
  background: var(--bw-sheet); border: 1px solid var(--bw-line); border-radius: var(--bw-r-sm);
  caret-color: var(--bw-oxblood);
  transition: border-color var(--bw-d-150) var(--bw-out), box-shadow var(--bw-d-150) var(--bw-out), transform var(--bw-d-150) var(--bw-out), background-color var(--bw-d-150) var(--bw-out);
}
.code-cell:focus { outline: none; border-color: var(--bw-oxblood); box-shadow: var(--bw-focus); }
.code-cell.is-filled { border-color: #bfae90; }
.code-gap { width: 8px; height: 2px; background: var(--bw-line); border-radius: 2px; }
.code.is-invalid .code-cell { border-color: var(--bw-oxblood); background: #fffaf8; }
.code.is-ok .code-cell { border-color: var(--bw-ok); background: var(--bw-ok-bg); color: var(--bw-ok); }
.code.is-busy .code-cell { opacity: .6; }
@media (max-width: 400px) { .code { gap: 6px; } .code-cell { width: 40px; height: 50px; } .code-gap { width: 4px; } }

/* ---------- Dropzone and progress ---------- */
.drop { display: grid; gap: var(--bw-s-2); }
.drop-input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.drop-area {
  display: grid; justify-items: center; gap: 6px; padding: 28px 20px; text-align: center; cursor: pointer;
  border: 1.5px dashed #cdbd9f; border-radius: var(--bw-r-md); background: var(--bw-sheet);
  transition: border-color var(--bw-d-150) var(--bw-out), background-color var(--bw-d-150) var(--bw-out);
}
@media (hover: hover) { .drop-area:hover { border-color: #b39f7d; } }
.drop-input:focus-visible + .drop-area { outline: 2px solid var(--bw-oxblood); outline-offset: 2px; }
.drop-area .i { width: 22px; height: 22px; color: var(--bw-muted); transition: transform var(--bw-d-200) var(--bw-out); }
.drop-area b { font-weight: 600; }
.drop-area .btn { margin-top: 6px; pointer-events: none; }
.drop.is-over .drop-area { border-color: var(--bw-oxblood); background: var(--bw-ox-tint); }
.drop.is-over .drop-area .i { transform: translateY(-3px); color: var(--bw-oxblood); }
.drop-file {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 4px 12px; padding: 14px 16px;
  border: 1px solid var(--bw-line); border-radius: var(--bw-r-md); background: var(--bw-sheet);
  animation: bw-enter var(--bw-d-200) var(--bw-out);
}
.drop-file-icon { grid-row: span 2; width: 40px; height: 40px; display: grid; place-items: center; border-radius: var(--bw-r-sm); background: var(--bw-paper); border: 1px solid var(--bw-line-soft); color: var(--bw-muted); }
.drop-file-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.drop-file-meta { grid-column: 2; font-size: var(--bw-t-13); color: var(--bw-muted); font-variant-numeric: tabular-nums; }
.drop-file .icon-btn { grid-row: 1 / span 2; grid-column: 3; }
.drop-file .progress { grid-column: 1 / -1; margin-top: 8px; }
.drop.is-done .drop-file-icon { background: var(--bw-ok-bg); border-color: transparent; color: var(--bw-ok); }
.drop.is-done .drop-file-meta { color: var(--bw-ok); }
.drop.is-done .progress { display: none; }
.drop.is-error .drop-file { border-color: var(--bw-oxblood); }
.drop.is-error .drop-file-meta { color: var(--bw-bad); }

.progress { height: 6px; border-radius: var(--bw-r-pill); background: var(--bw-line-soft); overflow: hidden; }
.progress-bar { height: 100%; width: 100%; background: var(--bw-oxblood); border-radius: inherit; transform-origin: left; transform: scaleX(var(--p, 0)); transition: transform var(--bw-d-200) var(--bw-out); }
.progress.is-indeterminate .progress-bar { width: 40%; animation: bw-slide 1.1s var(--bw-out) infinite; transform: none; }

/* ---------- Badges and stamps ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px;
  border-radius: var(--bw-r-pill); font-size: 12.5px; font-weight: 600; white-space: nowrap; line-height: 1;
  background: var(--bw-ink-wash); color: var(--bw-ink);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge.no-dot::before { display: none; }
.badge-review { background: #ece4d6; color: #4d443c; }
.badge-review::before { background: var(--bw-brass); opacity: 1; }
.badge-ok { background: var(--bw-ok-bg); color: var(--bw-ok); }
.badge-needs { background: var(--bw-warn-bg); color: var(--bw-warn); box-shadow: inset 0 0 0 1px var(--bw-warn-line); }
.badge-bad { background: var(--bw-bad-bg); color: var(--bw-oxblood); }
.badge-paused { background: transparent; color: var(--bw-muted); box-shadow: inset 0 0 0 1px var(--bw-line); }
.badge-paused::before { background: var(--bw-faint); }
.badge-live { background: var(--bw-oxblood); color: #fff8f0; }
.badge-live::before { background: #fff8f0; }

/* The stamp: one word, past tense, for the moment something happened (RECEIVED, APPROVED, PAID) */
.stamp {
  display: inline-block; padding: 6px 10px 5px; border: 3px solid currentColor; border-radius: 6px;
  outline: 1px solid currentColor; outline-offset: -7px;
  font: 700 18px/1 var(--bw-stamp); letter-spacing: .1em; text-transform: uppercase;
  color: var(--bw-oxblood); transform: rotate(var(--tilt, -4deg)); user-select: none;
}
.stamp-sm { font-size: 12px; border-width: 2px; padding: 4px 6px 3px; outline: 0; }
.stamp-lg { font-size: 30px; padding: 10px 16px 9px; border-width: 4px; outline-offset: -9px; }
.stamp-ok { color: var(--bw-ok); }
.stamp.is-landing { animation: bw-stamp var(--bw-stamp-in) var(--bw-out) both; }

/* Step label: STEP 2 OF 6, ANALYTICS RECORDING */
.step-label {
  display: inline-flex; align-items: center; gap: 8px; padding: 4px 8px 3px;
  border: 1px solid rgba(140, 28, 19, .35); border-radius: 4px; background: var(--bw-sheet);
  font: var(--bw-label-weight) var(--bw-t-12)/1.2 var(--bw-label); letter-spacing: .06em; text-transform: uppercase; color: var(--bw-oxblood);
}

/* ---------- Cards, stats, notices ---------- */
.card { background: var(--bw-sheet); border: 1px solid var(--bw-line); border-radius: var(--bw-r-md); padding: var(--bw-s-6); box-shadow: var(--bw-sh-1); }
.card-flat { box-shadow: none; }
.card-quiet { background: var(--bw-paper); border-color: var(--bw-line-soft); box-shadow: none; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--bw-s-4); margin-bottom: var(--bw-s-4); }
.card-head h2, .card-head h3 { font: 600 16px/1.35 var(--bw-body); color: var(--bw-ink); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card-head p { margin-top: 2px; }
.card-link { display: block; text-decoration: none; transition: border-color var(--bw-d-150) var(--bw-out), box-shadow var(--bw-d-150) var(--bw-out), transform var(--bw-d-150) var(--bw-out); }
@media (hover: hover) { .card-link:hover { border-color: #c8b79b; box-shadow: var(--bw-sh-2); } }
.card-list { display: grid; gap: var(--bw-s-3); }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--bw-s-4); }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--bw-s-4); }

.stat { display: grid; gap: 6px; align-content: start; }
.stat-num { font: var(--bw-display-weight) var(--bw-t-48)/.95 var(--bw-display); letter-spacing: var(--bw-display-track); color: var(--bw-ink); font-variant-numeric: lining-nums; }
.stat-num .cur, .stat-num .cents { font-size: .5em; color: var(--bw-muted); vertical-align: .8em; margin-right: 1px; }
.stat-num .cents { vertical-align: baseline; margin: 0 0 0 1px; }
.stat-label { font-size: var(--bw-t-13); color: var(--bw-muted); }
.stat-sm .stat-num { font-size: 28px; }
.example-tag { display: inline-block; font: var(--bw-label-weight) 12px/1 var(--bw-label); letter-spacing: .04em; text-transform: uppercase; color: var(--bw-muted); border: 1px dashed var(--bw-line); border-radius: 3px; padding: 2px 4px 1px; vertical-align: 1px; }

.dl { display: grid; grid-template-columns: max-content 1fr; gap: 10px 24px; font-size: var(--bw-t-14); }
.dl dt { color: var(--bw-muted); }
.dl dd { font-weight: 500; min-width: 0; overflow-wrap: anywhere; }

.notice { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--bw-r-md); background: var(--bw-ink-wash); font-size: var(--bw-t-14); line-height: 1.5; }
.notice > .i { margin-top: 1px; color: var(--bw-muted); }
.notice-body { flex: 1; min-width: 0; display: grid; gap: 10px; justify-items: start; }
.notice b { font-weight: 600; }
.notice-ox { background: var(--bw-ox-tint); color: var(--bw-wax); }
.notice-ox > .i { color: var(--bw-oxblood); }
.notice-needs { background: var(--bw-warn-bg); color: #4f3a0f; box-shadow: inset 0 0 0 1px var(--bw-warn-line); padding: 16px; }
.notice-needs > .i { color: var(--bw-warn); }
.notice-ok { background: var(--bw-ok-bg); color: #24502e; }
.notice-ok > .i { color: var(--bw-ok); }
.notice-bad { background: var(--bw-bad-bg); color: var(--bw-wax); }
.notice-bad > .i { color: var(--bw-oxblood); }

.divider { border: 0; border-top: 1px solid var(--bw-line); margin: var(--bw-s-8) 0; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--bw-line); border-radius: var(--bw-r-md); background: var(--bw-sheet); -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: var(--bw-t-14); font-variant-numeric: tabular-nums; }
.table th { position: sticky; top: 0; background: var(--bw-paper); text-align: left; font: var(--bw-label-weight) var(--bw-t-12)/1.2 var(--bw-label); letter-spacing: .06em; text-transform: uppercase; color: var(--bw-muted); padding: 11px 16px; border-bottom: 1px solid var(--bw-line); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--bw-line-soft); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background-color var(--bw-d-100) var(--bw-out); }
@media (hover: hover) { .table tbody tr:hover { background: #fdf8f1; } }
.table .num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; white-space: nowrap; }
.table tr.is-selected { background: var(--bw-ox-tint); }
.cell-user { display: flex; align-items: center; gap: 10px; min-width: 180px; }
.cell-user b { font-weight: 600; display: block; line-height: 1.25; }
.cell-user span { font-size: var(--bw-t-13); color: var(--bw-muted); }
.table-tools { display: flex; flex-wrap: wrap; gap: var(--bw-s-3); align-items: center; justify-content: space-between; margin-bottom: var(--bw-s-3); }
.search { position: relative; flex: 1 1 240px; max-width: 360px; }
.search .i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--bw-muted); pointer-events: none; }
.search .input { padding-left: 38px; }

/* ---------- Week calendar ---------- */
.week { display: grid; gap: var(--bw-s-4); container-type: inline-size; }
.week-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--bw-s-2); }
.week-range { font-weight: 600; min-width: 112px; text-align: center; font-variant-numeric: tabular-nums; }
.week-bar .seg { margin-left: auto; }
.week-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: var(--bw-s-2); }
.week-day { display: grid; grid-template-rows: auto 1fr; gap: 6px; min-height: 180px; min-width: 0; }
.week-day header { display: flex; align-items: baseline; gap: 6px; padding: 0 4px; font-size: var(--bw-t-13); color: var(--bw-muted); }
.week-day header b { font: var(--bw-display-weight) 22px/1 var(--bw-display); color: var(--bw-ink); }
.week-day.is-today header b { display: inline-grid; place-items: center; min-width: 28px; height: 28px; padding: 0 4px; border-radius: var(--bw-r-pill); background: var(--bw-oxblood); color: #fff8f0; font: 600 13px/1 var(--bw-body); font-variant-numeric: tabular-nums; }
.week-day ul { list-style: none; padding: 6px; display: grid; align-content: start; gap: 6px; border-radius: var(--bw-r-md); background: var(--bw-paper); border: 1px solid var(--bw-line-soft); }
.week-day.is-today ul { border-color: #e2b9b0; background: #fdf6f2; }
.week-day.is-weekend ul { background: transparent; border-style: dashed; }
.week-event { display: grid; gap: 2px; padding: 7px 8px; border-radius: 6px; background: var(--bw-sheet); border: 1px solid var(--bw-line); border-left: 3px solid var(--bw-ink); font-size: var(--bw-t-13); line-height: 1.3; min-width: 0; }
.week-event time { font: var(--bw-label-weight) 12px/1.2 var(--bw-label); letter-spacing: .04em; color: var(--bw-muted); }
.week-event b { font-weight: 600; overflow-wrap: anywhere; }
.week-event.is-launch { border-left-color: var(--bw-oxblood); }
.week-event.is-due { border-left-color: var(--bw-brass); }
.week-event.is-paid { border-left-color: var(--bw-ok); }
.week-empty { padding: 4px; font-size: 12px; color: var(--bw-muted); }
@container (max-width: 720px) {
  .week-grid { grid-template-columns: 1fr; gap: 0; border: 1px solid var(--bw-line); border-radius: var(--bw-r-md); background: var(--bw-sheet); overflow: hidden; }
  .week-day { grid-template-columns: 64px 1fr; grid-template-rows: none; min-height: 0; gap: 12px; padding: 12px; border-bottom: 1px solid var(--bw-line-soft); }
  .week-day:last-child { border-bottom: 0; }
  .week-day header { flex-direction: column; align-items: flex-start; gap: 4px; padding: 2px 0 0; }
  .week-day ul, .week-day.is-today ul, .week-day.is-weekend ul { padding: 0; border: 0; background: transparent; }
  .week-day.is-today { background: #fdf6f2; }
  .week-bar .seg { margin-left: 0; }
}

/* ---------- Empty states ---------- */
.empty { display: grid; justify-items: center; text-align: center; gap: 6px; padding: 48px 24px; border: 1px dashed var(--bw-line); border-radius: var(--bw-r-md); background: var(--bw-paper); }
.empty-mark { width: 40px; height: 40px; color: #cdbd9f; margin-bottom: 6px; }
.empty h3 { font: 600 16px/1.35 var(--bw-body); }
.empty p { color: var(--bw-muted); font-size: var(--bw-t-14); max-width: 44ch; }
.empty .btn { margin-top: 10px; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; z-index: var(--bw-z-toast); right: 20px; bottom: 20px; display: grid; gap: 8px; justify-items: end; pointer-events: none; width: min(380px, calc(100vw - 32px)); }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 12px 12px 12px 14px; border-radius: var(--bw-r-md);
  background: var(--bw-ink); color: var(--bw-cream); box-shadow: var(--bw-sh-3);
  font-size: var(--bw-t-14); line-height: 1.4;
  animation: bw-toast-in var(--bw-d-200) var(--bw-out) both;
}
.toast > .i { color: #d8c9b0; }
.toast.is-ok > .i { color: #9fd0a6; }
.toast.is-bad > .i { color: #f0a597; }
.toast-text { flex: 1; min-width: 0; }
.toast .toast-action { color: #fff; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; padding: 4px 6px; border-radius: 4px; }
.toast .icon-btn { width: 28px; height: 28px; color: #bdb2a3; }
.toast .icon-btn:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.toast.is-leaving { animation: bw-toast-out var(--bw-d-150) var(--bw-in) both; }
@media (max-width: 640px) { .toasts { left: 16px; right: 16px; bottom: 16px; width: auto; justify-items: stretch; } }

/* ---------- Dialog ---------- */
.dialog {
  width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); padding: 0; margin: auto;
  border: 1px solid var(--bw-line); border-radius: var(--bw-r-lg); background: var(--bw-sheet); color: var(--bw-ink);
  box-shadow: var(--bw-sh-3);
}
.dialog[open] { animation: bw-dialog-in var(--bw-d-200) var(--bw-out); }
.dialog::backdrop { background: rgba(31, 27, 24, .4); }
.dialog[open]::backdrop { animation: bw-fade var(--bw-d-200) var(--bw-out); }
.dialog.is-closing { animation: bw-dialog-out var(--bw-d-150) var(--bw-in) forwards; }
.dialog.is-closing::backdrop { animation: bw-fade-out var(--bw-d-150) var(--bw-in) forwards; }
.dialog-head { display: flex; justify-content: space-between; gap: 12px; padding: 20px 20px 0 24px; }
.dialog-head h2 { font: var(--bw-display-weight) 28px/1.1 var(--bw-display); letter-spacing: var(--bw-display-track); }
.dialog-body { padding: 12px 24px 20px; display: grid; gap: var(--bw-s-4); }
.dialog-foot { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: var(--bw-s-2); padding: 16px 24px; border-top: 1px solid var(--bw-line-soft); background: var(--bw-paper); border-radius: 0 0 var(--bw-r-lg) var(--bw-r-lg); }

/* ---------- Loaders ---------- */
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--bw-line); border-top-color: var(--bw-oxblood); animation: bw-spin 700ms linear infinite; }
.skel { border-radius: 4px; background: linear-gradient(90deg, var(--bw-line-soft) 0 40%, #f3ebdd 50%, var(--bw-line-soft) 60% 100%); background-size: 300% 100%; animation: bw-shimmer 1.4s linear infinite; }
.skel-line { height: 12px; }
.skel-title { height: 22px; width: 50%; }
.skel-circle { border-radius: 50%; }

/* ---------- Avatars and the handle chip ---------- */
.avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; flex: none; background: var(--bw-ox-tint); color: var(--bw-wax); display: inline-grid; place-items: center; font: 600 13px/1 var(--bw-body); box-shadow: 0 0 0 1px rgba(31, 27, 24, .08); overflow: hidden; }
.avatar-sm { width: 24px; height: 24px; font-size: 12px; }
.avatar-lg { width: 64px; height: 64px; font-size: 22px; }
.handle-chip { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px 0 4px; border-radius: var(--bw-r-pill); background: var(--bw-sheet); border: 1px solid var(--bw-line); font-size: var(--bw-t-14); font-weight: 600; max-width: 100%; min-width: 0; text-decoration: none; }
.handle-chip .avatar { width: 28px; height: 28px; font-size: 12px; }
.handle-chip .handle { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.handle-chip .pre { font-weight: 400; color: var(--bw-muted); }
.handle-chip.no-avatar { padding-left: 12px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--bw-brass); flex: none; }
.dot-ok { background: var(--bw-ok); }
.dot-ox { background: var(--bw-oxblood); }
.dot-muted { background: var(--bw-faint); }

/* ---------- Logo ---------- */
.logo { display: inline-flex; align-items: center; gap: 9px; color: var(--bw-oxblood); text-decoration: none; min-width: 0; }
.logo-wheel { width: 28px; height: 28px; flex: none; transition: transform var(--bw-d-300) var(--bw-out); }
@media (hover: hover) { .logo:hover .logo-wheel { transform: rotate(45deg); } }
.logo-word { font: 900 21px/1 var(--bw-mark); letter-spacing: -.01em; white-space: nowrap; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: var(--bw-sidebar) minmax(0, 1fr); min-height: 100dvh; }
.app-side {
  position: sticky; top: 0; height: 100dvh; z-index: var(--bw-z-sidebar);
  display: flex; flex-direction: column; gap: var(--bw-s-4); padding: 14px 12px 12px;
  background: var(--bw-cream); border-right: 1px solid var(--bw-line); overflow-y: auto; overflow-x: hidden;
}
.side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 40px; padding: 0 0 0 8px; }
.side-nav { display: grid; gap: var(--bw-s-4); align-content: start; flex: 1; }
.nav-group { list-style: none; padding: 0; display: grid; gap: 2px; }
.nav-label { padding: 0 10px; margin-bottom: 4px; font-size: 12px; font-weight: 600; color: var(--bw-muted); white-space: nowrap; }
.nav-link {
  position: relative; display: flex; align-items: center; gap: 11px; min-height: 38px; padding: 0 10px;
  border-radius: var(--bw-r-sm); color: #4a423b; font-size: var(--bw-t-14); font-weight: 500; text-decoration: none; white-space: nowrap;
  transition: background-color var(--bw-d-150) var(--bw-out), color var(--bw-d-150) var(--bw-out);
}
.nav-link .i { color: var(--bw-muted); transition: color var(--bw-d-150) var(--bw-out); }
.nav-link:hover { background: var(--bw-ink-wash); color: var(--bw-ink); }
.nav-link[aria-current="page"] { background: var(--bw-sheet); color: var(--bw-oxblood); font-weight: 600; box-shadow: var(--bw-sh-1), inset 0 0 0 1px var(--bw-line-soft); }
.nav-link[aria-current="page"] .i { color: var(--bw-oxblood); }
.nav-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; transition: opacity var(--bw-d-150) var(--bw-out); }
.nav-link .count { background: var(--bw-warn-bg); color: var(--bw-warn); }
.side-foot { display: grid; gap: 2px; padding-top: var(--bw-s-3); border-top: 1px solid var(--bw-line); }

.app-body { min-width: 0; display: flex; flex-direction: column; background: var(--bw-paper); }
.app-top {
  position: sticky; top: 0; z-index: var(--bw-z-topbar);
  display: flex; align-items: center; gap: var(--bw-s-3); min-height: var(--bw-topbar); padding: 0 var(--bw-gutter);
  background: rgba(251, 248, 242, .92); backdrop-filter: saturate(1.2) blur(8px); -webkit-backdrop-filter: saturate(1.2) blur(8px);
  border-bottom: 1px solid var(--bw-line-soft);
}
.app-top .top-end { margin-left: auto; display: flex; align-items: center; gap: var(--bw-s-2); }
.app-menu, .app-top .logo { display: none; }
.app-main { flex: 1; padding: var(--bw-s-10) var(--bw-gutter) var(--bw-s-16); }
.page { max-width: var(--bw-content); margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--bw-s-8); }
.page-wide { max-width: 1160px; }
.page-head { display: grid; gap: 8px; }
.page-head-row { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--bw-s-4); }
.section { display: grid; gap: var(--bw-s-4); }
.section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--bw-s-3); }
.section-head h2 { font: 600 17px/1.35 var(--bw-body); display: flex; align-items: center; gap: 10px; }
.app-scrim { display: none; }

/* Collapsed sidebar (desktop) */
.app.is-collapsed { grid-template-columns: var(--bw-sidebar-collapsed) minmax(0, 1fr); }
.app.is-collapsed .app-side { padding-inline: 10px; }
.app.is-collapsed .side-head { flex-direction: column; padding: 0; gap: 10px; }
.app.is-collapsed .logo-word, .app.is-collapsed .nav-label { display: none; }
.app.is-collapsed .nav-link { justify-content: center; padding: 0; }
.app.is-collapsed .nav-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); opacity: 0; }
.app.is-collapsed .nav-link .count { position: absolute; top: 1px; right: 1px; min-width: 18px; height: 18px; padding: 0 4px; font-size: 12px; }
.app.is-collapsed .nav-group + .nav-label, .app.is-collapsed .side-nav > .nav-group + .nav-group { border-top: 1px solid var(--bw-line); padding-top: var(--bw-s-3); }
.app.is-collapsed .side-collapse .i { transform: scaleX(-1); }

@media (max-width: 900px) {
  .app, .app.is-collapsed { grid-template-columns: minmax(0, 1fr); }
  .app-side {
    position: fixed; inset: 0 auto 0 0; width: min(288px, 84vw); height: 100dvh;
    box-shadow: var(--bw-sh-3); transform: translateX(-104%); visibility: hidden;
    transition: transform var(--bw-d-200) var(--bw-in), visibility 0s linear var(--bw-d-200);
  }
  .app.is-open .app-side { transform: none; visibility: visible; transition: transform var(--bw-d-300) var(--bw-out), visibility 0s; }
  .app.is-collapsed .app-side { padding-inline: 12px; }
  .app.is-collapsed .side-head { flex-direction: row; padding: 0 0 0 8px; }
  .app.is-collapsed .logo-word, .app.is-collapsed .nav-label { display: initial; }
  .app.is-collapsed .nav-link { justify-content: flex-start; padding: 0 10px; }
  .app.is-collapsed .nav-text { position: static; width: auto; height: auto; clip-path: none; opacity: 1; }
  .app-side .nav-link { min-height: 44px; }
  .side-collapse { display: none; }
  .app-scrim {
    display: block; position: fixed; inset: 0; z-index: calc(var(--bw-z-sidebar) - 1);
    background: rgba(31, 27, 24, .35); opacity: 0; pointer-events: none; transition: opacity var(--bw-d-200) var(--bw-out);
  }
  .app.is-open .app-scrim { opacity: 1; pointer-events: auto; }
  .app-menu { display: inline-grid; margin-left: -8px; }
  .app-top .logo { display: inline-flex; }
  .app-top .logo-wheel { width: 24px; height: 24px; }
  .app-top .logo-word { font-size: 18px; }
  .app-top .top-handle { display: none; }
  .app-main { padding-top: var(--bw-s-8); }
}
@media (max-width: 480px) {
  .app-top .top-end .btn-label { display: none; }
}

/* ---------- Onboarding layout (one question per screen) ---------- */
.ob { min-height: 100dvh; display: grid; grid-template-rows: auto 1fr; }
.ob-top { display: flex; align-items: center; justify-content: space-between; gap: var(--bw-s-3); padding: 16px var(--bw-gutter); }
.ob-body { display: grid; grid-template-columns: 220px minmax(0, 760px); justify-content: center; gap: var(--bw-s-10); padding: var(--bw-s-6) var(--bw-gutter) var(--bw-s-16); align-items: start; }
.ob-card { position: relative; background: var(--bw-paper); border: 1px solid var(--bw-line); border-radius: var(--bw-r-lg); box-shadow: var(--bw-sh-2); min-width: 0; }
/* Ledger margins: two faint rules, like a page in an account book */
.ob-card::before, .ob-card::after { content: ""; position: absolute; top: 0; bottom: 0; width: 1px; background: var(--bw-line-soft); pointer-events: none; }
.ob-card::before { left: 40px; }
.ob-card::after { right: 40px; }
.ob-head { padding: 40px 64px 28px; display: grid; gap: 10px; justify-items: start; border-bottom: 1px solid var(--bw-line-soft); }
.ob-title { font: var(--bw-display-weight) var(--bw-t-36)/1 var(--bw-display); letter-spacing: var(--bw-display-track); margin-top: 4px; }
.ob-lead { color: var(--bw-muted); font-size: 16px; max-width: 58ch; }
.ob-content { padding: 28px 64px; display: grid; gap: var(--bw-s-5); }
.ob-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--bw-s-3); padding: 20px 64px 28px; border-top: 1px solid var(--bw-line-soft); }
.ob-foot .btn-primary { margin-left: auto; }
.ob-foot-note { padding: 0 64px 28px; margin-top: -12px; font-size: var(--bw-t-13); color: var(--bw-muted); }

.steps { position: sticky; top: 24px; display: grid; gap: 10px; }
.steps-title { display: flex; align-items: center; gap: 10px; font-size: var(--bw-t-13); color: var(--bw-muted); padding-left: 2px; }
.steps-title::before { content: ""; width: 16px; height: 1px; background: var(--bw-line); }
.steps ol { list-style: none; padding: 0; display: grid; gap: 2px; counter-reset: step; }
.step a, .step > span { display: flex; align-items: center; gap: 10px; min-height: 38px; padding: 0 10px; border-radius: var(--bw-r-sm); font-size: var(--bw-t-14); color: var(--bw-muted); text-decoration: none; transition: background-color var(--bw-d-150) var(--bw-out), color var(--bw-d-150) var(--bw-out); }
.step { counter-increment: step; }
.step-mark { position: relative; flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--bw-line); background: transparent; font: var(--bw-label-weight) 10.5px/1 var(--bw-label); color: var(--bw-faint); transition: background-color var(--bw-d-200) var(--bw-out), border-color var(--bw-d-200) var(--bw-out), color var(--bw-d-200) var(--bw-out); }
.step-mark::before { content: counter(step, decimal-leading-zero); }
.step.is-done a, .step.is-done > span { color: var(--bw-ink); }
.step.is-done a:hover { background: var(--bw-ink-wash); }
.step.is-done .step-mark { background: var(--bw-ink); border-color: var(--bw-ink); }
.step.is-done .step-mark::before { content: ""; width: 4px; height: 8px; border: solid var(--bw-cream); border-width: 0 1.75px 1.75px 0; transform: translateY(-1px) rotate(45deg); }
.step.is-current a, .step.is-current > span { background: var(--bw-sheet); color: var(--bw-ink); font-weight: 600; box-shadow: var(--bw-sh-1), inset 0 0 0 1px var(--bw-line-soft); }
.step.is-current .step-mark { background: var(--bw-oxblood); border-color: var(--bw-oxblood); color: #fff8f0; }
.steps-bar { display: none; }

@media (max-width: 900px) {
  .ob-body { grid-template-columns: minmax(0, 1fr); gap: var(--bw-s-4); padding-top: 0; }
  .steps { position: static; }
  .steps-title, .steps ol { display: none; }
  .steps-bar { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; }
  .steps-bar i { height: 4px; border-radius: 2px; background: var(--bw-line); }
  .steps-bar i.is-done { background: var(--bw-ink); }
  .steps-bar i.is-current { background: var(--bw-oxblood); }
  .ob-card::before, .ob-card::after { display: none; }
  .ob-head, .ob-content, .ob-foot { padding-inline: 24px; }
  .ob-foot-note { padding-inline: 24px; }
}
@media (max-width: 480px) {
  .ob-top .handle-chip .pre { display: none; }
  .ob-head { padding-top: 28px; }
  .ob-head, .ob-content, .ob-foot, .ob-foot-note { padding-inline: 16px; }
  .ob-card { border-radius: var(--bw-r-md); margin-inline: -4px; }
}

/* ---------- The wax seal: the logo for big moments ---------- */
/* The photo seal, 48px and up only (under that, use the flat twin #bw-wheel). One per view, never in the nav. */
.seal { display: block; width: var(--seal, 112px); height: auto; aspect-ratio: 1; min-width: 48px; flex: none; user-select: none; -webkit-user-drag: none; }
.seal-sm { --seal: 64px; }
.seal-lg { --seal: 160px; }
.moment { display: grid; justify-items: center; text-align: center; gap: 10px; padding: 40px 24px; }
.moment .seal { margin-bottom: 6px; }
.moment h2 { font: var(--bw-display-weight) var(--bw-t-36)/1 var(--bw-display); letter-spacing: var(--bw-display-track); }
.moment p { color: var(--bw-muted); max-width: 46ch; }
.moment .seal.is-landing { animation: bw-seal var(--bw-d-300) var(--bw-out) both; }
@keyframes bw-seal { from { opacity: 0; transform: scale(1.12) rotate(-8deg); } }

/* ---------- Template card (playbook templates with fill-in blanks) ---------- */
.tcard { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; padding: 20px 20px 16px; background: var(--bw-sheet); border: 1px solid var(--bw-line); border-radius: var(--bw-r-md); box-shadow: var(--bw-sh-1); }
.tcard-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.tcard-head h3 { font: 600 16px/1.35 var(--bw-body); }
.tcard-head p { margin-top: 2px; }
.tcard-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: var(--bw-t-15); line-height: 1.75; padding: 14px 16px; border-radius: var(--bw-r-sm); background: var(--bw-paper); border: 1px solid var(--bw-line-soft); }
.blank {
  padding: 1px 4px; margin: 0 1px; border-radius: 3px; outline: none; cursor: text;
  background: var(--bw-warn-bg); box-shadow: inset 0 -2px 0 var(--bw-brass); color: var(--bw-ink); font-weight: 600;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
  transition: background-color var(--bw-d-150) var(--bw-out), box-shadow var(--bw-d-150) var(--bw-out);
}
.blank:empty::before { content: attr(data-ph); color: var(--bw-warn); font-weight: 500; }
.blank:focus { background: #f0d896; box-shadow: inset 0 -2px 0 var(--bw-warn); }
.blank.is-filled { padding: 1px 0; margin: 0; background: transparent; box-shadow: inset 0 -1.5px 0 #d6c39c; }
.blank.is-filled:focus { background: var(--bw-warn-bg); box-shadow: inset 0 -2px 0 var(--bw-brass); }
.tcard.is-ox .blank { background: var(--bw-ox-tint); box-shadow: inset 0 -2px 0 var(--bw-oxblood); }
.tcard.is-ox .blank:empty::before { color: var(--bw-oxblood); }
.tcard.is-ox .blank:focus { background: #f0d3cb; }
.tcard.is-ox .blank.is-filled { background: transparent; box-shadow: inset 0 -1.5px 0 #e2b9b0; }
.tcard.is-ox .blank.is-filled:focus { background: var(--bw-ox-tint); box-shadow: inset 0 -2px 0 var(--bw-oxblood); }
.tcard-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.tcard-left { margin-right: auto; font-size: var(--bw-t-13); color: var(--bw-muted); font-variant-numeric: tabular-nums; }
.tcard-stamp { --tilt: -6deg; opacity: 0; transition: opacity var(--bw-d-300) var(--bw-in); pointer-events: none; }
.tcard.is-copied .tcard-stamp { opacity: 1; transition: none; }

/* =====================================================================
   Motion and polish layer (docs/app/UI.md, "Motion and polish").
   Durations 100 / 150 / 200 / 300 ms; one deliberate moment per view may run 600 ms (number roll).
   Transform and opacity only, plus a light blur on reveal and the accordion's height (documented exceptions).
   ===================================================================== */

/* Focus rings draw in instead of popping */
:focus-visible { animation: bw-ring var(--bw-d-150) var(--bw-out); }
@keyframes bw-ring { from { outline-offset: 6px; outline-color: transparent; } }

/* Reveal: blur-to-sharp and fade up. Only hidden once ui.js has marked the page (html.bw-js), so no JS means no hidden content */
.bw-js [data-reveal]:not(.is-in) { opacity: 0; transform: translateY(10px); filter: blur(6px); }
[data-reveal].is-in { transition: opacity var(--bw-d-300) var(--bw-out), transform var(--bw-d-300) var(--bw-out), filter var(--bw-d-300) var(--bw-out); transition-delay: var(--bw-delay, 0ms); }

/* Step and page transitions. Same-site page loads cross-fade; the sidebar and top bar stay put */
@view-transition { navigation: auto; }
.app-side { view-transition-name: bw-side; }
.app-top { view-transition-name: bw-top; }
.ob-top { view-transition-name: bw-obtop; }
.steps { view-transition-name: bw-steps; }
.ob-content, [data-swap] { view-transition-name: bw-step; }
::view-transition-old(root) { animation: bw-vt-out var(--bw-d-150) var(--bw-in) both; }
::view-transition-new(root) { animation: bw-vt-in var(--bw-d-200) var(--bw-out) both; }
::view-transition-old(bw-step) { animation: bw-step-out var(--bw-d-150) var(--bw-in) both; }
::view-transition-new(bw-step) { animation: bw-step-in var(--bw-d-300) var(--bw-out) both; }
[data-bw-dir="back"]::view-transition-old(bw-step) { animation-name: bw-step-out-back; }
[data-bw-dir="back"]::view-transition-new(bw-step) { animation-name: bw-step-in-back; }
::view-transition-group(bw-step) { animation-duration: var(--bw-d-300); animation-timing-function: var(--bw-out); }
@keyframes bw-vt-out { to { opacity: 0; } }
@keyframes bw-vt-in { from { opacity: 0; transform: translateY(6px); } }
@keyframes bw-step-out { to { opacity: 0; transform: translateX(-24px); filter: blur(2px); } }
@keyframes bw-step-in { from { opacity: 0; transform: translateX(32px); filter: blur(2px); } }
@keyframes bw-step-out-back { to { opacity: 0; transform: translateX(24px); filter: blur(2px); } }
@keyframes bw-step-in-back { from { opacity: 0; transform: translateX(-32px); filter: blur(2px); } }
/* Fallback when the browser has no View Transitions */
.bw-swap-out-forward { animation: bw-step-out var(--bw-d-150) var(--bw-in) both; }
.bw-swap-out-back { animation: bw-step-out-back var(--bw-d-150) var(--bw-in) both; }
.bw-swap-in-forward { animation: bw-step-in var(--bw-d-300) var(--bw-out) both; }
.bw-swap-in-back { animation: bw-step-in-back var(--bw-d-300) var(--bw-out) both; }

/* Number roll: digits stay steady in tables (tabular Inter Tight); the serif stat number gets a locked box from ui.js */
[data-count] { font-variant-numeric: tabular-nums lining-nums; }

/* Blur-up images: soft and faint until loaded, then sharp. Put them on a .skel-backed frame if you like */
img.bw-img { opacity: 0; filter: blur(10px); transform: scale(1.02); transition: opacity var(--bw-d-300) var(--bw-out), filter var(--bw-d-300) var(--bw-out), transform var(--bw-d-300) var(--bw-out); }
img.bw-img.is-loaded { opacity: 1; filter: none; transform: none; }
.img-frame { position: relative; overflow: hidden; border-radius: var(--bw-r-md); background: var(--bw-line-soft); }
.img-frame:has(img.bw-img:not(.is-loaded)) { background: linear-gradient(90deg, var(--bw-line-soft) 0 40%, #f3ebdd 50%, var(--bw-line-soft) 60% 100%); background-size: 300% 100%; animation: bw-shimmer 1.4s linear infinite; }
.img-frame img { display: block; width: 100%; height: 100%; object-fit: cover; }

/* Button: loading, then a tick and the past-tense word, then back */
.btn.is-done { cursor: default; }
.btn-primary.is-done { background: var(--bw-ok); box-shadow: 0 1px 0 #1f4a29; }
.btn-secondary.is-done, .btn-ghost.is-done { color: var(--bw-ok); border-color: #b9d1b2; }
.bw-done-in { display: inline-flex; align-items: center; gap: 8px; animation: bw-done-in var(--bw-d-200) var(--bw-out) both; }
.bw-done-in .i { animation: bw-pop var(--bw-d-300) var(--bw-out) both; }
.bw-done-back { display: inline-flex; align-items: center; gap: inherit; animation: bw-fade var(--bw-d-200) var(--bw-out) both; }
@keyframes bw-done-in { from { opacity: 0; transform: translateY(4px); } }

/* The small "Saved" stamp after an inline save */
.bw-saved { margin-left: 10px; vertical-align: middle; pointer-events: none; }
.bw-saved.is-leaving { animation: bw-fade-out var(--bw-d-300) var(--bw-in) forwards; }

/* Accordion on <details>. Opening height animates where the browser supports it (Chrome 131+); elsewhere it opens at once */
.accordion { border: 1px solid var(--bw-line); border-radius: var(--bw-r-md); background: var(--bw-sheet); overflow: hidden; }
.accordion details + details { border-top: 1px solid var(--bw-line-soft); }
.accordion summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; padding: 12px 16px; cursor: pointer; list-style: none; font-weight: 600; transition: background-color var(--bw-d-150) var(--bw-out); }
.accordion summary::-webkit-details-marker { display: none; }
@media (hover: hover) { .accordion summary:hover { background: var(--bw-paper); } }
.accordion summary .i { color: var(--bw-muted); transition: transform var(--bw-d-200) var(--bw-out); }
.accordion details[open] > summary .i { transform: rotate(180deg); }
.accordion .acc-body { padding: 0 16px 16px; color: var(--bw-muted); }
.accordion details[open] .acc-body { animation: bw-enter var(--bw-d-300) var(--bw-out) both; }
@supports (interpolate-size: allow-keywords) {
  .accordion { interpolate-size: allow-keywords; }
  .accordion details::details-content { block-size: 0; overflow-y: clip; transition: block-size var(--bw-d-300) var(--bw-out), content-visibility var(--bw-d-300) allow-discrete; }
  .accordion details[open]::details-content { block-size: auto; }
}

/* Drawer: a side sheet on <dialog class="dialog drawer">, slides in from the right */
.dialog.drawer { margin: 0 0 0 auto; height: 100dvh; max-height: 100dvh; width: min(440px, 100vw); border-radius: var(--bw-r-lg) 0 0 var(--bw-r-lg); border-right: 0; display: none; }
.dialog.drawer[open] { display: flex; flex-direction: column; animation: bw-drawer-in var(--bw-d-300) var(--bw-out) both; }
.dialog.drawer.is-closing { animation: bw-drawer-out var(--bw-d-200) var(--bw-in) forwards; }
.dialog.drawer .dialog-body { flex: 1; overflow-y: auto; }
.dialog.drawer .dialog-foot { border-radius: 0; }
@keyframes bw-drawer-in { from { transform: translateX(100%); } }
@keyframes bw-drawer-out { to { transform: translateX(100%); } }
@media (max-width: 560px) { .dialog.drawer { border-radius: 0; } }

/* Toasts slide in from the edge they live on */
@media (min-width: 641px) { .toast { animation-name: bw-toast-in-side; } }
@keyframes bw-toast-in-side { from { opacity: 0; transform: translateX(24px); } }

/* Sliding sidebar indicator: one paper pill that glides to the current link */
.side-nav { position: relative; }
.nav-ind { position: absolute; left: 0; top: 0; z-index: 0; border-radius: var(--bw-r-sm); background: var(--bw-sheet); box-shadow: var(--bw-sh-1), inset 0 0 0 1px var(--bw-line-soft); opacity: 0; pointer-events: none; transition: transform var(--bw-d-300) var(--bw-move), width var(--bw-d-200) var(--bw-out), opacity var(--bw-d-150) var(--bw-out); }
.nav-ind.no-anim { transition: none; }
.side-nav .nav-group, .side-nav .nav-label { position: relative; z-index: 1; }
.side-nav.has-ind .nav-link[aria-current="page"] { background: transparent; box-shadow: none; }

/* Hover lift on interactive cards only (never on static cards) */
.card-link, .card.is-interactive { transition: transform var(--bw-d-150) var(--bw-out), box-shadow var(--bw-d-150) var(--bw-out), border-color var(--bw-d-150) var(--bw-out); will-change: transform; }
@media (hover: hover) {
  .card-link:hover, .card.is-interactive:hover { transform: translateY(-2px); box-shadow: var(--bw-sh-2); border-color: #c8b79b; }
}
.card-link:active, .card.is-interactive:active { transform: translateY(0) scale(.995); box-shadow: var(--bw-sh-1); transition-duration: var(--bw-d-100); }

@media (prefers-reduced-motion: reduce) {
  .bw-js [data-reveal]:not(.is-in) { opacity: 1; transform: none; filter: none; }
  img.bw-img { filter: none; transform: none; }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
  .card-link:hover, .card.is-interactive:hover { transform: none; }
}

/* One-shot moves: BW.pop, BW.shake, BW.press (seal) */
.bw-pop-once { animation: bw-pop-once var(--bw-d-200) var(--bw-out); }
@keyframes bw-pop-once { from { transform: scale(.94); } }
.bw-shake { animation: bw-shake var(--bw-d-300) var(--bw-out); }
@keyframes bw-shake { 20% { transform: translateX(-5px); } 40% { transform: translateX(4px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); } }
.seal.is-landing { animation: bw-seal var(--bw-d-300) var(--bw-out) both; }

/* Typewriter: a quiet caret while text writes itself in */
.is-typing { caret-color: transparent; }
.is-typing:not(textarea):not(input)::after { content: ""; display: inline-block; width: 2px; height: 1em; margin-left: 2px; vertical-align: -.12em; background: var(--bw-oxblood); animation: bw-caret 800ms steps(1) infinite; }
@keyframes bw-caret { 50% { opacity: 0; } }

/* Progress ring (BW.ring) */
.ring { position: relative; display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none; }
.ring-sm { width: 28px; height: 28px; }
.ring-lg { width: 64px; height: 64px; }
.ring-svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track, .ring-bar { fill: none; stroke-width: 3.5; }
.ring-track { stroke: var(--bw-line-soft); }
.ring-bar { stroke: var(--bw-oxblood); stroke-linecap: round; stroke-dasharray: 100; stroke-dashoffset: 100; transition: stroke-dashoffset var(--bw-d-200) var(--bw-out), stroke var(--bw-d-200) var(--bw-out); }
.ring.is-done .ring-bar { stroke: var(--bw-ok); }
.ring-num { position: relative; font: 600 11px/1 var(--bw-body); font-variant-numeric: tabular-nums; color: var(--bw-muted); }
.ring-sm .ring-num { display: none; }
.ring-lg .ring-num { font-size: 14px; }
.ring.is-done .ring-num { color: var(--bw-ok); }

@media (prefers-reduced-motion: reduce) {
  .is-typing::after { animation: none; }
}

/* BW.leave: the item goes, the list closes up (FLIP in ui.js) */
.bw-leave-left { animation: bw-leave-left var(--bw-d-200) var(--bw-in) forwards; }
.bw-leave-right { animation: bw-leave-right var(--bw-d-200) var(--bw-in) forwards; }
.bw-leave-up { animation: bw-leave var(--bw-d-200) var(--bw-in) forwards; }
@keyframes bw-leave-left { to { opacity: 0; transform: translateX(-24px); } }
@keyframes bw-leave-right { to { opacity: 0; transform: translateX(24px); } }

/* BW.grow: chart bars rise from the baseline */
.bw-js [data-grow] { transform: scaleY(0); transform-origin: 50% 100%; transform-box: fill-box; } /* fill-box: SVG bars grow from their own baseline */
.bw-js [data-grow].is-grown { transform: none; transition: transform var(--bw-d-300) var(--bw-out); transition-delay: var(--bw-delay, 0ms); }
@media (prefers-reduced-motion: reduce) { .bw-js [data-grow] { transform: none; } }

/* ---------- Founding member badge ---------- */
/* Only the founding 34. A small wax disc with the wheel, a brass hairline, the number in oxblood. */
.founder {
  --f-h: 30px; --f-disc: 22px;
  position: relative; display: inline-flex; align-items: center; gap: 8px; height: var(--f-h); padding: 0 12px 0 4px;
  border-radius: var(--bw-r-pill); overflow: hidden; isolation: isolate; vertical-align: middle; white-space: nowrap;
  width: max-content; max-width: 100%; justify-self: start; align-self: start;
  background: linear-gradient(180deg, #fffdf8, #f8efdf);
  box-shadow: inset 0 0 0 1px #e2c98f, inset 0 0 0 3px #fffaf0, inset 0 0 0 4px rgba(184, 134, 43, .35), 0 1px 2px rgba(92, 18, 13, .08);
  color: var(--bw-ink); font: 600 13px/1 var(--bw-body); user-select: none;
}
.founder-disc {
  width: var(--f-disc); height: var(--f-disc); flex: none; border-radius: 50%; display: grid; place-items: center; color: #f4ede1;
  background: radial-gradient(circle at 35% 30%, #b5372a 0, #8c1c13 45%, #5c120d 100%);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, .25), inset 0 -1px 2px rgba(0, 0, 0, .3), 0 1px 1px rgba(92, 18, 13, .35);
}
.founder-disc svg { width: 68%; height: 68%; }
.founder-text { display: inline-flex; align-items: baseline; gap: 8px; }
.founder-no { position: relative; padding-left: 9px; color: var(--bw-oxblood); font-variant-numeric: tabular-nums lining-nums; letter-spacing: .01em; }
.founder-no::before { content: ""; position: absolute; left: 0; top: 50%; width: 1px; height: 12px; transform: translateY(-50%); background: #e2c98f; }
.founder-sm { --f-h: 24px; --f-disc: 18px; gap: 6px; padding-right: 10px; font-size: 12px; }
.founder-sm .founder-no { padding-left: 7px; }
.founder-lg { --f-h: auto; gap: 12px; height: auto; padding: 8px 18px 8px 8px; border-radius: 40px; }
.founder-lg .founder-wax { width: 56px; height: 56px; flex: none; display: block; }
.founder-lg .founder-text { flex-direction: column; align-items: flex-start; gap: 4px; }
.founder-lg .founder-title { font: var(--bw-display-weight) 24px/1 var(--bw-display); letter-spacing: var(--bw-display-track); }
.founder-lg .founder-no { padding-left: 0; font: 500 12px/1 var(--bw-label); letter-spacing: .06em; text-transform: uppercase; }
.founder-lg .founder-no::before { display: none; }
/* A light passes over it on hover: one sweep, transform only */
.founder::after {
  content: ""; position: absolute; inset: -20% auto -20% -60%; width: 40%; z-index: 2; pointer-events: none;
  background: linear-gradient(100deg, transparent, rgba(255, 250, 235, .85), transparent);
  transform: translateX(0) skewX(-18deg); opacity: 0;
}
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .founder:hover::after { animation: bw-shine 650ms var(--bw-out) 1; }
}
@keyframes bw-shine { 0% { opacity: 0; transform: translateX(0) skewX(-18deg); } 15% { opacity: 1; } 100% { opacity: 0; transform: translateX(420%) skewX(-18deg); } }
.founder.is-landing { animation: bw-seal var(--bw-d-300) var(--bw-out) both; }

/* ---------- Rate benchmark ---------- */
.bench { --bench-p: 0%; display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; align-self: start; gap: 12px; padding: 16px; border: 1px solid var(--bw-line); border-radius: var(--bw-r-md); background: var(--bw-sheet); }
.bench-top { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; }
.bench-field { width: 132px; flex: none; }
.bench-field .input { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.bench-field .affix { font-size: 18px; }
.bench-tag { min-height: 26px; display: inline-flex; }
.bench-tag-in { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: var(--bw-r-pill); font: 600 13px/1 var(--bw-body); font-variant-numeric: tabular-nums; background: var(--bw-ink-wash); color: var(--bw-muted); animation: bw-done-in var(--bw-d-200) var(--bw-out) both; }
.bench-tag-in::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.bench.is-usual .bench-tag-in { background: var(--bw-ok-bg); color: var(--bw-ok); }
.bench.is-premium .bench-tag-in { background: var(--bw-ox-tint); color: var(--bw-oxblood); }
.bench.is-below .bench-tag-in { background: var(--bw-warn-bg); color: var(--bw-warn); }
.bench.is-above .bench-tag-in { background: #efe3cf; color: #5a4a36; }

.bench-track { position: relative; padding: 6px 0 22px; }
.bench-rail { position: absolute; left: 0; right: 0; top: 17px; height: 6px; border-radius: 3px; background: var(--bw-line-soft); overflow: hidden; }
.bench-band { position: absolute; top: 0; bottom: 0; z-index: 1; box-shadow: inset 0 0 0 1px rgba(47, 107, 60, .35); background: repeating-linear-gradient(135deg, rgba(47, 107, 60, .22) 0 4px, rgba(47, 107, 60, .12) 4px 8px); }
.bench-fill { position: absolute; inset: 0; background: var(--bw-oxblood); opacity: .3; transform-origin: left; transform: scaleX(0); transition: transform var(--bw-d-100) var(--bw-out); }
.bench-range { position: relative; z-index: 1; display: block; width: 100%; height: 28px; margin: 0; background: transparent; -webkit-appearance: none; appearance: none; cursor: pointer; touch-action: pan-y; }
.bench-range:focus { outline: none; }
.bench-range::-webkit-slider-runnable-track { height: 28px; background: transparent; }
.bench-range::-moz-range-track { height: 28px; background: transparent; }
.bench-range::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 24px; margin-top: 2px; border-radius: 50%; background: var(--bw-oxblood); border: 3px solid #fff8f0; box-shadow: 0 1px 3px rgba(31, 27, 24, .35); transition: transform var(--bw-d-150) var(--bw-out), box-shadow var(--bw-d-150) var(--bw-out); }
.bench-range::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--bw-oxblood); border: 3px solid #fff8f0; box-shadow: 0 1px 3px rgba(31, 27, 24, .35); }
.bench-range:active::-webkit-slider-thumb { transform: scale(1.12); box-shadow: 0 2px 8px rgba(92, 18, 13, .35); }
.bench-range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px var(--bw-paper), 0 0 0 5px var(--bw-oxblood); }
.bench-range:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 3px var(--bw-paper), 0 0 0 5px var(--bw-oxblood); }
.bench-mid { position: absolute; top: 13px; width: 2px; height: 14px; margin-left: -1px; border-radius: 1px; background: var(--bw-ok); z-index: 2; pointer-events: none; }
.bench-use { justify-self: start; font-size: var(--bw-t-13); background: none; border: 0; padding: 0; cursor: pointer; }
.bench-scale { position: absolute; left: 0; right: 0; bottom: 0; height: 16px; font-size: 12px; color: var(--bw-muted); font-variant-numeric: tabular-nums; }
.bench-scale span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.bench-take { font-size: var(--bw-t-15); color: var(--bw-muted); }
.bench-take b { color: var(--bw-ink); font-weight: 600; }
.bench-note { font-size: var(--bw-t-13); color: var(--bw-muted); }

/* ---------- Utilities ---------- */
/* Grids of one column never get wider than their box (long words, tables, code) */
.page-head, .section, .stack, .stack-sm, .stack-lg, .card-list, .ob-content, .dialog-body, .field, .drop, .week { grid-template-columns: minmax(0, 1fr); }
.stack { display: grid; gap: var(--bw-s-4); }
.stack-sm { display: grid; gap: var(--bw-s-2); }
.stack-lg { display: grid; gap: var(--bw-s-8); }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--bw-s-3); }
.row-between { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--bw-s-3); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.bw-enter { animation: bw-enter var(--bw-d-300) var(--bw-out) both; }
.bw-leave { animation: bw-leave var(--bw-d-150) var(--bw-in) both; }

/* ---------- Motion ---------- */
@keyframes bw-spin { to { transform: rotate(360deg); } }
@keyframes bw-fade { from { opacity: 0; } }
@keyframes bw-fade-out { to { opacity: 0; } }
@keyframes bw-fade-down { from { opacity: 0; transform: translateY(-4px); } }
@keyframes bw-enter { from { opacity: 0; transform: translateY(8px); } }
@keyframes bw-leave { to { opacity: 0; transform: translateY(-4px); } }
@keyframes bw-pop { from { opacity: 0; transform: scale(.6); } }
@keyframes bw-stamp { from { opacity: 0; transform: scale(1.15) rotate(calc(var(--tilt, -4deg) - 3deg)); } }
@keyframes bw-toast-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes bw-toast-out { to { opacity: 0; transform: translateY(4px) scale(.98); } }
@keyframes bw-dialog-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes bw-dialog-out { to { opacity: 0; transform: translateY(4px) scale(.98); } }
@keyframes bw-slide { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
@keyframes bw-shimmer { from { background-position: 100% 0; } to { background-position: -50% 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; scroll-behavior: auto !important; }
  .spinner, .btn.is-loading::before, .stepper-note.is-checking::before { animation-duration: 1.4s !important; animation-iteration-count: infinite !important; }
  .progress.is-indeterminate .progress-bar { animation: none; width: 100%; opacity: .5; }
  .skel { animation: none; }
}
