:root {
  /* Warm parchment palette */
  --bg: #f7f1e3;
  --bg-deep: #efe6cf;
  --card: #fffdf6;
  --ink: #1f1a14;
  --ink-soft: #6b6256;
  --rule: #e6dcc1;
  --rule-soft: #efe6cf;

  /* Accents */
  --gold: #b8932f;
  --gold-soft: #d4b558;
  --gold-deep: #8a6d20;

  /* Status colours — warm, not clinical */
  --y-bg: #f4d8cc;
  --y-text: #872f10;
  --y-dot: #b54820;

  --q-bg: #f7e6c5;
  --q-text: #8a5a05;
  --q-dot: #c47b1a;

  --n-bg: #e3ead7;
  --n-text: #3f5230;
  --n-dot: #6c8a52;

  /* Typography */
  --display: 'Playfair Display', 'Times New Roman', serif;
  --body: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;

  /* Layout */
  --max-w: 1180px;
  --gutter: 1.25rem;
  --radius: 14px;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  background-image:
    radial-gradient(circle at 12% 8%, rgba(184, 147, 47, 0.08), transparent 40%),
    radial-gradient(circle at 88% 92%, rgba(184, 147, 47, 0.06), transparent 50%);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== Header ===== */
.site-header {
  border-bottom: 1px solid var(--rule);
  padding: 3rem var(--gutter) 2.5rem;
  text-align: center;
  background: linear-gradient(180deg, transparent, rgba(255, 253, 246, 0.5));
}

.header-inner {
  max-width: 720px;
  margin: 0 auto;
}

.kicker {
  font-family: var(--body);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold-deep);
  margin: 0 0 1rem;
}

.display-title {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(2.4rem, 7vw, 3.8rem);
  line-height: 1.05;
  margin: 0 0 1rem;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.display-title em {
  font-style: italic;
  color: var(--gold-deep);
  font-weight: 400;
}

.lede {
  color: var(--ink-soft);
  font-size: 1.02rem;
  max-width: 52ch;
  margin: 0 auto;
}

/* ===== Container ===== */
.container {
  flex: 1;
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 2rem var(--gutter);
}

/* ===== Controls ===== */
.controls {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  position: sticky;
  top: 0;
  background: var(--bg);
  padding: 0.75rem 0;
  z-index: 10;
  margin: 0 calc(var(--gutter) * -1) 1rem;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}

.search-box {
  flex: 1;
  min-width: 200px;
  position: relative;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-soft);
  pointer-events: none;
}

#search {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.65rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--card);
  font-family: var(--body);
  font-size: 0.98rem;
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}

#search:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(184, 147, 47, 0.18);
}

#search::placeholder {
  color: var(--ink-soft);
}

.filter-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.15rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--card);
  font-family: var(--body);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.15s;
}

.filter-toggle:hover {
  border-color: var(--gold-soft);
  background: #fffaee;
}

.filter-toggle[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

.filter-toggle svg {
  transition: transform 0.2s;
}

.filter-count {
  background: var(--gold-deep);
  color: #fff;
  font-size: 0.75rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-weight: 600;
  min-width: 1.4em;
  text-align: center;
}

.filter-panel {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem 1.5rem;
  margin-bottom: 1.5rem;
  animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.filter-help {
  margin: 0 0 1rem;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.filter-help em {
  font-family: var(--display);
  font-style: italic;
  color: var(--ink);
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.5rem 1rem;
  margin-bottom: 1rem;
}

.filter-grid label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  user-select: none;
  font-size: 0.95rem;
  padding: 0.35rem 0;
}

.filter-grid input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--gold-deep);
  cursor: pointer;
}

.link-btn {
  background: none;
  border: none;
  color: var(--gold-deep);
  font-family: var(--body);
  font-size: 0.92rem;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 0;
}

.link-btn:hover { color: var(--ink); }

/* ===== Legend ===== */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  padding: 1rem 1.25rem;
  background: rgba(255, 253, 246, 0.6);
  border-radius: var(--radius);
  margin-bottom: 2rem;
  font-size: 0.9rem;
  color: var(--ink-soft);
  border: 1px dashed var(--rule);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-y { background: var(--y-dot); }
.dot-q { background: var(--q-dot); }
.dot-n { background: var(--n-dot); }

/* ===== Category sections ===== */
.category {
  margin-bottom: 3rem;
}

