/* Family Hub — modern farmhouse almanac.
   Warm paper, ink brown, wheat gold. Fraunces for display, Atkinson
   Hyperlegible for UI (designed for legibility at distance — wall tablet). */

/* ---------------------------------------------------------------- fonts */

@font-face {
  font-family: 'Fraunces';
  src: url('../fonts/fraunces-var.woff2') format('woff2');
  font-weight: 300 900;
  font-display: swap;
}
@font-face {
  font-family: 'Atkinson';
  src: url('../fonts/atkinson-400.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Atkinson';
  src: url('../fonts/atkinson-700.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}

/* ---------------------------------------------------------------- tokens */

:root {
  --paper: #f6f1e5;
  --paper-deep: #efe7d4;
  --card: #fdfaf1;
  --line: #e2d8c0;
  --line-soft: #eae2cd;
  --ink: #3a3122;
  --ink-soft: #6d5f45;
  --ink-faint: #a2946f;
  --gold: #d9a441;
  --gold-deep: #a87a1e;
  --gold-wash: #f3e3bb;
  --barn: #a94a34;
  --ok: #7d9469;
  --shadow: 0 10px 30px rgba(58, 49, 34, .14);
  --r: 10px;
  --serif: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  --sans: 'Atkinson', 'Avenir Next', 'Segoe UI', system-ui, sans-serif;
  --tap: 44px;
}

/* Chart palette (debt donut) — constant across Looks, like person colors.
   VALIDATED for colorblind-safe adjacency + contrast per theme (dataviz method:
   4 solid slots; 5th+ debt reuses hues with a hatch). Don't swap casually —
   re-run the palette validator if these ever change. */
:root {
  --chart-1: #d55e00;
  --chart-2: #0072b2;
  --chart-3: #e69f00;
  --chart-4: #009e73;
}
[data-theme="dark"] {
  --chart-1: #a94800;
  --chart-2: #2470ae;
  --chart-3: #bd8a0d;
  --chart-4: #2cab7e;
}
@media (prefers-color-scheme: dark) {
  [data-theme="auto"] {
    --chart-1: #a94800;
    --chart-2: #2470ae;
    --chart-3: #bd8a0d;
    --chart-4: #2cab7e;
  }
}

[data-theme="dark"] { color-scheme: dark; }
/* "only light" blocks Chrome/Android forced auto-darkening — when the family
   picks Light, the browser must not invert the page at night. */
[data-theme="light"] { color-scheme: only light; }

@media (prefers-color-scheme: dark) {
  [data-theme="auto"] {
    --paper: #211c12;
    --paper-deep: #191509;
    --card: #2a2417;
    --line: #403825;
    --line-soft: #362f1d;
    --ink: #efe7d2;
    --ink-soft: #c0b291;
    --ink-faint: #857852;
    --gold-wash: #3d3315;
    --shadow: 0 10px 30px rgba(0, 0, 0, .5);
  }
}
[data-theme="dark"] {
  --paper: #211c12;
  --paper-deep: #191509;
  --card: #2a2417;
  --line: #403825;
  --line-soft: #362f1d;
  --ink: #efe7d2;
  --ink-soft: #c0b291;
  --ink-faint: #857852;
  --gold-wash: #3d3315;
  --shadow: 0 10px 30px rgba(0, 0, 0, .5);
}

/* ---------------- alternate looks (Settings → This device → Look) ----------------
   Each look swaps the same dozen tokens; person colors stay constant. */

[data-palette="prairie"] {
  --paper: #f4f5ec; --paper-deep: #e7eada; --card: #fcfdf6;
  --line: #d6dbc2; --line-soft: #e0e4d0;
  --ink: #24321f; --ink-soft: #51614a; --ink-faint: #8b9779;
  --gold: #4f8f46; --gold-deep: #2f6b2e; --gold-wash: #e2eed8;
}
[data-palette="linen"] {
  --paper: #f7f6f2; --paper-deep: #eceae2; --card: #fffefb;
  --line: #dfdcd2; --line-soft: #e8e5dc;
  --ink: #302d27; --ink-soft: #6e6a60; --ink-faint: #a49d8d;
  --gold: #c76b45; --gold-deep: #a34e2c; --gold-wash: #f6e3d8;
}
[data-palette="slate"] {
  --paper: #f4f6f9; --paper-deep: #e7ebf1; --card: #ffffff;
  --line: #dbe1ea; --line-soft: #e5eaf1;
  --ink: #253140; --ink-soft: #5d6b7e; --ink-faint: #97a3b4;
  --gold: #3f78c8; --gold-deep: #2c5ea6; --gold-wash: #e0eafa;
}
[data-palette="gallery"] { /* Baker Arts–inspired: bright white + deep indigo */
  --paper: #f7f7fc; --paper-deep: #ececf5; --card: #ffffff;
  --line: #dcdcea; --line-soft: #e7e7f2;
  --ink: #1e1e2a; --ink-soft: #5a5a72; --ink-faint: #9a9ab2;
  --gold: #3d3d99; --gold-deep: #32327f; --gold-wash: #e4e4f7;
}

[data-theme="dark"][data-palette="prairie"] {
  --paper: #181d13; --paper-deep: #11150d; --card: #212819;
  --line: #37402b; --line-soft: #2c3421;
  --ink: #e9edda; --ink-soft: #b6c19d; --ink-faint: #7a865f;
  --gold: #6f9e54; --gold-deep: #8fbc72; --gold-wash: #263420;
}
[data-theme="dark"][data-palette="linen"] {
  --paper: #201e1b; --paper-deep: #191714; --card: #29261f;
  --line: #3b382f; --line-soft: #322f28;
  --ink: #ece8df; --ink-soft: #bdb5a4; --ink-faint: #837b6a;
  --gold: #d98a5f; --gold-deep: #e09a70; --gold-wash: #3a2b20;
}
[data-theme="dark"][data-palette="slate"] {
  --paper: #161b22; --paper-deep: #10141a; --card: #1f2630;
  --line: #313b49; --line-soft: #28303c;
  --ink: #e6ebf3; --ink-soft: #a9b4c4; --ink-faint: #6e7b8d;
  --gold: #6ba1e8; --gold-deep: #85b2ef; --gold-wash: #223349;
}
[data-theme="dark"][data-palette="gallery"] {
  --paper: #191922; --paper-deep: #131320; --card: #22222e;
  --line: #34344a; --line-soft: #2b2b3d;
  --ink: #ececf4; --ink-soft: #b4b4cc; --ink-faint: #77778f;
  --gold: #8585e0; --gold-deep: #a5a5f0; --gold-wash: #2a2a4a;
}
@media (prefers-color-scheme: dark) {
  [data-theme="auto"][data-palette="prairie"] {
    --paper: #181d13; --paper-deep: #11150d; --card: #212819;
    --line: #37402b; --line-soft: #2c3421;
    --ink: #e9edda; --ink-soft: #b6c19d; --ink-faint: #7a865f;
    --gold: #6f9e54; --gold-deep: #8fbc72; --gold-wash: #263420;
  }
  [data-theme="auto"][data-palette="linen"] {
    --paper: #201e1b; --paper-deep: #191714; --card: #29261f;
    --line: #3b382f; --line-soft: #322f28;
    --ink: #ece8df; --ink-soft: #bdb5a4; --ink-faint: #837b6a;
    --gold: #d98a5f; --gold-deep: #e09a70; --gold-wash: #3a2b20;
  }
  [data-theme="auto"][data-palette="slate"] {
    --paper: #161b22; --paper-deep: #10141a; --card: #1f2630;
    --line: #313b49; --line-soft: #28303c;
    --ink: #e6ebf3; --ink-soft: #a9b4c4; --ink-faint: #6e7b8d;
    --gold: #6ba1e8; --gold-deep: #85b2ef; --gold-wash: #223349;
  }
  [data-theme="auto"][data-palette="gallery"] {
    --paper: #191922; --paper-deep: #131320; --card: #22222e;
    --line: #34344a; --line-soft: #2b2b3d;
    --ink: #ececf4; --ink-soft: #b4b4cc; --ink-faint: #77778f;
    --gold: #8585e0; --gold-deep: #a5a5f0; --gold-wash: #2a2a4a;
  }
}

/* ---------------------------------------------------------------- base */

* { box-sizing: border-box; margin: 0; }
html { height: 100%; }
body {
  height: 100%;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { font-weight: inherit; }

#app {
  height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  grid-template-areas: 'mast' 'view' 'tabs';
}

/* Wide screens (wall tablet landscape, desktop): tabs become a left rail. */
@media (min-width: 900px) {
  #app {
    grid-template-columns: 13rem 1fr;
    grid-template-rows: auto 1fr;
    grid-template-areas: 'mast mast' 'tabs view';
  }
}

/* ---------------------------------------------------------------- masthead */

#masthead {
  grid-area: mast;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: calc(.6rem + env(safe-area-inset-top)) clamp(.9rem, 3vw, 2rem) .55rem;
  border-bottom: 3px double var(--ink);
  background: var(--paper);
}
.mast-brand {
  display: flex;
  align-items: center;
  gap: .55rem;
  cursor: pointer;
}
.wheat { width: 22px; height: 22px; color: var(--gold-deep); display: block; }
.mast-name {
  font-family: var(--serif);
  font-size: clamp(1.15rem, 2.6vw, 1.55rem);
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  font-variation-settings: 'opsz' 60;
}
.mast-side { display: flex; align-items: center; gap: .5rem; }
.mast-wx {
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 500;
  padding: .25rem .55rem;
  border-radius: 999px;
}
.mast-wx:hover { background: var(--paper-deep); }
.mast-gear { font-size: 1.15rem; padding: .3rem .5rem; border-radius: 8px; }
.offline-pip {
  font-size: .78rem;
  color: var(--barn);
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: .12rem .5rem;
}

/* ---------------------------------------------------------------- tabs */

#tabs {
  grid-area: tabs;
  display: flex;
  justify-content: space-around;
  gap: .15rem;
  padding: .35rem .5rem calc(.35rem + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--card);
}
.tab {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .1rem;
  min-width: var(--tap);
  min-height: var(--tap);
  justify-content: center;
  padding: .3rem .6rem;
  border-radius: var(--r);
  color: var(--ink-soft);
}
.tab-glyph { font-size: 1.15rem; line-height: 1; font-style: normal; }
.tab-lab { font-size: .72rem; letter-spacing: .04em; }
.tab.on { color: var(--ink); background: var(--gold-wash); }
.tab-badge {
  position: absolute;
  top: .1rem; right: .4rem;
  background: var(--barn);
  color: #fdf6ea;
  font-size: .68rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 0 .35rem;
  line-height: 1.35;
}
.tab-fab {
  background: var(--ink);
  color: var(--paper);
  font-size: 1.5rem;
  font-weight: 700;
  border-radius: 999px;
  width: var(--tap);
  flex: 0 0 auto;
}
.tab-fab:active { transform: scale(.94); }

