/* ═══════════════════════════════════════════════════════════
   THE LEDGER — iron-gall ink on a statement page
   Palette validated: OKLCH lightness band + chroma floor +
   CVD separation (tritan ΔE 8.0 / protan 10.2) + WCAG 4.5:1
   ═══════════════════════════════════════════════════════════ */

:root {
  /* Surfaces — ink-blue-black, not neutral grey */
  --ink-900: #0A0D13;
  --ink-800: #10141C;
  --ink-700: #161B26;
  --ink-600: #1D2431;
  --ink-500: #27303F;
  --ink-450: #35404F;

  /* Text tiers — every pair measured against WCAG 4.5:1 */
  --ink-0: #EDEFF4;
  /* 15.0:1 on 800 · 16.0:1 on 700 */
  --ink-1: #A7B0C2;
  /* 7.9:1  · 8.5:1  */
  --ink-2: #8A94A6;
  /* 5.6:1  · 6.0:1  */
  --ink-3: #6E7889;
  /* 3.9:1 — icons and rules only, never meaningful text */

  /* Data marks */
  --brass: #C48800;
  --mint: #03855E;
  --steel: #6589D0;
  --red: #D34131;

  /* Status text tints — for words, always paired with a label */
  --mint-text: #62C89D;
  --red-text: #F17260;
  --steel-text: #90B1F1;

  --brass-wash: rgba(196, 136, 0, 0.10);
  --red-wash: rgba(211, 65, 49, 0.12);

  --r-card: 16px;
  --r-ctrl: 12px;
  --r-pill: 999px;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --bar-h: 64px;

  --sans: 'Instrument Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --wide: 'Archivo', var(--sans);
}

* {
  box-sizing: border-box;
}

@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--ink-900);
  color: var(--ink-0);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

body {
  display: flex;
  justify-content: center;
  min-height: 100vh;
}

.app {
  width: 100%;
  max-width: 520px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--ink-800);
  position: relative;
}

.app[hidden] {
  display: none;
}

/* ── Type primitives ───────────────────────────────────── */

.wordmark {
  font-family: var(--wide);
  font-variation-settings: 'wdth' 88, 'wght' 800;
  font-size: 0.7rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--ink-0);
}

.wordmark-lg {
  font-size: 1.35rem;
  letter-spacing: 0.2em;
  font-variation-settings: 'wdth' 95, 'wght' 700;
}

.eyebrow {
  display: block;
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.stmt-title {
  font-family: var(--wide);
  font-variation-settings: 'wdth' 104, 'wght' 700;
  font-size: 1.5rem;
  line-height: 1.1;
  letter-spacing: -0.005em;
  margin: 3px 0 0;
  color: var(--ink-0);
}

.card-head {
  font-family: var(--wide);
  font-variation-settings: 'wdth' 104, 'wght' 700;
  font-size: 1.3rem;
  line-height: 1.15;
  margin: 6px 0 4px;
  color: var(--ink-0);
}

.card-note {
  font-size: 0.85rem;
  color: var(--ink-1);
  margin: 0 0 14px;
}

.sec-note {
  font-size: 0.8rem;
  color: var(--ink-2);
  margin: 0 0 10px;
}

.sec-note strong {
  color: var(--ink-1);
  font-weight: 600;
}

.sec-meta {
  font-size: 0.72rem;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

.motto {
  text-align: center;
  font-family: var(--wide);
  font-variation-settings: 'wdth' 90, 'wght' 500;
  font-size: 0.82rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 26px 12px 6px;
  margin: 0;
}

/* ── Boot ──────────────────────────────────────────────── */

.boot {
  position: fixed;
  inset: 0;
  background: var(--ink-900);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 100;
}

.boot[hidden] {
  display: none;
}

.boot-rule {
  width: 120px;
  height: 2px;
  background: var(--ink-500);
  overflow: hidden;
  position: relative;
}

.boot-rule::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--brass);
  transform: translateX(-100%);
  animation: sweep 1.1s ease-in-out infinite;
}

@keyframes sweep {
  0% {
    transform: translateX(-100%);
  }

  100% {
    transform: translateX(100%);
  }
}

/* ── Gates (auth, onboarding) ──────────────────────────── */

.gate {
  position: fixed;
  inset: 0;
  background: var(--ink-900);
  z-index: 90;
  overflow-y: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(24px + var(--safe-top)) 20px calc(24px + var(--safe-bottom));
}

.gate[hidden] {
  display: none;
}

.gate-inner {
  width: 100%;
  max-width: 400px;
}

.gate-brand {
  text-align: center;
  margin-bottom: 24px;
}

.gate-tag {
  font-size: 0.85rem;
  color: var(--ink-2);
  margin: 10px 0 0;
}

.gate-switch {
  text-align: center;
  font-size: 0.82rem;
  color: var(--ink-2);
  margin: 16px 0 0;
}

