/* Colours and sizes live here. Change the tokens to restyle the whole site.
   Brand colours (from the Briggys logo):
     plum  #450c3f   green #b9d175   cream #f5fbda   gold #da9627 */
:root {
  --bg: #f5fbda;
  --surface: #ffffff;
  --surface-2: #edf4cd;
  --text: #2e0a2a;
  --heading: #450c3f;
  --muted: #6b4f67;
  --border: #dbe5b5;
  --accent: #450c3f;
  --accent-strong: #2c0628;
  --accent-soft: #e1edb4;
  --on-accent: #f5fbda;
  --star: #c98a1e;
  --star-off: #d6dcbc;
  --danger: #b3261e;
  --success: #3e7a2e;
  --shadow: 0 1px 2px rgb(69 12 63 / 0.06), 0 4px 14px rgb(69 12 63 / 0.07);
  --radius: 14px;
  --radius-sm: 9px;
  --font-heading: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-body: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --nav-height: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c0a1a;
    --surface: #281226;
    --surface-2: #331a31;
    --text: #f5fbda;
    --heading: #f5fbda;
    --muted: #c9b9c5;
    --border: #4a2d46;
    --accent: #b9d175;
    --accent-strong: #d3e6a0;
    --accent-soft: #38412a;
    --on-accent: #1c0a1a;
    --star: #e3a93c;
    --star-off: #4d3a4a;
    --danger: #ff8a80;
    --success: #b9d175;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 4px 14px rgb(0 0 0 / 0.25);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 var(--font-body);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3 { font-family: var(--font-heading); line-height: 1.2; margin: 0 0 0.5em; font-weight: 600; color: var(--heading); }
h1 { font-size: clamp(1.8rem, 5vw, 2.6rem); letter-spacing: -0.01em; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 0.75em; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-strong); }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.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;
}

.skip-link { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 100; }
.skip-link:focus { left: 8px; }

.icon {
  width: 1.15em; height: 1.15em; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.icon.big { width: 48px; height: 48px; stroke-width: 1.5; color: var(--accent); margin-bottom: 8px; }

/* ---------- header and navigation ---------- */

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.header-inner {
  max-width: 1100px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand {
  display: flex; align-items: center; gap: 14px;
  font-family: var(--font-heading); font-weight: 600; font-size: 1.25rem;
  color: var(--heading); text-decoration: none; min-width: 0;
}
.brand:hover { color: var(--heading); }
.brand picture { display: flex; flex: none; }
.brand-logo { height: 52px; width: auto; }
.brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-left: 14px; border-left: 1px solid var(--border); }
@media (max-width: 640px) { .brand-logo { height: 44px; } }
.site-nav { display: flex; gap: 4px; }
.nav-link {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 12px; border-radius: 999px;
  color: var(--muted); text-decoration: none; font-weight: 500; white-space: nowrap;
}
.nav-link:hover { color: var(--text); background: var(--surface-2); }
.nav-link.active { color: var(--accent-strong); background: var(--accent-soft); }

/* On phones the menu moves to a bar along the bottom, within thumb reach,
   and the header scrolls away to leave more room for the recipe */
@media (max-width: 640px) {
  body { padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom)); }
  .site-header { position: static; }
  .header-inner { justify-content: center; }
  .site-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: var(--surface); border-top: 1px solid var(--border);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    justify-content: space-around;
  }
  .nav-link { flex-direction: column; gap: 2px; padding: 6px 8px; font-size: 0.75rem; border-radius: 12px; flex: 1; }
  .nav-link .icon { width: 22px; height: 22px; }
  .nav-link span { max-width: 80px; overflow: hidden; text-overflow: ellipsis; }
}

.offline-banner {
  margin: 0; padding: 8px 16px; text-align: center; font-size: 0.9rem; font-weight: 500;
  background: var(--star); color: #1c0a1a;
}

/* ---------- layout ---------- */

