@font-face {
  font-family: "Newsreader";
  src: url("/assets/fonts/newsreader.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Newsreader";
  src: url("/assets/fonts/newsreader-italic.woff2") format("woff2");
  font-weight: 200 800;
  font-style: italic;
  font-display: swap;
}

:root {
  --bg: #f7f6f3;
  --surface: #ffffff;
  --surface-2: #f0efeb;
  --line: #e8e6e1;
  --text: #2b2a28;
  --muted: #7c7a75;
  --faint: #aeaba5;
  --ink: #1c1b1a;
  --ink-text: #ffffff;
  --a-bg: #e3eef6;
  --a-fg: #2c5f80;
  --b-bg: #f7e5e1;
  --b-fg: #96493d;
  --both-bg: #e7efe5;
  --both-fg: #3e6240;
  --warn-bg: #fbf1d8;
  --warn-fg: #8a5d00;
  --danger: #a3332f;
  --serif: "Newsreader", "Iowan Old Style", Georgia, serif;
  --sans: -apple-system, "SF Pro Text", system-ui, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", monospace;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
  --tabbar: calc(58px + env(safe-area-inset-bottom));
  color-scheme: light;
}

:root[data-theme="dark"] {
    --bg: #23211e;
    --surface: #2c2a26;
    --surface-2: #35322e;
    --line: #3d3a35;
    --text: #eeeae3;
    --muted: #aaa59c;
    --faint: #757068;
    --ink: #f1ede6;
    --ink-text: #23211e;
    --a-bg: #2a3741;
    --a-fg: #a6cbe4;
    --b-bg: #42302b;
    --b-fg: #ebbcb1;
    --both-bg: #2d382c;
    --both-fg: #b3d1af;
    --warn-bg: #3d3420;
    --warn-fg: #e6c887;
    --danger: #ec958f;
    color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
      --bg: #23211e;
      --surface: #2c2a26;
      --surface-2: #35322e;
      --line: #3d3a35;
      --text: #eeeae3;
      --muted: #aaa59c;
      --faint: #757068;
      --ink: #f1ede6;
      --ink-text: #23211e;
      --a-bg: #2a3741;
      --a-fg: #a6cbe4;
      --b-bg: #42302b;
      --b-fg: #ebbcb1;
      --both-bg: #2d382c;
      --both-fg: #b3d1af;
      --warn-bg: #3d3420;
      --warn-fg: #e6c887;
      --danger: #ec958f;
      color-scheme: dark;
}
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
  font-variant-numeric: tabular-nums;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; }
svg.icon { width: 1em; height: 1em; flex: none; display: block; }

/* ---------- layout ---------- */

.app { min-height: 100dvh; }
.screen {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 20px) 20px calc(var(--tabbar) + 32px);
  animation: screen-in 260ms var(--ease-out);
}
@keyframes screen-in { from { opacity: 0; transform: translateY(6px); } }

.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 8px 0 24px; }
.head h1 {
  font: 500 34px/1.05 var(--serif);
  letter-spacing: -0.025em;
  margin: 0;
}
.head .sub { color: var(--muted); font-size: 14px; margin-top: 6px; }
.head .back { display: inline-flex; align-items: center; gap: 2px; color: var(--muted); font-size: 15px; margin-bottom: 10px; margin-left: -4px; }
.head .back .icon { font-size: 18px; }

