/* ============================================================
   piponi.com — design system (from the "Piponi Commonplace" mockup)
   Commonplace-book identity: warm paper, forest-green accent, brass.
   Mobile-first; desktop reflows. Light + dark via prefers-color-scheme.
   ============================================================ */

:root {
  --bg:        #ECE7DB;
  --paper:     #F6F3EC;
  --surface:   #FCFAF5;
  --surface-2: #F1ECE0;
  --ink:       #22271F;
  --muted:     #6B6F60;
  --line:      #E2DCCC;
  --line-strong:#D3CBB6;
  --accent:    #1F5B45;
  --accent-ink:#FFFFFF;
  --accent-soft:#E3EDE5;
  --brass:     #9C6E24;
  --good:      #3F8A4F;
  --good-soft: #E4EFE2;
  --warn:      #B77C1E;
  --warn-soft: #F3E8CF;
  --clay:      #A9463A;
  --clay-soft: #F1E0DA;
  --shadow:    0 1px 2px rgba(34,39,31,.05), 0 8px 24px rgba(34,39,31,.08);
  --radius:    14px;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:#121309; --paper:#191A15; --surface:#212319; --surface-2:#2A2C22;
    --ink:#ECEADE; --muted:#9EA18C; --line:#2F3128; --line-strong:#3B3D31;
    --accent:#74BE97; --accent-ink:#12241A; --accent-soft:#233227; --brass:#D2A24E;
    --good:#6FBE7C; --good-soft:#22321F; --warn:#E0A94A; --warn-soft:#332913;
    --clay:#E08476; --clay-soft:#35211D;
    --shadow:0 1px 2px rgba(0,0,0,.4), 0 10px 30px rgba(0,0,0,.45);
  }
}
:root[data-theme="dark"] {
  --bg:#121309; --paper:#191A15; --surface:#212319; --surface-2:#2A2C22;
  --ink:#ECEADE; --muted:#9EA18C; --line:#2F3128; --line-strong:#3B3D31;
  --accent:#74BE97; --accent-ink:#12241A; --accent-soft:#233227; --brass:#D2A24E;
  --good:#6FBE7C; --good-soft:#22321F; --warn:#E0A94A; --warn-soft:#332913;
  --clay:#E08476; --clay-soft:#35211D;
  --shadow:0 1px 2px rgba(0,0,0,.4), 0 10px 30px rgba(0,0,0,.45);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.2; text-wrap: balance; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ---------- layout ---------- */
.wrap { width: 100%; max-width: 680px; margin: 0 auto; padding: 0 16px; }
.stack > * + * { margin-top: 12px; }
.section-label { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); margin: 22px 2px 8px; }

/* ---------- public site header/footer ---------- */
header.site { border-bottom: 1px solid var(--line); }
header.site .bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0; }
header.site .brand { font-family: var(--font-display); font-weight: 700; font-size: 18px; color: var(--ink); }
header.site nav a { margin-left: 16px; color: var(--muted); font-size: 14px; }
header.site nav a:hover { color: var(--ink); }
main.site { padding: 26px 0 60px; }
footer.site { border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
footer.site .bar { padding: 18px 0; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.card.flush { padding: 4px 14px; }

/* ---------- buttons / forms ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-weight: 600; font-size: 15px; padding: 13px 18px; border-radius: 12px; border: 1px solid transparent; cursor: pointer; }
.btn.block { width: 100%; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.05); text-decoration: none; }
.btn.ghost { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.btn svg { width: 17px; height: 17px; }
.field { margin-bottom: 14px; }
.field label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 6px; }
.field input { width: 100%; font: inherit; padding: 13px 14px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); outline: none; }
.field input:focus { border-color: var(--accent); }
.honey { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.notice { font-size: 13.5px; padding: 11px 13px; border-radius: 10px; margin-bottom: 14px; }
.notice.err { background: var(--clay-soft); color: var(--clay); }
.notice.ok  { background: var(--good-soft); color: var(--good); }

/* ---------- stats / pills / rows (dashboard) ---------- */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 13px 14px; }
.stat .n { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 26px; line-height: 1; letter-spacing: -.5px; }
.stat .k { font-size: 12px; color: var(--muted); margin-top: 6px; }
.stat.alert .n { color: var(--clay); }

.row { display: flex; align-items: center; gap: 11px; padding: 11px 2px; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row .main { flex: 1; min-width: 0; }
.row .t { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .s { font-size: 12px; color: var(--muted); margin-top: 1px; }

.pill { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.pill.ok    { background: var(--good-soft);  color: var(--good); }
.pill.you   { background: var(--accent-soft);color: var(--accent); }
.pill.key   { background: var(--surface-2);  color: var(--muted); border: 1px solid var(--line); }
.pill.probe { background: var(--clay-soft);  color: var(--clay); }

svg.spark { width: 100%; height: 46px; display: block; }

/* ---------- admin shell ---------- */
.admin-top { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--paper) 86%, transparent); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); }
.admin-top .bar { display: flex; align-items: center; gap: 10px; padding: 14px 0; }
.admin-top .eyebrow { font-size: 10px; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); }
.admin-top h1 { font-size: 19px; margin: 1px 0 0; }
.admin-top .grow { flex: 1; }
.iconbtn { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; }
.iconbtn:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.iconbtn svg { width: 18px; height: 18px; }

