/* Disher — "enamelware": white enamel, cobalt rim, saffron for meals logged. */

@font-face {
  font-family: "Bricolage Grotesque";
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  src: url("fonts/bricolage-grotesque-latin-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Bricolage Grotesque";
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  src: url("fonts/bricolage-grotesque-latin-ext-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Figtree";
  font-style: normal;
  font-display: swap;
  font-weight: 300 900;
  src: url("fonts/figtree-latin-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Figtree";
  font-style: normal;
  font-display: swap;
  font-weight: 300 900;
  src: url("fonts/figtree-latin-ext-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---------- tokens ---------- */
:root {
  --bg: #fafaf7;
  --surface: #ffffff;
  --surface-2: #f2f3f7;
  --ink: #17203a;
  --muted: #5e6680;
  --faint: #8d93a6;
  --line: #e4e6ee;
  --line-strong: #cfd3e0;
  --rim: #1f3fa8;
  --rim-hover: #18338a;
  --rim-soft: #e8ecfa;
  --rim-ink: #ffffff;
  --saffron: #f2b21b;
  --saffron-soft: #fff4d6;
  --saffron-ink: #3a2a00;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --ok: #1d7a4a;
  --ok-soft: #e6f4ec;
  --focus: 0 0 0 3px color-mix(in srgb, var(--rim) 35%, transparent);
  --shadow-1: 0 1px 2px rgb(23 32 58 / .06), 0 1px 1px rgb(23 32 58 / .04);
  --shadow-2: 0 10px 30px -12px rgb(23 32 58 / .25), 0 2px 6px rgb(23 32 58 / .06);

  --font-display: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --font-body: "Figtree", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-pill: 999px;

  --sidebar: 232px;
  --tabbar: 56px;
  /* Clear the iPhone home indicator without a tall empty band under the tabs. */
  --tabbar-pad: max(6px, calc(env(safe-area-inset-bottom) - 18px));
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1320;
    --surface: #171c2c;
    --surface-2: #1e2436;
    --ink: #e8ebf4;
    --muted: #a2a9be;
    --faint: #737a90;
    --line: #262d42;
    --line-strong: #353d56;
    --rim: #7f9cff;
    --rim-hover: #9cb3ff;
    --rim-soft: #1f2846;
    --rim-ink: #0f1320;
    --saffron: #f5c04a;
    --saffron-soft: #3a2f14;
    --saffron-ink: #2a1e00;
    --danger: #ff8a80;
    --danger-soft: #3b1c1c;
    --ok: #6fd3a0;
    --ok-soft: #173326;
    --shadow-1: 0 1px 2px rgb(0 0 0 / .3);
    --shadow-2: 0 12px 32px -12px rgb(0 0 0 / .6);
    color-scheme: dark;
  }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.55 var(--font-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg { display: block; }
a { color: var(--rim); text-decoration: none; }
a:hover { color: var(--rim-hover); }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-sm); }
::selection { background: var(--rim-soft); }

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin: 0;
  text-wrap: balance;
}
h1 { font-size: clamp(1.9rem, 1.4rem + 2vw, 2.6rem); font-weight: 700; letter-spacing: -0.03em; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; letter-spacing: -0.01em; }
p { margin: 0; }
small, .meta { color: var(--muted); font-size: .875rem; }
.faint { color: var(--faint); }

.icon { width: 20px; height: 20px; flex: none; }
.icon-sm { width: 16px; height: 16px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- app shell ---------- */
.shell { min-height: 100dvh; }

.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar);
  display: flex; flex-direction: column; gap: 4px;
  padding: 22px 14px;
  border-right: 1px solid var(--line);
  background: var(--surface);
}
.wordmark {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 10px 22px;
  font-family: var(--font-display); font-weight: 750; font-size: 1.45rem;
  letter-spacing: -0.035em; color: var(--ink);
}
.wordmark:hover { color: var(--ink); }
.wordmark-plate {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--surface); border: 4px solid var(--rim);
  box-shadow: inset 0 0 0 3px var(--surface), inset 0 0 0 4px var(--line-strong);
}
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; border-radius: var(--r-sm);
  color: var(--muted); font-weight: 550;
}
.nav-link:hover { color: var(--ink); background: var(--surface-2); }
.nav-link[aria-current="page"] { color: var(--rim); background: var(--rim-soft); }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 12px; }
.account { display: flex; align-items: center; gap: 10px; padding: 8px 12px; color: var(--ink); font-weight: 600; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--rim-soft); color: var(--rim); font-weight: 700; font-size: .85rem; text-transform: uppercase;
}
.sidebar-foot form { margin: 0; }
.sidebar-foot .nav-link { width: 100%; background: none; border: 0; font: inherit; cursor: pointer; text-align: left; }

