:root {
  --bg: #17120f;
  --bg2: #1f1813;
  --card: #241c16;
  --card2: #2e241c;
  --text: #f5ece0;
  --muted: #b7a793;
  --line: rgba(245, 236, 224, 0.12);
  --accent: #e07a5f;
  --accent2: #e0a13c;
  --danger: #dc6a5a;
  --sp: 16px;
  --radius: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: radial-gradient(125% 90% at 50% 0%, #302219 0%, #1c1510 58%, #120d0a 100%);
  background-attachment: fixed;
  color: var(--text);
  font-family: "Inter", system-ui, sans-serif;
  font-size: 16px;
}
h1, h2, h3, .serif { font-family: "Fraunces", Georgia, serif; }
a { color: inherit; }
button { font-family: inherit; cursor: pointer; }
.loading, .empty { color: var(--muted); text-align: center; padding: 48px 16px; font-style: italic; }

/* ---- buttons ---- */
.btn {
  border: 1px solid var(--line); background: var(--card2); color: var(--text);
  border-radius: 999px; padding: 9px 16px; font-size: 14px; font-weight: 500;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { border-color: var(--accent2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: #2a130c; border-color: transparent; font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: rgba(224,106,90,.4); background: transparent; }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.icon-btn { background: transparent; border: none; color: var(--muted); font-size: 20px; padding: 4px 8px; border-radius: 8px; }
.icon-btn:hover { color: var(--text); background: rgba(255,255,255,.06); }

/* ---- top bar ---- */
.topbar {
  position: sticky; top: 0; z-index: 20; backdrop-filter: blur(10px);
  background: rgba(23,18,15,.85); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px; padding: 12px 18px;
}
.topbar .brand { font-family: "Fraunces", serif; font-weight: 800; font-size: 20px; letter-spacing: .2px; }
.topbar .brand .mark { color: var(--accent); }
.topbar .spacer { flex: 1; }
.topbar .who { color: var(--muted); font-size: 14px; }
.topbar .who b { color: var(--text); font-weight: 600; }

.wrap { max-width: 1040px; margin: 0 auto; padding: 20px 18px 80px; }

/* ---- controls row ---- */
.controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 20px; }
.controls .search {
  flex: 1; min-width: 200px; background: var(--card); border: 1px solid var(--line);
  color: var(--text); border-radius: 999px; padding: 10px 16px; font-size: 15px;
}
.controls select {
  background: var(--card); border: 1px solid var(--line); color: var(--text);
  border-radius: 999px; padding: 10px 14px; font-size: 14px;
}
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.chip {
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  border-radius: 999px; padding: 6px 13px; font-size: 13px;
}
.chip.active { background: var(--accent2); color: #241a08; border-color: transparent; font-weight: 600; }

/* ---- recipe grid ---- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; }
.rcard {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; text-decoration: none; color: inherit; display: flex; flex-direction: column;
  transition: transform .12s, border-color .12s; position: relative;
}
.rcard:hover { transform: translateY(-2px); border-color: var(--accent2); }
.rcard .cover { aspect-ratio: 4/3; background: linear-gradient(135deg, #3a2c22, #241a14); object-fit: cover; width: 100%; display: block; }
.rcard .cover.placeholder { display: flex; align-items: center; justify-content: center; font-size: 40px; opacity: .5; }
.rcard .body { padding: 12px 14px 14px; }
.rcard .title { font-family: "Fraunces", serif; font-weight: 600; font-size: 18px; margin: 0 0 6px; }
.rcard .meta { color: var(--muted); font-size: 13px; }
.rcard .tags { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.rcard .tag { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; }
.rcard .fav { position: absolute; top: 8px; right: 8px; font-size: 18px; filter: drop-shadow(0 1px 2px rgba(0,0,0,.6)); }
.rcard .plan-check { position: absolute; top: 8px; left: 8px; width: 24px; height: 24px; border-radius: 50%; border: 2px solid #fff; background: rgba(0,0,0,.4); display: none; align-items: center; justify-content: center; color: #fff; }
body.planning .rcard .plan-check { display: flex; }
.rcard.planned .plan-check { background: var(--accent); color: #2a130c; border-color: var(--accent); }

/* ---- detail ---- */
.detail-hero { width: 100%; max-height: 360px; object-fit: cover; border-radius: var(--radius); background: var(--card); }
.detail h1 { font-size: clamp(26px, 5vw, 40px); margin: 18px 0 6px; }
.detail .sub { color: var(--muted); font-size: 14px; margin-bottom: 18px; }
.detail .cols { display: grid; grid-template-columns: 1fr 1.4fr; gap: 30px; }
@media (max-width: 720px) { .detail .cols { grid-template-columns: 1fr; } }
.detail h2 { font-size: 20px; border-bottom: 1px solid var(--line); padding-bottom: 8px; margin: 0 0 14px; }
.ingredients { list-style: none; padding: 0; margin: 0; }
.ingredients li { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); align-items: baseline; }
.ingredients li input { margin-top: 2px; }
.ingredients .amt { color: var(--accent); font-variant-numeric: tabular-nums; white-space: nowrap; }
.steps { list-style: none; counter-reset: step; padding: 0; margin: 0; }
.steps li { counter-increment: step; display: flex; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.steps li::before { content: counter(step); flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--accent2); color: #241a08; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.serving-ctl { display: inline-flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 4px 6px; }
.serving-ctl button { width: 28px; height: 28px; border-radius: 50%; border: none; background: var(--card2); color: var(--text); font-size: 18px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0; }
.notes-box { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-top: 20px; white-space: pre-wrap; color: var(--muted); }

/* ---- form ---- */
.form { max-width: 720px; margin: 0 auto; }
.form label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; }
.form input[type=text], .form input[type=number], .form textarea, .form input:not([type]) {
  width: 100%; background: var(--card); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 10px 12px; font-size: 15px; font-family: inherit;
}
.form textarea { min-height: 70px; resize: vertical; }
.row-line { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.row-line input.amt { width: 64px; flex: none; }
.row-line select.unit { width: 104px; flex: none; background: var(--card); border: 1px solid var(--line); color: var(--text); border-radius: 10px; padding: 10px 8px; font-family: inherit; font-size: 15px; }
.row-line input.item { flex: 1; }
.row-line .grip { color: var(--muted); cursor: grab; }
.row-line textarea { flex: 1; min-height: 44px; }
.import-box { display: flex; gap: 8px; margin-bottom: 8px; }
.import-box input { flex: 1; }

/* tag chip input (add tags one at a time, like trips) */
.tag-input { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.tag-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--accent2); color: #241a08; border-radius: 999px; padding: 4px 6px 4px 11px; font-size: 13px; font-weight: 600; }
.tag-chip button { border: none; background: transparent; color: inherit; cursor: pointer; font-size: 16px; line-height: 1; padding: 0 2px; }
.tag-input input { flex: 1; min-width: 130px; border: none !important; background: transparent !important; color: var(--text); font-size: 15px; padding: 6px !important; outline: none; }
.tag-field { position: relative; }
.tag-menu { position: absolute; left: 0; right: 0; top: 100%; margin-top: 4px; z-index: 60; background: var(--card2); border: 1px solid var(--line); border-radius: 10px; max-height: 260px; overflow: auto; box-shadow: 0 10px 30px rgba(0,0,0,.5); }
.tag-menu .opt { display: block; width: 100%; text-align: left; background: transparent; border: none; color: var(--text); padding: 10px 14px; font-size: 14px; cursor: pointer; }
.tag-menu .opt.hl, .tag-menu .opt:hover { background: rgba(255,255,255,.08); }
.tag-menu .opt.create { color: var(--accent); font-weight: 600; }

/* ---- shopping ---- */
.shop-list { list-style: none; padding: 0; margin: 0; }
.shop-list li { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--line); }
.shop-list li.checked { opacity: .45; text-decoration: line-through; }
.shop-list .amt { color: var(--accent); font-variant-numeric: tabular-nums; }

/* ---- cook mode ---- */
.cook { position: fixed; inset: 0; z-index: 200; background: var(--bg); display: flex; flex-direction: column; }
.cook-top { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.cook-body { flex: 1; overflow: auto; padding: 24px 20px; max-width: 760px; margin: 0 auto; width: 100%; }
.cook-step { font-size: clamp(20px, 4vw, 30px); line-height: 1.5; font-family: "Fraunces", serif; }
.cook-step .n { color: var(--accent); display: block; font-size: 16px; letter-spacing: 2px; text-transform: uppercase; margin-bottom: 12px; }
.cook-nav { display: flex; gap: 12px; padding: 16px 20px; border-top: 1px solid var(--line); }
.cook-nav .btn { flex: 1; justify-content: center; text-align: center; }
.timer-btn { display: inline-block; margin-top: 16px; }

/* ---- login / name picker ---- */
.center-screen { min-height: 90vh; display: grid; place-items: center; padding: 24px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 32px; max-width: 380px; width: 100%; text-align: center; }
.panel .mark { font-size: 40px; }
.panel h1 { font-size: 28px; margin: 12px 0 4px; }
.panel p { color: var(--muted); margin: 0 0 20px; }
.panel input { width: 100%; background: var(--bg2); border: 1px solid var(--line); color: var(--text); border-radius: 10px; padding: 12px 14px; font-size: 16px; text-align: center; margin-bottom: 12px; }
.name-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.name-grid .btn { padding: 16px; font-size: 16px; }

/* ---- modal ---- */
.backdrop { position: fixed; inset: 0; z-index: 300; background: rgba(0,0,0,.6); display: grid; place-items: center; padding: 20px; }
.modal { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 24px; max-width: 420px; width: 100%; }
.modal h3 { margin: 0 0 12px; }
.modal .modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ---- toast ---- */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #222; color: #fff; padding: 12px 20px; border-radius: 999px; z-index: 500; font-size: 14px; box-shadow: 0 6px 24px rgba(0,0,0,.4); }

/* ---- plan bar ---- */
.plan-bar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 100; background: rgba(23,18,15,.96); border-top: 1px solid var(--line); padding: 14px 18px; display: flex; gap: 12px; align-items: center; justify-content: center; }
.plan-bar .count { color: var(--muted); }

@media print {
  .topbar, .controls, .chip-row, .actions, .plan-bar, .icon-btn, .serving-ctl button { display: none !important; }
  body { background: #fff; color: #000; }
  .detail .cols { grid-template-columns: 1fr 1fr; }
  .detail-hero { max-height: 240px; }
  a { color: #000; }
}
