/* Saucin — warm, rounded, thumb-first. Cream + chili red. System fonts only. */
:root {
  --bg: #FFF7EC; --card: #FFFFFF; --ink: #2B1B14; --muted: #8C6F62; --accent: #E4482B; --accent-deep: #C63A20;
  --accent-soft: #FFE4DC; --green: #5E9A4E; --line: #F1E2D2; --danger: #B3261E;
  --radius: 18px; --shadow: 0 2px 10px rgba(90, 40, 20, .08);
  --sat: env(safe-area-inset-top); --sab: env(safe-area-inset-bottom); --sal: env(safe-area-inset-left); --sar: env(safe-area-inset-right);
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); }
body {
  margin: 0; color: var(--ink); background: var(--bg);
  font: 17px/1.4 ui-rounded, -apple-system, BlinkMacSystemFont, "SF Pro Rounded", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  padding: var(--sat) var(--sar) calc(var(--sab) + 96px) var(--sal);
  -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%; overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* layout */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; min-height: 56px; padding: 8px 16px 0; background: rgba(255, 247, 236, .92); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 24px; letter-spacing: -.01em; }
.brand-emoji { font-size: 26px; }
.back { background: none; border: 0; color: var(--accent); font-weight: 700; font-size: 18px; padding: 8px 0; }
.main { max-width: 640px; margin: 0 auto; padding: 8px 16px; }
.h1 { font-size: 28px; line-height: 1.15; margin: 8px 0 10px; font-weight: 800; letter-spacing: -.02em; }
.h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 26px 0 10px; font-weight: 700; }
.sub { color: var(--muted); font-weight: 500; text-transform: none; letter-spacing: 0; font-size: 14px; }
.lead { font-size: 18px; }
.hint { color: var(--muted); font-size: 15px; }
.hint a { color: var(--accent); font-weight: 700; }
.msg { min-height: 1.2em; margin: 10px 2px; color: var(--accent-deep); font-weight: 600; }
.msg.info { color: var(--muted); font-weight: 500; }
.empty, .loading { text-align: center; color: var(--muted); padding: 56px 20px; font-size: 18px; }
.empty.small { padding: 12px; font-size: 15px; }

