:root {
  --paper:      #F2EDE3;
  --paper-2:    #EAE3D5;
  --card:       #FBF8F1;
  --ink:        #26221C;
  --ink-soft:   #6B6558;
  --line:       #DAD1C0;

  --pipi:       #33569B;
  --mimi:       #8E4585;

  --stat-red:   #C6473B;
  --stat-amber: #DFA02E;
  --stat-green: #6F8F3C;
  --done:       #5FC13A;   /* bright green for completed, used translucent */

  --r-lg: 22px;
  --r-md: 16px;
  --shadow: 0 1px 0 #FFFCF5 inset, 0 2px 6px rgba(38,34,28,.08), 0 12px 28px -18px rgba(38,34,28,.4);
  --disp: "Zen Maru Gothic", system-ui, sans-serif;
  --body: "Zen Kaku Gothic New", system-ui, sans-serif;
}

* { box-sizing: border-box; }

/* hidden must beat class-level display rules (.sheet-backdrop, .view) */
[hidden] { display: none !important; }

html, body { margin: 0; }

body {
  font-family: var(--body);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 80% -10%, #F7F2E8, transparent 60%),
    radial-gradient(900px 500px at -10% 110%, #EFE7D8, transparent 55%),
    var(--paper);
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: env(safe-area-inset-bottom);
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px clamp(16px, 5vw, 40px) 8px;
  max-width: 780px;
  margin: 0 auto;
  flex-wrap: wrap;
}

.plate {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 16px 7px;
  border-radius: 14px;
  background: linear-gradient(180deg, var(--pipi), #2B4A88);
  color: #F4EFE4;
  box-shadow: 0 2px 0 rgba(255,255,255,.25) inset, 0 6px 16px -8px rgba(51,86,155,.9);
  line-height: 1;
}
.plate-num {
  font-family: var(--disp);
  font-weight: 900;
  font-size: 30px;
  letter-spacing: 2px;
}
.plate-sub {
  font-size: 10px;
  letter-spacing: .18em;
  text-transform: uppercase;
  opacity: .82;
  margin-top: 3px;
}

.tabs {
  display: inline-flex;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
  gap: 2px;
}
.tab {
  border: 0;
  background: transparent;
  font-family: var(--body);
  font-weight: 700;
  font-size: 14px;
  color: var(--ink-soft);
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: color .15s, background .15s;
}
.tab[aria-selected="true"] {
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(38,34,28,.12);
}

/* ---------- Layout ---------- */
main { max-width: 780px; margin: 0 auto; padding: 6px clamp(16px, 5vw, 40px) 60px; }
.view { animation: rise .28s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.block { margin-top: 8px; }
.block + .block { margin-top: 30px; }
.eyebrow {
  font-size: 12px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase;
  color: var(--ink-soft); margin: 0 0 4px;
}
.eyebrow-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.eyebrow-row .eyebrow { margin: 0; }

/* ---------- Date bar ---------- */
.datebar {
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  align-items: center;
  gap: 8px;
  margin: 14px 0 22px;
}
.step {
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--card);
  font-size: 24px;
  color: var(--ink);
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .12s;
}
.step:hover { transform: translateY(-1px); }
.step:disabled { opacity: .32; cursor: default; transform: none; box-shadow: none; }
.dateblock { text-align: center; line-height: 1.05; }
.dow { display: block; font-size: 13px; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-soft); }
.date { display: block; font-family: var(--disp); font-weight: 900; font-size: clamp(30px, 8vw, 42px); }
.tag {
  display: inline-block;
  margin-top: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--stat-green);
}
.tag:empty { display: none; }

/* ---------- Chore grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.chore {
  position: relative;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: var(--r-lg);
  padding: 16px 16px 14px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .12s, box-shadow .12s;
  min-height: 108px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
button.chore:hover { transform: translateY(-2px); }
button.chore:active { transform: translateY(0) scale(.99); }
.chore-name { font-weight: 700; font-size: 16px; line-height: 1.2; padding-right: 26px; }
.chore-add {
  position: absolute; top: 12px; right: 12px;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--ink); color: var(--paper);
  display: grid; place-items: center; font-size: 18px; font-weight: 700;
  line-height: 1;
}
.turn { margin-top: 12px; font-size: 12.5px; font-weight: 700; color: var(--ink-soft); }
.tallies { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 12px; min-height: 22px; }
.chip {
  font-size: 12px; font-weight: 700;
  padding: 3px 9px; border-radius: 999px;
  color: #fff; display: inline-flex; align-items: center; gap: 4px;
}
.chip.Pipi { background: var(--pipi); }
.chip.Mimi { background: var(--mimi); }

/* completed: bright green, almost transparent, not interactive */
.done {
  cursor: default;
  border-color: rgba(95, 193, 58, .55) !important;
  background: rgba(95, 193, 58, .13) !important;
  box-shadow: none;
}
.check, .check-i { color: var(--done); font-weight: 900; }
.chore.done .check {
  position: absolute; top: 12px; right: 14px; font-size: 18px;
}

/* ---------- Week ---------- */
.weekhead { display: flex; align-items: baseline; gap: 12px; margin: 16px 0 18px; }
.weekhead h2 { font-family: var(--disp); font-weight: 900; font-size: 26px; margin: 0; }
.weekrange { color: var(--ink-soft); font-size: 13px; }