@media (min-width: 900px) {
  #tabs {
    flex-direction: column;
    justify-content: flex-start;
    gap: .3rem;
    padding: 1.1rem .8rem;
    border-top: 0;
    border-right: 1px solid var(--line);
    background: var(--paper);
  }
  .tab {
    flex-direction: row;
    justify-content: flex-start;
    gap: .6rem;
    width: 100%;
    padding: .55rem .8rem;
  }
  .tab-lab { font-size: .95rem; }
  .tab-badge { position: static; margin-left: auto; }
  .tab-fab {
    width: 100%;
    border-radius: var(--r);
    margin-top: .6rem;
    font-size: 1.2rem;
  }
}

/* ---------------------------------------------------------------- view */

#view {
  grid-area: view;
  overflow-y: auto;
  min-width: 0; /* a long nowrap row must squish, never widen the whole app */
  padding: clamp(.8rem, 2.5vw, 1.8rem);
  padding-bottom: 2.5rem;
}
.view-in > * { animation: rise .35s cubic-bezier(.22, 1, .36, 1) both; }
.view-in > *:nth-child(2) { animation-delay: .05s; }
.view-in > *:nth-child(3) { animation-delay: .1s; }
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

.empty-line { color: var(--ink-faint); font-style: italic; padding: .6rem 0; }
.sec-h {
  font-family: var(--serif);
  font-size: .85rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 1.1rem 0 .45rem;
}

/* ---------------------------------------------------------------- buttons & bits */

.btn-primary, .btn-ghost, .btn-danger {
  min-height: var(--tap);
  padding: .5rem 1.1rem;
  border-radius: var(--r);
  font-weight: 700;
}
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-primary:active { transform: translateY(1px); }
.btn-ghost { border: 1px solid var(--line); background: var(--card); font-weight: 400; }
.btn-ghost:hover { border-color: var(--ink-faint); }
.btn-danger { color: var(--barn); border: 1px solid var(--barn); }

.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: 0 0 auto; }
.dot-feed { background: transparent; border: 2px solid var(--fc, var(--ink-faint)); box-sizing: border-box; }
.dot.big { width: 16px; height: 16px; }
.dots { display: inline-flex; gap: 3px; align-items: center; }
.pill {
  color: #fdf6ea;
  font-size: .72rem;
  font-weight: 700;
  border-radius: 999px;
  padding: .1rem .5rem;
  white-space: nowrap;
}
.row-recur { color: var(--ink-faint); font-size: .85rem; }