main.admin { padding: 18px 0 96px; }

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: flex; border-top: 1px solid var(--line); background: var(--surface); }
.tabbar .tab { flex: 1; padding: 9px 4px 10px; display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--muted); font-size: 10px; }
.tabbar .tab:hover { text-decoration: none; color: var(--ink); }
.tabbar .tab.active { color: var(--accent); }
.tabbar .tab svg { width: 21px; height: 21px; }
.tabbar .tab[aria-disabled="true"] { opacity: .5; pointer-events: none; }

@media (min-width: 760px) {
  .tabbar { position: sticky; top: 0; max-width: 680px; margin: 0 auto; border: 1px solid var(--line); border-radius: 999px; margin-top: 14px; }
  .tabbar .tab { flex-direction: row; gap: 7px; padding: 12px; font-size: 13px; }
  main.admin { padding-bottom: 60px; }
}

/* ---------- recipe / content (public) ---------- */
.recipe-title { font-size: 28px; margin: 14px 0 6px; }
.metrow { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.metric { font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px; }
.metric b { color: var(--ink); }
.lede { color: var(--muted); font-size: 15px; }
.hero { height: 200px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: var(--surface-2); }
.ing-list { list-style: none; margin: 8px 0 0; padding: 0; }
.ing-list li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.ing-list li:last-child { border-bottom: 0; }
.ing-list .amt { color: var(--muted); font-family: var(--font-mono); font-size: 13px; white-space: nowrap; }
.steps { counter-reset: step; list-style: none; margin: 6px 0 0; padding: 0; }
.steps li { position: relative; padding: 4px 0 16px 40px; }
.steps li::before { counter-increment: step; content: counter(step); position: absolute; left: 0; top: 2px; width: 27px; height: 27px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-family: var(--font-mono); font-size: 13px; font-weight: 700; display: grid; place-items: center; }
/* subheadings inside ingredient / method lists (a line ending in ":") */
.ing-list li.subhead { display: block; border-bottom: 0; padding: 18px 0 4px; font-family: var(--font-display); font-weight: 700; font-size: 15px; color: var(--ink); }
.ing-list li.subhead:first-child { padding-top: 2px; }
.steps li.subhead { counter-increment: none; padding: 14px 0 4px 0; font-family: var(--font-display); font-weight: 700; }
.steps li.subhead::before, .steps li.subhead::after { display: none; content: none; }

/* ---------- pantry ---------- */
.search { display: flex; align-items: center; gap: 9px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px; padding: 11px 13px; }
.search svg { width: 17px; height: 17px; color: var(--muted); flex: none; }
.search input { border: 0; background: transparent; font: inherit; color: var(--ink); width: 100%; outline: none; }
.search input::placeholder { color: var(--muted); }

.cathead { display: flex; align-items: baseline; justify-content: space-between; margin: 20px 2px 8px; }
.cathead h2 { font-size: 15px; }
.cathead .n { font-size: 12px; color: var(--muted); font-family: var(--font-mono); }

.ing { display: flex; align-items: center; gap: 12px; padding: 11px 2px; border-bottom: 1px solid var(--line); }
.ing:last-child { border-bottom: 0; }
.ing .name { flex: 1; font-size: 15px; min-width: 0; }
.ing .name a { color: var(--ink); }
.ing form { margin: 0; display: flex; }

.stock-tag { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.stock-tag.in  { color: var(--good); background: var(--good-soft); }
.stock-tag.out { color: var(--clay); background: var(--clay-soft); }

.toggle { --w: 46px; width: var(--w); height: 27px; border-radius: 999px; padding: 0; position: relative; cursor: pointer; background: var(--surface-2); border: 1px solid var(--line-strong); transition: background .18s; flex: none; }
.toggle::after { content: ""; position: absolute; top: 2px; left: 2px; width: 21px; height: 21px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .18s; }
.toggle[aria-pressed="true"] { background: var(--good); border-color: var(--good); }
.toggle[aria-pressed="true"]::after { transform: translateX(19px); }
.toggle[data-state="out"] { background: var(--clay-soft); border-color: var(--clay); }

.addbar { display: flex; gap: 8px; margin-top: 10px; }
.addbar input[type="text"], select { font: inherit; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); outline: none; }
.addbar input[type="text"] { flex: 1; min-width: 0; }
.addbar select { flex: 1; min-width: 0; }
.addbar input:focus, select:focus { border-color: var(--accent); }
.field select { width: 100%; }

.pill-link { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; padding: 8px 14px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.pill-link:hover { text-decoration: none; filter: brightness(.98); }
.pill-link .count { font-family: var(--font-mono); }
.edit-link { color: var(--muted); font-size: 13px; padding: 0 4px; }
.toolbar { display: flex; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.muted { color: var(--muted); }

/* ---------- recipes: public index ---------- */
.rgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; margin-top: 18px; }
.rcard { display: block; color: var(--ink); }
.rcard:hover { text-decoration: none; }
.rcard .thumb { aspect-ratio: 4 / 3; border-radius: var(--radius); overflow: hidden; background: var(--surface-2); border: 1px solid var(--line); display: block; }
.rcard .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rcard .ph { width: 100%; height: 100%; display: grid; place-items: center; color: var(--muted); }
.rcard h3 { font-size: 16px; margin: 9px 2px 2px; line-height: 1.2; }
.rcard .meta { font-size: 12px; color: var(--muted); margin: 0 2px; }
.rcard:hover h3 { color: var(--accent); }

/* ---------- recipes: detail ---------- */
.rhero { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); margin-bottom: 4px; }
.rhero img { width: 100%; max-height: 62vh; object-fit: cover; display: block; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin-top: 16px; }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }

