/*
 * Recipe Tracker stylesheet.
 *

 */

/* ==========================================================================
   THEME TOKENS
   Every colour above is expressed as a CSS custom property. :root holds the
   built-in "default" palette (the original warm-paper look). Each theme is a
   [data-theme="key"] block (set on <body> from the logged-in user's profile,
   see User::THEMES) that overrides the structural tokens. Status/feedback
   colours (badges, flash) are deliberately shared so YES/MEH/NO keep one
   consistent traffic-light meaning across every theme.
   Palettes are the canonical published colours for each named theme.
   ========================================================================== */

:root {
  --page-bg:#f6f1e7; --surface:#ffffff; --surface-2:#efe7d8; --surface-hover:#fbf7ef;
  --text:#2f2b26; --text-2:#6b4a2f; --muted:#857a6c; --heading:#5a2015;
  --border:#e0d6c4; --border-strong:#cdbfa4; --border-soft:#eee3cf;
  --accent:#b5502a; --accent-hover:#98421f; --accent-on:#ffffff; --good-strong:#3f6b2e;
  --masthead-bg:#7a2e1d; --masthead-border:#5a2015; --masthead-text:#fdf6ec;
  --masthead-link:#f6d8bf; --masthead-link-hover:#ffe6da; --masthead-muted:#f0cbb4;
  --nav-sep:#b96a52;
  --btn-secondary:#6b6257; --btn-secondary-hover:#554d44; --btn-danger:#a33227;
  --btn-danger-on:#fff;   /* text on the danger button; dark in themes whose red is pale */

  /* Shared status + feedback (not re-themed; legible on light or dark). */
  --good:#4b9b3f; --warn:#d19a1e; --warn-2:#d06a1e; --bad:#c0392b; --neutral:#8a8078;
  --ok-bg:#e5f2df; --ok-border:#9ccf87; --ok-text:#2f5720;
  --err-bg:#fbe3e0; --err-border:#e39a90; --err-text:#7a2119;
  --info-bg:#eef4f8; --info-border:#b9cbd6; --info-text:#3f6a86;
}

/* Nord -- arctic, muted blue-grey (nordtheme.com). */
[data-theme="nord"] {
  --page-bg:#2e3440; --surface:#3b4252; --surface-2:#434c5e; --surface-hover:#353c4a;
  --text:#eceff4; --text-2:#d8dee9; --muted:#9aa4b8; --heading:#eceff4;
  --border:#434c5e; --border-strong:#4c566a; --border-soft:#3b4252;
  --accent:#88c0d0; --accent-hover:#8fbcbb; --accent-on:#2e3440;
  --masthead-bg:#3b4252; --masthead-border:#2e3440; --masthead-text:#eceff4;
  --masthead-link:#88c0d0; --masthead-link-hover:#eceff4; --masthead-muted:#9aa4b8;
  --nav-sep:#4c566a;
  --btn-secondary:#4c566a; --btn-secondary-hover:#434c5e; --btn-danger:#bf616a;
}

/* Solarized (dark) -- precision sepia base (ethanschoonover.com/solarized). */
[data-theme="solarized"] {
  --page-bg:#002b36; --surface:#073642; --surface-2:#0a4a59; --surface-hover:#063540;
  --text:#93a1a1; --text-2:#93a1a1; --muted:#657b83; --heading:#eee8d5;
  --border:#0a4a59; --border-strong:#586e75; --border-soft:#073642;
  --accent:#268bd2; --accent-hover:#2aa198; --accent-on:#fdf6e3;
  --masthead-bg:#073642; --masthead-border:#002b36; --masthead-text:#eee8d5;
  --masthead-link:#2aa198; --masthead-link-hover:#fdf6e3; --masthead-muted:#657b83;
  --nav-sep:#586e75;
  --btn-secondary:#586e75; --btn-secondary-hover:#657b83; --btn-danger:#dc322f;
}

/* Dracula -- vivid neon on charcoal (draculatheme.com). */
[data-theme="dracula"] {
  --page-bg:#282a36; --surface:#343746; --surface-2:#44475a; --surface-hover:#2f3240;
  --text:#f8f8f2; --text-2:#d3d4e0; --muted:#8b93b8; --heading:#f8f8f2;
  --border:#44475a; --border-strong:#565972; --border-soft:#343746;
  --accent:#bd93f9; --accent-hover:#ff79c6; --accent-on:#282a36;
  --masthead-bg:#343746; --masthead-border:#21222c; --masthead-text:#f8f8f2;
  --masthead-link:#bd93f9; --masthead-link-hover:#ff79c6; --masthead-muted:#8b93b8;
  --nav-sep:#6272a4;
  --btn-secondary:#6272a4; --btn-secondary-hover:#565972; --btn-danger:#ff5555;
  --btn-danger-on:#282a36;
}

/* Gruvbox (dark) -- retro-groove, warm earthy (github.com/morhetz/gruvbox). */
[data-theme="gruvbox"] {
  --page-bg:#282828; --surface:#3c3836; --surface-2:#504945; --surface-hover:#32302f;
  --text:#ebdbb2; --text-2:#d5c4a1; --muted:#a89984; --heading:#fabd2f;
  --border:#504945; --border-strong:#665c54; --border-soft:#3c3836;
  --accent:#fe8019; --accent-hover:#d65d0e; --accent-on:#282828;
  --masthead-bg:#3c3836; --masthead-border:#1d2021; --masthead-text:#fbf1c7;
  --masthead-link:#fabd2f; --masthead-link-hover:#fbf1c7; --masthead-muted:#a89984;
  --nav-sep:#665c54;
  --btn-secondary:#504945; --btn-secondary-hover:#665c54; --btn-danger:#cc241d;
}

/* Tokyo Night -- neon-noir indigo-navy (github.com/enkia/tokyo-night). */
[data-theme="tokyo_night"] {
  --page-bg:#1a1b26; --surface:#24283b; --surface-2:#2f344d; --surface-hover:#1f2233;
  --text:#c0caf5; --text-2:#a9b1d6; --muted:#7f88b0; --heading:#c0caf5;
  --border:#414868; --border-strong:#545c7e; --border-soft:#24283b;
  --accent:#7aa2f7; --accent-hover:#7dcfff; --accent-on:#1a1b26;
  --masthead-bg:#24283b; --masthead-border:#16161e; --masthead-text:#c0caf5;
  --masthead-link:#7aa2f7; --masthead-link-hover:#7dcfff; --masthead-muted:#7f88b0;
  --nav-sep:#414868;
  --btn-secondary:#414868; --btn-secondary-hover:#545c7e; --btn-danger:#f7768e;
  --btn-danger-on:#1a1b26;
}

