:root {
  --brand: #1f5f73;
  --brand-ink: #ffffff;
  --brand-soft: #dcebef;
  --ground: #f3f5f4;
  --card: #ffffff;
  --ink: #18242a;
  --muted: #5a6b72;
  --line: #d9e0e2;
  --calm: #2e7d4f;
  --calm-soft: #e1f2e7;
  --tense: #9a6a00;
  --tense-soft: #fbf0d4;
  --hostile: #b3392f;
  --hostile-soft: #f9e1de;
  --mine: #1f5f73;
  --mine-ink: #ffffff;
  --theirs: #ffffff;
  --shadow: 0 1px 2px rgba(16, 36, 42, .06), 0 2px 8px rgba(16, 36, 42, .05);
  --radius: 14px;
  --tap: 44px;
  --p1: #1f5f73;
  --p2: #a85a14;
  --p1-soft: #d6e8ee;
  --p2-soft: #f6e2cc;
  --pill-ink: #ffffff;
  --font: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display: 'Fraunces', Georgia, serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --brand: #5fb0c6;
    --brand-ink: #08222b;
    --brand-soft: #173a45;
    --ground: #10171a;
    --card: #182226;
    --ink: #e6eef0;
    --muted: #9db0b6;
    --line: #2a383d;
    --calm: #6fcf97;
    --calm-soft: #17352a;
    --tense: #e8b84a;
    --tense-soft: #3a2f12;
    --hostile: #f08a80;
    --hostile-soft: #3d1d1a;
    --mine: #2c7389;
    --mine-ink: #ffffff;
    --theirs: #1f2c31;
    --shadow: none;
    --p1: #5fb0c6;
    --p2: #e0a060;
    --p1-soft: #18343c;
    --p2-soft: #3a2916;
    --pill-ink: #0d1a1f;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 16px/1.45 var(--font);
  min-height: 100dvh;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hidden { display: none !important; }

#app { max-width: 560px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }
#app.wide { max-width: none; display: block; }

/* header */
.top {
  position: sticky; top: 0; z-index: 5;
  background: var(--brand); color: var(--brand-ink);
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  display: flex; align-items: center; gap: 12px;
}
.brand { font-family: var(--display); font-size: 1.5rem; font-weight: 600; letter-spacing: .01em; }
.top .who { font-size: .85rem; line-height: 1.25; opacity: .92; flex: 1; min-width: 0; }
.top .who b { font-weight: 600; }
.top button { background: transparent; border: 1px solid currentColor; color: inherit; border-radius: 999px; min-height: 36px; padding: 0 12px; font-size: .85rem; }

main { flex: 1; padding: 12px 16px calc(84px + env(safe-area-inset-bottom)); }

/* bottom tabs */
.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 5;
  display: flex; justify-content: center;
  background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs-inner { display: flex; width: 100%; max-width: 560px; }
.tabs button {
  flex: 1; min-height: 60px; background: none; border: 0; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: .78rem; font-weight: 600; position: relative;
}
.tabs button svg { width: 24px; height: 24px; }
.tabs button[aria-selected="true"] { color: var(--brand); }
.tabs .dot { position: absolute; top: 8px; left: calc(50% + 8px); min-width: 18px; height: 18px; border-radius: 9px; background: var(--hostile); color: #fff; font-size: .7rem; line-height: 18px; padding: 0 5px; }

/* cards and controls */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin-bottom: 12px; border: 1px solid var(--line); }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.stack > * + * { margin-top: 10px; }
.grow { flex: 1; min-width: 0; }
label { display: block; font-size: .85rem; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
input, select, textarea {
  width: 100%; min-height: var(--tap); border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); padding: 10px 12px;
}
textarea { resize: vertical; min-height: 88px; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
input[type="checkbox"] { width: 22px; min-height: 22px; height: 22px; margin: 0; flex: none; accent-color: var(--brand); }
.check { display: flex; gap: 10px; align-items: center; min-height: var(--tap); font-weight: 500; color: var(--ink); font-size: .95rem; }

.btn {
  min-height: var(--tap); padding: 0 16px; border-radius: 999px; border: 1px solid var(--brand);
  background: var(--brand); color: var(--brand-ink); font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none;
}
.btn.ghost { background: transparent; color: var(--brand); }
.btn.quiet { background: transparent; border-color: var(--line); color: var(--ink); }
.btn.danger { background: transparent; border-color: var(--hostile); color: var(--hostile); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: .85rem; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 8px; scrollbar-width: none; }
.chip {
  flex: none; min-height: var(--tap); padding: 0 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); font-weight: 600; font-size: .88rem; color: var(--ink);
}
.chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }

