:root {
  --paper: #f6f4ee;
  --paper-raised: #ffffff;
  --ink: #232725;
  --ink-soft: #6b706c;
  --ink-faint: #9a9d90;
  --line: #c9c3ac;
  --line-strong: #b3ac8f;
  --accent: #2f5d50;
  --accent-ink: #f3f7f4;
  --stamp: #bb2b26;
  --stamp-ink: #fff5f4;
  --danger: #b3432b;
  --shadow: 0 1px 2px rgba(35, 38, 43, 0.06), 0 6px 20px rgba(35, 38, 43, 0.05);
  --radius: 10px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #1c1e1b;
    --paper-raised: #262922;
    --ink: #eae7dc;
    --ink-soft: #a9ac9d;
    --ink-faint: #74776a;
    --line: #3a3d33;
    --line-strong: #4c503f;
    --accent: #7fb69f;
    --accent-ink: #16211c;
    --stamp: #e2726a;
    --stamp-ink: #2c1a18;
    --danger: #e2896f;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --paper: #1c1e1b;
  --paper-raised: #262922;
  --ink: #eae7dc;
  --ink-soft: #a9ac9d;
  --ink-faint: #74776a;
  --line: #3a3d33;
  --line-strong: #4c503f;
  --accent: #7fb69f;
  --accent-ink: #16211c;
  --stamp: #e2726a;
  --stamp-ink: #2c1a18;
  --danger: #e2896f;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Zen Kaku Gothic New", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  padding: 32px 16px 80px;
  line-height: 1.6;
}

.app {
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

header.top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--line-strong);
  flex-wrap: wrap;
}

header.top h1 {
  font-family: "Noto Serif JP", serif;
  font-weight: 700;
  font-size: 26px;
  margin: 0;
  letter-spacing: 0.02em;
  text-wrap: balance;
}

header.top .today {
  font-size: 13px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.report-cta { display: flex; justify-content: flex-end; }

button { font-family: inherit; cursor: pointer; }

.btn {
  border: 1px solid var(--line-strong);
  background: var(--paper-raised);
  color: var(--ink);
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
  font-weight: 700;
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--ink-soft);
  padding: 6px 10px;
  font-size: 12px;
}
.btn-ghost:hover { color: var(--danger); }

.card {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

form.add-form {
  padding: 18px;
  display: grid;
  grid-template-columns: 1fr 150px;
  gap: 10px 12px;
}
form.add-form .field-name { grid-column: 1 / -1; }
form.add-form .field-memo { grid-column: 1 / -1; }
form.add-form label {
  display: block;
  font-size: 12px;
  color: var(--ink-soft);
  margin-bottom: 5px;
  letter-spacing: 0.03em;
}
form.add-form input, form.add-form textarea {
  width: 100%;
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
}
form.add-form textarea { resize: vertical; min-height: 40px; }
.form-error {
  grid-column: 1 / -1;
  margin: -2px 0 0;
  font-size: 12.5px;
  color: var(--danger);
}
form.add-form .field-submit {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  margin-top: 2px;
}

section.list-section { display: flex; flex-direction: column; gap: 2px; }
section.list-section .section-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 2px 8px;
  color: var(--ink-soft);
  font-size: 13px;
  letter-spacing: 0.04em;
}
section.list-section .section-head .count {
  font-variant-numeric: tabular-nums;
  color: var(--ink-faint);
}
.rule-list {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.empty-row {
  padding: 22px 16px;
  color: var(--ink-faint);
  font-size: 13px;
  text-align: center;
}
.task-row {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: start;
  gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
}
.task-row:last-child { border-bottom: none; }
.check {
  width: 20px;
  height: 20px;
  border-radius: 5px;
  border: 1.5px solid var(--line-strong);
  background: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
  flex: none;
}
.check.checked {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-size: 13px;
}
.task-main .name { font-size: 14.5px; font-weight: 500; }
.task-row.done .task-main .name {
  color: var(--ink-soft);
  text-decoration: line-through;
  text-decoration-color: var(--line-strong);
}
.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
  font-size: 12px;
  color: var(--ink-soft);
}
.task-meta .due { font-variant-numeric: tabular-nums; }
.task-meta .memo { color: var(--ink-faint); }
.stamp {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid var(--stamp);
  color: var(--stamp);
  background: var(--stamp-ink);
  font-family: "Noto Serif JP", serif;
  font-size: 13px;
  font-weight: 700;
  transform: rotate(-8deg);
  flex: none;
  letter-spacing: 0.02em;
}
.row-actions { display: flex; gap: 4px; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 16, 0.42);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 16px;
  overflow-y: auto;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: 14px;
  max-width: 460px;
  width: 100%;
  box-shadow: var(--shadow);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.modal h2 { font-family: "Noto Serif JP", serif; font-size: 19px; margin: 0; }
.modal .sub { font-size: 12.5px; color: var(--ink-soft); margin-top: -8px; }
.mail-field { display: flex; flex-direction: column; gap: 4px; }
.mail-field .label-row { display: flex; justify-content: space-between; align-items: center; }
.mail-field label { font-size: 11.5px; color: var(--ink-soft); letter-spacing: 0.04em; }
.mail-field .value {
  font-size: 13.5px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  white-space: pre-wrap;
  font-variant-numeric: tabular-nums;
}
.copy-btn {
  border: none;
  background: none;
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 700;
  padding: 2px 4px;
}
.copy-btn:hover { text-decoration: underline; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--ink);
  color: var(--paper);
  padding: 9px 18px;
  border-radius: 999px;
  font-size: 12.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 480px) {
  form.add-form { grid-template-columns: 1fr; }
  .task-row { grid-template-columns: 20px 1fr; }
  .row-actions { grid-column: 2; justify-self: end; margin-top: -26px; }
}
