/* Hallmark · macrostructure: Workbench (app shell) · tone: utilitarian-calm · anchor hue: 152 green on cool 258 paper
 * theme: studied-DNA (source: https://www.usehallmark.com/examples/tally/) · studied: yes · DNA-source: url
 * observed-fonts: Geist + Geist Mono (+ Heebo for Hebrew) · observed-accent: green glow / live dot
 * nav: bottom tab bar (app) · footer: none (app shell)
 */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; overflow-x: clip; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  font-size: var(--text-md);
  line-height: 1.5;
  color: var(--color-ink);
  background: var(--color-paper);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }

.glow {
  position: fixed; inset: -20vh -30vw auto auto; width: 80vw; height: 60vh; pointer-events: none; z-index: 0;
  background: radial-gradient(closest-side, var(--color-glow), transparent);
}

.app {
  position: relative; z-index: 1;
  max-width: 560px; margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + var(--space-lg)) var(--space-md) calc(env(safe-area-inset-bottom) + 140px);
}

/* ---------- header */
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-md); margin-bottom: var(--space-lg); }
.head h1 { font-family: var(--font-display); font-size: var(--text-2xl); font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; margin: 0; overflow-wrap: anywhere; min-width: 0; }
.head .sub { color: var(--color-ink-2); font-size: var(--text-sm); margin: var(--space-2xs) 0 0; }
.live { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: var(--text-xs); color: var(--color-ink-2);
  border: 1px solid var(--color-rule); background: var(--color-surface); border-radius: var(--radius-pill); padding: 4px 10px; white-space: nowrap; }
.live::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--color-accent); }

