:root {
  --bg: #f6f6f4;
  --surface: #ffffff;
  --surface-2: #f1f1ee;
  --text: #1d1d1b;
  --text-dim: #6b6b66;
  --line: #e2e2dd;
  --accent: #c4502a;
  --accent-soft: #fbeae4;
  --ready: #2f7d4f;
  --ready-soft: #e4f3ea;
  --near: #b2791a;
  --near-soft: #fbf1dd;
  --swap: #2f6ea8;
  --swap-soft: #e3eef8;
  --far: #8b8b85;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 8px 24px rgba(0,0,0,.05);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17171a;
    --surface: #202024;
    --surface-2: #2a2a2f;
    --text: #ececea;
    --text-dim: #9b9b96;
    --line: #35353b;
    --accent: #e8805c;
    --accent-soft: #3a241d;
    --ready: #6fc48f;
    --ready-soft: #1f3a2a;
    --near: #e0b55f;
    --near-soft: #3a2f18;
    --swap: #78b6e8;
    --swap-soft: #172c3d;
    --far: #7a7a74;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.3);
  }
}
:root[data-theme="dark"] {
  --bg: #17171a;
  --surface: #202024;
  --surface-2: #2a2a2f;
  --text: #ececea;
  --text-dim: #9b9b96;
  --line: #35353b;
  --accent: #e8805c;
  --accent-soft: #3a241d;
  --ready: #6fc48f;
  --ready-soft: #1f3a2a;
  --near: #e0b55f;
  --near-soft: #3a2f18;
  --swap: #78b6e8;
  --swap-soft: #172c3d;
  --far: #7a7a74;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.3);
}

* { box-sizing: border-box; }

/* display 를 지정한 요소에도 hidden 이 먹도록 */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", Pretendard,
               "Noto Sans KR", "Malgun Gothic", "맑은 고딕", sans-serif;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

/* ── 상단 ─────────────────────────────── */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px 16px;
  max-width: 1180px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 30px; line-height: 1; }
.topbar h1 { margin: 0; font-size: 20px; letter-spacing: -.02em; }
.topbar p { margin: 2px 0 0; font-size: 13px; color: var(--text-dim); }
.icon-btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  width: 38px; height: 38px; border-radius: 10px; font-size: 16px; cursor: pointer;
  flex: none;
}
.icon-btn:hover { border-color: var(--accent); }

/* ── 레이아웃 ──────────────────────────── */
.layout {
  max-width: 1180px; margin: 0 auto; padding: 0 16px 64px;
  display: grid; grid-template-columns: 300px 1fr; gap: 20px; align-items: start;
}
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
}

.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
  position: sticky; top: 16px;
  max-height: calc(100vh - 32px); overflow-y: auto;
}
@media (max-width: 860px) { .panel { position: static; max-height: none; overflow: visible; } }

.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.panel h2 { margin: 0 0 10px; font-size: 15px; }
.count {
  display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 2px;
  background: var(--accent-soft); color: var(--accent);
  border-radius: 999px; font-size: 12px; text-align: center; font-weight: 600;
}
.link-btn {
  background: none; border: 0; color: var(--text-dim); font-size: 12px;
  cursor: pointer; padding: 0; text-decoration: underline; font-family: inherit;
}
.link-btn:hover { color: var(--accent); }

/* ── 재료 입력 ─────────────────────────── */
.input-wrap { position: relative; }
.input-wrap input, .search {
  width: 100%; padding: 9px 11px; font-size: 14px; font-family: inherit;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--surface-2); color: var(--text);
}
.input-wrap input:focus, .search:focus {
  outline: 2px solid var(--accent); outline-offset: -1px; background: var(--surface);
}
.suggest {
  position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; right: 0;
  margin: 0; padding: 4px; list-style: none; max-height: 240px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 9px; box-shadow: var(--shadow);
}
.suggest li {
  padding: 7px 9px; border-radius: 6px; cursor: pointer; font-size: 14px;
  display: flex; justify-content: space-between; gap: 8px;
}
.suggest li.on, .suggest li:hover { background: var(--accent-soft); color: var(--accent); }
.suggest .as { font-size: 11px; color: var(--text-dim); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 6px 4px 10px; border-radius: 999px; font-size: 13px;
  background: var(--accent-soft); color: var(--accent); border: 1px solid transparent;
}
.chip.unknown { background: var(--surface-2); color: var(--text-dim); border-style: dashed; border-color: var(--line); }
.chip button {
  border: 0; background: none; color: inherit; cursor: pointer;
  font-size: 14px; line-height: 1; padding: 0 2px; opacity: .6; font-family: inherit;
}
.chip button:hover { opacity: 1; }

