/* BetrCooking — a family cookbook, set like a reference work.
   Paper white, ink, herb-green links, butter note cards. */

:root {
  --paper: #FDFCF9;
  --paper-shade: #F6F4EB;
  --ink: #21201C;
  --ink-soft: #6B675C;
  --rule: #E4E1D5;
  --rule-strong: #C9C4B2;
  --green: #2D6A4F;
  --green-deep: #1B4332;
  --green-wash: #EDF3EE;
  --butter-bg: #FBF3D9;
  --butter-edge: #E8CE8C;
  --butter-ink: #6E5310;
  --tomato: #B3402A;
  --tomato-wash: #F9E9E4;
  --tomato-deep: #8F3221;   /* danger button hover */
  --tomato-ink: #7C2B1B;    /* text on tomato-wash */

  --card-bg: #fff;          /* menus, cards, form inputs */
  --on-accent: #fff;        /* text on solid green/tomato fills */
  --selection: #CDE3D2;
  --shadow: rgba(33, 32, 28, 0.12);

  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Source Serif 4', Georgia, serif;
  --font-ui: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', sans-serif;

  color-scheme: light;
}

/* Dark palette: warm near-black paper, off-white ink, lighter herb green.
   The site defaults to light; dark applies only via the header toggle. */

:root[data-theme="dark"] {
  --paper: #191813;
  --paper-shade: #211F18;
  --ink: #ECE8DB;
  --ink-soft: #A59E8C;
  --rule: #35322A;
  --rule-strong: #4C473A;
  --green: #8FBF9A;
  --green-deep: #B2D6BC;
  --green-wash: #22302A;
  --butter-bg: #2B2513;
  --butter-edge: #5D4F1F;
  --butter-ink: #E4C878;
  --tomato: #E07A5F;
  --tomato-wash: #38231D;
  --tomato-deep: #EC957D;
  --tomato-ink: #F0A78F;

  --card-bg: #201E17;
  --on-accent: #16211B;
  --selection: #33513F;
  --shadow: rgba(0, 0, 0, 0.5);

  color-scheme: dark;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

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

body {
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.65;
  color: var(--ink);
  background-color: var(--paper);
}

::selection { background: var(--selection); }

a { color: var(--green); text-decoration: none; }
a:hover { color: var(--green-deep); text-decoration: underline; text-underline-offset: 2px; }

:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ---------- Header ---------- */

header {
  border-bottom: 1px solid var(--rule-strong);
  background: var(--paper);
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.9rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
}

.logo { display: flex; align-items: center; gap: 0.7rem; text-decoration: none; flex-shrink: 0; }
.logo:hover { text-decoration: none; }

.logo-image { width: 46px; height: 46px; object-fit: contain; }

.logo-text { display: flex; flex-direction: column; }

.wordmark {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
  line-height: 1.1;
}

.wordmark em {
  font-style: italic;
  font-weight: 600;
  color: var(--green);
}

.logo-tagline {
  font-family: var(--font-ui);
  font-size: 0.68rem;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  margin-top: 0.15rem;
}

.header-search { flex: 1; max-width: 480px; }

.search-input {
  width: 100%;
  padding: 0.5rem 0.9rem;
  font-size: 0.95rem;
  font-family: var(--font-ui);
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
}

.search-input::placeholder { color: var(--ink-soft); }
.search-input:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 1px var(--green); }

.header-nav {
  display: flex;
  gap: 1.4rem;
  align-items: center;
  font-family: var(--font-ui);
  font-size: 0.9rem;
}

/* Account icon + dropdown */
.account { position: relative; display: flex; }

.account-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: var(--ink-soft);
  border: 1px solid var(--rule-strong);
  background: var(--paper);
  transition: color 120ms ease, border-color 120ms ease, background-color 120ms ease;
}

.account-btn:hover {
  color: var(--green-deep);
  border-color: var(--green);
  background: var(--green-wash);
  text-decoration: none;
}

.account-btn.signed-in {
  color: var(--on-accent);
  background: var(--green);
  border-color: var(--green);
}

.account-btn.signed-in:hover { background: var(--green-deep); }

/* Profile photo fills the account button when the user has one */
.account-btn .account-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

