/* =========================================================
   THEME TOKENS
   ========================================================= */

:root {
  --bg: #f6f7f9;
  --bg-top: #fff;
  --card: #fff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --surface: #fff;
  --surface2: #f3f4f6;
  --accent: #4F2185;
  --pill-bg: #f3f4f6;
  --shadow: 0 10px 30px rgba(17,24,39,.08);
  /* Density defaults (overridden by html[data-density]) */
  --card-pad: 12px;
  --card-gap: 14px;
  --thumb: 84px;          /* list thumb square */
  --thumb-grid-h: 160px;  /* grid thumb height */
  --title-size: 15px;
  --meta-size: 13px;
  --desc-size: 13px;
  --desc-lines: 3;
  --action-font: 13px;
  --action-pad-y: 10px;
  --action-pad-x: 14px;
  --actions-width: 220px;
  --line-height: 1.35;
  --font-sans: "Lato", system-ui, -apple-system, BlinkMacSystemFont,
               "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

[data-theme="dark"] {
  --accent: #FFC704;
  --bg: #0f172a;
  --bg-top: #060a14;
  --card: #111827;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --border: #1f2937;

  --surface: #0a1022;
  --surface2: #0b1226;

  --pill-bg: #1f2937;
  --shadow: 0 12px 40px rgba(0,0,0,.45);
}

/* =========================================================
   BASE RESET + GLOBAL SAFETY
   ========================================================= */

* {
  box-sizing: border-box;
  font-family: var(--font-sans);
  touch-action: manipulation;
  font-size: 15px;
  font-family: sans-serif;
  line-height: 1.5;
}

html, body {
  min-height: 100%;
  overflow-x: hidden;
  font-family: var(--font-sans);
}
body {
  font-weight: 400;
}

strong,
.recipeTitle,
h1, h2, h3 {
  font-weight: 700;
}

.muted {
  font-weight: 400;
}
body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, var(--bg-top), var(--bg));
  color: var(--text);
}

img, video, iframe { max-width: 100%; }

a, pre, code, textarea {
  overflow-wrap: anywhere;
  word-break: break-word;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

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

/* =========================================================
   LAYOUT + CARDS
   ========================================================= */

.container {
  max-width: 980px;
  margin: 0 auto;
  padding: 24px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 18px;
}

.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: 1fr 1fr; }
@media (max-width: 780px) {
  .grid.two { grid-template-columns: 1fr; }
}

/* =========================================================
   TOP BAR + DRAWER NAV (single source of truth)
   ========================================================= */

.topbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

@media (max-width: 768px) {
  .topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-top);
    padding: 10px 0;
  }
}

.brand a {
  background: url(logolight.svg) no-repeat;
  width: 200px;
  height: 100px;
  display: block;
}

[data-theme="dark"] .brand a {
  background: url(logodark.svg) no-repeat;
}

.brand a:hover {
  text-decoration: none;
}
/* Hamburger button */
.hamburger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  z-index: 1100;
}

.hamburger.is-open {
  z-index: -0;
}

.hamburger .bars {
  width: 20px;
  height: 14px;
  position: relative;
  display: block;
}

.hamburger .bars span {
  position: absolute;
  left: 0; right: 0;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  transition: transform .18s ease, top .18s ease, opacity .14s ease;
}

.hamburger .bars span:nth-child(1) { top: 1px; }
.hamburger .bars span:nth-child(2) { top: 6px; }
.hamburger .bars span:nth-child(3) { top: 11px; }

.hamburger.is-open .bars span:nth-child(1) { top: 6px; transform: rotate(45deg); }
.hamburger.is-open .bars span:nth-child(2) { opacity: 0; }
.hamburger.is-open .bars span:nth-child(3) { top: 6px; transform: rotate(-45deg); }

.drawer-close {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  /*width: 100%;*/
  padding: 8px 12px;
  margin-bottom: 6px;
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
}

.drawer-close:hover {
  color: var(--text);
}

.drawer-close:focus-visible {
  outline: 2px solid rgba(37,99,235,.45);
  outline-offset: 2px;
}

/* Drawer */
.nav-drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: min(360px, 90vw);
  background: var(--card);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 14px;

  transform: translateX(110%);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;

  transition: transform 220ms ease, opacity 220ms ease, visibility 0s linear 220ms;
  z-index: 1050;
}

