/* Housely im Browser — the planner look of the iOS app: cream paper, forest-green ink,
   butter-yellow highlights, DM Sans for the interface, Georgia for the big headings.
   Sizes are rem so the reader's browser font size wins. Body 1rem, captions ≥ .875rem,
   eyebrows ≥ .75rem, tap targets ≥ 44px. */

@font-face { font-family: "DM Sans"; src: url("/app/fonts/DMSans-Regular.otf") format("opentype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "DM Sans"; src: url("/app/fonts/DMSans-Medium.otf") format("opentype"); font-weight: 500; font-display: swap; }
@font-face { font-family: "DM Sans"; src: url("/app/fonts/DMSans-SemiBold.otf") format("opentype"); font-weight: 600; font-display: swap; }
@font-face { font-family: "DM Sans"; src: url("/app/fonts/DMSans-Bold.otf") format("opentype"); font-weight: 700; font-display: swap; }

:root {
  --primary: #00572E;
  --ink: #0B2E24;
  --paper: #EDEAE4;
  --button: #0F4234;
  --surface: #F8F5EE;
  --stroke: #D8D1C4;
  --muted: #5B6660; /* a shade darker than the app's #6F7A74 so small text passes WCAG AA */
  --danger: #A64032;
  --on-accent: #EDEAE4;
  --accent-subtle: #F0EBB8;
  --tint: rgba(0, 87, 46, .08);
  /* The forest hero reads the same in light and dark mode. */
  --hero: #0F4234;
  --hero-highlight: #F5F07E;
  --hero-text: #F8F5EE;
  --hero-caption: rgba(237, 234, 228, .85);

  --sans: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --serif: Georgia, "Times New Roman", serif;
  --gutter: 1.25rem;
  --tap: 2.75rem;
  --tabbar: 4.25rem;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --primary: #5FB88A;
    --ink: #EDF2EF;
    --paper: #0C1010;
    --button: #3D9268;
    --surface: #1C2622;
    --stroke: #3A4D44;
    --muted: #93A69C;
    --danger: #E07A6C;
    --on-accent: #F5FAF7;
    --accent-subtle: #1E3D30;
    --tint: rgba(95, 184, 138, .12);
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); }
svg { flex: none; }

:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: 6px; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: .5rem; top: -4rem; z-index: 50;
  background: var(--button); color: var(--on-accent); padding: .75rem 1rem; border-radius: .75rem;
}
.skip-link:focus { top: .5rem; }

/* MARK: - Frame */

.app { min-height: 100vh; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  max-width: 36rem; margin: 0 auto; padding: max(.5rem, env(safe-area-inset-top)) var(--gutter) 0;
}
.topbar-name {
  font-weight: 600; font-size: 1rem; margin: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* M-BE: household picker when the account is in several households. */
.select.topbar-select {
  width: auto; max-width: 60%; min-height: 2.75rem; padding: .5rem .875rem;
  font-weight: 600; font-size: 1rem; text-overflow: ellipsis;
}

.screen {
  max-width: 36rem; margin: 0 auto;
  padding: .75rem var(--gutter) calc(var(--tabbar) + 2.5rem + env(safe-area-inset-bottom));
}
.screen.no-tabs { padding-bottom: 3rem; }
.screen:focus { outline: none; }

.stack > * + * { margin-top: 1.5rem; }

.offline {
  max-width: 36rem; margin: .5rem auto 0; padding: 0 var(--gutter);
}
.offline p {
  margin: 0; padding: .75rem 1rem; border-radius: .875rem;
  background: var(--accent-subtle); color: var(--ink); font-size: .875rem;
}

/* MARK: - Type */

.eyebrow {
  margin: 0 0 .5rem; font-size: .75rem; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; color: var(--muted);
}
.page-title {
  margin: 0; font-family: var(--serif); font-weight: 400; font-size: 2.25rem; line-height: 1.15;
}
.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: .75rem; }
.page-sub { margin: .5rem 0 0; color: var(--muted); font-size: .9375rem; }

.section-title { margin: 0 0 .75rem; font-size: 1.25rem; font-weight: 600; line-height: 1.3; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: .75rem; }
.section-head .link { display: inline-flex; align-items: center; min-height: var(--tap); font-size: .875rem; font-weight: 500; }

