:root {
  --ground: #F4F1EA;
  --surface: #FFFFFF;
  --ink: #1E2B2A;
  --ink-soft: #3A4745;
  --muted: #55615F;
  --line: #DDD7CC;
  --line-soft: #E8E3D9;
  --accent: #2E5A55;
  --accent-dark: #1F403C;
  --accent-tint: #E3ECE9;
  --wait: #9A4A0B;
  --wait-tint: #F6E9DC;
  --danger: #8A2B2B;
  --radius: 12px;
  --font-display: 'Newsreader', Georgia, serif;
  --font-body: 'Public Sans', system-ui, sans-serif;
}

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

html { scroll-padding-top: env(safe-area-inset-top, 0px); }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--ground);
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 500; line-height: 1.2; margin: 0; }
h1 { font-size: 32px; }
h2 { font-size: 26px; }
h3 { font-size: 20px; }
p { margin: 0; }
a { color: var(--accent); }
a:hover { color: var(--accent-dark); }

.page { max-width: 720px; margin: 0 auto; padding: 24px 20px 64px; }
.page-wide { max-width: 1040px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 20px; background: var(--ink); color: #fff;
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5;
}
.topbar .brand { font-family: var(--font-display); font-size: 22px; color: #fff; text-decoration: none; }
.topbar .brand small { font-family: var(--font-body); font-size: 13px; color: #D8D3C9; margin-left: 10px; }
.topbar .who { font-size: 14px; color: #D8D3C9; }
.topbar button { color: #fff; border-color: #55615F; background: transparent; }

.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-lg { gap: 28px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grow { flex-grow: 1; }
.right { margin-left: auto; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 20px;
}
.card.quiet { background: transparent; border-style: dashed; }
.card-note { background: var(--accent-tint); border: 0; }
.card-warn { background: var(--wait-tint); border: 0; }

.lead { font-size: 17px; color: var(--ink-soft); }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.tiny { font-size: 13px; }

label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
label .hint { font-weight: 400; color: var(--muted); }
input[type="text"], input[type="email"], input[type="date"], input[type="tel"], select, textarea {
  width: 100%; height: 48px; padding: 0 14px; border: 1px solid #C9C2B5; border-radius: 10px;
  background: #fff; font: inherit; font-size: 16px; color: var(--ink);
}
textarea { height: auto; min-height: 96px; padding: 12px 14px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: 3px solid #9CC2BB; outline-offset: 2px;
}
.field { display: flex; flex-direction: column; }
.field + .field { margin-top: 16px; }
.field .help { font-size: 13px; color: var(--muted); margin-top: 6px; line-height: 1.45; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 520px) { .grid-2 { grid-template-columns: 1fr; } }

button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: 10px; border: 1px solid var(--accent);
  background: var(--accent); color: #fff; font: inherit; font-size: 16px; font-weight: 600;
  cursor: pointer; text-decoration: none;
}
button:hover, .btn:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }
button:disabled { opacity: .55; cursor: default; }
.btn-secondary { background: #fff; color: var(--accent); }
.btn-secondary:hover { background: var(--accent-tint); color: var(--accent-dark); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--accent); padding: 0 8px; min-height: 40px; }
.btn-ghost:hover { background: var(--accent-tint); border-color: transparent; color: var(--accent-dark); }
.btn-danger { background: #fff; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: #F8ECEC; color: var(--danger); border-color: var(--danger); }
.btn-block { width: 100%; }
.btn-sm { min-height: 40px; padding: 0 14px; font-size: 15px; }

.check-row {
  display: flex; align-items: center; gap: 12px; min-height: 46px; font-size: 16px; font-weight: 400;
  margin: 0; padding: 4px 0; border-top: 1px solid var(--line-soft); cursor: pointer;
}
.check-row:first-of-type { border-top: 0; }
.check-row input { width: 22px; height: 22px; margin: 0; accent-color: var(--accent); flex-shrink: 0; }
.check-row .sub { font-size: 13px; color: var(--muted); display: block; }

.radio-pills { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.radio-pills label {
  display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 46px;
  border: 1px solid #C9C2B5; border-radius: 10px; background: #fff; font-weight: 500; margin: 0; cursor: pointer;
}
.radio-pills label:has(input:checked) { background: var(--accent); border-color: var(--accent); color: #fff; }
.radio-pills input { margin: 0; }

.progress { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); }

.steps { display: flex; justify-content: space-between; align-items: center; font-size: 14px; color: var(--muted); }

.section-title { font-size: 13px; font-weight: 600; letter-spacing: 0.04em; color: var(--muted); margin-bottom: 8px; }

.task-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 14px; background: #fff; overflow: hidden; }
.task {
  display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--line-soft);
  background: #fff; width: 100%; text-align: left; border-left: 0; border-right: 0; border-bottom: 0; border-radius: 0;
  color: var(--ink); font-weight: 400; min-height: 0;
}
.task:first-child { border-top: 0; }
.task:hover { background: #FBFAF7; color: var(--ink); border-color: var(--line-soft); }
.task .name { font-weight: 600; font-size: 16px; }
.task .state { font-size: 14px; color: var(--muted); }
.task .icon { flex-shrink: 0; width: 22px; height: 22px; margin-top: 2px; }

.badge { display: inline-block; font-size: 13px; font-weight: 600; padding: 2px 10px; border-radius: 999px; }
.badge-complete { background: var(--accent-tint); color: var(--accent-dark); }
.badge-sent { background: var(--wait-tint); color: var(--wait); }
.badge-action { background: var(--ink); color: #fff; }
.badge-none { background: var(--line-soft); color: var(--muted); }

.counts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.counts .card { padding: 12px; }
.counts .n { font-size: 24px; font-weight: 600; }
.counts .n.wait { color: var(--wait); }
.counts .n.done { color: var(--accent); }
.counts .card.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.counts .card.dark .muted { color: #E6E2DA; }

.drawer-backdrop { position: fixed; inset: 0; background: rgba(30, 43, 42, .45); z-index: 20; display: none; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100%); background: var(--ground);
  z-index: 21; overflow-y: auto; padding: 20px 20px calc(32px + env(safe-area-inset-bottom, 0px));
  padding-top: calc(20px + env(safe-area-inset-top, 0px)); display: none;
}
.drawer.open, .drawer-backdrop.open { display: block; }

pre.letter {
  white-space: pre-wrap; font: 15px/1.5 var(--font-body); background: #fff; border: 1px solid var(--line);
  border-radius: 10px; padding: 16px; max-height: 360px; overflow: auto; margin: 0;
}

.note { padding: 10px 0; border-top: 1px solid var(--line-soft); font-size: 15px; }
.note .meta { font-size: 13px; color: var(--muted); }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 10px; font-size: 15px; z-index: 30;
  display: none; max-width: calc(100% - 40px);
}
.toast.show { display: block; }

.hidden { display: none !important; }

table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
th { font-size: 13px; color: var(--muted); font-weight: 600; }

.error { color: var(--danger); font-size: 14px; }

@media (prefers-reduced-motion: no-preference) {
  .drawer.open { animation: slide-in .18s ease-out; }
  @keyframes slide-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
}