.checkbox {
  width: 30px; height: 30px;
  flex: 0 0 auto;
  border: 2px solid var(--ink-faint);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  color: transparent;
  transition: all .18s cubic-bezier(.22, 1, .36, 1);
}
.checkbox:hover { border-color: var(--gold-deep); }
.checkbox.checked {
  background: var(--ok);
  border-color: var(--ok);
  color: #fdf6ea;
  transform: scale(1.05);
}

/* ---------------------------------------------------------------- calendar bar */

.cal-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .6rem;
  margin-bottom: .9rem;
}
.cal-nav { display: flex; align-items: center; gap: .35rem; }
.cal-row1 { display: flex; align-items: center; gap: .35rem; min-width: 0; }
.cal-arrow { font-size: 1.3rem; padding: .2rem .8rem; min-width: var(--tap); }
.cal-today { font-weight: 700; }
.cal-title-btn {
  display: flex;
  align-items: center;
  gap: .55rem;
  min-width: 0;
  min-height: var(--tap);
  padding: .2rem .55rem;
  border-radius: 10px;
  text-align: left;
}
.cal-title-btn:hover { background: var(--paper-deep); }
.cal-title {
  font-family: var(--serif);
  font-size: clamp(1.3rem, 3.5vw, 1.9rem);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.today-chip {
  flex: 0 0 auto;
  background: var(--gold-wash);
  border: 1px solid var(--gold);
  font-size: .72rem;
  font-weight: 700;
  border-radius: 999px;
  padding: .12rem .55rem;
}
.cal-modes { display: flex; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.mode { padding: .45rem .9rem; color: var(--ink-soft); min-height: var(--tap); }
.mode.on { background: var(--ink); color: var(--paper); }

@media (max-width: 700px) {
  .cal-bar { gap: .5rem; margin-bottom: .6rem; }
  .cal-row1 { width: 100%; }
  .cal-title-btn { flex: 1; justify-content: center; }
  .cal-title { font-size: 1.3rem; }
  .cal-modes { width: 100%; }
  .mode { flex: 1; text-align: center; padding: .55rem 0; }
}

/* ---------------------------------------------------------------- month */

.month { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--card); }
.month-head { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-bottom: 2px solid var(--ink); }
.month-dow {
  padding: .4rem 0;
  text-align: center;
  font-family: var(--serif);
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.month-row { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--line-soft); }
.month-row:first-of-type { border-top: 0; }
.month-cell {
  min-width: 0; /* long titles must NEVER inflate their column */
  min-height: clamp(78px, 12.5vh, 140px);
  padding: .3rem .35rem .4rem;
  border-left: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  gap: .2rem;
  cursor: pointer;
  text-align: left;
}
.month-cell:first-child { border-left: 0; }
.month-cell.wkend { background: color-mix(in srgb, var(--paper-deep) 55%, var(--card)); }
.month-cell.out { opacity: .38; }
.month-cell.today { background: var(--gold-wash); }
.month-cell:hover .cell-add { opacity: 1; }
.cell-top { display: flex; justify-content: space-between; align-items: center; }
.cell-num { font-family: var(--serif); font-size: 1.02rem; font-weight: 500; }
.today .cell-num {
  font-weight: 800;
  background: var(--ink);
  color: var(--paper);
  border-radius: 50%;
  width: 1.7em; height: 1.7em;
  display: grid; place-items: center;
}
.cell-add {
  opacity: 0;
  color: var(--ink-faint);
  font-size: 1rem;
  width: 24px; height: 24px;
  border-radius: 6px;
  transition: opacity .15s;
}
.cell-add:hover { background: var(--paper-deep); color: var(--ink); }
.cell-events { display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.chip {
  display: flex;
  align-items: center;
  gap: .3rem;
  font-size: .78rem;
  line-height: 1.25;
  padding: .12rem .3rem;
  border-radius: 6px;
  text-align: left;
  overflow: hidden;
  white-space: nowrap;
}
.chip:hover { background: var(--paper-deep); }
.chip-time { color: var(--ink-soft); font-weight: 700; font-size: .72rem; }
.chip-title { overflow: hidden; text-overflow: ellipsis; }
.cell-more { font-size: .72rem; color: var(--ink-faint); padding-left: .3rem; }
.chip-feedev .chip-title { font-style: italic; } /* external events read as "borrowed" */
.cell-meal {
  margin-top: auto;
  font-size: .72rem;
  font-style: italic;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* ------------------------------------------------ month (phone: dot grid + agenda) */

.mgrid {
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--card);
  overflow: hidden;
  touch-action: pan-y; /* vertical scroll stays native; horizontal = our swipe */
}
.mg-head { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-bottom: 2px solid var(--ink); }
.mg-dow {
  text-align: center;
  font-family: var(--serif);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--ink-soft);
  padding: .4rem 0 .3rem;
}
.mg-row { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.mg-cell {
  min-width: 0;
  height: 54px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-top: 1px solid var(--line-soft);
}
.mg-row:first-of-type .mg-cell { border-top: 0; }
.mg-cell.out { opacity: .35; }
.mg-cell.sel { background: var(--gold-wash); border-radius: 10px; }
.mg-cell.sel .mg-num { font-weight: 800; }
.mg-num { font-family: var(--serif); font-size: 1.05rem; line-height: 1; }
.mg-cell.today .mg-num {
  background: var(--ink);
  color: var(--paper);
  border-radius: 50%;
  width: 1.65em; height: 1.65em;
  display: grid; place-items: center;
}
.mg-dots { display: flex; gap: 3px; height: 8px; align-items: center; }
.mg-dot { width: 6.5px; height: 6.5px; border-radius: 50%; flex: 0 0 auto; }
.mg-dot.dot-feed { background: transparent; border: 1.5px solid var(--fc, var(--ink-faint)); width: 7.5px; height: 7.5px; }
.mg-more { width: 4px; height: 4px; border-radius: 50%; background: var(--ink-faint); }

.sel-agenda { margin-top: 1rem; }
.sa-head { display: flex; align-items: center; justify-content: space-between; gap: .6rem; margin-bottom: .25rem; }
.sa-rel {
  color: var(--gold-deep);
  font-weight: 700;
  font-size: .72rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  display: block;
}
.sa-date { font-family: var(--serif); font-size: 1.3rem; font-weight: 600; }
.sa-open { padding: .35rem .9rem; min-height: 40px; flex: 0 0 auto; }
.sel-agenda .event-row { padding: .7rem .4rem; }
.sel-agenda .row-time { min-width: 5.2rem; }
.sel-agenda .day-add { margin-top: 1.1rem; width: 100%; }

@media (max-width: 700px) {
  .cell-meal { display: none; }
  .chip-time { display: none; }
  .week { touch-action: pan-y; }
  .year { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
  .yr-month { padding: .5rem .55rem .6rem; }
  .yr-name { font-size: .92rem; margin-bottom: .3rem; }
}

/* ---------------------------------------------------------------- week */

.week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: .5rem;
}
@media (max-width: 860px) { .week { grid-template-columns: 1fr; } }
.week-col {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
  min-height: 9rem;
  display: flex;
  flex-direction: column;
}
.week-col.today { border-color: var(--gold-deep); box-shadow: inset 0 3px 0 var(--gold); }
.week-head {
  display: flex;
  align-items: baseline;
  gap: .45rem;
  padding: .5rem .6rem .35rem;
  border-bottom: 1px solid var(--line-soft);
}
.week-dow { font-size: .75rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-soft); }
.week-num { font-family: var(--serif); font-size: 1.35rem; font-weight: 600; }
.week-body { padding: .4rem .45rem .55rem; display: flex; flex-direction: column; gap: .25rem; }
.week-body .chip { white-space: normal; }
.week-empty { color: var(--ink-faint); font-size: 1.1rem; padding: .4rem; text-align: center; border-radius: 8px; }
.week-empty:hover { background: var(--paper-deep); }
.chip-chore { opacity: .8; }

/* ---------------------------------------------------------------- day */

.dayview { max-width: 44rem; }
.day-rel { color: var(--gold-deep); font-weight: 700; letter-spacing: .06em; }
.day-sec { margin-top: 1rem; }
.day-sec .day-h {
  font-family: var(--serif);
  font-size: .85rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 .4rem;
}
.event-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .6rem .65rem;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  min-height: var(--tap);
}
.event-row:hover { background: var(--card); }
.row-time {
  font-weight: 700;
  font-size: .85rem;
  color: var(--ink-soft);
  min-width: 6.2rem;
}
.row-title { font-size: 1.05rem; }
.day-meal { font-size: 1.05rem; }
.day-add { margin-top: 1.4rem; }