.category-header {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.category-title {
  font-family: var(--display);
  font-style: italic;
  font-weight: 400;
  font-size: 1.85rem;
  margin: 0;
  color: var(--ink);
}

.category-rule {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--gold-soft), transparent);
}

/* ===== Item cards ===== */
.items-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}

@media (min-width: 700px) {
  .items-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1024px) {
  .items-grid { grid-template-columns: repeat(3, 1fr); }
}

.item-card {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  position: relative;
}

.item-card:hover {
  transform: translateY(-2px);
  border-color: var(--gold-soft);
  box-shadow: 0 6px 24px -10px rgba(31, 26, 20, 0.18);
}

.item-name {
  font-family: var(--display);
  font-style: italic;
  font-weight: 600;
  font-size: 1.45rem;
  line-height: 1.15;
  margin: 0;
  color: var(--ink);
}

.item-desc {
  font-size: 0.93rem;
  color: var(--ink-soft);
  margin: 0;
  line-height: 1.55;
}

.item-divider {
  height: 1px;
  background: var(--rule);
  margin: 0;
  border: none;
}

.allergen-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.005em;
  white-space: nowrap;
}

.chip .dot {
  width: 7px;
  height: 7px;
}

.chip-y { background: var(--y-bg); color: var(--y-text); }
.chip-q { background: var(--q-bg); color: var(--q-text); }
.chip-n { background: transparent; color: var(--ink-soft); border: 1px solid var(--rule); }

.no-allergens {
  font-style: italic;
  color: var(--n-text);
  background: var(--n-bg);
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  font-size: 0.85rem;
  display: inline-block;
}

/* ===== Empty state ===== */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--ink-soft);
  font-style: italic;
  font-family: var(--display);
  font-size: 1.15rem;
}

/* ===== Footer ===== */
.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--rule);
  padding: 2rem var(--gutter);
  background: rgba(239, 230, 207, 0.5);
}

.footer-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  text-align: center;
  font-size: 0.88rem;
  color: var(--ink-soft);
}

.updated {
  margin: 0 0 0.85rem;
  font-weight: 500;
}

.disclaimer {
  margin: 0 auto 0.85rem;
  max-width: 60ch;
  font-size: 0.82rem;
  line-height: 1.6;
}

.brand-line {
  font-family: var(--display);
  font-style: italic;
  margin: 0;
  color: var(--ink);
}

.brand-line a {
  color: var(--gold-deep);
  text-decoration: none;
}

.brand-line a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ===== Loading ===== */
.loading {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--ink-soft);
  font-family: var(--display);
  font-style: italic;
  font-size: 1.1rem;
}

/* ===== Editor styles ===== */
.editor-body {
  padding: 0;
}

.editor-header {
  background: var(--ink);
  color: var(--card);
  padding: 1.25rem var(--gutter);
}

.editor-header-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.editor-header h1 {
  font-family: var(--display);
  font-style: italic;
  font-weight: 400;
  font-size: 1.35rem;
  margin: 0;
}

.editor-header h1 em {
  color: var(--gold-soft);
}

.editor-actions {
  display: flex;
  gap: 0.6rem;
  align-items: center;
}

