:root {
  /* Theme colors. Each theme below overrides these. */
  --bg: #0d0f0e;
  --bg-glow: #1b211f;
  --bezel: #141716;
  --bezel-ring-1: #4fae8a;
  --bezel-ring-2: #2e7a5f;
  --tile: #1a1d1c;
  --tile-hi: #202423;
  --well: #151817;
  --field: #101312;
  --placeholder: #55605c;
  --line: rgba(255, 255, 255, 0.06);
  --text: #d7e3ee;
  --text-rgb: 215 227 238;
  --muted: #7d8a86;
  --panel-1: #2f6b4f;
  --panel-2: #1d3f30;
  --panel-border: var(--panel-border);
  --accent: #ff6a2b;
  --accent-rgb: 255 106 43;
  --accent-hi: #ff8a50;
  --glow-rgb: 255 140 80;
  --accent-pale: #ffd2b8;
  --tick-on: var(--tick-on);
  --on-accent: #1a0d06;
  --cat: #ffc76b;
  --cat-glow-rgb: 255 170 80;
  --sparkle: #fff1b8;
  --sparkle-glow: #f7c948;
  --radius: 18px;
}

/* Rose: deep berry panels, neon pink accent, champagne cat */
:root[data-theme="rose"] {
  --bg: #100b0e;
  --bg-glow: #26161f;
  --bezel: #181216;
  --bezel-ring-1: #f4a6c6;
  --bezel-ring-2: #c56b91;
  --tile: #1e181c;
  --tile-hi: #251e23;
  --well: #18131a;
  --field: #120e11;
  --placeholder: #6b5662;
  --text: #f6e6ee;
  --text-rgb: 246 230 238;
  --muted: #9a8290;
  --panel-1: #8a3a60;
  --panel-2: #4a1d36;
  --panel-border: rgba(255, 170, 210, 0.3);
  --accent: #ff5fa2;
  --accent-rgb: 255 95 162;
  --accent-hi: #ff86bb;
  --glow-rgb: 255 130 190;
  --accent-pale: #ffd3e6;
  --tick-on: rgba(255, 200, 225, 0.95);
  --on-accent: #2a0716;
  --cat: #ffd9b0;
  --cat-glow-rgb: 255 190 160;
  --sparkle: #fff0f6;
  --sparkle-glow: #ff9cc8;
}

/* Lavender: violet panels with an icy cyan accent (synthwave) */
:root[data-theme="lavender"] {
  --bg: #0d0c12;
  --bg-glow: #1d1a2c;
  --bezel: #15131c;
  --bezel-ring-1: #b9a6f2;
  --bezel-ring-2: #7d68c9;
  --tile: #1b1922;
  --tile-hi: #221f2b;
  --well: #16141d;
  --field: #110f16;
  --placeholder: #5f5a72;
  --text: #e8e4f8;
  --text-rgb: 232 228 248;
  --muted: #8a84a3;
  --panel-1: #5b4a9e;
  --panel-2: #2e2558;
  --panel-border: rgba(190, 170, 255, 0.3);
  --accent: #5ee0ff;
  --accent-rgb: 94 224 255;
  --accent-hi: #8eeaff;
  --glow-rgb: 120 220 255;
  --accent-pale: #d2f6ff;
  --tick-on: rgba(190, 240, 255, 0.95);
  --on-accent: #06222b;
  --cat: #e6dcff;
  --cat-glow-rgb: 190 160 255;
  --sparkle: #f4f0ff;
  --sparkle-glow: #b9a6f2;
}

/* Halloween: dusky purple panels, pumpkin accent, a two-tone pumpkin/purple
   border, and an eerie green cat at 100% */
:root[data-theme="halloween"] {
  --bg: #0c0910;
  --bg-glow: #221530;
  --bezel: #141018;
  --bezel-ring-1: #ff8a2b;
  --bezel-ring-2: #7d46c4;
  --tile: #1c1722;
  --tile-hi: #231c2a;
  --well: #17121c;
  --field: #110d15;
  --placeholder: #64587a;
  --text: #f1e7f7;
  --text-rgb: 241 231 247;
  --muted: #9488a6;
  --panel-1: #4e2a73;
  --panel-2: #251238;
  --panel-border: rgba(200, 150, 255, 0.28);
  --accent: #ff7a1a;
  --accent-rgb: 255 122 26;
  --accent-hi: #ff9a4a;
  --glow-rgb: 255 140 60;
  --accent-pale: #ffd9b8;
  --tick-on: rgba(255, 190, 130, 0.95);
  --on-accent: #2a1000;
  --cat: #b8f25e;
  --cat-glow-rgb: 160 240 80;
  --sparkle: #effcd9;
  --sparkle-glow: #b8f25e;
}