.main { margin-left: var(--sidebar); padding: 40px clamp(20px, 4vw, 56px) 64px; }
.page { max-width: 920px; margin: 0 auto; }
.page-narrow { max-width: 640px; margin: 0 auto; }

.tabbar, .topbar { display: none; }

@media (max-width: 860px) {
  .sidebar { display: none; }
  .main { margin-left: 0; padding: 20px 16px calc(var(--tabbar) + var(--tabbar-pad) + 32px); }
  .topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: calc(12px + env(safe-area-inset-top)) 16px 12px; background: var(--bg);
  }
  .topbar .wordmark { padding: 0; font-size: 1.25rem; }
  .topbar .avatar-link { display: flex; }
  .tabbar {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    position: fixed; z-index: 20; left: 0; right: 0; bottom: 0;
    height: calc(var(--tabbar) + var(--tabbar-pad));
    padding: 0 env(safe-area-inset-right) var(--tabbar-pad) env(safe-area-inset-left);
    transform: translateZ(0);  /* keeps iOS from jittering the bar while scrolling */
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: saturate(1.4) blur(14px);
    -webkit-backdrop-filter: saturate(1.4) blur(14px);
    border-top: 1px solid var(--line);
  }
  .tab {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    padding-top: 4px; color: var(--faint); font-size: .7rem; font-weight: 600;
  }
  .tab[aria-current="page"] { color: var(--rim); }
  .tab .icon { width: 22px; height: 22px; }
}

/* ---------- page header ---------- */
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  margin-bottom: 24px;
}
.page-head .lede { margin-top: 8px; color: var(--muted); max-width: 60ch; }
.back {
  display: inline-flex; align-items: center; gap: 6px; margin-bottom: 14px;
  color: var(--muted); font-weight: 550; font-size: .925rem;
}
.back:hover { color: var(--ink); }