.tag { display: inline-block; font-size: .72rem; font-weight: 700; letter-spacing: .02em; padding: 2px 8px; border-radius: 999px; background: var(--brand-soft); color: var(--ink); }
.tag.calm { background: var(--calm-soft); color: var(--calm); }
.tag.tense, .tag.pending, .tag.warn { background: var(--tense-soft); color: var(--tense); }
.tag.hostile, .tag.disputed, .tag.declined { background: var(--hostile-soft); color: var(--hostile); }
.tag.approved, .tag.accepted, .tag.settled { background: var(--calm-soft); color: var(--calm); }

/* auth */
.auth { padding: 32px 16px; }
.auth .brand { color: var(--brand); font-size: 2.4rem; }
.auth .lead { color: var(--muted); margin-bottom: 20px; }
.seg { display: flex; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 4px; margin-bottom: 16px; }
.seg button { flex: 1; min-height: 40px; border: 0; border-radius: 999px; background: none; font-weight: 600; color: var(--muted); }
.seg button[aria-selected="true"] { background: var(--brand); color: var(--brand-ink); }
.error { color: var(--hostile); font-size: .9rem; min-height: 1.2em; }

/* needs-you banner */
.needs { background: var(--brand-soft); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 12px; }
.needs h3 { font-size: .9rem; margin: 0 0 4px; }
.needs ul { margin: 0; padding: 0; list-style: none; }
.needs li button { background: none; border: 0; padding: 6px 0; min-height: 36px; text-align: left; width: 100%; color: var(--ink); display: flex; gap: 8px; align-items: center; }
.needs li button::before { content: ''; width: 8px; height: 8px; border-radius: 4px; background: var(--brand); flex: none; }

/* messages */
.thread { display: flex; flex-direction: column; gap: 8px; padding-bottom: 8px; }
.bubble { max-width: 85%; padding: 9px 12px; border-radius: 16px; background: var(--theirs); border: 1px solid var(--line); align-self: flex-start; word-wrap: break-word; white-space: pre-wrap; }
.bubble.mine { align-self: flex-end; background: var(--mine); color: var(--mine-ink); border-color: transparent; }
.bubble .meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: .72rem; opacity: .85; margin-top: 4px; white-space: normal; }
.bubble .meta .tag { font-size: .66rem; }
.bubble.mine .tag { background: rgba(255,255,255,.18); color: inherit; }
.bubble details { font-size: .8rem; margin-top: 4px; white-space: normal; }
.bubble summary { cursor: pointer; min-height: 28px; }
.day-sep { text-align: center; font-size: .75rem; color: var(--muted); margin: 6px 0; }
.composer { position: sticky; bottom: calc(68px + env(safe-area-inset-bottom)); background: var(--ground); padding-top: 8px; }
.composer textarea { min-height: 72px; }
/* A tall coach panel scrolls with the page instead of covering the thread. */
.composer:has(.coach) { position: static; }

/* coach */
.coach { border-left: 4px solid var(--tense); }
.coach.hostile { border-left-color: var(--hostile); }
.coach.offtopic { border-left-color: var(--brand); }
.issue { padding: 8px 10px; border-radius: 10px; background: var(--tense-soft); margin-bottom: 6px; }
.coach.hostile .issue { background: var(--hostile-soft); }
.issue q { font-weight: 700; }
.rewrite { background: var(--calm-soft); border-radius: 10px; padding: 10px 12px; white-space: pre-wrap; }
.coach .actions { display: grid; gap: 8px; }

