:root {
  --bg: #17130f;
  --bg-2: #211a13;
  --surface: #2c2318;
  --surface-2: #382c1e;
  --line: #4a3a28;
  --gold: #e0a740;
  --gold-soft: #f0c780;
  --olive: #8fae5a;
  --tomato: #d8663f;
  --cream: #f4ecdf;
  --muted: #a8977f;
  --danger: #cf5a5a;
  --radius: 16px;
  --shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.7);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: 'Rubik', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--cream);
  min-height: 100vh;
  overflow-x: hidden;
}
.glow {
  position: fixed; top: -180px; left: 50%;
  transform: translateX(-50%);
  width: 620px; height: 620px;
  background: radial-gradient(circle, rgba(224, 167, 64, 0.2), transparent 62%);
  pointer-events: none; z-index: 0;
}

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 22px;
  background: linear-gradient(var(--bg), rgba(23, 19, 15, 0.4));
  backdrop-filter: blur(6px);
}
.brand {
  font-family: 'Secular One', sans-serif;
  font-size: 26px; color: var(--gold);
  text-shadow: 0 0 22px rgba(224, 167, 64, 0.3);
  cursor: pointer;
}
.topnav { display: flex; gap: 10px; }
.nav-link {
  border: 1px solid var(--line); background: var(--surface); color: var(--cream);
  padding: 8px 14px; border-radius: 999px; font: inherit; font-size: 14px; cursor: pointer;
  transition: border-color .15s, color .15s, transform .15s;
}
.nav-link:hover, .nav-link.active { border-color: var(--gold); color: var(--gold-soft); transform: translateY(-1px); }