/* Christmas: cranberry panels, a pine green border and warm gold lights */
:root[data-theme="christmas"] {
  --bg: #0c0d0b;
  --bg-glow: #1f1414;
  --bezel: #131512;
  --bezel-ring-1: #3e9e6a;
  --bezel-ring-2: #1f5c3e;
  --tile: #1b1c1a;
  --tile-hi: #22231f;
  --well: #161714;
  --field: #10110f;
  --placeholder: #5c6158;
  --text: #f6efe4;
  --text-rgb: 246 239 228;
  --muted: #9a958a;
  --panel-1: #8a2533;
  --panel-2: #44101a;
  --panel-border: rgba(255, 170, 170, 0.26);
  --accent: #f3c04f;
  --accent-rgb: 243 192 79;
  --accent-hi: #ffd57a;
  --glow-rgb: 255 210 110;
  --accent-pale: #fff0c8;
  --tick-on: rgba(255, 225, 160, 0.95);
  --on-accent: #2a1d00;
  --cat: #fff3d6;
  --cat-glow-rgb: 255 220 150;
  --sparkle: #ffffff;
  --sparkle-glow: #f3c04f;
}

/* Ocean: deep navy-teal panels with a warm amber accent */
:root[data-theme="ocean"] {
  --bg: #0a0d11;
  --bg-glow: #142131;
  --bezel: #11161c;
  --bezel-ring-1: #6fb8e8;
  --bezel-ring-2: #3a78a8;
  --tile: #171c22;
  --tile-hi: #1d232a;
  --well: #13181d;
  --field: #0e1216;
  --placeholder: #4f5f6e;
  --text: #dde8f2;
  --text-rgb: 221 232 242;
  --muted: #7a8a99;
  --panel-1: #1f5680;
  --panel-2: #122c47;
  --panel-border: rgba(130, 200, 255, 0.28);
  --accent: #ffb03b;
  --accent-rgb: 255 176 59;
  --accent-hi: #ffc566;
  --glow-rgb: 255 190 90;
  --accent-pale: #ffe6bd;
  --tick-on: rgba(255, 215, 150, 0.95);
  --on-accent: #2a1800;
  --cat: #ffd27a;
  --cat-glow-rgb: 255 200 110;
  --sparkle: #fff6dc;
  --sparkle-glow: #ffc566;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: radial-gradient(ellipse at 30% 0%, var(--bg-glow) 0%, var(--bg) 60%);
  color: var(--text);
  font-family: "Michroma", system-ui, sans-serif;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}

.device {
  width: min(1040px, 100%);
  background: var(--bezel);
  border-radius: 28px;
  padding: 18px;
  /* the thick border itself is the .bezel-draw SVG (see transitions.js) */
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  gap: 14px;
}

.tile {
  background: linear-gradient(160deg, var(--tile-hi), var(--tile));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  position: relative;
}

.label {
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- chores ---------- */

.chores {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chores-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}

.chore-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.chore {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--well);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--muted);
  font: inherit;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-align: left;
  cursor: pointer;
  transition: background 0.35s, color 0.35s, border-color 0.35s, transform 0.12s;
}

.chore:hover { border-color: rgba(255, 255, 255, 0.14); color: var(--text); }
.chore:active { transform: scale(0.985); }
.chore:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.chore .dot {
  flex: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid currentColor;
  transition: background 0.35s, border-color 0.35s, box-shadow 0.35s;
}

.chore[aria-pressed="true"] {
  background: linear-gradient(120deg, var(--panel-1), var(--panel-2));
  border-color: var(--panel-border);
  color: var(--text);
}

.chore[aria-pressed="true"] .dot {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

/* ---------- score ---------- */

.score {
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 14px;
}

.ring-tile {
  background: linear-gradient(150deg, var(--panel-1) 0%, var(--panel-2) 100%);
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 420px;
}

.ring-tile .label { color: rgb(var(--text-rgb) / 0.75); }

.status-dot {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgb(var(--text-rgb) / 0.35);
}

.ring-wrap {
  position: relative;
  display: grid;
  place-items: center;
  padding: 12px 0;
}

.ring {
  width: min(320px, 70vw);
  height: auto;
  transform: rotate(-90deg);
  overflow: visible;
}

.ring .track { stroke: rgba(0, 0, 0, 0.25); }
.ring .arc {
  stroke: var(--accent);
  stroke-linecap: round;
  filter: drop-shadow(0 0 6px rgb(var(--accent-rgb) / 0.6));
}
.ring .tick { stroke: rgb(var(--text-rgb) / 0.18); }
.ring .tick.on { stroke: var(--tick-on); }

.readout {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
}

.pct {
  font-family: "Orbitron", "Michroma", sans-serif;
  font-weight: 900;
  font-size: clamp(40px, 7vw, 64px);
  line-height: 1;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.pct small { font-size: 0.4em; margin-left: 2px; }

.sub {
  margin-top: 10px;
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgb(var(--text-rgb) / 0.7);
}

.ring-foot {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgb(var(--text-rgb) / 0.7);
}

/* ---------- bottom meters ---------- */

.meters {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 14px;
}

.segbar {
  display: flex;
  gap: 3px;
  margin: 14px 0 10px;
  height: 18px;
}

.seg {
  flex: 1;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.05);
  transition: background 0.3s;
}

.seg.on { background: var(--accent); }

.meter-row {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.12em;
}

.big {
  font-family: "Orbitron", sans-serif;
  font-weight: 900;
  font-size: 30px;
  margin-top: 14px;
  letter-spacing: 0.06em;
}

.reset {
  margin-top: 10px;
  background: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font: inherit;
  font-size: 9px;
  letter-spacing: 0.18em;
  padding: 7px 10px;
  cursor: pointer;
}

.reset:hover { color: var(--text); border-color: rgba(255, 255, 255, 0.16); }

/* Shrink the whole device proportionally on larger screens */
@media (min-width: 761px) {
  .device { zoom: 0.73; }
}

@media (max-width: 760px) {
  .device { grid-template-columns: 1fr; }
  .score { order: -1; }
  .ring-tile { min-height: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---------- HISTORY / SET buttons (top right of page) ---------- */

.top-nav {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 10;
  display: flex;
  gap: 8px;
}

.set-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--tile);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.2em;
  text-decoration: none;
  transition: color 0.2s, border-color 0.2s;
}

.set-btn:hover { color: var(--text); border-color: rgba(255, 255, 255, 0.16); }
.set-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* three-line "menu" icon, like the SET key on the device */
.set-icon,
.set-icon::before,
.set-icon::after {
  display: block;
  width: 10px;
  height: 1.5px;
  background: currentColor;
  border-radius: 1px;
}
.set-icon { position: relative; }
.set-icon::before,
.set-icon::after { content: ""; position: absolute; left: 0; }
.set-icon::before { top: -3.5px; width: 7px; }
.set-icon::after { top: 3.5px; width: 8px; }

/* ---------- setup page ---------- */

.setup-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 460px;
}

