/* ---------- tokens ---------- */
:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #fbfaf7;
  --ink: #1b1c19;
  --ink-2: #5c6058;
  --ink-3: #9b9e96;
  --hair: #ecebe5;
  --hair-2: #e2e0d8;
  --accent: #476a4b;
  --accent-2: #6f8f6f;
  --accent-soft: #eef2eb;
  --accent-ink: #ffffff;
  --water: #4f86e8;
  --water-soft: #e6eefc;
  --danger: #c2505a;
  --focus: rgba(71, 106, 75, .22);
  --shadow-sm: 0 1px 2px rgba(24, 24, 16, .05);
  --shadow: 0 1px 2px rgba(24, 24, 16, .04), 0 12px 32px -16px rgba(24, 24, 16, .14);
  --shadow-lg: 0 24px 60px -20px rgba(24, 24, 16, .28), 0 2px 6px rgba(24, 24, 16, .06);
  --radius: 18px;
  --serif: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  --sans: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f100e; --surface: #181916; --surface-2: #141512; --ink: #ecebe5; --ink-2: #a8aaa1; --ink-3: #6e7169;
    --hair: #262823; --hair-2: #30332d; --accent: #9dc29b; --accent-2: #7fa47e; --accent-soft: #1c251b; --accent-ink: #0f1a0f;
    --water: #7aa6ff; --water-soft: #1a2336; --danger: #e5838b; --focus: rgba(157, 194, 155, .25);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4); --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 32px -16px rgba(0, 0, 0, .6);
    --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, .7); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f100e; --surface: #181916; --surface-2: #141512; --ink: #ecebe5; --ink-2: #a8aaa1; --ink-3: #6e7169;
  --hair: #262823; --hair-2: #30332d; --accent: #9dc29b; --accent-2: #7fa47e; --accent-soft: #1c251b; --accent-ink: #0f1a0f;
  --water: #7aa6ff; --water-soft: #1a2336; --danger: #e5838b; --focus: rgba(157, 194, 155, .25);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4); --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 32px -16px rgba(0, 0, 0, .6);
  --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, .7); color-scheme: dark;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink);
  font: 15px/1.5 var(--sans); letter-spacing: -.005em;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  padding: env(safe-area-inset-top) 16px max(40px, env(safe-area-inset-bottom));
}
button, input { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
a { color: var(--accent); text-underline-offset: 3px; }

.app { max-width: 1040px; margin: 0 auto; }

/* ---------- app bar ---------- */
.appbar { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; letter-spacing: -.01em; }
.brand-mark { width: 22px; height: 22px; border-radius: 7px; background: var(--accent); position: relative; }
.brand-mark::after {
  content: ""; position: absolute; left: 8px; top: 4px; width: 5px; height: 10px;
  border: solid var(--accent-ink); border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.appbar-actions { display: flex; align-items: center; gap: 6px; }

.icon-btn {
  border: 0; background: transparent; width: 36px; height: 36px; border-radius: 10px;
  display: inline-grid; place-items: center; color: var(--ink-2); transition: background .2s var(--ease), color .2s;
}
.icon-btn:hover { background: var(--hair); color: var(--ink); }

.sync-chip {
  display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px;
  border: 1px solid var(--hair-2); background: var(--surface); border-radius: 999px;
  font-size: 12.5px; font-weight: 500; color: var(--ink-2); box-shadow: var(--shadow-sm);
  transition: border-color .2s, color .2s;
}
.sync-chip:hover { border-color: var(--ink-3); }
.sync-chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); }
.sync-chip[data-state="synced"] .dot { background: #3fa66b; box-shadow: 0 0 0 3px rgba(63, 166, 107, .15); }
.sync-chip[data-state="syncing"] .dot, .sync-chip[data-state="pending"] .dot { background: var(--water); animation: pulse 1s ease-in-out infinite alternate; }
.sync-chip[data-state="reconnect"], .sync-chip[data-state="error"] { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.sync-chip[data-state="reconnect"] .dot, .sync-chip[data-state="error"] .dot { background: var(--danger); }
@keyframes pulse { to { opacity: .3; } }

/* ---------- hero ---------- */
.hero {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap;
  padding: 28px 4px;
}
.eyebrow { margin: 0 0 2px; font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); }
.hero h1 { margin: 0; font: 400 clamp(52px, 9vw, 84px)/.95 var(--serif); letter-spacing: -.02em; color: var(--ink); }
.date-text {
  margin-top: 8px; border: 0; background: transparent; padding: 2px 0; border-radius: 6px;
  font: italic 400 22px/1.2 var(--serif); color: var(--ink-2); transition: color .2s;
}
.date-text:hover { color: var(--ink); }

.hero-side { display: flex; flex-direction: column; align-items: flex-end; gap: 14px; min-width: 240px; }
.nav {
  display: inline-flex; align-items: center; gap: 2px; padding: 3px;
  background: var(--surface); border: 1px solid var(--hair-2); border-radius: 12px; box-shadow: var(--shadow-sm);
}
.nav .icon-btn { width: 32px; height: 32px; border-radius: 9px; }
.nav-today { border: 0; background: transparent; height: 32px; padding: 0 12px; border-radius: 9px; font-size: 13px; font-weight: 500; color: var(--ink); }
.nav-today:hover:not(:disabled) { background: var(--hair); }
.nav-today:disabled { color: var(--ink-3); cursor: default; }

.progress { width: 240px; }
.progress-text { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--ink-2); margin-bottom: 7px; font-variant-numeric: tabular-nums; }
.progress-text #progressPct { color: var(--ink); font-weight: 500; }
.bar { height: 4px; border-radius: 4px; background: var(--hair-2); overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: inherit; transition: width .5s var(--ease); }

