:root {
  --bg: #fbf7f2;
  --surface: #ffffff;
  --surface-2: #f3ece3;
  --text: #2a1f17;
  --muted: #7a6a5c;
  --line: #e8ddd0;
  --accent: #c2410c;
  --accent-soft: #fde7d9;
  --good: #3f7d3a;
  --radius: 16px;
  --tabbar-h: 64px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17120e;
    --surface: #221b16;
    --surface-2: #2c241e;
    --text: #f3eae1;
    --muted: #b3a393;
    --line: #3a3029;
    --accent: #f97316;
    --accent-soft: #3d2416;
    --good: #7cc274;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  min-height: 100dvh;
  padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom));
  overscroll-behavior-y: contain;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Üst bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 8px;
  padding: calc(10px + var(--safe-top)) 12px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  min-height: 56px;
}
.topbar h1 { flex: 1; margin: 0 4px; font-size: 20px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  background: transparent; border: 0;
}
.icon-btn:active { background: var(--surface-2); }
#favBtn.on svg { fill: var(--accent); stroke: var(--accent); }

main { padding: 12px 16px 24px; max-width: 640px; margin: 0 auto; }

/* Arama ve kategoriler */
.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: 0 14px; height: 46px;
}
.search svg { color: var(--muted); width: 20px; height: 20px; flex: none; }
.search input { flex: 1; border: 0; background: transparent; outline: none; font-size: 16px; min-width: 0; }
.chips {
  display: flex; gap: 8px; overflow-x: auto; padding: 12px 0 4px;
  margin: 0 -16px; padding-left: 16px; padding-right: 16px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 8px 14px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line);
  font-size: 14px; font-weight: 500;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Tarif kartları */
.grid { display: grid; gap: 12px; margin-top: 12px; }
.card {
  display: flex; gap: 14px; align-items: center;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px;
  text-align: left; width: 100%;
}
.card:active { transform: scale(.99); }
.thumb {
  flex: none; width: 64px; height: 64px; border-radius: 14px;
  display: grid; place-items: center; font-size: 34px;
  background: var(--accent-soft);
}
.card-body { min-width: 0; flex: 1; }
.card h3 { margin: 0 0 4px; font-size: 17px; }
.meta { display: flex; gap: 12px; color: var(--muted); font-size: 13px; flex-wrap: wrap; }
.heart { color: var(--accent); font-size: 18px; }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; }
.empty .big { font-size: 48px; display: block; margin-bottom: 8px; }

/* Detay */
.hero {
  text-align: center; padding: 20px 12px 16px;
  background: var(--accent-soft); border-radius: var(--radius);
}
.hero .emoji { font-size: 64px; line-height: 1; }
.hero h2 { margin: 10px 0 6px; font-size: 24px; }
.hero .meta { justify-content: center; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 24px 0 10px; }
.section-title h3 { margin: 0; font-size: 18px; }
.stepper { display: flex; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.stepper button { width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--surface-2); font-size: 18px; font-weight: 700; }
.stepper span { min-width: 64px; text-align: center; font-size: 14px; font-weight: 600; }

.ingredients { list-style: none; padding: 0; margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.ingredients li { border-bottom: 1px solid var(--line); }
.ingredients li:last-child { border-bottom: 0; }
.ingredients label { display: flex; gap: 12px; align-items: center; padding: 12px 14px; }
.ingredients input { width: 22px; height: 22px; accent-color: var(--good); flex: none; }
.ingredients input:checked + span { text-decoration: line-through; color: var(--muted); }
.ingredients b { font-weight: 700; }

.steps { list-style: none; padding: 0; margin: 0; counter-reset: s; display: grid; gap: 10px; }
.steps li {
  counter-increment: s; position: relative;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 14px 14px 52px;
}
.steps li::before {
  content: counter(s); position: absolute; left: 12px; top: 12px;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 14px;
  display: grid; place-items: center;
}
.steps li.done { opacity: .5; }
.steps li.done::before { content: "✓"; background: var(--good); }
.timer-btn {
  margin-top: 10px; display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--accent); color: var(--accent); background: transparent;
  border-radius: 999px; padding: 6px 12px; font-size: 14px; font-weight: 600;
}
.timer-btn svg { width: 16px; height: 16px; }
.timer-btn.running { background: var(--accent); color: #fff; }

.row-actions { display: flex; gap: 10px; margin-top: 24px; flex-wrap: wrap; }
.btn {
  flex: 1; min-height: 48px; border-radius: 14px; border: 0;
  background: var(--accent); color: #fff; font-weight: 700; padding: 0 16px;
}
.btn.secondary { background: var(--surface); color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: transparent; color: #dc2626; border: 1px solid currentColor; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.switch input { width: 22px; height: 22px; accent-color: var(--accent); }

/* Form */
.form { display: grid; gap: 14px; }
.field label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.field small { color: var(--muted); font-weight: 400; }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--line); background: var(--surface);
  border-radius: 12px; padding: 12px; font-size: 16px; outline: none;
}
.field textarea { min-height: 120px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.emoji-pick { display: flex; gap: 6px; flex-wrap: wrap; }
.emoji-pick button { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-size: 22px; }
.emoji-pick button.active { border-color: var(--accent); background: var(--accent-soft); }

/* Alt menü */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--surface); border-top: 1px solid var(--line);
}
.tabbar button {
  flex: 1; border: 0; background: transparent; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 12px; font-weight: 600;
}
.tabbar button.active { color: var(--accent); }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 16px);
  transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px;
  font-size: 14px; font-weight: 600; transition: .25s; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Dünya mutfağı, dolap, besin değerleri ---------- */