.group { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.group summary {
  cursor: pointer; font-size: 14px; font-weight: 600; list-style: none;
  display: flex; align-items: center; gap: 6px;
}
.group summary::-webkit-details-marker { display: none; }
.group summary::before { content: "▸"; color: var(--text-dim); font-size: 11px; }
.group[open] summary::before { content: "▾"; }
.hint { font-weight: 400; font-size: 11px; color: var(--text-dim); }

.quick { margin-top: 10px; }
.quick h3 { margin: 12px 0 6px; font-size: 12px; color: var(--text-dim); font-weight: 600; }
.quick h3:first-child { margin-top: 4px; }
.pills { display: flex; flex-wrap: wrap; gap: 5px; }
.pill {
  padding: 4px 9px; border-radius: 999px; font-size: 12.5px; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text);
  font-family: inherit;
}
.pill:hover { border-color: var(--accent); color: var(--accent); }
.pill[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }

.staple-list { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 8px; }
.staple-list label { font-size: 12.5px; display: flex; align-items: center; gap: 4px; cursor: pointer; }

/* ── 결과 ─────────────────────────────── */
.toolbar {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 14px; box-shadow: var(--shadow);
  display: grid; gap: 10px;
}
.selects { display: flex; flex-wrap: wrap; gap: 10px; }
.selects label { font-size: 12px; color: var(--text-dim); display: flex; align-items: center; gap: 5px; }
.selects select {
  font-size: 13px; font-family: inherit; padding: 5px 8px; border-radius: 7px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
}
.checks { display: flex; flex-wrap: wrap; gap: 14px; }
.checks label { font-size: 13px; display: flex; align-items: center; gap: 5px; cursor: pointer; }

.summary { margin: 0 0 12px; font-size: 13.5px; color: var(--text-dim); }
.summary b { color: var(--text); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(248px, 1fr)); gap: 12px; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; cursor: pointer; text-align: left; font-family: inherit; color: var(--text);
  display: flex; flex-direction: column; gap: 8px; box-shadow: var(--shadow);
  transition: transform .12s ease, border-color .12s ease;
}
.card:hover { transform: translateY(-2px); border-color: var(--accent); }
.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.card h3 { margin: 0; font-size: 16px; letter-spacing: -.01em; }
.badge {
  flex: none; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  white-space: nowrap;
}
.badge.ready { background: var(--ready-soft); color: var(--ready); }
.badge.near { background: var(--near-soft); color: var(--near); }
.badge.far { background: var(--surface-2); color: var(--far); }

.meta-row { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; color: var(--text-dim); }
.bar { height: 5px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.card.is-ready .bar > i { background: var(--ready); }

.need { font-size: 12.5px; margin: 0; color: var(--text-dim); }
.need b { color: var(--near); font-weight: 600; }
.need.ok b { color: var(--ready); }

.empty {
  padding: 40px 16px; text-align: center; color: var(--text-dim); font-size: 14px;
  border: 1px dashed var(--line); border-radius: var(--radius);
}
.muted { color: var(--text-dim); }
.small { font-size: 12px; }

/* ── 상세 ─────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.45); }
.modal-box {
  position: relative; background: var(--surface); border-radius: 14px;
  width: min(620px, 100%); max-height: 88vh; overflow-y: auto; padding: 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.modal-box h2 { margin: 0 0 8px; font-size: 22px; padding-right: 32px; }
.modal-close {
  position: absolute; top: 14px; right: 14px; width: 30px; height: 30px;
  border: 0; border-radius: 8px; background: var(--surface-2); color: var(--text-dim);
  cursor: pointer; font-size: 13px; font-family: inherit;
}
.modal-close:hover { color: var(--accent); }
.modal-box h3 { margin: 22px 0 8px; font-size: 14px; }
.ing-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.ing-list li {
  font-size: 13px; padding: 3px 9px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-dim);
}
.ing-list li.have { background: var(--ready-soft); color: var(--ready); }
.ing-list li.miss { background: var(--near-soft); color: var(--near); font-weight: 600; }
.sub { font-size: 12px; color: var(--text-dim); margin: 10px 0 4px; }
.steps { margin: 0; padding-left: 22px; font-size: 14px; }
.steps li { margin-bottom: 8px; }
.tip {
  margin: 18px 0 0; padding: 11px 13px; border-radius: 10px; font-size: 13px;
  background: var(--accent-soft); color: var(--text); border-left: 3px solid var(--accent);
}

/* ── 대체 재료 · 버전 · 설치 ─────────────── */
.top-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.install-btn {
  border: 1px solid var(--accent); background: var(--accent); color: #fff;
  padding: 8px 14px; border-radius: 10px; font-size: 13px; font-weight: 600;
  cursor: pointer; font-family: inherit; white-space: nowrap;
}
.install-btn:hover { opacity: .9; }

.badge.swap { background: var(--swap-soft); color: var(--swap); }
.card.is-swap .bar > i { background: var(--swap); }
.need.swapped { color: var(--text-dim); }
.need.swapped b { color: var(--swap); font-weight: 600; }
.meta-row .ver {
  background: var(--accent-soft); color: var(--accent);
  padding: 1px 7px; border-radius: 999px; font-weight: 600; font-size: 11px;
}

.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 14px; }
.tab {
  padding: 5px 11px; border-radius: 999px; font-size: 13px; cursor: pointer;
  font-family: inherit; background: var(--surface-2); color: var(--text-dim);
  border: 1px solid var(--line);
}
.tab:hover { color: var(--accent); border-color: var(--accent); }
.tab.tab-ready { color: var(--ready); border-color: var(--ready-soft); }
.tab.tab-swap { color: var(--swap); border-color: var(--swap-soft); }
.tab.on { background: var(--accent); border-color: var(--accent); color: #fff; }

.ing-list li.swap { background: var(--swap-soft); color: var(--swap); font-weight: 600; }

.swap-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.swap-list li {
  font-size: 13px; padding: 9px 11px; border-radius: 9px;
  background: var(--surface-2); display: flex; flex-wrap: wrap; align-items: center; gap: 5px;
}
.swap-list li > b { color: var(--text); margin-right: 2px; }
.swap-list .opt {
  padding: 2px 8px; border-radius: 999px; font-size: 12px;
  background: var(--surface); color: var(--text-dim); border: 1px solid var(--line);
}
.swap-list .opt.have { background: var(--ready-soft); color: var(--ready); border-color: transparent; font-weight: 600; }
.swap-list .note { flex-basis: 100%; font-size: 12px; color: var(--text-dim); }

@media (max-width: 520px) {
  .topbar h1 { font-size: 18px; }
  .topbar p { display: none; }
  .cards { grid-template-columns: 1fr; }
}

/* ── 장보기 (쿠팡 파트너스) ──────────────── */
.shop { display: grid; gap: 8px; }
.shop-row { display: flex; align-items: flex-start; gap: 8px; }
.shop-label {
  flex: none; font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-dim); margin-top: 1px;
}
.shop-label.need { background: var(--near-soft); color: var(--near); }
.shop-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.shop-chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 13px; padding: 4px 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-dim); text-decoration: none;
  border: 1px solid var(--line);
}
.shop-chip.link { color: var(--text); }
.shop-chip.link:hover { border-color: var(--accent); color: var(--accent); }
.shop-chip .go { font-size: 11px; color: var(--accent); white-space: nowrap; }
.shop-chip.link:hover .go { color: inherit; }