/* ---------- buttons ---------- */
.btn {
  --btn-bg: var(--surface); --btn-fg: var(--ink); --btn-line: var(--line-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 16px;
  border: 1px solid var(--btn-line); border-radius: var(--r-pill);
  background: var(--btn-bg); color: var(--btn-fg);
  font: 600 .95rem/1 var(--font-body); white-space: nowrap;
  cursor: pointer; text-decoration: none;
  transition: background-color .15s, border-color .15s, color .15s, transform .1s;
}
.btn:hover { --btn-bg: var(--surface-2); color: var(--btn-fg); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn.htmx-request { opacity: .6; cursor: progress; }
.btn-primary { --btn-bg: var(--rim); --btn-fg: var(--rim-ink); --btn-line: var(--rim); }
.btn-primary:hover { --btn-bg: var(--rim-hover); --btn-line: var(--rim-hover); }
.btn-ghost { --btn-line: transparent; --btn-bg: transparent; color: var(--muted); }
.btn-ghost:hover { --btn-bg: var(--surface-2); color: var(--ink); }
.btn-danger { --btn-bg: var(--danger); --btn-fg: #fff; --btn-line: var(--danger); }
.btn-danger:hover { --btn-bg: color-mix(in srgb, var(--danger) 88%, black); }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: .875rem; }
.btn-icon { width: 36px; min-height: 36px; padding: 0; }
.btn-block { width: 100%; }
.inline { display: inline; margin: 0; }

/* The plate: logs a meal. Cobalt rim, fills with saffron once logged. */
.plate {
  position: relative; flex: none;
  width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center;
  border: 3px solid var(--rim);
  background: var(--surface);
  color: var(--rim);
  box-shadow: inset 0 0 0 3px var(--surface), inset 0 0 0 4px var(--line);
  cursor: pointer;
  transition: transform .12s, background-color .2s;
}
.plate:hover { background: var(--rim-soft); box-shadow: inset 0 0 0 3px var(--rim-soft), inset 0 0 0 4px var(--line-strong); }
.plate:active { transform: scale(.93); }
.plate .icon { width: 20px; height: 20px; }
.plate.is-logged {
  border-color: var(--saffron); background: var(--saffron); color: var(--saffron-ink);
  box-shadow: inset 0 0 0 3px var(--saffron);
  animation: plate-fill .45s cubic-bezier(.2, .9, .3, 1.4);
}
@keyframes plate-fill {
  0% { transform: scale(.8); background: var(--surface); }
  60% { transform: scale(1.08); }
  100% { transform: scale(1); }
}
.plate-lg { width: 64px; height: 64px; border-width: 4px; }
.plate-lg .icon { width: 26px; height: 26px; }

/* ---------- forms ---------- */
label { display: block; }
.field { display: grid; gap: 6px; margin-bottom: 18px; }
.field > span:first-child, .label { font-weight: 600; font-size: .925rem; }
.hint { color: var(--muted); font-size: .85rem; }
input[type="text"], input[type="search"], input[type="password"], input[type="date"],
input:not([type]), select, textarea {
  width: 100%; min-height: 44px; padding: 10px 14px;
  border: 1px solid var(--line-strong); border-radius: var(--r-md);
  background: var(--surface); color: var(--ink);
  font: inherit; font-size: 1rem;
  transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--rim); box-shadow: var(--focus); }
select {
  appearance: none; -webkit-appearance: none; padding-right: 40px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238d93a6' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 18px;
}
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--rim); margin: 0; flex: none; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
fieldset { border: 0; margin: 0 0 18px; padding: 0; min-width: 0; }
legend { padding: 0; margin-bottom: 8px; font-weight: 600; font-size: .925rem; }

.search {
  position: relative; display: block;
}
.search .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.search input { padding-left: 44px; min-height: 50px; border-radius: var(--r-pill); font-size: 1.02rem; box-shadow: var(--shadow-1); }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: clamp(18px, 3vw, 28px);
}

/* ---------- flash ---------- */
.flash {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; margin-bottom: 20px; border-radius: var(--r-md);
  font-weight: 550; font-size: .95rem;
}
.flash-success { background: var(--ok-soft); color: var(--ok); }
.flash-error { background: var(--danger-soft); color: var(--danger); }
.flash a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }

/* ---------- chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: var(--r-pill);
  background: var(--surface-2); color: var(--muted);
  font-size: .8rem; font-weight: 600; line-height: 1.5; white-space: nowrap;
}
a.chip:hover { background: var(--rim-soft); color: var(--rim); }
.chip-on { background: var(--rim); color: var(--rim-ink); }
a.chip-on:hover { background: var(--rim-hover); color: var(--rim-ink); }
.chip-remove { all: unset; cursor: pointer; display: inline-flex; opacity: .7; }
.chip-remove:hover, .chip-remove:focus-visible { opacity: 1; }
.chip .icon { width: 13px; height: 13px; }

/* Filter toggles: chip-shaped checkboxes */
.toggles { display: flex; flex-wrap: wrap; gap: 8px; }
.toggle { position: relative; }
.toggle input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.toggle span {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border: 1px solid var(--line-strong); border-radius: var(--r-pill);
  background: var(--surface); font-size: .875rem; font-weight: 550; color: var(--ink);
  transition: background-color .15s, border-color .15s;
}
.toggle span small { font-size: .75rem; color: var(--faint); }
.toggle input:checked + span { background: var(--rim); border-color: var(--rim); color: var(--rim-ink); }
.toggle input:checked + span small { color: color-mix(in srgb, var(--rim-ink) 75%, transparent); }
.toggle input:focus-visible + span { box-shadow: var(--focus); }