/* ---------- cards */
.card { background: var(--color-surface); border: 1px solid var(--color-rule); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); padding: var(--space-md); margin-bottom: var(--space-md); }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-sm); margin-bottom: var(--space-xs); }
.card-head h2 { font-size: var(--text-lg); font-weight: 600; margin: 0; letter-spacing: -0.01em; }
.card-head .count { font-family: var(--font-mono); font-size: var(--text-sm); color: var(--color-ink-3); }
.link { background: none; border: 0; padding: 0; color: var(--color-ink-2); font-size: var(--text-sm); text-decoration: underline; text-underline-offset: 3px; white-space: nowrap; }
.link:hover { color: var(--color-ink); }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-xs); margin-bottom: var(--space-md); }
.stat { background: var(--color-surface); border: 1px solid var(--color-rule); border-radius: var(--radius-md); padding: var(--space-sm); text-align: start; }
.stat b { display: block; font-family: var(--font-mono); font-size: var(--text-xl); font-weight: 500; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat span { font-size: var(--text-xs); color: var(--color-ink-2); }
.stat.warn b { color: var(--color-danger); }
button.stat { cursor: pointer; transition: border-color var(--dur-fast) var(--ease-out); }
button.stat:hover { border-color: var(--color-rule-strong); }

.group-label { font-size: var(--text-xs); color: var(--color-ink-3); font-weight: 500; margin: var(--space-md) 0 var(--space-2xs); }
.group-label.late { color: var(--color-danger); }
.group-label:first-child { margin-top: 0; }

/* ---------- task rows */
.list { list-style: none; margin: 0; padding: 0; }
.row { display: flex; align-items: flex-start; gap: var(--space-sm); padding: var(--space-sm) 0; border-top: 1px solid var(--color-rule); }
.list > .row:first-child { border-top: 0; }
.check {
  flex: none; width: 26px; height: 26px; margin-top: 1px; border-radius: 50%;
  border: 1.5px solid var(--color-rule-strong); background: var(--color-surface);
  display: grid; place-items: center; transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.check svg { width: 14px; height: 14px; opacity: 0; transition: opacity var(--dur-fast) var(--ease-out); }
.check:hover { border-color: var(--color-accent); }
.check:hover svg { opacity: 0.4; }
.check:active { transform: scale(0.94); }
.check.is-done { background: var(--color-accent); border-color: var(--color-accent); color: var(--color-on-ink); }
.check.is-done svg { opacity: 1; }
.row-main { flex: 1; min-width: 0; background: none; border: 0; padding: 0; text-align: start; }
.row-title { display: block; font-weight: 500; overflow-wrap: anywhere; }
.row.is-done .row-title { color: var(--color-ink-3); text-decoration: line-through; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 4px; font-size: var(--text-xs); color: var(--color-ink-2); }
.meta .mono { font-family: var(--font-mono); }
.meta .late { color: var(--color-danger); }
.owner { border-radius: var(--radius-pill); padding: 1px 8px; font-weight: 500; }
.owner.yarin { background: var(--color-yarin-soft); color: var(--color-yarin); }
.owner.freya { background: var(--color-freya-soft); color: var(--color-freya); }
.owner.both { background: var(--color-accent-soft); color: var(--color-accent-ink); }
.meta svg { width: 12px; height: 12px; vertical-align: -1px; }

.empty { color: var(--color-ink-2); font-size: var(--text-sm); padding: var(--space-sm) 0; margin: 0; }

/* ---------- chips / segmented */
.chips { display: flex; gap: var(--space-xs); overflow-x: auto; padding-bottom: 2px; margin-bottom: var(--space-md); scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid var(--color-rule); background: var(--color-surface); color: var(--color-ink-2);
  border-radius: var(--radius-pill); padding: 6px 14px; font-size: var(--text-sm); white-space: nowrap;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.chip:hover { border-color: var(--color-rule-strong); color: var(--color-ink); }
.chip[aria-pressed="true"] { background: var(--color-ink); color: var(--color-on-ink); border-color: var(--color-ink); }
.chip:disabled { opacity: 0.45; cursor: not-allowed; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); background: var(--color-paper-2); border: 1px solid var(--color-rule); border-radius: var(--radius-pill); padding: 3px; margin-bottom: var(--space-md); }
.seg button { border: 0; background: none; border-radius: var(--radius-pill); padding: 7px 8px; font-size: var(--text-sm); color: var(--color-ink-2); white-space: nowrap; transition: background var(--dur-fast) var(--ease-out); }
.seg button[aria-pressed="true"] { background: var(--color-surface); color: var(--color-ink); font-weight: 500; box-shadow: var(--shadow-card); }

/* ---------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--color-ink); background: var(--color-ink); color: var(--color-on-ink);
  border-radius: var(--radius-pill); padding: 11px 20px; font-size: var(--text-sm); font-weight: 500; white-space: nowrap;
  transition: transform var(--dur-fast) var(--ease-out), opacity var(--dur-fast) var(--ease-out);
}
.btn:hover { opacity: 0.9; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn[data-state="loading"] { opacity: 0.7; pointer-events: none; }
.btn.ghost { background: var(--color-surface); color: var(--color-ink); border-color: var(--color-rule-strong); }
.btn.danger { background: var(--color-surface); color: var(--color-danger); border-color: var(--color-danger-soft); }
.btn.block { width: 100%; }
.btn svg { width: 16px; height: 16px; }

.fab { position: fixed; z-index: 5; inset-inline-start: max(var(--space-md), calc(50% - 280px + var(--space-md))); bottom: calc(env(safe-area-inset-bottom) + 84px); box-shadow: 0 8px 24px oklch(0.18 0.03 258 / 0.25); }

/* ---------- tab bar */
.tabs {
  position: fixed; z-index: 6; left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom) + var(--space-sm));
  width: min(calc(100% - 2 * var(--space-md)), 420px);
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  background: oklch(0.984 0.005 258 / 0.82); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--color-rule); border-radius: var(--radius-pill); padding: 5px; box-shadow: var(--shadow-card);
}
.tabs button { border: 0; background: none; border-radius: var(--radius-pill); padding: 7px 4px; display: grid; justify-items: center; gap: 2px; font-size: 11px; color: var(--color-ink-3); white-space: nowrap; }
.tabs button svg { width: 20px; height: 20px; }
.tabs button[aria-current="page"] { background: var(--color-ink); color: var(--color-on-ink); }