.caption { margin: 0; font-size: .875rem; color: var(--muted); }
.muted { color: var(--muted); }
.danger { color: var(--danger); }
.amount { font-weight: 600; white-space: nowrap; }

.badge {
  flex: none; font-size: .875rem; font-weight: 500; color: var(--primary);
  background: var(--tint); border-radius: 999px; padding: .375rem .75rem;
}

/* MARK: - Hero */

.hero {
  background: var(--hero); color: var(--hero-text);
  border-radius: 1.5rem; padding: 1.375rem;
}
.hero .eyebrow { color: var(--hero-highlight); letter-spacing: .14em; }
.hero-title {
  margin: .25rem 0 .75rem; font-family: var(--serif); font-weight: 400; font-size: 1.75rem; line-height: 1.2;
}
.hero-amount { margin: .25rem 0 .5rem; font-size: 2.25rem; font-weight: 500; line-height: 1.1; }
.hero .caption { color: var(--hero-caption); }
.progress {
  margin-top: 1rem; height: .375rem; border-radius: 999px; overflow: hidden;
  background: rgba(245, 240, 126, .18);
}
.progress span { display: block; height: 100%; width: 0; background: var(--hero-highlight); border-radius: inherit; }

/* MARK: - Tiles */

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.tile {
  display: flex; flex-direction: column; gap: .375rem; min-height: var(--tap);
  padding: 1rem; border-radius: 1.125rem; background: var(--surface);
  color: var(--ink); text-decoration: none;
}
.tile.yellow { background: var(--accent-subtle); }
.tile-label { display: flex; align-items: center; gap: .375rem; font-size: .875rem; font-weight: 500; }
.tile-value { font-size: 1.625rem; font-weight: 400; line-height: 1.2; overflow-wrap: anywhere; }
.tile .caption { font-size: .875rem; }

/* MARK: - Lists */

.rows { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.row {
  display: flex; align-items: center; gap: .5rem;
  background: var(--surface); border-radius: 1rem; padding: .25rem .25rem .25rem 1rem; min-height: 3.5rem;
}
.row.finished { background: color-mix(in srgb, var(--surface) 55%, transparent); }
.row-main { flex: 1; min-width: 0; padding: .625rem 0; }
.row-title { margin: 0; font-weight: 600; font-size: 1rem; line-height: 1.35; overflow-wrap: anywhere; }
.row.finished .row-title { color: var(--muted); }
.row.done .row-title { text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 60%, transparent); }
.row-meta { margin: .25rem 0 0; font-size: .875rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: .25rem .375rem; align-items: center; }
.row-meta .danger { color: var(--danger); }
.row-meta svg { width: 1rem; height: 1rem; }
.tile-label svg { width: 1.125rem; height: 1.125rem; }
.row.lead { padding-left: .25rem; }
.row-amount { flex: none; padding-right: .75rem; font-weight: 600; text-align: right; }
.row-amount.plain { font-weight: 500; color: var(--muted); }

.tick {
  flex: none; display: grid; place-items: center; width: 3rem; height: 3rem;
  border: 0; border-radius: 999px; background: transparent; color: var(--primary); cursor: pointer;
}
.tick:hover { background: var(--tint); }
.tick.locked { color: var(--muted); }
.tick.checked { color: color-mix(in srgb, var(--primary) 60%, transparent); }
.tick:disabled { cursor: default; opacity: .5; }
.tick svg { width: 1.625rem; height: 1.625rem; }

.empty {
  margin: 0; padding: 1.125rem 1rem; border-radius: 1rem; background: var(--surface);
  color: var(--muted); font-size: .9375rem;
}

/* Month rule: "September 2026 ——— 481,12 €" */
.divider {
  display: flex; align-items: center; gap: .75rem; margin: 1.75rem 0 .875rem;
  font-size: .875rem; font-weight: 500;
}
.divider::after { content: ""; order: 1; flex: 1; height: 1px; background: var(--stroke); }
.divider .divider-trailing { order: 2; color: var(--muted); font-weight: 500; }
.divider:first-child { margin-top: .5rem; }

