:root {
  --paper: #f6f3ea;
  --ink: #2e2b25;
  --muted: #8a8375;
  --faint: #aaa292;
  --line: #d8d0be;
  --line-soft: #e7e1d2;
  --field: #fffdf8;
  --accent: #b4492f;
  --accent-dark: #9c3c25;
  --ok: #647f56;
  --warn: #b28a2e;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.page {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: 34px 18px calc(48px + env(safe-area-inset-bottom));
}

h1 {
  margin: 0;
  font-family: "Songti SC", "STSong", "Noto Serif CJK SC", SimSun, serif;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1.3;
}

.sub {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12.5px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Add row */

.add {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 168px 76px;
  gap: 8px;
  margin: 24px 0 28px;
}

.field-title,
.field-person {
  min-width: 0;
}

.add input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--field);
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  line-height: 1.4;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.add input::placeholder {
  color: var(--faint);
}

.add input:focus {
  border-color: #b7aa90;
  box-shadow: 0 0 0 3px rgba(180, 73, 47, 0.08);
}

.btn {
  height: 42px;
  padding: 0 16px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff8ee;
  font: inherit;
  font-size: 15px;
  cursor: pointer;
  transition: background-color 0.15s ease, opacity 0.15s ease;
}

.btn:hover {
  background: var(--accent-dark);
}

.btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Table */

.board {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.board col:nth-child(1) {
  width: 55%;
}

.board col:nth-child(2) {
  width: 25%;
}

.board col:nth-child(3) {
  width: 20%;
}

.board th {
  padding: 0 8px 8px;
  border-bottom: 1px solid #c8bfab;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-align: left;
  white-space: nowrap;
}

.board th:first-child {
  padding-left: 2px;
}

.board th:last-child {
  padding-left: 6px;
}

.board td {
  padding: 0;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
}

@media (hover: hover) {
  .board tbody tr:not(.state-row):hover {
    background: rgba(255, 253, 248, 0.55);
  }
}

.cell {
  display: block;
  width: 100%;
  margin: 0;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  line-height: 1.5;
  outline: none;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}

.cell:focus {
  background: var(--field);
  border-color: var(--line);
  box-shadow: 0 0 0 2px rgba(180, 73, 47, 0.06);
}

.cell::placeholder {
  color: var(--faint);
}

textarea.cell-title {
  min-height: 44px;
  padding: 10px 6px;
  overflow: hidden;
  resize: none;
  overflow-wrap: break-word;
  word-break: break-word;
}

input.cell-person {
  height: 44px;
  padding: 10px 6px;
  color: #5f594c;
  text-overflow: ellipsis;
}

.done-cell {
  display: flex;
  align-items: flex-start;
  gap: 5px;
  min-height: 44px;
  padding: 11px 2px 0 5px;
}

.check {
  flex: 0 0 auto;
  width: 19px;
  height: 19px;
  margin: 1px 0 0;
  accent-color: var(--ok);
  cursor: pointer;
}

.del {
  flex: 0 0 auto;
  width: 18px;
  height: 20px;
  margin: 0 0 0 auto;
  padding: 0;
  border: 0;
  border-radius: 3px;
  background: none;
  color: #b6ae9d;
  font: inherit;
  font-size: 16px;
  line-height: 20px;
  cursor: pointer;
}

.del:hover {
  color: var(--accent);
  background: rgba(180, 73, 47, 0.08);
}

.del:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

tr.done .cell-title,
tr.done .cell-person {
  color: #a8a08f;
  text-decoration: line-through;
  text-decoration-color: #c6bdaa;
}

.state-row td {
  padding: 26px 4px;
  color: var(--muted);
  font-size: 13.5px;
}

/* Footer */

.foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 14px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 12px;
}

.sync {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.sync:hover {
  color: var(--ink);
}

.sync:disabled {
  cursor: default;
}

.sync:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.dot {
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
}

.dot.ok {
  background: var(--ok);
}

.dot.error {
  background: var(--accent);
}

.dot.syncing {
  background: var(--warn);
  animation: pulse 1.2s ease-in-out infinite;
}

.privacy {
  white-space: nowrap;
}

.noscript {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 18px 24px;
  color: var(--muted);
  font-size: 13.5px;
}

@keyframes pulse {
  0%, 100% {
    opacity: 0.35;
  }
  50% {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .dot.syncing {
    animation: none;
  }

  .add input,
  .btn,
  .cell {
    transition: none;
  }
}

@media (max-width: 540px) {
  .page {
    padding: 26px 14px calc(44px + env(safe-area-inset-bottom));
  }

  h1 {
    font-size: 23px;
  }

  .add {
    grid-template-columns: minmax(0, 1fr) 76px;
    gap: 8px;
    margin: 20px 0 24px;
  }

  .field-title {
    grid-column: 1 / -1;
  }

  .btn {
    padding: 0;
  }

  .board th {
    padding-right: 4px;
    padding-bottom: 7px;
  }

  .board th:first-child {
    padding-left: 1px;
  }

  .board th:last-child {
    padding-left: 4px;
  }

  textarea.cell-title,
  input.cell-person {
    padding-left: 4px;
    padding-right: 4px;
  }

  .done-cell {
    gap: 4px;
    padding-left: 4px;
    padding-right: 1px;
  }

  .del {
    width: 16px;
  }
}