/* Theme toggle (injected by initTheme in app.js; reuses .account-btn look) */
button.theme-toggle {
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
}
button.theme-toggle:hover {
  color: var(--green-deep);
  border-color: var(--green);
  background: var(--green-wash);
}
.theme-toggle svg { display: block; width: 18px; height: 18px; }

.account-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.5rem);
  min-width: 210px;
  background: var(--card-bg);
  border: 1px solid var(--rule-strong);
  border-radius: 10px;
  box-shadow: 0 6px 20px var(--shadow);
  padding: 0.35rem;
  z-index: 50;
  font-family: var(--font-ui);
  font-size: 0.92rem;
}

.account-menu a {
  display: block;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  color: var(--ink);
}

.account-menu a:hover { background: var(--green-wash); color: var(--green-deep); text-decoration: none; }

.account-menu-user {
  padding: 0.5rem 0.75rem 0.6rem;
  font-size: 0.8rem;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--rule);
  margin-bottom: 0.3rem;
}

/* ---------- Layout ---------- */

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2.25rem 1.5rem 4rem;
  display: flex;
  gap: 3rem;
}

.sidebar {
  width: 215px;
  flex-shrink: 0;
  position: sticky;
  top: 1.25rem;
  align-self: flex-start;
  max-height: calc(100vh - 2.5rem);
  overflow-y: auto;
  /* Keep the inner scrollbar invisible until it's needed — a permanent
     second scrollbar next to the page's own looks broken. */
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
  padding-right: 0.6rem;
  font-family: var(--font-ui);
}

.sidebar:hover,
.sidebar:focus-within {
  scrollbar-color: var(--rule-strong) transparent;
}

.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: transparent; border-radius: 3px; }
.sidebar:hover::-webkit-scrollbar-thumb,
.sidebar:focus-within::-webkit-scrollbar-thumb { background: var(--rule-strong); }

.sidebar-section { margin-bottom: 1.75rem; }

.sidebar-title {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--rule-strong);
  margin-bottom: 0.5rem;
}

.sidebar-list { list-style: none; }
.sidebar-list li { padding: 0.22rem 0; font-size: 0.92rem; }
.sidebar-list .count { color: var(--ink-soft); font-size: 0.8rem; margin-left: 0.3rem; }

.main-content { flex: 1; min-width: 0; max-width: 760px; }

/* ---------- Article typography ---------- */

h1 {
  font-family: var(--font-display);
  font-size: 2.35rem;
  font-weight: 500;
  letter-spacing: -0.015em;
  line-height: 1.15;
  margin-bottom: 0.75rem;
}

/* Star ratings */
.rating-row {
  display: flex;
  align-items: center;
  gap: 0.05rem;
  margin-bottom: 0.6rem;
  font-family: var(--font-ui);
}

.star-btn {
  background: none;
  border: none;
  padding: 0 0.08rem;
  font-size: 1.45rem;
  line-height: 1;
  color: var(--rule-strong);
  cursor: pointer;
  transition: color 100ms ease, transform 100ms ease;
}

.star-btn:hover { background: none; }
.star-btn.filled, .star-btn.hover { color: #DD9A00; }
.star-btn.hover { transform: scale(1.12); }
.star-btn:disabled { cursor: default; }

.rating-text { font-size: 0.85rem; color: var(--ink-soft); margin-left: 0.5rem; }

/* Cookbook chapter rule: thin over thick */
.title-rule {
  border: none;
  border-top: 1px solid var(--rule-strong);
  margin: 0 0 1.5rem;
  position: relative;
}
.title-rule::after {
  content: '';
  display: block;
  border-top: 3px solid var(--ink);
  width: 64px;
  margin-top: -2px;
}

h2 {
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 550;
  margin: 2.25rem 0 0.9rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--rule);
}

h3 { font-family: var(--font-ui); font-size: 1.05rem; font-weight: 600; margin: 1.5rem 0 0.75rem; }

.lede { color: var(--ink-soft); font-size: 1.05rem; margin-bottom: 1rem; }

.eyebrow {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--green);
}

/* ---------- Recipe index (homepage) ---------- */

.recipe-count {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin-bottom: 0.75rem;
}