.page { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 24px 16px 48px; outline: none; }
.narrow { max-width: 640px; margin: 0 auto; }
.narrow > * + * { margin-top: 16px; }
.site-footer { text-align: center; color: var(--muted); font-size: 0.85rem; padding: 16px; }
.site-footer p { margin: 0; }
.loading { color: var(--muted); padding: 40px 0; text-align: center; }
.muted { color: var(--muted); }
.hint { display: block; color: var(--muted); font-size: 0.875rem; margin: 2px 0 6px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.panel > :last-child { margin-bottom: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.panel-head h2 { margin: 0; }

.notice {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--accent-soft); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 20px;
}
.notice p { margin: 0; }
.notice .icon { margin-top: 3px; color: var(--accent-strong); }

.empty-state { text-align: center; padding: 48px 16px; max-width: 460px; margin: 0 auto; }
.empty-state.small { padding: 24px 8px; grid-column: 1 / -1; }
.empty-state .icon.big { margin: 0 auto 8px; display: block; }

.back-link { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 16px; text-decoration: none; font-weight: 500; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px;
  border: 1px solid transparent; border-radius: 999px;
  font: inherit; font-weight: 600; line-height: 1.2; text-decoration: none;
  cursor: pointer; transition: background 0.15s, border-color 0.15s;
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-strong); color: var(--on-accent); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { border-color: var(--accent); color: var(--text); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 0.9rem; }
.btn.full { width: 100%; }
.btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-strong); }
.link-btn {
  background: none; border: 0; padding: 0; font: inherit; color: var(--accent);
  text-decoration: underline; text-underline-offset: 2px; cursor: pointer;
}

.icon-btn {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; flex: none; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer;
}
.icon-btn:hover:not(:disabled) { border-color: var(--accent); }
.icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 6px 12px; min-height: 34px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-size: 0.875rem; cursor: pointer; white-space: nowrap;
}
.chip .icon { width: 0.9em; height: 0.9em; }
.chip:hover { border-color: var(--accent); }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.chip.static { cursor: default; min-height: 0; padding: 3px 10px; background: var(--surface-2); border-color: transparent; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px; font-size: 0.75rem; font-weight: 600;
  background: var(--surface-2); color: var(--muted); vertical-align: middle; white-space: nowrap;
}
.badge .icon { width: 0.95em; height: 0.95em; }
.badge-off { color: var(--danger); }

/* ---------- home page ---------- */

.intro { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.intro h1 { margin-bottom: 0.15em; }
.tagline { color: var(--muted); font-size: 1.1rem; margin: 0; }
/* With the site name already in the header, the tagline takes the heading's place */
.intro h1.sr-only + .tagline { font-family: var(--font-heading); font-size: clamp(1.4rem, 4vw, 1.9rem); color: var(--heading); line-height: 1.25; }

.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 12px; }
.search-box {
  flex: 1 1 280px; display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
  padding: 0 16px; min-height: 46px; color: var(--muted);
}
.search-box:focus-within { border-color: var(--accent); outline: 3px solid var(--accent-soft); }
.search-box input { flex: 1; min-width: 0; border: 0; background: transparent; font: inherit; color: var(--text); padding: 10px 0; outline: none; }
.toolbar-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }

.segmented { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 3px; }
.segmented button {
  border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 600;
  padding: 8px 14px; border-radius: 999px; cursor: pointer; min-height: 38px;
}
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.sort-select { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.9rem; }
.sort-select select { min-height: 42px; }

.tag-row { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 8px; margin-bottom: 4px; scrollbar-width: thin; }
.tag-row.suggestions { flex-wrap: wrap; overflow: visible; margin: -4px 0 12px; }
.result-count { color: var(--muted); font-size: 0.9rem; margin-bottom: 12px; }

