/* Bowden Family Recipes -- new look. The original flower wallpaper fills the
   window and the content sits on one white sheet. The palette comes from the
   wallpaper (#a8c8e8 / #88a8d8 / #7898c8); the only warm note is the
   favorite star. Follows dark mode. */

:root {
  --page: #f3f6fb;
  --surface: #ffffff;
  --ink: #1c2434;
  --muted: #5b6880;
  --link: #3f68b0;
  --line: #dce4f0;
  --hover: #ecf2fa;
  --current: #dbe7f7;
  --accent: #3f68b0;
  --star: #d0573f;
  --badge-bg: #dbe7f7;
  --badge-ink: #2c4f8f;
  --focus: #e08a2c;
  --wall: #94b4db url(../img/background.jpg) repeat;
  --wall-dim: transparent;               /* darkens the wallpaper in dark mode */
  --glass: rgba(255, 255, 255, .94);     /* pills sitting on the wallpaper */
  --shadow: 0 1px 2px rgba(28, 52, 92, .07), 0 6px 18px rgba(28, 52, 92, .08);
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --serif: Fraunces, Georgia, serif;
  --hand: Caveat, "Bradley Hand", cursive;
  --wide: 980px;
}

/* Dark mode: follows the device unless this device chose Light or Dark
   (data-theme on <html>, set from the footer's Theme switch) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --page: #11151c;
    --surface: #1a2029;
    --ink: #e6ebf3;
    --muted: #9aa7bb;
    --link: #92b5ee;
    --line: #29313e;
    --hover: #212937;
    --current: #263552;
    --accent: #7ea3e6;
    --star: #ee8468;
    --badge-bg: #263552;
    --badge-ink: #c4d6f5;
    --wall-dim: rgba(10, 14, 22, .70);
    --glass: rgba(26, 32, 41, .94);
    --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 6px 18px rgba(0, 0, 0, .3);
  }
}
:root[data-theme="dark"] {
  --page: #11151c;
  --surface: #1a2029;
  --ink: #e6ebf3;
  --muted: #9aa7bb;
  --link: #92b5ee;
  --line: #29313e;
  --hover: #212937;
  --current: #263552;
  --accent: #7ea3e6;
  --star: #ee8468;
  --badge-bg: #263552;
  --badge-ink: #c4d6f5;
  --wall-dim: rgba(10, 14, 22, .70);
  --glass: rgba(26, 32, 41, .94);
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 6px 18px rgba(0, 0, 0, .3);
}

:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--page);
  color: var(--ink);
  font: 1.0625rem/1.55 var(--sans);
}
a { color: var(--link); }
img { max-width: 100%; height: auto; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
main:focus { outline: none; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--surface); padding: 8px 12px; }
.skip:focus { left: 8px; }

/* ---- masthead ---- */
.masthead { padding: 0 16px; }
.bar {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: var(--wide);
  margin: 0 auto;
  padding: 14px 0 0;
}
.acctbtn {
  background: var(--glass);
  color: var(--ink);
  box-shadow: var(--shadow);
}

/* The title is an index card -- a nod to the old site's recipe-card look:
   handwritten name, red header rule, blue ruled lines, a slight tilt. */