.op {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-bottom: 18px;
}

.op-step {
  width: 30px;
  height: 3px;
  border-radius: var(--r-pill);
  background: var(--ink-500);
}

.op-step.is-on {
  background: var(--brass);
}

.onboard-step[hidden] {
  display: none;
}

/* ── Top bar ───────────────────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(13px + var(--safe-top)) 18px 12px;
  background: var(--ink-800);
  border-bottom: 1px solid var(--ink-500);
}

.streak {
  display: flex;
  align-items: baseline;
  gap: 5px;
}

.streak-icon {
  width: 13px;
  height: 13px;
  fill: var(--brass);
  align-self: center;
}

.streak-num {
  font-family: var(--wide);
  font-variation-settings: 'wdth' 100, 'wght' 700;
  font-size: 0.95rem;
  color: var(--brass);
  font-variant-numeric: tabular-nums;
}

.streak-label {
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-2);
}

/* ── Layout ────────────────────────────────────────────── */

.content {
  flex: 1;
  padding: 18px 18px calc(var(--bar-h) + 26px + var(--safe-bottom));
}

.panel {
  display: none;
  flex-direction: column;
  gap: 22px;
}

.panel.is-active {
  display: flex;
  animation: rise 0.22s ease;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(5px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

.stmt-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.sec {
  display: flex;
  flex-direction: column;
}

.sec-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--ink-500);
}

.card {
  background: var(--ink-700);
  border: 1px solid var(--ink-500);
  border-radius: var(--r-card);
  padding: 18px 16px;
}

.card+.card {
  margin-top: 12px;
}

.card-flush {
  padding: 4px 16px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ── The balance card (signature) ──────────────────────── */

.balance {
  padding: 18px 16px 20px;
  position: relative;
  overflow: hidden;
}

.balance::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: var(--brass);
}

.balance-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.balance-amount {
  font-family: var(--wide);
  font-variation-settings: 'wdth' 100, 'wght' 700;
  /* Proportional figures: tabular makes a large standalone number read loose */
  font-variant-numeric: proportional-nums;
  font-size: clamp(2.9rem, 15vw, 3.6rem);
  line-height: 0.95;
  letter-spacing: -0.02em;
  color: var(--ink-0);
  margin: 10px 0 0;
}

.balance-amount.is-over {
  color: var(--red-text);
}

.balance-sub {
  font-size: 0.82rem;
  color: var(--ink-1);
  margin: 6px 0 14px;
}

.balance-split {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--ink-500);
}

.split-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.split-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.split-value {
  font-family: var(--wide);
  font-variation-settings: 'wdth' 100, 'wght' 600;
  font-variant-numeric: tabular-nums;
  font-size: 0.92rem;
  color: var(--ink-0);
}

.split-note {
  font-size: 0.74rem;
  color: var(--ink-2);
  margin: 8px 0 0;
}

.split-note.is-hit {
  color: var(--mint-text);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot.is-mint {
  background: var(--mint);
}

.dot.is-brass {
  background: var(--brass);
}

.dot.is-steel {
  background: var(--steel);
}

/* ── Meters ────────────────────────────────────────────── */

.meter {
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--ink-600);
  overflow: hidden;
}

.meter-sm {
  height: 5px;
}

.meter-fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: var(--r-pill);
  transition: width 0.45s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.meter-fill.is-cal {
  background: var(--brass);
}

.meter-fill.is-protein {
  background: var(--mint);
}

.meter-fill.is-over {
  background: var(--red);
}

/* ── Segmented controls ────────────────────────────────── */

.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  padding: 3px;
  background: var(--ink-600);
  border: 1px solid var(--ink-500);
  border-radius: var(--r-pill);
}

.seg-4 {
  grid-template-columns: repeat(4, 1fr);
  border-radius: var(--r-ctrl);
  margin: 8px 0 16px;
}

.seg-btn {
  appearance: none;
  border: none;
  background: transparent;
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ink-1);
  padding: 9px 12px;
  min-height: 38px;
  border-radius: var(--r-pill);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}

.seg-4 .seg-btn {
  border-radius: 9px;
  padding: 9px 4px;
  font-size: 0.72rem;
}

.seg-btn.is-on {
  background: var(--brass);
  color: var(--ink-900);
}

/* ── Buttons ───────────────────────────────────────────── */

.btn {
  appearance: none;
  font-family: var(--sans);
  font-size: 0.88rem;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  padding: 12px 20px;
  min-height: 46px;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.08s ease;
}

.btn:active {
  transform: scale(0.985);
}

.btn-primary {
  background: var(--brass);
  color: var(--ink-900);
}

.btn-ghost {
  background: transparent;
  border-color: var(--ink-450);
  color: var(--ink-0);
}

.btn-quiet {
  background: transparent;
  border-color: transparent;
  color: var(--ink-2);
  font-weight: 500;
  min-height: 44px;
}

