:root {
  --bg: #fbf8f3;
  --surface: #ffffff;
  --ink: #23201c;
  --muted: #6f675e;
  --line: #e9e2d8;
  --accent: #c2410c;
  --accent-ink: #ffffff;
  --accent-soft: #fde7da;
  --danger: #b42318;
  --discord: #5865f2;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(35, 32, 28, .06), 0 6px 20px rgba(35, 32, 28, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171513;
    --surface: #211e1b;
    --ink: #f1ece6;
    --muted: #a99f94;
    --line: #34302b;
    --accent: #f97316;
    --accent-ink: #1a0f08;
    --accent-soft: #3a2416;
    --danger: #f97066;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
a { color: var(--accent); text-underline-offset: 2px; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); letter-spacing: -.01em; }
h2 { font-size: 1.2rem; margin-top: 1.6em; }
img { max-width: 100%; height: auto; }
.wrap { max-width: 1100px; margin: 0 auto; padding-inline: 16px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.inline { display: inline; }
.danger { color: var(--danger); }

/* top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top, 0px);
}
.topbar-inner { display: flex; align-items: center; gap: 16px; min-height: 60px; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 1.15rem; color: var(--ink); text-decoration: none; display: flex; gap: 6px; align-items: center; }
.nav { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; margin-left: auto; }
.nav a:not(.btn) { color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 8px; }
.nav a.on, .nav a:not(.btn):hover { color: var(--ink); background: var(--accent-soft); }
.me { position: relative; }
.me summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; padding: 4px; border-radius: 999px; }
.me summary::-webkit-details-marker { display: none; }
.me-menu {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 170px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
  padding: 6px; display: grid;
}
.me-menu a, .me-menu .linklike { padding: 8px 10px; border-radius: 8px; text-align: left; color: var(--ink); text-decoration: none; }
.me-menu a:hover, .me-menu .linklike:hover { background: var(--accent-soft); }
.avatar { width: 28px; height: 28px; border-radius: 50%; vertical-align: middle; }
@media (max-width: 640px) { .me-name { display: none; } .nav { margin-left: 0; order: 3; width: 100%; } }

/* buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent); color: var(--accent-ink); border: 1px solid transparent;
  padding: 9px 16px; border-radius: 10px; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn:hover { filter: brightness(1.05); }
.btn-small { padding: 6px 12px; font-size: .9rem; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--accent-soft); }
.btn-on { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-discord { background: var(--discord); color: #fff; font-size: 1.05rem; padding: 12px 22px; }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; }

/* home */
.hero { margin: 28px 0 18px; }
.search { display: flex; gap: 8px; max-width: 640px; }
.search input { flex: 1; min-width: 0; }
input[type=text], input[type=search], input[type=url], textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
}
textarea { resize: vertical; }
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 0; }
.tag {
  display: inline-block; font-size: .8rem; padding: 3px 10px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); color: var(--muted); text-decoration: none;
}
.tag.on, a.tag:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.tag .count { opacity: .7; }

.cards { list-style: none; padding: 0; margin: 0; display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.card { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.card-link { color: inherit; text-decoration: none; display: block; }
.card-img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; background: var(--accent-soft); }
.card-img-empty { display: grid; place-items: center; font-size: 2.4rem; }
.card-body { padding: 12px 14px 14px; }
.card-title { font-size: 1.02rem; margin: 0 0 6px; }
.card-tags { margin: 0 0 6px; display: flex; gap: 4px; flex-wrap: wrap; }
.card-meta { margin: 0; color: var(--muted); font-size: .85rem; }
.card-fav { position: absolute; top: 8px; right: 8px; }
.fav {
  width: 36px; height: 36px; border-radius: 50%; border: 0; cursor: pointer; font-size: 1.1rem;
  background: rgba(255, 255, 255, .9); color: #9a9188; box-shadow: var(--shadow);
}
.fav.on { color: #e11d48; }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.pager { display: flex; justify-content: center; gap: 8px; margin: 24px 0; }

/* recipe */
.recipe { max-width: 860px; margin: 24px auto; }
.recipe-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.cover { margin: 18px 0; }
.cover img { width: 100%; max-height: 520px; object-fit: cover; border-radius: var(--radius); }
.lead { font-size: 1.08rem; }
.facts { display: flex; gap: 12px; flex-wrap: wrap; margin: 16px 0; }
.facts div { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px 14px; }
.facts dt { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.facts dd { margin: 0; font-weight: 600; }
.recipe-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 28px; }
@media (max-width: 760px) { .recipe-grid { grid-template-columns: 1fr; } }
.ingredients { list-style: none; padding: 0; margin: 0; }
.ingredients li { padding: 6px 0; border-bottom: 1px dashed var(--line); }
.ingredients label { display: flex; gap: 10px; align-items: baseline; cursor: pointer; }
.ingredients input:checked + span { text-decoration: line-through; color: var(--muted); }
.subhead { font-weight: 700; padding-top: 14px !important; border-bottom: 0 !important; list-style: none; }
.steps { padding-left: 1.3em; margin: 0; }
.steps li { margin: 0 0 12px; padding-left: 4px; }
.steps li.subhead { margin-left: -1.3em; }
.source { margin-top: 24px; word-break: break-all; }
.gallery { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; display: block; }
.gallery-actions { display: flex; justify-content: space-between; margin-top: 4px; }
.upload { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.timeline { padding-left: 1.1em; }
.danger-zone { margin-top: 32px; border-top: 1px solid var(--line); padding-top: 12px; }
.danger-zone summary { cursor: pointer; color: var(--muted); }
.danger-zone form { display: grid; gap: 8px; max-width: 480px; margin-top: 10px; }

/* forms */
.recipe-form { display: grid; gap: 14px; max-width: 860px; }
.field { display: grid; gap: 4px; }
.field > span { font-weight: 600; font-size: .95rem; }
.field em { font-weight: 400; font-style: normal; font-size: .85rem; }
.field-row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.form-actions { display: flex; gap: 8px; }

/* history */
.crumbs { margin: 20px 0 6px; }
.history { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.history > li { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; }
.history-link { display: flex; justify-content: space-between; gap: 12px; color: inherit; text-decoration: none; flex-wrap: wrap; }
.history-who { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.history-when { color: var(--muted); font-size: .9rem; white-space: nowrap; }
.history-summary { margin: 6px 0 0; font-style: italic; }
.diff { width: 100%; border-collapse: collapse; margin-top: 16px; table-layout: fixed; }
.diff th, .diff td { border-bottom: 1px solid var(--line); padding: 8px; text-align: left; vertical-align: top; }
.diff thead th { font-size: .8rem; color: var(--muted); text-transform: uppercase; }
.diff tbody th { width: 120px; }
.diff tr.changed td:last-child { background: var(--accent-soft); }
.pre { white-space: pre-wrap; word-break: break-word; font-size: .92rem; }
.thumb-tiny { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; margin-right: 4px; }
@media (max-width: 640px) { .diff, .diff tbody, .diff tr, .diff th, .diff td { display: block; width: 100%; } .diff thead { display: none; } }

/* banners & cards */
.banner { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; background: var(--accent-soft); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; margin: 16px 0; }
.banner-warn { border-color: #f5b98f; }
.banner-error { background: color-mix(in srgb, var(--danger) 14%, var(--surface)); border-color: var(--danger); }
.center-card { max-width: 440px; margin: 10vh auto; text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 32px 24px; box-shadow: var(--shadow); }
.big-emoji { font-size: 3rem; }
.footer { color: var(--muted); font-size: .8rem; padding-block: 32px; text-align: center; }
