/* The Hoppers — "Fridge door": paper white, ink outlines, offset shadows, a solid colour per child. */
:root {
  --bg: #FBFBF8; --card: #FFFFFF; --ink: #1B1B1B; --muted: #555555; --line: #1B1B1B; --soft-line: #E4E2DC;
  --accent: #F5C542; --accent-ink: #1B1B1B; --accent-soft: #FFF3C9;
  --tomato: #E8553D; --sky: #4A90E2; --leaf: #3FB27F;
  --warn: #C2321D; --warn-soft: #FDE3DE; --ok: #1F7A4E;
  --radius: 20px; --shadow: 5px 5px 0 var(--ink); --shadow-sm: 3px 3px 0 var(--ink);
  font-family: 'Bricolage Grotesque', ui-sans-serif, system-ui, sans-serif; color: var(--ink); background: var(--bg);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { overflow-x: hidden; overflow-x: clip; max-width: 100%; }
body { margin: 0; min-height: 100vh; min-height: 100dvh; font-size: 16px; line-height: 1.45; -webkit-text-size-adjust: 100%; }
a { color: var(--ink); text-underline-offset: 3px; }
h1, h2, h3 { line-height: 1.1; margin: 0 0 .6em; font-weight: 800; letter-spacing: -0.02em; }
h2 { font-size: 1.9rem; } h3 { font-size: 1.2rem; }
.muted { color: var(--muted); } .small { font-size: .88rem; }
.error { color: var(--warn); background: var(--warn-soft); padding: .6em .8em; border-radius: 12px; border: 2px solid var(--warn); font-weight: 600; }
code { font-size: .95em; background: var(--accent-soft); padding: .1em .4em; border-radius: 6px; }

/* header */
.top { display: flex; align-items: center; gap: 1.2rem; padding: .8rem 1.4rem; background: var(--bg); border-bottom: 2px solid var(--ink); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: .55rem; font-size: 1.45rem; font-weight: 800; letter-spacing: -0.02em; margin: 0; white-space: nowrap; text-transform: lowercase; }
.brand .logo { width: 34px; height: 34px; border-radius: 11px; background: var(--accent); border: 2px solid var(--ink); box-shadow: var(--shadow-sm); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.top nav { display: flex; gap: .15rem; flex-wrap: wrap; }
.top nav a { text-decoration: none; color: var(--ink); padding: .4rem .85rem; border-radius: 999px; font-weight: 600; white-space: nowrap; }
.top nav a:hover { background: var(--accent-soft); }
.top nav a.on { background: var(--ink); color: var(--bg); }
.top .spacer { flex: 1; }
.badge { background: var(--tomato); color: #fff; border-radius: 999px; font-size: .72rem; padding: 0 .45em; margin-left: .3em; font-weight: 800; }
main#view { max-width: 1080px; margin: 0 auto; padding: 1.8rem 1.4rem 5rem; }

/* menu: inline on desktop, a drop-down on phones */
.menu-panel { display: contents; }
.menu-btn { display: none; }
.person-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1.4fr) auto; gap: .8rem; align-items: center; padding: .7rem 0; border-bottom: 2px solid var(--soft-line); }
.person-row:last-child { border-bottom: 0; }
.row.wrap { flex-wrap: wrap; gap: .6rem; }
.access-list { margin-top: .4rem; }
.access-row { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) auto; gap: .4rem .8rem; align-items: center; padding: .75rem 0; border-bottom: 2px solid var(--soft-line); }
.access-row:last-child { border-bottom: 0; }
.access-who strong, .access-who .small { overflow-wrap: anywhere; }
.access-actions { display: flex; gap: .4rem; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 640px) {
  .access-row { grid-template-columns: minmax(0, 1fr) auto; }
  .access-role { text-align: right; }
  .access-actions { grid-column: 1 / -1; justify-content: flex-start; }
}
.colour-pick { display: flex; gap: .4rem; align-items: center; }
.colour-pick select { width: auto; margin: 0; padding: .3rem .5rem; }
.colour-pick input[type=color] { width: 44px; height: 38px; margin: 0; padding: .15rem; }