/* ---------- carry banner ---------- */
.carry {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--hair-2); border-radius: 14px;
  padding: 10px 10px 10px 14px; margin-bottom: 18px; box-shadow: var(--shadow-sm); font-size: 14px;
  animation: rise .35s var(--ease);
}
.carry-icon { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
#carryText { flex: 1; min-width: 160px; color: var(--ink); }
.carry-actions { display: flex; gap: 6px; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; height: 34px; padding: 0 14px;
  border: 1px solid var(--hair-2); background: var(--surface); border-radius: 10px;
  font-size: 13.5px; font-weight: 500; white-space: nowrap; cursor: pointer;
  transition: background .2s, border-color .2s, transform .1s;
}
.btn:hover { border-color: var(--ink-3); }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn-primary:hover { border-color: var(--ink); opacity: .9; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--hair); border-color: transparent; color: var(--ink); }

/* ---------- layout ---------- */
.grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.col { display: grid; gap: 18px; min-width: 0; }
.card { background: var(--surface); border: 1px solid var(--hair); border-radius: var(--radius); padding: 20px 20px 10px; box-shadow: var(--shadow); }
.card-accent { background: linear-gradient(180deg, var(--accent-soft), var(--surface) 70%); }
.card-quiet { background: var(--surface-2); box-shadow: none; }
.label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.label { margin: 0 0 8px; font-size: 12px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-2); }
.card-accent .label { color: var(--accent); }
.count { font-size: 12.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* ---------- lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list.numbered { counter-reset: n; }
.item, .add-row { position: relative; display: flex; align-items: flex-start; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--hair); }
.list > :last-child { border-bottom: 0; }
.item { animation: fade .25s var(--ease); }
@keyframes fade { from { opacity: 0; } }

.numbered .item::before, .numbered .add-row::before {
  counter-increment: n; content: counter(n);
  flex: none; width: 22px; font: 400 26px/1 var(--serif); color: var(--accent); padding-top: 1px;
}
.numbered .add-row::before { color: var(--ink-3); opacity: .6; }

.item .body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.item .text {
  width: 100%; border: 0; background: transparent; padding: 3px 0; outline: none;
  font-size: 15.5px; font-weight: 450; color: var(--ink); text-overflow: ellipsis; transition: color .2s;
}
.numbered .item .text { font-size: 16.5px; font-weight: 500; }
.item .note { width: 100%; border: 0; background: transparent; outline: none; padding: 0 0 2px; font-size: 13px; color: var(--ink-2); }
.item .note::placeholder { color: var(--ink-3); }
.item .time, .add-row .time {
  flex: none; width: 74px; border: 0; background: transparent; padding: 4px 0; outline: none;
  font-size: 13px; font-weight: 500; color: var(--ink-2); font-variant-numeric: tabular-nums;
}
.item .time::-webkit-calendar-picker-indicator, .add-row .time::-webkit-calendar-picker-indicator { opacity: .35; margin-left: 2px; cursor: pointer; }
.time.empty:not(:focus):not(:focus-within) { color: transparent; }
.time.empty:not(:focus)::-webkit-calendar-picker-indicator { opacity: .5; }
.schedule .item:hover .time.empty, .add-row:hover .time.empty { color: var(--ink-3); }
.schedule .item, .schedule .add-row { align-items: center; }
.schedule .item .body { border-left: 2px solid var(--accent-2); padding-left: 10px; }