.section { margin-top: 32px; }
.section:first-of-type { margin-top: 0; }
.label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 10px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.label .count { font-weight: 500; color: var(--faint); letter-spacing: 0; text-transform: none; font-size: 13px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
}
.card + .card { margin-top: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.rows { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  width: 100%;
  text-align: left;
}
.row:last-child { border-bottom: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .title { overflow-wrap: anywhere; }
.row .meta { font-size: 13px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 1px; }
.row .end { color: var(--muted); font-size: 14px; white-space: nowrap; }
.row .chev { color: var(--faint); font-size: 16px; }
.row.done .title { color: var(--faint); text-decoration: line-through; text-decoration-thickness: 1px; }
button.row:active, .pressable:active { background: var(--surface-2); }

.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.serif { font-family: var(--serif); }
.num { font-variant-numeric: tabular-nums; }
.danger { color: var(--danger); }
.center { text-align: center; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.inline { display: flex; align-items: center; gap: 8px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.wrap { flex-wrap: wrap; }

.empty { color: var(--faint); font-size: 15px; padding: 18px 16px; text-align: center; }

/* ---------- controls ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 46px;
  padding: 0 18px;
  border-radius: 10px;
  background: var(--ink);
  color: var(--ink-text);
  font-weight: 600;
  font-size: 16px;
  transition: transform 140ms var(--ease-out), opacity 140ms ease;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; }
.btn.block { width: 100%; }
.btn.ghost { background: var(--surface-2); color: var(--text); }
.btn.quiet { background: transparent; color: var(--muted); font-weight: 500; }
.btn.danger { background: transparent; color: var(--danger); font-weight: 500; }
.btn.small { height: 34px; padding: 0 12px; font-size: 14px; border-radius: 8px; }

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: inline-grid;
  place-items: center;
  font-size: 20px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  transition: transform 140ms var(--ease-out);
}
.icon-btn:active { transform: scale(0.94); }
.icon-btn.solid { background: var(--ink); color: var(--ink-text); border-color: var(--ink); }

.check {
  width: 24px;
  height: 24px;
  flex: none;
  border-radius: 50%;
  border: 1.5px solid var(--faint);
  display: grid;
  place-items: center;
  color: transparent;
  font-size: 13px;
  transition: background-color 160ms ease, border-color 160ms ease, transform 140ms var(--ease-out);
}
.check:active { transform: scale(0.88); }
.check.on { background: var(--ink); border-color: var(--ink); color: var(--ink-text); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; color: var(--muted); font-weight: 500; }
.input {
  width: 100%;
  min-height: 46px;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 16px;
  outline: none;
  transition: border-color 140ms ease;
  -webkit-appearance: none;
  appearance: none;
}
.input:focus { border-color: var(--muted); }
textarea.input { resize: none; min-height: 88px; line-height: 1.45; }
input[type="date"].input, input[type="time"].input { display: flex; align-items: center; }
input[type="date"].input::-webkit-date-and-time-value, input[type="time"].input::-webkit-date-and-time-value { text-align: left; }
.input.big { font-size: 20px; border: 0; padding: 4px 0; background: transparent; min-height: 40px; }
.input.big::placeholder { color: var(--faint); }

.seg {
  display: flex;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}
.seg button {
  flex: 1;
  height: 36px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  transition: background-color 160ms ease, color 160ms ease;
  white-space: nowrap;
  padding: 0 8px;
}
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  height: 34px;
  padding: 0 13px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 14px;
  color: var(--text);
  transition: transform 140ms var(--ease-out), background-color 140ms ease;
}
.chip:active { transform: scale(0.96); }
.chip.on { background: var(--ink); color: var(--ink-text); border-color: var(--ink); }

.tag {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.tag.a { background: var(--a-bg); color: var(--a-fg); }
.tag.b { background: var(--b-bg); color: var(--b-fg); }
.tag.both { background: var(--both-bg); color: var(--both-fg); }
.tag.warn { background: var(--warn-bg); color: var(--warn-fg); }
.tag.plain { background: var(--surface-2); color: var(--muted); }

.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot.a { background: var(--a-fg); }
.dot.b { background: var(--b-fg); }
.dot.both { background: var(--both-fg); }

.toggle { position: relative; width: 50px; height: 30px; flex: none; }
.toggle input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.toggle span { position: absolute; inset: 0; border-radius: 999px; background: var(--line); transition: background-color 200ms ease; pointer-events: none; }
.toggle span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  transition: transform 220ms var(--ease-out);
}
.toggle input:checked + span { background: var(--both-fg); }
.toggle input:checked + span::after { transform: translateX(20px); }

/* ---------- tab bar ---------- */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--tabbar);
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
  justify-content: space-around;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(20px);
  backdrop-filter: saturate(1.4) blur(20px);
  border-top: 1px solid var(--line);
  z-index: 20;
}
.tabbar button {
  flex: 1;
  max-width: 110px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--faint);
  transition: color 160ms ease;
}
.tabbar button .icon { font-size: 24px; }
.tabbar button.on { color: var(--text); }

/* ---------- sheet ---------- */

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 18, 15, 0.32);
  z-index: 40;
  opacity: 0;
  transition: opacity 300ms ease;
}
.backdrop.open { opacity: 1; }
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 41;
  max-width: 640px;
  margin: 0 auto;
  max-height: calc(100dvh - env(safe-area-inset-top) - 24px);
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-radius: 16px 16px 0 0;
  transform: translateY(100%);
  transition: transform 380ms var(--ease-drawer);
}
.sheet.open { transform: translateY(0); }
.sheet .grab { width: 36px; height: 5px; border-radius: 3px; background: var(--line); margin: 8px auto 0; flex: none; }
.sheet .sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 20px 4px; flex: none; }
.sheet .sheet-head h2 { font: 500 22px/1.2 var(--serif); letter-spacing: -0.015em; margin: 0; }
.sheet .sheet-body { padding: 14px 20px calc(env(safe-area-inset-bottom) + 20px); overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 18px; }
.sheet .actions { display: flex; gap: 10px; margin-top: 4px; }
.sheet .actions .btn { flex: 1; }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar) + 14px);
  transform: translate(-50%, 0);
  background: var(--ink);
  color: var(--ink-text);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 60;
  transition: opacity 200ms ease, transform 260ms var(--ease-out);
  max-width: calc(100vw - 40px);
  display: flex;
  gap: 14px;
  align-items: center;
}
.toast.hide { opacity: 0; transform: translate(-50%, 8px); pointer-events: none; }
.toast button { color: inherit; font-weight: 600; opacity: 0.8; }