.add-row {
  display: flex;
  gap: 8px;
}

.field {
  min-width: 0;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font: inherit;
  font-size: 11px;
  letter-spacing: 0.08em;
  padding: 12px 14px;
}

.field::placeholder { color: var(--placeholder); }
.field:focus { outline: none; border-color: var(--accent); }
.field.name-field { flex: 1; }

.btn {
  background: var(--accent);
  border: none;
  border-radius: 10px;
  color: var(--on-accent);
  font: inherit;
  font-size: 10px;
  letter-spacing: 0.18em;
  padding: 0 16px;
  cursor: pointer;
  transition: filter 0.2s, opacity 0.2s;
}

.btn:hover { filter: brightness(1.1); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; filter: none; }
.btn:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }

.btn.ghost {
  background: none;
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 10px 14px;
}
.btn.ghost:hover { color: var(--text); border-color: rgba(255, 255, 255, 0.16); }

/* Fixed height so adding/removing chores never resizes the page */
.my-list {
  list-style: none;
  margin: 0;
  padding: 0 4px 0 0;
  display: grid;
  align-content: start;
  gap: 6px;
  height: 380px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

.my-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 10px 10px 16px;
  background: linear-gradient(120deg, var(--panel-1), var(--panel-2));
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.my-item .name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.remove {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.2);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}
.remove:hover { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

.empty {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 18px 0;
  text-align: center;
}

.hint {
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  height: 14px;
  line-height: 14px;
}

.common-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--well);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  font: inherit;
  font-size: 9.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-align: left;
  cursor: pointer;
  transition: background 0.25s, color 0.25s, border-color 0.25s;
}

.chip .dot {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
}

.chip:hover { color: var(--text); border-color: rgba(255, 255, 255, 0.14); }
.chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.chip:disabled { opacity: 0.35; cursor: not-allowed; }