.btn-block {
  width: 100%;
  display: block;
}

.btn-grow {
  flex: 1;
}

.btn-lg {
  min-height: 52px;
  font-size: 0.95rem;
}

.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.link-btn {
  appearance: none;
  background: none;
  border: none;
  padding: 6px 2px;
  min-height: 34px;
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--brass);
  cursor: pointer;
}

.icon-btn {
  appearance: none;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  background: var(--ink-600);
  border: 1px solid var(--ink-500);
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
}

.icon-btn svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: var(--ink-1);
  stroke-width: 2;
}

.danger-btn {
  appearance: none;
  background: transparent;
  border: 1px solid var(--ink-450);
  color: var(--red-text);
  font-family: var(--sans);
  font-size: 0.74rem;
  font-weight: 600;
  border-radius: var(--r-pill);
  padding: 7px 12px;
  min-height: 34px;
  cursor: pointer;
}

/* ── Fields ────────────────────────────────────────────── */

.field {
  display: block;
  position: relative;
}

.field-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin-bottom: 6px;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  font-family: var(--sans);
  font-size: 0.95rem;
  color: var(--ink-0);
  background: var(--ink-600);
  border: 1px solid var(--ink-500);
  border-radius: var(--r-ctrl);
  padding: 12px 14px;
  min-height: 48px;
}

.field textarea {
  min-height: 112px;
  resize: vertical;
  line-height: 1.5;
  padding: 12px 14px;
}

.field input::placeholder {
  color: var(--ink-3);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--brass);
  outline: none;
}

.field select {
  appearance: none;
  padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='7' viewBox='0 0 11 7'%3E%3Cpath d='M1 1l4.5 4.5L10 1' fill='none' stroke='%238A94A6' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}

.field-unit {
  position: absolute;
  right: 14px;
  bottom: 15px;
  font-size: 0.78rem;
  color: var(--ink-2);
  pointer-events: none;
}

.field-hint {
  font-size: 0.74rem;
  color: var(--ink-2);
  margin: 6px 0 0;
}

.readonly {
  font-family: var(--wide);
  font-variation-settings: 'wdth' 100, 'wght' 600;
  font-variant-numeric: tabular-nums;
  font-size: 0.95rem;
  color: var(--ink-1);
  background: var(--ink-600);
  border: 1px solid var(--ink-500);
  border-radius: var(--r-ctrl);
  padding: 13px 14px;
  margin: 0;
}

.form-error {
  font-size: 0.8rem;
  color: var(--red-text);
  margin: 10px 0 0;
  min-height: 0;
}

.form-error:empty {
  display: none;
}

.form-note {
  font-size: 0.8rem;
  color: var(--ink-2);
  margin: 12px 0 0;
}

.form-note.is-error {
  color: var(--red-text);
}

:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}

/* ── Usuals grid ───────────────────────────────────────── */

.usuals {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(102px, 1fr));
  gap: 10px;
}

.usual {
  appearance: none;
  text-align: left;
  background: var(--ink-700);
  border: 1px solid var(--ink-500);
  border-radius: var(--r-ctrl);
  padding: 11px 12px 12px;
  min-height: 92px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.usual:active {
  border-color: var(--brass);
  background: var(--ink-600);
}

.usual-qty {
  font-family: var(--wide);
  font-variation-settings: 'wdth' 100, 'wght' 700;
  font-variant-numeric: tabular-nums;
  font-size: 0.8rem;
  color: var(--brass);
}

.usual-name {
  flex: 1;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-0);
  line-height: 1.25;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
}

.usual-macros {
  font-family: var(--wide);
  font-variation-settings: 'wdth' 100, 'wght' 500;
  font-variant-numeric: tabular-nums;
  font-size: 0.72rem;
  color: var(--ink-2);
}

.usual.is-meal {
  border-style: dashed;
  border-color: var(--ink-450);
}

.usual.is-add {
  border-style: dashed;
  border-color: var(--ink-450);
  align-items: flex-start;
  justify-content: center;
  color: var(--ink-1);
  font-size: 0.82rem;
  font-weight: 600;
}

.usual.is-add svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--brass);
  stroke-width: 2;
}

/* ── The ledger (signature) ────────────────────────────── */

.led-row {
  display: grid;
  grid-template-columns: 1fr 58px 66px 34px;
  align-items: center;
  gap: 8px;
  padding: 11px 0;
  border-bottom: 1px solid var(--ink-500);
}

.led-row:last-child {
  border-bottom: none;
}

.led-main {
  min-width: 0;
}