/* ---------- specific ---------- */

.hero-date { color: var(--muted); font-size: 14px; margin-bottom: 6px; }
.hero-date::first-letter { text-transform: uppercase; }
.together { color: var(--muted); font-size: 15px; margin-top: 8px; }
.together b { color: var(--text); font-weight: 600; }

.note-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px 20px 16px;
  position: relative;
}
.note-card blockquote {
  margin: 0;
  font: italic 400 21px/1.35 var(--serif);
  letter-spacing: -0.01em;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.note-card .by { margin-top: 12px; font-size: 13px; color: var(--muted); display: flex; justify-content: space-between; align-items: center; }

.stat { font: 500 30px/1.1 var(--serif); letter-spacing: -0.02em; }
.stat-label { font-size: 13px; color: var(--muted); margin-top: 4px; }

.bar { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; display: flex; }
.bar > i { display: block; height: 100%; transition: transform 500ms var(--ease-out); transform-origin: left; }
.bar > i.a { background: var(--a-fg); }
.bar > i.b { background: var(--b-fg); }
.bar > i.ink { background: var(--ink); }

.water { display: flex; gap: 6px; flex-wrap: wrap; }
.water button {
  width: 30px;
  height: 36px;
  border-radius: 6px 6px 9px 9px;
  border: 1.5px solid var(--line);
  position: relative;
  overflow: hidden;
  transition: transform 140ms var(--ease-out), border-color 160ms ease;
}
.water button::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 100%;
  background: var(--a-bg);
  transform: translateY(100%);
  transition: transform 280ms var(--ease-out);
}
.water button.on { border-color: var(--a-fg); }
.water button.on::after { transform: translateY(0); }
.water button:active { transform: scale(0.92); }

.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-head h3 { margin: 0; font: 500 20px/1.2 var(--serif); text-transform: capitalize; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.cal .dow { font-size: 11px; color: var(--faint); font-weight: 600; padding-bottom: 6px; text-transform: uppercase; letter-spacing: 0.04em; }
.cal button {
  aspect-ratio: 1;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 15px;
  position: relative;
}
.cal button.out { color: var(--faint); }
.cal button.today { font-weight: 700; }
.cal button.today::before { content: ""; position: absolute; inset: 4px; border: 1px solid var(--line); border-radius: 9px; }
.cal button.sel { background: var(--ink); color: var(--ink-text); }
.cal button.sel::before { display: none; }
.cal .dots { display: flex; gap: 3px; height: 5px; }
.cal .dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--muted); }
.cal button.sel .dots i { background: var(--ink-text); }
.cal .dots i.special { background: var(--b-fg); }

.menu-day { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.menu-day:last-child { border-bottom: 0; }
.menu-day .d { font-weight: 600; text-transform: capitalize; margin-bottom: 6px; display: flex; justify-content: space-between; }
.menu-day .d.today { color: var(--both-fg); }
.menu-slot { display: grid; grid-template-columns: 76px 1fr; gap: 10px; font-size: 14px; padding: 3px 0; text-align: left; width: 100%; }
.menu-slot .s { color: var(--muted); }
.menu-slot .t.empty-t { color: var(--faint); }

.spark { width: 100%; height: 72px; display: block; }
.spark path.line { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.spark path.line.a { stroke: var(--a-fg); }
.spark path.line.b { stroke: var(--b-fg); }

.doc-preview { width: 100%; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); }
iframe.doc-preview { height: 60dvh; }

.login { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; padding: calc(env(safe-area-inset-top) + 24px) 24px calc(env(safe-area-inset-bottom) + 24px); max-width: 420px; margin: 0 auto; }
.login h1 { font: 500 42px/1.05 var(--serif); letter-spacing: -0.03em; margin: 0 0 8px; }
.who { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.who button {
  height: 96px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  font: 500 24px/1 var(--serif);
  transition: transform 140ms var(--ease-out), border-color 160ms ease;
}
.who button:active { transform: scale(0.97); }
.who button.on { border-color: var(--ink); border-width: 1.5px; }
.pin { letter-spacing: 0.5em; text-align: center; font-size: 24px; font-family: var(--mono); }

.list-enter { animation: item-in 280ms var(--ease-out) both; }
@keyframes item-in { from { opacity: 0; transform: translateY(4px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}