/* calendar */
.event { display: flex; gap: 12px; }
.event .date { flex: none; width: 52px; text-align: center; border-radius: 10px; background: var(--brand-soft); padding: 6px 0; }
.event .date b { display: block; font-size: 1.3rem; line-height: 1.1; }
.event .date span { font-size: .72rem; text-transform: uppercase; font-weight: 700; color: var(--muted); }
.event .body { flex: 1; min-width: 0; }
.event .title { font-weight: 700; }
.change { margin-top: 10px; padding: 10px; border-radius: 10px; background: var(--tense-soft); }
.cal-head { display: flex; align-items: center; gap: 6px; margin: 4px 0 10px; }
.cal-head h2 { flex: 1; text-align: center; margin: 0; font-size: 1.05rem; }
.icon-btn { min-width: var(--tap); min-height: var(--tap); border-radius: 999px; border: 1px solid var(--line); background: var(--card); font-size: 1.4rem; line-height: 1; color: var(--ink); }
.month-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; touch-action: pan-y; }
.month-grid .dow { text-align: center; font-size: .72rem; color: var(--muted); font-weight: 700; padding-bottom: 2px; }
.day { min-height: 58px; padding: 5px 0 4px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); display: flex; flex-direction: column; align-items: center; gap: 4px; font-weight: 600; font-size: .9rem; color: var(--ink); }
.day.out { opacity: .45; }
.day.today .num { text-decoration: underline 2px; text-underline-offset: 3px; }
.day[aria-pressed="true"] { border: 2px solid var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.dots { display: flex; gap: 3px; height: 7px; }
.dots i, .legend i { width: 7px; height: 7px; border-radius: 4px; background: var(--p1); display: inline-block; }
.dots i.p2, .legend i.p2 { background: var(--p2); }
.dots i.pending, .legend i.pending { background: transparent; box-shadow: inset 0 0 0 2px var(--hostile); }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; font-size: .8rem; color: var(--muted); margin: 10px 0 4px; }
.legend i { margin-right: 6px; width: 10px; height: 10px; border-radius: 5px; }
.week-day { display: flex; gap: 12px; align-items: flex-start; width: 100%; text-align: left; padding: 10px 12px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); margin-bottom: 6px; min-height: 56px; color: var(--ink); }
.week-day.today { border: 2px solid var(--brand); }
.week-day[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--ink); }
.week-day .wd { width: 40px; flex: none; text-align: center; font-size: .72rem; text-transform: uppercase; font-weight: 700; color: var(--muted); }
.week-day .wd b { display: block; font-size: 1.25rem; color: var(--ink); }
.week-day .evs { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; padding-top: 2px; }
.ev-chip { font-size: .85rem; padding: 3px 8px; border-radius: 8px; background: var(--ground); border-left: 4px solid var(--p1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev-chip.p2 { border-left-color: var(--p2); }
.pill { display: inline-block; font-size: .75rem; font-weight: 700; line-height: 1.5; padding: 1px 9px; border-radius: 999px; background: var(--p1); color: var(--pill-ink); white-space: nowrap; }
.pill.p2 { background: var(--p2); }
.day .who { display: flex; gap: 2px; min-height: 15px; }
.day .who .pill { font-size: .66rem; line-height: 15px; padding: 0 5px; }
.day.with-p1, .week-day.with-p1 { background: var(--p1-soft); }
.day.with-p2, .week-day.with-p2 { background: var(--p2-soft); }
.day.with-both, .week-day.with-both { background: linear-gradient(135deg, var(--p1-soft) 50%, var(--p2-soft) 50%); }
.week-day.with-p1 { border-left: 6px solid var(--p1); }
.week-day.with-p2 { border-left: 6px solid var(--p2); }
.event-card { border-left: 5px solid var(--p1); }
.event-card.p2 { border-left-color: var(--p2); }
.month { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin: 16px 0 8px; }

/* money */
.balance { text-align: center; }
.balance .big { font-family: var(--display); font-size: 2rem; color: var(--brand); }
.amount { font-weight: 700; font-variant-numeric: tabular-nums; }
.receipts { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.receipt { width: 64px; height: 64px; border-radius: 10px; border: 1px solid var(--line); overflow: hidden; display: flex; align-items: center; justify-content: center; background: var(--brand-soft); color: var(--brand); font-weight: 700; font-size: .8rem; text-decoration: none; }
.receipt img { width: 100%; height: 100%; object-fit: cover; }
input[type="file"] { padding: 8px; }

/* review */
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th:not(:first-child), td:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }
.flag { padding: 8px 0; border-bottom: 1px solid var(--line); }
.flag:last-child { border-bottom: 0; }

#toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(80px + env(safe-area-inset-bottom));
  background: var(--ink); color: var(--ground); padding: 10px 16px; border-radius: 999px; z-index: 20;
  max-width: calc(100% - 32px); font-size: .9rem; box-shadow: var(--shadow);
}

/* landing page */
.landing { --l-max: 1080px; }
.landing > * { width: 100%; max-width: var(--l-max); margin-left: auto; margin-right: auto; padding-left: 16px; padding-right: 16px; }
.l-top { display: flex; align-items: center; justify-content: space-between; padding-top: calc(env(safe-area-inset-top) + 14px); padding-bottom: 14px; }
.l-top .brand { color: var(--brand); font-size: 1.6rem; }
.l-hero { padding-top: 32px; padding-bottom: 40px; max-width: 760px; text-align: center; }
.l-eyebrow { display: inline-block; font-size: .78rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--brand); background: var(--brand-soft); padding: 4px 12px; border-radius: 999px; margin-bottom: 18px; }
.l-hero h1 { font-family: var(--display); font-weight: 600; font-size: clamp(2.4rem, 8vw, 4rem); line-height: 1.05; letter-spacing: -.01em; margin: 0 0 16px; color: var(--ink); }
.l-lead { font-size: clamp(1.05rem, 2.6vw, 1.25rem); color: var(--muted); max-width: 34em; margin: 0 auto 26px; }
.l-cta { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.l-cta .btn, .l-join .btn { min-height: 52px; padding: 0 26px; font-size: 1.02rem; }
.landing h2 { font-family: var(--display); font-weight: 600; font-size: clamp(1.6rem, 4.5vw, 2.2rem); margin: 0 0 22px; }
.l-screens { padding-top: 24px; padding-bottom: 40px; }
.l-screens h2, .l-note { text-align: center; }
.l-gallery { display: flex; gap: 20px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 4px 4px 18px; margin: 0 -16px; padding-left: 16px; padding-right: 16px; scrollbar-width: thin; }
.l-shot { flex: 0 0 min(78vw, 270px); scroll-snap-align: center; margin: 0; }
.l-phone { border-radius: 30px; padding: 8px; background: #10171a; box-shadow: 0 10px 30px rgba(16, 36, 42, .18); }
.l-phone img { display: block; width: 100%; height: auto; border-radius: 22px; }
.l-shot figcaption { padding: 14px 4px 0; }
.l-shot h3 { font-size: 1.05rem; margin: 0 0 4px; }
.l-shot p { color: var(--muted); font-size: .95rem; margin: 0; }
@media (min-width: 1000px) {
  .l-gallery { overflow: visible; margin: 0; padding: 4px 0 18px; justify-content: space-between; }
  .l-shot { flex: 0 1 23%; }
}
.l-features { padding-top: 32px; padding-bottom: 40px; }
.l-grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 700px) { .l-grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1000px) { .l-grid { grid-template-columns: 1fr 1fr 1fr; } }
.l-feature { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.l-feature h3 { margin: 0 0 6px; font-size: 1.05rem; }
.l-feature p { margin: 0; color: var(--muted); }
.l-fair { padding-top: 16px; padding-bottom: 40px; max-width: 760px; }
.l-fair ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.l-fair li { display: flex; gap: 12px; align-items: flex-start; font-size: 1.02rem; }
.l-fair li::before { content: ''; flex: none; width: 22px; height: 22px; margin-top: 1px; border-radius: 11px; background: var(--calm-soft) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232e7d4f' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 12l4 4 8-8'/%3E%3C/svg%3E") center / 14px no-repeat; }
.l-join { text-align: center; padding-top: 36px; padding-bottom: 44px; max-width: 760px; width: calc(100% - 32px); background: var(--brand-soft); border-radius: 22px; margin-bottom: 28px; }
.l-join p { color: var(--ink); max-width: 30em; margin: 0 auto 18px; }
.l-join .small { margin-top: 12px; margin-bottom: 0; color: var(--muted); }
.l-foot { display: flex; justify-content: space-between; padding-top: 14px; padding-bottom: calc(env(safe-area-inset-bottom) + 24px); border-top: 1px solid var(--line); }

@media print {
  .top, .tabs, .composer { display: none; }
}