/* Ingredient suggestions (editor) and searching by ingredient (home page) */
.chip-count {
  margin-left: 2px; padding: 0 6px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); font-size: 0.75rem; font-weight: 600;
}
.suggest-label { color: var(--muted); font-size: 0.875rem; align-self: center; }
/* Sits just above the box and stays in view as you scroll down a long list */
.ingredient-suggest {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  position: sticky; top: 84px; z-index: 4;
  margin: 0 0 8px; padding: 8px; border-radius: var(--radius-sm);
  background: var(--surface-2); box-shadow: var(--shadow);
}
@media (max-width: 640px) { .ingredient-suggest { top: 8px; } }
.ingredient-finder { margin-bottom: 14px; padding: 16px; }
.ingredient-finder .search-box { margin: 6px 0 10px; }
.ingredient-finder .tag-row.suggestions { margin: 0 0 4px; align-items: center; }
.ingredient-finder .muted { margin: 0; font-size: 0.9rem; }

.recipe-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; }
@media (max-width: 520px) { .recipe-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; } }

.recipe-card {
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); text-decoration: none; box-shadow: var(--shadow);
  transition: transform 0.15s, border-color 0.15s;
}
.recipe-card:hover { transform: translateY(-2px); border-color: var(--accent); color: var(--text); }
.card-photo { position: relative; aspect-ratio: 4 / 3; background: var(--surface-2); }
.card-photo img { width: 100%; height: 100%; object-fit: cover; }
.card-photo .badge { position: absolute; top: 8px; left: 8px; background: var(--surface); }
.photo-placeholder { display: grid; place-items: center; width: 100%; height: 100%; color: var(--star-off); }
.photo-placeholder .icon { width: 40%; height: 40%; stroke-width: 1.2; }
.card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.card-title { font-size: 1.1rem; margin: 0; overflow-wrap: anywhere; }
.card-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; color: var(--muted); font-size: 0.85rem; margin: 0; }
.card-meta > span { display: inline-flex; align-items: center; gap: 4px; }
.card-foot { color: var(--muted); font-size: 0.8rem; margin: auto 0 0; }
@media (max-width: 520px) {
  .card-body { padding: 10px; }
  .card-title { font-size: 0.98rem; }
}

.stars { display: inline-flex; gap: 1px; vertical-align: -2px; }
.stars .icon { width: 0.95em; height: 0.95em; stroke: var(--star-off); fill: var(--star-off); }
.stars .icon.on { stroke: var(--star); fill: var(--star); }

/* ---------- recipe page ---------- */

.recipe-head { display: grid; gap: 24px; margin-bottom: 24px; }
.recipe-head.has-photo { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 760px) { .recipe-head.has-photo { grid-template-columns: 1fr; } }
.recipe-photo { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--radius); box-shadow: var(--shadow); }
/* On phones keep the top of the recipe short, so the ingredients aren't far away */
@media (max-width: 640px) {
  .recipe-head { gap: 16px; margin-bottom: 16px; }
  .recipe-photo { aspect-ratio: 16 / 9; }
  .recipe-description { font-size: 1rem; }
}
.recipe-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.recipe-description { font-size: 1.1rem; color: var(--muted); white-space: pre-line; }
.recipe-times { display: flex; gap: 10px; flex-wrap: wrap; margin: 0 0 16px; }
.recipe-times div { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 14px; }
.recipe-times dt { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.recipe-times dd { margin: 0; font-weight: 600; }
.recipe-byline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--muted); }
.recipe-source a { display: inline-flex; align-items: center; gap: 4px; }
.recipe-source .icon { width: 0.9em; height: 0.9em; }
.recipe-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.recipe-footer { margin: 16px 0 0; text-align: right; }

/* Shortcuts to each part of the recipe, for phones where it's one long column */
.jump-links { display: none; }
@media (max-width: 760px) {
  .jump-links { display: flex; gap: 8px; overflow-x: auto; margin: -4px 0 16px; padding: 2px; }
}
.ingredients, .method, .cook-log { scroll-margin-top: 90px; }
@media (max-width: 640px) { .ingredients, .method, .cook-log { scroll-margin-top: 12px; } }

.recipe-columns { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); gap: 20px; align-items: start; margin-bottom: 20px; }
@media (max-width: 760px) { .recipe-columns { grid-template-columns: 1fr; } }
/* Stays in view beside the method; a long list scrolls inside the panel instead of being cut off */
@media (min-width: 761px) { .ingredients { position: sticky; top: 88px; max-height: calc(100vh - 104px); overflow-y: auto; } }