.led-name {
  display: block;
  font-size: 0.88rem;
  color: var(--ink-0);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.led-sub {
  display: block;
  font-size: 0.72rem;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  margin-top: 1px;
}

.led-amt,
.led-bal {
  font-family: var(--wide);
  font-variation-settings: 'wdth' 100, 'wght' 600;
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
  text-align: right;
}

.led-amt {
  color: var(--ink-2);
}

.led-bal {
  color: var(--ink-0);
}

.led-row.is-open,
.led-row.is-close {
  grid-template-columns: 1fr 58px 66px 34px;
}

.led-row.is-open .led-name,
.led-row.is-close .led-name {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.led-row.is-open .led-bal {
  color: var(--brass);
}

.led-row.is-close {
  border-bottom: none;
  border-top: 1px solid var(--ink-450);
  box-shadow: inset 0 -3px 0 -2px var(--ink-450);
  padding-bottom: 14px;
}

.led-row.is-close .led-bal {
  font-size: 1rem;
  font-variation-settings: 'wdth' 100, 'wght' 700;
}

.led-row.is-close .led-bal.is-over {
  color: var(--red-text);
}

.led-group {
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brass);
  padding: 14px 0 4px;
}

.led-del {
  appearance: none;
  width: 34px;
  height: 44px;
  margin-right: -6px;
  display: grid;
  place-items: center;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

.led-del svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: var(--ink-3);
  stroke-width: 2;
}

.led-del:active svg {
  stroke: var(--red-text);
}

.qty-tag {
  display: inline-block;
  font-family: var(--wide);
  font-variation-settings: 'wdth' 100, 'wght' 600;
  font-variant-numeric: tabular-nums;
  font-size: 0.7rem;
  color: var(--ink-1);
  background: var(--ink-600);
  border-radius: 6px;
  padding: 1px 6px;
  margin-left: 5px;
}

/* ── Generic list rows ─────────────────────────────────── */

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--ink-500);
  text-align: left;
  width: 100%;
  background: none;
  border-left: none;
  border-right: none;
  border-top: none;
  font-family: var(--sans);
}

.row:last-child {
  border-bottom: none;
}

.row-btn {
  appearance: none;
  cursor: pointer;
  min-height: 56px;
}

.row-btn:active {
  opacity: 0.6;
}

.row-main {
  flex: 1;
  min-width: 0;
}

