/* ofte — phone-first styles. Tokens first, then layout, components, and page specifics. */

:root {
  --bg: #fbf7f2;
  --surface: #ffffff;
  --surface-2: #f4eee6;
  --text: #221d17;
  --muted: #6e6458;
  --border: #e7ded2;
  --accent: #d95f26;
  --accent-ink: #ffffff;
  --accent-soft: #fde6d6;
  --good: #2b8f61;
  --good-soft: #dff3e8;
  --warn: #b97c08;
  --warn-soft: #fbefd2;
  --bad: #c9405a;
  --bad-soft: #fbe3e7;
  --neutral: #a0958a;
  --track: #ece4d9;
  --focus: #2f6fdb;
  --shadow: 0 1px 2px rgba(60, 40, 20, 0.06), 0 4px 16px rgba(60, 40, 20, 0.05);
  --radius: 16px;
  --radius-sm: 10px;
  --tabbar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16130f; --surface: #1f1b16; --surface-2: #29231d; --text: #f4eee7; --muted: #a99d8f; --border: #3a3129;
    --accent: #f2874f; --accent-ink: #1b120b; --accent-soft: #3d2618; --good: #4cc08a; --good-soft: #17322a; --warn: #e3ab3e; --warn-soft: #3a2d12;
    --bad: #ef6a7b; --bad-soft: #3d1c22; --neutral: #847869; --track: #342c24; --focus: #7aa7ff;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #16130f; --surface: #1f1b16; --surface-2: #29231d; --text: #f4eee7; --muted: #a99d8f; --border: #3a3129;
  --accent: #f2874f; --accent-ink: #1b120b; --accent-soft: #3d2618; --good: #4cc08a; --good-soft: #17322a; --warn: #e3ab3e; --warn-soft: #3a2d12;
  --bad: #ef6a7b; --bad-soft: #3d1c22; --neutral: #847869; --track: #342c24; --focus: #7aa7ff;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3); color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 var(--font); -webkit-font-smoothing: antialiased; overflow-x: hidden; }
body.has-sheet { overflow: hidden; }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 0; }
p { margin: 0.4em 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.boot { padding: 40px 20px; text-align: center; color: var(--muted); }
.boot-error { padding: 24px; max-width: 560px; margin: 0 auto; }
.muted { color: var(--muted); }
.small { font-size: 0.86rem; }
.block { display: block; }
.grow { flex: 1 1 auto; }
.pad { padding: 12px; }
.pad-y { padding: 8px 0; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.row-wrap { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.big-num { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.01em; }
.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- layout ---------- */

.app { min-height: 100vh; }
.main-col { min-width: 0; }
.view { padding: 12px 16px calc(var(--tabbar-h) + var(--safe-b) + 28px); max-width: 1100px; margin: 0 auto; outline: none; }
.sidenav { display: none; }
.tabbar {
  position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-around; align-items: stretch;
  height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
}
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); text-decoration: none; font-size: 0.72rem; font-weight: 600; min-width: 0; }
.tab .icon { width: 24px; height: 24px; }
.tab[aria-current="page"] { color: var(--accent); }
.tab-primary .tab-icon { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); box-shadow: 0 4px 12px color-mix(in srgb, var(--accent) 40%, transparent); margin-top: -14px; }
.tab-primary .tab-icon .icon { width: 26px; height: 26px; stroke-width: 2.4; }
.tab-primary { color: var(--text); }
body[data-editor="1"] .tabbar { display: none; }
body[data-editor="1"] .view { padding-bottom: calc(96px + var(--safe-b)); }

@media (min-width: 900px) {
  .app { display: grid; grid-template-columns: 232px minmax(0, 1fr); }
  .tabbar { display: none; }
  .view { padding: 20px 28px 48px; }
  body[data-editor="1"] .view { padding-bottom: 110px; }
  .sidenav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 18px 12px; border-right: 1px solid var(--border); background: var(--surface); }
  .brand { display: grid; grid-template-columns: auto 1fr; column-gap: 10px; align-items: center; text-decoration: none; color: var(--text); padding: 4px 10px 18px; }
  .brand-mark { grid-row: span 2; font-size: 1.7rem; }
  .brand-name { font-weight: 800; font-size: 1.3rem; letter-spacing: -0.02em; }
  .brand-sub { font-size: 0.75rem; color: var(--muted); }
  .sidenav-link { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--text); text-decoration: none; font-weight: 550; }
  .sidenav-link:hover { background: var(--surface-2); }
  .sidenav-link[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
  .sidenav-primary { background: var(--accent); color: var(--accent-ink); margin: 4px 0 10px; }
  .sidenav-primary:hover { background: color-mix(in srgb, var(--accent) 88%, black); }
  .sidenav-primary[aria-current="page"] { background: var(--accent); color: var(--accent-ink); }
  .sidenav-foot { margin-top: auto; padding: 10px 12px; }
}

