:root {
	--bg: #f6efe4;
	--card: #fffaf3;
	--ink: #2b2118;
	--dim: #85776a;
	--line: #e8dccb;
	--accent: #c8622f;
	--accent-ink: #fffaf3;
	--soft: #f1e3d0;
	--ok: #4f8a4a;
	--warn: #c9891c;
	--bad: #c23b2b;
	--chip: #f3e8d9;
	--shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 4px 16px rgba(60, 40, 20, .06);
	color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
	:root {
		--bg: #1d1712;
		--card: #29211a;
		--ink: #f3e9dc;
		--dim: #a6968a;
		--line: #3a2f26;
		--accent: #e07a43;
		--accent-ink: #1d1712;
		--soft: #3a2c20;
		--ok: #7fb978;
		--warn: #e2a948;
		--bad: #ec6b5a;
		--chip: #342a21;
		--shadow: none;
	}
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
	font: 17px/1.35 ui-rounded, -apple-system, "SF Pro Rounded", system-ui, sans-serif;
	-webkit-user-select: none; user-select: none;
	padding: env(safe-area-inset-top) 0 0;
	overscroll-behavior-y: none;
}
input, textarea, select { -webkit-user-select: text; user-select: text; font: inherit; color: inherit; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; touch-action: manipulation; }

#app { max-width: 560px; margin: 0 auto; padding: 0 16px calc(96px + env(safe-area-inset-bottom)); }
.top { padding: 18px 4px 8px; }
.top h1 { margin: 0; font-size: 34px; letter-spacing: -.5px; }
.top p { margin: 2px 0 0; color: var(--dim); min-height: 1.35em; }

.card { background: var(--card); border-radius: 22px; padding: 16px; margin: 12px 0; box-shadow: var(--shadow); }
.card h2 { margin: 0; font-size: 21px; display: flex; align-items: baseline; gap: 8px; }
.card h2 small { font-size: 14px; font-weight: 500; color: var(--dim); margin-left: auto; text-align: right; }
.label { font-size: 13px; color: var(--dim); text-transform: uppercase; letter-spacing: .4px; margin: 14px 2px 6px; }

.seg { display: flex; background: var(--chip); border-radius: 14px; padding: 3px; gap: 2px; }
.seg button { flex: 1; padding: 9px 2px; border-radius: 11px; font-size: 15px; color: var(--dim); white-space: nowrap; }
.seg button.on { background: var(--card); color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.12); }

.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.big {
	min-height: 64px; border-radius: 16px; background: var(--soft); font-size: 24px; font-weight: 650;
	display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1;
	transition: transform .08s ease;
}
.big small { font-size: 12px; font-weight: 500; color: var(--dim); margin-top: 3px; }
.big.mark { outline: 2px solid var(--accent); outline-offset: -2px; }
.big:active, .btn:active, .chip:active { transform: scale(.96); }
.pop { animation: pop .35s ease; }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(.92); background: var(--accent); color: var(--accent-ink); } 100% { transform: scale(1); } }