/* Rose Pine -- muted rosy-mauve, "soho vibes" (rosepinetheme.com). */
[data-theme="rose_pine"] {
  --page-bg:#191724; --surface:#1f1d2e; --surface-2:#26233a; --surface-hover:#211f30;
  --text:#e0def4; --text-2:#cbc9e0; --muted:#908caa; --heading:#e0def4;
  --border:#403d52; --border-strong:#524f67; --border-soft:#26233a;
  --accent:#c4a7e7; --accent-hover:#ebbcba; --accent-on:#191724;
  --masthead-bg:#1f1d2e; --masthead-border:#100f1a; --masthead-text:#e0def4;
  --masthead-link:#c4a7e7; --masthead-link-hover:#ebbcba; --masthead-muted:#908caa;
  --nav-sep:#403d52;
  --btn-secondary:#403d52; --btn-secondary-hover:#524f67; --btn-danger:#eb6f92;
  --btn-danger-on:#191724;
}

/* Material -- ink on paper, saturated indigo (m2.material.io). Light theme. */
[data-theme="material"] {
  --page-bg:#fafafa; --surface:#ffffff; --surface-2:#eef0f6; --surface-hover:#f2f4f9;
  --text:#212121; --text-2:#424242; --muted:#757575; --heading:#1a237e;
  --border:#e0e0e0; --border-strong:#bdbdbd; --border-soft:#eeeeee;
  --accent:#3f51b5; --accent-hover:#303f9f; --accent-on:#ffffff;
  --masthead-bg:#3f51b5; --masthead-border:#303f9f; --masthead-text:#ffffff;
  --masthead-link:#e8eaf6; --masthead-link-hover:#ffffff; --masthead-muted:#c5cae9;
  --nav-sep:#7986cb;
  --btn-secondary:#616161; --btn-secondary-hover:#424242; --btn-danger:#b00020;
}

/* Secondary buttons keep light text (their grey backgrounds stay dark in every
   theme). Danger buttons use --btn-danger-on so themes with a pale red can put
   dark text on it for legibility -- they never follow --accent-on. */
.button.secondary, button.secondary { color: #fff; }
.button.danger, button.danger { color: var(--btn-danger-on); }

/* ---- Profile: live theme preview ---- */
.profile-theme .theme-preview {
  margin-top: 16px;
  max-width: 520px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--page-bg);
  color: var(--text);
}
.theme-preview .tp-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--masthead-bg);
  color: var(--masthead-text);
  border-bottom: 3px solid var(--masthead-border);
}
.theme-preview .tp-brand { font-weight: bold; }
.theme-preview .tp-nav { font-size: 12px; color: var(--masthead-link); }
.theme-preview .tp-body {
  padding: 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.theme-preview .tp-card {
  flex: 1 1 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
}
.theme-preview .tp-title { font-weight: bold; color: var(--heading); }
.theme-preview .tp-chips,
.theme-preview .tp-kids { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }


/* ---------- Base ---------- */
* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--page-bg);
}

a        { color: var(--accent); text-decoration: none; }
a:hover  { text-decoration: underline; }

.inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- Masthead ---------- */
#masthead {
  background: var(--masthead-bg);
  color: var(--masthead-text);
  padding: 14px 0;
  border-bottom: 4px solid var(--masthead-border);
}
#masthead .inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 18px;
}
.site-title {
  margin: 0;
  font-size: 22px;
}
.site-title a, .site-title a:hover {
  color: var(--masthead-text);
  text-decoration: none;
}
.main-nav a {
  color: var(--masthead-link);
  margin-right: 12px;
  font-size: 14px;
}
.main-nav a:hover { color: #fff; }
.main-nav .nav-sep { color: var(--nav-sep); margin-right: 8px; }

/* ---------- Content ---------- */
#content { padding-top: 24px; padding-bottom: 40px; min-height: 60vh; }

h1, h2, h3 { color: var(--heading); }
h1 { margin-top: 0; }

/* ---------- Flash ---------- */
.flash {
  padding: 10px 14px;
  border-radius: 4px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}
.flash-notice { background: var(--ok-bg); border-color: var(--ok-border); color: var(--ok-text); }
.flash-alert  { background: var(--err-bg); border-color: var(--err-border); color: var(--err-text); }

/* ---------- Buttons ---------- */
.button, button, input[type="submit"] {
  display: inline-block;
  background: var(--accent);
  color: var(--accent-on);
  border: none;
  padding: 8px 14px;
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
}
.button:hover, button:hover, input[type="submit"]:hover {
  background: var(--accent-hover);
  text-decoration: none;
}
.button.secondary { background: var(--btn-secondary); }
.button.secondary:hover { background: var(--btn-secondary-hover); }
.button.danger { background: var(--btn-danger); }
.button.small { padding: 4px 9px; font-size: 12px; }

/* ---------- Tables ---------- */
table.list {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
}
table.list th, table.list td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-soft);
  text-align: left;
  vertical-align: middle;
}
table.list th {
  background: var(--surface-2);
  color: var(--heading);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
table.list tr:hover td { background: var(--surface-hover); }

/* Sortable table headers (see sortable_table.js). */
table.sortable th.sortable-col { cursor: pointer; -webkit-user-select: none; -moz-user-select: none; user-select: none; }
table.sortable th.sortable-col:hover { background: var(--surface-hover); }
table.sortable th.sortable-col:after { content: '\2195'; opacity: 0.35; margin-left: 6px; font-size: 11px; }
table.sortable th.sort-asc:after  { content: '\2191'; opacity: 0.9; }
table.sortable th.sort-desc:after { content: '\2193'; opacity: 0.9; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: bold;
  color: #fff;
  white-space: nowrap;
}
.opinion-yes      { background: var(--good); }
.opinion-meh      { background: var(--warn); }
.opinion-no       { background: var(--bad); }
.opinion-notsure  { background: var(--neutral); }
.opinion-blank    { background: var(--surface-2); color: var(--muted); }

.complexity-easy   { background: var(--good); }
.complexity-medium { background: var(--warn); }
.complexity-hard   { background: var(--warn-2); }
.complexity-expert { background: var(--bad); }
.complexity-blank  { background: var(--surface-2); color: var(--muted); }

/* Marks a "My Recipe" that was imported from a linked website (vs written by us). */
.origin-badge {
  display: inline-block;
  vertical-align: middle;
  margin-left: 8px;
  padding: 1px 8px;
  border-radius: 10px;
  border: 1px solid var(--info-border);
  background: var(--info-bg);
  color: var(--info-text);
  font-size: 11px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
h1 .origin-badge { font-size: 13px; }

/* ---------- Forms ---------- */
.form-field { margin-bottom: 16px; }
.form-field label {
  display: block;
  font-weight: bold;
  margin-bottom: 4px;
  color: var(--heading);
}
input[type="text"], input[type="url"], input[type="email"], input[type="password"],
input[type="search"], input[type="number"], input[type="date"], input[type="file"],
textarea, select {
  width: 100%;
  max-width: 520px;
  padding: 7px 8px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
}
/* Native <select> dropdown list items (and date/time controls) use OS defaults
   unless told otherwise -- without this the option text renders black on the
   dark themes' dark surface and is unreadable. */
select option, select optgroup { background: var(--surface); color: var(--text); }
input[type="date"] { color-scheme: light dark; }
textarea { min-height: 90px; }
.form-actions { margin-top: 20px; }
.field-hint { color: var(--muted); font-size: 12px; }

.errors {
  background: var(--err-bg);
  border: 1px solid var(--err-border);
  color: var(--err-text);
  padding: 10px 14px;
  border-radius: 4px;
  margin-bottom: 16px;
}
.errors ul { margin: 6px 0 0 18px; }

/* ---------- Ratings grid on the form ---------- */
.ratings-grid { display: table; border-spacing: 10px 0; }
.rating-cell  { display: inline-block; margin-right: 16px; }
.rating-cell label { display: block; }

/* ---------- Recipe show ---------- */
.recipe-meta { margin: 0 0 20px 0; padding: 0; list-style: none; }
.recipe-meta li { margin-bottom: 6px; }
.recipe-meta .label { display: inline-block; width: 130px; font-weight: bold; color: var(--heading); }

.section { margin-bottom: 28px; }
.section h2 {
  border-bottom: 2px solid var(--border);
  padding-bottom: 6px;
}

/* ---------- Pictures ---------- */
.gallery { list-style: none; margin: 0; padding: 0; }
.gallery li {
  display: inline-block;
  vertical-align: top;
  margin: 0 12px 12px 0;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 6px;
  border-radius: 4px;
}
.gallery img {
  display: block;
  max-width: 220px;
  max-height: 220px;
  height: auto;
}
.gallery .caption { font-size: 12px; color: var(--muted); margin-top: 4px; max-width: 220px; }
.thumb-small img { max-width: 70px; max-height: 70px; }

/* ---------- Recipes index: wider than other pages (for the many-column
   table) but still centered in the window like every other page. ---------- */
body.recipes-index #masthead .inner,
body.recipes-index #content.inner {
  max-width: 1440px;
}
/* The table sizes to its content (not stretched) so it stays compact; if it
   needs more than the container, .table-scroll scrolls it horizontally. */
body.recipes-index table.sortable-table { width: auto; }

/* ---------- Sortable / filterable table ---------- */
.table-scroll { overflow-x: auto; }

/* Compact cells so all columns fit without horizontal scrolling. */
table.sortable-table { font-size: 13px; }
table.sortable-table th,
table.sortable-table td { padding: 5px 8px; }

/* Notes column: capped width, wraps instead of forcing the table wide. */
table.sortable-table td.note-cell { color: var(--muted); font-size: 12px; }
table.sortable-table td.note-cell .note-clip {
  max-width: 300px;
  white-space: normal;
  line-height: 1.35;
}

table.sortable-table th.sortable {
  cursor: pointer;
  white-space: nowrap;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}
table.sortable-table th.sortable:hover { background: var(--surface-hover); }
table.sortable-table th.sorted { background: var(--surface-2); }
table.sortable-table th .sort-ind {
  font-size: 11px;
  color: var(--muted);
  margin-left: 3px;
}

table.sortable-table tr.filter-row th {
  background: var(--surface-2);
  padding: 4px 6px;
  border-bottom: 1px solid var(--border);
}
table.sortable-table tr.filter-row input,
table.sortable-table tr.filter-row select {
  width: 100%;
  min-width: 68px;
  max-width: none;
  padding: 3px 4px;
  font-size: 12px;
}

/* ---------- "Has a write-up" indicator ---------- */
.recipe-doc-icon,
.recipe-link-icon {
  text-decoration: none;
  margin-left: 5px;
  font-size: 13px;
  opacity: 0.8;
  cursor: pointer;
}
.recipe-doc-icon:hover,
.recipe-link-icon:hover { opacity: 1; text-decoration: none; }

/* ---------- Inline-editable cells ---------- */
table.sortable-table td.editable {
  cursor: pointer;
  position: relative;
}
table.sortable-table td.editable:hover {
  background: var(--surface-hover);
  box-shadow: inset 0 0 0 1px var(--border-strong);
}
table.sortable-table td.editable:hover:after {
  content: "\270E"; /* pencil */
  position: absolute;
  top: 3px;
  right: 4px;
  font-size: 10px;
  color: var(--accent);
}
table.sortable-table td.editing,
table.sortable-table td.editing:hover { background: var(--surface); box-shadow: none; }
table.sortable-table td.editing:after { content: none; }
.inline-edit-select {
  width: 100%;
  min-width: 90px;
  max-width: none;
  padding: 3px 4px;
  font-size: 13px;
}
table.sortable-table td.saving { opacity: 0.5; }
table.sortable-table td.cell-saved { background: var(--ok-bg) !important; box-shadow: inset 0 0 0 1px var(--ok-border) !important; }
table.sortable-table td.cell-error { background: var(--err-bg) !important; box-shadow: inset 0 0 0 1px var(--err-border) !important; }

/* ---------- Filter bar ---------- */
.filter-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 12px 14px;
  margin-bottom: 20px;
}
.filter-bar .filter-field {
  display: inline-block;
  vertical-align: bottom;
  margin: 0 12px 8px 0;
}
.filter-bar label { display: block; font-size: 12px; font-weight: bold; color: var(--heading); }
.filter-bar select, .filter-bar input[type="text"] { width: auto; min-width: 140px; }

/* ---------- Misc ---------- */
.toolbar { margin-bottom: 18px; }
.muted { color: var(--muted); }
.inline-form { display: inline; }
.stat-cards { margin: 0 0 24px 0; padding: 0; list-style: none; }
.stat-cards li {
  display: inline-block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px 22px;
  margin: 0 12px 12px 0;
  text-align: center;
}
.stat-cards .num { display: block; font-size: 30px; font-weight: bold; color: var(--accent); }
.stat-cards .lbl { color: var(--muted); font-size: 13px; }

/* ---------- View toggle (table / tiles) ---------- */
.view-toggle { display: inline-block; margin-left: 4px; vertical-align: middle; }
.view-toggle .view-btn { border-radius: 0; margin: 0; }
.view-toggle .view-btn:first-child { border-radius: 4px 0 0 4px; }
.view-toggle .view-btn:last-child  { border-radius: 0 4px 4px 0; }
.view-toggle .view-btn.is-active { background: var(--accent); }
.view-toggle .view-btn.is-active:hover { background: var(--accent-hover); }

/* Show one container at a time. In tiles mode the table header stays visible
   so its sort + per-column filters still drive both views; only the tbody is
   hidden. */
#recipes-view.view-table #recipes-tiles { display: none; }
#recipes-view.view-tiles #recipes-table tbody { display: none; }
/* With the tbody hidden the header table would shrink to its own content width;
   stretch it to fill the container so the sort/filter header lines up with the
   full-width tiles grid below it. */
#recipes-view.view-tiles #recipes-table { width: 100%; }