.disclosure {
  font-size: 11.5px; color: var(--text-dim); line-height: 1.5; margin: 0;
}
.disclosure.in-modal {
  margin-top: 10px; padding: 8px 11px; border-radius: 8px;
  background: var(--surface-2);
}
.site-foot {
  max-width: 1180px; margin: 0 auto; padding: 0 16px 40px;
}
.foot-about {
  border-top: 1px solid var(--line); padding-top: 22px; margin-bottom: 18px;
  font-size: 13.5px; color: var(--text-dim); line-height: 1.7;
}
.foot-about h2 { font-size: 16px; color: var(--text); margin: 0 0 8px; }
.foot-about h3 { font-size: 13px; color: var(--text); margin: 18px 0 8px; }
.foot-about p { margin: 0 0 8px; max-width: 760px; }
.foot-about a { color: var(--accent); }
.foot-links {
  list-style: none; padding: 0; margin: 0 0 14px;
  display: flex; flex-wrap: wrap; gap: 7px;
}
.foot-links a {
  display: inline-block; padding: 4px 11px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line);
  color: var(--text-dim); text-decoration: none; font-size: 12.5px;
}
.foot-links a:hover { border-color: var(--accent); color: var(--accent); }
.recipe-index { list-style: none; padding: 0; margin: 0 0 8px; }
.recipe-index li {
  padding: 8px 0; border-bottom: 1px solid var(--line);
  display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; font-size: 14px;
}
.recipe-index a { text-decoration: none; color: var(--text); }
.recipe-index a:hover { color: var(--accent); }
.ri-meta { font-size: 12px; color: var(--text-dim); }
.ri-ing { font-size: 12.5px; color: var(--text-dim); flex-basis: 100%; }

/* ── 상품 카드 ───────────────────────────── */
.prod-list { display: grid; gap: 8px; margin-bottom: 10px; }
.prod {
  display: flex; gap: 11px; align-items: center; text-decoration: none;
  padding: 9px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text);
}
.prod:hover { border-color: var(--accent); }
.prod img, .prod-noimg {
  width: 56px; height: 56px; flex: none; border-radius: 8px;
  object-fit: cover; background: var(--surface);
}
.prod-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.prod-for {
  font-size: 11px; font-weight: 600; color: var(--accent);
}
.prod-name {
  font-size: 13px; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.prod-meta { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-dim); }
.prod-meta b { color: var(--text); font-size: 13.5px; }
.rocket {
  font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 4px;
  background: var(--swap-soft); color: var(--swap);
}
.asof { font-size: 11.5px; color: var(--text-dim); margin: 0 0 10px; }

/* ── 첫 방문 안내 ────────────────────────── */
.first-hint {
  margin: 10px 0 4px; padding: 11px 13px; border-radius: 10px;
  background: var(--accent-soft); border-left: 3px solid var(--accent);
}
.first-hint p { margin: 0 0 7px; font-size: 13px; line-height: 1.55; }
.first-hint b { color: var(--accent); }
.first-hint .link-btn { color: var(--accent); font-size: 12.5px; }