/* Timeline: day circle on the left, a fine rule connecting the days. */
.day { display: grid; grid-template-columns: 3rem 1fr; gap: .875rem; position: relative; padding-bottom: 1.5rem; }
.day::before {
  content: ""; position: absolute; left: 1.5rem; top: 4.5rem; bottom: 0; width: 1px; background: var(--stroke);
}
.day:last-child::before { display: none; }
.day-spine { display: flex; flex-direction: column; align-items: center; gap: .25rem; }
.day-weekday { font-size: .75rem; font-weight: 500; text-transform: uppercase; color: var(--muted); }
.day-number {
  display: grid; place-items: center; width: 2.75rem; height: 2.75rem; border-radius: 999px;
  border: 1px solid var(--stroke); background: var(--paper); font-weight: 600; font-size: 1.125rem;
}
.day.today .day-number { background: var(--button); border-color: transparent; color: var(--on-accent); }
.day.overdue .day-number { color: var(--danger); }
.day-head { display: flex; align-items: baseline; gap: .5rem; min-height: 1.75rem; margin: 0 0 .5rem; font-size: 1rem; font-weight: 600; }
.day-head .danger { font-size: .875rem; font-weight: 500; }
.day-head .count { margin-left: auto; font-size: .875rem; font-weight: 500; color: var(--muted); }

.group-title { margin: 1.25rem 0 .5rem; font-size: .875rem; font-weight: 600; color: var(--muted); }
.group-title:first-child { margin-top: 0; }

details.more { margin-top: 1.5rem; }
details.more > summary {
  display: flex; align-items: center; min-height: var(--tap); cursor: pointer;
  font-weight: 600; color: var(--ink); list-style: none;
}
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before {
  content: ""; width: .5rem; height: .5rem; margin: 0 .75rem 0 .25rem;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg);
  transition: transform .15s ease;
}
details.more[open] > summary::before { transform: rotate(45deg); }
details.more > .rows { margin-top: .5rem; }

/* MARK: - Controls */

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 3.25rem; padding: .75rem 1.25rem; border: 0; border-radius: .875rem;
  background: var(--button); color: var(--on-accent); font-weight: 600; font-size: 1rem;
  text-decoration: none; cursor: pointer;
}
.button.full { width: 100%; }
.button.secondary { background: var(--surface); color: var(--ink); }
.button.quiet { background: transparent; color: var(--primary); min-height: var(--tap); padding: .5rem .75rem; }
.button.small { min-height: var(--tap); padding: .5rem 1rem; font-size: .9375rem; }
.button:disabled { opacity: .5; cursor: default; }

.icon-button {
  display: grid; place-items: center; width: var(--tap); height: var(--tap);
  border: 0; border-radius: 999px; background: var(--surface); color: var(--ink); cursor: pointer;
}
.icon-button svg { width: 1.125rem; height: 1.125rem; }

.segmented {
  display: inline-flex; gap: .25rem; padding: .25rem; border-radius: 999px; background: var(--surface);
}
.segmented button {
  min-height: 2.5rem; min-width: 5rem; padding: .375rem 1rem; border: 0; border-radius: 999px;
  background: transparent; color: var(--ink); font-weight: 500; cursor: pointer;
}
.segmented button[aria-pressed="true"] { background: var(--button); color: var(--on-accent); }

.field { display: grid; gap: .375rem; }
.field + .field, .field + fieldset, fieldset + .field { margin-top: 1rem; }
.label { font-size: .9375rem; font-weight: 600; }
.hint { font-size: .875rem; color: var(--muted); margin: 0; }
.input, .select {
  width: 100%; min-height: 3.25rem; padding: .75rem 1rem;
  border: 1px solid var(--stroke); border-radius: .875rem; background: var(--surface); color: var(--ink);
}
.input::placeholder { color: var(--muted); opacity: 1; }
.input.code { text-transform: uppercase; letter-spacing: .14em; font-weight: 600; }
.input.one-time-code { font-size: 1.5rem; letter-spacing: .3em; font-weight: 600; font-variant-numeric: tabular-nums; } /* I-BE */
.input-row { display: flex; gap: .5rem; }
.input-row .input { flex: 1; min-width: 0; }
.money-input { position: relative; }
.money-input .input { padding-right: 2.5rem; font-size: 1.5rem; font-weight: 500; }
.money-input span { position: absolute; right: 1rem; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 1.25rem; }

fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { padding: 0; margin-bottom: .5rem; }
.choice {
  display: flex; align-items: center; gap: .75rem; min-height: var(--tap);
  padding: .375rem .25rem; cursor: pointer;
}
.choice input { width: 1.25rem; height: 1.25rem; accent-color: var(--button); margin: 0; flex: none; }
.choice-sub { margin-left: 2.25rem; }

.form-error {
  margin: 1rem 0 0; padding: .75rem 1rem; border-radius: .875rem;
  background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); font-size: .9375rem;
}
.form-error:empty { display: none; }

/* MARK: - Auth and join */

.mark {
  width: 2.75rem; height: 2.75rem; border-radius: .625rem; background: var(--hero);
  display: grid; place-items: center; margin: 1.5rem 0 1.75rem;
}
.mark span { width: 1.25rem; height: 1.25rem; border: 2px solid var(--hero-highlight); border-radius: .3125rem; }
.card { background: var(--surface); border-radius: 1.125rem; padding: 1.25rem; }
.code-box {
  display: flex; justify-content: space-between; align-items: baseline; gap: 1rem;
  background: var(--surface); border-radius: 1.125rem; padding: 1rem 1.125rem;
}
.code-box strong { font-size: 1.25rem; letter-spacing: .12em; }
.actions { display: grid; gap: .5rem; }
.card .actions { margin-top: 1.25rem; }
h1[tabindex="-1"]:focus { outline: none; }

/* MARK: - Konto löschen */

.notice {
  margin: 0; padding: .75rem 1rem; border-radius: .875rem;
  background: var(--accent-subtle); color: var(--ink); font-size: .9375rem;
}
.consequences { list-style: none; margin: 0; padding: 0; background: var(--surface); border-radius: 1.125rem; }
.consequences li {
  position: relative; padding: .875rem 1rem .875rem 2.5rem; font-size: .9375rem; color: var(--ink);
}
.consequences li + li { border-top: 1px solid var(--stroke); }
.consequences li::before {
  content: ""; position: absolute; left: 1rem; top: 1.25rem; width: .5rem; height: .5rem;
  border-radius: 50%; background: var(--danger);
}
.button.destructive { background: var(--danger); color: #FFFFFF; }
@media (prefers-color-scheme: dark) {
  .button.destructive { color: var(--paper); } /* the light dark-mode red needs dark text */
}
.button.quiet.danger { color: var(--danger); }
.account-links { margin: 2rem 0 0; text-align: center; }

/* MARK: - Tab bar */

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-top: 1px solid var(--stroke);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar ul {
  list-style: none; margin: 0 auto; padding: 0 .5rem; max-width: 36rem;
  display: grid; grid-template-columns: repeat(4, 1fr);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .125rem;
  min-height: var(--tabbar); color: var(--muted); text-decoration: none; font-size: .875rem; font-weight: 500;
}
.tabbar a svg { width: 1.5rem; height: 1.5rem; }
.tabbar a[aria-current="page"] { color: var(--primary); font-weight: 600; }

/* MARK: - Sheet (dialog) */

.sheet {
  width: min(36rem, 100%); max-height: min(92vh, 52rem); margin: auto auto 0; padding: 0;
  border: 0; border-radius: 1.5rem 1.5rem 0 0; background: var(--paper); color: var(--ink);
}
@media (min-width: 40rem) {
  .sheet { margin: auto; border-radius: 1.5rem; }
}
.sheet::backdrop { background: rgba(11, 20, 16, .45); }
.sheet-head {
  position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: .75rem;
  padding: 1rem var(--gutter); background: var(--paper);
}
.sheet-head h2 { flex: 1; margin: 0; font-size: 1.25rem; font-weight: 600; }
.sheet-body { padding: 0 var(--gutter) calc(1.5rem + env(safe-area-inset-bottom)); }

/* MARK: - Toast */

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar) + 1rem + env(safe-area-inset-bottom)); z-index: 60;
  transform: translateX(-50%); width: max-content; max-width: calc(100% - 2 * var(--gutter));
  pointer-events: none;
}
.toast p {
  margin: 0; padding: .75rem 1.125rem; border-radius: 999px;
  background: var(--hero); color: var(--hero-text); font-size: .9375rem; box-shadow: 0 6px 24px rgba(0, 0, 0, .18);
}
.toast:empty { display: none; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