/* ---------- Tiles / cards ---------- */
.tiles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.recipe-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.tile-photo {
  height: 150px;
  background: var(--surface-2);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tile-photo img {
  width: 100%;
  height: 150px;
  object-fit: cover;
  display: block;
}
.tile-photo:hover { text-decoration: none; }
.tile-noimg { color: var(--muted); font-size: 13px; }
.tile-body {
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tile-title { font-weight: bold; font-size: 15px; line-height: 1.25; }
.tile-title a { color: var(--heading); }
.tile-meta { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.chip {
  display: inline-block;
  background: var(--surface-2);
  color: var(--text-2);
  border-radius: 10px;
  padding: 2px 8px;
  font-size: 12px;
  white-space: nowrap;
}
.tile-ratings { display: flex; flex-wrap: wrap; gap: 6px; }
.tile-rating { display: inline-flex; align-items: center; gap: 4px; }
.tile-rating-name { font-size: 11px; color: var(--muted); }

/* ---------- Recipe show: hero photo ---------- */
.recipe-hero {
  position: relative;
  margin: 0 0 20px 0;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-2);
}
.recipe-hero-img {
  display: block;
  width: 100%;
  max-height: 380px;
  object-fit: cover;
}
.recipe-hero-overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 32px 20px 14px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.68), rgba(0, 0, 0, 0));
}
.recipe-hero-title {
  margin: 0;
  color: #fff;
  font-size: 30px;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}

/* ---------- Meal planner ---------- */
.meal-week h2, .meal-history h2 { margin-bottom: 8px; }
.week-range {
  font-size: 15px;
  font-weight: normal;
  color: var(--muted);
  margin-left: 8px;
}
.more-weeks { margin-top: 10px; }

.meal-grid-wrap { overflow-x: auto; }
.meal-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  min-width: 900px;
  background: var(--surface);
}
.meal-table th, .meal-table td {
  border: 1px solid var(--border);
  vertical-align: top;
  padding: 4px 6px;
}
.meal-rowhead {
  width: 78px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12px;
  text-align: right;
  white-space: nowrap;
}
.meal-dayhead {
  background: var(--masthead-bg);
  color: var(--masthead-text);
  font-size: 12px;
  text-align: center;
  line-height: 1.2;
}
.meal-dayname { display: block; font-weight: bold; }
.meal-daydate { display: block; font-size: 11px; opacity: 0.85; }

.meal-cell, .event-cell { height: 44px; }
.meal-cell .cell-items, .event-cell .cell-items { min-height: 20px; }
.editable-cell, .editable-events { cursor: text; }
.editable-cell:hover, .editable-events:hover { background: var(--surface-hover); }

.meal-item { font-size: 13px; line-height: 1.3; padding: 1px 0; }
.meal-item a { color: var(--accent); }
.meal-item.made-recently { color: var(--warn-2); }
.repeat-flag { font-size: 11px; }
/* Count badge when an item's name matches more than one recipe (click to pick) */
.meal-match-count {
  font-size: 11px;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: 8px;
  padding: 0 5px;
  margin-left: 4px;
}

.events-row .meal-rowhead { background: var(--surface-2); }
.event-cell { background: var(--surface-hover); }
.event-item {
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.3;
  padding: 1px 0;
}

.cell-editor {
  width: 100%;
  box-sizing: border-box;
  font-family: inherit;
  font-size: 13px;
  border: 1px solid var(--accent);
  border-radius: 3px;
  padding: 3px 4px;
  resize: vertical;
}
.cell-saved { background: var(--ok-bg) !important; transition: background 0.3s; }
.cell-error { background: var(--err-bg) !important; transition: background 0.3s; }
.meal-cell.saving, .event-cell.saving { opacity: 0.6; }

/* Compact read-only history grids */
.history-week { margin-bottom: 22px; }
.history-week h3 { margin: 0 0 6px 0; font-size: 16px; }
.is-compact .meal-table { min-width: 760px; }
.is-compact .meal-table th, .is-compact .meal-table td { padding: 2px 5px; }
.is-compact .meal-cell, .is-compact .event-cell { height: auto; }
.is-compact .meal-item, .is-compact .event-item { font-size: 12px; }

