:root {
  color-scheme: light;
  --font-serif: "Fraunces", Georgia, "Times New Roman", serif;
  --font-sans: "DM Sans", "Segoe UI", system-ui, sans-serif;

  --bg: #f7f5f1;
  --card: #ffffff;
  --ink: #1f1b16;
  --text-2: #4a433b;
  --muted: #7a7166;
  --line: #e8e2d9;
  --primary-bg: #1f1b16;
  --primary-fg: #ffffff;
  --disabled-bg: #ebe6de;
  --disabled-fg: #a79e92;
  --icon-filter: none;
  --shadow: rgba(31, 27, 22, .14);
  --accent: #b4532a;
  --warn: #c62828;
  --placeholder-bg: #dfe6ee;

  --veg: #2e7d32;
  --vegan: #7cb342;
  --pesc: #00838f;

  --stove: #dc2626;
  --oven: #ea580c;
  --countertop: #ca8a04;
  --board: #16a34a;
  --fridge: #0891b2;
  --freezer: #4f46e5;
  --me: #2563eb;

  --stove-bg: #fef2f2;
  --oven-bg: #fff7ed;
  --countertop-bg: #fefce8;
  --board-bg: #f0fdf4;
  --fridge-bg: #ecfeff;
  --freezer-bg: #eef2ff;
  --me-bg: #eff6ff;

  --tip-bg: #fffbeb;
  --tip-line: #fcd34d;
  --tip-ink: #92400e;

  --radius: 6px;
}

/* Dark theme: chosen in Options, or "System" with a dark system setting */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1b1814;
  --card: #26221d;
  --ink: #f4efe8;
  --text-2: #d8d0c5;
  --muted: #a89e91;
  --line: #3d372f;
  --primary-bg: #f4efe8;
  --primary-fg: #1b1814;
  --disabled-bg: #34302a;
  --disabled-fg: #7a7166;
  --icon-filter: invert(1);
  --shadow: rgba(0, 0, 0, .5);
  --accent: #e08a5f;
  --warn: #ef5350;
  --placeholder-bg: #2c3540;
  --veg: #66bb6a;
  --vegan: #aed581;
  --pesc: #4dd0e1;
  --stove: #f87171;
  --oven: #fb923c;
  --countertop: #facc15;
  --board: #4ade80;
  --fridge: #22d3ee;
  --freezer: #818cf8;
  --me: #60a5fa;
  --stove-bg: #3b1d1d;
  --oven-bg: #3b2414;
  --countertop-bg: #3a3010;
  --board-bg: #15301f;
  --fridge-bg: #10303a;
  --freezer-bg: #1e2244;
  --me-bg: #1e2a44;
  --tip-bg: #3a3010;
  --tip-line: #a16207;
  --tip-ink: #fcd34d;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    color-scheme: dark;
    --bg: #1b1814;
    --card: #26221d;
    --ink: #f4efe8;
    --text-2: #d8d0c5;
    --muted: #a89e91;
    --line: #3d372f;
    --primary-bg: #f4efe8;
    --primary-fg: #1b1814;
    --disabled-bg: #34302a;
    --disabled-fg: #7a7166;
    --icon-filter: invert(1);
    --shadow: rgba(0, 0, 0, .5);
    --accent: #e08a5f;
    --warn: #ef5350;
    --placeholder-bg: #2c3540;
    --veg: #66bb6a;
    --vegan: #aed581;
    --pesc: #4dd0e1;
    --stove: #f87171;
    --oven: #fb923c;
    --countertop: #facc15;
    --board: #4ade80;
    --fridge: #22d3ee;
    --freezer: #818cf8;
    --me: #60a5fa;
    --stove-bg: #3b1d1d;
    --oven-bg: #3b2414;
    --countertop-bg: #3a3010;
    --board-bg: #15301f;
    --fridge-bg: #10303a;
    --freezer-bg: #1e2244;
    --me-bg: #1e2a44;
    --tip-bg: #3a3010;
    --tip-line: #a16207;
    --tip-ink: #fcd34d;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.45;
}

