:root {
  --bg: #f7f5f1;
  --surface: #ffffff;
  --surface-2: #f1ede6;
  --text: #1f1d1a;
  --muted: #6b665e;
  --line: #e4ded4;
  --accent: #d9480f;
  --accent-soft: #fde8dc;
  --ok: #2b8a3e;
  --ok-soft: #e3f4e6;
  --warn: #c92a2a;
  --warn-soft: #fde5e5;
  --minor-soft: #efeae2;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 4px 14px rgba(0, 0, 0, .05);
  --radius: 14px;
  --f-salty: #4c6ef5;
  --f-sweet: #f59f00;
  --f-sour: #82c91e;
  --f-bitter: #845ef7;
  --f-umami: #c2410c;
  --f-spicy: #e03131;
  --f-fatty: #b08850;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161513;
    --surface: #201f1c;
    --surface-2: #2a2825;
    --text: #f1eee8;
    --muted: #a39d93;
    --line: #37342f;
    --accent: #ff7a3d;
    --accent-soft: #3a2418;
    --ok: #69db7c;
    --ok-soft: #1d3322;
    --warn: #ff8787;
    --warn-soft: #3b1f1f;
    --minor-soft: #2e2b27;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR",
    "Malgun Gothic", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* 상단 */
.top { 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); }
.top-inner { max-width: 1120px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center;
  gap: 16px; flex-wrap: wrap; }
.brand { display: flex; align-items: baseline; gap: 8px; font-weight: 700; font-size: 17px; }
.logo { color: var(--accent); }
.dbinfo { font-weight: 400; font-size: 12px; color: var(--muted); }
.tabs { display: flex; gap: 4px; margin-left: auto; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 8px 12px; border-radius: 999px; color: var(--muted);
  white-space: nowrap; font-weight: 600; }
.tabs button[aria-selected="true"] { background: var(--text); color: var(--bg); }

main { max-width: 1120px; margin: 0 auto; padding: 20px 16px 80px; }
.intro h1 { font-size: 24px; margin: 6px 0 4px; letter-spacing: -0.02em; }
.intro p { margin: 0 0 16px; color: var(--muted); }

/* 입력 카드 */
.form-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; }
.field-label { font-size: 13px; font-weight: 700; color: var(--muted); }
input[type="text"], input[type="search"], input[type="number"], select {
  border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 9px 12px;
  outline: none; min-width: 0; }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.inline { display: flex; gap: 8px; align-items: center; }
.grow { flex: 1; }
.primary { align-self: flex-start; border: 0; background: var(--accent); color: #fff; font-weight: 700;
  padding: 10px 18px; border-radius: 10px; }
.primary:hover { filter: brightness(1.05); }
.ghost { align-self: flex-start; border: 1px dashed var(--line); background: none; padding: 7px 12px;
  border-radius: 10px; color: var(--muted); }
.options { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; font-size: 14px; }
.check { display: inline-flex; gap: 6px; align-items: center; }
.select { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); }
.select select { padding: 6px 10px; }
.seg { display: inline-flex; align-items: center; gap: 4px; }
.seg-label { color: var(--muted); margin-right: 4px; }
.seg button { border: 1px solid var(--line); background: var(--surface); padding: 4px 10px; border-radius: 8px; }
.seg button.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.allergy summary { cursor: pointer; color: var(--muted); }
.allergy-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; max-width: 520px; }
.allergy-list label { border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; font-size: 13px;
  display: inline-flex; gap: 4px; align-items: center; }

/* 칩 입력 */
.chip-input { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--surface); position: relative; }
.chip-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.chip-input input { border: 0; box-shadow: none !important; flex: 1; min-width: 160px; padding: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--surface-2); border-radius: 999px;
  padding: 3px 6px 3px 10px; font-size: 14px; }
.chip button { border: 0; background: none; color: var(--muted); padding: 0 4px; font-size: 15px; line-height: 1; }
.quick, .chips-row, .examples { display: flex; flex-wrap: wrap; gap: 6px; }
.quick button, .chips-row button, .examples button { border: 1px solid var(--line); background: var(--surface);
  border-radius: 999px; padding: 4px 11px; font-size: 13px; color: var(--muted); }
.quick button:hover, .examples button:hover { border-color: var(--accent); color: var(--accent); }
.chips-row button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.examples::before { content: "예시"; font-size: 12px; color: var(--muted); align-self: center; margin-right: 2px; }

/* 자동완성 */
.ac-wrap { position: relative; }
.ac-wrap input { width: 100%; }
.ac-list { position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); list-style: none; margin: 0;
  padding: 4px; max-height: 280px; overflow: auto; }
.ac-list li { padding: 7px 10px; border-radius: 7px; cursor: pointer; display: flex; justify-content: space-between;
  gap: 8px; }
