:root {
  color-scheme: light;
  --bg: #f3f6f4;
  --card: #ffffff;
  --text: #102621;
  --muted: #5c7069;
  --line: #d5e4dd;
  --accent: #004d40;
  --accent-fill: #004d40;
  --on-accent: #ffffff;
  --accent-soft: #e5f3ee;
  --gold: #e8943a;
  --danger: #c4462d;
  --danger-soft: #fdecea;
  --warn: #9a5b12;
  --warn-soft: #fff3e0;
  --shadow: 0 1px 2px rgba(0, 49, 40, 0.06);
}

html[data-scheme="dark"] {
  color-scheme: dark;
  --bg: #0e1916;
  --card: #152823;
  --text: #e7f3ef;
  --muted: #9ab5ad;
  --line: #2c463e;
  --accent: #8fd9cb;
  --accent-fill: #0e6b59;
  --on-accent: #ffffff;
  --accent-soft: #16362f;
  --gold: #f0a54a;
  --danger: #ff8a78;
  --danger-soft: #3a221e;
  --warn: #f0b56a;
  --warn-soft: #3a2c1a;
  --shadow: none;
}

* { box-sizing: border-box; }

html, body, #app { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

button, input, textarea { font: inherit; color: inherit; }

#app { min-height: 100%; }

.app {
  height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.top {
  display: grid;
  grid-template-columns: 72px 1fr 72px;
  align-items: center;
  padding: calc(10px + env(safe-area-inset-top)) 8px 10px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.title { text-align: center; font-weight: 650; }

.screen {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 16px 16px 28px;
}

.footer {
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--card);
  border-top: 1px solid var(--line);
}

.progress {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  margin-bottom: 8px;
}

.bar {
  height: 4px;
  border-radius: 99px;
  background: var(--line);
  margin: 0 0 16px;
  overflow: hidden;
}

.bar > span {
  display: block;
  height: 100%;
  background: var(--gold);
}

.screen-title {
  margin: 0 0 6px;
  font-size: 26px;
  line-height: 1.15;
  letter-spacing: -0.03em;
}

.lead {
  margin: 0 0 16px;
  color: var(--muted);
}

.prose {
  white-space: pre-wrap;
  background: var(--card);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.prose.secondary { margin-top: 12px; }

.field { margin: 0 0 18px; }

.label { font-weight: 650; margin-bottom: 4px; }

.hint, .row-detail, .note {
  color: var(--muted);
  font-size: 14px;
}

.hint { margin: 0 0 8px; }

input, textarea {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
  outline: none;
}

textarea { min-height: 88px; resize: vertical; }

input:focus, textarea:focus { border-color: var(--accent); }

.choices { display: flex; flex-wrap: wrap; gap: 8px; }

.choice, .primary, .text-btn {
  border: 0;
  cursor: pointer;
}

.choice {
  flex: 1;
  min-width: 96px;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
}

.choice:disabled { opacity: 0.6; }

.suggest-wrap { position: relative; }

.suggest {
  position: absolute;
  z-index: 5;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  max-height: 240px;
  overflow: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.suggest-item, .suggest-empty {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  cursor: pointer;
}

.suggest-item:last-child { border-bottom: 0; }

.suggest-title, .suggest-sub { display: block; }

.suggest-sub, .suggest-empty {
  color: var(--muted);
  font-size: 13px;
}

.suggest-empty { cursor: default; }

.place-note { margin-top: 8px; }

.choice.is-on {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 650;
}

.primary {
  width: 100%;
  min-height: 48px;
  border-radius: 12px;
  background: var(--accent-fill);
  color: var(--on-accent);
  font-weight: 650;
}

.primary:disabled { opacity: 0.6; }

.text-btn {
  background: transparent;
  color: var(--accent);
  padding: 8px;
}

.text-btn.block { display: block; margin: 12px auto; }

.banner {
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 12px;
}

.banner.error { background: var(--danger-soft); color: var(--danger); }

.banner.warn { background: var(--warn-soft); color: var(--warn); }

.hero, .card {
  background: var(--card);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.hero {
  background: linear-gradient(180deg, var(--accent-soft), var(--card) 70%);
  border: 1px solid var(--line);
}

.card.tight { padding: 8px 16px; }

.card.person .hint { margin: 10px 0 0; }

.person-name { font-weight: 700; }

.grand { font-size: 34px; font-weight: 750; letter-spacing: -0.04em; line-height: 1.1; }

.formula-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
}

.formula-row + .formula-row { border-top: 1px solid var(--line); }

.formula-row.is-sum {
  font-size: 18px;
  font-weight: 750;
}

.check-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin: 8px 0 10px;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--card);
}

.check-card input {
  width: 22px;
  height: 22px;
  margin: 2px 0 0;
  accent-color: var(--accent);
  flex: none;
}

.check-copy { display: block; min-width: 0; }

.check-copy .label,
.check-copy .hint { display: block; }

.check-card.is-on {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.check-card .hint { margin: 4px 0 0; }

.section-title {
  margin: 18px 0 8px;
  font-size: 15px;
  font-weight: 700;
}

.row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.row:last-child { border-bottom: 0; }

.row-sum { white-space: nowrap; font-weight: 650; }

.total-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  font-weight: 700;
}

.note { margin: 8px 0; }

.actions { display: flex; justify-content: center; }