/* ---------- dish list ---------- */
.toolbar { display: grid; gap: 12px; margin-bottom: 8px; }
.toolbar-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.toolbar-row select { width: auto; min-height: 38px; padding-block: 6px; border-radius: var(--r-pill); font-size: .9rem; font-weight: 550; }
.toolbar .count { margin-left: auto; color: var(--muted); font-size: .9rem; }

.disclosure { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
.disclosure > summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; gap: 10px; padding: 12px 16px; font-weight: 600;
}
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary .chev { margin-left: auto; color: var(--faint); transition: transform .2s; }
.disclosure[open] > summary .chev { transform: rotate(180deg); }
.disclosure-body { padding: 4px 16px 16px; display: grid; gap: 16px; }
.scroll-box { max-height: 220px; overflow-y: auto; padding: 2px; }
.active-filters { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.active-filters .clear { font-size: .875rem; font-weight: 600; margin-left: 4px; }

.dish-list { list-style: none; margin: 8px 0 0; padding: 0; }
.dish-row {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 4px; border-bottom: 1px solid var(--line);
}
.dish-row:last-child { border-bottom: 0; }
.dish-body { flex: 1; min-width: 0; display: grid; gap: 6px; }
.dish-name {
  font-family: var(--font-display); font-weight: 620; font-size: 1.22rem; letter-spacing: -0.02em;
  color: var(--ink); line-height: 1.2;
}
.dish-name:hover { color: var(--rim); }
.eat-cell { display: flex; align-items: center; gap: 14px; flex: none; }
.eat-cell form { margin: 0; }
.eat-stat { text-align: right; line-height: 1.25; }
.eat-stat strong { display: block; font-family: var(--font-display); font-weight: 650; font-size: 1.05rem; }
.eat-stat span { color: var(--muted); font-size: .8rem; }
@media (max-width: 520px) {
  .dish-row { gap: 12px; padding-block: 14px; }
  .eat-stat strong { font-size: .95rem; }
}

.empty {
  text-align: center; padding: 56px 20px; border: 1.5px dashed var(--line-strong); border-radius: var(--r-lg);
  color: var(--muted);
}
.empty h2 { color: var(--ink); margin-bottom: 8px; }
.empty .btn { margin-top: 18px; }
.empty-inline { color: var(--muted); padding: 12px 0; }

/* ---------- dish detail ---------- */
.dish-hero { display: grid; gap: 14px; margin-bottom: 28px; }
.dish-hero h1 { font-size: clamp(2.2rem, 1.5rem + 3vw, 3.4rem); }
.dish-hero .description { font-size: 1.1rem; color: var(--muted); max-width: 62ch; white-space: pre-line; }
.hero-actions { display: flex; gap: 8px; }

.detail-grid { display: grid; grid-template-columns: 1fr 1.1fr; gap: 20px; align-items: start; }
@media (max-width: 760px) { .detail-grid { grid-template-columns: 1fr; } }
.panel-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }

.ingredients { list-style: none; margin: 0; padding: 0; }
.ingredients li {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding: 9px 0; border-bottom: 1px dashed var(--line);
}
.ingredients li:last-child { border-bottom: 0; }
.ingredients a { color: var(--ink); font-weight: 550; }
.ingredients a:hover { color: var(--rim); }
.ingredients .note { color: var(--muted); font-size: .9rem; text-align: right; }