/* ---------------------------------------------------------------- year */

.year {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
  gap: .8rem;
}
.yr-month {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: .7rem .8rem .8rem;
  text-align: left;
}
.yr-month:hover { border-color: var(--gold-deep); }
.yr-name { font-family: var(--serif); font-weight: 600; margin-bottom: .45rem; }
.yr-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; }
.yr-day {
  font-size: .68rem;
  text-align: center;
  padding: .14rem 0;
  border-radius: 4px;
  color: var(--ink-soft);
}
.yr-day.busy { background: var(--gold-wash); color: var(--ink); font-weight: 700; }
.yr-day.today { background: var(--ink); color: var(--paper); font-weight: 700; }

/* ---------------------------------------------------------------- today dashboard */

.today {
  display: grid;
  gap: clamp(1rem, 3vw, 2.5rem);
  max-width: 75rem;
}
@media (min-width: 980px) {
  .today { grid-template-columns: 1.25fr 1fr; align-items: start; }
}
.hero-kicker {
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--gold-deep);
}
.hero-date {
  font-family: var(--serif);
  font-size: clamp(1.9rem, 5.2vw, 3.4rem);
  font-weight: 550;
  font-variation-settings: 'opsz' 100;
  line-height: 1.05;
  margin: .15rem 0 .6rem;
}
.hero-wx { display: flex; align-items: baseline; gap: .55rem; flex-wrap: wrap; }
.wx-emoji { font-size: 1.5rem; }
.wx-temp { font-family: var(--serif); font-size: 1.9rem; font-weight: 600; }
.wx-meta { color: var(--ink-soft); }
.hero-dinner {
  margin-top: .8rem;
  display: inline-block;
  font-size: 1rem;
  padding: .45rem .8rem;
  border-radius: 999px;
  background: var(--gold-wash);
  border: 1px solid var(--gold);
  text-align: left;
}
.hero-dinner.unset { background: none; border: 1px dashed var(--ink-faint); color: var(--ink-soft); }
.today-agenda { margin-top: .6rem; }
.agenda-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: .7rem;
  flex-wrap: wrap;
  text-align: left;
  padding: .55rem .3rem;
  border-bottom: 1px solid var(--line-soft);
  min-height: var(--tap);
}
.agenda-row:hover { background: var(--card); }
.agenda-time { font-weight: 700; font-size: .85rem; color: var(--ink-soft); min-width: 5.4rem; }
.agenda-title { font-size: 1.12rem; }

.side-tile {
  display: flex;
  align-items: baseline;
  gap: .6rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: .8rem 1rem;
  width: 100%;
  text-align: left;
}
.side-tile:hover { border-color: var(--gold-deep); }
.tile-big { font-family: var(--serif); font-size: 2rem; font-weight: 650; color: var(--gold-deep); }
.tile-lab { color: var(--ink-soft); }
.star-row { margin-top: .4rem; }
.star-line { display: flex; align-items: center; gap: .6rem; padding: .25rem 0; }
.star-n { letter-spacing: .06em; }
.up-day { margin-bottom: .7rem; }
.up-h { display: flex; align-items: baseline; gap: .6rem; margin-bottom: .15rem; }
.up-when { font-weight: 700; font-size: .82rem; letter-spacing: .05em; color: var(--gold-deep); text-transform: uppercase; }
.up-date { color: var(--ink-faint); font-size: .82rem; }
.up-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: .5rem;
  text-align: left;
  padding: .4rem .3rem;
  border-bottom: 1px solid var(--line-soft);
}
.up-row:hover { background: var(--card); }
.up-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-time { color: var(--ink-soft); font-size: .85rem; font-weight: 700; }

/* ---------------------------------------------------------------- lists (groceries & chores) */

.list-page { max-width: 44rem; }
.gro-form, .chore-form { display: flex; gap: .5rem; margin-bottom: 1rem; }
.chore-form { flex-direction: column; }
.chore-form-row { display: flex; gap: .5rem; flex-wrap: wrap; }
.chore-form-row > * { flex: 1 1 8rem; }
.gro-input { flex: 1; }
.gro-row, .chore-row {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .5rem .35rem;
  border-bottom: 1px solid var(--line-soft);
  min-height: var(--tap);
}
.gro-name, .chore-title { flex: 1; font-size: 1.08rem; }
.gro-row.done .gro-name, .chore-row.done .chore-title {
  text-decoration: line-through;
  text-decoration-color: var(--ink-faint);
  color: var(--ink-faint);
}
.chore-due { font-size: .8rem; font-weight: 700; color: var(--ink-soft); white-space: nowrap; }
.chore-row.overdue .chore-title { color: var(--barn); }
.badge-late { color: var(--barn); font-size: .78rem; font-weight: 700; white-space: nowrap; }
.row-del { color: var(--ink-faint); padding: .4rem; border-radius: 8px; }
.row-del:hover { color: var(--barn); background: var(--paper-deep); }
.gro-done { margin-top: 1.2rem; }
.gro-done summary {
  cursor: pointer;
  font-family: var(--serif);
  font-weight: 700;
  letter-spacing: .1em;
  font-size: .85rem;
  text-transform: uppercase;
  color: var(--ink-soft);
  padding: .4rem 0;
}
.gro-clear { margin-top: .7rem; }
.chore-group { margin-bottom: .6rem; }