.nav-drawer.is-open {
  transform: translateX(0);
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: transform 220ms ease, opacity 220ms ease, visibility 0s linear 0s;
}

body.drawer-open { overflow: hidden; }

/* Drawer lists */
.drawer-list,
.drawer-sub {
  list-style: none;
  margin: 0;
  padding: 0;
}

.drawer-list {
  display: grid;
  gap: 8px;
}

.drawer-list a {
  display: block;
  padding: 10px 12px;
  text-decoration: none;
  color: var(--text);
}

.drawer-list a:hover {
  background: var(--pill-bg);
  text-decoration: none;
}

/* Parent row for nested sections */
.drawer-parent {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  background: transparent;
  border: 0px solid var(--border);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}

.drawer-parent .chev { transition: transform 180ms ease; }
.drawer-item.is-expanded .drawer-parent .chev { transform: rotate(180deg); }

/* Submenu animation */
.drawer-sub {
  margin: 6px 0 0;
  padding: 0 0 0 10px;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 220ms ease, opacity 180ms ease;
}

.drawer-item.is-expanded > .drawer-sub {
  max-height: 480px;
  opacity: 1;
}

.drawer-sub a {
  border: 1px solid var(--border);
  background: transparent;
}

/* =========================================================
   FORMS
   ========================================================= */

label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

input,select,textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--pill-bg);
  color: var(--text);
  padding: 11px 12px;
  outline: none;
}

textarea {
  min-height: 220px;
  resize: vertical;
}

/* =========================================================
   BUTTONS
   ========================================================= */

.btnrow {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

button,.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--pill-bg);
  color: var(--text);
  padding: 10px 14px;
  cursor: pointer;
}

button.primary,.btn.primary {
  background: rgba(37,99,235,.12);
  border-color: rgba(37,99,235,.35);
}

[data-theme="dark"] button.primary,
[data-theme="dark"] .btn.primary {
  background: rgba(106,166,255,.15);
  border-color: rgba(106,166,255,.35);
}

button.danger,.btn.danger {
  background: rgba(255,106,106,.10);
  border-color: rgba(255,106,106,.35);
}

button[aria-pressed="true"] {
  box-shadow: inset 0 0 0 2px rgba(106,166,255,.35);
}

/* =========================================================
   TEXT + DIVIDERS
   ========================================================= */

.muted { color: var(--muted); font-size: 14px; }
.small { font-size: 12px; color: var(--muted); }

.error {
  border: 1px solid var(--border);
    padding: 10px;
    border-radius: 12px;
    background: #c82626a1;
    color: #fff;
}
.error-illustration {
    width: 100%;
    max-width: 100%;
    margin: 0 auto 16px;
    aspect-ratio: 4 / 2;
    overflow: hidden;
    border-radius: 16px;
}

.error-illustration img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
}
.hr {
  height: 1px;
  background: var(--border);
  margin: 14px 0;
}

h2 { margin: 12px 0 8px; font-size: 18px; }
ol,ul { margin: 8px 0 0 22px; }
li { margin: 6px 0; }

/* =========================================================
   ACCESSIBILITY: FOCUS STYLES
   ========================================================= */

button: focus-visible,
a.btn: focus-visible,
input: focus-visible,
textarea: focus-visible,
select:focus-visible {
  outline: 2px solid rgba(37,99,235,.45);
  outline-offset: 2px;
}

[data-theme="dark"] button: focus-visible,
[data-theme="dark"] a.btn: focus-visible,
[data-theme="dark"] input: focus-visible,
[data-theme="dark"] textarea: focus-visible,
[data-theme="dark"] select:focus-visible {
  outline: 2px solid rgba(106,166,255,.55);
  outline-offset: 2px;
}

/* =========================================================
   FOOTER
   ========================================================= */

.site-footer {
  margin-top: 32px;
  padding: 20px 0;
  border-top: 1px solid var(--border);
}
.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* =========================================================
   iOS-STYLE TOGGLE
   ========================================================= */