.recipe-list { list-style: none; }

.recipe-item { border-bottom: 1px solid var(--rule); }
.recipe-item:last-child { border-bottom: none; }

.recipe-item a {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.8rem 0.4rem;
  color: inherit;
  text-decoration: none;
  transition: background-color 120ms ease;
}

.recipe-item a:hover { background: var(--green-wash); text-decoration: none; }

.recipe-thumb {
  width: 56px;
  height: 56px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--paper-shade);
  border: 1px solid var(--rule);
}

.recipe-thumb.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-style: italic;
  color: var(--rule-strong);
  font-size: 1.4rem;
}

.recipe-item .recipe-title {
  font-family: var(--font-body);
  font-size: 1.08rem;
  font-weight: 600;
  color: var(--ink);
}

.recipe-item a:hover .recipe-title { color: var(--green-deep); }

.recipe-item .recipe-meta {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  color: var(--ink-soft);
  margin-top: 0.1rem;
}

.category-heading {
  margin-top: 2.5rem;
}
.category-heading:first-of-type { margin-top: 1.5rem; }

/* Recipe of the day */
.rotd {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 1rem;
  margin-bottom: 1.75rem;
  background: var(--paper-shade);
  border: 1px solid var(--rule-strong);
  border-radius: 10px;
  color: inherit;
  text-decoration: none;
  transition: border-color 120ms ease;
}

.rotd:hover { text-decoration: none; border-color: var(--green); }

.rotd-image {
  width: 108px;
  height: 108px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--rule);
  background: var(--paper);
}

.rotd-image.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-style: italic;
  color: var(--rule-strong);
  font-size: 2.5rem;
}

.rotd-body { display: flex; flex-direction: column; gap: 0.2rem; min-width: 0; }

.rotd-title {
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 550;
  line-height: 1.2;
  color: var(--ink);
}

.rotd:hover .rotd-title { color: var(--green-deep); }

/* ---------- Recipe page ---------- */

.recipe-card {
  float: right;
  width: 300px;
  margin: 0.4rem 0 1.25rem 2rem;
  background: var(--paper-shade);
  border: 1px solid var(--rule-strong);
  border-radius: 8px;
  overflow: hidden;
  font-family: var(--font-ui);
  font-size: 0.88rem;
}

.recipe-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
  border-bottom: 1px solid var(--rule-strong);
}

.recipe-card-facts { padding: 0.85rem 1rem; display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem 1rem; }

.fact-label {
  display: block;
  font-size: 0.66rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-soft);
}

.fact-value { color: var(--ink); }

.recipe-section { margin: 1.75rem 0; scroll-margin-top: 1.5rem; }

/* Signature: tap-to-strike ingredient checklist */
.ingredients-list { list-style: none; }

.ingredients-list li { border-bottom: 1px solid var(--rule); }
.ingredients-list li:last-child { border-bottom: none; }

.ingredients-list label {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  padding: 0.5rem 0.2rem;
  cursor: pointer;
}

.ingredients-list input[type="checkbox"] {
  appearance: none;
  width: 17px;
  height: 17px;
  border: 1.5px solid var(--rule-strong);
  border-radius: 4px;
  flex-shrink: 0;
  position: relative;
  top: 2px;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease;
}

.ingredients-list input[type="checkbox"]:checked {
  background: var(--green);
  border-color: var(--green);
}

.ingredients-list input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 4.5px; top: 1px;
  width: 4px; height: 8px;
  border: solid var(--on-accent);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.ingredients-list input[type="checkbox"]:checked + span {
  color: var(--ink-soft);
  text-decoration: line-through;
  text-decoration-color: var(--rule-strong);
}

.checklist-hint {
  font-family: var(--font-ui);
  font-size: 0.78rem;
  color: var(--ink-soft);
  margin-bottom: 0.4rem;
}

/* Numbered steps with green numerals */
.instructions-list {
  list-style: none;
  counter-reset: step;
}

.instructions-list li {
  counter-increment: step;
  position: relative;
  padding: 0.55rem 0 0.55rem 3rem;
}

.instructions-list li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0.55rem;
  width: 2rem;
  text-align: right;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.15rem;
  color: var(--green);
}

