:root {
  --bg: #f7f5ef; --surface: #ffffff; --surface2: #f0ede4; --text: #1f2421; --muted: #6b716c; --line: #e3dfd4;
  --accent: #2f6f4f; --accent-soft: #e2efe7; --bad: #c2412d; --bad-soft: #fbe5e0; --warn: #b8741a; --warn-soft: #fbefd9;
  --ok: #2f6f4f; --ok-soft: #e2efe7; --info: #3b62a8; --info-soft: #e3eaf7;
  --radius: 14px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141715; --surface: #1d211f; --surface2: #262b28; --text: #e9ece9; --muted: #9aa39d; --line: #313733;
    --accent: #6fbf94; --accent-soft: #1f3529; --bad: #f08a76; --bad-soft: #3a211c; --warn: #e6b460; --warn-soft: #3a2f1a;
    --ok: #6fbf94; --ok-soft: #1f3529; --info: #8fb0ea; --info-soft: #1f2a3d; --shadow: none;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font-family: 'Pretendard Variable', Pretendard, -apple-system, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }

/* ── 상단/탭 */
.top { position: sticky; top: 0; z-index: 10; background: var(--bg); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; padding: 12px 16px; max-width: 1080px; margin: 0 auto; font-size: 17px; }
.brand .logo { font-size: 20px; }
.sync { margin-left: auto; font-size: 12px; color: var(--muted); background: var(--surface2); padding: 3px 9px; border-radius: 99px; }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 20; }
.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 8px 0 7px; font-size: 19px; text-decoration: none; color: var(--muted); cursor: pointer; }
.tabs a span { font-size: 11px; }
.tabs a.on { color: var(--accent); }
.tabs a.on span { font-weight: 700; }
@media (min-width: 860px) {
  body { padding-bottom: 32px; }
  .top { display: flex; align-items: center; }
  .top .brand { margin: 0; padding-left: max(16px, calc((100vw - 1080px) / 2)); }
  .top .sync { margin-left: 12px; }
  .tabs { position: static; border: 0; background: none; margin-left: auto; padding-right: max(16px, calc((100vw - 1080px) / 2)); gap: 4px; }
  .tabs a { flex: none; flex-direction: row; gap: 6px; font-size: 15px; padding: 8px 12px; border-radius: 10px; }
  .tabs a span { font-size: 14px; }
  .tabs a.on { background: var(--accent-soft); }
}