.ios-toggle {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}
.ios-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.ios-toggle .track {
  width: 44px;
  height: 26px;
  background: #c7c7cc;
  border-radius: 999px;
  position: relative;
  transition: background .2s ease;
  flex-shrink: 0;
}
.ios-toggle .track::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 20px; height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,.35);
}
.ios-toggle input:checked + .track { background: #34c759; }
.ios-toggle input:checked + .track::after { transform: translateX(18px); }
.ios-toggle .label { font-size: 14px; color: var(--muted); }

/* =========================================================
   PILLS (unified)
   ========================================================= */

.pillrow {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
}

/* legacy link pill */
.pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--pill-bg);
  color: var(--muted);
  font-size: 12px;
  margin: 0 6px 6px 0;
}
.pill.active { font-weight: 700; }

/* unified chip/button style */
.pill-btn,
.pill-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 10px;
  background: var(--pill-bg);
  color: var(--text);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
}
.pill-btn span,
.pill-chip span{
  font-size: 12px !important;
}

.pill-btn: hover,
.pill-chip:hover {
  text-decoration: none;
  filter: brightness(.98);
}

.pill-btn.active,
.pill-chip.active {
  font-weight: 700;
  box-shadow: inset 0 0 0 2px rgba(37,99,235,.25);
}

[data-theme="dark"] .pill-btn.active,
[data-theme="dark"] .pill-chip.active {
  box-shadow: inset 0 0 0 2px rgba(106,166,255,.35);
}

/* show × only when active */
.pill-remove {
  display: none;
  font-weight: 800;
  opacity: .75;
}
.pill-btn.active .pill-remove,
.pill-chip.active .pill-remove {
  display: inline;
}
.pill-btn.active: hover .pill-remove,
.pill-btn.active: focus-visible .pill-remove,
.pill-chip.active: hover .pill-remove,
.pill-chip.active:focus-visible .pill-remove {
  opacity: 1;
}

#category-pills-selected .pill-btn.active {
  background: var(--pill-bg);
  border-color: var(--border);
}
/* =========================================================
   iOS-STYLE SEGMENTED CONTROL
   ========================================================= */

.filterControls,
.viewControls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
}

@media (max-width: 640px) {
  .viewControls { justify-content: flex-start; }
}

.segmented {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--border);
  background: var(--surface2);
  border-radius: 999px;
  padding: 4px;
  overflow: hidden;
  gap: 0;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.55);
}

[data-theme="dark"] .segmented {
  background: var(--pill-bg);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
}

.segBtn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 999px;
  font: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  line-height: 1;
  min-width: 92px;
}

[data-theme="dark"] .segBtn + .segBtn {
  border-left: 1px solid rgba(255,255,255,.08);
}

.segBtn:hover {
  color: var(--text);
  filter: brightness(.98);
}

.segBtn.is-active,
.segBtn[aria-selected="true"] {
  background: var(--card);
  color: var(--text);
  font-weight: 800;
  box-shadow: 0 1px 2px rgba(17,24,39,.10);
}
[data-theme="dark"] .segBtn.is-active,
[data-theme="dark"] .segBtn[aria-selected="true"] {
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(0,0,0,.35);
}

.segBtn:focus-visible {
  outline: 2px solid rgba(37,99,235,.45);
  outline-offset: 2px;
}
[data-theme="dark"] .segBtn:focus-visible {
  outline: 2px solid rgba(106,166,255,.55);
  outline-offset: 2px;
}

/* =========================================================
   INDEX: DENSITY TOKENS (MORE OBVIOUS)
   ========================================================= */

/* Comfortable */
html[data-density="comfortable"] {
  --card-pad: 16px;
  --card-gap: 14px;

  --thumb: 92px;
  --thumb-grid-h: 170px;

  --title-size: 18px;
  --meta-size: 13px;

  --desc-size: 14px;
  --desc-lines: 3;

  --action-font: 13px;
  --action-pad-y: 10px;
  --action-pad-x: 14px;
  --actions-width: 220px;

  --line-height: 1.4;
}

/* Compact */
html[data-density="compact"] {
  --card-pad: 10px;
  --card-gap: 8px;

  --thumb: 64px;
  --thumb-grid-h: 120px;

  --title-size: 15px;
  --meta-size: 12px;

  --desc-size: 13px;
  --desc-lines: 2;

  --action-font: 12px;
  --action-pad-y: 7px;
  --action-pad-x: 10px;
  --actions-width: 200px;

  --line-height: 1.25;
}