.btn {
  font-family: var(--body);
  font-weight: 500;
  font-size: 0.9rem;
  padding: 0.55rem 1rem;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-primary {
  background: var(--gold);
  color: var(--ink);
  border-color: var(--gold);
}

.btn-primary:hover { background: var(--gold-soft); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: transparent;
  color: var(--card);
  border-color: rgba(255, 253, 246, 0.3);
}

.btn-secondary:hover { background: rgba(255, 253, 246, 0.08); }

.btn-danger {
  background: transparent;
  color: var(--y-text);
  border-color: var(--y-bg);
}

.btn-danger:hover { background: var(--y-bg); }

.editor-status {
  font-size: 0.85rem;
  color: var(--gold-soft);
  font-style: italic;
}

.editor-main {
  max-width: var(--max-w);
  margin: 1.5rem auto;
  padding: 0 var(--gutter);
}

.editor-toolbar {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.editor-toolbar input[type="text"] {
  padding: 0.55rem 0.85rem;
  border: 1px solid var(--rule);
  border-radius: 8px;
  font-family: var(--body);
  font-size: 0.92rem;
  background: var(--card);
  flex: 1;
  min-width: 180px;
}

.editor-table-wrap {
  overflow-x: auto;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  -webkit-overflow-scrolling: touch;
}

.editor-table {
  border-collapse: collapse;
  width: 100%;
  min-width: 1100px;
  font-size: 0.88rem;
}

.editor-table th,
.editor-table td {
  padding: 0;
  border-bottom: 1px solid var(--rule-soft);
  text-align: left;
  vertical-align: middle;
}

.editor-table thead th {
  background: var(--bg-deep);
  position: sticky;
  top: 0;
  font-weight: 500;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
  padding: 0.75rem 0.6rem;
  white-space: nowrap;
  z-index: 2;
}

.editor-table thead th.sticky-left {
  left: 0;
  z-index: 3;
  min-width: 240px;
}

.editor-table tbody td.sticky-left {
  position: sticky;
  left: 0;
  background: var(--card);
  border-right: 1px solid var(--rule);
  z-index: 1;
  padding: 0.65rem 0.75rem;
}

.editor-table tbody tr:hover td.sticky-left { background: #fffaee; }

.editor-table input.cell-name,
.editor-table input.cell-desc,
.editor-table input.cell-cat,
.editor-table input.cell-notes {
  width: 100%;
  border: none;
  background: transparent;
  font-family: var(--body);
  font-size: 0.9rem;
  padding: 0.4rem 0.5rem;
  border-radius: 4px;
  color: var(--ink);
}

.editor-table input.cell-name {
  font-family: var(--display);
  font-style: italic;
  font-size: 1rem;
  font-weight: 500;
}

.editor-table input.cell-name:focus,
.editor-table input.cell-desc:focus,
.editor-table input.cell-cat:focus,
.editor-table input.cell-notes:focus {
  outline: 2px solid var(--gold-soft);
  background: #fffaee;
}

.cell-cycle {
  width: 100%;
  height: 100%;
  min-height: 42px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: var(--body);
  font-weight: 600;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s;
}

.cell-cycle:hover { background: rgba(184, 147, 47, 0.08); }
.cell-cycle.is-y { background: var(--y-bg); color: var(--y-text); }
.cell-cycle.is-q { background: var(--q-bg); color: var(--q-text); }
.cell-cycle.is-n { background: transparent; color: var(--ink-soft); }
.cell-cycle.is-empty::after { content: "—"; color: var(--rule); }

.editor-table td.cell-status { padding: 0; text-align: center; min-width: 50px; }

.row-actions {
  padding: 0.5rem;
  text-align: center;
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--ink-soft);
  cursor: pointer;
  padding: 0.4rem;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover {
  color: var(--y-text);
  background: var(--y-bg);
}

.editor-table .desc-row td {
  padding: 0 0.75rem 0.75rem;
  background: var(--card);
}

.desc-row td.sticky-left {
  position: sticky;
  left: 0;
  z-index: 1;
}

.desc-input-wrap {
  display: grid;
  gap: 0.4rem;
  grid-template-columns: 1fr;
}

.desc-input-wrap input {
  font-size: 0.82rem !important;
  color: var(--ink-soft) !important;
  border: 1px solid var(--rule) !important;
  background: var(--card) !important;
}

.desc-input-wrap input::placeholder { font-style: italic; }

/* Login screen */
[hidden] { display: none !important; }

.login-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: var(--gutter);
}

.login-card {
  background: var(--card);
  padding: 2.5rem 2rem;
  border-radius: var(--radius);
  border: 1px solid var(--rule);
  max-width: 380px;
  width: 100%;
  text-align: center;
}

.login-card h2 {
  font-family: var(--display);
  font-style: italic;
  font-weight: 600;
  font-size: 1.7rem;
  margin: 0 0 0.5rem;
}

.login-card p {
  color: var(--ink-soft);
  margin: 0 0 1.5rem;
  font-size: 0.92rem;
}

.login-card input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--rule);
  border-radius: 8px;
  font-family: var(--body);
  font-size: 1rem;
  margin-bottom: 1rem;
}

.login-card input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(184, 147, 47, 0.18);
}

.login-error {
  color: var(--y-text);
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
  min-height: 1.2em;
}

.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: var(--card);
  padding: 0.85rem 1.5rem;
  border-radius: 999px;
  font-size: 0.92rem;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(31, 26, 20, 0.25);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.error { background: var(--y-text); }
.toast.success { background: #3f5230; }

/* Print */
@media print {
  .controls, .filter-panel, .filter-toggle, .editor-header, .editor-toolbar, .footer-inner .brand-line a { display: none; }
  body { background: white; }
  .item-card { bre