/* Want-to-try list */
.wishlist { margin: 26px 0; }
.wishlist-add {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.wishlist-add input[type=text] {
  padding: 5px 7px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  font-size: 14px;
}
.wishlist-add input[placeholder='Dish to try'] { flex: 1 1 200px; }
.wishlist-add input[placeholder='Link (optional)'] { flex: 1 1 220px; }
.wishlist-add input[placeholder='Notes (optional)'] { flex: 1 1 160px; }
.wishlist-list { list-style: none; margin: 0; padding: 0; }
.wishlist-list li {
  padding: 6px 0;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.wishlist-main { flex: 1 1 200px; }
.wishlist-notes { font-size: 12px; color: var(--muted); margin-left: 6px; }
.wishlist-actions { font-size: 12px; }

/* Print the week: on the planner pages, strip everything but the week grid and
   print it landscape in ink-friendly black-on-white. Scoped to meal_plans pages
   (any meal_plans-* body class) so it never affects other pages' printing. The
   Print button lives in the toolbar, which is hidden below, so it never prints. */
@media print {
  body[class*="meal_plans-"] #masthead,
  body[class*="meal_plans-"] .flash,
  body[class*="meal_plans-"] .toolbar,
  body[class*="meal_plans-"] .field-hint,
  body[class*="meal_plans-"] .more-weeks,
  body[class*="meal_plans-"] .meal-history,
  body[class*="meal_plans-"] .wishlist,
  body[class*="meal_plans-"] .no-print { display: none !important; }

  @page { size: landscape; margin: 0.5in; }

  body[class*="meal_plans-"] #content { margin: 0; padding: 0; }

  /* Let the grid fill the page instead of scrolling in a fixed-min-width box. */
  body[class*="meal_plans-"] .meal-grid-wrap { overflow: visible; }
  body[class*="meal_plans-"] .meal-table { min-width: 0; width: 100%; }

  /* Ink-friendly headers: the on-screen dark masthead colour won't print, so
     force black-on-white with a solid border instead. */
  body[class*="meal_plans-"] .meal-dayhead {
    background: #fff; color: #000; border-bottom: 2px solid #000;
  }
  body[class*="meal_plans-"] .meal-daydate { opacity: 1; }
  body[class*="meal_plans-"] .meal-rowhead,
  body[class*="meal_plans-"] .event-cell { background: #fff; color: #000; }

  /* Room to read each cell; keep whole rows together across page breaks. */
  body[class*="meal_plans-"] .meal-cell,
  body[class*="meal_plans-"] .event-cell { height: auto; min-height: 0.55in; }
  body[class*="meal_plans-"] .meal-table tr { page-break-inside: avoid; }

  /* Crisp black borders + text on paper. */
  body[class*="meal_plans-"] .meal-table th,
  body[class*="meal_plans-"] .meal-table td { border: 1px solid #000; }
  body[class*="meal_plans-"] .meal-item,
  body[class*="meal_plans-"] .meal-item a,
  body[class*="meal_plans-"] .meal-item.made-recently,
  body[class*="meal_plans-"] .event-item { color: #000; }
}
.wishlist-actions a { margin-left: 8px; }

.wishlist-pull {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0;
}
.wishlist-pull select {
  font-size: 12px;
  padding: 2px 4px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: var(--surface);
}
.button.btn-small { padding: 3px 9px; font-size: 12px; }

/* ---------- Photo lightbox ---------- */
img.has-lightbox { cursor: zoom-in; }

.lightbox-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.85);
  /* center the figure and flank it with the nav arrows */
  text-align: center;
}
.lightbox-overlay.is-open { display: flex; align-items: center; justify-content: center; }

.lightbox-figure {
  margin: 0;
  max-width: 92%;
  max-height: 92%;
}
.lightbox-img {
  display: block;
  max-width: 100%;
  max-height: 84vh;
  height: auto;
  margin: 0 auto;
  border-radius: 4px;
  box-shadow: 0 6px 30px rgba(0, 0, 0, 0.6);
  cursor: default;
}
.lightbox-caption {
  margin-top: 10px;
  color: #f2ece0;
  font-size: 14px;
}

.lightbox-close,
.lightbox-nav {
  position: absolute;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  border: none;
  cursor: pointer;
  line-height: 1;
  border-radius: 6px;
}
.lightbox-close {
  top: 14px; right: 18px;
  font-size: 30px;
  width: 44px; height: 44px;
}
.lightbox-nav {
  top: 50%;
  transform: translateY(-50%);
  font-size: 44px;
  width: 54px; height: 74px;
}
.lightbox-prev { left: 14px; }
.lightbox-next { right: 14px; }
.lightbox-close:hover,
.lightbox-nav:hover { background: rgba(255, 255, 255, 0.2); }

/* ---------- Print: a My Recipe as a clean recipe card ---------- */
/* Shown only when printing (see the @media print block below). */
.print-only { display: none; }

@media print {
  /* Scoped to the My Recipe show page (body class = "controller-action"), so
     every other page still prints with the browser default. Strip the site
     chrome and the picture-management UI, leaving title + ingredients +
     instructions + notes — plus one finished-dish photo. */
  body.own_recipes-show #masthead,
  body.own_recipes-show #site-footer,
  body.own_recipes-show .toolbar,
  body.own_recipes-show .flash,
  body.own_recipes-show .origin-badge,
  body.own_recipes-show .no-print {
    display: none !important;
  }

  body.own_recipes-show,
  body.own_recipes-show #page,
  body.own_recipes-show #content.inner {
    margin: 0;
    padding: 0;
    max-width: none;
    width: auto;
    background: var(--surface);
    color: #000;
    box-shadow: none;
  }

  body.own_recipes-show h1 { font-size: 22pt; margin: 0 0 8pt; }
  body.own_recipes-show h2 { font-size: 13pt; margin: 12pt 0 4pt; page-break-after: avoid; }
  body.own_recipes-show .section { margin: 0 0 8pt; }
  body.own_recipes-show p { orphans: 3; widows: 3; }
  body.own_recipes-show a { text-decoration: none; color: #000; }

  body.own_recipes-show .print-only { display: block; }
  body.own_recipes-show .recipe-print-photo { margin: 0 0 10pt; }
  body.own_recipes-show .recipe-print-photo img {
    max-width: 3.2in;
    max-height: 3.2in;
    height: auto;
  }
}

/* ---------- Cook mode ---------- */
/* Full-screen hands-free view. The [hidden] attribute hides it until opened, so
   display lives on :not([hidden]) (never unconditionally, or [hidden] loses). */
.cook-mode {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 1100;
  flex-direction: column;
  background: var(--surface-hover);   /* warm, high-contrast for reading across a kitchen */
  color: var(--text);
}
.cook-mode:not([hidden]) { display: flex; }

.cook-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.cook-title { font-size: 20px; font-weight: bold; }
.cook-close { font-size: 15px; }

.cook-body { flex: 1; display: flex; min-height: 0; }

.cook-ingredients {
  width: 300px;
  flex: none;
  padding: 16px 20px;
  border-right: 1px solid var(--border);
  overflow-y: auto;
}
.cook-ingredients h2 { margin: 0 0 10px; font-size: 16px; }
.cook-ingredients ul { margin: 0; padding-left: 20px; }
.cook-ingredients li { margin: 0 0 8px; font-size: 17px; line-height: 1.35; }

.cook-steps {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px 28px;
  min-width: 0;
}
.cook-progress { color: var(--muted); font-size: 15px; margin-bottom: 12px; }
.cook-step-list {
  flex: 1;
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
}
.cook-step { display: none; }
.cook-step.is-active {
  display: block;
  font-size: 30px;
  line-height: 1.45;
  max-width: 22em;
}
.cook-nav { display: flex; gap: 14px; padding-top: 16px; }
.cook-nav .button { font-size: 18px; padding: 12px 22px; }
.cook-nav .button[disabled] { opacity: 0.4; cursor: default; }

@media (max-width: 700px) {
  .cook-body { flex-direction: column; }
  .cook-ingredients {
    width: auto;
    max-height: 30vh;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .cook-step.is-active { font-size: 24px; }
}

/* ---------- Global search ---------- */
/* Compact box in the masthead (present on every page). Pushed to the right so
   the title + nav sit on the left of the single-row header. */
.site-search { margin: 0 0 0 auto; }
.site-search input[type="text"] {
  padding: 5px 8px;
  border: 1px solid var(--masthead-border);
  border-radius: 4px;
  font-size: 13px;
  width: 240px;
  max-width: 60%;
  vertical-align: middle;
}
.site-search .button { padding: 5px 12px; font-size: 13px; vertical-align: middle; }

/* Larger box on the search results page. */
.search-form-lg { margin: 0 0 18px; }
.search-form-lg input[type="text"] {
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  font-size: 16px;
  width: 420px;
  max-width: 70%;
  vertical-align: middle;
}

.search-own { list-style: none; margin: 0; padding: 0; }
.search-own li { margin: 0 0 12px; }
.search-own .origin-badge { margin-left: 6px; }

/* --- Authentication ------------------------------------------------------ */

/* Login state in the masthead. */
.user-box {
  display: inline-block;
  font-size: 13px;
  white-space: nowrap;
}
.user-box .user-name { color: var(--masthead-muted); margin-right: 8px; }
.user-box .user-logout { color: #fff; text-decoration: underline; }
.user-box .user-logout:hover { color: var(--masthead-link-hover); }

/* Login page. */
.login-page {
  max-width: 360px;
  margin: 48px auto;
  padding: 28px 30px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.login-page h2 { margin: 0 0 6px; }
.login-page .login-intro { color: var(--text-2); margin: 0 0 20px; }
.login-form .field { margin: 0 0 16px; }
.login-form label { display: block; font-weight: bold; margin: 0 0 4px; font-size: 14px; }
.login-form input[type="text"],
.login-form input[type="password"] {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  font-size: 15px;
  box-sizing: border-box;
}
.login-form .actions { margin-top: 20px; }
.login-form .actions .button { width: 100%; padding: 10px; font-size: 15px; }

/* Role badge in the Accounts list. */
.role-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: bold;
  text-transform: capitalize;
}
.role-admin  { background: var(--ok-bg); color: var(--good-strong); }
.role-viewer { background: var(--surface-2); color: var(--text-2); }

/* Small helper text under form fields. */
.form-field .hint,
.hint { display: block; color: var(--muted); font-size: 12px; margin-top: 3px; }

/* Cooked log (recipe show page + index column). */
.cooked-log .cooked-summary { margin: 0 0 12px; font-size: 15px; }
.cooked-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin: 0 0 14px;
}
.cooked-backdate { display: flex; align-items: center; gap: 8px; margin: 0; }
.cooked-backdate label { font-size: 13px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.cooked-backdate input[type="date"] {
  padding: 6px 8px;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  font-size: 14px;
}
.cooked-history { list-style: none; margin: 0; padding: 0; }
.cooked-history li {
  padding: 5px 0;
  border-top: 1px solid var(--border-soft);
  font-size: 14px;
}
.cooked-history .cooked-row { display: flex; align-items: center; gap: 8px; }
.cooked-history .cooked-when { font-weight: bold; }
.cooked-history .cooked-row .button.small { margin-left: auto; }
.cooked-note {
  margin: 3px 0 0;
  font-style: italic;
  color: var(--text-2);
}
.cooked-note-edit { display: flex; align-items: center; gap: 6px; margin: 4px 0 0; }
.cooked-note-edit input[type="text"] { flex: 1 1 auto; max-width: 340px; }
.cooked-date { white-space: nowrap; }

/* Last-cooked line on a recipe tile. */
.tile-cooked { margin-top: 8px; font-size: 13px; }
.tile-cooked-label { color: var(--muted); margin-right: 4px; }

/* ---- Shopping list (management view) ---- */
.shopping-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 0 4px;
}
.shopping-toolbar form { margin: 0; }        /* button_to renders a <form> -- keep it inline */
.shopping-toolbar .button { margin: 0; }

.shopping-add-fields {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.shopping-add-fields input[type="text"] {
  padding: 5px 8px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  font-size: 13px;
}
.shopping-add-fields .si-name  { flex: 2 1 160px; }
.shopping-add-fields .si-qty   { flex: 1 1 110px; }
.shopping-add-fields .si-note  { flex: 2 1 150px; }
.shopping-add-fields .si-store { padding: 5px; border: 1px solid var(--border-strong); border-radius: 4px; font-size: 13px; }

.shopping-stores {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-start;
}
.store-card {
  flex: 1 1 300px;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px 4px;
}
.store-head {
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border-soft);
  padding-bottom: 4px;
  margin-bottom: 2px;
}
.store-head h2 { margin: 0; font-size: 15px; }
.store-count { color: var(--muted); font-size: 12px; }
.store-head .button { margin-left: auto; }

.shopping-list { list-style: none; margin: 0; padding: 0; }
.shopping-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  border-top: 1px solid var(--border-soft);
}
.shopping-row:first-child { border-top: 0; }

.si-toggle-form { margin: 0; flex: 0 0 auto; }
.si-toggle {
  cursor: pointer;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 2px solid var(--border-strong);
  border-radius: 4px;
  background: var(--surface);
  color: var(--good-strong);
  font-size: 13px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.si-toggle:hover { border-color: var(--good-strong); }
.si-box { display: inline-block; }

.si-text { flex: 1 1 auto; min-width: 0; }
.si-item { font-size: 14px; font-weight: bold; }
.si-qty-tag {
  display: inline-block;
  margin-left: 5px;
  padding: 0 6px;
  background: var(--surface-2);
  border-radius: 9px;
  font-size: 11px;
  color: var(--text-2);
}
.si-note-tag {
  color: var(--muted);
  font-size: 11px;
  margin-left: 6px;
}
.si-actions { flex: 0 0 auto; display: flex; align-items: center; gap: 2px; }
.si-actions form { margin: 0; display: inline; }
.si-icon {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 6px;
  background: none;
  border: 0;
  border-radius: 4px;
  font-size: 14px;
  line-height: 1;
  text-decoration: none;
}
.si-icon:hover { background: var(--border-soft); }
.si-icon.si-del:hover { background: var(--err-bg); }

/* Drag-to-reorder handle (arrange items in the order you hit them in the store). */
.si-grip {
  flex: 0 0 auto;
  cursor: grab;
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
  touch-action: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
}
.si-grip:active { cursor: grabbing; }
.shopping-row.is-dragging { opacity: .55; background: var(--surface-hover); }

/* Inline edit: hidden until the row is being edited, then it takes the row. */
.si-edit { display: none; margin: 0; }
.shopping-row.is-editing { flex-wrap: wrap; }
.shopping-row.is-editing .si-text,
.shopping-row.is-editing .si-actions,
.shopping-row.is-editing .si-grip,
.shopping-row.is-editing .si-toggle-form { display: none; }
.shopping-row.is-editing .si-edit {
  display: flex;
  flex: 1 1 100%;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
}
.si-edit input[type="text"],
.si-edit select {
  padding: 4px 7px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  font-size: 13px;
}
.si-edit .si-edit-name { flex: 2 1 130px; }
.si-edit .si-edit-qty  { flex: 1 1 80px; }
.si-edit .si-edit-note { flex: 2 1 110px; }
.si-edit .button.small { padding: 3px 9px; font-size: 12px; }

/* Purchased: struck through, muted, and it sinks to the bottom on reload. */
.shopping-row.is-purchased .si-item,
.shopping-row.is-purchased .si-qty-tag,
.shopping-row.is-purchased .si-note-tag { text-decoration: line-through; color: var(--muted); }
.shopping-row.is-purchased .si-toggle { background: var(--ok-bg); border-color: var(--good-strong); }

@media (max-width: 520px) {
  .shopping-add-fields .si-name,
  .shopping-add-fields .si-qty,
  .shopping-add-fields .si-note { flex: 1 1 100%; }
  .store-card { flex-basis: 100%; }
}

/* ---- Shopping mode (phone-friendly in-store view) ---- */
.shop-view { max-width: 560px; margin: 0 auto; }

.shop-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0 6px;
  background: var(--page-bg);
}
.shop-bar h1 { margin: 0; font-size: 18px; }
.shop-bar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.shop-hidebought { font-size: 13px; color: var(--text-2); display: flex; align-items: center; gap: 5px; }
.shop-hidebought input { width: 15px; height: 15px; }

/* Store filter pills -- horizontally scrollable, stays put under the bar. */
.shop-filter {
  position: sticky;
  top: 34px;
  z-index: 4;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 4px 0 6px;
  background: var(--page-bg);
  -webkit-overflow-scrolling: touch;
}
.shop-pill {
  flex: 0 0 auto;
  cursor: pointer;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-2);
  border-radius: 14px;
  padding: 4px 11px;
  font-size: 13px;
  white-space: nowrap;
}
.shop-pill.is-active { background: var(--good-strong); border-color: var(--good-strong); color: #fff; }
.shop-pill-count {
  display: inline-block;
  min-width: 16px;
  margin-left: 3px;
  padding: 0 5px;
  border-radius: 9px;
  background: rgba(0,0,0,.12);
  font-size: 11px;
  text-align: center;
}
.shop-pill.is-active .shop-pill-count { background: rgba(255,255,255,.25); }

.shop-store-name {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  margin: 10px 0 1px;
}
.shop-list { list-style: none; margin: 0; padding: 0; }

.shop-row { border-bottom: 1px solid var(--border-soft); }
.shop-toggle-form { margin: 0; }
.shop-toggle-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  padding: 6px 4px;
  background: none;
  border: 0;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
}
.shop-readonly { cursor: default; }
.shop-check {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border: 2px solid var(--border-strong);
  border-radius: 5px;
  background: var(--surface);
  color: var(--good-strong);
  font-size: 14px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.shop-item-text { flex: 1 1 auto; min-width: 0; }
.shop-item-name { display: block; font-size: 15px; font-weight: bold; }
.shop-item-sub { display: inline; }
.shop-item-qty {
  display: inline-block;
  margin-left: 6px;
  padding: 0 7px;
  background: var(--surface-2);
  border-radius: 9px;
  font-size: 12px;
  color: var(--text-2);
}
.shop-item-note { color: var(--muted); font-size: 12px; margin-left: 6px; }

/* Checked-off: green check, struck through. */
.shop-row.is-purchased .shop-check { background: var(--good-strong); border-color: var(--good-strong); color: #fff; }
.shop-row.is-purchased .shop-item-name,
.shop-row.is-purchased .shop-item-qty,
.shop-row.is-purchased .shop-item-note { text-decoration: line-through; color: var(--muted); }

/* "Hide bought" removes checked rows from view. */
.shop-view.hide-bought .shop-row.is-purchased { display: none; }

.shop-empty { font-size: 14px; padding: 16px 0; }

/* ---- Administration hub ---- */
.admin-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-start;
  margin-top: 12px;
}
.admin-card {
  flex: 1 1 220px;
  max-width: 320px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 18px 14px;
}
.admin-card h2 {
  margin: 0 0 6px;
  font-size: 16px;
  border-bottom: 1px solid var(--border-soft);
  padding-bottom: 6px;
}
.admin-card ul { list-style: none; margin: 0; padding: 0; }
.admin-card li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 0;
}
.admin-card li + li { border-top: 1px solid var(--border-soft); }
.admin-count {
  min-width: 26px;
  text-align: center;
  padding: 0 7px;
  background: var(--surface-2);
  border-radius: 10px;
  font-size: 12px;
  color: var(--text-2);
}
.admin-count-bad { background: var(--err-bg); color: var(--err-text); font-weight: bold; }

/* ---- Link health ---- */
.link-status {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: bold;
  color: #fff;
  white-space: nowrap;
}
.link-status.ls-ok          { background: var(--good); }
.link-status.ls-gone        { background: var(--bad); }
.link-status.ls-paywall     { background: var(--warn-2); }
.link-status.ls-blocked     { background: var(--neutral); }
.link-status.ls-unreachable { background: var(--neutral); }
.link-status.ls-muted       { background: var(--neutral); }

.lc-badge {
  display: inline-block;
  min-width: 22px;
  text-align: center;
  padding: 0 7px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: bold;
  color: #fff;
}
.lc-badge-bad  { background: var(--bad); }
.lc-badge-warn { background: var(--warn-2); }

.lc-runs .lc-breakdown { font-size: 12px; }

.lc-list { list-style: none; margin: 0; padding: 0; }
.lc-row {
  padding: 8px 0;
  border-top: 1px solid var(--border-soft);
}
.lc-row-main { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lc-row .lc-recipe { font-weight: bold; }
.lc-changed {
  font-size: 12px;
  color: var(--warn-2);
  background: var(--surface-2);
  border-radius: 8px;
  padding: 1px 7px;
}
.lc-row-url { font-size: 13px; margin: 2px 0 0; word-break: break-all; }
.lc-row-note { font-size: 12px; margin: 2px 0 0; }
.lc-row-actions { margin: 4px 0 0; }
.lc-group { margin: 6px 0; }
.lc-group summary { cursor: pointer; padding: 4px 0; }

/* ---- Home dashboard ---- */
.dash-head { margin-bottom: 16px; }
.dash-title { font-size: 24px; margin: 0 0 2px; }

.dash-stats { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 16px; }
.dash-stats li { margin: 0; padding: 9px 16px; border-radius: 6px; min-width: 88px; }
.dash-stats .num { font-size: 22px; }
.dash-stats .lbl { font-size: 12px; }
.dash-stats a { display: block; text-decoration: none; color: inherit; }
.dash-stats a:hover .lbl { color: var(--accent); }

.dash-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 20px; }
.dash-actions .button { margin: 0; padding: 5px 12px; font-size: 13px; }

.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  align-items: start;
}
.dash-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px 14px;
}
.dash-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid var(--border-soft);
  padding-bottom: 6px;
  margin-bottom: 8px;
}
.dash-card-head h2 { margin: 0; font-size: 16px; border: 0; padding: 0; }
.dash-more { font-size: 12px; white-space: nowrap; }
.dash-sub { font-size: 11px; color: var(--muted); white-space: nowrap; }