.scaler { display: flex; align-items: center; gap: 8px; }
.scaler output { min-width: 78px; text-align: center; font-weight: 600; }

.ingredient-list, .check-list, .method-list, .log-list, .admin-list { list-style: none; margin: 0; padding: 0; }
.ingredient-list { margin-bottom: 16px; }
.ingredient-list li + li { border-top: 1px solid var(--border); }
.ingredient-heading { font-weight: 700; padding: 14px 0 6px; font-family: var(--font-heading); }

/* Big tick boxes and rows: easier to hit with wet or floury hands */
.tick { display: flex; align-items: flex-start; gap: 14px; padding: 12px 0; cursor: pointer; }
.tick input { width: 24px; height: 24px; margin: 0; flex: none; accent-color: var(--accent); cursor: pointer; }
.tick.done span { text-decoration: line-through; color: var(--muted); }

.method-list { counter-reset: none; }
.method-list li + li { margin-top: 6px; }
.step {
  display: flex; gap: 14px; width: 100%; text-align: left;
  background: transparent; border: 0; border-radius: var(--radius-sm); padding: 10px 8px;
  font: inherit; color: inherit; cursor: pointer;
}
.step:hover { background: var(--surface-2); }
.step-number {
  display: grid; place-items: center; width: 30px; height: 30px; flex: none;
  border-radius: 50%; background: var(--accent-soft); color: var(--accent-strong); font-weight: 700;
}
.step-text { white-space: pre-line; padding-top: 3px; }
.step[aria-pressed="true"] .step-text { color: var(--muted); text-decoration: line-through; }
.step[aria-pressed="true"] .step-number { background: var(--accent); color: var(--on-accent); }
.step-timers { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 8px 6px 52px; }
.timer-chip { background: var(--accent-soft); border-color: transparent; color: var(--accent-strong); font-weight: 600; }
.timer-chip:hover { border-color: var(--accent); }
.recipe-notes { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.recipe-notes p { white-space: pre-line; }

.log-summary { color: var(--muted); }
.log-entry { padding: 16px 0; border-top: 1px solid var(--border); }
.log-head { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.log-head p { margin: 0; }
.log-notes { white-space: pre-line; margin: 8px 0 0; }
.log-photo { margin-top: 10px; border-radius: var(--radius-sm); max-height: 280px; width: auto; }
.log-actions { display: flex; gap: 4px; margin-top: 8px; }

.log-form { background: var(--surface-2); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; scroll-margin-top: 90px; }
.rating-field { border: 0; padding: 0; margin: 0 0 16px; }
.rating-input { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.rating-input label { cursor: pointer; padding: 4px; border-radius: 6px; }
.rating-input label .icon { width: 30px; height: 30px; stroke: var(--star-off); fill: var(--star-off); }
.rating-input label.on .icon { stroke: var(--star); fill: var(--star); }
.rating-input input { position: absolute; opacity: 0; pointer-events: none; }
.rating-input label:focus-within { outline: 3px solid var(--accent); }
/* Preview the rating as you hover over the stars */
@media (hover: hover) {
  .rating-input:has(label:hover) label .icon { stroke: var(--star-off); fill: var(--star-off); }
  .rating-input:has(label:hover) label:hover .icon,
  .rating-input:has(label:hover) label:has(~ label:hover) .icon { stroke: var(--star); fill: var(--star); }
}

/* ---------- forms ---------- */

.field { display: block; margin-bottom: 16px; }
.field-label { display: block; font-weight: 600; margin-bottom: 4px; }
.required { font-weight: 400; color: var(--muted); font-size: 0.875rem; }
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), textarea, select {
  width: 100%; min-height: 44px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit;
}
.search-box input:not([type="checkbox"]):not([type="radio"]):not([type="file"]) {
  width: auto; min-height: 0; padding: 10px 0; border: 0; border-radius: 0; background: transparent; outline: none;
}
select { width: auto; padding-right: 32px; }
textarea { resize: vertical; line-height: 1.5; }
input:focus, textarea:focus, select:focus { outline: 3px solid var(--accent-soft); border-color: var(--accent); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: end; }
@media (max-width: 560px) {
  .form-grid { grid-template-columns: 1fr; }
  .form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 8px; }
  .form-grid.three .field-label { font-size: 0.85rem; }
}
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 8px; }

