:root {
  --ink: #241c15;
  --ink-soft: #5e5348;
  --paper: #f3ebe1;
  --paper-deep: #e9dfd2;
  --card: #fffaf4;
  --line: #e4d5c4;
  --pine: #1e4d3a;
  --pine-deep: #17382b;
  --pine-soft: #e5f1ea;
  --gold: #6d4c16;
  --clay: #8f3b2e;
  --red-bg: #f8e6e0;
  --red-line: #e3b4a8;
  --amber-bg: #fbf4dc;
  --amber-line: #e3d09a;
  --serif: Palatino, "Palatino Linotype", "Iowan Old Style", Georgia, serif;
  --sans: "Avenir Next", "Segoe UI", "Gill Sans", sans-serif;
  --shadow: 0 10px 28px rgba(55, 36, 18, 0.06);
  --nav: 84px;
  color-scheme: light;
}

* { box-sizing: border-box; }

html { font-size: 17px; }

html.simple { font-size: 21px; }

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 0% -10%, #f8e6cf 0%, transparent 55%),
    var(--paper);
  font-family: var(--sans);
  line-height: 1.45;
}

button, input, select, textarea { font: inherit; color: inherit; }

button { cursor: pointer; }

:focus-visible {
  outline: 3px solid #c4622d;
  outline-offset: 2px;
}

.shell, #app {
  width: min(480px, 100%);
  margin: 0 auto;
  min-height: 100dvh;
  padding-bottom: calc(var(--nav) + env(safe-area-inset-bottom));
}