/* Section separators inside ingredients / instructions */
.recipe-subhead {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.1rem;
  font-weight: 550;
  color: var(--green-deep);
  margin: 1.4rem 0 0.4rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px dashed var(--rule-strong);
}

.recipe-subhead:first-child { margin-top: 0.25rem; }

.notes-box {
  background: var(--butter-bg);
  border: 1px solid var(--butter-edge);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
}

.notes-box strong {
  display: block;
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--butter-ink);
  margin-bottom: 0.4rem;
}

.notes-box p { margin: 0.3rem 0; }

.source-line { font-family: var(--font-ui); font-size: 0.85rem; color: var(--ink-soft); }
.source-line a { word-break: break-all; }

/* ---------- Forms ---------- */

.form-container {
  max-width: 820px;
  margin: 0 auto;
  padding: 2.25rem 1.5rem 4rem;
}

.form-group { margin-bottom: 1.4rem; }

label {
  display: block;
  font-family: var(--font-ui);
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.field-hint {
  display: block;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  color: var(--ink-soft);
  margin-top: 0.3rem;
}

input[type="text"],
input[type="url"],
input[type="password"],
textarea,
select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  font-size: 1rem;
  font-family: var(--font-ui);
  color: var(--ink);
  background: var(--card-bg);
  border: 1px solid var(--rule-strong);
  border-radius: 6px;
}

textarea { min-height: 110px; resize: vertical; line-height: 1.5; }

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 1px var(--green);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

button, .button {
  font-family: var(--font-ui);
  background: var(--green);
  color: var(--on-accent);
  padding: 0.65rem 1.6rem;
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 120ms ease;
}

button:hover { background: var(--green-deep); }
button:disabled { background: var(--rule-strong); cursor: default; }

button.secondary {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--rule-strong);
}
button.secondary:hover { background: var(--paper-shade); }

button.danger { background: var(--tomato); }
button.danger:hover { background: var(--tomato-deep); }

button.small { padding: 0.35rem 0.9rem; font-size: 0.85rem; }

button.ghost {
  background: transparent;
  color: var(--green);
  border: none;
  padding: 0.35rem 0.5rem;
  font-weight: 600;
}
button.ghost:hover { background: var(--green-wash); }

/* ---------- Structured recipe editor ---------- */

.import-panel {
  background: var(--green-wash);
  border: 1px solid var(--green);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 2rem;
}

.import-panel .import-row { display: flex; gap: 0.6rem; }
.import-panel input { flex: 1; }

.editor-rows { display: flex; flex-direction: column; gap: 0.4rem; }

.editor-row { display: flex; gap: 0.4rem; align-items: flex-start; }

.editor-row .row-handle {
  font-family: var(--font-display);
  font-style: italic;
  color: var(--green);
  width: 1.6rem;
  text-align: right;
  padding-top: 0.55rem;
  font-size: 0.95rem;
  flex-shrink: 0;
  cursor: grab;
  user-select: none;
  border-radius: 4px;
}

.editor-row .row-handle:hover { background: var(--green-wash); }
.editor-row .row-handle:active { cursor: grabbing; }

.editor-row .row-handle svg {
  display: inline-block;
  vertical-align: middle;
  color: var(--rule-strong);
}
.editor-row .row-handle:hover svg { color: var(--green); }

.editor-row.dragging { opacity: 0.45; }
.editor-row.dragging input, .editor-row.dragging textarea { border-style: dashed; }

.editor-row input, .editor-row textarea { flex: 1; }
.editor-row textarea { min-height: 2.6rem; }

.row-buttons { display: flex; gap: 0.15rem; flex-shrink: 0; padding-top: 0.2rem; }

.row-buttons button {
  background: transparent;
  color: var(--ink-soft);
  border: none;
  padding: 0.3rem 0.4rem;
  font-size: 0.9rem;
  border-radius: 4px;
  line-height: 1;
}
.row-buttons button:hover { background: var(--paper-shade); color: var(--ink); }
.row-buttons button.remove:hover { color: var(--tomato); background: var(--tomato-wash); }

.add-row-btn { align-self: flex-start; margin-top: 0.5rem; }