.ac-list li.active, .ac-list li:hover { background: var(--surface-2); }
.ac-list .ac-sub { color: var(--muted); font-size: 12px; }

/* 결과 */
.results { margin-top: 18px; }
.summary { color: var(--muted); margin: 0 0 10px; font-size: 14px; }
.summary b { color: var(--text); }
.notice { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; color: var(--muted); font-size: 14px; }
.error { background: var(--warn-soft); color: var(--warn); border-radius: 10px; padding: 10px 12px; }
.group-title { font-size: 15px; margin: 18px 0 8px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px; cursor: pointer;
  transition: transform .08s ease, border-color .08s ease; }
.card:hover { border-color: var(--accent); transform: translateY(-1px); }
.card h3 { margin: 0; font-size: 16px; letter-spacing: -0.01em; }
.card-head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.badges { display: flex; flex-wrap: wrap; gap: 4px; }
.badge { font-size: 11.5px; padding: 2px 7px; border-radius: 6px; background: var(--surface-2); color: var(--muted);
  white-space: nowrap; }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.meta { font-size: 13px; color: var(--muted); }
.cover { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.cover .track { flex: 1; height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.cover .fill { height: 100%; background: var(--ok); border-radius: 99px; }
.ing-row { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; font-size: 13px; }
.ing-row .lbl { color: var(--muted); font-size: 12px; margin-right: 2px; min-width: 44px; }
.pill { padding: 1px 8px; border-radius: 999px; font-size: 12.5px; }
.pill.have { background: var(--ok-soft); color: var(--ok); }
.pill.need { background: var(--warn-soft); color: var(--warn); }
.pill.minor { background: var(--minor-soft); color: var(--muted); }
.ready { color: var(--ok); font-weight: 700; font-size: 13px; }
.more { display: block; margin: 16px auto 0; }

/* 맛 막대 */
.track, .fill { display: block; }
.flavor { display: grid; grid-template-columns: 64px 1fr 34px; gap: 4px 8px; align-items: center; font-size: 12.5px; }
.flavor .name { color: var(--muted); }
.flavor .track { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; position: relative; }
.flavor .fill { height: 100%; border-radius: 99px; }
.flavor .val { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.flavor.mini { grid-template-columns: 52px 1fr; font-size: 11.5px; gap: 2px 6px; }
.flavor.mini .track { height: 5px; }
.compare { display: grid; grid-template-columns: 72px 1fr 54px; gap: 6px 10px; align-items: center; font-size: 13px; }
.compare .bars { display: flex; flex-direction: column; gap: 3px; }
.compare .track { height: 9px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.compare .fill { height: 100%; border-radius: 99px; }
.compare .fill.before { background: color-mix(in srgb, var(--muted) 45%, transparent); }
.compare .delta { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.delta.up { color: var(--ok); } .delta.down { color: var(--warn); } .delta.same { color: var(--muted); font-weight: 400; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin: 6px 0 10px; }
.legend i { display: inline-block; width: 18px; height: 8px; border-radius: 99px; margin-right: 5px; vertical-align: middle; }

/* 소스·실험 */
.guide { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px;
  box-shadow: var(--shadow); margin-bottom: 14px; }
.guide h2 { font-size: 16px; margin: 0 0 6px; }
.guide p { margin: 0 0 10px; color: var(--muted); font-size: 14px; }
.dirs { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; }
.dir { background: var(--surface-2); border-radius: 10px; padding: 10px; font-size: 13.5px; }
.dir b { display: block; margin-bottom: 2px; }
.dir .why { color: var(--muted); margin-bottom: 6px; }
.link-chip { border: 0; background: var(--surface); border-radius: 999px; padding: 2px 9px; margin: 2px 2px 0 0;
  font-size: 12.5px; color: var(--accent); }
.link-chip:hover { text-decoration: underline; }
.avoid { font-size: 13px; color: var(--warn); margin-top: 8px; }
.lab-row { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; flex-wrap: wrap; }
.lab-row .ac-wrap { flex: 1; min-width: 160px; }
.lab-row input[type="number"] { width: 80px; }
.lab-row .x { border: 0; background: none; color: var(--muted); font-size: 18px; padding: 0 6px; }
.lab-result { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 14px; }
@media (max-width: 820px) { .lab-result { grid-template-columns: 1fr; } }
.box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px;
  box-shadow: var(--shadow); }
.box h2 { font-size: 17px; margin: 0 0 4px; }
.box h3 { font-size: 14px; margin: 14px 0 6px; color: var(--muted); }
.becomes { display: inline-block; margin-top: 4px; font-size: 13px; background: var(--accent-soft); color: var(--accent);
  padding: 2px 9px; border-radius: 999px; font-weight: 700; }
.case { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 10px; }
.case:first-of-type { border-top: 0; margin-top: 0; padding-top: 0; }
.case p { margin: 4px 0; }
.case .adjust { color: var(--muted); font-size: 14px; }
.principle { font-size: 13.5px; margin: 8px 0; }
.principle b { display: block; }
.principle span { color: var(--muted); }

/* 서랍 */
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 30; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100%); background: var(--bg); z-index: 40;
  overflow-y: auto; box-shadow: -8px 0 30px rgba(0, 0, 0, .15); }
.drawer-close { position: sticky; top: 8px; float: right; margin: 8px 8px 0 0; border: 0; background: var(--surface-2);
  width: 34px; height: 34px; border-radius: 50%; font-size: 20px; line-height: 1; z-index: 2; }
.drawer-body { padding: 18px 20px 60px; }
.drawer-body h2 { margin: 0; font-size: 22px; letter-spacing: -0.02em; }
.drawer-body .sub { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.drawer-body h3 { font-size: 14px; margin: 20px 0 8px; color: var(--muted); text-transform: none; }
.facts { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13.5px; margin: 10px 0; }
.facts span b { font-weight: 700; }
.ing-group { margin-bottom: 8px; }
.ing-group .g { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.ing-list { list-style: none; margin: 0; padding: 0; }
.ing-list li { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1px dashed var(--line);
  font-size: 14px; }
.ing-list .amt { color: var(--muted); white-space: nowrap; }
.ing-list .prep { color: var(--muted); font-size: 12.5px; }
.steps { margin: 0; padding-left: 0; list-style: none; counter-reset: s; }
.steps li { counter-increment: s; position: relative; padding: 0 0 12px 34px; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 13px; display: grid; place-items: center; }
.tips li, .plain li { margin-bottom: 4px; font-size: 14px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.skeleton { height: 120px; border-radius: var(--radius); background: linear-gradient(90deg, var(--surface-2), var(--surface), var(--surface-2));
  background-size: 200% 100%; animation: sh 1.2s infinite linear; }
@keyframes sh { to { background-position: -200% 0; } }

/* 내 주방 */
.tabs .count { font-size: 11px; background: var(--accent); color: #fff; border-radius: 999px; padding: 0 6px; margin-left: 2px; }
.tabs .count:empty { display: none; }
.kitchen-link { font-size: 12.5px; color: var(--accent); text-decoration: none; }
.kitchen-opt.off { opacity: .55; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.presets::before { content: "빠른 설정"; font-size: 12px; color: var(--muted); margin-right: 2px; }
.presets button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 11px; font-size: 13px; color: var(--muted); }
.presets button:hover { border-color: var(--accent); color: var(--accent); }
.eq-group { margin-top: 6px; }
.eq-group h3 { font-size: 13px; color: var(--muted); margin: 8px 0 6px; }
.eq-list { display: flex; flex-wrap: wrap; gap: 6px; }
.eq-list button { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 7px 12px; font-size: 14px; }
.eq-list button[aria-pressed="true"] { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); font-weight: 700; }
.eq-list button[aria-pressed="true"]::before { content: "✓ "; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat b { display: block; font-size: 24px; letter-spacing: -0.02em; }
.stat span { font-size: 13px; color: var(--muted); }
.stat.ok b { color: var(--ok); } .stat.adapt b { color: var(--accent); } .stat.no b { color: var(--muted); }
.pick { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; box-shadow: var(--shadow); }
.pick h2 { font-size: 17px; margin: 0 0 2px; }
.pick h3 { font-size: 13px; color: var(--muted); margin: 12px 0 6px; }
.mini-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.mini { border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; cursor: pointer; background: var(--bg); }
.mini:hover { border-color: var(--accent); }
.mini b { display: block; font-size: 14px; }
.mini .meta { font-size: 12px; }
.mini .how { font-size: 12px; color: var(--muted); margin-top: 3px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.eq-need { list-style: none; padding: 0; margin: 0; }
.eq-need li { display: flex; gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.eq-need .st { flex: 0 0 auto; font-weight: 700; width: 44px; }
.eq-need .st.ok { color: var(--ok); } .eq-need .st.adapt { color: var(--accent); } .eq-need .st.no { color: var(--warn); }
.eq-need .how { color: var(--muted); font-size: 13px; }
.tip-box { background: var(--accent-soft); color: var(--text); border-radius: 10px; padding: 9px 11px; font-size: 13.5px; margin-top: 8px; }

@media (max-width: 640px) {
  .tabs { gap: 0; }
  .tabs button { padding: 7px 8px; font-size: 13.5px; }
  .stats { grid-template-columns: 1fr 1fr 1fr; }
  .stat b { font-size: 20px; }
  .tabs { margin-left: 0; width: 100%; }
  .intro h1 { font-size: 20px; }
  .inline { flex-wrap: wrap; }
  .primary { width: 100%; }
}
