:root {
  color-scheme: light;
  --paper: #F3F0E4;
  --surface: #FBF9F2;
  --ink: #22302D;
  --muted: #5F6F69;
  --teal: #2F7F7A;
  --teal-soft: #D5E8E4;
  --fern: #5E8C3A;
  --gold: #B88F2E;
  --gold-soft: #F1E4BE;
  --line: #DCD6C4;
  --radius-stone: 14px 18px 16px 12px;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #13211F;
    --surface: #1B2D2A;
    --ink: #E9E6DA;
    --muted: #A3B2AC;
    --teal: #6CC3BA;
    --teal-soft: #234440;
    --fern: #9CC46E;
    --gold: #E2C16E;
    --gold-soft: #3A3420;
    --line: #2E4440;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #13211F; --surface: #1B2D2A; --ink: #E9E6DA; --muted: #A3B2AC;
  --teal: #6CC3BA; --teal-soft: #234440; --fern: #9CC46E; --gold: #E2C16E;
  --gold-soft: #3A3420; --line: #2E4440;
}

*, *::before, *::after { box-sizing: inherit; }
html { height: 100%; scroll-padding-top: env(safe-area-inset-top, 0px); }
body {
  margin: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font: 17px/1.55 "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
  padding-bottom: 150px;
}
h1, h2, h3, .brand, .add-button, .tabs button {
  font-family: "Fredoka", "Atkinson Hyperlegible", system-ui, sans-serif;
  font-weight: 600;
}
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }

.skip { position: absolute; left: -999px; }
.skip:focus { left: 12px; top: 12px; background: var(--surface); padding: 6px 10px; z-index: 20; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.top, main { max-width: 620px; margin: 0 auto; padding: 0 20px; }
.top { display: flex; align-items: baseline; justify-content: space-between; padding-top: 18px; }
.brand { margin: 0; font-size: 1.6rem; color: var(--teal); letter-spacing: .01em; }
.pebbles { margin: 0; color: var(--muted); display: flex; align-items: center; gap: 8px; }
#pebble-count { color: var(--ink); font-weight: 700; }
.pebble-dot { width: 14px; height: 11px; border-radius: 60% 50% 55% 45%; background: var(--gold); display: inline-block; }

.view-title { font-size: 2.4rem; line-height: 1.1; margin: 22px 0 2px; }
.date-line { margin: 0; color: var(--muted); }
h3 { font-size: 1.15rem; margin: 28px 0 8px; }

/* The current: the one bold element */
.current { margin: 14px 0 4px; height: 40px; }
.current svg { width: 100%; height: 40px; display: block; overflow: visible; }
.current-bed { fill: none; stroke: var(--teal-soft); stroke-width: 10; stroke-linecap: round; }
.current-flow {
  fill: none; stroke: var(--teal); stroke-width: 10; stroke-linecap: round;
  stroke-dasharray: 100; stroke-dashoffset: 100;
  transition: stroke-dashoffset .9s cubic-bezier(.3,.7,.3,1);
}
.river-says { margin: 6px 0 0; font-size: 1.05rem; }

.slot h3 { display: flex; justify-content: space-between; align-items: baseline; }
.slot h3 small { font-family: "Atkinson Hyperlegible", sans-serif; font-weight: 400; font-size: .9rem; color: var(--muted); }
.stones { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.stone {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-stone);
  padding: 10px 12px;
}
.stone:nth-child(2n) { border-radius: 18px 12px 14px 17px; }
.stone .check {
  flex: none; width: 34px; height: 30px; border-radius: 55% 45% 50% 50%;
  border: 2px solid var(--teal); background: transparent; cursor: pointer;
  display: grid; place-items: center; padding: 0;
}
.stone.done .check { background: var(--teal); border-color: var(--teal); }
.stone.done .check::after { content: ""; width: 10px; height: 6px; border: solid var(--surface); border-width: 0 0 3px 3px; transform: rotate(-45deg) translate(1px,-1px); }
.stone .text { flex: 1; min-width: 0; }
.stone .title { display: block; overflow-wrap: anywhere; }
.stone.done .title { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--teal); }
.stone .meta { font-size: .85rem; color: var(--muted); }
.stone .meta .area { color: var(--fern); }
.stone .remove { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 6px 8px; border-radius: 8px; }
.stone .remove:hover { color: var(--ink); }
.empty { color: var(--muted); margin: 4px 0; }