.log-card { display: grid; gap: 18px; }
.log-main { display: flex; align-items: center; gap: 16px; }
.log-main p { color: var(--muted); }
.log-main strong { color: var(--ink); font-family: var(--font-display); font-size: 1.15rem; display: block; }
.log-more > summary { cursor: pointer; color: var(--rim); font-weight: 600; font-size: .925rem; list-style: none; }
.log-more > summary::-webkit-details-marker { display: none; }
.log-more[open] > summary { margin-bottom: 12px; }
.log-more .row { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; margin-bottom: 10px; }
@media (max-width: 420px) { .log-more .row { grid-template-columns: 1fr; } }

.entries { list-style: none; margin: 0; padding: 0; }
.entries li {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 0; border-top: 1px solid var(--line);
}
.entries .when { font-weight: 550; }
.entries .note { color: var(--muted); font-size: .9rem; }
.entries .btn-icon { color: var(--faint); }
.entries .btn-icon:hover { color: var(--danger); }

/* ---------- ideas ---------- */
.ideas { margin-top: 36px; }
.ideas-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.ideas-head h2 { display: flex; align-items: center; gap: 8px; margin-right: auto; }
.ideas-head h2 .icon { color: var(--saffron); }
.seg { display: inline-flex; padding: 4px; gap: 4px; border-radius: var(--r-pill); background: var(--surface-2); }
.seg .btn { min-height: 34px; border: 0; --btn-bg: transparent; color: var(--muted); }
.seg .btn:hover { --btn-bg: var(--surface); color: var(--ink); }
.loading { display: none; align-items: center; gap: 10px; color: var(--muted); font-weight: 550; padding: 8px 0 16px; }
.htmx-request.loading, .htmx-request .loading { display: flex; }
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid var(--rim-soft); border-top-color: var(--rim);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.idea-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
/* Draft: not on the list yet (dashed). Matched: already a dish (solid rim). */
.idea {
  display: flex; flex-direction: column; gap: 10px;
  padding: 18px; border-radius: var(--r-lg);
  border: 1.5px dashed var(--line-strong); background: var(--surface);
}
.idea.is-match { border: 1.5px solid var(--rim); background: var(--rim-soft); }
.idea h3 { font-size: 1.12rem; }
.idea .why { color: var(--muted); font-size: .95rem; flex: 1; }
.idea .uses { font-size: .875rem; color: var(--ink); }
.idea .uses span { color: var(--faint); }
.idea-foot { margin-top: 4px; }
.ideas-foot { display: flex; align-items: center; gap: 12px; margin-top: 16px; color: var(--faint); font-size: .85rem; }

/* ---------- dish form ---------- */
.ingredient-rows { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 8px; }
.ingredient-row { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.row-actions { display: inline-flex; gap: 2px; }
.row-actions .btn-icon { width: 32px; min-height: 32px; color: var(--faint); }
.row-actions .btn-icon:hover { color: var(--ink); }
@media (max-width: 560px) {
  .ingredient-row { grid-template-columns: 1fr 1fr; padding-bottom: 8px; border-bottom: 1px dashed var(--line); }
  .row-actions { grid-column: 1 / -1; justify-content: flex-end; }
}
.tag-editor {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  min-height: 44px; padding: 6px 8px;
  border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface);
}
.tag-editor:focus-within { border-color: var(--rim); box-shadow: var(--focus); }
.tag-editor .chip { background: var(--rim-soft); color: var(--rim); }
.tag-editor input[type="text"] {
  flex: 1 1 8rem; min-width: 6rem; min-height: 30px; border: 0; padding: 4px; box-shadow: none; background: transparent;
}
.tag-editor input[type="text"]:focus { box-shadow: none; }
.danger-zone { margin-top: 28px; border-color: color-mix(in srgb, var(--danger) 30%, var(--line)); }
.danger-zone h2 { color: var(--danger); margin-bottom: 8px; }
.danger-zone p { color: var(--muted); margin-bottom: 14px; }