.page-head { display: flex; align-items: flex-start; gap: 8px; margin: 4px 0 14px; }
.page-title-wrap { flex: 1; min-width: 0; }
.page-title { font-size: 1.55rem; font-weight: 800; letter-spacing: -0.02em; outline: none; }
.page-sub { color: var(--muted); margin: 2px 0 0; font-size: 0.92rem; }
.page-actions { display: flex; gap: 6px; align-items: center; }
.back { margin-left: -8px; }

.grid-2 { display: grid; gap: 14px; }
.col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
@media (min-width: 1000px) { .grid-2 { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); align-items: start; } }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; }
.page > .card, .page > .banner, .page > section { margin-bottom: 14px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.card-title { font-size: 1.02rem; font-weight: 700; }
.card-actions { display: flex; gap: 4px; }
.section-title { display: flex; justify-content: space-between; align-items: center; margin: 18px 2px 8px; }
.section-title h2 { font-size: 1.05rem; }

/* ---------- buttons ---------- */

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid transparent; font-weight: 650; cursor: pointer; text-decoration: none; background: none; white-space: nowrap; -webkit-tap-highlight-color: transparent; user-select: none; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, black); }
.btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: color-mix(in srgb, var(--surface-2) 85%, var(--text)); }
.btn-danger { background: var(--bad); color: #fff; }
.btn-text { color: var(--accent); padding: 0 10px; }
.btn-text:hover { background: var(--surface-2); }
.btn-danger-text { color: var(--bad); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 0.9rem; border-radius: 10px; }
.btn-lg { min-height: 52px; font-size: 1.05rem; padding: 0 20px; border-radius: 14px; }
.btn-icon { width: 44px; padding: 0; }
.btn-icon.btn-sm { width: 36px; }

/* ---------- inputs ---------- */

.input { width: 100%; min-height: 44px; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 16px; }
textarea.input { min-height: 64px; resize: vertical; }
.input:focus { border-color: var(--focus); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent); }
.input.invalid { border-color: var(--bad); }
.select { appearance: none; -webkit-appearance: none; padding-right: 30px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.input.num { text-align: right; font-variant-numeric: tabular-nums; }
.input-unit { display: flex; align-items: center; gap: 6px; min-width: 0; }
.input-unit .input { flex: 1; min-width: 0; }
.unit { color: var(--muted); font-size: 0.85rem; min-width: 26px; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 0 0 12px; min-width: 0; }
.field:last-child { margin-bottom: 0; }
.field-label { font-size: 0.82rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.field-hint { font-size: 0.82rem; color: var(--muted); font-weight: 400; text-transform: none; letter-spacing: 0; }
.fields-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.fields-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 420px) { .fields-3 { grid-template-columns: 1fr 1fr; } }
.check { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; cursor: pointer; }
.check input, .check-row input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; margin: 1px 0 0; }
.toggle-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.toggle-row:last-child { border-bottom: 0; }
.toggle-text { flex: 1; }
.switch { appearance: none; -webkit-appearance: none; width: 48px; height: 28px; border-radius: 99px; background: var(--track); position: relative; cursor: pointer; flex: none; transition: background 0.15s; margin: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform 0.15s; }
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(20px); }