.progress-list { display: flex; flex-direction: column; gap: 10px; }
.prow {
  display: block; width: 100%; text-align: left;
  font-family: var(--body); color: var(--ink);
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 14px 16px; box-shadow: var(--shadow);
  transition: transform .12s, box-shadow .12s;
}
button.prow { cursor: pointer; }
button.prow:hover { transform: translateY(-1px); }
button.prow:active { transform: none; }
.turn-msg { margin: 10px 0 0; font-size: 12.5px; color: var(--ink-soft); }
.turn-msg b { color: var(--ink); font-weight: 700; }
.prow-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.prow-name { font-weight: 700; font-size: 15px; }
.prow-name .wtag {
  font-size: 10px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-soft); margin-left: 8px; font-weight: 700;
}
.prow-count { font-family: var(--disp); font-weight: 900; font-size: 18px; white-space: nowrap; }
.prow-count small { color: var(--ink-soft); font-weight: 700; font-size: 13px; }
.bar { height: 10px; border-radius: 999px; background: var(--paper-2); margin: 10px 0 8px; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; transition: width .5s ease; }
.prow-people { display: flex; gap: 6px; flex-wrap: wrap; min-height: 20px; }
.done-check { color: var(--stat-green); font-weight: 700; }

/* ---------- Log ---------- */
.log-list { display: flex; flex-direction: column; gap: 20px; }
.log-day .log-date {
  font-family: var(--disp); font-weight: 700; font-size: 14px;
  color: var(--ink-soft); letter-spacing: .04em;
  padding-bottom: 8px; border-bottom: 1px solid var(--line); margin-bottom: 10px;
}
.log-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 4px;
}
.log-item .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.log-item .dot.Pipi { background: var(--pipi); }
.log-item .dot.Mimi { background: var(--mimi); }
.log-item .lname { font-weight: 600; flex: 1; }
.log-item .lwho { font-weight: 700; font-size: 13px; }
.log-item .lwho.Pipi { color: var(--pipi); }
.log-item .lwho.Mimi { color: var(--mimi); }
.log-item .ldel {
  border: 0; background: transparent; color: var(--ink-soft);
  cursor: pointer; font-size: 16px; padding: 4px 8px; border-radius: 8px;
}
.log-item .ldel:hover { background: var(--paper-2); color: var(--stat-red); }
.empty { color: var(--ink-soft); text-align: center; padding: 48px 0; }

/* ---------- Person picker sheet ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(38,34,28,.34);
  display: grid; place-items: end center;
  animation: fade .2s ease both;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  width: 100%; max-width: 460px;
  background: var(--card);
  border-radius: 26px 26px 0 0;
  padding: 22px 20px calc(24px + env(safe-area-inset-bottom));
  box-shadow: 0 -10px 40px -10px rgba(38,34,28,.5);
  animation: slideup .26s cubic-bezier(.2,.8,.2,1) both;
}
@media (min-width: 520px) {
  .sheet-backdrop { place-items: center; }
  .sheet { border-radius: 26px; margin-bottom: 0; }
}
@keyframes slideup { from { transform: translateY(100%); } to { transform: none; } }
.sheet-title { font-family: var(--disp); font-weight: 900; font-size: 20px; margin: 0 0 2px; text-align: center; }
.sheet-chore { text-align: center; color: var(--ink-soft); margin: 0 0 18px; font-size: 14px; }
.who { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stamp {
  border: 0; cursor: pointer; color: #fff;
  font-family: var(--disp); font-weight: 900; font-size: 22px;
  padding: 26px 0; border-radius: 18px; position: relative;
  transition: transform .12s;
}
.stamp:active { transform: scale(.96); }
.stamp[data-person="Pipi"] { background: var(--pipi); box-shadow: 0 8px 20px -10px var(--pipi); }
.stamp[data-person="Mimi"] { background: var(--mimi); box-shadow: 0 8px 20px -10px var(--mimi); }
.stamp.suggest { outline: 3px solid var(--ink); outline-offset: 3px; }
.stamp.suggest::after {
  content: "up next"; position: absolute; top: -10px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--paper);
  font-family: var(--body); font-weight: 700; font-size: 10px; letter-spacing: .08em;
  text-transform: uppercase; padding: 2px 8px; border-radius: 999px; white-space: nowrap;
}
.sheet-cancel {
  width: 100%; margin-top: 12px; padding: 14px; border-radius: 14px;
  border: 1px solid var(--line); background: transparent; color: var(--ink-soft);
  font-family: var(--body); font-weight: 700; font-size: 15px; cursor: pointer;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--ink); color: var(--paper);
  padding: 12px 20px; border-radius: 999px; z-index: 60;
  font-weight: 700; font-size: 14px; box-shadow: 0 12px 30px -12px rgba(0,0,0,.6);
  animation: pop .22s ease both;
}
@keyframes pop { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* stamp burst on log */
.burst { position: fixed; z-index: 70; pointer-events: none; font-family: var(--disp); font-weight: 900; }
@keyframes burstUp {
  0% { opacity: 0; transform: translate(-50%, 0) scale(.5); }
  30% { opacity: 1; transform: translate(-50%, -14px) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%, -46px) scale(1); }
}

:focus-visible { outline: 3px solid var(--pipi); outline-offset: 2px; border-radius: 6px; }

@media (max-width: 380px) {
  .grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