.btn { display: block; width: 100%; min-height: 56px; border-radius: 16px; background: var(--accent); color: var(--accent-ink); font-size: 19px; font-weight: 650; margin-top: 12px; padding: 0 14px; transition: transform .08s ease; }
.btn.second { background: var(--soft); color: var(--ink); }
.btn.warn { background: var(--warn); color: #fff; }
.btn.small { min-height: 44px; font-size: 16px; }
.link { color: var(--accent); font-size: 15px; padding: 12px 2px 2px; font-weight: 600; }
.row { display: flex; gap: 8px; align-items: center; }
.row > * { flex: 1; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 10px 14px; border-radius: 999px; background: var(--chip); font-size: 15px; transition: transform .08s ease; }
.chip.on { background: var(--accent); color: var(--accent-ink); }

.meals { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.meal { border-radius: 16px; padding: 12px; background: var(--chip); }
.meal b { display: block; font-size: 20px; margin-top: 2px; }
.meal small { color: var(--dim); }
.meal.done { background: color-mix(in srgb, var(--ok) 18%, var(--card)); }
.meal.done b { color: var(--ok); }
.meal.now:not(.done) { outline: 2px dashed var(--accent); outline-offset: -2px; }

.running { text-align: center; padding: 8px 0 0; }
.timer { font-size: 56px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -1px; }
.running p { margin: 0; color: var(--dim); }

details summary { list-style: none; cursor: pointer; }
details summary::-webkit-details-marker { display: none; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 11px 2px; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list .ico { width: 30px; display: flex; justify-content: center; color: var(--accent); }
.list .main { flex: 1; min-width: 0; }
.list .main b { font-weight: 600; }
.list .main div { color: var(--dim); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .time { font-variant-numeric: tabular-nums; color: var(--dim); font-size: 15px; text-align: right; }
.list li[data-id] { cursor: pointer; }
.empty { color: var(--dim); text-align: center; padding: 12px 0; }
.day-h { font-size: 14px; color: var(--dim); font-weight: 600; margin: 18px 4px 4px; text-transform: uppercase; letter-spacing: .4px; }

.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; align-items: end; height: 120px; margin-top: 10px; }
.week div { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; font-size: 12px; color: var(--dim); }
.week i { display: block; width: 100%; border-radius: 7px 7px 3px 3px; background: var(--accent); opacity: .85; min-height: 3px; }
.week .today i { opacity: 1; }
.week b { font-size: 11px; color: var(--ink); font-weight: 600; margin-bottom: 3px; }

.due { font-weight: 600; font-size: 14px; }
.due.ok { color: var(--ok); } .due.soon { color: var(--warn); } .due.over { color: var(--bad); }

.field { display: block; margin: 10px 0; }
.field span { display: block; font-size: 13px; color: var(--dim); margin: 0 2px 4px; }
.field input, .field textarea, .field select { width: 100%; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); font-size: 17px; }
.field textarea { min-height: 70px; resize: vertical; }

.tabs {
	position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center;
	background: color-mix(in srgb, var(--card) 88%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
	border-top: 1px solid var(--line); padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}
.tabs button { flex: 1; max-width: 140px; display: flex; flex-direction: column; align-items: center; font-size: 11px; color: var(--dim); padding: 4px 0; gap: 1px; }
.tabs button span { display: flex; height: 26px; align-items: center; }
.tabs .i { width: 24px; height: 24px; }
.tabs button.on { color: var(--accent); font-weight: 600; }

.toast {
	position: fixed; left: 12px; right: 12px; bottom: calc(80px + env(safe-area-inset-bottom)); max-width: 536px; margin: 0 auto;
	background: var(--ink); color: var(--bg); border-radius: 18px; padding: 10px 10px 10px 16px;
	display: flex; align-items: center; gap: 8px; box-shadow: 0 8px 30px rgba(0,0,0,.25); animation: up .2s ease;
}
.toast[hidden] { display: none; }
.toast .msg { flex: 1; font-weight: 600; }
.toast button { padding: 8px 12px; border-radius: 12px; background: color-mix(in srgb, var(--bg) 16%, transparent); font-size: 15px; color: inherit; }
.toast button.on { background: var(--accent); color: var(--accent-ink); }
@keyframes up { from { transform: translateY(20px); opacity: 0; } }

.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: flex-end; z-index: 10; }
.sheet[hidden] { display: none; }
.sheet-body {
	background: var(--card); width: 100%; max-width: 560px; margin: 0 auto; border-radius: 24px 24px 0 0;
	padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); max-height: 88vh; overflow: auto; animation: up .2s ease;
}
.sheet-body h3 { margin: 0 0 4px; font-size: 22px; }
.sheet-body .sub { color: var(--dim); margin: 0 0 8px; }
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper b { flex: 1; text-align: center; font-size: 22px; font-variant-numeric: tabular-nums; }
.stepper button { min-width: 64px; min-height: 48px; border-radius: 14px; background: var(--chip); font-size: 16px; font-weight: 600; }
.danger { color: var(--bad); }

.login { text-align: center; padding-top: 12vh; }
.login input { text-align: center; font-size: 26px; letter-spacing: 4px; text-transform: uppercase; }
.err { color: var(--bad); min-height: 1.4em; }
.spark { width: 100%; height: 60px; display: block; margin-top: 8px; }
.spark path { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.hint { font-size: 14px; color: var(--dim); }
.paircode { font-size: 34px; font-weight: 700; letter-spacing: 4px; text-align: center; margin: 12px 0 4px; font-variant-numeric: tabular-nums; -webkit-user-select: text; user-select: text; }
.i { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.i .f { fill: currentColor; stroke: none; }
.card h2 .i { color: var(--accent); align-self: center; width: 24px; height: 24px; }
.i.sm { width: 18px; height: 18px; stroke-width: 2.4; vertical-align: -2px; margin-right: 3px; }
.chip.ic { display: inline-flex; align-items: center; gap: 6px; }
.chip.ic .i { width: 18px; height: 18px; }

.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 8px 0 6px; }
.act {
	background: var(--card); border-radius: 22px; box-shadow: var(--shadow); padding: 16px 6px 12px; min-height: 124px;
	display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; transition: transform .08s ease;
}
.act:active { transform: scale(.96); }
.act .i { width: 38px; height: 38px; color: var(--accent); margin-bottom: 4px; }
.act b { font-size: 18px; }
.act small { font-size: 13px; color: var(--dim); text-align: center; line-height: 1.2; min-height: 1.2em; font-variant-numeric: tabular-nums; }
.act.live { background: var(--accent); color: var(--accent-ink); }
.act.live .i, .act.live small { color: var(--accent-ink); }
.act.done .i { color: var(--ok); }
.act.warn { background: var(--warn); color: #fff; }
.act.warn .i, .act.warn small { color: #fff; }
ul.list.card { padding: 4px 14px; margin: 0; }
.day-h:first-of-type { margin-top: 14px; }
.sheet-body h3 { display: flex; align-items: baseline; }
.sheet-body h3 small { margin-left: auto; font-size: 15px; font-weight: 500; }
.sheet-body .link { padding-top: 14px; }
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tile { min-height: 96px; border-radius: 16px; background: var(--soft); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 8px 4px; transition: transform .08s ease; }
.tile:active { transform: scale(.96); }
.tile .i { width: 30px; height: 30px; color: var(--accent); }
.tile b { font-size: 15px; font-weight: 600; text-align: center; line-height: 1.15; }
.tile small { font-size: 12px; color: var(--dim); }
.tile.add { background: none; outline: 2px dashed var(--line); outline-offset: -2px; }
.tile.edit { outline: 2px solid var(--accent); outline-offset: -2px; }
.icons { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.icons button { aspect-ratio: 1; border-radius: 14px; background: var(--chip); display: flex; align-items: center; justify-content: center; }
.icons button .i { width: 28px; height: 28px; }
.icons button.on { background: var(--accent); color: var(--accent-ink); }
.tabs button { position: relative; }
.tabs button.dot::after { content: ''; position: absolute; top: 4px; left: calc(50% + 10px); width: 8px; height: 8px; border-radius: 50%; background: var(--bad); }
.big.when { font-size: 18px; }
.i.tag { width: 17px; height: 17px; margin-left: 6px; vertical-align: -2px; color: #8a5a32; }
@media (prefers-color-scheme: dark) { .i.tag { color: #c08a5c; } }
.seg .i.sm { margin-right: 4px; }
.filters { display: flex; gap: 8px; overflow-x: auto; margin: 14px -16px 0; padding: 2px 16px 4px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.filters::-webkit-scrollbar { display: none; }
.filters .chip { flex: none; white-space: nowrap; }
.filters .chip .i { width: 17px; height: 17px; }
.btn.start { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 64px; font-size: 21px; margin-top: 14px; }
.btn.start .i { width: 26px; height: 26px; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--dim); font-size: 13px; text-transform: uppercase; letter-spacing: .4px; margin: 20px 2px 0; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.section-h { display: flex; align-items: center; gap: 8px; font-weight: 650; font-size: 17px; margin: 22px 2px 10px; }
.section-h .i { color: var(--accent); width: 20px; height: 20px; }
.day-h { display: flex; align-items: center; justify-content: space-between; }
.day-h .sum { display: inline-flex; align-items: center; gap: 5px; text-transform: none; letter-spacing: 0; font-variant-numeric: tabular-nums; }
.day-h .sum .i { width: 15px; height: 15px; color: var(--accent); }
.search { flex: none; display: flex; align-items: center; gap: 6px; width: 210px; padding: 0 6px 0 12px; border-radius: 999px; background: var(--chip); }
.search .i { width: 17px; height: 17px; color: var(--dim); flex: none; }
.search input { flex: 1; min-width: 0; border: 0; background: none; outline: none; font-size: 16px; padding: 9px 0; -webkit-appearance: none; }
.search input::-webkit-search-cancel-button { display: none; }
.search button { display: flex; padding: 4px; }
ul.list.card { overflow: hidden; }
.list li[data-id] { position: relative; background: var(--card); transition: transform .2s ease; }
.list li[data-id].swiping { transition: none; }
.list li .del { position: absolute; top: 0; bottom: -1px; left: 100%; width: 110px; padding-right: 14px; background: var(--bad); color: #fff; font-weight: 650; font-size: 16px; }
/* Running walk: a quiet barber pole behind the Gassi tile. */
.act.live { position: relative; overflow: hidden; isolation: isolate; }
.act.live::before {
	content: ''; position: absolute; inset: 0 -40px 0 0; z-index: -1;
	background: repeating-linear-gradient(-45deg, rgba(255, 255, 255, .13) 0 10px, transparent 10px 20px);
	animation: barber 1.6s linear infinite;
}
@keyframes barber { to { transform: translateX(-28.28px); } }
@media (prefers-reduced-motion: reduce) { .act.live::before { animation: none; } }
.list li.live { isolation: isolate; }
.list li.live::before {
	content: ''; position: absolute; top: 0; bottom: 0; left: -14px; right: -14px; z-index: -1;
	background: repeating-linear-gradient(-45deg, color-mix(in srgb, var(--accent) 12%, transparent) 0 10px, transparent 10px 20px) 0 0 / 28.28px 28.28px;
	animation: barber-bg 1.6s linear infinite;
}
@keyframes barber-bg { to { background-position: -28.28px 0; } }
@media (prefers-reduced-motion: reduce) { .list li.live::before { animation: none; } }
ul.list.card > li.live:first-child::before { top: -4px; }
ul.list.card > li.live:last-child::before { bottom: -4px; }
/* The delete button runs to the card's edge; the card clips it. */
ul.list.card > li:first-child .del { top: -4px; }
ul.list.card > li:last-child .del { bottom: -4px; }
/* Hidden once the row has snapped back (after its .2s transition). */
.list li .del { visibility: hidden; transition: visibility 0s .2s; }
.list li.open .del, .list li.swiping .del, .list li.gone .del { visibility: visible; transition: none; }