.chip[aria-pressed="true"] {
  background: linear-gradient(120deg, var(--panel-1), var(--panel-2));
  border-color: var(--panel-border);
  color: var(--text);
}
.chip[aria-pressed="true"] .dot {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

.setup-foot {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.setup-foot .btn:not(.ghost) { padding: 12px 18px; text-decoration: none; }

@media (max-width: 760px) {
  .setup-col { min-height: 0; }
  .my-list { height: 300px; }
  .common-grid { grid-template-columns: 1fr; }
}

/* ---------- 100% celebration ---------- */

.ring-tile {
  overflow: hidden;
  transition: box-shadow 0.8s, filter 0.8s;
}

.ring-tile::after {
  /* soft light that blooms across the tile on completion */
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(circle at 50% 48%, rgb(var(--glow-rgb) / 0.35), transparent 60%);
  opacity: 0;
  pointer-events: none;
}

.ring-tile.complete {
  box-shadow: 0 0 0 1px rgb(var(--glow-rgb) / 0.35), 0 0 40px rgb(var(--accent-rgb) / 0.18);
}

.ring-tile.celebrate::after { animation: bloom 1.6s ease-out; }

@keyframes bloom {
  0%   { opacity: 0; }
  15%  { opacity: 1; }
  100% { opacity: 0; }
}

.ring-tile.complete .status-dot {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: blink 1.6s ease-in-out infinite;
}

@keyframes blink {
  50% { opacity: 0.35; }
}

.burst {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

/* expanding rings that ripple off the score ring */
.waves {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.wave {
  grid-area: 1 / 1;
  width: calc(min(320px, 70vw) * 0.78);
  aspect-ratio: 1;
  border-radius: 50%;
  border: 2px solid rgb(var(--glow-rgb) / 0.8);
  opacity: 0;
  animation: wave 1.4s cubic-bezier(0.2, 0.7, 0.3, 1) forwards;
}

@keyframes wave {
  0%   { transform: scale(1);   opacity: 0.9; }
  100% { transform: scale(1.9); opacity: 0;   border-width: 0.5px; }
}

.ring .arc { transition: stroke 0.4s; }

.ring-tile.complete .arc {
  stroke: var(--accent-hi);
  animation: arcGlow 2.4s ease-in-out infinite;
}

@keyframes arcGlow {
  0%, 100% { filter: drop-shadow(0 0 6px rgb(var(--accent-rgb) / 0.6)); }
  50%      { filter: drop-shadow(0 0 14px rgb(var(--glow-rgb) / 0.95)); }
}

/* a bright highlight that chases around the tick marks */
.ring .tick.chase { animation: chase 0.9s ease-out; }

@keyframes chase {
  0%   { stroke: #fff; stroke-width: 3; }
  100% { stroke: var(--tick-on); }
}

.ring-tile.celebrate .pct { animation: pop 0.7s cubic-bezier(0.3, 1.6, 0.5, 1); }

@keyframes pop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.12); text-shadow: 0 0 24px rgb(var(--glow-rgb) / 0.8); }
  100% { transform: scale(1); }
}

.ring-tile.complete .sub {
  color: var(--accent-pale);
  animation: spread 0.9s ease-out;
}

@keyframes spread {
  from { letter-spacing: 0.05em; opacity: 0; }
  to   { letter-spacing: 0.2em;  opacity: 1; }
}

/* segments flash left to right */
.seg.sweep { animation: sweep 0.6s ease-out; }

@keyframes sweep {
  0%   { background: #fff; box-shadow: 0 0 8px var(--accent-pale); }
  100% { background: var(--accent); box-shadow: none; }
}

.done-pop { animation: pop 0.7s cubic-bezier(0.3, 1.6, 0.5, 1); transform-origin: left center; }

@media (prefers-reduced-motion: reduce) {
  .wave, .burst { display: none; }
  .ring-tile.complete .arc,
  .ring-tile.complete .status-dot,
  .ring-tile.celebrate::after { animation: none; }
}

/* Leave room for the fixed SET button on narrow screens */
@media (max-width: 760px) {
  body { padding-top: 64px; }
}

/* ---------- golden cat (appears at 100%) ---------- */

.cat-wrap {
  position: relative;
  justify-self: center;
  width: 76px;
  height: 0;
  opacity: 0;
  transition: height 0.5s cubic-bezier(0.3, 1.2, 0.5, 1), opacity 0.3s;
}

.ring-tile.complete .cat-wrap {
  height: 70px;
  margin-bottom: 4px;
  opacity: 1;
}

.cat {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 76px;
  height: 76px;
  overflow: visible;
  color: var(--cat);
  filter: drop-shadow(0 0 4px rgb(var(--cat-glow-rgb) / 0.9)) drop-shadow(0 0 12px rgb(var(--accent-rgb) / 0.45));
}

/* the silhouette fills in from the bottom up, like the ring filling */
.cat { clip-path: inset(100% -30% -30% -30%); }

.ring-tile.complete .cat {
  clip-path: inset(-30%);
  animation: fillUp 0.9s cubic-bezier(0.5, 0, 0.3, 1) 0.15s backwards;
}

@keyframes fillUp {
  from { clip-path: inset(100% -30% -30% -30%); }
  to   { clip-path: inset(-30%); }
}

.cat-bob { transform-box: view-box; }

.ring-tile.complete .cat-bob { animation: catBob 2.8s ease-in-out 0.9s infinite; }

@keyframes catBob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-3px); }
}


/* four-point twinkles around the cat */
.sparkle {
  position: absolute;
  width: 10px;
  height: 10px;
  background: var(--sparkle);
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
  filter: drop-shadow(0 0 4px var(--sparkle-glow));
  opacity: 0;
}

.sparkle.s1 { left: -14px; top: 4px; }
.sparkle.s2 { right: -16px; top: 18px; width: 8px; height: 8px; }
.sparkle.s3 { left: -6px; top: 52px; width: 7px; height: 7px; }
.sparkle.s4 { right: -8px; top: -8px; width: 12px; height: 12px; }

.ring-tile.complete .sparkle { animation: twinkle 1.8s ease-in-out infinite; }
.ring-tile.complete .sparkle.s2 { animation-delay: 0.45s; }
.ring-tile.complete .sparkle.s3 { animation-delay: 0.9s; }
.ring-tile.complete .sparkle.s4 { animation-delay: 1.35s; }

@keyframes twinkle {
  0%, 100% { transform: scale(0) rotate(0);     opacity: 0; }
  50%      { transform: scale(1) rotate(45deg); opacity: 1; }
}

/* little hearts that float up once when the cat arrives */
.heart {
  position: absolute;
  left: 50%;
  top: 20px;
  width: 10px;
  height: 10px;
  background: var(--accent);
  clip-path: path("M5 9.5 L1 5.5 A2.6 2.6 0 0 1 5 2 A2.6 2.6 0 0 1 9 5.5 Z");
  opacity: 0;
}

.heart.h1, .heart.h3 { background: var(--cat); }