/* =========================================================
   INDEX: RESULTS + CARDS
   ========================================================= */

.results {
  margin-top: 12px;
  display: grid;
  gap: 12px;
}

html[data-view="grid"] .results {
  grid-template-columns: repeat(auto-fill,minmax(220px,1fr));
}

html[data-view="list"] .results {
  grid-template-columns: 1fr;
  gap: 10px;
}

/* Card base */
.recipeCard,
.recipe-card {
  background: var(--pill-bg);
  border: 1px solid var(--border);
  overflow: hidden;
}
/* Make each recipe card a column so actions can stick to bottom */
.recipeCard.recipe-card {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Ensure the body takes remaining space */
.recipeCard.recipe-card .recipeBody.recipe-body {
  flex: 1 1 auto;
  min-height: 0;
}

/* Pin actions to the bottom */
.recipeCard.recipe-card .recipeActions.recipe-actions {
  margin-top: auto;
}
/* GRID VIEW: vertical card */
html[data-view="grid"] .recipeCard,
html[data-view="grid"] .recipe-card {
  display: flex;
  flex-direction: column;
  min-height: 240px;
}

/* LIST VIEW: thumb | body | actions */
html[data-view="list"] .recipeCard,
html[data-view="list"] .recipe-card {
  display: grid;
  grid-template-columns: var(--thumb) 1fr var(--actions-width);
  gap: var(--card-gap);
  align-items: center;
  padding: var(--card-pad);
}

/* Thumbs */
html[data-view="grid"] .recipeThumb,
html[data-view="grid"] .recipe-thumb {
  width: 100%;
  height: var(--thumb-grid-h);
  display: block;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}

html[data-view="grid"] .recipeThumb img,
html[data-view="grid"] .recipe-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

html[data-view="list"] .recipeThumb,
html[data-view="list"] .recipe-thumb {
  width: var(--thumb);
  height: var(--thumb);
  border: 1px solid var(--border);
  overflow: hidden;
  background: var(--surface2);
}

html[data-view="list"] .recipeThumb img,
html[data-view="list"] .recipe-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Body spacing */
html[data-view="grid"] .recipeBody,
html[data-view="grid"] .recipe-body {
  padding: var(--card-pad);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

html[data-view="list"] .recipeBody,
html[data-view="list"] .recipe-body {
  padding: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.scaleBar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0 14px;
  flex-wrap: wrap;
}
.scaleBar .segmented .segBtn {
  min-width: auto;
  padding: 8px 10px;
}

/* Typography */
.recipeTitle,
.recipe-title {
  font-weight: 800;
  font-size: var(--title-size);
  line-height: var(--line-height);
  margin: 0;
  word-break: break-word;
}

.recipeMeta {
  color: var(--muted);
  font-size: var(--meta-size);
  line-height: var(--line-height);
  word-break: break-word;
}

.recipeMeta.small { opacity: .85; }

html[data-density="comfortable"][data-view="grid"] .results {
grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
}
html[data-density="compact"][data-view="grid"] .results {
grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
}

html[data-density="compact"][data-view="list"] .recipeMeta,
html[data-density="compact"][data-view="list"] .recipe-excerpt
{
  display: none !important;
}

/* Description clamp, affected by density */
.recipeDesc,
.recipe-excerpt {
  font-size: var(--desc-size);
  line-height: var(--line-height);
  margin-top: 2px;

  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
  -webkit-line-clamp: var(--desc-lines);
}

/* In compact LIST mode, make excerpt even tighter and optional */
html[data-density="compact"][data-view="list"] .recipeDesc,
html[data-density="compact"][data-view="list"] .recipe-excerpt {
  -webkit-line-clamp: 2;
}

/* Actions */
.recipeActions,
.recipe-actions {
  display: grid;
  gap: 10px;
  align-items: center;
}
actions layout: mobile stacked, desktop 2x2 */
.recipeCard .recipeActions,
.recipeCard .recipe-actions{
  display: grid !important;
  gap: 8px !important;
  grid-template-columns: 1fr !important; /* mobile */
  align-items: stretch !important;
}

/* Make each action fill its grid cell */
.recipeCard .recipeActions > a,
.recipeCard .recipeActions > form,
.recipeCard .recipe-actions > a,
.recipeCard .recipe-actions > form{
  width: 100% !important;
  margin: 0 !important;
}

/* Make buttons fill */
.recipeCard .recipeActions .btn,
.recipeCard .recipe-actions .btn{
  width: 100% !important;
  justify-content: center !important;
}

/* Desktop: 2 columns (2x2 if 4 actions exist) */
@media (min-width: 900px){
  .recipeCard .recipeActions,
  .recipeCard .recipe-actions{
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}
/* Grid: actions sit at bottom */
html[data-view="grid"] .recipeActions,
html[data-view="grid"] .recipe-actions {
  padding: var(--card-pad);
  padding-top: 0;
  grid-template-columns: 1fr;
}

/* List: actions in right column */
html[data-view="list"] .recipeActions,
html[data-view="list"] .recipe-actions {
  justify-self: end;
  width: var(--actions-width);
  display: grid;
  gap: 8px;
  align-self: center;
}

/* BIG difference: compact list uses 2-column actions (desktop/tablet) */
@media (min-width: 720px) {
  html[data-view="list"][data-density="compact"] .recipeActions,
  html[data-view="list"][data-density="compact"] .recipe-actions {
    grid-template-columns: 1fr 1fr;
    width: var(--actions-width);
    gap: 6px;
  }

  /* make "Delete" span full width if present */
  html[data-view="list"][data-density="compact"] .recipeActions .danger,
  html[data-view="list"][data-density="compact"] .recipe-actions .danger {
    grid-column: 1 / -1;
  }
}

/* Action button sizing responds to density */
.recipeActions .btn,
.recipeActions button,
.recipeActions form > button {
  width: 100%;
  justify-content: center;
  white-space: nowrap;
  font-size: var(--action-font);
  padding: var(--action-pad-y) var(--action-pad-x);
}

.recipeActions form {
  margin: 0;
  display: contents;
}

/* Mobile: list stacks */
@media (max-width: 640px) {
  html[data-view="list"] .recipeCard,
  html[data-view="list"] .recipe-card {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  html[data-view="list"] .recipeThumb,
  html[data-view="list"] .recipe-thumb {
    width: 100%;
    height: auto;
    aspect-ratio: 1/1;
    border-radius: 0;
  }

  html[data-view="list"] .recipeActions,
  html[data-view="list"] .recipe-actions {
    width: 100%;
    grid-template-columns: 1fr;
    justify-self: stretch;
  }
}

/* =========================================================
   LEGACY: recipeRow
   ========================================================= */

.recipeRow {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  padding: 12px;
  border: 1px solid var(--border);
  background: var(--pill-bg);
}
.recipeRow .title { font-weight: 700; }
.recipeRow .meta { color: var(--muted); font-size: 13px; margin-top: 4px; }
.recipeRow .actions { display: flex; gap: 10px; white-space: nowrap; }

/* =========================================================
   PROFILE: status list
   ========================================================= */

.status-list { display: grid; gap: 10px; margin-top: 10px; }
.status-row { display: flex; justify-content: space-between; align-items: center; font-size: 14px; }

/* =========================================================
   AUTHOR BADGE + LINK
   ========================================================= */

.authorLine {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.avatarBadge {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 12px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  flex: 0 0 auto;
  overflow: hidden;
}
.avatarBadge img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

html[data-density="compact"] .avatarBadge {
  width: 18px;
  height: 18px;
  font-size: 11px;
}

.authorLink {
  font-size: 12px;
  color: var(--muted);
  text-decoration: none;
}
.authorLink:hover {
  text-decoration: underline;
  color: var(--text);
}

/* =========================================================
   STEPS EDITOR
   ========================================================= */

.stepsEditor { display: grid; gap: 10px; margin-top: 8px; }
.stepRow { display: grid; grid-template-columns: 34px 1fr 44px; gap: 10px; align-items: start; }
.stepNum {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  background: var(--surface2);
  font-weight: 800;
}
.stepInput { min-height: 76px; }
.stepRemove { padding: 10px 0; }

/* =========================================================
   RECIPE: Step checklist
   ========================================================= */

.stepList { margin-top: 0; }

.stepItem { margin: 0 0 10px; }

.stepBtn {
  width: 100%;
  text-align: left;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--pill-bg);
  color: var(--text);
  cursor: pointer;
}

.stepBtn:hover { filter: brightness(.99); }

.stepCheck {
  width: 18px;
  height: 18px;
  border-radius: 6px;
  border: 2px solid rgba(107,114,128,.55);
  margin-top: 2px;
  flex: 0 0 auto;
  position: relative;
  background: transparent;
}

.stepItem.is-done .stepBtn {
  opacity: .62;
  filter: saturate(.85);
}

.stepItem.is-done .stepText {
  text-decoration: line-through;
}

.stepItem.is-done .stepCheck {
  border-color: rgba(37,99,235,.55);
  background: rgba(37,99,235,.12);
}

.stepItem.is-done .stepCheck::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 2px;
  width: 4px;
  height: 8px;
  border-right: 2px solid rgba(37,99,235,.9);
  border-bottom: 2px solid rgba(37,99,235,.9);
  transform: rotate(45deg);
}

[data-theme="dark"] .stepCheck {
  border-color: rgba(156,163,175,.55);
}

#themeToggle,
#tourStartBtn,
#logout {
  width: 100%;
  margin: 0px;
  text-align: center;
  font-size: small;
}

/* =========================================================
   VISIBILITY BADGE
   ========================================================= */

.visBadge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .2px;
  line-height: 1;
  border: 1px solid var(--border);
  background: var(--pill-bg);
  color: var(--muted);
  text-transform: uppercase;
}

/* Public */
.vis-public {
  background: rgba(34,197,94,.12);
  border-color: rgba(34,197,94,.35);
  color: #166534;
}

/* Private */
.vis-private {
  background: rgba(239,68,68,.12);
  border-color: rgba(239,68,68,.35);
  color: #7f1d1d;
}

/* Shared */
.vis-shared {
  background: rgba(59,130,246,.12);
  border-color: rgba(59,130,246,.35);
  color: #1e3a8a;
}

[data-theme="dark"] .vis-public { color: #86efac; }
[data-theme="dark"] .vis-private { color: #fca5a5; }
[data-theme="dark"] .vis-shared { color: #93c5fd; }




/* =========================================================
   TAG PILLS 
   ========================================================= */
.tagPill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface2);
  border: 1px solid var(--border);
  font-size: 13px;
}

.tagIcon {
  fill: currentColor;
  opacity: 0.75;
}

.tagPill:hover .tagIcon {
  opacity: 1;
}


/* =========================================================
   UAT CHECKLIST PAGE
   ========================================================= */


  fieldset { border:1px solid var(--border2); padding:16px; margin: 0 0 18px; border-radius:var(--radius); }
  legend { font-weight:700; padding:0 8px; }

  .metaGrid { display:grid; grid-template-columns: 1fr 1fr 1fr; gap:12px; margin-bottom:14px; }


  .taskRow { border:1px solid #eee; border-radius:var(--radius); padding:12px; margin-top:10px; }
  .rowTop { display:grid; grid-template-columns: 1fr 220px; gap:10px; align-items:center; }

     .taskTitle { font-weight:600; }


  .hint { font-size:12px; color:var(--muted); margin-top:6px; }
  .failExtras { display:none; margin-top:10px; }
  .failExtras .fileRow { display:flex; gap:10px; align-items:center; flex-wrap:wrap; }

  .btnPrimary { background:#111; color:#fff; border-color:#111; }

  .barWrap { position: sticky; top: 0; background:var(--surface); padding:10px 0 14px; z-index:5; border-bottom:1px solid #eee; margin-bottom:14px; }
  .barTop { display:flex; justify-content:space-between; align-items:center; gap:12px; }
  progress { width:100%; height:14px; }
  .barText { font-size:13px; color:#333; white-space:nowrap; }

  .errorBox { display:none; background:#fff4f4; border:1px solid #ffcccc; color:#7a0010; padding:12px; border-radius:var(--radius); margin:12px 0; }

  .pf-chips { display:flex; gap:8px; justify-content:flex-end; }
  .chip {
    border:1px solid var(--border);
    border-radius:999px;
    padding:6px 12px;
    font-weight:700;
    background:var(--surface);
    cursor:pointer;
    user-select:none;
  }
  .chip.pass { color:#0f766e; }
  .chip.fail { color:#b91c1c; }

  .chip.active.pass { background:#dcfce7; border-color:#16a34a; }
  .chip.active.fail { background:#fee2e2; border-color:#dc2626; }





/* =========================================================
   COOKIES
   ========================================================= */

  .cookie-banner[hidden] { display: none; }

  .cookie-banner {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 12px;
    z-index: 9999;
    display: flex;
    justify-content: center;
  }

  .cookie-card {
    width: min(920px, 100%);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,.15);
    padding: 14px;
  }

  .cookie-text p { max-width: 70ch; }

  .cookie-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
    margin-top: 10px;
  }

  .cookie-prefs .cookie-row {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    margin: 8px 0;
  }

  .cookie-prefs input[type="checkbox"] {
    margin-top: 3px;
    width:auto;
  }


#cookieBanner{
  position:fixed;
  inset:auto 16px 16px 16px;
  max-width:720px;
  margin:auto;
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:14px;
  padding:16px 18px;
  box-shadow:0 12px 40px rgba(0,0,0,.15);
  z-index:9999;
}
#cookieBanner h3{margin:0 0 6px;font-size:16px}
#cookieBanner p{margin:0 0 12px;font-size:14px;line-height:1.45}
#cookieBanner .grid{
  display:grid;
  gap:10px;
  margin:12px 0 14px;
}
@media (min-width:640px){
  #cookieBanner .grid{ grid-template-columns: 1fr 1fr; }
}
.cookieCard{
  border:1px solid var(--border);
  border-radius:12px;
  padding:12px;
  background:var(--surface2);
}
.cookieCard .top{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  margin-bottom:6px;
}
.cookieCard .title{font-weight:800}
.cookieCard .desc{margin:0;font-size:13px;line-height:1.45;color:var(--muted)}
.cookieRow{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  justify-content:flex-end;
  align-items:center;
  margin-top:12px;
}
#cookieBanner button{
  padding:8px 14px;
  border-radius:10px;
  border:1px solid var(--border);
  background:var(--surface2);
  cursor:pointer;
}
#cookieBanner button.primary{
  background:var(--accent);
  color:#fff;
  border-color:var(--accent);
}
#cookieBanner button.link{
  background:none;
  border:none;
  padding:8px 6px;
  color:var(--muted);
}
.cookieToggle{
  display:inline-flex;
  align-items:center;
  gap:10px;
}
.cookieToggle input{ accent-color: var(--accent); }
.smallLinks{
  display:flex;
  gap:12px;
  flex-wrap:wrap;
  font-size:13px;
  color:var(--muted);
}
.smallLinks a{ color:inherit; }


/* =========================================================
   MEAL PLANNER: Mobile layout fixes
   ========================================================= */

@media (max-width: 780px) {
  /* Give the page a little less side padding on small screens */
  #mealPlannerPage.container {
    padding: 14px;
  }
}

@media (max-width: 640px) {
  /* Stack each day row vertically instead of side-by-side */
  #mealPlannerList .recipeRow {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  /* Kill the desktop min-width behavior that causes overflow */
  #mealPlannerList .recipeRow > div {
    min-width: 0 !important;
    width: 100%;
  }

  /* The inline field wrapper has min-width:260px. Override it safely. */
  #mealPlannerList [id^="dayFields-"] {
    min-width: 0 !important;
    width: 100%;
  }

  /* The inline date label wrapper has min-width:220px. Override it safely. */
  #mealPlannerList [id^="dayRow-"] > div:first-child {
    min-width: 0 !important;
    width: 100%;
  }

  /* Make your "two" grid become one column on phones (if not already) */
  #mealPlannerList .grid.two {
    grid-template-columns: 1fr !important;
  }

  /* Make select/input/textarea feel better on mobile */
  #mealPlannerList select,
  #mealPlannerList input[type="text"],
  #mealPlannerList textarea {
    width: 100%;
  }

  /* Optional: tighten row padding a bit */
  #mealPlannerList .recipeRow {
    padding: 10px;
  }
}