.dash-list { list-style: none; margin: 0; padding: 0; }
.dash-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 0;
}
.dash-list li + li { border-top: 1px solid var(--border-soft); }
.dash-when { color: var(--muted); font-size: 12px; white-space: nowrap; }

.dash-meals { list-style: none; margin: 0; padding: 0; }
.dash-meals li { padding: 4px 0; }
.dash-meal-type {
  display: inline-block;
  min-width: 74px;
  font-weight: bold;
  color: var(--heading);
  font-size: 13px;
}
.dash-meal-items { color: var(--text-2); }

.dash-big { font-size: 26px; font-weight: bold; color: var(--accent); margin: 2px 0 8px; }
.dash-big-lbl { font-size: 14px; font-weight: normal; color: var(--muted); }
.dash-stores { list-style: none; margin: 0 0 10px; padding: 0; }
.dash-stores li { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; font-size: 14px; }
.dash-count { background: var(--surface-2); border-radius: 9px; padding: 0 7px; font-size: 12px; color: var(--text-2); }

.dash-empty { font-size: 13px; padding: 6px 0; }

/* ---------- Tags ---------- */
.tag-chip {
  display: inline-block;
  background: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 1px 8px;
  margin: 1px 3px 1px 0;
  font-size: 12px;
  line-height: 1.5;
  white-space: nowrap;
  text-decoration: none;
}
a.tag-chip:hover { background: var(--surface-hover); color: var(--text); }
.recipe-tags { margin: 0 0 14px; }
.tile-tags { margin-top: 6px; }
.tags-cell { max-width: 180px; }