main { max-width: 1080px; margin: 0 auto; padding: 16px; }
h1 { font-size: 22px; margin: 4px 0 2px; letter-spacing: -0.02em; }
h2 { font-size: 17px; margin: 26px 0 10px; display: flex; align-items: center; gap: 8px; letter-spacing: -0.01em; }
h2 .more { margin-left: auto; font-size: 13px; font-weight: 500; }
.sub { color: var(--muted); font-size: 13px; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.pad { padding: 14px 16px; }
.grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.note { background: var(--info-soft); color: var(--text); border-radius: 12px; padding: 12px 14px; font-size: 13.5px; }
.note b { color: var(--info); }

/* ── 뱃지·칩 */
.bdg { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 99px; white-space: nowrap; }
.bdg.bad { background: var(--bad-soft); color: var(--bad); }
.bdg.warn { background: var(--warn-soft); color: var(--warn); }
.bdg.ok { background: var(--ok-soft); color: var(--ok); }
.bdg.muted { background: var(--surface2); color: var(--muted); font-weight: 500; }
.bdg.info { background: var(--info-soft); color: var(--info); }
.tag { display: inline-block; font-size: 11.5px; padding: 1px 7px; border-radius: 6px; background: var(--surface2); color: var(--muted); margin-right: 4px; }
.tag.est { background: var(--warn-soft); color: var(--warn); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.chip { border: 1px solid var(--line); background: var(--surface); padding: 6px 12px; border-radius: 99px; font-size: 13.5px; cursor: pointer; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .chip.on { color: #0e1a13; } }

/* ── 재료 목록 */
.list { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-top: 1px solid var(--line); cursor: pointer; }
.row:first-child { border-top: 0; }
.row:hover { background: var(--surface2); }
.row .main { flex: 1; min-width: 0; }
.row .name { font-weight: 600; }
.row .meta { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .warnline { font-size: 12px; color: var(--warn); }
.grp { font-size: 13px; font-weight: 700; color: var(--muted); margin: 18px 2px 6px; display: flex; gap: 6px; align-items: center; }
.search { width: 100%; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); }

/* ── 레시피 카드 */
.rc { padding: 14px 16px; cursor: pointer; display: flex; flex-direction: column; gap: 6px; }
.rc:hover { border-color: var(--accent); }
.rc .t { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; }
.rc .t .bdg { margin-left: auto; }
.rc .ings { font-size: 13px; line-height: 1.7; }
.have { color: var(--ok); }
.miss { color: var(--bad); font-weight: 600; }
.bar { height: 5px; border-radius: 9px; background: var(--surface2); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 9px; }

/* ── 모달 */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--surface); width: 100%; max-width: 640px; max-height: 92vh; overflow: auto; border-radius: 20px 20px 0 0; padding: 18px 16px calc(20px + env(safe-area-inset-bottom)); }
@media (min-width: 700px) { .modal { align-items: center; } .sheet { border-radius: 20px; padding: 22px 24px; } }
.sheet h1 { display: flex; align-items: center; gap: 8px; }
.sheet .x { margin-left: auto; border: 0; background: var(--surface2); width: 34px; height: 34px; border-radius: 50%; cursor: pointer; font-size: 16px; }
.form { display: grid; gap: 12px; margin-top: 12px; }
.form label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.form input, .form select, .form textarea { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); font-size: 15px; width: 100%; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { flex: 1; border: 0; background: var(--bg); padding: 9px 4px; cursor: pointer; font-size: 14px; }
.seg button.on { background: var(--accent); color: #fff; font-weight: 700; }
@media (prefers-color-scheme: dark) { .seg button.on { color: #0e1a13; } }
.guidebox { background: var(--accent-soft); border-radius: 12px; padding: 12px 14px; font-size: 13.5px; }
.guidebox .ranges { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; font-weight: 600; }
.btns { display: flex; gap: 8px; margin-top: 16px; }
.btn { border: 1px solid var(--line); background: var(--surface); padding: 11px 16px; border-radius: 12px; cursor: pointer; font-weight: 600; font-size: 14.5px; text-decoration: none; color: var(--text); display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn.pri { background: var(--accent); border-color: var(--accent); color: #fff; flex: 1; }
@media (prefers-color-scheme: dark) { .btn.pri { color: #0e1a13; } }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 9px; }
.fab { position: fixed; right: 18px; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 15; width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; font-size: 28px; box-shadow: 0 6px 18px rgba(0,0,0,.2); cursor: pointer; }
@media (min-width: 860px) { .fab { bottom: 28px; right: max(24px, calc((100vw - 1080px) / 2)); } }

/* ── 레시피 상세 */
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 99px; overflow: hidden; }
.stepper button { border: 0; background: var(--surface2); width: 36px; height: 34px; font-size: 18px; cursor: pointer; }
.stepper b { padding: 0 14px; }
table.ing { width: 100%; border-collapse: collapse; font-size: 14.5px; margin-top: 8px; }
table.ing td { padding: 8px 4px; border-top: 1px solid var(--line); vertical-align: top; }
table.ing td.q { text-align: right; white-space: nowrap; font-weight: 700; font-variant-numeric: tabular-nums; }
table.ing td.s { width: 26px; text-align: center; }
table.ing .nt { display: block; font-size: 12px; color: var(--muted); }
ol.steps { padding-left: 22px; margin: 8px 0; }
ol.steps li { margin: 8px 0; }
ul.tips { padding-left: 18px; margin: 6px 0; color: var(--muted); font-size: 14px; }

/* ── 할인 */
.deal { display: flex; gap: 10px; align-items: center; padding: 11px 14px; border-top: 1px solid var(--line); }
.deal:first-child { border-top: 0; }
.deal .price { text-align: right; white-space: nowrap; }
.deal .price b { font-size: 16px; }
.deal .price s { display: block; font-size: 12px; color: var(--muted); }
.season { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.season .card { padding: 10px 12px; }
.season .card b { display: block; }

.toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 99px; font-size: 14px; z-index: 60; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; font-size: 14px; }