.carry { margin-top: 18px; padding: 12px 14px; border: 1px dashed var(--line); border-radius: 14px; }
.carry p { margin: 0 0 8px; }
.carry .stones { gap: 6px; }

.week-nav { display: flex; align-items: center; gap: 8px; }
.week-nav .date-line { flex: 1; text-align: center; }
.week-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin: 14px 0 6px; }
.day {
  border: 1px solid var(--line); background: var(--surface); border-radius: 12px;
  padding: 8px 0 10px; cursor: pointer; display: grid; justify-items: center; gap: 2px;
}
.day .dow { font-size: .8rem; color: var(--muted); }
.day .num { font-family: "Fredoka", sans-serif; font-weight: 600; font-size: 1.2rem; }
.day .dot { width: 7px; height: 7px; border-radius: 50%; background: transparent; }
.day.has-open .dot { background: var(--teal); }
.day.today .num { color: var(--teal); }
.day[aria-selected="true"] { border-color: var(--teal); box-shadow: inset 0 0 0 1px var(--teal); }

.plain-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.plain-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.plain-list .cost { color: var(--muted); font-size: .9rem; }
.inline-form { display: flex; gap: 8px; margin-top: 10px; }
.inline-form input { flex: 1; min-width: 0; }
.inline-form .num { flex: 0 0 72px; }

input, select {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 11px; width: 100%;
}
button {
  background: var(--teal); color: var(--surface); border: 0; border-radius: 12px;
  padding: 9px 16px; cursor: pointer; font-weight: 700;
}
button:disabled { opacity: .45; cursor: not-allowed; }
button.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); font-weight: 400; }
button.small { padding: 5px 12px; font-size: .9rem; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row.end { justify-content: flex-end; margin-top: 18px; }
.quiet { color: var(--muted); margin: 0 0 10px; }

.marks { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.mark { padding: 10px 12px; border-radius: 14px; border: 1px solid var(--line); color: var(--muted); font-size: .92rem; }
.mark strong { display: block; color: var(--muted); font-weight: 700; }
.mark.earned { background: var(--gold-soft); border-color: var(--gold); color: var(--ink); }
.mark.earned strong { color: var(--ink); }

.add-button {
  position: fixed; right: max(18px, calc(50% - 300px)); bottom: calc(78px + env(safe-area-inset-bottom, 0px));
  padding: 13px 20px; border-radius: 22px 18px 24px 16px; font-size: 1.05rem; z-index: 5;
  box-shadow: 0 6px 18px -8px rgba(20, 60, 55, .55);
}
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: flex; justify-content: center; gap: 4px;
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px));
}
.tabs button { background: transparent; color: var(--muted); flex: 1; max-width: 180px; font-weight: 500; font-size: 1.05rem; }
.tabs button[aria-current="page"] { color: var(--teal); background: var(--teal-soft); }

dialog {
  border: 1px solid var(--line); border-radius: 20px; background: var(--surface); color: var(--ink);
  width: min(520px, calc(100% - 28px)); padding: 22px;
}
dialog::backdrop { background: rgba(10, 30, 28, .45); }
dialog h2 { margin: 0 0 14px; font-size: 1.5rem; }
dialog label { display: block; font-size: .9rem; color: var(--muted); margin: 10px 0 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.hint { margin: 6px 0 0; color: var(--fern); font-size: .92rem; }

.toast {
  position: fixed; left: 50%; bottom: calc(140px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 14px;
  max-width: calc(100% - 32px); z-index: 10; text-align: center;
}

@media (max-width: 420px) {
  .view-title { font-size: 2rem; }
  .grid2 { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .current-flow { transition: none; }
}
.plain-list .row { flex-wrap: nowrap; flex: none; }