.tag-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
}
.tag-check {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 14px;
  white-space: nowrap;
}

/* ---------- Freezer inventory ---------- */
.freezer-add-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.freezer-add-fields input[type="text"],
.freezer-add-fields input[type="date"] {
  padding: 5px 7px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  font-size: 13px;
}
.freezer-add-fields .fi-name   { flex: 2 1 170px; }
.freezer-add-fields .fi-qty    { flex: 1 1 110px; }
.freezer-add-fields .fi-note   { flex: 2 1 150px; }
.freezer-add-fields .fi-loc,
.freezer-add-fields .fi-recipe {
  padding: 5px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  font-size: 13px;
}
.fi-inline-label { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; }

.freezer-locations {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-start;
}
.freezer-card {
  flex: 1 1 320px;
  max-width: 480px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px 4px;
}
.freezer-head {
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border-soft);
  padding-bottom: 4px;
  margin-bottom: 2px;
}
.freezer-head h2 { margin: 0; font-size: 15px; }
.freezer-count { color: var(--muted); font-size: 12px; }

.freezer-list { list-style: none; margin: 0; padding: 0; }
.freezer-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  border-top: 1px solid var(--border-soft);
}
.freezer-row:first-child { border-top: 0; }
.fi-text { flex: 1 1 auto; display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; }
.fi-item-name { font-size: 14px; color: var(--text); }
.fi-tag, .fi-note-tag, .fi-frozen {
  font-size: 12px;
  color: var(--text-2);
  background: var(--surface-2);
  border-radius: 9px;
  padding: 0 7px;
}
.fi-note-tag { color: var(--muted); background: transparent; font-style: italic; padding: 0; }
.fi-frozen { color: var(--muted); background: transparent; padding: 0; }
.fi-recipe-link { font-size: 12px; text-decoration: none; }
.fi-actions { flex: 0 0 auto; display: inline-flex; gap: 2px; }
.fi-icon {
  background: none;
  border: 0;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 2px 4px;
  text-decoration: none;
}
.fi-actions form { margin: 0; display: inline; }