.row-name {
  display: block;
  font-size: 0.88rem;
  color: var(--ink-0);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-sub {
  display: block;
  font-size: 0.74rem;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

.row-side {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.row-actions {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.chev-r {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--ink-3);
  stroke-width: 2;
  flex-shrink: 0;
}

.empty {
  font-size: 0.85rem;
  color: var(--ink-2);
  padding: 18px 0;
  margin: 0;
  text-align: center;
}

.empty strong {
  display: block;
  color: var(--ink-0);
  font-weight: 600;
  margin-bottom: 4px;
}

.staple-toggle {
  appearance: none;
  background: transparent;
  border: 1px solid var(--ink-450);
  color: var(--ink-2);
  font-family: var(--sans);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: var(--r-pill);
  padding: 7px 11px;
  min-height: 34px;
  cursor: pointer;
}

.staple-toggle.is-on {
  background: var(--brass-wash);
  border-color: var(--brass);
  color: var(--brass);
}

.done-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.done-row[hidden] {
  display: none;
}

.done-text {
  font-family: var(--wide);
  font-variation-settings: 'wdth' 100, 'wght' 600;
  font-variant-numeric: tabular-nums;
  font-size: 0.92rem;
  color: var(--ink-0);
}

/* ── History ───────────────────────────────────────────── */

.hist-row {
  display: grid;
  grid-template-columns: 58px 1fr auto 16px;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 13px 0;
  background: none;
  border: none;
  border-bottom: 1px solid var(--ink-500);
  cursor: pointer;
  text-align: left;
  font-family: var(--sans);
  min-height: 60px;
}

.hist-row:last-child {
  border-bottom: none;
}

.hist-row:active {
  opacity: 0.6;
}

.hist-date {
  font-family: var(--wide);
  font-variation-settings: 'wdth' 100, 'wght' 600;
  font-variant-numeric: tabular-nums;
  font-size: 0.78rem;
  color: var(--ink-1);
}

.hist-bars {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.mini {
  display: grid;
  grid-template-columns: 22px 1fr;
  align-items: center;
  gap: 7px;
}

.mini-label {
  font-size: 0.6rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.mini-track {
  height: 5px;
  border-radius: var(--r-pill);
  background: var(--ink-600);
  overflow: hidden;
}

.mini-fill {
  display: block;
  height: 100%;
  border-radius: var(--r-pill);
}

.hist-side {
  font-family: var(--wide);
  font-variation-settings: 'wdth' 100, 'wght' 600;
  font-variant-numeric: tabular-nums;
  font-size: 0.76rem;
  color: var(--ink-1);
  text-align: right;
  white-space: nowrap;
}

.hist-side-sub {
  display: block;
  font-size: 0.66rem;
  color: var(--ink-2);
  font-weight: 400;
}

/* ── History Overview: 7-Day Averages & Streak Calendar ─────── */

.hist-overview {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.hist-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.hist-stat-card {
  background: var(--ink-700);
  border: 1px solid var(--ink-500);
  border-radius: var(--r-card);
  padding: 14px 15px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  transition: border-color 0.15s ease;
}

.hist-stat-card:hover {
  border-color: var(--ink-450);
}

.hist-stat-label {
  font-size: 0.63rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.hist-stat-value-group {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.hist-stat-val {
  font-family: var(--wide);
  font-variation-settings: 'wdth' 100, 'wght' 700;
  font-variant-numeric: tabular-nums;
  font-size: 1.45rem;
  line-height: 1.1;
  color: var(--ink-0);
}

.hist-stat-card:first-child .hist-stat-val {
  color: var(--brass);
}

.hist-stat-card:last-child .hist-stat-val {
  color: var(--mint);
}

.hist-stat-unit {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--ink-2);
}

.hist-stat-sub {
  font-size: 0.66rem;
  color: var(--ink-3);
  margin-top: 2px;
}

/* ── Streak Calendar Card ───────────────────────────────── */

.streak-card {
  background: var(--ink-700);
  border: 1px solid var(--ink-500);
  border-radius: var(--r-card);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.streak-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.streak-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(217, 164, 65, 0.12);
  border: 1px solid rgba(217, 164, 65, 0.35);
  padding: 5px 11px;
  border-radius: 999px;
  color: var(--brass);
}

.streak-fire {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.streak-pill-text {
  font-family: var(--wide);
  font-variation-settings: 'wdth' 100, 'wght' 600;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
}

.streak-pill-text strong {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.cal-nav {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.cal-month-title {
  font-family: var(--wide);
  font-variation-settings: 'wdth' 100, 'wght' 600;
  font-size: 0.84rem;
  color: var(--ink-0);
  min-width: 116px;
  text-align: center;
  user-select: none;
}

.cal-nav-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--r-ctrl);
  border: 1px solid var(--ink-500);
  background: var(--ink-600);
  color: var(--ink-1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: all 0.15s ease;
}

.cal-nav-btn svg {
  width: 14px;
  height: 14px;
}

.cal-nav-btn:hover {
  border-color: var(--brass);
  color: var(--ink-0);
  background: var(--ink-500);
}

.streak-grid-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
  user-select: none;
}

.cal-days-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.cal-day {
  aspect-ratio: 1;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: var(--wide);
  font-variation-settings: 'wdth' 100, 'wght' 500;
  font-variant-numeric: tabular-nums;
  font-size: 0.78rem;
  color: var(--ink-2);
  background: var(--ink-800);
  border: 1px solid var(--ink-600);
  padding: 0;
  cursor: default;
  transition: all 0.15s ease;
  position: relative;
  user-select: none;
}

.cal-day.is-empty {
  opacity: 0.15;
  border-color: transparent;
  background: transparent;
  pointer-events: none;
}

.cal-day.is-today {
  border-color: var(--brass);
  color: var(--ink-0);
  font-weight: 700;
}

.cal-day.is-logged {
  background: rgba(62, 186, 134, 0.14);
  border-color: rgba(62, 186, 134, 0.45);
  color: var(--mint);
  font-weight: 600;
  cursor: pointer;
}

.cal-day.is-logged::after {
  content: '';
  position: absolute;
  bottom: 3px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 4px var(--mint);
}

.cal-day.is-logged:hover {
  background: rgba(62, 186, 134, 0.28);
  border-color: var(--mint);
  transform: scale(1.06);
}

.cal-day.is-logged.is-today {
  box-shadow: 0 0 0 1px var(--brass);
}

.streak-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 0.68rem;
  color: var(--ink-2);
  padding-top: 10px;
  border-top: 1px solid var(--ink-600);
  flex-wrap: wrap;
}

.streak-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-swatch {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}

.legend-swatch.is-logged {
  background: var(--mint);
  box-shadow: 0 0 4px var(--mint);
}

.legend-swatch.is-today {
  border: 1px solid var(--brass);
  background: var(--ink-800);
}

.streak-legend-summary {
  margin-left: auto;
  font-family: var(--wide);
  font-size: 0.72rem;
  color: var(--ink-1);
}

.hist-list-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ── Folds (You tab) ───────────────────────────────────── */

.fold {
  border-bottom: 1px solid var(--ink-500);
}

.fold-toggle {
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  background: none;
  border: none;
  padding: 16px 2px;
  min-height: 56px;
  cursor: pointer;
  font-family: var(--wide);
  font-variation-settings: 'wdth' 100, 'wght' 600;
  font-size: 1rem;
  color: var(--ink-0);
  text-align: left;
}

.chev {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  fill: none;
  stroke: var(--ink-3);
  stroke-width: 2;
  transition: transform 0.2s ease;
}

.fold-toggle[aria-expanded="true"] .chev {
  transform: rotate(180deg);
  stroke: var(--brass);
}

.fold-body {
  padding-bottom: 18px;
}

.fold-body[hidden] {
  display: none;
}

/* ── Tab bar ───────────────────────────────────────────── */

.tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 520px;
  z-index: 14;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  align-items: center;
  gap: 6px;
  padding: 8px 12px calc(8px + var(--safe-bottom));
  background: var(--ink-800);
  border-top: 1px solid var(--ink-500);
}

.tab {
  appearance: none;
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 2px;
  min-height: 48px;
  cursor: pointer;
  font-family: var(--sans);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-2);
  border-radius: 10px;
}

.tab svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: var(--ink-2);
  stroke-width: 1.7;
}

.tab.is-active {
  color: var(--brass);
}

.tab.is-active svg {
  stroke: var(--brass);
}

.log-btn {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--brass);
  color: var(--ink-900);
  border: none;
  border-radius: var(--r-pill);
  padding: 0 18px 0 14px;
  height: 48px;
  cursor: pointer;
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 600;
}

.log-btn svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: var(--ink-900);
  stroke-width: 2.4;
}

.log-btn:active {
  transform: scale(0.97);
}

/* ── Overlays and sheets ───────────────────────────────── */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(4, 6, 10, 0.7);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.overlay[hidden] {
  display: none;
}

.sheet {
  width: 100%;
  max-width: 520px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--ink-700);
  border-top: 2px solid var(--brass);
  border-radius: 20px 20px 0 0;
  animation: slide-up 0.24s cubic-bezier(0.22, 0.61, 0.36, 1);
}

@keyframes slide-up {
  from {
    transform: translateY(24px);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

/* Browse view — flex column so search-results scrolls on its own */
#view-browse {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  padding: 18px 18px 0;
  overflow: hidden;
}

/* Static parts at the top of browse stay put */
#view-browse .sheet-head,
#view-browse .draft-banner,
#view-browse [class^="eyebrow"],
#view-browse .seg,
#view-browse .search {
  flex-shrink: 0;
}

/* Search results grow and scroll */
#search-results {
  flex: 1;
  overflow-y: auto;
  /* give space so content doesn't hide behind footer fade */
  padding-bottom: 8px;
}