/* Section rows in the editor */
.editor-row.section { margin-top: 0.6rem; }

.editor-row.section .row-handle { color: var(--green-deep); font-weight: 600; }

.editor-row.section input {
  background: var(--green-wash);
  border-color: var(--green);
  font-weight: 600;
  font-style: italic;
}

/* Import image picker */
.image-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 0.6rem;
  margin-top: 0.5rem;
  margin-bottom: 0.75rem;
}

.image-picker-cell {
  padding: 0;
  background: none;
  border: 2px solid var(--rule);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  aspect-ratio: 1;
}

.image-picker-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }

.image-picker-cell:hover { border-color: var(--green); background: none; }

.image-picker-cell.selected { border-color: var(--green); box-shadow: 0 0 0 2px var(--green-wash); }

.fraction-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 0.25rem; margin-bottom: 0.5rem; }

.fraction-btn {
  background: var(--paper-shade);
  border: 1px solid var(--rule-strong);
  color: var(--ink);
  padding: 0.15rem 0.6rem;
  font-size: 1rem;
  border-radius: 4px;
}
.fraction-btn:hover { background: var(--green); border-color: var(--green); color: var(--on-accent); }

/* Image drop zone */
.drop-zone {
  border: 1.5px dashed var(--rule-strong);
  border-radius: 8px;
  padding: 1.5rem;
  text-align: center;
  font-family: var(--font-ui);
  font-size: 0.9rem;
  color: var(--ink-soft);
  cursor: pointer;
  transition: border-color 120ms ease, background-color 120ms ease;
}

.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--green);
  background: var(--green-wash);
  color: var(--green-deep);
}

.image-preview { margin-top: 0.75rem; max-width: 280px; position: relative; }
.image-preview img { width: 100%; border-radius: 8px; border: 1px solid var(--rule-strong); display: block; }
.image-preview .image-note { font-family: var(--font-ui); font-size: 0.78rem; color: var(--ink-soft); margin-top: 0.3rem; }

/* Live preview panel */
.preview-panel {
  border-top: 1px solid var(--rule-strong);
  margin-top: 2.5rem;
  padding-top: 1.5rem;
}

/* ---------- Admin ---------- */

.submission-card {
  border: 1px solid var(--rule-strong);
  background: var(--card-bg);
  border-radius: 8px;
  padding: 1.4rem;
  margin-bottom: 1.5rem;
}

.submission-title { font-family: var(--font-display); font-size: 1.3rem; font-weight: 550; }

.submission-meta { font-family: var(--font-ui); font-size: 0.82rem; color: var(--ink-soft); margin-top: 0.2rem; }

.submission-body { margin: 1rem 0; border-top: 1px solid var(--rule); padding-top: 1rem; }

.submission-section { margin: 0.75rem 0; }

.submission-section strong {
  display: block;
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-soft);
  margin-bottom: 0.3rem;
}

.submission-image { max-width: 260px; border-radius: 8px; border: 1px solid var(--rule-strong); }

.submission-actions {
  display: flex;
  gap: 0.75rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
}

.admin-bar {
  font-family: var(--font-ui);
  margin-top: 3rem;
  padding: 1rem 1.25rem;
  background: var(--paper-shade);
  border: 1px solid var(--rule);
  border-radius: 8px;
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.admin-bar .eyebrow { color: var(--ink-soft); margin-right: auto; }

/* Users table */
.users-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-ui);
  font-size: 0.92rem;
  margin: 0.5rem 0 2rem;
}

.users-table th {
  text-align: left;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-soft);
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--rule-strong);
}

.users-table td {
  padding: 0.55rem 0.6rem;
  border-bottom: 1px solid var(--rule);
}

.users-actions { text-align: right; white-space: nowrap; }

.you-tag {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--green-deep);
  background: var(--green-wash);
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
  margin-left: 0.3rem;
}

button.danger-ghost { color: var(--tomato); }
button.danger-ghost:hover { background: var(--tomato-wash); color: var(--tomato-ink); }

.checkbox-label { display: flex; align-items: center; gap: 0.5rem; font-weight: 500; }
.checkbox-label input { width: auto; }

/* Recipe scale bar */
.scale-bar {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0.25rem 0 0.6rem;
  font-family: var(--font-ui);
}