/* ---------- inputs */
.field { display: grid; gap: 6px; margin-bottom: var(--space-md); }
.field > span { font-size: var(--text-xs); color: var(--color-ink-2); font-weight: 500; }
.input {
  width: 100%; min-width: 0; border: 1px solid var(--color-rule-strong); background: var(--color-surface); border-radius: var(--radius-md);
  padding: 11px 14px; font-size: 16px; transition: border-color var(--dur-fast) var(--ease-out);
}
.input:hover { border-color: var(--color-ink-3); }
.input:focus { outline: none; border-color: var(--color-ink); }
.input:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 1px; }
.input[aria-invalid="true"] { border-color: var(--color-danger); }
.input:disabled { background: var(--color-paper-2); }
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-sm); }
.addrow { display: flex; gap: var(--space-xs); margin-bottom: var(--space-md); }
.addrow .input { flex: 1; }
.err { color: var(--color-danger); font-size: var(--text-sm); margin: 0 0 var(--space-sm); }

/* ---------- sheet */
.scrim { position: fixed; inset: 0; z-index: 20; background: var(--color-scrim); animation: fade var(--dur-med) var(--ease-out); }
.sheet {
  position: fixed; z-index: 21; left: 50%; bottom: 0; transform: translateX(-50%);
  width: min(100%, 560px); max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--color-paper); border-radius: var(--radius-lg) var(--radius-lg) 0 0; box-shadow: var(--shadow-sheet);
  padding: var(--space-sm) var(--space-md) calc(env(safe-area-inset-bottom) + var(--space-lg));
  animation: rise var(--dur-slow) var(--ease-out);
}
.sheet .grab { width: 40px; height: 4px; border-radius: 4px; background: var(--color-rule-strong); margin: 0 auto var(--space-md); }
.sheet h2 { font-size: var(--text-xl); font-weight: 600; letter-spacing: -0.02em; margin: 0 0 var(--space-md); overflow-wrap: anywhere; }
.sheet-actions { display: flex; flex-wrap: wrap; gap: var(--space-xs); margin-top: var(--space-lg); }
.sheet-actions .btn:first-child { flex: 1 1 100%; }
.sheet-actions .btn { min-width: 0; }
.sheet-actions .btn.ghost { flex: 1 1 0; }
.sheet-actions a.btn { text-decoration: none; overflow: hidden; text-overflow: ellipsis; }
@keyframes rise { from { transform: translate(-50%, 24px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- toast */
.toast {
  position: fixed; z-index: 30; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom) + 84px);
  display: flex; align-items: center; gap: var(--space-md); background: var(--color-ink); color: var(--color-on-ink);
  border-radius: var(--radius-pill); padding: 10px 10px 10px 18px; font-size: var(--text-sm); box-shadow: var(--shadow-sheet);
  max-width: calc(100% - 2 * var(--space-md));
}
.toast button { background: oklch(1 0 0 / 0.14); border: 0; color: var(--color-on-ink); border-radius: var(--radius-pill); padding: 5px 12px; white-space: nowrap; }

/* ---------- food */
.player { margin: 0 0 var(--space-md); }
.player video { display: block; width: 100%; max-width: 360px; aspect-ratio: 9 / 16; margin: 0 auto; border-radius: var(--radius-md); background: var(--color-ink); object-fit: cover; }
.player .frame { max-width: 360px; margin: 0 auto; border-radius: var(--radius-md); overflow: hidden; background: var(--color-paper-2); }
.player iframe { width: 100%; height: 100%; border: 0; display: block; }
.player figcaption { text-align: center; margin-top: var(--space-xs); font-size: var(--text-xs); }
.player figcaption a { color: var(--color-ink-3); }
details.video { margin: 0 0 var(--space-md); }
details.video summary { cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-sm); font-weight: 500; color: var(--color-ink-2); padding: var(--space-xs) 0; }
details.video summary svg { width: 14px; height: 14px; }
details.video .frame { max-width: 360px; margin: var(--space-xs) auto 0; border-radius: var(--radius-md); overflow: hidden; background: var(--color-paper-2); }
details.video iframe { width: 100%; height: 100%; border: 0; display: block; }
.sheet-actions .btn svg { width: 16px; height: 16px; }
.shop-row { display: flex; align-items: center; gap: var(--space-sm); padding: 10px 0; border-top: 1px solid var(--color-rule); }
.list > .shop-row:first-child { border-top: 0; }
.shop-row label { flex: 1; min-width: 0; overflow-wrap: anywhere; display: grid; }
.shop-from { font-size: var(--text-xs); color: var(--color-ink-3); }
.x { flex: none; width: 28px; height: 28px; border: 0; background: none; color: var(--color-ink-3); border-radius: 50%; display: grid; place-items: center; opacity: 0.6; }
.x svg { width: 14px; height: 14px; }
.x:hover { opacity: 1; background: var(--color-paper-2); color: var(--color-danger); }
.servings { display: flex; align-items: center; gap: var(--space-sm); margin-top: var(--space-lg); }
.servings span { color: var(--color-ink-2); font-size: var(--text-sm); margin-inline-end: auto; }
.servings b { font-family: var(--font-mono); font-size: var(--text-lg); min-width: 2ch; text-align: center; }
.step { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--color-rule-strong); background: var(--color-surface); display: grid; place-items: center; }
.step svg { width: 14px; height: 14px; }
.step:active { transform: scale(0.94); }
.day-items { flex: 1; min-width: 0; display: grid; gap: 6px; }
.day .d small { color: var(--color-ink-3); }
.menu-item { display: flex; align-items: center; gap: var(--space-xs); }
.menu-item img { width: 44px; height: 44px; border-radius: var(--radius-sm); object-fit: cover; flex: none; }
.menu-name { flex: 1; min-width: 0; background: none; border: 0; padding: 0; text-align: start; display: grid; }
.menu-name b { font-weight: 500; overflow-wrap: anywhere; }
.menu-name small { color: var(--color-ink-3); font-size: var(--text-xs); }
.add-meal { justify-self: start; text-decoration: none; color: var(--color-ink-3); }
.add-meal:hover { color: var(--color-ink); }
.shop-row.is-done label { color: var(--color-ink-3); text-decoration: line-through; }
details.bought summary { cursor: pointer; font-size: var(--text-sm); color: var(--color-ink-2); padding: var(--space-xs) 0; }