/* Sticky footer wrapper */
.browse-footer {
  flex-shrink: 0;
  position: relative;
  background: var(--ink-700);
  padding: 0 0 calc(16px + var(--safe-bottom));
}

/* Subtle gradient fade above the footer buttons */
.browse-footer::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
  height: 36px;
  background: linear-gradient(to bottom, transparent, var(--ink-700));
  pointer-events: none;
}

/* The two action buttons sit side-by-side or stacked */
.browse-footer-btns {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 12px;
}

/* Non-browse sheet-views keep the old behaviour (own padding + scroll) */
#view-qty,
#view-builder {
  padding: 18px 18px calc(20px + var(--safe-bottom));
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}



#view-browse[hidden],
.sheet-view[hidden] {
  display: none !important;
}

.sheet-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.sheet-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.sheet-titles {
  flex: 1;
  min-width: 0;
}

.sheet-title {
  font-family: var(--wide);
  font-variation-settings: 'wdth' 104, 'wght' 700;
  font-size: 1.25rem;
  line-height: 1.15;
  color: var(--ink-0);
  margin: 0;
  flex: 1;
  min-width: 0;
}

.sheet-sub {
  font-size: 0.75rem;
  color: var(--ink-2);
  margin: 2px 0 0;
}

.sheet-sub[hidden] {
  display: none;
}

/* ── Search ────────────────────────────────────────────── */

.search {
  position: relative;
  margin-bottom: 6px;
}

.search input {
  width: 100%;
  font-family: var(--sans);
  font-size: 0.95rem;
  color: var(--ink-0);
  background: var(--ink-600);
  border: 1px solid var(--ink-500);
  border-radius: var(--r-ctrl);
  padding: 13px 46px 13px 42px;
  min-height: 50px;
}

.search input::placeholder {
  color: var(--ink-3);
}

.search input:focus {
  border-color: var(--brass);
  outline: none;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 17px;
  height: 17px;
  fill: none;
  stroke: var(--ink-2);
  stroke-width: 2;
  pointer-events: none;
}

.search-clear {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  appearance: none;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

.search-clear[hidden] {
  display: none;
}

.search-clear svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: var(--ink-2);
  stroke-width: 2;
}

.res-group {
  display: block;
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-2);
  padding: 16px 0 2px;
}

.teach-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  appearance: none;
  background: var(--brass-wash);
  border: 1px dashed var(--brass);
  border-radius: var(--r-ctrl);
  padding: 14px;
  margin-top: 12px;
  cursor: pointer;
  text-align: left;
  font-family: var(--sans);
  min-height: 56px;
}