/* ---------- recipes: admin ---------- */
.rrow { display: flex; align-items: center; gap: 12px; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.rrow:last-child { border-bottom: 0; }
.rrow .rthumb { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; border: 1px solid var(--line); flex: none; background: var(--surface-2); }
.rrow .main { flex: 1; min-width: 0; }
.rrow .main a { color: var(--ink); font-family: var(--font-display); font-size: 16px; }
.rrow .sub { font-size: 12px; color: var(--muted); }
.pill.draft { background: var(--warn-soft); color: var(--warn); }
.pill.published { background: var(--good-soft); color: var(--good); }

.field textarea { width: 100%; font: inherit; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); outline: none; resize: vertical; min-height: 92px; line-height: 1.5; }
.field textarea:focus { border-color: var(--accent); }
.field .hint { font-size: 11.5px; color: var(--muted); margin-top: 5px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.uploader { border: 1px dashed var(--line-strong); border-radius: 12px; padding: 14px; text-align: center; }
.uploader input[type="file"] { font: inherit; width: 100%; }
.photo-manage { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; margin-top: 12px; }
.photo-manage figure { margin: 0; position: relative; }
.photo-manage img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); display: block; }
.photo-manage button { position: absolute; top: 5px; right: 5px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(0,0,0,.55); color: #fff; cursor: pointer; font-size: 14px; line-height: 1; }