[hidden] { display: none !important; }

/* While a dialog is open the page behind it doesn't scroll */
html.no-scroll { overflow: hidden; }

h1, h2, h3, p { margin: 0; }
h1, h2, h3, .section-title, .category-title { font-family: var(--font-serif); font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 34px; }
h2 { font-size: 26px; }
h3 { font-size: 19px; }

/* Black line icons (utensils, areas) turn white in dark mode */
img.icon { filter: var(--icon-filter); }

.wrap { max-width: 680px; margin: 0 auto; padding: 24px 16px 48px; }
.wrap-wide { max-width: 960px; }
.hint { color: var(--muted); font-size: 14px; }
.muted { color: var(--muted); font-weight: 400; }
.stack { display: grid; gap: 10px; margin-top: 24px; }
.section-title { font-size: 22px; margin: 28px 0 12px; }

/* Buttons */
.btn {
  font: inherit;
  font-weight: 600;
  border-radius: var(--radius);
  border: 1px solid var(--ink);
  padding: 12px 18px;
  cursor: pointer;
  min-height: 44px;
}
.btn:focus-visible, .block:focus-visible, .recipe-card:focus-visible, select:focus-visible,
.btn-options:focus-visible, .area-move:focus-visible, .chip:focus-visible, .choice:has(input:focus-visible) {
  outline: 3px solid var(--me);
  outline-offset: 2px;
}
.btn-primary { background: var(--primary-bg); color: var(--primary-fg); border-color: var(--primary-bg); }
.btn-secondary { background: var(--card); color: var(--ink); border-color: var(--line); }
.btn-ghost { background: transparent; color: var(--ink); border-color: transparent; padding-left: 0; }
.btn-small { padding: 6px 12px; min-height: 36px; font-size: 14px; }
.btn-wide { width: 100%; }
.btn:disabled, .btn.is-disabled { background: var(--disabled-bg); color: var(--disabled-fg); border-color: var(--disabled-bg); cursor: not-allowed; }
.btn-back::before { content: "\2190  "; }

/* Options button (top right, every screen) */
.btn-options {
  position: fixed;
  top: 8px;
  right: 8px;
  z-index: 30;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
}