/* checkbox */
.check {
  flex: none; order: 9; position: relative; width: 22px; height: 22px; margin-top: 3px; padding: 0;
  border-radius: 50%; border: 1.5px solid var(--hair-2); background: var(--surface);
  display: grid; place-items: center; transition: border-color .2s, background .25s var(--ease), transform .15s;
}
.numbered .check { margin-top: 4px; }
.schedule .check { margin-top: 0; }
.check:hover { border-color: var(--accent); }
.check:active { transform: scale(.9); }
.check svg { position: absolute; width: 12px; height: 12px; opacity: 0; transform: scale(.5); transition: opacity .2s, transform .25s var(--ease); }
.status-done .check { background: var(--accent); border-color: var(--accent); }
.status-done .check .tick { opacity: 1; transform: none; }
.status-done .text { color: var(--ink-3); text-decoration: line-through; text-decoration-color: var(--hair-2); text-decoration-thickness: 1.5px; }
.status-dropped .text { color: var(--ink-3); text-decoration: line-through; text-decoration-thickness: 1.5px; }
.status-dropped .check { border-style: dashed; }
.status-moved .text { color: var(--ink-3); }
.status-moved .check { border-color: var(--hair); background: var(--surface-2); }
.status-moved .check .arrow { opacity: 1; transform: none; }

.more {
  flex: none; order: 8; border: 0; background: transparent; width: 28px; height: 28px;
  color: var(--ink-3); border-radius: 8px; display: grid; place-items: center;
  opacity: 0; transition: opacity .15s, background .15s, color .15s;
}
.item:hover .more, .item:focus-within .more, .more[aria-expanded="true"] { opacity: 1; }
@media (hover: none) { .more { opacity: .55; } }
.more:hover, .more[aria-expanded="true"] { background: var(--hair); color: var(--ink); }

.add-row input.add { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; padding: 3px 0; font-size: 15px; color: var(--ink); }
.add-row input.add::placeholder { color: var(--ink-3); }
.list:not(.numbered) .add-row::after {
  content: "+"; flex: none; width: 22px; height: 22px; margin-top: 2px; order: 9;
  display: grid; place-items: center; font-size: 17px; color: var(--ink-3); transition: color .2s;
}
.add-row:focus-within::after { color: var(--accent); }

.hint { margin: 4px 0 10px; font-size: 12.5px; color: var(--ink-3); }