/* ---------- history (a timeline: entries are a dated sequence) ---------- */
.filters-bar { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; gap: 10px; align-items: end; margin-bottom: 28px; }
.filters-bar .field { margin: 0; }
@media (max-width: 680px) { .filters-bar { grid-template-columns: 1fr 1fr; } .filters-bar .field:nth-child(3) { grid-column: 1 / -1; } }
.timeline { position: relative; padding-left: 28px; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 8px; bottom: 8px; width: 2px; background: var(--line); border-radius: 2px; }
.day { position: relative; margin-bottom: 26px; }
.day::before {
  content: ""; position: absolute; left: -28px; top: 4px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--rim);
}
.day-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.day-head h2 { font-size: 1.05rem; }
.day .entries li:first-child { border-top: 0; }
.day .entries a { color: var(--ink); font-weight: 600; }
.day .entries a:hover { color: var(--rim); }
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 24px; color: var(--muted); font-size: .9rem; }

/* ---------- reports ---------- */
.range-bar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 24px; }
.seg a.btn[aria-current="true"] { --btn-bg: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
.range-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.range-form input { width: auto; min-height: 38px; padding: 6px 10px; font-size: .9rem; }
.summary-line {
  font-family: var(--font-display); font-weight: 500; font-size: clamp(1.25rem, 1rem + 1.2vw, 1.7rem);
  letter-spacing: -0.02em; line-height: 1.35; margin-bottom: 28px; max-width: 34ch;
}
.summary-line strong { font-weight: 700; color: var(--rim); }
.report-grid { display: grid; gap: 20px; }
.report-grid-2 { display: grid; gap: 20px; grid-template-columns: 1fr 1fr; align-items: start; }
@media (max-width: 760px) { .report-grid-2 { grid-template-columns: 1fr; } }
.chart-box { position: relative; width: 100%; height: 260px; margin: 6px 0 14px; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .925rem; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: .8rem; padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td a { color: var(--ink); font-weight: 550; }
td a:hover { color: var(--rim); }
.bar-cell { display: flex; align-items: center; gap: 10px; }
.minibar { height: 6px; border-radius: 3px; background: var(--rim); opacity: .85; }

/* ---------- tags, admin ---------- */
.rename { display: flex; gap: 6px; align-items: center; }
.rename input { min-height: 36px; padding: 6px 10px; font-size: .9rem; max-width: 220px; }
.users td { vertical-align: top; }
.users .inactive td:first-child { opacity: .55; }
.users select, .users input { min-height: 36px; padding: 6px 10px; font-size: .875rem; }
.users select { padding-right: 34px; width: auto; }
.users input { max-width: 200px; }
.users .stack { display: flex; gap: 6px; align-items: center; }
.badge { display: inline-block; padding: 1px 8px; border-radius: var(--r-pill); font-size: .75rem; font-weight: 650; }
.badge-admin { background: var(--rim-soft); color: var(--rim); }
.badge-muted { background: var(--surface-2); color: var(--muted); }
@media (max-width: 760px) {
  .users thead { display: none; }
  .users tr { display: grid; gap: 8px; padding: 14px 0; border-bottom: 1px solid var(--line); }
  .users td { padding: 0; border: 0; }
}

/* ---------- login ---------- */
.auth {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px;
  background:
    radial-gradient(circle at 50% 50%, transparent 0 262px, var(--line) 263px 264px, transparent 265px),
    radial-gradient(circle at 50% 50%, var(--surface) 0 300px, transparent 301px),
    radial-gradient(circle at 50% 50%, var(--rim) 0 318px, transparent 319px),
    radial-gradient(circle at 50% 50%, var(--surface) 0 334px, transparent 335px),
    var(--bg);
}
.auth-card { width: min(400px, 100%); }
.auth-card .wordmark { justify-content: center; font-size: 2.2rem; padding: 0 0 6px; }
.auth-card .wordmark-plate { width: 34px; height: 34px; }
.auth-card .tagline { text-align: center; color: var(--muted); margin-bottom: 24px; }
.auth-card .card { box-shadow: var(--shadow-2); }
@media (max-width: 700px), (max-height: 680px) { .auth { background: var(--bg); } }
.auth-card .card { position: relative; }

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

/* ---------- odds and ends ---------- */
.card > h2 { margin-bottom: 16px; }
.card .disclosure { border-radius: var(--r-md); margin-top: 4px; }
.card .disclosure .table-scroll { padding: 0 16px 12px; }
.ingredient-filter { position: relative; }
.ingredient-filter > summary { padding: 7px 14px; border-radius: var(--r-pill); font-size: .9rem; }
.ingredient-filter[open] { flex-basis: 100%; }
.disclosure-plain > summary { list-style: none; cursor: pointer; margin-bottom: 0; }
.disclosure-plain > summary::-webkit-details-marker { display: none; }
.disclosure-plain > summary .meta { display: inline-flex; align-items: center; gap: 6px; }
.disclosure-plain[open] > summary { margin-bottom: 14px; }
.disclosure-plain[open] > summary .chev { transform: rotate(180deg); }
.logout-row { margin-top: 16px; }
progress.minibar {
  display: block; width: 100%; max-width: 220px; height: 6px; margin-top: 6px;
  appearance: none; -webkit-appearance: none; border: 0; border-radius: 3px;
  background: var(--surface-2); color: var(--rim);
}
progress.minibar::-webkit-progress-bar { background: var(--surface-2); border-radius: 3px; }
progress.minibar::-webkit-progress-value { background: var(--rim); border-radius: 3px; }
progress.minibar::-moz-progress-bar { background: var(--rim); border-radius: 3px; }
.filter-chips .chip {
  padding: 5px 12px; font-size: .85rem; background: var(--surface);
  border: 1px solid var(--line-strong); color: var(--ink);
}
.filter-chips a.chip:hover { border-color: var(--rim); background: var(--surface); }
.filter-chips .chip-on, .filter-chips a.chip-on:hover { background: var(--rim); border-color: var(--rim); color: var(--rim-ink); }
.dish-row { border-radius: var(--r-md); padding-inline: 10px; margin-inline: -10px; }
.dish-row:has(.dish-name:hover) { background: var(--surface); }
.crumbs { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.crumbs .back { margin: 0; }
.log-form { display: grid; gap: 14px; }
.log-card .entries li { padding: 6px 0; }
.log-card .entries .when { font-weight: 500; font-size: .95rem; }
.seg .btn[aria-pressed="true"] { --btn-bg: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
@media (max-width: 860px) {
  .filter-chips { flex-wrap: nowrap; overflow-x: auto; margin-inline: -16px; padding: 2px 16px; scrollbar-width: none; }
  .filter-chips::-webkit-scrollbar { display: none; }
  .page-head .btn-primary { min-height: 40px; }
}

/* ---------- suggestions dropdown ---------- */
.suggest { position: relative; display: block; min-width: 0; }
.suggest-list {
  position: absolute; z-index: 30; top: calc(100% + 6px); left: 0;
  min-width: 100%; width: max-content; max-width: min(360px, calc(100vw - 32px));
  max-height: 272px; overflow-y: auto; overscroll-behavior: contain;
  margin: 0; padding: 6px; list-style: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: var(--shadow-2);
}
.suggest-list[hidden] { display: none; }
.suggest-option {
  padding: 9px 12px; border-radius: var(--r-sm); cursor: pointer;
  color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.suggest-option[aria-selected="true"] { background: var(--rim-soft); color: var(--rim); }
.suggest-option mark { background: none; color: inherit; font-weight: 700; }
.tag-editor .suggest { flex: 1 1 8rem; min-width: 6rem; }
.tag-editor .suggest input[type="text"] { width: 100%; }
@media (pointer: coarse) { .suggest-option { padding: 12px; } }