.brand {
  display: inline-block;
  padding: .3em .75em 1.25em;
  font: 600 1.75rem/1 var(--hand);
  color: #1c2434;
  text-decoration: none;
  background:
    linear-gradient(#e0726a, #e0726a) 0 1.42em / 100% 2px no-repeat,
    linear-gradient(#bcd0ee, #bcd0ee) 0 1.88em / 100% 1px no-repeat,
    linear-gradient(#bcd0ee, #bcd0ee) 0 2.28em / 100% 1px no-repeat,
    #fffdf8;
  border-radius: 3px;
  box-shadow: 0 1px 1px rgba(20, 40, 80, .12), 2px 6px 14px rgba(20, 40, 80, .28);
  transform: rotate(-2deg);
  transition: transform .15s ease;
}
.brand:hover { transform: rotate(0deg); }

.account { position: relative; margin-left: auto; display: flex; gap: 8px; align-items: center; }
.acctbtn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 6px;
  border-radius: 999px;
  border: 0;
  font-size: .95rem;
  text-decoration: none;
  cursor: pointer;
}
a.acctbtn { padding: 8px 16px; }
.avatar {
  display: grid; place-items: center;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: #fff;
  font-weight: 700; font-size: .85rem;
}
.caret { font-size: .75rem; color: var(--muted); }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 40;
  min-width: 270px; padding: 6px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 12px 32px rgba(20, 40, 80, .25);
}
.menu[hidden] { display: none; }
.menu a, .menu button {
  display: block; width: 100%; padding: 10px 12px;
  border: 0; border-radius: 8px; background: none;
  color: var(--ink); text-align: left; text-decoration: none; font-size: .95rem; cursor: pointer;
}
.menu a:hover, .menu button:hover, .menu a:focus-visible, .menu button:focus-visible { background: var(--hover); }
.menu small { color: var(--muted); }
.menuhead { margin: 6px 12px 8px; font-size: .85rem; color: var(--muted); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 4px; }

.search { position: relative; max-width: 640px; margin: 16px auto 0; }
.search input {
  width: 100%;
  font: inherit;
  font-size: 1.05rem;
  padding: 13px 20px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

/* ---- category chips ---- */
.chips {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--page);
  border-bottom: 1px solid var(--line);
}
.chips ul {
  display: flex;
  gap: 4px;
  max-width: var(--wide);
  margin: 0 auto;
  padding: 8px 16px;
  list-style: none;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 12px, #000 calc(100% - 24px), transparent);
          mask-image: linear-gradient(to right, transparent 0, #000 12px, #000 calc(100% - 24px), transparent);
}
.chips ul::-webkit-scrollbar { display: none; }
.chips li { flex: none; }
.chips li.sep { width: 1px; background: var(--line); margin: 4px 6px; }
.chips a {
  display: block;
  padding: 6px 13px;
  border-radius: 999px;
  font-size: .92rem;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.chips a:hover { background: var(--hover); }
.chips a[aria-current="page"] { background: var(--current); color: var(--badge-ink); font-weight: 600; }
.needs-login { display: none; }
.loggedin .needs-login { display: block; }

/* ---- content ---- */
.sheet { flex: 1; display: flex; flex-direction: column; }
.content { flex: 1; width: 100%; max-width: var(--wide); margin: 0 auto; padding: 24px 16px 40px; }
.foot { text-align: center; padding: 18px 16px 28px; font-size: .9rem; color: var(--muted); }
.foot a { color: var(--muted); }

.pagehead { margin: 4px 0 14px; font: 600 1.9rem/1.15 var(--serif); display: flex; align-items: baseline; gap: 10px; }
.count { font: .95rem var(--sans); color: var(--muted); }
.subhead { margin: 30px 0 10px; font: 600 1.3rem/1.2 var(--serif); display: flex; align-items: baseline; gap: 12px; }
.subhead a { font: .9rem var(--sans); margin-left: auto; }
.content > .subhead:first-child, .homegrid:first-child .subhead { margin-top: 8px; }
.status, .empty, .muted { color: var(--muted); }
/* Results being replaced by a newer search: dim only if it takes a moment */
.content { transition: opacity .12s; }
.content.refreshing { opacity: .55; transition: opacity .15s .25s; }

.recipes {
  list-style: none; margin: 0; padding: 4px 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
}
.recipes li + li { border-top: 1px solid var(--line); }
.reciperow {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px;
  padding: 11px 8px; margin: 0 -8px; border-radius: 8px;
  color: var(--ink); text-decoration: none;
}
.reciperow:hover { background: var(--hover); }
.rtitle { font-weight: 600; }
.rsource, .when { font-size: .875rem; color: var(--muted); }
.when { margin-left: auto; }
.reciperow mark { background: #fde9a6; color: inherit; border-radius: 3px; padding: 0 1px; }
.snippet { flex-basis: 100%; font-size: .875rem; color: var(--muted); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .reciperow mark { background: #5a4a14; }
}
:root[data-theme="dark"] .reciperow mark { background: #5a4a14; }
.star { color: var(--star); margin-right: 4px; }
.badge { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 1px 6px; border-radius: 4px; background: var(--badge-bg); color: var(--badge-ink); }

.homegrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 400px), 1fr)); gap: 0 28px; }

.cattiles { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.cattiles a {
  display: block; padding: 16px 14px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
  color: var(--ink); text-decoration: none; font: 600 1.05rem var(--serif);
}
.cattiles a:hover { background: var(--hover); border-color: var(--current); }

.tidylist li { padding: 10px 0; }
.tidyrow { display: flex; align-items: center; gap: 12px; }
.tidyrow .rtitle { flex: 1; color: var(--ink); text-decoration: none; }
.tidyrow .rtitle:hover { text-decoration: underline; }
.tidyproblems { margin: 4px 0 0; padding-left: 18px; font-size: .9rem; }
.tidyproblems li { padding: 1px 0; border: 0 !important; }
.tidyfix.applied .rtitle { color: var(--muted); }
.tidyfix .rowstatus { font-size: .9rem; }
.tidyfix details { margin: 6px 0 0 18px; font-size: .9rem; }
.tidyfix summary { cursor: pointer; color: var(--link); }
.beforeafter { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin-top: 8px; }
.tidypreview { padding: 10px 14px; border: 1px dashed var(--line); border-radius: 10px; font-size: .9rem; }
.tidypreview .recipebody.split { display: block; }
.tidypreview .split .col-ing { position: static; }   /* no pinned ingredients inside a preview */
.tidypage .btn.primary { margin: 4px 0 10px; }
.jump { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 10px; }
.jump a { min-width: 2.1em; text-align: center; padding: 4px; border-radius: 6px; text-decoration: none; color: var(--ink); background: var(--surface); border: 1px solid var(--line); }
.jump a:hover { background: var(--hover); }
.letterhead { margin: 20px 0 6px; font: 600 1.1rem var(--serif); color: var(--accent); scroll-margin-top: 64px; }

/* ---- recipe ---- */
.recipe .title { margin: 0; font: 600 clamp(1.8rem, 5vw, 2.4rem)/1.12 var(--serif); }
.source { margin: 4px 0 0; color: var(--muted); }
.byline { margin: 2px 0 0; font-size: .9rem; color: var(--muted); }
.stepmode .byline { display: none; }
.tools { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 8px; }
.tool {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px;
  padding: 6px 14px; font-size: .92rem;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  text-decoration: none; cursor: pointer;
}
.tool:hover { background: var(--hover); }
.tool[aria-pressed="true"] { background: var(--current); border-color: var(--accent); }
.picture { display: block; width: min(100%, 420px); margin: 12px 0; border-radius: 12px; }
.edphoto { display: block; max-width: min(100%, 320px); max-height: 240px; margin: 4px 0 8px; border-radius: 10px; object-fit: cover; }
.edphoto[hidden] { display: none; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
label.tool { cursor: pointer; }

.recipebody .subhead { margin-top: 22px; font: 700 .8rem var(--sans); text-transform: uppercase; letter-spacing: .08em; color: var(--accent); }
.ingredients {
  list-style: none; margin: 0 0 10px; padding: 8px 18px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
}
.ingredients li { padding: 7px 0; border-bottom: 1px solid var(--line); }
.ingredients li:last-child { border-bottom: 0; }
.ingredients li.group { font-weight: 700; color: var(--accent); padding-top: 10px; }
.step { margin: 0 0 14px; max-width: 66ch; }
.recipebody a, .notes a, .stepcard a { overflow-wrap: anywhere; }
/* standard-shape recipes with parts: grouped side by side on wide screens,
   part by part (each group's ingredients, then its steps) on phones */
.stepgroup { margin: 18px 0 8px; font: 600 1.15rem var(--serif); color: var(--accent); }
.col-dir > .stepgroup:first-of-type, .parts > .stepgroup:first-child { margin-top: 4px; }
.recipebody.parts { display: none; }
@media (max-width: 859px) {
  .recipebody.split.wideonly { display: none; }
  .recipebody.parts { display: block; }
}
.preview .recipebody.split.wideonly, .tidypreview .recipebody.split.wideonly { display: none; }
.preview .recipebody.parts, .tidypreview .recipebody.parts { display: block; }
.cooking .stepgroup { font-size: calc(var(--cook-text) * .8); }
.stepgroupname { margin: 0; font: 700 calc(var(--cook-text) * .55) var(--sans); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.notes { margin-top: 20px; padding: 12px 16px; border-left: 4px solid var(--accent); background: var(--surface); border-radius: 0 10px 10px 0; }

@media (min-width: 860px) {
  .recipebody.split { display: grid; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); gap: 0 36px; align-items: start; }
  .split .col-ing { position: sticky; top: 70px; }
}

/* ---- cooking mode: just the recipe, big, with tap-to-check ---- */
.cookbar, .cookhint { display: none; }
.cooking .masthead, .cooking .chips, .cooking .foot, .cooking .tools { display: none; }
.cooking .content { padding-top: 0; }
.cooking .cookbar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px 14px;
  position: sticky; top: 0; z-index: 30;
  margin: 0 -16px 18px; padding: 10px 16px;
  background: var(--current); color: var(--ink);
  border-radius: 0 0 14px 14px; box-shadow: var(--shadow);
  font-size: 1rem;
}
.cookstatus { font-size: .9rem; color: var(--muted); }
.cookbar .tool { font-weight: 600; min-height: 40px; }
.cookbar .cookdone { margin-left: auto; }
.cooksizes { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--surface); }
.cooksizes button { min-width: 42px; min-height: 40px; border: 0; background: none; color: var(--ink); cursor: pointer; font-weight: 700; line-height: 1; }
.cooksizes button:nth-child(1) { font-size: .85rem; }
.cooksizes button:nth-child(2) { font-size: 1.1rem; }
.cooksizes button:nth-child(3) { font-size: 1.4rem; }
.cooksizes button + button { border-left: 1px solid var(--line); }
.cooksizes button[aria-pressed="true"] { background: var(--accent); color: var(--surface); }
.cooking .cookhint { display: block; font-size: 1rem; color: var(--muted); margin: 6px 0 0; }
/* three text sizes for reading from across the kitchen; on big screens (a
   kitchen computer) they grow with the width */
.cooking { --cook-text: clamp(1.4rem, 1.3vw, 2.6rem); }
.cooking.cook-size-2 { --cook-text: clamp(1.9rem, 1.8vw, 3.4rem); }
.cooking.cook-size-3 { --cook-text: clamp(2.5rem, 2.4vw, 4.4rem); }
.cooking .recipe { font-size: var(--cook-text); line-height: 1.45; }
.cooking .recipe .title { font-size: calc(var(--cook-text) * 1.6); line-height: 1.1; }
.cooking .recipebody .subhead { font-size: calc(var(--cook-text) * .55); }
@media (min-width: 860px) {
  .cooking .split .col-ing { top: 80px; }
  /* wide screens at the biggest size: give the steps the room */
  .cooking.cook-size-3 .recipebody.split { grid-template-columns: minmax(300px, 40%) minmax(0, 1fr); }
}

/* one step at a time */
.stepview { display: none; }
.stepmode .stepview { display: flex; flex-direction: column; min-height: calc(100vh - 150px); min-height: calc(100dvh - 150px); }
.stepmode .recipebody, .stepmode .notes, .stepmode .cookhint, .stepmode .source, .stepmode .picture { display: none; }
.stepmode .recipe .title { font-size: min(calc(var(--cook-text) * .9), 6.5vw); margin-bottom: 4px; }
.stepcount { margin: 0; font: 700 calc(var(--cook-text) * .55) var(--sans); text-transform: uppercase; letter-spacing: .08em; color: var(--accent); }
.stepcard { flex: 1; font-size: min(calc(var(--cook-text) * 1.25), 8.5vw); line-height: 1.35; }
.stepcard p { margin: .3em 0 0; max-width: 40ch; }
.stepcard .ingredients { font-size: var(--cook-text); }
.stepnav { position: sticky; bottom: 0; display: flex; gap: 12px; padding: 14px 0 calc(14px + env(safe-area-inset-bottom)); background: var(--page); }
.stepbtn {
  flex: 1; min-height: 64px; font: 700 1.3rem var(--sans);
  border: 2px solid var(--accent); border-radius: 16px; background: var(--surface); color: var(--accent); cursor: pointer;
}
.stepbtn.primary { flex: 2; background: var(--accent); color: var(--surface); }
.stepbtn:disabled { opacity: .35; cursor: default; }
.peekbtn { font-size: 1rem; align-self: flex-start; margin: 2px 0 8px; }
.steppeek .ingredients { font-size: calc(var(--cook-text) * .75); }
.stepside { display: none; }
.stepnext { margin: .4em 0 0; font-size: calc(var(--cook-text) * .75); color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.stepnext:empty { display: none; }
@media (max-width: 699px) { .stepnext { display: none; } }

/* wide screens: use the whole screen; step view in two columns, every
   ingredient on the left and the current step on the right */
@media (min-width: 1100px) {
  .cooking .content { max-width: min(1800px, 96vw); }
  .cooking .recipebody.split, .cooking.cook-size-3 .recipebody.split { grid-template-columns: minmax(320px, 32%) minmax(0, 1fr); gap: 0 4vw; }
  .cooking .step { max-width: 60ch; }
  .stepmode .stepview[data-sidebar="yes"] {
    display: grid; grid-template-columns: minmax(300px, 32%) minmax(0, 1fr); gap: 0 4vw;
    grid-template-rows: auto 1fr auto auto; align-items: start;
  }
  .stepview[data-sidebar="yes"] .stepside {
    display: block; grid-column: 1; grid-row: 1 / span 4;
    position: sticky; top: 80px; max-height: calc(100vh - 100px); overflow: auto;
  }
  .stepside .subhead { margin-top: 0; font-size: calc(var(--cook-text) * .55); }
  .stepside .ingredients { font-size: calc(var(--cook-text) * .85); }
  .stepview[data-sidebar="yes"] > :not(.stepside) { grid-column: 2; }
  .stepview[data-sidebar="yes"] .peekbtn, .stepview[data-sidebar="yes"] .steppeek { display: none; }
  .stepcard p { max-width: 32ch; }
}
@media (max-width: 600px) {
  /* phones: Done on the first row of the bar, options on the second */
  .cookbar .cookdone { order: 1; }
  .cookbar .cookopt { order: 2; }
  .cookbar .cookstatus { order: 3; }
  .stepmode .cookbar .cookstatus { display: none; }
  .stepmode .stepview { min-height: calc(100dvh - 190px); }
  .stepbtn { min-height: 58px; }
}
.cooking .ingredients li:not(.group), .cooking .step {
  position: relative; cursor: pointer; padding-left: 2.1em; border-radius: 8px;
  -webkit-tap-highlight-color: transparent;
}
.cooking .step { padding-top: 6px; padding-bottom: 6px; }
.cooking .ingredients li:not(.group)::before, .cooking .step::before {
  content: ""; position: absolute; left: .35em; top: .5em;
  width: 1.1em; height: 1.1em; border: 2px solid var(--accent); border-radius: 50%;
  font-size: .9em; line-height: 1; text-align: center;
}
.cooking .step::before { top: .65em; }
.cooking .done::before { content: "✓"; background: var(--accent); color: var(--surface); font-weight: 700; }
.cooking .done { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 2px; }

/* ---- add / edit ---- */
.addbtn { font-weight: 600; color: var(--accent); }
.edhead { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.edtabs { display: none; margin-left: auto; padding: 3px; border-radius: 999px; background: var(--hover); }
.edtabs button { border: 0; background: none; padding: 6px 16px; border-radius: 999px; font-size: .95rem; cursor: pointer; }
.edtabs [aria-selected="true"] { background: var(--surface); box-shadow: var(--shadow); font-weight: 600; }
.edpanes { display: grid; gap: 32px; align-items: start; }
.field { margin: 0 0 22px; padding: 0; border: 0; min-width: 0; }
.field > label, .field > legend { display: block; padding: 0; margin-bottom: 4px; font-weight: 700; }
.hint { margin: 0 0 8px; font-size: .9rem; color: var(--muted); }
.subnote { margin: 6px 0 0; font-size: .85rem; color: var(--muted); }
.edform input[type="text"], .edform textarea {
  display: block; width: 100%;
  padding: 10px 12px; font: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
}
.edform textarea { min-height: 9em; resize: vertical; field-sizing: content; line-height: 1.5; }
#ed-notes { min-height: 4.5em; }
#ed-title { font: 600 1.25rem var(--serif); }
.edform input:focus, .edform textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.edtools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 6px; }
.tool.small { min-height: 36px; padding: 4px 12px; font-size: .9rem; }
.catpick { display: flex; flex-wrap: wrap; gap: 6px; }
.catpick label, .vispick label { cursor: pointer; }
.catpick input, .vispick input { position: absolute; opacity: 0; pointer-events: none; }
.catpick span {
  display: block; padding: 6px 13px; font-size: .92rem;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
}
.catpick input:checked + span { background: var(--current); border-color: var(--accent); color: var(--badge-ink); font-weight: 600; }
.catpick input:checked + span::before { content: "✓ "; }
.vispick { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px; }
.vispick span {
  display: block; padding: 10px 14px; height: 100%;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
}
.vispick small { display: block; color: var(--muted); }
.vispick input:checked + span { border-color: var(--accent); background: var(--current); box-shadow: inset 0 0 0 1px var(--accent); }
.catpick input:focus-visible + span, .vispick input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.preview { padding: 18px 20px; border: 1px dashed var(--line); border-radius: 14px; min-width: 0; }
.preview-label { margin: 0 0 8px; font: 700 .75rem var(--sans); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.preview .recipebody.split { display: block; }
.preview .split .col-ing { position: static; }
.warn { margin: 0 0 12px; padding: 10px 14px; border-radius: 10px; background: #fdf0d8; color: #6b4a0c; font-size: .92rem; }
.notice { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; margin: 0 0 16px; padding: 10px 14px; border-radius: 10px; background: var(--current); }
.notice[hidden] { display: none; }
.linkbtn { border: 0; background: none; padding: 0; color: var(--link); text-decoration: underline; cursor: pointer; }
.danger { color: #b3261e; }
.dangerzone { margin: 28px 0 0; }
.savebar {
  position: sticky; bottom: 0; z-index: 10;
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px;
  margin: 18px -24px -40px; padding: 12px 24px calc(12px + env(safe-area-inset-bottom));
  background: var(--page); border-top: 1px solid var(--line);
}
.savestatus { font-size: .9rem; color: var(--muted); }
.savestatus:empty { display: none; }
.savestatus.bad { color: #b3261e; font-weight: 600; }
.spacer { flex: 1; }
.btn {
  min-height: 42px; padding: 8px 18px; font-size: .95rem; font-weight: 600;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink); cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn:disabled { opacity: .6; cursor: wait; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .warn { background: #3d3115; color: #f3dca6; }
  :root:not([data-theme="light"]) .danger, :root:not([data-theme="light"]) .savestatus.bad { color: #ff9a8f; }
  :root:not([data-theme="light"]) .btn.primary { color: #10151d; }
}
:root[data-theme="dark"] .warn { background: #3d3115; color: #f3dca6; }
:root[data-theme="dark"] .danger, :root[data-theme="dark"] .savestatus.bad { color: #ff9a8f; }
:root[data-theme="dark"] .btn.primary { color: #10151d; }
@media (min-width: 1000px) {
  .edpanes { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .preview { position: sticky; top: 70px; max-height: calc(100vh - 160px); overflow: auto; }
}
@media (max-width: 999px) {
  .edtabs { display: flex; }
  .edpanes[data-pane="edit"] .preview, .edpanes[data-pane="preview"] .edform { display: none; }
}

/* ---- log in / change password ---- */
.authpage { max-width: 420px; }
.authform input[type="text"], .authform input[type="password"], .authform input[type="email"] {
  display: block; width: 100%;
  padding: 11px 12px; font: inherit; font-size: 1.05rem; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
}
.authform input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.labelrow { display: flex; align-items: baseline; justify-content: space-between; }
.labelrow label { font-weight: 700; margin-bottom: 4px; }
.showpw { font-size: .9rem; }
.check { display: flex; align-items: center; gap: 8px; margin: -6px 0 18px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.formmsg { margin: 0 0 14px; color: #b3261e; font-weight: 600; }
.formmsg:empty { display: none; }
.formmsg.good { color: #1f7a3a; }
.authform .btn.primary { width: 100%; min-height: 48px; font-size: 1.05rem; }
.authpage > .hint { margin-top: 18px; }
.trap { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.hint.bad { color: #b3261e; font-weight: 600; }
.peoplepage { max-width: 760px; }
/* stats */
.statspage { --chart-bar: #3f68b0; }
:root[data-theme="dark"] .statspage { --chart-bar: #6a8fd6; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .statspage { --chart-bar: #6a8fd6; } }
.stattiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin: 8px 0 8px; }
.stattile { padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.stattile strong { display: block; font: 600 1.8rem/1.1 var(--serif); }
.stattile span { font-size: .85rem; color: var(--muted); }
.daychart { position: relative; padding: 18px 0 0; }
.chartmax { position: absolute; top: 0; left: 0; font-size: .8rem; color: var(--muted); }
.bars { display: flex; align-items: flex-end; gap: 2px; height: 140px; border-bottom: 1px solid var(--line); }
.daybar { flex: 1; height: max(var(--h), 1px); background: var(--chart-bar); border-radius: 4px 4px 0 0; position: relative; outline-offset: 1px; }
.daybar::before { content: ""; position: absolute; inset: -18px -1px 0; }   /* a bigger hover target */
.daybar:hover, .daybar:focus-visible { filter: brightness(1.15); }
.daybar:hover::after, .daybar:focus-visible::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); z-index: 5;
  white-space: nowrap; padding: 4px 8px; border-radius: 6px; font-size: .8rem;
  background: var(--ink); color: var(--surface); pointer-events: none;
}
.chartdates { display: flex; justify-content: space-between; font-size: .8rem; color: var(--muted); margin-top: 4px; }
.stattable table { border-collapse: collapse; margin-top: 8px; font-size: .9rem; }
.stattable th, .stattable td { padding: 3px 14px 3px 0; text-align: left; }
.stattable summary { cursor: pointer; color: var(--link); margin: 10px 0; }
.statgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 0 28px; }
.statlist ol { margin: 0; padding-left: 1.4em; }
.statlist li { padding: 3px 0; }
.statlist li .count { margin-left: 8px; }
.statrange { display: inline-flex; flex-wrap: wrap; gap: 2px; margin: 4px 0 6px; padding: 3px; border-radius: 999px; background: var(--hover); }
.statrange a { padding: 6px 14px; border-radius: 999px; font-size: .95rem; color: inherit; text-decoration: none; }
.statrange a[aria-current="page"] { background: var(--surface); box-shadow: var(--shadow); font-weight: 600; }
.trend { margin-left: 8px; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.stattile .trend { display: block; margin: 2px 0 0; }
.trend.up { color: #1e7a3a; }
.trend.down { color: #b3261e; }
:root[data-theme="dark"] .trend.up { color: #7fd99a; }
:root[data-theme="dark"] .trend.down { color: #ff9a8f; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .trend.up { color: #7fd99a; }
  :root:not([data-theme="light"]) .trend.down { color: #ff9a8f; }
}
.peoplefilter {
  width: 100%; max-width: 360px; margin: 0 0 12px; padding: 9px 14px; font: inherit;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink);
}
.people { list-style: none; margin: 0; padding: 4px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.person { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.person:last-child { border-bottom: 0; }
.person[hidden] { display: none; }
.person .who { flex: 1 1 260px; min-width: 0; }
.person .who .muted { font-size: .88rem; overflow-wrap: anywhere; }
.person .badge { margin-left: 8px; }
.person.highlight { background: var(--current); margin: 0 -16px; padding-left: 16px; padding-right: 16px; border-radius: 10px; }
.perms { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; }
.switch[hidden] { display: none; }
.switch { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: .95rem; }
.switch input { width: 20px; height: 20px; accent-color: var(--accent); }
.switch input:disabled + span { color: var(--muted); }
.rowstatus { font-size: .85rem; color: var(--muted); min-width: 4em; }
.accountpage { max-width: 520px; }
.settings { margin: 0 0 12px; padding: 4px 0 22px; border-bottom: 1px solid var(--line); }
.settings:last-child { border-bottom: 0; }
.settings .subhead { margin-top: 18px; }
.settings .btn.primary { width: auto; min-height: 44px; font-size: .95rem; }
.fieldnote { margin: -14px 0 18px; }
.sessions { list-style: none; margin: 0 0 14px; padding: 0; }
.sessions li { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.sessions li > div { grid-column: 1; }
.sessions li > .linkbtn { grid-column: 2; grid-row: 1 / span 2; }
.sessions .badge { margin-left: 8px; }
.sessions .muted { font-size: .9rem; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .formmsg { color: #ff9a8f; }
  :root:not([data-theme="light"]) .formmsg.good { color: #7fd69a; }
}
:root[data-theme="dark"] .formmsg { color: #ff9a8f; }
:root[data-theme="dark"] .formmsg.good { color: #7fd69a; }

/* ---- the sheet: wallpaper behind, content on one white sheet ---- */
body { background: linear-gradient(var(--wall-dim), var(--wall-dim)) fixed, var(--wall) fixed; }
.masthead { padding-bottom: 22px; }
.search input { border-color: transparent; }
.sheet {
  width: calc(100% - 32px);
  max-width: calc(var(--wide) + 48px);
  margin: 0 auto 24px;
  background: var(--page);
  border-radius: 18px;
  box-shadow: 0 10px 40px rgba(20, 40, 80, .25);
  overflow: clip;
}
.chips { border-radius: 18px 18px 0 0; }
.chips ul, .content { padding-left: 24px; padding-right: 24px; }
.foot, .foot a { color: var(--ink); }
.themeswitch { display: inline-flex; align-items: center; gap: 2px; }
.themeswitch button { border: 0; background: none; color: inherit; font: inherit; font-size: .85rem; padding: 2px 7px; border-radius: 999px; cursor: pointer; }
.themeswitch button[aria-pressed="true"] { background: var(--accent); color: var(--surface); }
.settings .themeswitch { border: 1px solid var(--line); border-radius: 999px; padding: 3px; background: var(--surface); }
.settings .themeswitch button { font-size: .95rem; padding: 6px 14px; }
.foot { background: var(--glass); width: fit-content; margin: 0 auto 20px; padding: 6px 14px; border-radius: 999px; }
body.cooking { background: var(--page); }
.cooking .sheet { width: 100%; max-width: none; margin: 0; border-radius: 0; box-shadow: none; }

@media (max-width: 600px) {
  .masthead { padding: 0 12px 16px; }
  .brand { font-size: 1.45rem; }
  .acctname, .addlabel { display: none; }   /* just the initial and "+" on phones */
  .savebar { margin: 18px -14px -32px; padding-left: 14px; padding-right: 14px; }
  .savestatus { flex-basis: 100%; }
  .content { padding: 18px 14px 32px; }
  .when { margin-left: 0; }
  .sheet { width: calc(100% - 16px); border-radius: 14px; }
  .chips ul, .content { padding-left: 14px; padding-right: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}

@media print {
  body { background: #fff; color: #000; font-size: 12pt; }
  .masthead, .chips, .tools, .foot, .skip { display: none !important; }
  .sheet { box-shadow: none !important; margin: 0 !important; width: auto !important; }
  .ingredients, .notes { box-shadow: none; background: none; }
  .recipebody.split { display: block; }
  a { color: #000; text-decoration: none; }
}