.editor { max-width: 760px; margin: 0 auto; }
.editor > .panel { margin-bottom: 16px; }
.sticky-actions {
  position: sticky; bottom: 0; z-index: 5;
  background: var(--bg); padding: 12px 0; border-top: 1px solid var(--border);
}
@media (max-width: 640px) { .sticky-actions { bottom: calc(var(--nav-height) + env(safe-area-inset-bottom)); } }
.danger-zone { margin-top: 32px; }
.danger-zone h2 { font-size: 1.1rem; }

.photo-row { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.photo-preview {
  width: 140px; aspect-ratio: 4 / 3; border-radius: var(--radius-sm); overflow: hidden;
  background: var(--surface-2); border: 1px dashed var(--border); flex: none;
}
.photo-preview img { width: 100%; height: 100%; object-fit: cover; }
.photo-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.photo-actions .hint { margin: 0; width: 100%; }

.visibility-field legend { font-family: var(--font-heading); font-size: 1.2rem; font-weight: 600; padding: 0 4px; }
.choice-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 560px) { .choice-cards { grid-template-columns: 1fr; } }
.choice-card {
  display: grid; gap: 2px; padding: 12px 14px; cursor: pointer;
  border: 2px solid var(--border); border-radius: var(--radius-sm); position: relative;
}
.choice-card input { position: absolute; opacity: 0; pointer-events: none; }
.choice-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice-card:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
.choice-title { display: flex; align-items: center; gap: 6px; font-weight: 700; }
.choice-hint { color: var(--muted); font-size: 0.875rem; }

.password-wrap { display: flex; gap: 8px; align-items: center; }
.password-wrap input { flex: 1; }

/* ---------- sign-in pages ---------- */

.auth-page { max-width: 440px; margin: 16px auto; }
.auth-form h1 { font-size: 1.9rem; }
.auth-footer { padding: 16px 4px; color: var(--muted); font-size: 0.95rem; }
.auth-footer p { margin-bottom: 8px; }

/* ---------- shopping ---------- */

.shopping { max-width: 640px; margin: 0 auto; }
.add-item { display: flex; gap: 8px; margin-bottom: 20px; }
.add-item input { flex: 1; }
.shop-group { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; }
.shop-group h2 { font-size: 1.05rem; margin-bottom: 4px; }
.check-list li { display: flex; align-items: center; gap: 8px; }
.check-list li + li { border-top: 1px solid var(--border); }
.check-list .tick { flex: 1; }
.check-list .icon-btn { border: 0; background: transparent; color: var(--muted); }
.shop-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.shop-toolbar .result-count { margin: 0; }
.shop-detail { display: block; font-size: 0.85rem; color: var(--muted); }

/* ---------- admin ---------- */

.inline-form { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { flex: 1 1 220px; margin: 0; }
.admin-list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 0; }
.admin-list li + li { border-top: 1px solid var(--border); }
.admin-list li > div:first-child { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.admin-list .muted { font-size: 0.875rem; }
.row-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.code-box { margin-top: 16px; padding: 16px; border-radius: var(--radius-sm); background: var(--accent-soft); }
.code { font: 700 1.5rem/1.2 ui-monospace, 'Cascadia Mono', Consolas, monospace; letter-spacing: 0.08em; color: var(--accent-strong); margin: 8px 0; }
.code-link { font-size: 0.85rem; overflow-wrap: anywhere; color: var(--muted); }

/* ---------- toast and dialog ---------- */

.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 60;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  max-width: min(92vw, 480px); width: max-content;
  background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 12px;
  box-shadow: var(--shadow); transition: opacity 0.2s, transform 0.2s; font-weight: 500;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); color: #fff; }
@media (prefers-color-scheme: dark) { .toast.error { color: var(--bg); } }
@media (max-width: 640px) { .toast { bottom: calc(var(--nav-height) + 16px + env(safe-area-inset-bottom)); } }