/* Dialogs (options, written recipe) */
.dialog {
  width: min(420px, calc(100% - 32px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--ink);
  padding: 0;
}
.dialog::backdrop { background: rgba(0, 0, 0, .45); }
.dialog form, .read-dialog { padding: 20px; }
.dialog h2 { margin-bottom: 16px; }
.read-dialog { width: min(720px, calc(100% - 32px)); max-height: calc(100vh - 48px); }
.read-dialog[open] { display: flex; flex-direction: column; }
.read-body { overflow-y: auto; overscroll-behavior: contain; flex: 1; color: var(--text-2); padding-right: 4px; }
.read-body p { margin: 0 0 12px; }
.read-body h3 { font-size: 17px; margin: 16px 0 8px; color: var(--ink); }
.read-body ul { margin: 0 0 12px; padding-left: 20px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 16px; border-top: 1px solid var(--line); margin-top: 12px; }

/* Form bits */
.field { display: grid; gap: 8px; margin-bottom: 20px; }
.field-label { font-weight: 600; }
select {
  font: inherit;
  color: var(--ink);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  min-height: 44px;
}
.choices { border: 0; padding: 0; margin: 0 0 20px; }
.choices legend { font-weight: 600; padding: 0; margin-bottom: 8px; }
.choices-row { display: flex; flex-wrap: wrap; gap: 8px; }
.choice {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 15px;
}
.choice:has(input:checked) { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.choice input { width: 16px; height: 16px; margin: 0; accent-color: var(--ink); flex: none; }
.choices.centered { text-align: center; }
.choices.centered legend { margin-left: auto; margin-right: auto; }
.choices.centered .choices-row { justify-content: center; }
.choice-text { display: grid; line-height: 1.25; }
.choice-text small { font-size: 12px; color: var(--muted); max-width: 26ch; }

/* People counters */
.people { border: 0; padding: 0; margin: 8px 0 24px; text-align: center; }
.people legend { font-family: var(--font-serif); font-size: 22px; font-weight: 600; padding: 0; margin: 0 auto 12px; }
.counters { display: flex; justify-content: center; flex-wrap: wrap; gap: 24px; }
.counter { display: grid; justify-items: center; gap: 6px; }
.counter-label { font-weight: 600; }
.stepper { display: flex; align-items: center; gap: 14px; }
.stepper .btn { width: 44px; font-size: 22px; padding: 0; }
.stepper output { min-width: 28px; text-align: center; font-size: 24px; font-weight: 700; }
.people .hint { margin-top: 8px; }
.kids-warning {
  margin: 14px auto 0;
  max-width: 520px;
  text-align: left;
  border: 1px solid var(--warn);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 15px;
}
.kids-warning p + p { margin-top: 6px; }
.kids-warning strong { color: var(--warn); }

/* Layout editor */
.screen-layout {
  position: fixed;
  inset: 0;
  z-index: 25;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.landscape-note {
  background: var(--primary-bg);
  color: var(--primary-fg);
  text-align: center;
  font-weight: 600;
  padding: 8px 60px;
}
.layout-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 16px; }
.layout-bar .hint { flex: 1; text-align: center; }
.canvas {
  position: relative;
  flex: 1;
  margin: 0 16px 16px;
  background: var(--card);
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  touch-action: none;
  overflow: hidden;
}
.block {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 2px solid currentColor;
  border-radius: var(--radius);
  font-weight: 600;
  cursor: grab;
  user-select: none;
  touch-action: none;
  overflow: hidden;
}
.block img { width: 40%; max-width: 56px; max-height: 45%; }
.block span { color: var(--ink); font-size: 14px; text-align: center; }
.block.dragging { cursor: grabbing; box-shadow: 0 8px 24px var(--shadow); }
.block-me { border-style: dashed; border-radius: 50px; }
.block.blocked { animation: blocked .3s; }
@keyframes blocked { 50% { border-style: dotted; } }
.block .resize {
  color: inherit;
  position: absolute;
  right: 0;
  bottom: 0;
  width: 22px;
  height: 22px;
  cursor: nwse-resize;
  touch-action: none;
  background: linear-gradient(135deg, transparent 50%, currentColor 50%);
}

.area-stove { color: var(--stove); background: var(--stove-bg); }
.area-oven { color: var(--oven); background: var(--oven-bg); }
.area-countertop { color: var(--countertop); background: var(--countertop-bg); }
.area-board { color: var(--board); background: var(--board-bg); }
.area-fridge { color: var(--fridge); background: var(--fridge-bg); }
.area-freezer { color: var(--freezer); background: var(--freezer-bg); }
.area-me { color: var(--me); background: var(--me-bg); }

.rotate-overlay { display: none; }
@media (pointer: coarse) and (orientation: portrait) {
  .screen-layout .canvas, #btn-layout-save, .layout-bar .hint { display: none; }
  .rotate-overlay {
    display: flex;
    flex: 1;
    align-items: center;
    justify-content: center;
    padding: 32px;
    text-align: center;
    font-size: 20px;
    font-weight: 600;
  }
}

/* Recipe list */
.layout-home { margin-bottom: 16px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 8px; padding-right: 48px; }
.filters .divider { width: 1px; background: var(--line); margin: 4px 4px; }
.chip {
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--primary-bg); color: var(--primary-fg); border-color: var(--primary-bg); }
.category-title {
  font-size: 30px;
  margin: 32px 0 14px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--ink);
}
.recipe-list, .ing-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.recipe-list { grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); }
.recipe-item { position: relative; }
.recipe-card {
  display: flex;
  align-items: stretch;
  gap: 14px;
  width: 100%;
  height: 100%;
  padding: 0;
  text-align: left;
  font: inherit;
  color: inherit;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
}
.recipe-card:hover { border-color: var(--muted); }
.recipe-card .photo { width: 120px; min-height: 120px; flex: none; }
.recipe-card-body { display: grid; align-content: start; gap: 5px; padding: 12px 12px 12px 0; min-width: 0; }
.recipe-card-body .title-row { font-size: 20px; padding-right: 96px; }
.btn-read-card { position: absolute; top: 8px; right: 8px; }
.meta-line { font-size: 14px; color: var(--text-2); }
.nutri-line small { display: block; font-size: 12px; color: var(--muted); padding-left: 1.6em; }