/* ---------- Freezer-meal label ---------- */
.label-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 8px 0 16px;
}
.label-date-form { display: inline-flex; align-items: center; gap: 6px; margin: 0; }

.freezer-label {
  max-width: 460px;
  margin: 0 auto;
  padding: 18px 22px;
  background: #fff;
  color: #000;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
}
.fl-title {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: bold;
  text-decoration: underline;
  color: #000;
}
.fl-made { margin: 0 0 12px; font-size: 14px; color: #000; }
.fl-steps { margin: 0 0 14px; padding-left: 22px; }
.fl-steps li { margin: 4px 0; font-size: 14px; line-height: 1.35; color: #000; }
.fl-noinstructions { color: #444; margin: 0 0 14px; }
.fl-link {
  display: flex;
  align-items: center;
  gap: 12px;
  border-top: 1px solid #ccc;
  padding-top: 12px;
}
.fl-qr { flex: 0 0 auto; width: 120px; height: 120px; }
.fl-qr svg { width: 100%; height: 100%; display: block; }
.fl-url { font-size: 12px; word-break: break-all; color: #333; }

@media print {
  /* Print only the label card -- strip masthead, nav, flash and the on-screen
     controls. Body class is "<controller>-<action>" (see the layout). */
  body.recipes-freezer_label #masthead,
  body.recipes-freezer_label .toolbar,
  body.recipes-freezer_label .label-controls,
  body.recipes-freezer_label .flash,
  body.recipes-freezer_label .no-print { display: none !important; }
  body.recipes-freezer_label #content { margin: 0; padding: 0; }
  body.recipes-freezer_label .freezer-label {
    margin: 0;
    border: 1px solid #000;
    max-width: none;
    width: auto;
  }
}

/* ==========================================================================
   Opinion history (recipe show: how a child's opinion changed over time)
   ========================================================================== */
.opinion-history { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 12px; }
.opinion-history h3 { margin: 0 0 8px; font-size: 15px; }
.opinion-history-list { list-style: none; margin: 0; padding: 0; }
.opinion-history-list li {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 4px 0;
}
.opinion-history-child { min-width: 70px; font-weight: bold; color: var(--text-2); }
.opinion-trail { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.opinion-step { display: inline-flex; align-items: center; gap: 5px; }
.opinion-step-date { font-size: 12px; color: var(--muted); }
.opinion-arrow { color: var(--muted); }

/* ==========================================================================
   Freezer panel on the meal planner (read-only snapshot)
   ========================================================================== */
.freezer-panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.freezer-panel-head h2 { margin: 0; }
.freezer-panel-cols {
  display: flex; flex-wrap: wrap; gap: 18px; margin-top: 8px;
}
.freezer-panel-col { flex: 1 1 200px; min-width: 180px; }
.freezer-panel-col h3 { margin: 0 0 6px; font-size: 14px; color: var(--text-2); }
.freezer-panel-list { list-style: none; margin: 0; padding: 0; }
.freezer-panel-list li { padding: 3px 0; border-bottom: 1px solid var(--border-soft); }

/* ==========================================================================
   Kitchen insights
   ========================================================================== */
.insight-stats {
  display: flex; flex-wrap: wrap; gap: 12px; margin: 16px 0 24px;
}
.insight-tile {
  flex: 1 1 140px; text-align: center; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 8px; padding: 14px 10px;
  text-decoration: none; color: inherit; display: block;
}
a.insight-tile:hover { background: var(--surface-hover); }
.insight-num { display: block; font-size: 30px; font-weight: bold; color: var(--heading); line-height: 1.1; }
.insight-lbl { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; }

.insight-section { }
.insight-section h2 { font-size: 17px; }
.insight-two-col { display: flex; flex-wrap: wrap; gap: 20px; }
.insight-two-col > .insight-section { flex: 1 1 320px; min-width: 280px; }

/* Vertical monthly bars */
.insight-months {
  display: flex; align-items: flex-end; gap: 6px; height: 160px; padding-top: 6px;
}
.insight-month { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; height: 100%; }
.insight-month-bar-wrap { flex: 1 1 auto; width: 100%; display: flex; align-items: flex-end; }
.insight-month-bar {
  width: 70%; margin: 0 auto; background: var(--accent); border-radius: 3px 3px 0 0;
  min-height: 1px;
}
.insight-month-count { font-size: 11px; color: var(--text-2); height: 14px; }
.insight-month-label { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* Horizontal bar lists (most cooked, categories) */
.insight-barlist { list-style: none; margin: 0; padding: 0; }
.insight-barlist li {
  display: flex; align-items: center; gap: 10px; padding: 4px 0;
}
.insight-bar-label { flex: 0 0 40%; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.insight-bar-track { flex: 1 1 auto; background: var(--surface-2); border-radius: 4px; height: 14px; }
.insight-bar-fill { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.insight-bar-value { flex: 0 0 auto; font-variant-numeric: tabular-nums; color: var(--text-2); min-width: 24px; text-align: right; }

.insight-list { list-style: none; margin: 0; padding: 0; }
.insight-list li { padding: 4px 0; border-bottom: 1px solid var(--border-soft); }

/* Kids' taste profiles (stacked opinion bar) */
.taste-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 10px; font-size: 12px; color: var(--muted); }
.taste-key { display: inline-flex; align-items: center; gap: 5px; }
.taste-swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.taste-profiles { list-style: none; margin: 0; padding: 0; }
.taste-profiles li { margin-bottom: 12px; }
.taste-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.taste-name { font-weight: bold; }
.taste-bar { display: flex; height: 18px; border-radius: 4px; overflow: hidden; background: var(--surface-2); }
.taste-seg { display: block; height: 100%; }

.turnaround-child { font-weight: bold; }

@media (max-width: 560px) {
  .insight-bar-label { flex-basis: 50%; }
}