.recipes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-md) var(--space-sm); }
.recipe { background: var(--color-surface); border: 1px solid var(--color-rule); border-radius: var(--radius-md); overflow: hidden; padding: 0; text-align: start; transition: border-color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out); }
.recipe:hover { border-color: var(--color-rule-strong); }
.recipe:active { transform: scale(0.99); }
.recipe .ph { aspect-ratio: 1; background: var(--color-paper-2); display: grid; place-items: center; color: var(--color-ink-3); }
.recipe img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.recipe .rn { display: block; padding: var(--space-xs) var(--space-sm) 2px; font-weight: 600; font-size: var(--text-md); line-height: 1.25; overflow-wrap: anywhere; }
.recipe .rt { display: block; padding: 0 var(--space-sm) var(--space-sm); font-size: var(--text-xs); color: var(--color-ink-3); }
.hero-img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; border-radius: var(--radius-md); margin-bottom: var(--space-md); display: block; }
.ingredients { padding-inline-start: 1.1em; margin: 0 0 var(--space-lg); }
.ingredients li { padding: 3px 0; }
.steps { padding-inline-start: 1.3em; margin: 0; }
.steps li { padding: 5px 0; }
.steps li::marker { font-family: var(--font-mono); color: var(--color-ink-3); }
.sheet h3 { font-size: var(--text-md); font-weight: 600; margin: var(--space-md) 0 var(--space-xs); }

.day { display: flex; gap: var(--space-sm); padding: 10px 0; border-top: 1px solid var(--color-rule); }
.list > .day:first-child { border-top: 0; }
.day .d { flex: none; width: 64px; font-size: var(--text-xs); color: var(--color-ink-2); padding-top: 2px; }

/* ---------- login */
.login { min-height: 80dvh; display: grid; align-content: center; gap: var(--space-lg); }
.login h1 { font-size: var(--text-2xl); font-weight: 600; letter-spacing: -0.02em; margin: 0; }
.login p { color: var(--color-ink-2); margin: 0; }
.who { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-sm); }
.code-input { font-family: var(--font-mono); font-size: var(--text-xl); letter-spacing: 0.3em; text-align: center; direction: ltr; }

.skeleton { height: 64px; border-radius: var(--radius-md); background: var(--color-paper-2); margin-bottom: var(--space-xs); }

@media (min-width: 768px) {
  .app { padding-top: var(--space-2xl); }
  .head h1 { font-size: 2.5rem; }
}

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