.scale-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-soft);
  margin-right: 0.3rem;
}

.scale-bar button {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  padding: 0.25rem 0.85rem;
  font-size: 0.88rem;
  font-weight: 600;
}

.scale-bar button:hover { border-color: var(--green); color: var(--green-deep); background: transparent; }

.scale-bar button.active {
  background: var(--green);
  border-color: var(--green);
  color: var(--on-accent);
}

/* ---------- Alerts ---------- */

.alert {
  font-family: var(--font-ui);
  font-size: 0.92rem;
  padding: 0.85rem 1.1rem;
  margin-bottom: 1.5rem;
  border-radius: 8px;
  border: 1px solid;
}

.alert-success { background: var(--green-wash); border-color: var(--green); color: var(--green-deep); }
.alert-info { background: var(--paper-shade); border-color: var(--rule-strong); color: var(--ink-soft); }
.alert-danger { background: var(--tomato-wash); border-color: var(--tomato); color: var(--tomato-ink); }

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .container { flex-direction: column; gap: 1.5rem; }
  .sidebar { position: static; width: 100%; max-height: none; overflow: visible; padding-right: 0; order: 2; }
  .main-content { order: 1; max-width: 100%; }
  .recipe-card { float: none; width: 100%; margin: 0 0 1.5rem; }
  .header-content { flex-wrap: wrap; row-gap: 0.6rem; }
  .header-search { order: 3; max-width: 100%; flex-basis: 100%; }
}

@media (max-width: 600px) {
  body { font-size: 16px; }
  h1 { font-size: 1.85rem; }
  .form-row { grid-template-columns: 1fr; }

  /* Compact top bar: no tagline, smaller mark, tighter spacing */
  .header-content { padding: 0.6rem 1rem; gap: 0.75rem; row-gap: 0.5rem; }
  .logo { gap: 0.5rem; }
  .logo-image { width: 34px; height: 34px; }
  .wordmark { font-size: 1.3rem; }
  .logo-tagline { display: none; }
  .header-nav { gap: 0.75rem; font-size: 0.85rem; }
  .account-btn { width: 34px; height: 34px; }
  /* 16px stops iOS Safari from zooming the page when the field is focused */
  .search-input { font-size: 16px; padding: 0.42rem 0.85rem; }
  .container { padding: 1.5rem 1rem 3rem; }
}

/* ---------- Print: a clean recipe card ---------- */

@media print {
  header, .sidebar, .header-nav, .header-search, .admin-bar, .checklist-hint { display: none !important; }
  .container, .main-content { max-width: 100%; padding: 0; }
  body { font-size: 12pt; background: #fff; }
  .recipe-card { float: none; width: 100%; border: 1px solid #000; border-radius: 0; }
  a { color: inherit; text-decoration: none; }
  .ingredients-list input[type="checkbox"] { border-color: #000; }
}

/* ---------- Search typeahead ---------- */
/* Dropdown of live results under the header search input (non-homepage pages).
   Injected by initSearchTypeahead() in app.js. Uses only CSS variables so it
   follows light/dark themes automatically. */

.header-search.has-typeahead { position: relative; }

.search-typeahead {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 60;
  background: var(--card-bg);
  border: 1px solid var(--rule-strong);
  border-radius: 12px;
  box-shadow: 0 6px 20px var(--shadow);
  overflow: hidden;
  overflow-y: auto;
  max-height: 320px;
}

.search-typeahead-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem 0.75rem;
  text-decoration: none;
  color: var(--ink);
}

.search-typeahead-item + .search-typeahead-item { border-top: 1px solid var(--rule); }

.search-typeahead-item.active,
.search-typeahead-item:hover { background: var(--green-wash); }

.search-typeahead-thumb {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--rule);
}

.search-typeahead-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--green-wash);
  color: var(--green-deep);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
}

.search-typeahead-text { min-width: 0; }

.search-typeahead-title {
  font-family: var(--font-ui);
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-typeahead-meta {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.search-typeahead-empty {
  padding: 0.6rem 0.75rem;
  font-family: var(--font-ui);
  font-size: 0.9rem;
  color: var(--ink-soft);
}