.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 600; font-size: 0.92rem; }
.seg-btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.seg-sm .seg-btn { min-height: 34px; font-size: 0.85rem; padding: 0 10px; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips.scroll-x { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
.chips.scroll-x::-webkit-scrollbar { display: none; }
.chip { display: inline-flex; align-items: center; gap: 4px; min-height: 36px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface); color: var(--text); text-decoration: none; font-size: 0.9rem; font-weight: 600; cursor: pointer; white-space: nowrap; }
.chip:hover { border-color: var(--accent); }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.tag { display: inline-block; font-size: 0.72rem; font-weight: 700; padding: 1px 7px; border-radius: 99px; margin-left: 6px; vertical-align: 1px; }
.tag-soft { background: var(--surface-2); color: var(--muted); }
.tag-warn { background: var(--warn-soft); color: var(--warn); }
.tag-good { background: var(--good-soft); color: var(--good); }

/* ---------- banners, alerts, toasts, sheets ---------- */

.banner { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; border-radius: 12px; font-size: 0.92rem; }
.banner-info { background: var(--accent-soft); }
.banner-bad { background: var(--bad-soft); color: var(--text); display: block; margin: 8px 16px 0; }
.banner-warn { background: var(--warn-soft); }
.alerts { display: flex; flex-direction: column; gap: 8px; padding: 0 16px; max-width: 1100px; margin: 8px auto 0; }
.alerts:empty { display: none; }
.alert { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; background: var(--surface); border: 1px solid var(--accent); border-radius: 14px; box-shadow: var(--shadow); }
.alert-emoji { font-size: 1.4rem; }
.alert-text { flex: 1 1 160px; }
.alert-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.toasts { position: fixed; z-index: 60; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar-h) + var(--safe-b) + 12px); display: flex; flex-direction: column; gap: 8px; width: min(520px, calc(100vw - 24px)); pointer-events: none; }
body[data-editor="1"] .toasts { bottom: calc(88px + var(--safe-b)); }
@media (min-width: 900px) { .toasts { bottom: 24px; } }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 4px; padding: 6px 6px 6px 14px; border-radius: 12px; background: var(--text); color: var(--bg); box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2); animation: rise 0.18s ease-out; }
.toast .btn-text { color: color-mix(in srgb, var(--accent) 70%, var(--bg)); }
.toast .btn-text:hover { background: transparent; text-decoration: underline; }
.toast-msg { flex: 1; font-size: 0.93rem; }
.toast.bad { background: var(--bad); color: #fff; }
.toast.out { opacity: 0; transition: opacity 0.2s; }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(20, 14, 8, 0.45); display: flex; align-items: flex-end; justify-content: center; animation: fade 0.15s; }
.overlay.out { opacity: 0; transition: opacity 0.15s; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet { background: var(--surface); width: 100%; max-height: 88vh; border-radius: 20px 20px 0 0; display: flex; flex-direction: column; padding-bottom: var(--safe-b); animation: rise 0.18s ease-out; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 8px 4px 18px; }
.sheet-title { font-size: 1.1rem; }
.sheet-body { overflow-y: auto; padding: 4px 18px 12px; }
.sheet-actions { display: flex; gap: 8px; justify-content: flex-end; padding: 10px 18px 14px; border-top: 1px solid var(--border); }
.sheet-actions .btn { flex: 1; }
@media (min-width: 700px) {
  .overlay { align-items: center; }
  .sheet { width: min(480px, 92vw); border-radius: 18px; }
  .sheet-wide { width: min(760px, 94vw); }
  .sheet-actions .btn { flex: 0 0 auto; }
}

/* ---------- empty states ---------- */

.empty { text-align: center; padding: 18px 8px; }
.empty-icon { display: inline-grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; background: var(--surface-2); color: var(--muted); margin-bottom: 6px; }
.empty-icon .icon { width: 26px; height: 26px; }
.empty-title { font-weight: 700; margin: 4px 0; }
.empty .btn { margin-top: 8px; }

/* ---------- today ---------- */

.day-nav { display: flex; align-items: center; gap: 2px; }
.day-nav-label { font-weight: 650; font-size: 0.9rem; min-width: 70px; text-align: center; }
.hero { border-radius: 20px; padding: 16px; margin-bottom: 12px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }
.hero-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.hero-pill { font-size: 0.78rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; padding: 3px 10px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.hero-last { color: var(--muted); text-decoration: none; }
.hero-big { font-size: 1.55rem; margin: 10px 0 2px; letter-spacing: -0.01em; }
.hero-sub { color: var(--muted); margin: 0 0 12px; font-size: 0.92rem; }
.hero-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.hero-ok .hero-pill { background: var(--good-soft); color: var(--good); }
.hero-soon .hero-pill { background: var(--warn-soft); color: var(--warn); }
.hero-due { border-color: var(--accent); background: linear-gradient(180deg, var(--accent-soft), var(--surface) 70%); }
.hero-due .hero-pill { background: var(--accent); color: var(--accent-ink); }
.hero-overdue { border-color: var(--bad); background: linear-gradient(180deg, var(--bad-soft), var(--surface) 70%); }
.hero-overdue .hero-pill { background: var(--bad); color: #fff; }
.quick { margin: 0 0 12px; }
.quick-label { margin: 0 2px 6px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; font-size: 0.75rem; }
.upcoming { display: flex; align-items: center; gap: 4px; margin: 0 2px 12px; }
.upcoming .icon { width: 16px; height: 16px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(82px, 1fr)); gap: 10px 6px; }
.tile { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px; min-width: 0; }
.tile-num { height: 58px; display: flex; align-items: center; justify-content: center; font-weight: 750; font-size: 1.2rem; gap: 2px; }
.tile-unit { font-size: 0.7rem; color: var(--muted); font-weight: 600; }
.tile-label { font-size: 0.8rem; font-weight: 650; }
.tile-cov { font-size: 0.68rem; color: var(--muted); }
.ring-label { font-size: 13px; font-weight: 750; fill: var(--text); }
.ring-sub { font-size: 8.5px; fill: var(--muted); }
.card-sugg { border-color: color-mix(in srgb, var(--good) 40%, var(--border)); }
.sugg { margin: 6px 0 0; padding-left: 18px; }
.sugg li { margin: 4px 0; }
.total-line { margin-top: 8px; }

.entry-list { display: flex; flex-direction: column; }
.entry-row { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--border); text-decoration: none; color: var(--text); min-height: 56px; }
.entry-row:last-child { border-bottom: 0; }
.entry-row:hover { background: var(--surface-2); border-radius: 10px; }
.entry-icon { font-size: 1.4rem; width: 32px; text-align: center; flex: none; }
.entry-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.entry-title { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry-sub { color: var(--muted); font-size: 0.84rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry-chev { color: var(--muted); font-size: 1.4rem; }

.gbar { position: relative; height: 10px; border-radius: 99px; background: var(--track); margin: 8px 0; overflow: visible; }
.gbar-fill { height: 100%; border-radius: 99px; max-width: 100%; }
.gbar-mark { position: absolute; top: -3px; width: 2px; height: 16px; border-radius: 2px; }
.gbar-min { background: var(--good); }
.gbar-max { background: var(--bad); }
.check-list { display: flex; flex-direction: column; }
.check-row { display: flex; align-items: center; gap: 12px; padding: 10px 2px; border-bottom: 1px solid var(--border); cursor: pointer; min-height: 48px; }
.check-row:last-child { border-bottom: 0; }
.check-row.done .grow { text-decoration: line-through; color: var(--muted); }

/* ---------- editor ---------- */

.when-row { display: grid; grid-template-columns: 1.2fr 1fr; gap: 8px; }
.when .chips { margin-top: 8px; }
.when .chip { min-height: 34px; }
.when { margin-bottom: 14px; display: flex; flex-direction: column; gap: 6px; }
.seg-wrap .seg-btn { flex: 0 0 auto; }
.items { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.item { border: 1px solid var(--border); border-radius: 14px; padding: 10px; background: var(--bg); }
.item-top { display: flex; align-items: center; gap: 8px; }
.item-emoji { font-size: 1.3rem; width: 28px; text-align: center; }
.item-name { font-weight: 650; border-color: transparent; background: transparent; padding-left: 4px; }
.item-name:focus { background: var(--surface); }
.item-qty { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; }
.item-qty .qty { width: 76px; flex: none; }
.unit-select { width: auto; min-width: 84px; max-width: 150px; }
.item-summary { flex: 1 1 100%; padding-left: 2px; }
.item-details { margin-top: 6px; }
.item-details summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: 0.9rem; padding: 6px 2px; min-height: 36px; display: flex; align-items: center; gap: 4px; list-style: none; }
.item-details summary::-webkit-details-marker { display: none; }
.item-details summary::before { content: "▸"; display: inline-block; transition: transform 0.15s; }
.item-details[open] summary::before { transform: rotate(90deg); }
.ninputs { display: flex; flex-direction: column; gap: 8px; margin: 6px 0; }
.ngroup { border: 0; padding: 0; margin: 0; min-width: 0; }
.ngroup legend { font-weight: 700; font-size: 0.82rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; padding: 0; margin-bottom: 6px; }
.ngrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px 12px; }
.nfield { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.nlabel { font-size: 0.82rem; font-weight: 600; }
.nfield .unit { min-width: 30px; }
.food-search { margin-top: 4px; }
.search-box { position: relative; display: flex; align-items: center; }
.search-box .icon { position: absolute; left: 12px; color: var(--muted); pointer-events: none; }
.search-input { padding-left: 40px; }
.search-results { display: flex; flex-direction: column; margin-top: 6px; max-height: 330px; overflow-y: auto; border-radius: 12px; }
.result { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border: 0; border-bottom: 1px solid var(--border); background: none; text-align: left; cursor: pointer; min-height: 52px; width: 100%; }
.result:hover, .result:focus-visible { background: var(--surface-2); }
.result-emoji { font-size: 1.25rem; width: 30px; text-align: center; flex: none; }
.result-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.result-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-sub { font-size: 0.82rem; color: var(--muted); }
.result-add { color: var(--accent); }
.result-quick .result-name { color: var(--accent); }
.fav-dot { color: var(--warn); }
.mt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 10px; }
.mt-cell { display: flex; flex-direction: column; }
.mt-val { font-weight: 750; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.mt-unit { font-size: 0.75rem; color: var(--muted); margin-left: 2px; font-weight: 600; }
.mt-label { font-size: 0.8rem; color: var(--muted); }
.mt-cov { color: var(--warn); font-weight: 800; }
.more-actions { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; margin: 4px 0 16px; }
.savebar { position: fixed; z-index: 35; left: 0; right: 0; bottom: 0; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 10px 16px calc(10px + var(--safe-b)); background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--border); }
.savebar .btn { min-height: 48px; }
.savebar-note { flex: 1 1 100%; text-align: center; margin-top: -4px; font-size: 0.75rem; }
@media (min-width: 900px) { .savebar { left: 232px; padding-left: 28px; padding-right: 28px; } .savebar-note { flex: 0 0 auto; order: -1; margin: 0; } }

/* ---------- lists (cookbook etc.) ---------- */

.list { display: flex; flex-direction: column; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--border); color: var(--text); text-decoration: none; min-height: 56px; }
.list-row:last-child { border-bottom: 0; }
.list-row:hover { background: var(--surface-2); border-radius: 10px; }
.list-emoji { font-size: 1.35rem; width: 32px; text-align: center; flex: none; }
.list-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.list-title { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-sub { color: var(--muted); font-size: 0.84rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-side { display: flex; align-items: center; gap: 2px; flex: none; }
.star-btn[aria-pressed="true"] { color: var(--warn); }
.star-btn[aria-pressed="true"] .icon { fill: currentColor; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.toolbar .search-box { flex: 1 1 220px; }

/* ---------- charts and tables ---------- */

.chart { display: block; max-width: 100%; height: auto; overflow: visible; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .baseline { stroke: var(--muted); stroke-width: 1; }
.chart .axis { font-size: 10px; fill: var(--muted); font-family: var(--font); }
.chart .goal-min { stroke: var(--good); stroke-width: 2; stroke-dasharray: 5 4; }
.chart .goal-max { stroke: var(--bad); stroke-width: 2; stroke-dasharray: 5 4; }
.chart .line { stroke: var(--accent); stroke-width: 2.2; }
.chart .dot { fill: var(--accent); }
.chart .clickable { cursor: pointer; }
.chart-bar:hover { opacity: 0.85; }
.spark path { stroke: var(--accent); stroke-width: 1.6; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.8rem; color: var(--muted); margin-top: 6px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { display: inline-block; width: 12px; height: 10px; border-radius: 3px; }
.legend i.l-min { height: 0; border-top: 2px dashed var(--good); }
.legend i.l-max { height: 0; border-top: 2px dashed var(--bad); }
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table.data { border-collapse: collapse; width: 100%; font-size: 0.88rem; font-variant-numeric: tabular-nums; }
table.data th, table.data td { padding: 7px 8px; border-bottom: 1px solid var(--border); text-align: right; white-space: nowrap; }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
td.ok { color: var(--good); font-weight: 650; }
td.over { color: var(--bad); font-weight: 650; }
td.under { color: var(--warn); }
.contrib { display: flex; flex-direction: column; gap: 8px; }
.contrib-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; align-items: center; }
.contrib-bar { grid-column: 1 / -1; height: 6px; border-radius: 99px; background: var(--track); overflow: hidden; }
.contrib-bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.stat { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.stat b { display: block; font-size: 1.25rem; }
.stat span { font-size: 0.8rem; color: var(--muted); }

/* ---------- more menu ---------- */

.menu-list { display: flex; flex-direction: column; }
.menu-item { display: flex; align-items: center; gap: 14px; padding: 14px 6px; border-bottom: 1px solid var(--border); text-decoration: none; color: var(--text); font-weight: 600; min-height: 56px; }
.menu-item:last-child { border-bottom: 0; }
.menu-item .icon { color: var(--accent); width: 22px; height: 22px; }
.menu-item small { display: block; font-weight: 400; color: var(--muted); }

/* ---------- welcome ---------- */

.welcome { max-width: 640px; margin: 0 auto; }
.welcome-hero { text-align: center; padding: 24px 8px 10px; }
.welcome-hero .mark { font-size: 3rem; }
.welcome-hero h1 { font-size: 2rem; letter-spacing: -0.03em; }
.choice-list { display: flex; flex-direction: column; gap: 8px; }
.choice { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border: 1px solid var(--border); border-radius: 14px; cursor: pointer; background: var(--surface); }
.choice input { margin-top: 3px; width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice b { display: block; }

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

/* ---------- goals ---------- */

.goal-row { padding: 10px 0; border-bottom: 1px solid var(--border); }
.goal-row:last-of-type { border-bottom: 0; }
.goal-name { margin-bottom: 6px; }
.goal-inputs .field { margin: 0; }
.chart-wrap { margin: 6px 0 2px; overflow: hidden; }
.metric-grid { display: grid; gap: 14px; margin-bottom: 14px; }
@media (min-width: 1100px) { .metric-grid { grid-template-columns: 1fr 1fr; } }

/* ---------- v0.2: log sheet, time field, modules ---------- */

.log-sheet section { margin-bottom: 14px; }
.log-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; margin-top: 6px; }
.log-tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 84px; padding: 8px 6px; border-radius: 14px; border: 1px solid var(--border); background: var(--bg); color: var(--text); text-decoration: none; cursor: pointer; text-align: center; font: inherit; }
.log-tile:hover, .log-tile:focus-visible { border-color: var(--accent); background: var(--accent-soft); }
.lt-emoji { font-size: 1.6rem; line-height: 1.1; }
.lt-label { font-weight: 650; font-size: 0.88rem; }
.lt-sub { font-size: 0.72rem; color: var(--muted); }
.when-field { margin-bottom: 14px; }
.when-summary { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 8px; }
.when-summary .field-label { grid-column: 1 / -1; }
.when-text { min-height: 36px; display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.opt-moment { padding: 8px 0; border-bottom: 1px solid var(--border); }
.opt-moment:last-of-type { border-bottom: 0; }
.opt-moment .when { margin-bottom: 4px; }
.nav-emoji { width: 22px; text-align: center; font-size: 1.05rem; flex: none; }
.good-text { color: var(--good); font-weight: 650; }
.day-group { margin-bottom: 10px; }
.list-row.compact { min-height: 44px; padding: 6px 2px; }
.module-picks .check { border-bottom: 1px solid var(--border); }
.dev-list { margin: 0; padding-left: 18px; }
.dev-list li { margin: 6px 0; }
.legal h3 { font-size: 0.98rem; margin: 14px 0 4px; }
.legal section:first-child h3 { margin-top: 0; }

/* routines */
.routine { padding: 6px 0 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.routine:last-child { border-bottom: 0; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--track); margin-left: 3px; vertical-align: middle; }
.dot-part { background: color-mix(in srgb, var(--good) 45%, var(--track)); }
.dot-full { background: var(--good); }
.step-row { flex-wrap: nowrap; margin-bottom: 6px; }

/* kitchen */
.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 0.78rem; font-weight: 750; padding: 2px 9px; border-radius: 99px; white-space: nowrap; }
.pill-good { background: var(--good-soft); color: var(--good); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-bad { background: var(--bad-soft); color: var(--bad); }
.recipe-list { display: flex; flex-direction: column; gap: 10px; }
.recipe-card { border: 1px solid var(--border); border-radius: 14px; padding: 10px 12px; background: var(--bg); }
.small-chips { gap: 6px; margin: 8px 0; }
.ing-chip { display: inline-flex; align-items: center; gap: 5px; font-size: 0.82rem; padding: 3px 9px; border-radius: 99px; background: var(--surface); border: 1px solid var(--border); }
.ing-missing { border-color: var(--bad); color: var(--bad); }
.ing-low { border-color: var(--warn); }
.ing-optional { opacity: 0.7; border-style: dashed; }
.stock-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex: none; }
.stock-have { background: var(--good); }
.stock-low { background: var(--warn); }
.stock-out { background: var(--bad); }
.stock-unknown { background: var(--neutral); }
.cat-head { margin: 12px 2px 2px; }
.ing-row { display: flex; align-items: center; gap: 8px; padding: 8px 2px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.ing-main { display: flex; align-items: center; gap: 10px; flex: 1 1 180px; min-width: 0; text-decoration: none; color: inherit; }
.ing-side { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.stock-seg .seg-btn { min-height: 32px; padding: 0 9px; }
.cart-btn { opacity: 0.45; }
.cart-btn[aria-pressed="true"] { opacity: 1; background: var(--accent-soft); }
.quick-add { display: flex; flex-direction: column; gap: 8px; }
.recipe-lines { display: flex; flex-direction: column; }
.recipe-line { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.recipe-line .check { padding: 0; font-size: 0.85rem; }
.recipe-line .input { min-height: 38px; }

/* food review */
.page-wide { max-width: none; }
.review-table table.data td, .review-table table.data th { white-space: nowrap; }
.review-table .sticky-col { position: sticky; left: 0; background: var(--surface); z-index: 1; text-align: left; max-width: 46vw; overflow: hidden; text-overflow: ellipsis; }
.review-table .notes-col { white-space: normal; min-width: 160px; max-width: 260px; text-align: left; color: var(--muted); }
.click-row { cursor: pointer; }
.click-row:hover td { background: var(--surface-2); }
.row-link { color: var(--text); text-decoration: none; font-weight: 600; }
.th-btn { background: none; border: 0; padding: 0; font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; cursor: pointer; }
.th-btn.sorted { color: var(--accent); }
.review-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.review-card { display: block; border: 1px solid var(--border); border-left-width: 4px; border-radius: 14px; padding: 10px 12px; color: var(--text); text-decoration: none; background: var(--bg); }
.review-card:hover { border-color: var(--accent); }
.v-good { --v: var(--good); } .v-okay { --v: var(--neutral); } .v-suspect { --v: var(--warn); } .v-problem { --v: var(--bad); }
.review-card.v-good, .review-card.v-okay, .review-card.v-suspect, .review-card.v-problem { border-left-color: var(--v); }
.pill.v-good { background: var(--good-soft); color: var(--good); }
.pill.v-okay { background: var(--surface-2); color: var(--muted); }
.pill.v-suspect { background: var(--warn-soft); color: var(--warn); }
.pill.v-problem { background: var(--bad-soft); color: var(--bad); }
.flag { font-size: 0.75rem; font-weight: 650; padding: 2px 8px; border-radius: 99px; }
.flag-bad { background: var(--bad-soft); color: var(--bad); }
.flag-good { background: var(--good-soft); color: var(--good); }
.alt-row { flex-wrap: nowrap; margin-bottom: 6px; }
@media (max-width: 480px) { .alt-row { flex-wrap: wrap; } }

/* barcode */
.barcode-video { width: 100%; max-height: 50vh; border-radius: 12px; background: #000; margin-top: 10px; object-fit: cover; }
.settings-hub .menu-item { padding: 10px 4px; min-height: 48px; }
.view-options { margin-top: 10px; }
.view-options summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: 0.9rem; min-height: 36px; display: flex; align-items: center; }