.dialog {
  border: 0; border-radius: var(--radius); padding: 0;
  width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgb(0 0 0 / 0.3);
}
.dialog::backdrop { background: rgb(28 10 26 / 0.55); }
.dialog-inner { padding: 20px; }
.dialog .check-list { max-height: 50vh; overflow-y: auto; margin-bottom: 12px; }

/* ---------- kitchen timers ---------- */

.timer-tray {
  position: fixed; right: 16px; bottom: 16px; z-index: 50;
  width: min(340px, calc(100vw - 32px));
}
@media (max-width: 640px) {
  .timer-tray { left: 16px; width: auto; bottom: calc(var(--nav-height) + 12px + env(safe-area-inset-bottom)); }
}
.timer-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.timer {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 6px 6px 14px; border-radius: 999px;
  background: var(--text); color: var(--bg); box-shadow: var(--shadow);
}
.timer-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.875rem; }
.timer-time { font-weight: 700; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.timer .icon-btn { width: 36px; height: 36px; background: transparent; border-color: transparent; color: inherit; }
.timer.done { background: var(--star); color: #1c0a1a; animation: timer-pulse 0.8s ease-in-out infinite alternate; }
@keyframes timer-pulse { to { transform: scale(1.03); } }

/* ---------- cook mode ---------- */

.cook-mode {
  width: 100%; height: 100%; max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0;
  background: var(--bg); color: var(--text);
}
.cook-mode[open] { display: flex; flex-direction: column; }
.cook-mode::backdrop { background: var(--bg); }
.cook-top {
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.cook-heading { flex: 1; min-width: 0; }
.cook-title {
  margin: 0; font-family: var(--font-heading); font-weight: 600; color: var(--heading);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cook-count { margin: 0; color: var(--muted); font-size: 0.875rem; }
.cook-bar { height: 4px; background: var(--surface-2); flex: none; }
.cook-bar span { display: block; height: 100%; background: var(--accent); transition: width 0.2s; }
.cook-body {
  position: relative; flex: 1; min-height: 0; display: flex; gap: 24px;
  width: 100%; max-width: 1100px; margin: 0 auto; padding: 24px 20px; overflow-y: auto;
}
.cook-step { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.cook-step-text { font-size: clamp(1.4rem, 4.5vw, 2.1rem); line-height: 1.45; white-space: pre-line; margin: 0 0 20px; }
.cook-timers { display: flex; flex-wrap: wrap; gap: 8px; }
.cook-timers .timer-chip { min-height: 48px; padding: 8px 16px; font-size: 1rem; }
.cook-ingredients {
  flex: 0 0 320px; align-self: flex-start; max-height: 100%; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 4px 16px; box-shadow: var(--shadow);
}
.cook-ingredients .tick { font-size: 1.1rem; }
/* On smaller screens the ingredients open over the step instead of beside it */
@media (max-width: 899px) {
  .cook-ingredients { position: absolute; inset: 12px; z-index: 2; max-height: none; }
}
.cook-nav {
  display: flex; gap: 12px; flex: none;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--border);
}
.cook-nav .btn { flex: 1; min-height: 56px; font-size: 1.1rem; }
.cook-mode .timer-tray { bottom: calc(92px + env(safe-area-inset-bottom)); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* ---------- printing a recipe ---------- */

@media print {
  :root { --bg: #fff; --surface: #fff; --text: #000; --muted: #444; --border: #ccc; --shadow: none; }
  .site-header, .site-footer, .no-print, .back-link, .toast, .site-nav, .offline-banner, .timer-tray { display: none !important; }
  body { padding: 0; }
  .page { padding: 0; }
  .panel { border: 0; padding: 0; }
  .recipe-columns { grid-template-columns: 1fr 1.6fr; }
  .ingredients { position: static; }
  .recipe-photo { max-height: 240px; width: auto; }
  .recipe-head.has-photo { grid-template-columns: 1fr 1.4fr; }
  .tick input { display: none; }
  .step { padding: 4px 0; }
}
