:root {
  --bg: #f3efe6;
  --ink: #1f1a16;
  --muted: #6d6258;
  --line: #e0d6c8;
  --accent: #a33b24;
  --serif: "Iowan Old Style", "Palatino Linotype", "Songti SC", "SimSun", serif;
  --sans: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 36px 28px 96px;
}

.top {
  margin: 0 -28px 32px;
  padding: 0 28px 22px;
  border-bottom: 1px solid var(--ink);
}

.mark {
  margin: 0 0 6px;
  font-size: 13px;
  letter-spacing: 0.12em;
  color: var(--muted);
}

h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(44px, 7vw, 68px);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 0.95;
}

.lead {
  max-width: 36em;
  margin: 12px 0 0;
  color: var(--muted);
}

.setup {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 22px 28px;
  align-items: end;
}

.field span,
.mini-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 13px;
}

.field input,
.field select {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--ink);
  border-radius: 0;
  background: transparent;
  padding: 4px 0 6px;
  font-family: var(--serif);
  font-size: 28px;
  line-height: 1.2;
}

.field input[type="date"] {
  font-family: var(--sans);
  font-size: 18px;
}

input[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 28px;
  margin-top: 18px;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.check input { accent-color: var(--accent); }

#lv1-field { display: none; }
#lv1-field.show { display: block; }

.answer { margin-top: 36px; }

.need {
  margin: 0;
  font-size: 18px;
}

.days {
  margin: 4px 0 0;
  font-family: var(--serif);
  font-size: clamp(64px, 12vw, 112px);
  font-weight: 600;
  letter-spacing: -0.045em;
  line-height: 0.88;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.days.tick { animation: rise 220ms ease-out; }

@keyframes rise {
  from { transform: translateY(8px); opacity: 0.35; }
  to { transform: none; opacity: 1; }
}

.when,
.meta,
.stats,
.notes p {
  margin: 8px 0 0;
}

.when { font-size: 18px; }

.meta,
.notes p { color: var(--muted); max-width: 42em; }

.notes p.block { color: var(--accent); }

.stats { max-width: 42em; }

.plan-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 24px;
  margin-top: 48px;
}

h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.presets { display: flex; gap: 18px; }

.presets button {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.presets button:hover,
.presets button:focus-visible { color: var(--accent); }

.fine {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  max-width: 46em;
}

.scroll-hint { display: none; }

.sheet {
  margin-top: 18px;
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 880px;
  font-variant-numeric: tabular-nums;
}

th,
td {
  padding: 10px 8px;
  text-align: center;
  vertical-align: middle;
  border-bottom: 1px solid var(--line);
  font-weight: 400;
}

thead th {
  border-bottom: 1px solid var(--ink);
  font-weight: 600;
  font-size: 14px;
}

.name-col,
th.name-col {
  position: sticky;
  left: 0;
  z-index: 1;
  text-align: left;
  min-width: 148px;
  background: var(--bg);
}

.alias {
  display: block;
  font-weight: 600;
}

.boss-name,
.pending,
.per {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.spent {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.loc {
  display: inline-block;
  margin-top: 4px;
  font-size: 13px;
  color: var(--muted);
}

.loc[aria-pressed="true"] { color: var(--accent); }

th.is-start .dow-name::after {
  content: "起";
  margin-left: 4px;
  color: var(--accent);
  font-size: 12px;
}

.in-town { background: rgba(163, 59, 36, 0.06); transition: background 160ms ease; }

.stepper {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.stepper button {
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  line-height: 1;
}

.stepper button:hover { border-color: var(--ink); }

.stepper button:active { transform: translateY(1px); }

.stepper button:disabled {
  opacity: 0.35;
  cursor: default;
}

.stepper b {
  min-width: 1ch;
  font-weight: 600;
}

input.mini {
  width: 3.2em;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: right;
  padding: 0 0 2px;
  font-variant-numeric: tabular-nums;
}

input.mini:focus { border-bottom-color: var(--accent); }

tfoot td {
  border-bottom: 0;
  border-top: 1px solid var(--ink);
  font-weight: 600;
}

.foot-label { text-align: left; }

#log-wrap { margin-top: 22px; }

summary { cursor: pointer; }

.log-line {
  display: grid;
  grid-template-columns: 11em 3em 4em 1fr;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}

.log-line span:last-child { color: var(--muted); }

.block-title { margin: 52px 0 12px; }

.steps,
.chart {
  width: 100%;
  min-width: 0;
}

.steps td,
.chart td,
.steps th,
.chart th { text-align: right; }

.steps td:first-child,
.chart td:first-child,
.steps th:first-child,
.chart th:first-child { text-align: left; }

.chart { min-width: 640px; }

.gate td {
  text-align: left;
  color: var(--accent);
  font-size: 14px;
}

.footnotes {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 14px;
}

.footnotes li { margin: 6px 0; }

#reset-data {
  margin-top: 8px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

#reset-data:hover { color: var(--accent); }

@media (max-width: 900px) {
  .wrap { padding: 24px 16px 72px; }
  .top { margin-left: -16px; margin-right: -16px; padding-left: 16px; padding-right: 16px; }
  .setup { grid-template-columns: 1fr 1fr; }
  .scroll-hint { display: block; }
  .log-line { grid-template-columns: 1fr 3em 3em; }
  .log-line span:last-child { grid-column: 1 / -1; }
}

@media (max-width: 560px) {
  .setup { grid-template-columns: 1fr; }
  .stepper button { width: 36px; height: 36px; }
}

@media (prefers-reduced-motion: reduce) {
  .days.tick { animation: none; }
  .in-town { transition: none; }
  html { scroll-behavior: auto; }
}