/* ---------- water ---------- */
.water { padding-bottom: 16px; }
.glasses { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 14px; }
.bottle {
  border: 0; background: transparent; padding: 4px 3px; width: 34px; height: 54px; border-radius: 10px;
  display: grid; place-items: center; transition: background .2s, transform .15s var(--ease);
}
.bottle:hover { background: var(--water-soft); }
.bottle:active { transform: scale(.92); }
.bottle svg { width: 26px; height: 44px; overflow: visible; }
.bottle .outline { fill: none; stroke: var(--ink-3); stroke-width: 1.4; stroke-linejoin: round; transition: stroke .2s; }
.bottle .cap { fill: var(--ink-3); transition: fill .2s; }
.bottle .shine { stroke: #fff; stroke-opacity: 0; stroke-width: 1.4; stroke-linecap: round; transition: stroke-opacity .3s; }
.bottle .liquid {
  fill: var(--water); transform-box: view-box; transform: translateY(30px);
  transition: transform .55s var(--ease);
}
.bottle.half .liquid { transform: translateY(15px); }
.bottle.full .liquid { transform: none; }
.bottle.half .outline, .bottle.full .outline { stroke: var(--water); }
.bottle.half .cap, .bottle.full .cap { fill: var(--water); }
.bottle.full .shine { stroke-opacity: .45; }
.water-foot { display: flex; align-items: center; gap: 12px; }
.water-bar { flex: 1; }
.water-bar span { background: var(--water); }
.water-sub { font-size: 12.5px; color: var(--ink-3); white-space: nowrap; }
.water-total { color: var(--ink-2); font-weight: 500; }
.water.goal-met .water-total { color: var(--water); }
.water.goal-met .water-total::after { content: " ✓"; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.input-unit { position: relative; display: block; }
.input-unit input { width: 100%; padding-right: 40px; }
.input-unit em { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-style: normal; font-size: 13px; color: var(--ink-3); pointer-events: none; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.chip {
  height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--hair-2); background: transparent;
  font-size: 12.5px; font-weight: 500; color: var(--ink-2); transition: all .2s;
}
.chip:hover { border-color: var(--ink-3); color: var(--ink); }
.chip.on { background: var(--water-soft); border-color: color-mix(in srgb, var(--water) 45%, transparent); color: var(--water); }

/* ---------- menu ---------- */
.menu {
  position: fixed; z-index: 20; min-width: 220px; padding: 6px;
  background: var(--surface); border: 1px solid var(--hair-2); border-radius: 14px; box-shadow: var(--shadow-lg);
  animation: pop .16s var(--ease); transform-origin: top right;
}
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(-4px); } }
.menu button { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 8px 10px; border-radius: 8px; font-size: 13.5px; color: var(--ink); }
.menu button:hover, .menu button:focus-visible { background: var(--hair); outline: none; }
.menu button.danger { color: var(--danger); }
.menu hr { border: 0; border-top: 1px solid var(--hair); margin: 5px 4px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: flex; gap: 16px; align-items: center; z-index: 30; max-width: calc(100vw - 32px);
  background: var(--ink); color: var(--bg); padding: 11px 16px; border-radius: 12px;
  font-size: 13.5px; box-shadow: var(--shadow-lg); animation: toast .25s var(--ease);
}
@keyframes toast { from { opacity: 0; transform: translate(-50%, 8px); } }
.toast button { background: transparent; border: 0; padding: 0; color: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; opacity: .85; }
.toast button:hover { opacity: 1; }

/* ---------- settings ---------- */
dialog {
  border: 1px solid var(--hair-2); border-radius: 22px; padding: 0; width: min(500px, calc(100vw - 32px));
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg);
}
dialog[open] { animation: pop .2s var(--ease); }
dialog::backdrop { background: rgba(15, 16, 14, .3); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.settings-inner { padding: 22px 24px 24px; }
.settings-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.settings-head h2 { margin: 0; font: 400 34px/1 var(--serif); letter-spacing: -.01em; }
.settings-section { padding-top: 18px; margin-top: 18px; border-top: 1px solid var(--hair); }
.settings-section:first-of-type { border-top: 0; margin-top: 4px; padding-top: 8px; }
.settings-section h3 { margin: 0 0 6px; font-size: 12px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-2); }
.field { display: grid; gap: 6px; margin: 12px 0 6px; font-size: 13px; font-weight: 500; }
.field input {
  height: 40px; border: 1px solid var(--hair-2); border-radius: 10px; padding: 0 12px; background: var(--surface-2);
  font-weight: 400; font-size: 13.5px; outline: none; transition: border-color .2s, box-shadow .2s;
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--focus); }
.field input:disabled { color: var(--ink-2); }
.row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.muted { color: var(--ink-2); margin: 4px 0; font-size: 14px; }
.small { font-size: 12.5px; }
code { font-size: 12px; background: var(--hair); padding: 1px 6px; border-radius: 5px; }

/* ---------- phone ---------- */
@media (max-width: 760px) {
  body { padding-left: 14px; padding-right: 14px; }
  .appbar { height: 56px; }
  .hero { flex-direction: column; align-items: stretch; padding: 14px 2px 22px; gap: 18px; }
  .hero-side { flex-direction: row-reverse; align-items: center; justify-content: space-between; min-width: 0; }
  .progress { width: auto; flex: 1; }
  .grid, .col { gap: 14px; }
  .grid { grid-template-columns: minmax(0, 1fr); }
  .card { padding: 18px 16px 8px; border-radius: 16px; }
  .glasses { gap: 4px; }
  .bottle { width: 30px; }
  .carry-actions { width: 100%; justify-content: flex-end; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