.teach-row svg {
  width: 19px;
  height: 19px;
  flex-shrink: 0;
  fill: none;
  stroke: var(--brass);
  stroke-width: 2;
}

.teach-row-text {
  font-size: 0.85rem;
  color: var(--ink-0);
}

.teach-row-text b {
  font-weight: 600;
}

.teach-row-sub {
  display: block;
  font-size: 0.74rem;
  color: var(--ink-2);
  margin-top: 2px;
}

.teach {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--ink-500);
}

.teach[hidden] {
  display: none;
}

.teach-name {
  font-family: var(--wide);
  font-variation-settings: 'wdth' 104, 'wght' 700;
  font-size: 1.15rem;
  margin: 6px 0 4px;
  color: var(--ink-0);
}

.draft-banner {
  display: block;
  width: 100%;
  appearance: none;
  text-align: left;
  background: var(--brass-wash);
  border: 1px solid var(--brass);
  border-radius: var(--r-ctrl);
  padding: 12px 14px;
  margin-bottom: 16px;
  cursor: pointer;
  font-family: var(--sans);
  font-size: 0.82rem;
  color: var(--ink-0);
  min-height: 48px;
}

.draft-banner[hidden] {
  display: none;
}

.draft-banner b {
  font-weight: 600;
}

/* ── Quantity view ─────────────────────────────────────── */

.qty-basis {
  font-family: var(--wide);
  font-variation-settings: 'wdth' 100, 'wght' 500;
  font-variant-numeric: tabular-nums;
  font-size: 0.76rem;
  color: var(--ink-1);
  background: var(--ink-600);
  border-radius: var(--r-pill);
  padding: 7px 13px;
  margin: 0;
  display: inline-block;
}

.stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 22px 0 16px;
}

.step-btn {
  appearance: none;
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  background: var(--ink-600);
  border: 1px solid var(--ink-450);
  border-radius: 50%;
  padding: 0;
  cursor: pointer;
}

.step-btn svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: var(--ink-0);
  stroke-width: 2.2;
}

.step-btn:active {
  border-color: var(--brass);
  background: var(--brass-wash);
}

.stepper-field {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 116px;
  justify-content: center;
}

.stepper-field input {
  width: 84px;
  text-align: right;
  font-family: var(--wide);
  font-variation-settings: 'wdth' 100, 'wght' 700;
  font-variant-numeric: proportional-nums;
  font-size: 2.1rem;
  line-height: 1;
  color: var(--ink-0);
  background: none;
  border: none;
  border-bottom: 2px solid var(--ink-450);
  border-radius: 0;
  padding: 4px 2px;
  appearance: textfield;
  -moz-appearance: textfield;
}

.stepper-field input::-webkit-inner-spin-button,
.stepper-field input::-webkit-outer-spin-button {
  appearance: none;
  margin: 0;
}

.stepper-field input:focus {
  outline: none;
  border-bottom-color: var(--brass);
}

.stepper-unit {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink-2);
}

.qty-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 20px;
}

.qty-chip {
  appearance: none;
  font-family: var(--wide);
  font-variation-settings: 'wdth' 100, 'wght' 600;
  font-variant-numeric: tabular-nums;
  font-size: 0.8rem;
  color: var(--ink-1);
  background: var(--ink-600);
  border: 1px solid var(--ink-500);
  border-radius: var(--r-pill);
  padding: 9px 15px;
  min-height: 40px;
  cursor: pointer;
}

.qty-chip.is-on {
  border-color: var(--brass);
  color: var(--brass);
  background: var(--brass-wash);
}

/* ── Summary lists ─────────────────────────────────────── */

.summary {
  margin: 0 0 18px;
  padding: 14px 0 0;
  border-top: 1px solid var(--ink-500);
}

.summary-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
}

.summary-row dt {
  font-size: 0.82rem;
  color: var(--ink-1);
}

.summary-row dd {
  margin: 0;
  font-family: var(--wide);
  font-variation-settings: 'wdth' 100, 'wght' 600;
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
  color: var(--ink-0);
}

.summary-row.is-total {
  margin-top: 6px;
  padding-top: 12px;
  border-top: 1px solid var(--ink-450);
}

.summary-row.is-total dt {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.summary-row.is-total dd {
  font-size: 1.05rem;
  font-variation-settings: 'wdth' 100, 'wght' 700;
}

.summary-row.is-total dd.is-over {
  color: var(--red-text);
}

/* ── Day detail ────────────────────────────────────────── */

/* Keep day-detail actions visible while long records scroll inside the sheet. */
#day-detail .sheet {
  height: min(92vh, 760px);
  height: min(92dvh, 760px);
  max-height: 92vh;
  max-height: 92dvh;
}

#day-detail .sheet-head {
  flex: 0 0 auto;
  padding: 18px 18px 0;
  margin-bottom: 0;
}