.welcome-wrap, .setup-wrap { padding: 28px 20px 40px; }

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

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.eyebrow {
  margin: 0;
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1, h2, h3 {
  font-family: var(--serif);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

h1 { margin: 4px 0 8px; font-size: 2.05rem; }

h2 { margin: 0; font-size: 1.35rem; }

.lede, .hint, .bill-due, .pay-head p, .quiet {
  color: var(--ink-soft);
}

.lede { margin: 0 0 18px; font-size: 1.05rem; }

.logo { display: block; flex: none; }

.privacy-hero, .privacy, .callout {
  background: var(--pine-deep);
  color: #f6f1e8;
  border-radius: 18px;
}

.privacy-hero { padding: 16px 16px 14px; margin: 8px 0 18px; }

.privacy-hero strong {
  display: block;
  font-family: var(--serif);
  font-size: 1.35rem;
  margin-bottom: 4px;
}

.privacy-hero p { margin: 0; color: #f0e4d4; }

.sticky {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 14px 16px 10px;
  background: rgba(243, 235, 225, 0.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid transparent;
}

.top h1 { font-size: 1.55rem; margin: 0; }

.top-actions { display: flex; gap: 4px; align-items: center; }

fieldset { border: 0; margin: 12px 0; padding: 0; }

legend { font-weight: 700; margin-bottom: 8px; }

.text-btn, .linkish {
  border: 0;
  background: transparent;
  color: var(--pine);
  font-weight: 700;
  padding: 8px 2px;
  min-height: 44px;
}

.privacy {
  margin: 10px 0 0;
  padding: 10px 12px;
  font-size: 0.92rem;
  font-weight: 700;
}

html[data-offline="true"] .privacy { background: #6d4a1a; }

.free {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 16px 0;
  padding: 8px 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.free p { margin: 0; flex: 1; font-size: 0.92rem; font-weight: 700; white-space: nowrap; }

.meter { display: flex; gap: 4px; }

.meter span {
  width: 10px;
  height: 10px;
  border-radius: 99px;
  background: #e5d8c8;
}

.meter span.on { background: var(--pine); }

.view { padding: 14px 16px 8px; }

.attention {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--pine-soft);
  color: var(--pine-deep);
  font-weight: 700;
}

.attention[data-tone="alert"] { background: var(--red-bg); color: var(--clay); }

.attention[data-tone="tight"] { background: var(--amber-bg); color: #5c430c; }

.pay-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 6px solid var(--pine);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 14px;
}

.pay-card[data-tone="alert"] {
  background: #fff7f4;
  border-color: var(--red-line);
  border-left-color: var(--clay);
}

.pay-card[data-tone="tight"] {
  background: #fffaf0;
  border-color: var(--amber-line);
  border-left-color: #a67c2d;
}

.pay-card.is-drop { outline: 3px solid var(--pine); outline-offset: 2px; }

.pay-head, .bill-main, .sub-row, .storm-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.pay-head p { margin: 4px 0 0; font-size: 0.86rem; }

.pills { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }

.pill {
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.pill-overdue, .pill-short { background: var(--clay); color: #fff7f4; }

.pill-tight { background: #8a5a12; color: #fff8e8; }

.totals {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 14px 0;
}

.totals div {
  background: rgba(255, 255, 255, 0.55);
  border-radius: 12px;
  padding: 8px;
}

.totals dt { color: var(--ink-soft); font-size: 0.75rem; }

.totals dd {
  margin: 2px 0 0;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.left {
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 700;
}

.left-tight { color: #8a5a12; }

.left-short { color: var(--clay); }

.bill {
  border-top: 1px solid var(--line);
  padding: 12px 0 4px;
}

.bill.is-paid .bill-name,
.bill.is-paid .bill-amount { text-decoration: line-through; opacity: 0.6; }

.bill-main { align-items: center; }

.bill-name {
  border: 0;
  background: transparent;
  padding: 0;
  text-align: left;
  font-weight: 700;
  min-height: 44px;
  flex: 1;
  min-width: 0;
}

.bill-amount { font-variant-numeric: tabular-nums; font-weight: 700; }

.bill-due, .bill-extra { margin: 0 0 8px; font-size: 0.86rem; }

.bill-actions { display: flex; gap: 8px; margin-bottom: 8px; }

.bill-actions button, .btn, .choice {
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  min-height: 48px;
}

.bill-actions button { padding: 8px 12px; font-weight: 700; }

.btn {
  display: block;
  width: 100%;
  margin: 8px 0;
  padding: 12px 14px;
  font-weight: 700;
}

.btn.primary { background: var(--pine); color: #f6f1e8; border-color: var(--pine); }

.btn.secondary { background: transparent; color: var(--pine); border-color: var(--pine); }

.btn.danger { background: transparent; color: var(--clay); border-color: var(--red-line); }

.btn:disabled, button:disabled { opacity: 0.55; cursor: not-allowed; }

.stack { display: grid; gap: 8px; margin: 12px 0 18px; }

.choice {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  text-align: left;
  position: relative;
}

.choice input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.choice:has(input:checked) {
  border-color: var(--pine);
  background: var(--pine-soft);
}

.choice small { color: var(--ink-soft); }

label.field { display: grid; gap: 6px; font-weight: 700; margin: 10px 0; }

label.field input, label.field select, textarea {
  width: 100%;
  min-height: 48px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 10px 12px;
  font-weight: 500;
}

textarea { min-height: 180px; resize: vertical; }

.checkline {
  display: flex;
  gap: 10px;
  align-items: center;
  font-weight: 700;
  margin: 8px 0 12px;
}

.error {
  background: var(--red-bg);
  color: var(--clay);
  border-radius: 12px;
  padding: 10px 12px;
  margin: 8px 0;
  font-weight: 700;
}

.nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: min(480px, 100%);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: #fffaf4;
  border-top: 1px solid var(--line);
  z-index: 6;
}

.nav-simple { grid-template-columns: repeat(3, 1fr); }

.nav button {
  border: 0;
  background: transparent;
  border-radius: 12px;
  min-height: 52px;
  padding: 6px;
  line-height: 1.15;
  font-weight: 700;
  color: var(--ink-soft);
}

.nav button[aria-current="page"] { background: var(--pine-soft); color: var(--pine-deep); }

.sub-hero, .storm-card, .panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}

.sub-hero { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.stat { background: var(--pine-soft); border-radius: 14px; padding: 12px; }

.stat span { display: block; color: var(--ink-soft); font-size: 0.82rem; }

.stat strong {
  display: block;
  margin-top: 4px;
  font-family: var(--serif);
  font-size: 1.7rem;
}

.sub-row, .storm-item { padding: 12px 0; border-top: 1px solid var(--line); }

.storm-card h2 { font-size: 1.8rem; }

.storm-actions { margin: 8px 0 4px; }

.storm-item h3 { margin: 0 0 4px; font-size: 1.15rem; }

.storm-item p { margin: 2px 0; overflow-wrap: anywhere; }

.phone-link { color: var(--pine); font-weight: 800; font-size: 1.05rem; }

.legend { font-size: 0.86rem; }

dialog.sheet {
  position: fixed;
  inset: auto 0 0 0;
  width: min(480px, 100%);
  max-height: 92dvh;
  margin: 0 auto;
  border: 0;
  padding: 0;
  border-radius: 22px 22px 0 0;
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 -12px 40px rgba(36, 28, 21, 0.18);
}

dialog.sheet::backdrop { background: rgba(36, 28, 21, 0.48); }

.sheet-body { padding: 10px 16px calc(18px + env(safe-area-inset-bottom)); overflow: auto; max-height: 92dvh; }

.grabber {
  width: 48px;
  height: 5px;
  border-radius: 99px;
  background: var(--line);
  margin: 4px auto 12px;
}

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

.move-option { text-align: left; }

.move-option small { display: block; color: var(--ink-soft); font-weight: 600; }

.move-option.warn { border-color: var(--amber-line); background: var(--amber-bg); }

.move-option.bad { border-color: var(--red-line); background: var(--red-bg); }

.grip {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 10px;
  background:
    radial-gradient(circle, var(--ink-soft) 1.5px, transparent 1.7px) 0 0 / 8px 8px;
  background-color: transparent;
  flex: none;
  touch-action: none;
}

#drag-ghost {
  position: fixed;
  z-index: 80;
  pointer-events: none;
  transform: translate(-50%, -140%);
  background: var(--pine-deep);
  color: #fffaf4;
  padding: 8px 12px;
  border-radius: 999px;
  font-weight: 700;
}

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav) + 12px);
  transform: translateX(-50%) translateY(12px);
  width: min(440px, calc(100% - 24px));
  background: var(--ink);
  color: #fffaf4;
  border-radius: 14px;
  padding: 12px 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
  z-index: 70;
}

#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.noscript { padding: 32px 20px; }

.empty-bills { color: var(--ink-soft); margin: 4px 0 8px; }

form[data-recurring="yes"] [data-when="date"],
form[data-recurring="no"] [data-when="day"] { display: none; }

html.simple .simple-hide { display: none !important; }

html.simple .btn,
html.simple .nav button,
html.simple .bill-actions button { min-height: 64px; }

html.simple .bill-actions { display: grid; grid-template-columns: 1fr 1fr; }

html.simple .bill-actions button[data-action="toggle-paid"] {
  background: var(--pine);
  color: #f6f1e8;
  border-color: var(--pine);
}

html.simple .bill-actions button[data-action="open-move"] {
  background: transparent;
  color: var(--pine);
  border: 2px solid var(--pine);
}

html.simple .welcome-wrap h1,
html.simple .setup-wrap h1 { font-size: 2.15rem; }

html.simple .top h1 { font-size: 1.65rem; }

html.simple .left { font-size: 1.8rem; }

html.simple .privacy { font-size: 1.05rem; }

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

@media (forced-colors: active) {
  .pill, .pay-card, .btn { border: 1px solid CanvasText; }
}

@media print {
  body { background: white; }
  .sticky, .nav, .free, .no-print, #toast, #drag-ghost { display: none !important; }
  #app { max-width: none; padding: 0; }
  .storm-card, .sub-hero, .panel, .pay-card { box-shadow: none; }
  .phone-link { color: black; text-decoration: none; }
}