.ring-tile.celebrate .heart { animation: floatUp 1.6s ease-out forwards; }
.ring-tile.celebrate .heart.h1 { --dx: -26px; animation-delay: 0.5s; }
.ring-tile.celebrate .heart.h2 { --dx: 4px;   animation-delay: 0.7s; }
.ring-tile.celebrate .heart.h3 { --dx: 28px;  animation-delay: 0.9s; }

@keyframes floatUp {
  0%   { transform: translate(-50%, 0) scale(0.4);                    opacity: 0; }
  20%  { opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx)), -46px) scale(1.2); opacity: 0; }
}

/* make room for the cat inside the ring */
.ring-tile.complete .pct { font-size: clamp(28px, 4.6vw, 40px); }
.ring-tile.complete .sub { margin-top: 6px; }
.pct { transition: font-size 0.5s; }

@media (prefers-reduced-motion: reduce) {
  .ring-tile.complete .cat { animation: none; }
  .ring-tile.complete .cat-bob,
  .ring-tile.complete .sparkle,
  .ring-tile.celebrate .heart { animation: none; }
  .ring-tile.complete .sparkle { opacity: 1; transform: scale(0.8); }
}

/* More room inside the ring on desktop, so a bigger cat */
@media (min-width: 761px) {
  .cat-wrap { width: 92px; }
  .ring-tile.complete .cat-wrap { height: 84px; }
  .cat { width: 92px; height: 92px; }
}

/* small clock icon for the HISTORY button */
.hist-icon {
  position: relative;
  width: 10px;
  height: 10px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
}
.hist-icon::before,
.hist-icon::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 50%;
  width: 1.5px;
  margin-left: -0.75px;
  background: currentColor;
  border-radius: 1px;
  transform-origin: bottom center;
}
.hist-icon::before { height: 3.5px; }
.hist-icon::after { height: 2.5px; transform: rotate(90deg); }

/* ---------- history page ---------- */

.history-list {
  list-style: none;
  margin: 0;
  padding: 0 4px 0 0;
  display: grid;
  align-content: start;
  gap: 6px;
  height: 440px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

.history-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: var(--well);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text);
}

.history-row .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1.5px solid var(--muted);
}