#day-detail .sheet-foot {
  flex: 0 0 auto;
}

#day-detail-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 18px 18px 8px;
}

#day-detail-body .led-row,
#day-detail-body .led-row.is-open,
#day-detail-body .led-row.is-close {
  grid-template-columns: minmax(0, 1fr) 46px 58px 40px;
  gap: 6px;
}

#day-detail-body .led-del {
  display: grid;
  width: 40px;
  color: var(--ink-3);
}
.dd-sec {
  margin-bottom: 22px;
}

.dd-sec:last-child {
  margin-bottom: 0;
}

.dd-sec .eyebrow {
  padding-bottom: 8px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--ink-500);
}

.dd-note {
  font-family: var(--wide);
  font-variation-settings: 'wdth' 100, 'wght' 600;
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
  color: var(--ink-1);
  padding: 12px 0;
  margin: 0;
}

.day-note-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: var(--sans);
  font-weight: 400;
  font-variant-numeric: normal;
}

.history-note-field textarea {
  min-height: 104px;
}

.history-note-save {
  margin-top: 12px;
}

/* ── Historical Day Edit Mode ───────────────────────────── */

/* Edit mode banner at top of Today panel */
.edit-mode-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  margin-bottom: 16px;
  background: linear-gradient(135deg, rgba(196, 136, 0, 0.22), rgba(255, 179, 0, 0.1));
  border: 1px solid rgba(196, 136, 0, 0.45);
  border-radius: var(--r-card, 16px);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.3);
  animation: editBarSlide 0.25s ease-out;
}

.edit-mode-bar[hidden] {
  display: none !important;
}

@keyframes editBarSlide {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.edit-mode-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.edit-mode-badge {
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brass, #c48800);
  font-family: var(--wide);
}

.edit-mode-date-label {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink-0, #fff);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.edit-mode-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.edit-mode-actions .btn-sm {
  padding: 6px 14px;
  font-size: 0.8rem;
  border-radius: 8px;
}

/* Nav bar styles during edit mode */
.tabbar.is-editing [data-tab="today"] {
  color: var(--brass, #c48800);
}

.tabbar.is-editing [data-tab="today"] svg {
  stroke: var(--brass, #c48800);
}



/* Future calendar days */
.cal-day.is-future {
  opacity: 0.25;
  cursor: not-allowed;
}

/* Unlogged past days — subtle hover so they feel clickable */
.cal-day:not(.is-logged):not(.is-today):not(.is-future):not([disabled]) {
  cursor: pointer;
}

.cal-day:not(.is-logged):not(.is-today):not(.is-future):not([disabled]):hover {
  background: var(--ink-500);
  border-color: var(--ink-450);
}

/* ── Snackbar ──────────────────────────────────────────── */

.snackbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--bar-h) + 18px + var(--safe-bottom));
  z-index: 70;
  width: calc(100% - 28px);
  max-width: 492px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 10px 10px 16px;
  background: var(--ink-600);
  border: 1px solid var(--ink-450);
  border-radius: var(--r-ctrl);
  box-shadow: 0 10px 28px rgba(4, 6, 10, 0.5);
  animation: snack-in 0.2s ease;
}

.snackbar[hidden] {
  display: none;
}

@keyframes snack-in {
  from {
    opacity: 0;
    transform: translate(-50%, 10px);
  }

  to {
    opacity: 1;
    transform: translateX(-50%);
  }
}

.snack-text {
  flex: 1;
  min-width: 0;
  font-size: 0.83rem;
  color: var(--ink-0);
}

.snack-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.snack-btn {
  appearance: none;
  background: none;
  border: none;
  font-family: var(--sans);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--brass);
  padding: 10px 12px;
  min-height: 44px;
  border-radius: var(--r-pill);
  cursor: pointer;
}

.snack-btn:active {
  background: var(--brass-wash);
}

/* ── Export preset chips ───────────────────────────────── */

.export-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.preset-chip {
  appearance: none;
  background: var(--ink-700);
  border: 1px solid var(--ink-500);
  border-radius: 20px;
  color: var(--ink-1);
  font-family: var(--wide);
  font-variation-settings: 'wdth' 100, 'wght' 500;
  font-size: 0.76rem;
  padding: 5px 12px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}

.preset-chip:hover {
  border-color: var(--brass);
  color: var(--brass);
}

.preset-chip.is-active {
  background: var(--brass-wash);
  border-color: var(--brass);
  color: var(--brass);
}

/* Style date inputs to match field inputs */
input[type="date"] {
  color-scheme: dark;
}

/* ── Small screens ─────────────────────────────────────── */

@media (max-width: 359px) {
  .content {
    padding-left: 14px;
    padding-right: 14px;
  }

  .hist-stats {
    grid-template-columns: 1fr;
  }

  .log-btn span {
    display: none;
  }

  .log-btn {
    padding: 0 14px;
  }
}