/* buttons */
.btn { font-weight: 700; background: var(--accent); color: #fff; border: 0; border-radius: 14px; padding: 14px 18px; font-size: 17px; }
.btn:active { background: var(--accent-deep); }
.btn:disabled { opacity: .6; }
.btn.small { padding: 10px 14px; font-size: 15px; }
.btn-big { width: 100%; padding: 16px; font-size: 18px; margin-top: 14px; border-radius: 16px; }
.btn-ghost { background: #fff; color: var(--ink); border: 2px solid var(--line); }
.btn-danger { background: var(--danger); }
.btn-link { background: none; border: 0; color: var(--accent); font-weight: 700; padding: 8px 0; }
.btn-link.danger { color: var(--danger); }
.chip { font-weight: 700; font-size: 15px; padding: 9px 14px; border-radius: 999px; border: 2px solid var(--line); background: #fff; color: var(--ink); white-space: nowrap; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip .n { color: var(--muted); font-weight: 600; font-size: 13px; margin-left: 2px; }
.chip.on .n { color: rgba(255, 255, 255, .8); }
.chip.small { padding: 7px 12px; font-size: 14px; }

/* inputs */
.search input, .row input, .manual input, .manual textarea, textarea#notes, .key input, .tags-sel {
  width: 100%; font-size: 17px; padding: 13px 14px; border: 2px solid var(--line); border-radius: 16px; background: #fff; color: var(--ink); outline: none; -webkit-appearance: none; appearance: none;
}
.search input:focus, .row input:focus, .manual input:focus, .manual textarea:focus, textarea#notes:focus, .key input:focus, .tags-sel:focus-within { border-color: var(--accent); }
.search input { font-size: 18px; padding: 14px 16px; }
.row { display: flex; gap: 8px; }
.row input { flex: 1; min-width: 0; }
textarea { resize: vertical; }
select { border: 0; background: transparent; font-weight: 700; color: var(--accent); padding: 6px 2px; -webkit-appearance: none; appearance: none; }

/* home */
.listbar { display: flex; align-items: center; justify-content: space-between; margin: 16px 2px 6px; color: var(--muted); font-size: 14px; font-weight: 600; }
.sort { display: flex; align-items: center; gap: 4px; }
.list { display: flex; flex-direction: column; gap: 12px; }
.card { display: flex; gap: 14px; align-items: center; min-height: 92px; padding: 12px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); text-decoration: none; color: inherit; }
.card:active { transform: scale(.985); }
.thumb, .mini-thumb { position: relative; flex: none; display: flex; align-items: center; justify-content: center; overflow: hidden; background: var(--accent-soft); font-size: 30px; }
.thumb { width: 70px; height: 70px; border-radius: 14px; }
.thumb img, .mini-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.card-body { min-width: 0; }
.card-title { font-weight: 700; font-size: 18px; line-height: 1.2; }
.card-meta { color: var(--muted); font-size: 15px; margin-top: 4px; }
.card-sub { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 5px; align-items: center; }
.card-site { color: var(--accent); font-size: 13px; font-weight: 600; }
.card-tag { font-size: 12px; font-weight: 700; color: var(--muted); background: var(--bg); border-radius: 999px; padding: 2px 8px; }
.recent .h2 { margin: 18px 0 8px; }
.scroller { display: flex; gap: 10px; overflow-x: auto; margin: 0 -16px; padding: 2px 16px 8px; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.scroller::-webkit-scrollbar { display: none; }
.mini { flex: none; width: 118px; text-decoration: none; color: inherit; scroll-snap-align: start; }
.mini-thumb { width: 118px; height: 88px; border-radius: 14px; }
.mini-title { font-size: 14px; font-weight: 700; line-height: 1.2; margin-top: 6px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tagrow { display: flex; gap: 8px; overflow-x: auto; margin: 14px -16px 0; padding: 2px 16px 4px; scrollbar-width: none; }
.tagrow::-webkit-scrollbar { display: none; }
.fab { position: fixed; left: 50%; bottom: calc(var(--sab) + 16px); transform: translateX(-50%); z-index: 6; background: var(--accent); color: #fff; font-weight: 800; font-size: 18px; padding: 16px 28px; border-radius: 999px; text-decoration: none; box-shadow: 0 8px 24px rgba(228, 72, 43, .35); white-space: nowrap; }
.fab:active { background: var(--accent-deep); }
.tipbox { margin: 18px 0; padding: 12px 14px; background: var(--accent-soft); border-radius: 14px; font-size: 15px; color: var(--accent-deep); }
.tipbox .btn-link { padding: 0 0 0 6px; }

/* add */
.preview { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin-top: 12px; }
.preview .h2 { margin-top: 16px; }
.hero { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--radius); margin-bottom: 12px; }
.preview-title { font-weight: 800; font-size: 21px; line-height: 1.2; }
.manual { margin-top: 12px; }
.manual label { display: block; font-weight: 700; margin-top: 14px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.manual input, .manual textarea { display: block; margin-top: 6px; }
.manual .h2 { margin-top: 18px; }

/* tag editor */
.tags-sel { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px 10px; }
.tag { display: inline-flex; align-items: center; gap: 4px; background: var(--accent-soft); color: var(--accent-deep); font-weight: 700; font-size: 15px; padding: 6px 6px 6px 12px; border-radius: 999px; }
.tag-x { background: none; border: 0; color: var(--accent-deep); font-size: 20px; line-height: 1; padding: 0 6px; }
.tag-in { flex: 1; min-width: 110px; border: 0; outline: none; background: transparent; padding: 6px 4px; font-size: 16px; }
.tags-sugg { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

/* recipe */
.meta-row { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--muted); font-size: 15px; margin-bottom: 14px; }
.source { color: var(--accent); font-weight: 700; text-decoration: none; }
.dial { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px 12px; text-align: center; }
.dial-label { text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-size: 13px; font-weight: 700; }
.dial-row { display: flex; align-items: center; justify-content: center; gap: 18px; margin: 6px 0; }
.dial-btn { width: 62px; height: 62px; border-radius: 50%; border: 0; background: var(--accent-soft); color: var(--accent-deep); font-size: 36px; font-weight: 800; line-height: 1; }
.dial-btn:active { background: var(--accent); color: #fff; }
.dial-num { background: none; border: 0; font-size: 54px; font-weight: 800; min-width: 110px; padding: 0; letter-spacing: -.03em; line-height: 1.1; }
.dial-in { width: 140px; font-size: 44px; font-weight: 800; text-align: center; border: 2px solid var(--accent); border-radius: 14px; padding: 4px; outline: none; -webkit-appearance: none; appearance: none; }
.chips { display: flex; justify-content: center; gap: 8px; margin-top: 4px; }
.dial-foot { margin-top: 10px; font-size: 15px; color: var(--muted); min-height: 1.4em; }
.dial-foot .btn-link { padding: 4px 0; }
.base-form { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; }
.base-form input { width: 80px; font-size: 18px; padding: 8px; border: 2px solid var(--line); border-radius: 12px; text-align: center; outline: none; -webkit-appearance: none; appearance: none; }

.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.grid-h { grid-column: 1 / -1; font-weight: 800; text-transform: uppercase; font-size: 12px; letter-spacing: .08em; color: var(--muted); margin: 6px 2px -2px; }
.tile { display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 4px; min-height: 124px; padding: 12px 6px 10px; background: #fff; border: 0; border-radius: 16px; box-shadow: var(--shadow); text-align: center; }
.tile:active { transform: scale(.97); }
.tile-icon { font-size: 34px; line-height: 1; }
.tile-name { font-size: 14px; font-weight: 700; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }
.tile-amt { font-size: 13px; color: var(--accent-deep); font-weight: 700; line-height: 1.2; margin-top: auto; }
.tile.done { opacity: .45; }
.tile.done .tile-name { text-decoration: line-through; }

.steps { list-style: none; padding: 0; margin: 0; }
.step { padding: 10px 0; }
.step-row { display: flex; gap: 12px; align-items: flex-start; }
.num { flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-deep); font-weight: 800; display: flex; align-items: center; justify-content: center; font-size: 15px; }
.step-text { flex: 1; }
.step-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 0 42px; }
.step.also .step-chips { margin-left: 0; padding-top: 6px; border-top: 1px dashed var(--line); }
.also-label { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); align-self: center; margin-right: 2px; }
.chipi { display: inline-flex; align-items: center; gap: 4px; background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px 4px 6px; font-size: 13px; font-weight: 600; box-shadow: 0 1px 3px rgba(90, 40, 20, .06); }
.chipi-ic { font-size: 15px; }
.chipi-amt { color: var(--accent-deep); font-weight: 700; }
.chipi.done { opacity: .45; text-decoration: line-through; }
.section-h { font-weight: 800; margin: 14px 0 2px; text-transform: uppercase; font-size: 12px; letter-spacing: .08em; color: var(--muted); }
textarea#notes { min-height: 110px; }
.danger { margin-top: 36px; text-align: center; }
.confirm { margin-top: 8px; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; align-items: center; }

/* ingredient sheet */
.sheet-wrap { position: fixed; inset: 0; z-index: 20; background: rgba(43, 27, 20, .45); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 640px; background: #fff; border-radius: 22px 22px 0 0; padding: 18px 20px calc(var(--sab) + 20px); text-align: center; box-shadow: 0 -8px 30px rgba(0, 0, 0, .15); }
.sheet-icon { font-size: 44px; }
.sheet-line { font-size: 19px; font-weight: 700; margin-top: 6px; }
.sheet-orig { color: var(--muted); font-size: 15px; margin-top: 6px; }
.sheet-btns { display: flex; gap: 8px; justify-content: center; margin-top: 16px; }
.sheet-btns .btn { flex: 1; }

/* key screen */
.key { text-align: center; padding-top: 36px; }
.key-emoji { font-size: 72px; }
.key input { text-align: center; margin-top: 8px; }

/* toast */
.toast { position: fixed; left: 50%; bottom: calc(var(--sab) + 92px); z-index: 30; transform: translate(-50%, 16px); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-weight: 700; opacity: 0; transition: opacity .2s ease, transform .2s ease; pointer-events: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 640px) {
  .grid { grid-template-columns: repeat(4, 1fr); }
  .scroller, .tagrow { margin-left: 0; margin-right: 0; padding-left: 0; padding-right: 0; }
}