/* ---------------------------------------------------------------- meals */

.meals-nav { margin-bottom: .4rem; }
.meals-hint { color: var(--ink-soft); margin-bottom: 1rem; }
.meals-week { display: flex; flex-direction: column; gap: .45rem; }
.meal-day {
  display: grid;
  grid-template-columns: 6.5rem 1fr;
  align-items: center;
  gap: .7rem;
}
.meal-day.today .meal-dow b { color: var(--gold-deep); }
.meal-dow { font-family: var(--serif); font-size: 1.05rem; color: var(--ink-soft); }
.meal-dow b { font-weight: 700; letter-spacing: .06em; }

/* ---------------------------------------------------------------- forms & sheet */

.f-input {
  width: 100%;
  min-width: 0;   /* iOS date/time inputs refuse to shrink without this */
  max-width: 100%;
  min-height: var(--tap);
  padding: .5rem .7rem;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--card);
}
input.f-input::-webkit-date-and-time-value { text-align: left; } /* iOS centers it */
/* iOS gives date/time inputs a fixed intrinsic width that tramples flex columns
   (and paints the current time in empty fields). appearance:none makes them
   behave like normal text fields that honor their column width. */
input[type="date"].f-input,
input[type="time"].f-input {
  -webkit-appearance: none;
  appearance: none;
  display: block;
}
:focus-visible { outline: 2px solid var(--gold-deep); outline-offset: 2px; }
.f-input:focus-visible { outline: 2px solid var(--gold-deep); outline-offset: 1px; border-color: transparent; }
textarea.f-input { min-height: 3.4rem; resize: vertical; }
.f-lab {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-top: .8rem;
  flex: 1;
  min-width: 0; /* let rows compress on phones instead of overflowing */
}
.f-row2 { display: flex; flex-wrap: wrap; gap: 0 .7rem; }
.f-row2 .f-lab { flex: 1 1 9.5rem; }
.f-chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.pchip, .cchip {
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: .35rem .8rem;
  min-height: 38px;
  font-weight: 700;
  color: var(--ink-soft);
  transition: all .15s;
}
.pchip.on { background: var(--pc); border-color: var(--pc); color: #fdf6ea; }
.cchip.on { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.dchip {
  border: 1.5px solid var(--line);
  border-radius: 999px;
  width: 42px;
  min-height: 42px;
  font-weight: 700;
  color: var(--ink-soft);
  transition: all .15s;
}
.dchip.on { background: var(--gold-deep); border-color: var(--gold-deep); color: var(--paper); }
.day-caption { font-style: italic; text-transform: none; letter-spacing: 0; font-weight: 400; font-size: .85rem; color: var(--ink-faint); }

/* House-standard refresh button: full-width, bold, spinner-on-click, hard reload */
.btn-refresh {
  width: 100%;
  min-height: 48px;
  border-radius: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .55rem;
  background: var(--ink);
  color: var(--paper);
  margin-top: .9rem;
}
.btn-refresh:active { transform: translateY(1px); }
.btn-refresh .r-icon { width: 19px; height: 19px; display: block; }
.btn-refresh.busy .r-icon { animation: rspin .9s linear infinite; }
@keyframes rspin { to { transform: rotate(360deg); } }

#sheet {
  border: 0;
  border-radius: 16px 16px 0 0;
  padding: 0;
  width: 100%;
  max-width: 100vw;
  margin: auto 0 0;
  max-height: 92vh;  /* fallback for pre-dvh Safari */
  max-height: 92dvh;
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow);
  /* The DIALOG is the one and only scroller — nested scrollers inside a
     top-layer <dialog> hand iOS swipes to the page behind. */
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
/* And while the sheet is up, the view behind it simply cannot scroll. */
html.sheet-open #view { overflow-y: hidden; }
#sheet::backdrop { background: rgba(35, 28, 15, .45); }
@media (min-width: 700px) {
  #sheet {
    margin: auto;
    width: min(34rem, 92vw);
    border-radius: 16px;
    border: 1px solid var(--line);
  }
}
.sheet-body { padding: 1.1rem 1.2rem calc(1.2rem + env(safe-area-inset-bottom)); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .8rem; }
.sheet-title { font-family: var(--serif); font-size: 1.4rem; font-weight: 600; }
.sheet-x { border: 0; font-size: 1rem; }
.sheet-actions { display: flex; gap: .6rem; margin-top: 1.3rem; align-items: center; }
.spacer { flex: 1; }

/* ---------------------------------------------------------------- settings */

.set-sec { margin-bottom: 1.4rem; }
.set-person { display: flex; align-items: center; gap: .6rem; padding: .45rem 0; flex-wrap: wrap; }
.set-person .f-input { max-width: 11rem; }
.swatches { display: flex; gap: .3rem; }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid transparent; }
.swatch.on { border-color: var(--ink); transform: scale(1.12); }
.set-note { color: var(--ink-faint); font-size: .85rem; margin-top: .6rem; }
.set-feed { padding: .35rem 0 .1rem; border-bottom: 1px solid var(--line-soft); }
.set-feed-row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.set-feed-row .f-input { max-width: 11rem; }
.feed-status { color: var(--ink-faint); font-size: .8rem; padding: .25rem 0 .4rem 1.6rem; }
.feed-add { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .8rem; }
.feed-add .f-input { flex: 1 1 12rem; min-width: 0; }
.feed-tools { margin-top: .6rem; }
.feed-when { display: flex; align-items: center; gap: .5rem; font-size: 1.05rem; margin: .3rem 0 .5rem; }
.feed-loc { color: var(--ink-soft); margin-bottom: .4rem; }
.set-people > .btn-ghost { margin-top: .5rem; }

/* ---------------------------------------------------------------- money */

.money { max-width: 52rem; }
.mny-import-btn { flex: 0 0 auto; padding: .5rem .9rem; }

.mny-accts { display: flex; flex-wrap: wrap; gap: .4rem; margin: .2rem 0 .9rem; }