.thumb.photo { overflow: hidden; background: var(--surface-2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tabbar button span { white-space: nowrap; }
@media (max-width: 360px) { .tabbar button { font-size: 11px; } }

.hero.has-img { padding: 0 0 16px; overflow: hidden; }
.hero-img { display: block; width: 100%; aspect-ratio: 4 / 3; max-height: 320px; object-fit: cover; margin-bottom: 4px; background: var(--surface-2); }
.hero.has-img h2 { padding: 0 12px; }

.note {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 12px; padding: 10px 14px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line); color: var(--muted); font-size: 14px;
}
.note button { margin-left: auto; border: 0; background: transparent; color: var(--accent); font-weight: 700; padding: 4px 0; }
.note.warn { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }

.nutri {
  display: grid; grid-template-columns: 1.3fr 1fr 1fr 1fr; gap: 8px; margin-top: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px;
}
.nutri > div { display: flex; flex-direction: column; justify-content: center; text-align: center; padding: 6px 2px; border-radius: 10px; background: var(--surface-2); }
.nutri .kcal { background: var(--accent-soft); }
.nutri b { font-size: 18px; font-variant-numeric: tabular-nums; }
.nutri .kcal b { font-size: 22px; color: var(--accent); }
.nutri span { font-size: 11px; color: var(--muted); }
.nutri p { grid-column: 1 / -1; margin: 2px 0 0; font-size: 12px; color: var(--muted); text-align: center; }
@media (max-width: 380px) { .nutri { grid-template-columns: 1fr 1fr 1fr; } .nutri .kcal { grid-column: 1 / -1; } }

.links { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.links .btn { display: flex; align-items: center; justify-content: center; text-decoration: none; }

.dice {
  display: flex; align-items: center; gap: 14px; width: 100%; margin-top: 12px; text-align: left;
  padding: 12px 14px; border-radius: var(--radius); border: 0;
  background: var(--accent); color: #fff;
}
.dice b { display: block; font-size: 17px; }
.dice small { display: block; opacity: .85; font-size: 13px; }
.dice-face { font-size: 30px; line-height: 1; display: inline-block; }
.dice.rolling .dice-face { animation: zar .5s linear infinite; }
.dice:disabled { opacity: .8; }
@keyframes zar { to { transform: rotate(360deg); } }

.label { margin: 16px 0 0; font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.label + .chips { padding-top: 8px; }
.chips.wrap { flex-wrap: wrap; overflow: visible; margin: 0; padding: 10px 0 0; }
.chip span { opacity: .8; margin-left: 2px; }
.result-head { margin: 22px 0 0; font-size: 17px; font-weight: 700; }
.lead { margin: 4px 0 14px; color: var(--muted); }
.hint { color: var(--muted); font-size: 14px; }
.add-row { display: flex; gap: 8px; }
.add-row input {
  flex: 1; min-width: 0; height: 48px; border: 1px solid var(--line); background: var(--surface);
  border-radius: 14px; padding: 0 14px; font-size: 16px; outline: none;
}
.add-row input:focus { border-color: var(--accent); }
.add-row .btn { flex: none; }
.btn.find { width: 100%; margin-top: 16px; }
.btn:disabled { opacity: .5; }
.match { display: inline-block; margin-top: 6px; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.match.full { background: color-mix(in srgb, var(--good) 18%, transparent); color: var(--good); }
.retry { margin-top: 14px; flex: none; }

.spinner {
  display: block; width: 32px; height: 32px; margin: 0 auto 12px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--accent); animation: zar .8s linear infinite;
}
.spinner.small { display: inline-block; width: 16px; height: 16px; margin: 0; border-width: 2px; }
@media (prefers-reduced-motion: reduce) { .spinner, .dice.rolling .dice-face { animation-duration: 2s; } }