/* surfaces */
.card { background: var(--card); border: 2px solid var(--ink); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.2rem 1.35rem; margin-bottom: 1.3rem; }
a.card { transition: transform .08s ease, box-shadow .08s ease; }
a.card:hover { transform: translate(-2px, -2px); box-shadow: 7px 7px 0 var(--ink); }
.card.narrow { max-width: 440px; }
.page main.card { margin: 10vh auto; }
.page .brand { margin-bottom: 1.2rem; }
.grid { display: grid; gap: 1.3rem; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); margin-bottom: 1.3rem; }
.grid > .card { margin-bottom: 0; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.4rem; }
.page-head .kicker { font-size: .9rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.page-head h2 { font-size: clamp(2.2rem, 5vw, 3.6rem); letter-spacing: -0.035em; margin: 0; line-height: 1; }

/* inside narrow child cards the category drops under the title */
.kid .ev { grid-template-columns: 64px minmax(0, 1fr); }
.kid .ev > .tag { grid-column: 2; }

/* child cards: a solid colour header per child */
.kid { padding: 0; overflow: hidden; }
.kid > .kid-head { background: var(--c, var(--sky)); color: var(--c-ink, #fff); padding: .8rem 1.2rem; border-bottom: 2px solid var(--ink); display: flex; justify-content: space-between; align-items: center; gap: .6rem; }
.kid > .kid-head h3 { margin: 0; font-size: 1.6rem; }
.kid > .kid-head .pill { font-size: .8rem; font-weight: 700; background: #fff; color: var(--ink); border: 2px solid var(--ink); border-radius: 999px; padding: .1rem .6rem; }
.kid > .kid-body { padding: .9rem 1.2rem 1.1rem; }

/* forms */
label { display: block; font-size: .88rem; font-weight: 600; color: var(--muted); margin: .7rem 0; }
label.check { display: flex; gap: .55rem; align-items: center; color: var(--ink); font-size: 1rem; font-weight: 600; }
input, select, textarea { display: block; width: 100%; min-width: 0; max-width: 100%; margin-top: .3rem; font: inherit; font-size: 16px; font-weight: 500; color: var(--ink); background: #fff; border: 2px solid var(--ink); border-radius: 12px; padding: .55rem .7rem; }
input[type=checkbox] { width: 20px; height: 20px; margin: 0; accent-color: var(--ink); flex: none; }
input[type=color] { padding: .2rem; height: 44px; }
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--accent); outline-offset: 1px; }
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .9rem; }
.two > * { min-width: 0; }
input[type=date], input[type=time] { -webkit-appearance: none; appearance: none; min-height: 44px; }
button { font: inherit; font-weight: 700; cursor: pointer; border: 2px solid var(--ink); background: #fff; color: var(--ink); border-radius: 14px; padding: .5rem 1rem; box-shadow: var(--shadow-sm); transition: transform .06s ease, box-shadow .06s ease; min-height: 44px; }
button:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
button:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
button.primary { background: var(--accent); color: var(--accent-ink); }
button.danger { color: var(--warn); }
button.link { border: 0; background: none; box-shadow: none; color: var(--ink); padding: 0; min-height: 0; text-decoration: underline; font-weight: 600; }
button.link:hover, button.link:active { transform: none; box-shadow: none; }
button.small, .row button.small { min-height: 34px; padding: .25rem .7rem; font-size: .88rem; border-radius: 10px; }
button:disabled { opacity: .5; cursor: default; transform: none; }

/* events */
.day { margin-bottom: 1.3rem; }
.day h3 { font-size: .9rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); border-bottom: 2px solid var(--ink); padding-bottom: .35rem; }
.day.today h3 { color: var(--ink); }
.day.today h3::after { content: 'Today'; margin-left: .6rem; background: var(--accent); border: 2px solid var(--ink); border-radius: 999px; padding: 0 .5rem; font-size: .75rem; }
.ev { display: grid; grid-template-columns: 78px 1fr auto; gap: .9rem; padding: .6rem .5rem; border-radius: 12px; cursor: pointer; align-items: start; }
.ev:hover { background: var(--accent-soft); }
.ev .time { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 1.05rem; }
.ev .time .small { font-weight: 600; color: var(--muted); }
.ev .title { font-weight: 700; font-size: 1.08rem; }
.ev .meta { color: var(--muted); font-size: .9rem; }
.ev.handoff { background: var(--accent); border: 2px solid var(--ink); box-shadow: var(--shadow-sm); margin: .4rem 0; }
.ev.handoff .meta { color: var(--ink); }
.chip { display: inline-flex; align-items: center; gap: .35em; font-size: .8rem; font-weight: 700; border-radius: 999px; padding: .05em .6em; background: #fff; border: 2px solid var(--ink); margin-right: .25em; }
.chip .dot { width: .6em; height: .6em; border-radius: 50%; border: 1.5px solid var(--ink); }
.sched-change { white-space: nowrap; display: inline-block; background: var(--tomato); color: #fff; border: 2px solid var(--ink); border-radius: 999px; padding: .05rem .5rem; letter-spacing: .04em; }
.tag { font-size: .74rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; }
.empty { color: var(--muted); padding: .6rem 0; }

/* gifts & lists */
.item { display: grid; grid-template-columns: 1fr auto; gap: .7rem; padding: .8rem 0; border-bottom: 2px solid var(--soft-line); }
.item:last-child { border-bottom: 0; }
.item .title { font-weight: 700; font-size: 1.05rem; }
.reserved { color: var(--ok); font-size: .9rem; font-weight: 700; }
.idea { font-size: .72rem; background: var(--accent); border: 2px solid var(--ink); border-radius: 6px; padding: 0 .4em; margin-left: .45em; font-weight: 700; }
.check-row { display: grid; grid-template-columns: 28px 1fr auto; gap: .7rem; align-items: start; padding: .65rem 0; border-bottom: 2px solid var(--soft-line); }
.check-row:last-child { border-bottom: 0; }
.check-row input[type=checkbox] { margin-top: .2rem; }
.done .title, .done > div > .title { text-decoration: line-through; color: var(--muted); }
.overdue { color: var(--warn); font-weight: 700; }
.money { font-variant-numeric: tabular-nums; }
#quick { box-shadow: var(--shadow-sm); }

/* meals */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: .6rem; }
.week .col { background: #fff; border: 2px solid var(--ink); border-radius: 16px; padding: .6rem; min-height: 140px; box-shadow: var(--shadow-sm); }
.week .col h4 { margin: 0 0 .5rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 800; }
.meal { font-size: .92rem; font-weight: 700; padding: .4rem .5rem; border-radius: 10px; background: var(--accent); border: 2px solid var(--ink); margin-bottom: .4rem; cursor: pointer; }
.meal .slot { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; display: block; font-weight: 700; }

/* settings */
.switch-row { display: grid; grid-template-columns: 1fr auto; gap: .9rem; padding: .7rem 0; border-bottom: 2px solid var(--soft-line); align-items: center; }
.switch-row:last-child { border-bottom: 0; }
.rsvp-btns button.on { background: var(--ink); color: var(--bg); }

/* dialogs */
dialog { border: 2px solid var(--ink); border-radius: 22px; padding: 0; width: min(580px, calc(100vw - 24px)); max-width: calc(100vw - 24px); box-sizing: border-box; overflow-x: hidden; box-shadow: 8px 8px 0 var(--ink); max-height: 92vh; overflow-y: auto; background: var(--card); color: var(--ink); }
dialog::backdrop { background: rgba(27, 27, 27, .45); }
dialog form, dialog .body { padding: 1.4rem 1.5rem; }
dialog .actions { display: flex; gap: .7rem; justify-content: flex-end; margin-top: 1.2rem; flex-wrap: wrap; }
fieldset { border: 0; padding: 0; margin: .6rem 0; }
legend { padding: 0; }
.toast { position: fixed; bottom: 1.4rem; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: .7rem 1.1rem; border-radius: 14px; z-index: 50; font-weight: 700; box-shadow: 4px 4px 0 var(--accent); }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
td, th { text-align: left; padding: .55rem .35rem; border-bottom: 2px solid var(--soft-line); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; border-bottom-color: var(--ink); }
details summary { cursor: pointer; font-weight: 600; }

@media (max-width: 760px) {
  .top { flex-wrap: nowrap; padding: .7rem 1rem; gap: .6rem; position: sticky; }
  .brand { font-size: 1.25rem; }
  .top > a:first-child { flex: 1; min-width: 0; }
  .menu-btn { display: inline-flex; align-items: center; gap: .35rem; background: var(--ink); color: var(--bg); box-shadow: 3px 3px 0 var(--accent); border-radius: 999px; padding: .45rem .95rem; }
  .menu-panel { display: none; position: fixed; top: var(--top-h, 64px); left: 0; right: 0; z-index: 30; background: var(--bg); border-bottom: 2px solid var(--ink); box-shadow: 0 6px 0 rgba(27,27,27,.08); padding: .6rem 1rem 1rem; flex-direction: column; gap: .3rem; max-height: calc(100dvh - var(--top-h, 64px)); overflow-y: auto; overscroll-behavior: contain; }
  .top.open .menu-panel { display: flex; }
  .menu-panel nav { flex-direction: column; gap: .2rem; }
  .menu-panel nav a { font-size: 1.15rem; padding: .7rem .9rem; border-radius: 14px; }
  .menu-panel .spacer { display: none; }
  .menu-panel #family-switch { margin: .4rem 0; }
  .menu-panel .signout { border-top: 2px solid var(--soft-line); padding-top: .6rem; margin-top: .2rem; }
  .menu-panel .signout button { font-size: 1.05rem; padding: .5rem .9rem; }
  .person-row { grid-template-columns: 1fr auto; row-gap: .3rem; }
  .person-row .meta { grid-column: 1; color: var(--muted); font-size: .88rem; }
  .person-row .colour-pick { grid-column: 2; grid-row: 1 / span 2; }
  .page-head h2 { font-size: 2.4rem; }
  .two { grid-template-columns: 1fr; }
  .ev { grid-template-columns: 62px 1fr; }
  .ev > :last-child { grid-column: 2; }
  .week { grid-template-columns: 1fr; }
  .card { box-shadow: 4px 4px 0 var(--ink); }
  main#view { padding: 1.2rem 1rem 4rem; }
  .card > table { display: block; overflow-x: auto; }
}

html:has(dialog[open]) { overflow: hidden; }

/* family profiles */
.avatar { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; border: 2px solid var(--ink); object-fit: cover; font-weight: 800; flex: none; background: #fff; }
.group-head { margin-top: 1.4rem; font-size: .9rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.profile-grid { display: grid; gap: 1.1rem; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.profile-card { text-decoration: none; text-align: center; padding: 0 1rem 1rem; overflow: hidden; margin-bottom: 0; }
.profile-card .avatar { margin-top: -40px; position: relative; box-shadow: var(--shadow-sm); }
.profile-cover { height: 64px; margin: 0 -1rem; background: var(--c); border-bottom: 2px solid var(--ink); }
.profile-cover.big { height: 110px; margin: -1.2rem -1.35rem 0; }
.profile-name { font-weight: 800; font-size: 1.15rem; margin-top: .4rem; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin: .3rem 0; }
.profile-hero { overflow: hidden; }
.profile-hero .hero-row { display: flex; align-items: flex-end; gap: 1rem; margin-top: -56px; flex-wrap: wrap; }
.profile-hero .hero-row h2 { padding-top: 64px; }
.profile-hero .hero-row .avatar { box-shadow: var(--shadow-sm); position: relative; }
.button-like { display: inline-flex; align-items: center; font-weight: 700; cursor: pointer; border: 2px solid var(--ink); background: #fff; border-radius: 14px; padding: .5rem 1rem; box-shadow: var(--shadow-sm); min-height: 44px; margin: 0; }

/* consistent spacing: page headers, toolbars and the boxes under them */
main#view > .row, main#view > .page-head, main#view > p:has(> a:only-child) { margin: 0 0 1.3rem; }
main#view > .row.between { align-items: center; row-gap: .9rem; }
main#view > .row.between > h2 { margin: 0; }
main#view > .row.between > .row { gap: .6rem; }
.row > a { display: inline-flex; text-decoration: none; }
.row select, .row input:not([type=checkbox]):not([type=radio]) { margin: 0; width: auto; }
.seg { display: inline-flex; gap: .6rem; flex-wrap: nowrap; }
.seg button[aria-label] { min-width: 44px; padding-left: .7rem; padding-right: .7rem; }
main#view > h3 { margin: 1.6rem 0 .8rem; }
.card + .card, .grid + .card, .card + .grid { margin-top: 0; }
@media (max-width: 700px) {
  main#view > .row.between > .row { width: 100%; }
}

/* iPhone notch and home bar (in Safari full-screen and the iOS app) */
.top { padding-top: max(.8rem, env(safe-area-inset-top)); padding-left: max(1.4rem, env(safe-area-inset-left)); padding-right: max(1.4rem, env(safe-area-inset-right)); }
@media (max-width: 700px) { .top { padding-top: max(.7rem, env(safe-area-inset-top)); padding-left: max(1rem, env(safe-area-inset-left)); padding-right: max(1rem, env(safe-area-inset-right)); } }
main#view { padding-bottom: max(5rem, calc(env(safe-area-inset-bottom) + 3rem)); }
.toast { bottom: max(1.4rem, calc(env(safe-area-inset-bottom) + .6rem)); }
body.page { padding-top: env(safe-area-inset-top); }
/* inside the iOS app: no tap highlight, no long-press callouts on buttons */
html.native { -webkit-tap-highlight-color: transparent; }
html.native button, html.native .menu-btn { -webkit-touch-callout: none; user-select: none; }

/* gift lists: roomy rows, and on phones the buttons go under the gift instead of squeezing it */
.gift-item { padding: 1rem 0; }
.gift-item .gift-body { min-width: 0; overflow-wrap: anywhere; }
.gift-item .gift-body > div + div { margin-top: .25rem; }
.gift-item .title { font-size: 1.12rem; line-height: 1.3; }
.gift-item .reserved { margin-top: .45rem; }
.gift-actions { justify-content: flex-end; align-content: flex-start; }
.gift-item.is-hidden .gift-body { opacity: .6; }
@media (max-width: 700px) {
  .gift-item { grid-template-columns: 1fr; gap: .65rem; }
  .gift-actions { justify-content: flex-start; }
  .gift-actions button.small { min-height: 40px; padding: .35rem .85rem; font-size: .92rem; }
  .gift-actions .small.muted { width: 100%; }
}

/* colour swatches */
.swatch { display: inline-block; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--ink); flex: none; }
.swatch-btn { display: inline-flex; align-items: center; gap: .5rem; min-height: 40px; padding: .3rem .8rem; font-size: .92rem; }
.swatch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: .55rem; }
.swatch-pick { display: flex; flex-direction: column; align-items: center; gap: .25rem; padding: .55rem .3rem; min-height: 0; box-shadow: none; border-width: 2px; }
.swatch-pick .swatch { width: 34px; height: 34px; }
.swatch-pick.on { background: var(--accent-soft); box-shadow: var(--shadow-sm); }
.tiny { font-size: .7rem; line-height: 1; }

/* photo cropper */
.crop-stage { position: relative; overflow: hidden; margin: .4rem auto 0; border-radius: 16px; border: 2px solid var(--ink); background: #222; touch-action: none; cursor: grab; user-select: none; }
.crop-stage img { position: absolute; left: 0; top: 0; transform-origin: 0 0; max-width: none; pointer-events: none; }
.crop-ring { position: absolute; inset: 0; border-radius: 50%; box-shadow: 0 0 0 999px rgba(251, 251, 248, .72); border: 2px dashed var(--ink); pointer-events: none; }

.effects { width: 100%; margin: .5rem 0; }
.effects td { padding: .35rem .4rem; vertical-align: top; border-bottom: 1px solid var(--soft-line); }
.effects td:first-child { white-space: nowrap; }

.giver-checks { border: 2px solid var(--soft-line); border-radius: 12px; padding: .4rem .8rem; max-height: 42vh; overflow-y: auto; margin: 0; }
.giver-checks label.check { margin: .45rem 0; }

/* assistant */
.ai-fab { position: fixed; right: max(1.1rem, env(safe-area-inset-right)); bottom: max(1.1rem, calc(env(safe-area-inset-bottom) + .6rem)); z-index: 40; width: 58px; height: 58px; border-radius: 50%; padding: 0; display: inline-flex; align-items: center; justify-content: center; background: var(--accent); box-shadow: var(--shadow); }
.ai-panel { position: fixed; right: max(1rem, env(safe-area-inset-right)); bottom: max(1rem, calc(env(safe-area-inset-bottom) + .5rem)); z-index: 45; width: min(420px, calc(100vw - 2rem)); height: min(620px, calc(100dvh - 6rem)); background: var(--card); border: 2px solid var(--ink); border-radius: 22px; box-shadow: 8px 8px 0 var(--ink); display: flex; flex-direction: column; overflow: hidden; }
.ai-panel[hidden] { display: none; }
.ai-head { display: flex; align-items: center; justify-content: space-between; padding: .7rem .9rem; border-bottom: 2px solid var(--ink); background: var(--accent-soft); }
.ai-head button.small { min-height: 34px; }
.ai-log { flex: 1; overflow-y: auto; padding: .9rem; display: flex; flex-direction: column; gap: .6rem; overscroll-behavior: contain; }
.ai-msg { max-width: 88%; padding: .6rem .8rem; border-radius: 16px; border: 2px solid var(--ink); font-size: .97rem; line-height: 1.4; overflow-wrap: anywhere; }
.ai-msg p { margin: 0 0 .5em; } .ai-msg p:last-child { margin: 0; }
.ai-msg ul { margin: .2em 0; padding-left: 1.2em; }
.ai-msg.user { align-self: flex-end; background: var(--ink); color: var(--bg); border-bottom-right-radius: 6px; }
.ai-msg.assistant { align-self: flex-start; background: #fff; border-bottom-left-radius: 6px; }
.ai-msg.typing { display: inline-flex; gap: .3rem; }
.ai-msg.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--ink); animation: ai-dot 1s infinite ease-in-out; }
.ai-msg.typing span:nth-child(2) { animation-delay: .15s; } .ai-msg.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes ai-dot { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.ai-chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.ai-chips button { box-shadow: none; }
.ai-form { display: flex; gap: .5rem; padding: .7rem; border-top: 2px solid var(--ink); align-items: flex-end; }
.ai-form textarea { margin: 0; resize: none; min-height: 44px; max-height: 140px; }
.ai-form button { width: 48px; flex: none; font-size: 1.2rem; padding: 0; }
@media (max-width: 700px) {
  .ai-panel { left: 0; right: 0; bottom: 0; width: 100%; height: min(78dvh, calc(100dvh - 4rem)); border-radius: 22px 22px 0 0; border-bottom: 0; box-shadow: 0 -4px 0 var(--ink); padding-bottom: env(safe-area-inset-bottom); }
}
main#view { padding-bottom: max(6.5rem, calc(env(safe-area-inset-bottom) + 5rem)); }

/* suggestions */
.sugg { align-items: flex-start; font-weight: 500; margin: .45rem 0; }
.sugg input { margin-top: .2rem; flex: none; width: 20px; height: 20px; }
.sugg-head { margin: .9rem 0 .2rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }

/* lists: long text wraps, and the add box stacks on phones */
.check-row > div { min-width: 0; overflow-wrap: anywhere; }
.quick-add { display: grid; grid-template-columns: 1fr auto auto auto; gap: .6rem; align-items: center; padding: .8rem; }
.quick-add input, .quick-add select { margin: 0; width: auto; min-width: 0; }
.quick-add .qa-title { width: 100%; }
@media (max-width: 700px) {
  .quick-add { grid-template-columns: 1fr 1fr auto; }
  .quick-add .qa-title { grid-column: 1 / -1; }
  .quick-add select, .quick-add input[type=date], .quick-add input[name=quantity] { width: 100%; }
}

/* keep the assistant button out of the way of the menu and dialogs */
html.menu-open .ai-fab, html:has(dialog[open]) .ai-fab { display: none; }
@media (max-width: 700px) {
  /* the assistant fills the visible screen, and follows the keyboard (set from visualViewport) */
  .ai-panel { top: var(--vv-top, 0px); bottom: auto; left: 0; right: 0; width: 100%; height: var(--vv-h, 100dvh); border-radius: 0; border: 0; box-shadow: none; padding-bottom: 0; }
  .ai-head { padding-top: max(.7rem, env(safe-area-inset-top)); }
  .ai-form { padding-bottom: max(.7rem, env(safe-area-inset-bottom)); }
  html.ai-kb .ai-form { padding-bottom: .7rem; }
}

dialog { overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }

@media (max-width: 700px) {
  .top.open { position: fixed; top: 0; left: 0; right: 0; z-index: 50; }
  .top.open .menu-panel { bottom: 0; max-height: none; border-bottom: 0; box-shadow: none; padding-bottom: max(1rem, env(safe-area-inset-bottom)); }
}

.note-card { cursor: pointer; }
.note-body { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: .6rem; max-height: 12em; overflow: hidden; }

#df:focus { outline: none; }

#dialog:focus { outline: none; }

.map-link { color: inherit; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }

/* Tables that become stacked cards on a phone (expenses). Each cell carries its column name in data-label. */
@media (max-width: 640px) {
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack tr:first-child { display: none; }
  table.stack tr { padding: .7rem 0; border-bottom: 2px solid var(--soft-line); }
  table.stack tr:last-child { border-bottom: 0; }
  table.stack td { border: 0; padding: .15rem 0; text-align: left; }
  table.stack td[data-label] { display: flex; justify-content: space-between; gap: 1rem; }
  table.stack td[data-label]::before { content: attr(data-label); color: var(--muted, #6b6b6b); font-size: .85rem; }
  table.stack td[data-label]:empty, table.stack td[data-label="Child"]:empty { display: none; }
  table.stack td.stack-main { font-weight: 600; order: -1; }
  table.stack td.stack-actions { padding-top: .5rem; }
  table.stack td.empty { text-align: center; }
}
.preview-row { padding: .5rem 0; border-bottom: 2px solid var(--soft-line); }
.preview-row:last-child { border-bottom: 0; }

/* Loading placeholders */
.skeleton { padding-top: .4rem; }
.sk-card { background: var(--card); border: 2px solid var(--soft-line); border-radius: var(--radius); padding: 1.1rem 1.3rem; margin-bottom: 1.1rem; }
.sk-line { height: 14px; border-radius: 7px; background: linear-gradient(90deg, #EEECE6 25%, #F6F5F1 50%, #EEECE6 75%); background-size: 200% 100%; animation: sk 1.2s ease-in-out infinite; margin: .45rem 0; }
.sk-line.short { width: 55%; }
.sk-title { height: 26px; width: 40%; margin: .2rem 0 1.2rem; }
@keyframes sk { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .sk-line { animation: none; } }
/* Pull to refresh */
.ptr { position: fixed; top: var(--top-h, 64px); left: 0; right: 0; height: 0; opacity: 0; overflow: hidden; display: grid; place-items: center; z-index: 30; font-weight: 700; font-size: .9rem; color: var(--muted); background: var(--bg); transition: height .2s, opacity .2s; pointer-events: none; }