.mny-heroes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
  gap: .6rem;
  margin-bottom: .9rem;
}
.mny-hero {
  display: flex;
  flex-direction: column;
  gap: .15rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: .75rem .9rem;
}
.mny-hero-n {
  font-family: var(--serif);
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 650;
  color: var(--gold-deep);
  font-variant-numeric: tabular-nums;
}
.mny-hero-n.quiet { color: var(--ink); }
.mny-hero-lab { color: var(--ink-soft); font-size: .82rem; }
.mny-delta { font-size: .78rem; font-weight: 700; color: var(--ink-faint); }
.mny-delta.up { color: var(--barn); }
.mny-delta.down { color: var(--ok); }

/* account balance strip — the anchor chips + overdraft truth-telling */
.mny-balstrip { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0 0 .55rem; }
.mny-bal {
  display: inline-flex;
  align-items: baseline;
  gap: .45rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .32rem .8rem;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.mny-bal:hover { background: var(--paper-deep); }
.mny-bal-name { font-size: .8rem; color: var(--ink-soft); }
.mny-bal-amt { font-weight: 800; font-variant-numeric: tabular-nums; }
.mny-bal-asof { font-size: .72rem; color: var(--ink-faint); }
.mny-bal-set { font-size: .8rem; font-weight: 700; color: var(--gold-deep); }
.mny-bal.neg {
  border-color: var(--barn);
  background: color-mix(in srgb, var(--barn) 9%, var(--card));
}
.mny-bal.neg .mny-bal-amt { color: var(--barn); }

/* the month's penny-exact reconciliation line */
.mny-mathline {
  color: var(--ink-soft);
  font-size: .88rem;
  font-variant-numeric: tabular-nums;
  margin: 0 0 .9rem;
}
.mny-mathline b.pos { color: var(--ok); }
.mny-mathline b.neg { color: var(--barn); }

/* ghost row in "Where it went": transfers shown but visually not-spending */
.mny-catrow.ghost .mny-cat-name { color: var(--ink-soft); font-style: italic; }
.mny-catrow.ghost .mny-cat-amt { color: var(--ink-soft); }

/* cash-flow radar */
.mny-head-btns { display: flex; gap: .5rem; flex: 0 0 auto; }
.mny-radar-btn { font-weight: 700; }
.mny-alert {
  width: 100%;
  text-align: left;
  background: color-mix(in srgb, var(--barn) 14%, var(--card));
  border: 1.5px solid var(--barn);
  color: var(--barn);
  border-radius: var(--r);
  padding: .6rem .8rem;
  font-weight: 700;
  margin-bottom: .6rem;
  min-height: var(--tap);
}
.radar { max-width: 56rem; }
.radar-title { font-family: var(--serif); font-size: clamp(1.3rem, 3.5vw, 1.9rem); font-weight: 600; flex: 1; }
.radar-asof { color: var(--ink-faint); font-size: .78rem; }
.mny-hero.radar-bad { border-color: var(--barn); background: color-mix(in srgb, var(--barn) 10%, var(--card)); }
.mny-hero-n.radar-red { color: var(--barn); font-size: 1.35rem; letter-spacing: .04em; }
.radar-prob {
  border: 1px solid var(--line);
  border-left: 4px solid var(--barn);
  border-radius: var(--r);
  background: var(--card);
  padding: .6rem .8rem;
  margin-bottom: .6rem;
}
.radar-prob-head { display: flex; align-items: baseline; gap: .5rem; }
.radar-flag { font-size: 1rem; }
.radar-prob-who { font-weight: 700; font-size: 1.05rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.radar-prob-fees { color: var(--barn); font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.radar-prob-line { color: var(--ink-soft); font-size: .88rem; margin-top: .2rem; }
.radar-prob-fix { font-size: .92rem; margin-top: .35rem; padding-top: .35rem; border-top: 1px dashed var(--line-soft); }
.radar-up {
  display: grid;
  grid-template-columns: 6.6rem minmax(0, 1fr) auto auto auto;
  gap: .55rem;
  align-items: baseline;
  padding: .4rem .45rem;
  border-bottom: 1px solid var(--line-soft);
}
.radar-up.warn { background: var(--gold-wash); border-radius: 8px; }
.radar-up-date { font-weight: 700; font-size: .85rem; color: var(--ink-soft); white-space: nowrap; }
.radar-up-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.radar-up-acct { color: var(--ink-faint); font-size: .75rem; white-space: nowrap; }
.radar-up-flag { color: var(--barn); font-size: .78rem; font-weight: 700; white-space: nowrap; }
.radar-stretch { padding: .3rem 0; font-size: .95rem; }
.radar-stretch.warn { color: var(--barn); font-weight: 700; }
.radar-fee-line { line-height: 1.5; }
@media (max-width: 700px) {
  .radar-up { grid-template-columns: 5.2rem minmax(0, 1fr) auto; }
  .radar-up-acct, .radar-up-flag { grid-column: 2; font-size: .72rem; }
  .radar-asof { display: none; }
}

.mny-nudge {
  width: 100%;
  text-align: left;
  background: var(--gold-wash);
  border: 1px solid var(--gold);
  border-radius: var(--r);
  padding: .55rem .8rem;
  font-weight: 700;
  margin-bottom: .4rem;
  min-height: var(--tap);
}

.mny-sec { margin-bottom: .6rem; }

/* category bar-table: glyph · name · bar · amount (the bar IS the chart) */
.mny-catrow {
  width: 100%;
  display: grid;
  grid-template-columns: 1.5rem minmax(6.5rem, 10rem) minmax(0, 1fr) auto;
  align-items: center;
  gap: .55rem;
  padding: .42rem .45rem;
  border-radius: 8px;
  text-align: left;
  min-height: 40px;
}
.mny-catrow:hover { background: var(--paper-deep); }
.mny-catrow.on { background: var(--gold-wash); }
.mny-cat-glyph { font-size: 1rem; line-height: 1; }
.mny-cat-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .95rem; }
.mny-bar-wrap { min-width: 0; }
.mny-bar {
  display: block;
  height: 12px;
  min-width: 2px;
  border-radius: 2px 4px 4px 2px; /* rounded data end, anchored start */
  background: var(--gold-deep);
}
.mny-cat-amt {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: .9rem;
  text-align: right;
  white-space: nowrap;
}

.mny-trend { max-width: 27rem; }
.mny-trend-svg { width: 100%; height: auto; display: block; }
.mny-trend-svg rect:focus-visible { outline: 2px solid var(--gold-deep); }
.mny-trend-val { font-size: 11px; font-weight: 700; fill: var(--ink-soft); }
.mny-trend-mo { font-size: 11px; fill: var(--ink-faint); }
.mny-trend-mo.sel { fill: var(--ink); font-weight: 700; }

.mny-recur {
  display: grid;
  grid-template-columns: 1.5rem minmax(0, 1fr) auto auto; /* names ellipsize, never overflow */
  align-items: baseline;
  gap: .55rem;
  padding: .38rem .45rem;
  border-bottom: 1px solid var(--line-soft);
}
.mny-recur-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mny-recur-meta { color: var(--ink-faint); font-size: .78rem; white-space: nowrap; }
.mny-recur-total { color: var(--ink-soft); font-style: italic; font-size: .88rem; margin-top: .45rem; }

.mny-ledger-head { display: flex; align-items: baseline; justify-content: space-between; gap: .6rem; }
.mny-clear { font-size: .78rem; padding: .25rem .7rem; min-height: 32px; }
.mny-search { max-width: 24rem; margin: .2rem 0 .6rem; }

.mny-day { margin-bottom: .55rem; }
.mny-day-h {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .6rem;
  font-family: var(--serif);
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: .5rem 0 .1rem;
}
.mny-day-sum { color: var(--ink-faint); letter-spacing: 0; text-transform: none; font-family: var(--sans); font-weight: 400; }
.mny-txn {
  width: 100%;
  display: grid;
  grid-template-columns: 1.5rem minmax(0, 1fr) auto auto;
  align-items: center;
  gap: .55rem;
  padding: .42rem .45rem;
  border-bottom: 1px solid var(--line-soft);
  min-height: var(--tap);
  text-align: left;
}
.mny-txn:hover { background: var(--card); }
.mny-txn-glyph { font-size: 1rem; line-height: 1; }
.mny-txn-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .98rem; }
.mny-txn-note { color: var(--ink-faint); }
.mny-txn-acct { color: var(--ink-faint); font-size: .72rem; white-space: nowrap; }
.mny-txn-amt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mny-txn-amt.in { color: var(--ok); }
.mny-txn.off { opacity: .55; }
.mny-txn.off .mny-txn-amt { text-decoration: line-through; }
.mny-more { margin-top: .6rem; }

/* debts — the circle of what's owed + payoff order */
.mny-donut { max-width: 300px; margin: .3rem auto .2rem; }
.mny-donut-svg { width: 100%; height: auto; display: block; }
.mny-donut-total {
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 650;
  fill: var(--ink);
  font-variant-numeric: tabular-nums;
}
.mny-donut-sub { font-size: 12px; fill: var(--ink-soft); }
.mny-debt-interest { color: var(--ink-soft); font-size: .92rem; text-align: center; margin: .2rem 0 .7rem; }
.mny-payoff-modes { margin-bottom: .3rem; }
.mny-payoff-note { margin: 0 0 .5rem; }
.mny-debt {
  width: 100%;
  display: grid;
  grid-template-columns: 1.4rem 14px minmax(0, 1fr) auto;
  align-items: center;
  gap: .55rem;
  padding: .5rem .45rem;
  border-bottom: 1px solid var(--line-soft);
  min-height: var(--tap);
  text-align: left;
  border-radius: 8px;
}
.mny-debt:hover { background: var(--paper-deep); }
.mny-debt.first { background: var(--gold-wash); }
.mny-debt-rank {
  font-family: var(--serif);
  font-weight: 700;
  color: var(--ink-faint);
  text-align: center;
}
.mny-debt.first .mny-debt-rank { color: var(--gold-deep); }
.mny-debt-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--dc);
  flex: 0 0 auto;
}
.mny-debt-dot.hatch,
.mny-cswatch.hatch {
  background: repeating-linear-gradient(45deg, var(--dc) 0 3.5px, var(--card) 3.5px 5.5px);
}
.mny-debt-main { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.mny-debt-name {
  font-size: 1rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mny-debt-first-tag {
  background: var(--gold);
  color: #2b2312;
  font-size: .66rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: .1rem .45rem;
  margin-left: .45rem;
  white-space: nowrap;
}
.mny-debt-meta {
  font-size: .78rem;
  color: var(--ink-faint);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mny-debt-meta.warn { color: var(--barn); }
.mny-debt-amt {
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.mny-cswatch { background: var(--dc); }
@media (max-width: 700px) {
  .mny-debt-meta { white-space: normal; } /* the warnings must never truncate on phones */
}

.mny-welcome { max-width: 38rem; }
.mny-wel-title { font-family: var(--serif); font-size: clamp(1.5rem, 4vw, 2.1rem); font-weight: 600; margin-bottom: .5rem; }
.mny-wel-p { color: var(--ink-soft); margin-bottom: .9rem; line-height: 1.5; }
.mny-wel-steps { padding-left: 1.25rem; display: flex; flex-direction: column; gap: .55rem; line-height: 1.45; }
.mny-wel-btn { width: 100%; margin-top: 1.1rem; }
.mny-offline { text-align: center; padding: 2rem 0; display: flex; flex-direction: column; gap: .6rem; align-items: center; }

/* import + transaction sheets */
.mny-file { padding: .45rem .55rem; }
.mny-preview {
  background: var(--paper-deep);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: .7rem .85rem;
  margin-top: .9rem;
}
.mny-prev-line { margin: .15rem 0; font-size: .92rem; }
.mny-prev-err { color: var(--barn); }
.mny-prev-warn { color: var(--barn); }
.mny-prev-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.mny-prev-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mny-flip { display: flex; align-items: center; gap: .5rem; margin: .7rem 0 .2rem; font-size: .92rem; }
.mny-flip input { width: 18px; height: 18px; accent-color: var(--gold-deep); flex: 0 0 auto; }
.mny-map { margin-top: .6rem; }
.mny-map summary { cursor: pointer; font-size: .85rem; color: var(--ink-soft); padding: .3rem 0; }
.mny-sort-hint { margin: -.3rem 0 .6rem; }
.mny-sort-last {
  display: flex;
  align-items: center;
  gap: .6rem;
  background: var(--gold-wash);
  border: 1px solid var(--gold);
  border-radius: var(--r);
  padding: .35rem .4rem .35rem .7rem;
  margin-bottom: .7rem;
  font-size: .9rem;
}
.mny-sort-last-txt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mny-sort-undo { min-height: 36px; padding: .3rem .8rem; font-weight: 700; flex: 0 0 auto; }
.mny-sheet-amt { font-family: var(--serif); font-size: 1.9rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.mny-sheet-amt.in { color: var(--ok); }
.mny-sheet-meta { color: var(--ink-soft); margin: .1rem 0 .5rem; }
.mny-sheet-desc {
  font-size: .8rem;
  color: var(--ink-faint);
  background: var(--paper-deep);
  border-radius: 8px;
  padding: .4rem .55rem;
  word-break: break-word;
  margin-bottom: .4rem;
}

@media (max-width: 700px) {
  .mny-txn-acct { display: none; }
  .mny-recur-when { display: none; } /* "· last Aug 12" is desktop garnish */
  .mny-catrow { grid-template-columns: 1.5rem minmax(5.5rem, 7.5rem) minmax(0, 1fr) auto; gap: .45rem; }
  .mny-cat-name { font-size: .88rem; }
}

/* ---------------------------------------------------------------- toasts */

#toasts {
  position: fixed;
  bottom: calc(4.6rem + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  width: min(26rem, calc(100vw - 2rem));
}
@media (min-width: 900px) { #toasts { bottom: 1.4rem; } }
.toast {
  display: flex;
  align-items: center;
  gap: .7rem;
  background: var(--ink);
  color: var(--paper);
  border-radius: 12px;
  padding: .7rem .95rem;
  box-shadow: var(--shadow);
  animation: rise .3s cubic-bezier(.22, 1, .36, 1);
}
.toast span { flex: 1; }
.toast-act {
  color: var(--gold);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: .82rem;
}
.toast-x { color: var(--paper); opacity: .7; padding: .2rem .3rem; }

/* ---------------------------------------------------------------- ambient (wall) mode */

#ambient[hidden] { display: none !important; } /* author display would beat [hidden] */
#ambient:not(.on) { pointer-events: none; }    /* never eat taps while faded out */
#ambient {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #191509;
  color: #efe7d2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .6rem;
  text-align: center;
  opacity: 0;
  transition: opacity .4s ease;
  cursor: pointer;
  padding: 2rem;
}
#ambient.on { opacity: 1; }
.amb-clock {
  font-family: var(--serif);
  font-size: clamp(5rem, 22vw, 15rem);
  font-weight: 350;
  font-variation-settings: 'opsz' 144;
  line-height: 1;
  letter-spacing: .01em;
}
.amb-date { font-family: var(--serif); font-size: clamp(1.2rem, 4vw, 2.2rem); color: #c0b291; }
.amb-wx { font-size: clamp(1rem, 3vw, 1.5rem); color: #c0b291; margin-top: .4rem; }
.amb-next { margin-top: 1.6rem; display: flex; flex-direction: column; gap: .45rem; }
.amb-line { display: flex; gap: .9rem; align-items: baseline; font-size: clamp(1.05rem, 3.2vw, 1.6rem); }
.amb-when {
  color: var(--gold);
  font-weight: 700;
  font-size: .72em;
  text-transform: uppercase;
  letter-spacing: .1em;
  min-width: 7.5em;
  text-align: right;
}
.amb-quiet { color: #857852; font-style: italic; }

/* ---------------------------------------------------------------- scrollbars (wall polish) */

#view::-webkit-scrollbar { width: 10px; }
#view::-webkit-scrollbar-thumb { background: var(--line); border-radius: 5px; }
#view::-webkit-scrollbar-track { background: transparent; }

/* ---------------------------------------------------------------- gate
   Sign-in + household onboarding. Sits above everything and starts visible,
   so a household's data can never paint behind it — not even for one frame.
   Uses the same paper/ink/wheat tokens as the app so signing in already looks
   like the thing you are signing into. */

#gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: max(20px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom));
  background: var(--paper);
  overflow-y: auto;
}

#gate[hidden] { display: none !important; }  /* authored display beats [hidden] */

.gate-card {
  width: 100%;
  max-width: 27rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: clamp(20px, 5vw, 34px);
}

.gate-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.gate-wheat { font-size: 1.6rem; line-height: 1; }

.gate-name {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(1.5rem, 5vw, 1.9rem);
  color: var(--ink);
  margin: 0;
}

.gate-lede {
  color: var(--ink-soft);
  line-height: 1.5;
  margin: 0 0 18px;
}

.gate-fine {
  color: var(--ink-faint);
  font-size: .85rem;
  line-height: 1.45;
  margin: 14px 0 0;
}

.gate-err {
  background: color-mix(in srgb, var(--barn) 10%, transparent);
  border-left: 3px solid var(--barn);
  color: var(--barn);
  border-radius: 4px;
  padding: 9px 12px;
  margin: 0 0 16px;
  font-size: .92rem;
  line-height: 1.4;
}

#gate .f-lab { display: block; margin-bottom: 14px; }

.gate-go {
  width: 100%;
  min-height: var(--tap);
  margin-top: 4px;
}

.gate-back {
  width: 100%;
  min-height: var(--tap);
  margin-top: 10px;
}

/* Six-digit code: wide tracking so a typo is visible at a glance. */
.gate-code {
  font-family: var(--serif);
  font-size: 1.5rem;
  letter-spacing: .34em;
  text-align: center;
}

.gate-or {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink-faint);
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin: 20px 0 16px;
}
.gate-or::before,
.gate-or::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

.gate-pick { display: grid; gap: 10px; margin-bottom: 6px; }

/* ---- household controls (Settings) */
.set-invite { margin-top: 10px; }

/* The code gets read aloud across a room, so: big, monospaced-ish tracking,
   and selectable in one tap. */
.invite-code {
  font-family: var(--serif);
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: .18em;
  text-align: center;
  color: var(--ink);
  background: var(--gold-wash);
  border: 1px dashed var(--gold-deep);
  border-radius: var(--r);
  padding: 14px 10px;
  margin-bottom: 8px;
  user-select: all;
}

/* Each live code is its own card so "turn this one off" has an obvious target
   when more than one is outstanding. */
.invite-card {
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 10px;
  margin-bottom: 10px;
}
.invite-card .invite-code { margin-bottom: 6px; }

.invite-meta {
  color: var(--ink-faint);
  font-size: .82rem;
  text-align: center;
  margin-bottom: 8px;
}

.invite-acts { display: flex; gap: 8px; }
/* Equal widths so no single action reads as the default one — copying and
   revoking are both one tap and should look like it. */
.invite-act { flex: 1 1 0; min-width: 0; }
.invite-revoke { color: var(--ink-faint); }

/* ---- household members */
.set-members { margin-top: 8px; }

.member-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line-soft);
}
.member-row:last-child { border-bottom: 0; }

/* Emails are long and the column is narrow; truncate the address rather than
   let it push "joined" off the row. */
.member-who {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.member-you {
  margin-left: 6px;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ink-faint);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 6px;
}

.member-when { color: var(--ink-faint); font-size: .82rem; white-space: nowrap; }

.set-subh {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--ink-faint);
  margin: 16px 0 0;
}

.set-switch:not(:empty) { margin-top: 14px; }
.set-signout { margin-top: 14px; }