/* Photos and the placeholder (large pot on pale grey-blue) */
.photo { background: var(--placeholder-bg); display: block; object-fit: cover; }
.photo-placeholder {
  background: var(--placeholder-bg) url("../icons/cooking-pot.svg") center / 55% no-repeat;
}
.photo-hero { width: 120px; height: 120px; border-radius: var(--radius); flex: none; }

/* Diet label next to the title */
.title-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-family: var(--font-serif); font-weight: 600; }
.diet-badge {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .02em;
  border: 1px solid currentColor;
  border-radius: 4px;
  padding: 1px 6px;
  white-space: nowrap;
}
.diet-veg { color: var(--veg); }
.diet-vegan { color: var(--vegan); }
.diet-pesc { color: var(--pesc); }

/* "Contains" row: meat, pork, fish and allergens */
.warn-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.warn-row .warn-icon { font-size: 15px; }
.keyword { font-size: 13px; border: 1px solid var(--line); border-radius: 4px; padding: 1px 7px; }

/* Recipe page */
.top-row { display: flex; justify-content: space-between; align-items: center; padding-right: 48px; }
.detail-hero { display: flex; align-items: center; gap: 16px; margin: 8px 0 16px; }
.detail-hero .meta-line { margin-top: 6px; }
.info {
  display: grid;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 24px;
}
.info-label { font-family: var(--font-sans); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.nutrition { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px 20px; margin: 0; }
.nutrition div { display: grid; }
.nutrition dt { font-size: 12px; color: var(--muted); }
.nutrition dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Ingredient cards */
.ing-group {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 600;
  margin: 10px 0 -2px;
}
.ing-group:first-child { margin-top: 0; }
.ing-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
}
.ing-card img { width: 64px; height: 64px; object-fit: cover; display: block; flex: none; }
.ing-card .name { flex: 1; font-weight: 600; }
.ing-card .note { display: block; font-weight: 400; font-size: 13px; color: var(--muted); }
.ing-card .amount { padding-right: 14px; font-weight: 700; white-space: nowrap; }

