*, *::before, *::after {
  box-sizing: border-box;
  border-radius: 0 !important;
}

:root {
  --bg: #f3f1e8;
  --ink: #1d2318;
  --mute: #5d6655;
  --line: #1d2318;
  --green: #2f6b27;
  --card: #ffffff;
  --red: #c7261b;
  --orange: #d9730d;
  --grey: #8a8f85;
}

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  font-size: 16px;
  line-height: 1.45;
  padding-bottom: env(safe-area-inset-bottom);
}

button, input, select { font: inherit; color: inherit; }

.top {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--green);
  color: #fff;
  padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
}
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.top h1 { margin: 0; font-size: 22px; letter-spacing: 1px; }

.filters { display: flex; gap: 6px; overflow-x: auto; margin-top: 10px; padding-bottom: 2px; }
.chip-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 4px 12px;
  background: #fff;
  color: var(--ink);
  border: 2px solid #fff;
  cursor: pointer;
}
.chip-btn[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: #fff; }

main { padding: 12px; max-width: 640px; margin: 0 auto; }

.btn {
  min-height: 44px;
  padding: 8px 14px;
  background: #fff;
  border: 2px solid var(--line);
  cursor: pointer;
  font-weight: 600;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn:active { background: #e4e1d2; }
.btn.primary { background: var(--ink); color: #fff; }
.btn.danger { color: var(--red); border-color: var(--red); }
.top .btn.primary { background: #fff; color: var(--ink); border-color: #fff; }

.link { background: none; border: 0; padding: 8px 0; text-decoration: underline; cursor: pointer; color: var(--green); }

.notice { background: #fff8d6; border: 2px solid var(--line); padding: 10px 12px; margin-bottom: 12px; }
.notice p { margin: 0 0 8px; }
.notice-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.small { font-size: 13px; color: var(--mute); margin: 6px 0 0; }

.summary { margin: 0 0 10px; font-weight: 600; }
.empty { text-align: center; color: var(--mute); padding: 24px 0; }

.list { display: flex; flex-direction: column; gap: 14px; }

.card {
  background: var(--card);
  border: 2px solid var(--line);
  border-left-width: 10px;
  border-left-color: var(--green);
}
.card.u6 { border-left-color: var(--orange); }
.card.u1 { border-left-color: var(--red); }
.card.done { border-left-color: var(--grey); }
.card.done .photo, .card.done .count { filter: grayscale(1); opacity: .75; }

.photo { display: block; width: 100%; aspect-ratio: 800 / 475; object-fit: cover; background: #cfd6c4; border-bottom: 2px solid var(--line); }
.photo-none {
  width: 100%;
  aspect-ratio: 800 / 475;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 18px;
  border-bottom: 2px solid var(--line);
}

.card-body { padding: 10px 12px 12px; }
.place { margin: 0; font-size: 19px; font-weight: 700; word-break: break-word; }
.mtype { display: flex; align-items: center; gap: 8px; margin-top: 4px; color: var(--mute); }
.swatch { width: 16px; height: 16px; border: 1px solid var(--line); flex: 0 0 auto; }

.count {
  margin: 8px 0 2px;
  font-size: clamp(34px, 11.5vw, 56px);
  font-weight: 800;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
}
.card.u6 .count { color: var(--orange); }
.card.u1 .count { color: var(--red); }
.card.u1:not(.done) .count { animation: pulse 1.2s steps(2, jump-none) infinite; }
@keyframes pulse { 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) { .card.u1 .count { animation: none !important; } }

.tag { display: inline-block; padding: 1px 8px; font-size: 13px; font-weight: 700; color: #fff; background: var(--green); vertical-align: middle; margin-left: 6px; letter-spacing: 0; }
.card.u6 .tag { background: var(--orange); }
.card.u1 .tag { background: var(--red); }
.card.done .tag { background: var(--grey); }

.endat { margin: 0; font-size: 16px; font-weight: 600; }
.stats { margin: 4px 0 0; color: var(--mute); font-size: 14px; }

.members { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.person {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px 3px 4px;
  border: 2px solid var(--pc);
  background: #fff;
  font-weight: 600;
  font-size: 15px;
}
.av {
  position: relative;
  width: 24px; height: 24px; flex: 0 0 auto;
  background: linear-gradient(to bottom, var(--hair) 0 52%, #f6d3b0 52% 100%);
  border: 1px solid rgba(0, 0, 0, .45);
}
.av.sun::after { content: ""; position: absolute; left: 2px; right: 2px; top: 10px; height: 6px; background: #8b3fd6; }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.actions .wide { grid-column: 1 / -1; }

.foot { max-width: 640px; margin: 8px auto 0; padding: 12px 12px 40px; display: flex; flex-direction: column; align-items: flex-start; }

.sheet { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, .55); overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sheet[hidden] { display: none; }
.sheet-body {
  background: var(--bg);
  max-width: 560px;
  margin: 0 auto;
  min-height: 100%;
  padding: calc(14px + env(safe-area-inset-top)) 14px calc(24px + env(safe-area-inset-bottom));
  border-left: 2px solid var(--line);
  border-right: 2px solid var(--line);
}
.sheet-body h2 { margin: 0 0 12px; font-size: 21px; }

.field { display: block; border: 0; padding: 0; margin: 0 0 14px; min-width: 0; }
.field > span, .field > legend { display: block; font-weight: 700; margin-bottom: 6px; padding: 0; }
.field input[type="text"], .field input[type="number"], .field input[type="datetime-local"], .field select, #mode-abs input {
  width: 100%; min-height: 46px; padding: 8px 10px; background: #fff; border: 2px solid var(--line);
}
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.member-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.member-pick label { cursor: pointer; }
.member-pick input { position: absolute; opacity: 0; pointer-events: none; }
.member-pick .person { min-height: 46px; padding-right: 14px; opacity: .55; }
.member-pick input:checked + .person { opacity: 1; background: color-mix(in srgb, var(--pc) 22%, #fff); box-shadow: inset 0 0 0 2px var(--pc); }
.member-pick input:focus-visible + .person { outline: 3px solid var(--ink); outline-offset: 2px; }

.seg { display: grid; grid-template-columns: 1fr 1fr; margin-bottom: 10px; }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: flex; align-items: center; justify-content: center; min-height: 44px; border: 2px solid var(--line); background: #fff; font-weight: 600; margin: 0; }
.seg label + label span { border-left: 0; }
.seg input:checked + span { background: var(--ink); color: #fff; }

.rel-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.rel-grid label { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.rel-grid input { text-align: center; }
.rel-grid span { font-size: 14px; color: var(--mute); }

.preview { display: block; width: 100%; aspect-ratio: 800 / 475; object-fit: cover; border: 2px solid var(--line); margin-bottom: 8px; }
.preview[hidden] { display: none; }
.photo-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.error { color: var(--red); font-weight: 700; margin: 0 0 10px; }
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; position: sticky; bottom: 0; padding: 10px 0; background: var(--bg); }