main { position: relative; z-index: 1; max-width: 820px; margin: 0 auto; padding: 20px 22px 90px; }
.screen { animation: rise .35s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.eyebrow { text-transform: uppercase; letter-spacing: 3px; font-size: 12px; color: var(--gold); margin: 22px 0 6px; }
.gate-title, .screen-title {
  font-family: 'Secular One', sans-serif; font-weight: 400;
  font-size: clamp(28px, 6.5vw, 44px); margin: 0 0 6px; line-height: 1.1;
}
.gate-sub { color: var(--muted); margin: 0 0 22px; }
.lock-error { color: var(--danger); margin: 14px 2px 0; font-weight: 500; }
.shake { animation: shake .4s ease; }
@keyframes shake { 10%,90%{transform:translateX(-2px);} 20%,80%{transform:translateX(4px);} 30%,50%,70%{transform:translateX(-8px);} 40%,60%{transform:translateX(8px);} }
.empty { color: var(--muted); text-align: center; margin-top: 30px; }

/* Buttons / inputs */
.primary {
  background: var(--gold); color: #2a1c08; border: none;
  padding: 12px 20px; border-radius: 12px; font: inherit; font-weight: 700; cursor: pointer;
  transition: filter .15s, transform .12s;
}
.primary:hover { filter: brightness(1.08); transform: translateY(-1px); }
.primary:disabled { opacity: .6; cursor: default; transform: none; filter: none; }
.big-btn { width: 100%; padding: 16px; font-size: 17px; margin-top: 8px; }
.ghost {
  background: var(--surface-2); border: 1px solid var(--line); color: var(--cream);
  padding: 11px 16px; border-radius: 12px; font: inherit; cursor: pointer; transition: border-color .15s, color .15s;
}
.ghost:hover { border-color: var(--gold); color: var(--gold-soft); }
.ghost.danger:hover { border-color: var(--danger); color: var(--danger); }
.chef-btn {
  background: linear-gradient(135deg, var(--olive), #6f9142); color: #10240a; border: none;
  padding: 11px 16px; border-radius: 12px; font: inherit; font-weight: 700; cursor: pointer; transition: filter .15s, transform .12s;
}
.chef-btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.chef-btn:disabled { opacity: .6; }

input, textarea, select {
  background: var(--surface); border: 1px solid var(--line); color: var(--cream);
  padding: 12px 14px; border-radius: 12px; font: inherit; width: 100%;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
textarea { resize: vertical; }

.inline-add { display: flex; gap: 8px; margin-top: 20px; }
.inline-add.big { margin: 8px 0 26px; }
.inline-add input { flex: 1; }
.inline-add button { padding: 0 22px; }

.toolbar { display: flex; gap: 10px; margin: 8px 0 22px; }
.toolbar input { flex: 1; }
.toolbar .primary { flex: none; white-space: nowrap; }

/* Recipe groups */
.recipe-group { margin-bottom: 24px; }
.recipe-group h2 {
  font-family: 'Secular One', sans-serif; font-weight: 400; font-size: 20px;
  color: var(--gold-soft); margin: 0 0 12px; border-bottom: 1px dashed var(--line); padding-bottom: 6px;
}
.recipe-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 620px) { .recipe-grid { grid-template-columns: 1fr 1fr; } }
.recipe-card {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; cursor: pointer; transition: border-color .15s, transform .12s;
  border-inline-start: 3px solid var(--gold);
}
.recipe-card:hover { border-color: var(--gold); transform: translateY(-2px); }
.recipe-card .rc-icon { font-size: 24px; }
.recipe-card .rc-name { font-size: 17px; font-weight: 500; }
.recipe-card .rc-meta { color: var(--muted); font-size: 13px; margin-top: 2px; }

.cat-pill {
  display: inline-block; background: var(--surface-2); border: 1px solid var(--line);
  color: var(--gold-soft); font-size: 13px; padding: 3px 10px; border-radius: 999px;
}

/* Meal picker */
.meal-picker { display: grid; gap: 16px; margin-bottom: 20px; }
.meal-block {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.meal-block h3 {
  font-family: 'Secular One', sans-serif; font-weight: 400; font-size: 19px; margin: 0 0 12px;
  display: flex; align-items: center; gap: 8px;
}
.course-chips { display: flex; flex-wrap: wrap; gap: 9px; }
.course-chip {
  border: 1px solid var(--line); background: var(--surface-2); color: var(--cream);
  padding: 9px 15px; border-radius: 999px; font: inherit; cursor: pointer; user-select: none;
  transition: background .15s, border-color .15s, transform .12s; position: relative;
}
.course-chip:hover { transform: translateY(-2px); border-color: var(--gold); }
.course-chip.on { background: var(--gold); border-color: var(--gold); color: #2a1c08; font-weight: 600; }
.course-chip .star { font-size: 11px; margin-inline-start: 4px; opacity: .8; }

/* Menu result */
.menu-result { margin-top: 26px; }
.menu-meal { margin-bottom: 22px; }
.menu-meal h3 {
  font-family: 'Secular One', sans-serif; font-weight: 400; font-size: 20px; color: var(--gold-soft);
  margin: 0 0 12px; border-bottom: 1px dashed var(--line); padding-bottom: 6px;
}
.menu-line {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; margin-bottom: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; cursor: pointer;
  transition: border-color .15s;
}
.menu-line:hover { border-color: var(--gold); }
.menu-line .ml-course { color: var(--muted); font-size: 13px; min-width: 92px; }
.menu-line .ml-name { font-weight: 500; flex: 1; }
.menu-line.empty-slot { cursor: default; opacity: .7; }
.menu-line.empty-slot:hover { border-color: var(--line); }

/* Modals */
.picker-backdrop {
  position: fixed; inset: 0; background: rgba(8, 6, 4, 0.74);
  display: flex; align-items: flex-end; justify-content: center; z-index: 20; animation: fade .2s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.picker {
  background: var(--surface); border: 1px solid var(--line); border-radius: 20px 20px 0 0;
  padding: 22px; width: 100%; max-width: 820px; max-height: 88vh; overflow-y: auto;
  animation: sheet .28s ease both;
}
@keyframes sheet { from { transform: translateY(30px); opacity: .4; } to { transform: none; opacity: 1; } }
@media (min-width: 620px) { .picker { border-radius: 20px; margin-bottom: 4vh; } .picker-backdrop { align-items: center; } }
.picker h3 { font-family: 'Secular One', sans-serif; font-weight: 400; font-size: 22px; margin: 0 0 16px; }

.editor label { display: block; margin-bottom: 14px; font-size: 14px; color: var(--muted); }
.editor label input, .editor label textarea, .editor label select { margin-top: 6px; color: var(--cream); }
.editor-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-start; margin-top: 8px; }
.editor-actions .primary { margin-inline-start: auto; }

.viewer-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.viewer-head h3 { margin: 0; }
.viewer-body { display: grid; gap: 16px; margin-bottom: 18px; }
.v-section h4 { margin: 0 0 6px; color: var(--gold-soft); font-size: 15px; }
.v-section div { white-space: pre-wrap; line-height: 1.55; color: var(--cream); }

.improve-result { margin-top: 18px; border-top: 1px dashed var(--line); padding-top: 16px; }
.improve-result h4 { color: var(--olive); margin: 0 0 12px; }
.chef-link {
  display: block; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; margin-bottom: 10px; text-decoration: none; color: var(--cream);
  transition: border-color .15s, transform .12s;
}
.chef-link:hover { border-color: var(--olive); transform: translateY(-1px); }
.chef-link .cl-title { font-weight: 600; color: var(--gold-soft); }
.chef-link .cl-snippet { color: var(--muted); font-size: 13px; margin-top: 4px; }
.chef-link .cl-url { color: var(--olive); font-size: 12px; margin-top: 4px; direction: ltr; text-align: left; word-break: break-all; }
.loading { color: var(--muted); text-align: center; padding: 16px; }