/* Cooking header */
.cook-head {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  padding: 10px 64px 0 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.cook-title { flex: 1; min-width: 0; }
.cook-title h2 { font-size: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cook-title .hint { font-size: 13px; }
.cook-clocks { display: flex; gap: 14px; }
.cook-clock { display: grid; font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; line-height: 1.2; }
.clock-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.progress { flex-basis: 100%; height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; margin: 8px 0 10px; }
.progress i { display: block; height: 100%; width: 0; background: var(--ink); transition: width .3s; }
.view-toggle-wrap { position: relative; }
.view-toggle.is-ready { background: #2e7d32; color: #fff; border-color: #2e7d32; }
.view-toggle.is-ready:hover { background: #256b29; }
@media (pointer: coarse) { .view-toggle-wrap { display: none; } }
.tooltip {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  width: 240px;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary-fg);
  background: var(--primary-bg);
  border-radius: var(--radius);
  padding: 8px 10px;
  box-shadow: 0 6px 18px var(--shadow);
}

.cook-body { position: relative; }

/* "Start now" overlay before the clock runs (the header stays usable above it) */
.start-overlay {
  position: fixed;
  inset: 0;
  z-index: 9;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(24, 22, 19, .62);
  backdrop-filter: blur(2px);
}
.btn-start-now {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 4px;
  width: 190px;
  height: 190px;
  border-radius: 50%;
  border: 0;
  font: inherit;
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 600;
  color: #fff;
  background: #2e7d32;
  box-shadow: 0 12px 36px rgba(0, 0, 0, .4);
  cursor: pointer;
  transition: transform .15s;
}
.btn-start-now small { font-family: var(--font-sans); font-size: 13px; font-weight: 500; opacity: .9; }
.btn-start-now:hover { transform: scale(1.05); }
.btn-start-now:focus-visible { outline: 3px solid var(--me); outline-offset: 4px; }

/* Step cards */
.cook-list { max-width: 680px; margin: 0 auto; padding: 16px 16px 120px; display: grid; gap: 14px; }

.step {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px 16px;
  display: grid;
  gap: 10px;
  box-shadow: 0 1px 3px var(--shadow);
}
.step[data-area="stove"] { --area-color: var(--stove); --area-bg: var(--stove-bg); }
.step[data-area="oven"] { --area-color: var(--oven); --area-bg: var(--oven-bg); }
.step[data-area="countertop"] { --area-color: var(--countertop); --area-bg: var(--countertop-bg); }
.step[data-area="board"] { --area-color: var(--board); --area-bg: var(--board-bg); }
.step[data-area="fridge"] { --area-color: var(--fridge); --area-bg: var(--fridge-bg); }
.step[data-area="freezer"] { --area-color: var(--freezer); --area-bg: var(--freezer-bg); }

.step-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.area-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--area-color);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.area-badge span {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  background: var(--area-bg);
  border-radius: 50%;
}
.area-badge img { width: 20px; height: 20px; }
.step-tools { display: flex; gap: 4px; }
.step-tools img { width: 30px; height: 30px; padding: 3px; border: 1px solid var(--line); border-radius: 4px; }
.step h3 { font-size: 21px; }
.step-text { color: var(--text-2); }
.step-parts { margin: 0; padding-left: 20px; color: var(--text-2); display: grid; gap: 4px; }
.step-parts b { color: var(--ink); }

.step-ings { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.step-ings li {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding-right: 10px;
  font-size: 14px;
  overflow: hidden;
}
.step-ings img { width: 36px; height: 36px; object-fit: cover; display: block; }
.step-ings b { white-space: nowrap; }
.done-when { font-size: 13px; color: var(--muted); }

/* Footer: round timer with Start in the middle, Done next to it */
.step-foot { display: flex; align-items: center; gap: 16px; }
.ring { position: relative; width: 92px; height: 92px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 6; }
.ring .ring-track { stroke: var(--line); }
.ring .ring-fill { stroke: var(--area-color); stroke-linecap: round; transition: stroke-dashoffset .5s linear; }
.ring-center { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.btn-start {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 1px solid var(--ink);
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.btn-start:disabled { border-color: var(--line); color: var(--disabled-fg); cursor: not-allowed; }
.ring-time { display: grid; font-variant-numeric: tabular-nums; font-weight: 700; font-size: 16px; line-height: 1.1; }
.ring-time small { font-size: 11px; font-weight: 600; color: var(--muted); }
.step-foot .btn-done { flex: 1; }
.step.time-up { background: color-mix(in srgb, var(--card) 86%, var(--warn)); border-color: color-mix(in srgb, var(--line) 50%, var(--warn)); }
.step.time-up .ring-fill { stroke: var(--warn); }
.step.time-up .ring-time { color: var(--warn); }

/* A card that is no longer needed fades out and the next one slides up */
.step.leaving {
  overflow: hidden;
  pointer-events: none;
  transition: opacity 1s ease, height 1s ease, padding 1s ease, margin 1s ease;
}


/* Done but still needed by a step that is open: greyed and folded, can be re-opened */
.step.is-done { opacity: .6; padding: 8px 14px; gap: 4px; box-shadow: none; background: var(--bg); }
.step.is-done:not(.expanded) > :not(.step-head):not(h3):not(.done-row) { display: none; }
.step.is-done h3 { font-size: 16px; text-decoration: line-through; }
.step.is-done .step-foot { display: none; }
.done-row { display: none; }
.step.is-done .done-row { display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: 600; }
.btn-reopen { font: inherit; font-size: 13px; background: none; border: 0; color: var(--ink); text-decoration: underline; cursor: pointer; padding: 4px; }

/* Time is up: the card shakes once every 10 seconds */
.step.time-up { animation: nudge 10s ease-in-out infinite; }
@keyframes nudge {
  0%, 6%, 100% { transform: translateX(0); }
  1% { transform: translateX(-5px) rotate(-.6deg); }
  2% { transform: translateX(5px) rotate(.6deg); }
  3% { transform: translateX(-4px); }
  4% { transform: translateX(3px); }
  5% { transform: translateX(-1px); }
}
@media (prefers-reduced-motion: reduce) {
  .step.time-up { animation: none; outline: 2px solid var(--warn); }
}

/* Map view (landscape) */
.cook-map {
  position: relative;
  height: calc(100vh - var(--head-h, 80px) - 8px);
  margin: 0 8px 8px;
}
.map-area {
  position: absolute;
  display: flex;
  flex-direction: column;
  border: 2px solid currentColor;
  border-radius: var(--radius);
  overflow: hidden;
}
.map-area.dragging { box-shadow: 0 8px 24px var(--shadow); }
.map-area-head { display: flex; align-items: center; gap: 6px; padding: 4px 4px 4px 8px; font-size: 13px; font-weight: 700; text-transform: uppercase; }
.map-area-head img { width: 22px; height: 22px; }
.map-area-head .label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.area-move {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  color: inherit;
  background: transparent;
  border: 1px solid currentColor;
  border-radius: 4px;
  cursor: grab;
  touch-action: none;
}
.map-area-cards { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 12px 6px 6px; display: grid; gap: 10px; align-content: start; }
.map-area-cards.in-strip { position: absolute; }
.map-area-cards > .step { min-width: 0; }
.map-area.is-empty .map-area-head .label, .map-area.is-empty .map-area-head img { opacity: .5; }

.cook-map .step { padding: 8px 10px; gap: 6px; color: var(--ink); }
.cook-map .area-badge, .cook-map .done-when { display: none; }
.cook-map .step-ings li { font-size: 12px; }
.cook-map .step-ings img { width: 26px; height: 26px; }
.cook-map .step-head { position: absolute; top: 6px; right: 8px; }
.cook-map .step-tools img { width: 22px; height: 22px; padding: 2px; }
.cook-map h3 { font-size: 16px; padding-right: 60px; }
.cook-map .step-text, .cook-map .step-parts { font-size: 13px; }
.cook-map .btn { min-height: 34px; padding: 4px 8px; font-size: 13px; }
.cook-map .step-foot { gap: 8px; flex-wrap: wrap; }
.cook-map .ring { width: 64px; height: 64px; }
.cook-map .btn-start { width: 44px; height: 44px; font-size: 11px; }
.cook-map .ring-time { font-size: 12px; }

.map-area-ings { list-style: none; margin: 0; padding: 0 6px 6px; display: flex; flex-wrap: wrap; gap: 4px; pointer-events: none; }
.map-area-ings li {
  display: flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  font-size: 11px;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding-right: 6px;
  overflow: hidden;
}
.map-area-ings img { width: 24px; height: 24px; object-fit: cover; flex: none; }
.map-area-ings span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.map-area-ings b { white-space: nowrap; }

/* Finished */
.finished { text-align: center; }
.finished .stack { max-width: 360px; margin: 24px auto 0; }

/* "New thing to do!" label on a new card: pops up, then fades out within 10 s */
.new-badge {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1;
  pointer-events: none;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  background: #2563eb;
  border-radius: 999px;
  padding: 2px 10px;
  animation: new-badge 10s ease-out forwards;
}
@keyframes new-badge {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.6); }
  3% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
  6% { transform: translate(-50%, -50%) scale(1); }
  70% { opacity: 1; }
  100% { opacity: 0; }
}

/* Something on the heat is past its time */
body.overdo::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  background: #dc2626;
  animation: overdo-pulse 1.2s ease-in-out infinite;
}
@keyframes overdo-pulse {
  0%, 100% { opacity: 0; }
  50% { opacity: .14; }
}
.overdo-note { display: none; }
.step.time-up .overdo-note {
  display: block;
  text-align: center;
  font-size: 18px;
  font-weight: 800;
  color: #fff;
  background: #dc2626;
  border-radius: 4px;
  padding: 6px 10px;
}
.cook-map .step.time-up .overdo-note { font-size: 14px; padding: 4px 8px; }
@media (prefers-reduced-motion: reduce) {
  body.overdo::before { animation: none; opacity: .08; }
  .new-badge { animation-name: new-badge-still; }
  @keyframes new-badge-still { 0%, 70% { opacity: 1; } 100% { opacity: 0; } }
}

/* Star rating: stars fill up, no outline on click */
.stars { border: 0; padding: 0; margin: 24px 0 0; }
.stars legend { width: 100%; text-align: center; font-weight: 600; margin-bottom: 8px; padding: 0; }
.stars-row { display: flex; justify-content: center; gap: 4px; }
.star { position: relative; cursor: pointer; font-size: 40px; line-height: 1; color: var(--line); padding: 2px; }
.star input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.star.lit { color: #f59e0b; }
.star:has(input:focus-visible) { text-decoration: underline; text-decoration-color: var(--muted); }
.star-text { height: 28px; line-height: 28px; margin-top: 6px; font-family: var(--font-serif); font-style: italic; font-size: 18px; overflow: hidden; }
.star-pop {
  position: absolute;
  left: 2px;
  top: 2px;
  color: #f59e0b;
  pointer-events: none;
  animation: star-pop .6s ease-out forwards;
}
@keyframes star-pop { from { transform: scale(1); opacity: .9; } to { transform: scale(2.4); opacity: 0; } }

/* "Time's up" pop-over for a card that is off screen */
.due-toast {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 35;
  max-width: calc(100% - 120px);
  font: inherit;
  font-weight: 700;
  color: #fff;
  background: var(--warn);
  border: 0;
  border-radius: 999px;
  padding: 10px 20px;
  box-shadow: 0 6px 20px var(--shadow);
  cursor: pointer;
  animation: drop .25s ease-out;
}
@keyframes drop { from { transform: translate(-50%, -20px); opacity: 0; } }

/* Tip */
.tip {
  position: fixed;
  left: 50%;
  bottom: 16px;
  z-index: 15;
  width: min(480px, calc(100% - 32px));
  transform: translateX(-50%);
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--ink);
  background: var(--tip-bg);
  border: 1px solid var(--tip-line);
  border-radius: var(--radius);
  padding: 12px 8px 12px 16px;
  box-shadow: 0 8px 24px var(--shadow);
  touch-action: pan-y;
  user-select: none;
  transition: transform .3s ease, opacity .3s ease;
}
.tip.dragging { transition: none; }
.tip-body { flex: 1; }
.tip-label { font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--tip-ink); }
.tip-close { font: inherit; font-size: 22px; line-height: 1; color: var(--ink); background: none; border: 0; cursor: pointer; padding: 4px 8px; min-width: 36px; min-height: 36px; }
