:root {
  color-scheme: light dark;
  --bg: #f4f1ec;
  --card: #fffdf9;
  --ink: #1d1a16;
  --quiet: #655e55;
  --line: #e2dcd2;
  --edge: #8d867c;
  --good: #256b42;
  --bad: #a83a29;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16130f;
    --card: #1f1b16;
    --ink: #efe9df;
    --quiet: #a39a8e;
    --line: #322c24;
    --edge: #746c60;
    --good: #6cc08e;
    --bad: #ea8572;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: 0.5; cursor: default; }
[hidden] { display: none !important; }

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 640px;
  margin: 0 auto;
  padding: 8px 16px 0;
}
.top h1 { font-size: 15px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--quiet); margin: 0; }
.who { min-height: 44px; background: none; border: 0; padding: 0 0 0 12px; color: var(--quiet); text-decoration: underline; text-underline-offset: 3px; }

.wrap { max-width: 640px; margin: 0 auto; padding: 8px 16px 110px; }
.quiet { color: var(--quiet); }

.headline { margin: 14px 0 18px; font-size: 34px; line-height: 1.1; font-weight: 700; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.headline.good { color: var(--good); }
.headline.bad { color: var(--bad); }
.headline:has(+ .sub) { margin-bottom: 6px; }
.sub { margin: 0 0 18px; color: var(--quiet); }

h2 { display: flex; align-items: center; gap: 4px; margin: 22px 0 0; min-height: 32px; font-size: 13px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--quiet); }
.info { display: grid; place-items: center; width: 44px; height: 32px; padding: 0; border: 0; background: none; color: var(--quiet); }
.info::before { content: ""; position: absolute; width: 20px; height: 20px; border: 1px solid var(--edge); border-radius: 50%; }
.info { position: relative; font: italic 600 13px/1 Georgia, serif; text-transform: none; }
.note { margin: 4px 0 8px; font-size: 14px; color: var(--quiet); }

.rows { list-style: none; margin: 0; padding: 0; }
.row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 60px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  min-width: 0;
}
.row .main { flex: 1; min-width: 0; min-height: 44px; background: none; border: 0; padding: 0; text-align: left; display: flex; flex-direction: column; justify-content: center; }
.row .title { display: block; overflow-wrap: anywhere; }
.row .meta { display: block; font-size: 14px; color: var(--quiet); overflow-wrap: anywhere; }
.row .meta .done { color: var(--good); }
.row .meta .warn { color: var(--bad); }
.row .sum { white-space: nowrap; font-variant-numeric: tabular-nums; }
.row.mine .title { font-weight: 600; }

.icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  background: none;
  color: var(--quiet);
  text-decoration: none;
  font-size: 17px;
}
.icon.link { width: 32px; }
.small { flex: none; min-height: 44px; border: 1px solid var(--edge); border-radius: 10px; background: none; padding: 0 14px; font-size: 14px; }

.add {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  border: 0;
  border-radius: 999px;
  padding: 14px 26px;
  background: var(--ink);
  color: var(--bg);
  font-weight: 600;
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.25);
}

details summary { cursor: pointer; min-height: 44px; padding: 12px 0; color: var(--quiet); }

dialog {
  width: min(560px, 100%);
  max-width: 100%;
  max-height: 92dvh;
  margin: auto auto 0;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  border: 0;
  border-radius: 18px 18px 0 0;
  background: var(--card);
  color: var(--ink);
  overflow-y: auto;
}
@media (min-width: 600px) { dialog { margin: auto; border-radius: 18px; } }
dialog::backdrop { background: rgb(0 0 0 / 0.5); }
dialog h3 { margin: 0 0 14px; font-size: 20px; }

.field { display: block; margin: 0 0 14px; }
.field > span:first-child, fieldset legend { display: block; margin-bottom: 4px; font-size: 13px; color: var(--quiet); }
.field input, .field select, .inline input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--edge);
  border-radius: 10px;
  background: var(--bg);
}
fieldset { margin: 0 0 14px; padding: 0; border: 0; min-width: 0; }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.checks label { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; border: 1px solid var(--edge); border-radius: 10px; }
.checks input { width: 18px; height: 18px; margin: 0; accent-color: var(--ink); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
.actions .primary { flex: 1; min-height: 48px; border: 0; border-radius: 10px; padding: 0 18px; background: var(--ink); color: var(--bg); font-weight: 600; }
.actions .plain { min-height: 48px; border: 1px solid var(--edge); border-radius: 10px; padding: 0 18px; background: none; }
.error { margin: 0 0 10px; color: var(--bad); }
.error:empty { display: none; }
.quietlink { display: block; min-height: 44px; margin: 10px auto 0; padding: 0 12px; border: 0; background: none; color: var(--quiet); text-decoration: underline; text-underline-offset: 3px; }
.quietlink.danger { color: var(--bad); }

.people { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.people button { min-height: 44px; border: 1px solid var(--edge); border-radius: 10px; background: none; padding: 0 16px; }
.people button.on { border-color: var(--ink); border-width: 2px; font-weight: 600; }
.inline { display: flex; gap: 8px; margin-bottom: 8px; }
.inline input { flex: 1; min-width: 0; }

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(84px + env(safe-area-inset-bottom));
  max-width: 420px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 2px 6px 2px 16px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--bg);
}
.toast button { min-width: 64px; min-height: 44px; border: 0; background: none; color: inherit; font-weight: 600; text-decoration: underline; }