.history-row.today .dot {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

.history-row .name {
  display: flex;
  align-items: center;
  min-width: 0;
}

.history-row .name .txt {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-row .when {
  text-align: right;
  font-size: 9.5px;
  letter-spacing: 0.12em;
  color: var(--muted);
  line-height: 1.6;
}

.history-row .when b {
  display: block;
  font-weight: normal;
  color: var(--text);
}

.history-row.never { color: var(--muted); }

.history-row .tag {
  margin-left: 8px;
  font-size: 8px;
  letter-spacing: 0.16em;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 6px;
  flex: none;
}

.last-tile {
  background: linear-gradient(150deg, var(--panel-1) 0%, var(--panel-2) 100%);
  display: flex;
  flex-direction: column;
}

/* time sits at the bottom-left, like the device's clock tile */
.last-tile .last-name { margin-top: auto; padding-top: 18px; }

.last-tile .label { color: rgb(var(--text-rgb) / 0.75); }

.last-name {
  font-size: 14px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.last-time {
  margin-top: 10px;
  font-family: "Orbitron", sans-serif;
  font-weight: 900;
  font-size: 56px;
  line-height: 1.05;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}

.last-date {
  margin-top: 6px;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgb(var(--text-rgb) / 0.75);
}

.stat-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 760px) {
  .history-list { height: 320px; }
  .last-time { font-size: 36px; }
}

/* ---------- color switcher ---------- */

.theme-pill { gap: 2px; padding: 2px 6px 2px 12px; }
.theme-pill::after { display: none; }

/* The button is a fixed 24px hit area; the visible 14px circle is ::before,
   so hover/press can scale the circle without shrinking what you can click. */
.swatch {
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.swatch::before {
  content: "";
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-sizing: border-box;
  transition: box-shadow 0.2s, transform 0.15s;
}

.swatch.mint::before { background: linear-gradient(135deg, #4fae8a, #2f6b4f 55%, #ff6a2b 56%); }
.swatch.rose::before { background: linear-gradient(135deg, #f4a6c6, #8a3a60 55%, #ff5fa2 56%); }
.swatch.lavender::before { background: linear-gradient(135deg, #b9a6f2, #5b4a9e 55%, #5ee0ff 56%); }
.swatch.ocean::before { background: linear-gradient(135deg, #6fb8e8, #1f5680 55%, #ffb03b 56%); }
.swatch.halloween::before { background: linear-gradient(135deg, #ff8a2b, #4e2a73 55%, #b8f25e 56%); }
.swatch.christmas::before { background: linear-gradient(135deg, #3e9e6a, #8a2533 55%, #f3c04f 56%); }

.swatch:hover::before { transform: scale(1.12); }
.swatch:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.swatch[aria-checked="true"]::before { box-shadow: 0 0 0 2px var(--bezel), 0 0 0 3.5px var(--text); }

/* smooth fade when switching themes */
body, .device, .tile, .chore, .chip, .my-item, .history-row, .set-btn {
  transition: background 0.4s, color 0.4s, border-color 0.4s, box-shadow 0.4s, transform 0.12s;
}

/* ---------- page transitions (see transitions.js) ---------- */

.device { position: relative; }

/* Entrance: the device fades up out of a soft blur */
html.boot .device {
  animation: deviceIn 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
}

@keyframes deviceIn {
  from { opacity: 0; transform: scale(0.985); filter: blur(6px); }
  to   { opacity: 1; transform: none; filter: none; }
}

/* tiles rise in one after another */
html.boot .device .tile,
html.boot .setup-foot {
  animation: tileIn 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) var(--d, 0.15s) backwards;
}

@keyframes tileIn {
  from { opacity: 0; transform: translateY(10px) scale(0.985); filter: blur(2px); }
  to   { opacity: 1; transform: none; filter: none; }
}

/* rows and chips slide in, cascading down the list */
html.boot .chore-list li,
html.boot .my-list li,
html.boot .history-list li,
html.boot .common-grid .chip {
  animation: rowIn 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) var(--d, 0.3s) backwards;
}

@keyframes rowIn {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 1; transform: none; }
}

/* labels expand from tight letter-spacing, like text resolving on a screen */
html.boot .label {
  animation: labelIn 0.7s ease-out 0.25s backwards;
}

@keyframes labelIn {
  from { opacity: 0; letter-spacing: 0.35em; }
}

/* top buttons drop in */
html.boot .top-nav > * {
  animation: dropIn 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) var(--d, 0.4s) backwards;
}

@keyframes dropIn {
  from { opacity: 0; transform: translateY(-8px); }
}

/* Exit: the device eases back and fades out before the next page loads */
html.leaving .device {
  animation: deviceOut 0.28s cubic-bezier(0.4, 0, 1, 1) forwards;
}

@keyframes deviceOut {
  to { opacity: 0; transform: scale(0.985); filter: blur(4px); }
}

html.leaving .top-nav {
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.25s, transform 0.25s;
}

/* buttons feel physical when pressed (not the COLOR pill: it only holds the
   swatches, and shrinking it would slide them out from under the cursor) */
.set-btn:not(.theme-pill):active,
.btn:active,
.chip:active,
.reset:active { transform: scale(0.96); }
.swatch:active::before { transform: scale(0.85); }

/* A click only counts if press and release land on the same element, so a
   slightly larger invisible hit area keeps edge clicks working while the
   button is scaled down. */
.set-btn,
.btn,
.chip,
.reset { position: relative; }

.set-btn::after,
.btn::after,
.chip::after,
.reset::after {
  content: "";
  position: absolute;
  inset: -4px;
}

/* Let clicks pass through the color-reveal overlay to the real page */
::view-transition { pointer-events: none; }

/* Color switch: the new theme is revealed in a growing circle (transitions.js).
   Turn off the normal color fades so the new snapshot is already final. */
::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}

html.theme-switching *,
html.theme-switching *::before,
html.theme-switching *::after { transition: none !important; }

@media (prefers-reduced-motion: reduce) {
  html.boot *,
  html.boot *::after,
  html.leaving .device { animation: none !important; }
  html.leaving .device { opacity: 0; }
}

/* ---------- device border (transitions.js) ----------
   The thick border is an SVG drawn just outside the device, not box-shadow
   rings, so the same element that draws itself in on page open stays as the
   border afterwards. (Swapping to box-shadow at the end caused a 1px jump.) */

.bezel-draw {
  position: absolute;
  left: -8px;
  top: -8px;
  width: calc(100% + 16px);
  height: calc(100% + 16px);
  overflow: visible;
  pointer-events: none;
}

.bezel-draw path {
  fill: none;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
}

html.boot .bezel-draw path {
  animation: bezelDraw 1.1s cubic-bezier(0.45, 0, 0.25, 1) 0.15s backwards;
}

.bezel-draw .ring-inner { stroke: var(--bezel-ring-1); stroke-width: 6; }
.bezel-draw .ring-outer { stroke: var(--bezel-ring-2); stroke-width: 2; }

@keyframes bezelDraw {
  from { stroke-dashoffset: 1; }
}

/* ---------- top-right buttons: magnetic pull + traced border (nav.js) ---------- */

.top-nav > .set-btn {
  transform: translate(var(--mx, 0px), var(--my, 0px));
  transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), color 0.2s, border-color 0.2s, background 0.4s;
}

.top-nav > .set-btn:not(.theme-pill):active {
  transform: translate(var(--mx, 0px), var(--my, 0px)) scale(0.96);
}

/* (nav.js sets its exact position and size to cover the whole button) */
.btn-trace {
  position: absolute;
  left: 0;
  top: 0;
  overflow: visible;
  pointer-events: none;
}

.btn-trace path {
  fill: none;
  stroke: var(--text);
  stroke-width: 1;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  opacity: 0.85;
  transition: stroke-dashoffset 0.45s cubic-bezier(0.45, 0, 0.25, 1), stroke-width 0.15s, opacity 0.2s, filter 0.2s;
}

/* draws around on hover (or keyboard focus) and stays full while pressed */
.traced:hover .btn-trace path,
.traced:focus-visible .btn-trace path,
.traced:active .btn-trace path {
  stroke-dashoffset: 0;
}

.traced:active .btn-trace path {
  stroke-width: 1.6;
  opacity: 1;
  filter: drop-shadow(0 0 4px rgb(var(--text-rgb) / 0.7));
}

/* the traced line replaces the plain hover border */
.top-nav > .set-btn:hover { border-color: var(--line); }

/* ---------- mute switch ---------- */

.sound-btn {
  padding: 8px 10px;
  font: inherit;
  cursor: pointer;
}

.sound-icon {
  display: block;
  width: 15px;
  height: 13px;
  overflow: visible;
}

.sound-icon path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: opacity 0.2s, transform 0.2s;
  transform-box: fill-box;
  transform-origin: left center;
}

.sound-icon .speaker { fill: currentColor; fill-opacity: 0.25; }
.sound-icon .cross { opacity: 0; transform: scale(0.4); transform-origin: center; }

/* muted: the sound waves fold away and a small cross appears */
.sound-btn[aria-pressed="true"] .waves { opacity: 0; transform: scaleX(0.3); }
.sound-btn[aria-pressed="true"] .cross { opacity: 1; transform: scale(1); }
.sound-btn[aria-pressed="true"] { color: var(--accent); }

/* ---------- headline + peeking cat (main page) ---------- */

/* "safe": if the page is taller than the screen, start at the top instead of
   overflowing off it where you can't scroll */
body { align-content: safe center; row-gap: 14px; }

.stage {
  position: relative;
  width: 100%;
  display: grid;
  justify-items: center;
  /* room for the cat above the device: enough to show him down to his
     mouth, with his chin tucked behind the border */
  padding-top: 100px;
}

.stage .device { z-index: 1; }

/* the cat sits behind the device, so its top edge hides his chin */
.peek {
  position: absolute;
  left: 50%;
  top: 0;
  width: 120px;
  height: 108px;
  margin-left: -60px;
  z-index: 0;
  pointer-events: none;
}

.peek-cat {
  position: absolute;
  left: 0;
  top: 0;
  width: 120px;
  height: 108px;
  overflow: visible;
  filter: drop-shadow(0 6px 14px rgb(0 0 0 / 0.35));
  /* hidden behind the border until he has something to say (catSay).
     Also invisible while down: during page transitions the device fades
     and blurs, which would otherwise show him waiting behind it. */
  transform: translateY(100%);
  visibility: hidden;
  transition: transform 0.4s cubic-bezier(0.5, 0, 0.75, 0), visibility 0s 0.4s;
}

.peek.up .peek-cat {
  transform: none;
  visibility: visible;
  transition: transform 0.6s cubic-bezier(0.3, 1.4, 0.5, 1), visibility 0s;
}

/* and he leaves with the page if it changes while he's talking */
html.leaving .peek,
html.leaving .bubble {
  opacity: 0;
  transition: opacity 0.2s;
}

.peek-cat .head {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  transform: rotate(var(--tilt, 0deg));
  transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.peek-cat .face {
  transform: translate(var(--fx, 0px), var(--fy, 0px));
  transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Two cats share one drawing, in the flat emoji style:
   blue  = Russian blue with the smirk (says hello)
   flame = flame point Balinese: cream fur with orange "points" (ears and
           markings), happier eyes and mouth (says "Nice work!") */
.peek[data-cat="blue"] {
  --fur: #8a9db3;
  --ear-in: #6e8197;
  --muzzle: #a9b9cb;
  --marks: #74879e;
  --nose: #2b303b;
  --whisker: #4a5465;
}

.peek[data-cat="flame"] {
  --fur: #f7efe4;
  --ear-out: #e8915a;
  --ear-in: #f6bf93;
  --muzzle: #fffaf4;
  --marks: #e8915a;
  --nose: #d9735f;
  --whisker: #c4ab97;
  --features: #d4703c;
}

.peek-cat .fur { fill: var(--fur); }
.peek-cat .ear-out { fill: var(--ear-out, var(--fur)); }
.peek-cat .ear-in { fill: var(--ear-in); }
.peek-cat .muzzle { fill: var(--muzzle); }
.peek-cat .marks path { fill: none; stroke: var(--marks); stroke-width: 6; stroke-linecap: round; }
.peek-cat .eyes path { fill: #232833; }
/* the flame point's eyes: smiling "^ ^" arcs */
.peek-cat .eyes .arc { fill: none; stroke: var(--features, #232833); stroke-width: 6.5; stroke-linecap: round; }
/* each eye (with its sparkle) blinks as one piece */
.peek-cat .eyes > * { transform-box: fill-box; transform-origin: center; transition: transform 0.12s; }
.peek-cat .nose { fill: var(--nose); }
.peek-cat .mouth { fill: none; stroke: var(--features, #2b303b); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.peek-cat .whiskers path { fill: none; stroke: var(--whisker); stroke-width: 4; stroke-linecap: round; }

/* the flame point swaps in closed, smiling eyes and a smile */
.peek-cat .mouth-happy,
.peek-cat .eyes-happy,
.peek[data-cat="flame"] .mouth-smirk,
.peek[data-cat="flame"] .eyes-smug { display: none; }
.peek[data-cat="flame"] .mouth-happy,
.peek[data-cat="flame"] .eyes-happy { display: inline; }

.peek.blink .eyes > * { transform: scaleY(0.12); }
/* his eyes are already closed, so he doesn't blink */
.peek[data-cat="flame"].blink .eyes > * { transform: none; }

.peek-cat .ear { transform-box: fill-box; }
.peek-cat .ear-r { transform-origin: 30% 90%; }
.peek.twitch .ear-r { animation: earTwitch 0.18s ease-in-out 2 alternate; }

@keyframes earTwitch { to { transform: rotate(10deg); } }

/* little pixel squares floating around him, like GitHub's hero */
.pix {
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 1px;
  opacity: 0;
  transform: scale(0);
  transition: opacity 0.3s, transform 0.3s;
  animation: pixFloat 3.2s ease-in-out infinite alternate;
}

/* they pop in around him while he's up */
.peek.up .pix {
  opacity: 0.9;
  transform: none;
  transition: opacity 0.4s 0.3s, transform 0.4s cubic-bezier(0.3, 1.6, 0.5, 1) 0.3s;
}

.pix.p1 { left: -34px; top: 26px; background: var(--accent); }
.pix.p2 { left: -16px; top: 54px; background: var(--bezel-ring-1); width: 5px; height: 5px; animation-delay: 0.4s; }
.pix.p3 { right: -30px; top: 12px; background: var(--bezel-ring-1); animation-delay: 0.8s; }
.pix.p4 { right: -44px; top: 46px; background: var(--accent); width: 5px; height: 5px; animation-delay: 1.2s; }
.pix.p5 { right: -14px; top: 66px; background: var(--text); width: 4px; height: 4px; animation-delay: 1.6s; }

@keyframes pixFloat {
  to { translate: 0 -6px; }
}

@media (max-width: 760px) {
  .stage { padding-top: 81px; }
  .peek, .peek-cat { width: 96px; height: 86px; }
  .peek { margin-left: -48px; }
}

/* ---------- iMessage-style speech bubble ---------- */

.bubble {
  position: absolute;
  /* to the right of the cat, its bottom at his cheek, growing upward */
  left: calc(50% + 50px);
  top: 58px;
  z-index: 2;
  max-width: min(240px, calc(50vw - 66px));
  padding: 8px 13px;
  border-radius: 18px;
  /* the grey-white "received" bubble: it's the cat talking to you */
  background: #e9e9eb;
  color: #000;
  font: 15px/1.3 -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  letter-spacing: 0;
  pointer-events: none;
  transform-origin: 0 100%;
  translate: 0 -100%;
  opacity: 0;
  transform: scale(0.4);
  transition: opacity 0.2s, transform 0.2s;
}

.bubble.show {
  opacity: 1;
  transform: none;
  transition: opacity 0.2s, transform 0.4s cubic-bezier(0.3, 1.5, 0.5, 1);
}

/* floats up and fades away */
.bubble.out {
  opacity: 0;
  transform: translateY(-10px) scale(0.9);
  transition: opacity 0.35s ease-in, transform 0.35s ease-in;
}

/* The tail starts inside the bubble and reaches past its rounded corner to
   where the bottom edge is straight, so the two shapes join with no notch. */
.bubble .tail {
  position: absolute;
  left: -6px;
  bottom: 0;
  width: 28px;
  height: 22px;
}

.bubble .tail path { fill: #e9e9eb; }

/* text and dots sit above the tail, which overlaps the bubble's corner */
.bubble .msg,
.bubble .typing { position: relative; z-index: 1; }

/* typing indicator: three dots that bounce in turn */
.bubble .typing { display: none; gap: 4px; padding: 4px 2px; }
.bubble.typing .typing { display: flex; }

.bubble .typing i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #8e8e93;
  animation: dot 1s ease-in-out infinite;
}

.bubble .typing i:nth-child(2) { animation-delay: 0.15s; }
.bubble .typing i:nth-child(3) { animation-delay: 0.3s; }

@keyframes dot {
  0%, 60%, 100% { transform: none; opacity: 0.55; }
  30%           { transform: translateY(-3px); opacity: 1; }
}

.bubble .msg { display: none; }
.bubble.text .msg { display: inline; }
.bubble.text { animation: msgPop 0.3s cubic-bezier(0.3, 1.5, 0.5, 1); }

@keyframes msgPop { from { transform: scale(0.92); } }

@media (max-width: 760px) {
  .bubble { left: calc(50% + 40px); top: 46px; font-size: 14px; }
  /* the bubble wraps onto more lines here, so leave room under the menu */
  .stage { margin-top: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  .peek-cat, .pix, .bubble, .bubble .typing i { animation: none !important; transition: none !important; }
}

/* narrow phones: tighter top menu so all four buttons fit */
@media (max-width: 480px) {
  .top-nav { right: 8px; gap: 6px; }
  .swatch { width: 20px; }
  .theme-pill .pill-label,
  .top-nav .nav-label { display: none; }
  .theme-pill { padding-left: 4px; }
}
