/* ==========================================================
   한주밥상 사이트 공통 CSS (04 디자인 → 05 개발)
   - 분위기 A: <html data-theme="warm">  (따뜻한 밥상)
   - 분위기 B: <html data-theme="clean"> (깨끗한 주방)
   - 글꼴: Pretendard(무료, OFL) → 못 불러오면 Noto Sans KR(무료, OFL)
   ========================================================== */

/* ---------- 1. 색·모양 토큰 ---------- */
:root, [data-theme="warm"] {
  --bg: #FFF8EF;          /* 바탕: 크림색 */
  --surface: #FFFFFF;     /* 카드 */
  --surface-2: #FBEEDD;   /* 연한 강조 바탕 */
  --ink: #2E2420;         /* 본문 글씨 */
  --ink-2: #6B5D55;       /* 보조 글씨 */
  --line: #EEDFCC;        /* 선 */
  --primary: #D9622B;     /* 주 색: 당근 주황 */
  --primary-ink: #FFFFFF;
  --primary-soft: #FCE3D3;
  --accent: #6E8B4E;      /* 보조 색: 쑥 초록 */
  --accent-soft: #E6EEDB;
  --warn: #B3261E;        /* 주의 */
  --warn-soft: #FDECEA;
  /* 분류 색 (밥·국·반찬·간식) */
  --c-rice: #E8A33D;  --c-rice-soft: #FDF0D8;
  --c-soup: #D9622B;  --c-soup-soft: #FCE3D3;
  --c-side: #6E8B4E;  --c-side-soft: #E6EEDB;
  --c-snack: #C2618A; --c-snack-soft: #F8E1EA;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 2px 10px rgba(120, 72, 30, .08);
  --font-head: "Gowun Dodum", "Pretendard Variable", Pretendard, "Noto Sans KR", sans-serif;
  --head-weight: 400;
}
[data-theme="clean"] {
  --bg: #F6F8F6;
  --surface: #FFFFFF;
  --surface-2: #EDF3EF;
  --ink: #1C2421;
  --ink-2: #5A6661;
  --line: #DCE5E0;
  --primary: #2F7A55;     /* 주 색: 채소 초록 */
  --primary-ink: #FFFFFF;
  --primary-soft: #DCEFE4;
  --accent: #E58A2E;      /* 보조 색: 단호박 */
  --accent-soft: #FCEBD8;
  --warn: #B3261E;
  --warn-soft: #FDECEA;
  --c-rice: #C98A1B;  --c-rice-soft: #FBF1DC;
  --c-soup: #2F6FA8;  --c-soup-soft: #DFEBF6;
  --c-side: #2F7A55;  --c-side-soft: #DCEFE4;
  --c-snack: #B4527A; --c-snack-soft: #F6E0E9;
  --radius: 10px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(20, 40, 30, .06), 0 0 0 1px var(--line);
  --font-head: "Pretendard Variable", Pretendard, "Noto Sans KR", sans-serif;
  --head-weight: 800;
}

/* ---------- 2. 기본 ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Pretendard Variable", Pretendard, "Noto Sans KR", -apple-system, sans-serif;
  font-size: 17px;            /* 본문 최소 17px: '글씨 크게' */
  line-height: 1.65;
  word-break: keep-all;       /* 한국어 단어 중간에서 줄바꿈 안 함 */
  overflow-wrap: anywhere;
}
a { color: inherit; }
img { max-width: 100%; display: block; }
.wrap { max-width: 640px; margin: 0 auto; padding: 0 16px 96px; }
h1, h2, h3 { font-family: var(--font-head); font-weight: var(--head-weight); line-height: 1.35; margin: 0; }
h1 { font-size: 26px; }
h2 { font-size: 21px; margin: 32px 0 12px; }
h3 { font-size: 18px; }
p { margin: 0 0 12px; }
.muted { color: var(--ink-2); }
.small { font-size: 14px; }

/* ---------- 3. 상단 바 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar .in { max-width: 640px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 10px; }
.logo { font-family: var(--font-head); font-weight: var(--head-weight); font-size: 22px; text-decoration: none; display: flex; align-items: center; gap: 8px; }
.logo .mark { width: 30px; height: 30px; flex: none; }
.topbar .back { text-decoration: none; font-size: 15px; color: var(--ink-2); padding: 8px 0; }
.topbar .spacer { flex: 1; }

/* ---------- 4. 아래 탭 (엄지로 누르기) ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar .in { max-width: 640px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); }
.tabbar a {
  min-height: 60px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-decoration: none; font-size: 13px; color: var(--ink-2); gap: 2px;
}
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a[aria-current="page"] { color: var(--primary); font-weight: 700; }

/* ---------- 5. 버튼 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 22px; border-radius: var(--radius-sm);
  font: inherit; font-size: 17px; font-weight: 700; text-decoration: none;
  border: 0; cursor: pointer;
}
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-ghost { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn-block { width: 100%; }
.btn-sm { min-height: 40px; font-size: 15px; padding: 0 14px; }

/* ---------- 6. 카드·칩·꼬리표 ---------- */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px;
  border-radius: 999px; background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--line);
  text-decoration: none; font-size: 16px;
}
.tag { display: inline-block; font-size: 13px; font-weight: 700; padding: 2px 9px; border-radius: 999px; }
.tag.rice  { background: var(--c-rice-soft);  color: var(--c-rice); }
.tag.soup  { background: var(--c-soup-soft);  color: var(--c-soup); }
.tag.side  { background: var(--c-side-soft);  color: var(--c-side); }
.tag.snack { background: var(--c-snack-soft); color: var(--c-snack); }
.tag.warn  { background: var(--warn-soft);    color: var(--warn); }

/* ---------- 7. 홈 ---------- */
.hero { padding: 24px 0 8px; }
.hero .eyebrow { color: var(--primary); font-weight: 700; font-size: 15px; margin-bottom: 6px; }
.hero h1 { font-size: 30px; margin-bottom: 10px; }
.hero p { color: var(--ink-2); }
.today { margin-top: 16px; }
.today .row { display: grid; grid-template-columns: 52px 1fr; gap: 6px 10px; padding: 10px 0; border-top: 1px dashed var(--line); }
.today .row:first-of-type { border-top: 0; }
.today .meal { font-size: 14px; font-weight: 700; color: var(--ink-2); padding-top: 2px; }
.cat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cat {
  display: flex; flex-direction: column; justify-content: space-between; min-height: 92px;
  padding: 14px; border-radius: var(--radius); text-decoration: none;
}
.cat b { font-size: 18px; font-family: var(--font-head); font-weight: var(--head-weight); }
.cat span { font-size: 14px; opacity: .8; }
.cat.rice { background: var(--c-rice-soft); } .cat.soup { background: var(--c-soup-soft); }
.cat.side { background: var(--c-side-soft); } .cat.snack { background: var(--c-snack-soft); }
.rlist { display: grid; gap: 10px; }
.ritem { display: grid; grid-template-columns: 64px 1fr; gap: 14px; align-items: center; text-decoration: none; }
.ritem .thumb { width: 64px; height: 64px; border-radius: var(--radius-sm); display: grid; place-items: center; }
.ritem b { display: block; font-size: 17px; }
.ritem small { color: var(--ink-2); font-size: 14px; }
.promise { display: grid; gap: 10px; }
.promise div { display: grid; grid-template-columns: 36px 1fr; gap: 10px; align-items: start; }
.promise .num { width: 36px; height: 36px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-weight: 800; }

/* ---------- 8. 주간 식단표 (캡처 한 장에 일주일) ---------- */
.week-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; padding: 12px 0 10px; }
.week-head h1 { font-size: 24px; }
.week-head .sub { font-size: 14px; color: var(--ink-2); }
.plan { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.plan th, .plan td { padding: 6px 4px; vertical-align: top; border-bottom: 1px solid var(--line); border-left: 1px solid var(--line); }
.plan th:first-child, .plan td:first-child { border-left: 0; }
.plan tr:last-child td { border-bottom: 0; }
.plan thead th { background: var(--surface-2); font-size: 13px; font-weight: 700; color: var(--ink-2); text-align: center; padding: 8px 2px; }
.plan .day { width: 38px; text-align: center; font-weight: 800; font-size: 15px; background: var(--surface-2); vertical-align: middle; }
.plan .day small { display: block; font-weight: 400; font-size: 11px; color: var(--ink-2); }
.plan .wkend td.day { color: var(--primary); }
.plan td a { display: block; text-decoration: none; font-size: 14px; line-height: 1.32; font-weight: 600; }
.plan td a + a { margin-top: 3px; font-weight: 400; color: var(--ink-2); font-size: 12.5px; }
.plan td a::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 3px; vertical-align: 1px; }
.plan a.rice::before { background: var(--c-rice); } .plan a.soup::before { background: var(--c-soup); }
.plan a.side::before { background: var(--c-side); } .plan a.snack::before { background: var(--c-snack); }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 13px; color: var(--ink-2); margin: 10px 2px 0; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 4px; }
.plan-foot { display: flex; justify-content: space-between; font-size: 14px; color: var(--ink-2); margin: 8px 2px 0; }
.prep { counter-reset: s; list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.prep li { counter-increment: s; display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center; background: var(--surface); border-radius: var(--radius-sm); padding: 12px; box-shadow: var(--shadow); }
.prep li::before { content: counter(s); width: 30px; height: 30px; border-radius: 50%; background: var(--primary); color: var(--primary-ink); display: grid; place-items: center; font-weight: 800; font-size: 15px; }
.prep .min { font-size: 14px; color: var(--ink-2); white-space: nowrap; }
.weeknav { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0; scrollbar-width: none; }
.weeknav a { flex: none; }
.weeknav a[aria-current="page"] { background: var(--primary); color: var(--primary-ink); box-shadow: none; }

/* ---------- 9. 레시피 상세 ---------- */
.rhead { padding: 16px 0 6px; }
.rhead .tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.photo { aspect-ratio: 4 / 3; border-radius: var(--radius); background: var(--surface-2); display: grid; place-items: center; margin: 14px 0; overflow: hidden; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0; }
.facts div { background: var(--surface); border-radius: var(--radius-sm); box-shadow: var(--shadow); padding: 10px 6px; text-align: center; }
.facts b { display: block; font-size: 19px; }
.facts span { font-size: 13px; color: var(--ink-2); }
.ing { list-style: none; padding: 0; margin: 0; }
.ing li { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px dashed var(--line); }
.ing li span:last-child { color: var(--ink-2); text-align: right; }
.steps { list-style: none; padding: 0; margin: 0; counter-reset: st; }
.steps li { counter-increment: st; position: relative; padding: 0 0 18px 46px; }
.steps li::before { content: counter(st); position: absolute; left: 0; top: 0; width: 32px; height: 32px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-weight: 800; display: grid; place-items: center; }
.box { border-radius: var(--radius); padding: 16px; margin: 12px 0; }
.box h3 { margin-bottom: 6px; display: flex; gap: 8px; align-items: center; }
.box.warn { background: var(--warn-soft); }
.box.warn h3 { color: var(--warn); }
.box.family { background: var(--accent-soft); }
.box.keep { background: var(--surface); box-shadow: var(--shadow); }
.notice { font-size: 13px; color: var(--ink-2); border-top: 1px solid var(--line); margin-top: 28px; padding-top: 14px; }

/* ---------- 10. 장보기 목록 ---------- */
.shop-sum { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.shop-sum b { font-size: 24px; color: var(--primary); }
.shop-group { margin-top: 14px; }
.shop-group h3 { font-size: 15px; color: var(--ink-2); margin: 0 0 6px 4px; font-family: inherit; font-weight: 700; }
.shop { list-style: none; padding: 0; margin: 0; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.shop li { border-bottom: 1px solid var(--line); }
.shop li:last-child { border-bottom: 0; }
.shop label { display: grid; grid-template-columns: 28px 1fr auto; gap: 12px; align-items: center; padding: 12px 14px; min-height: 56px; cursor: pointer; }
.shop input { width: 24px; height: 24px; accent-color: var(--primary); margin: 0; }
.shop .name { font-weight: 600; }
.shop .name small { display: block; font-weight: 400; font-size: 13px; color: var(--ink-2); }
.shop .price { font-size: 15px; color: var(--ink-2); white-space: nowrap; }
.shop input:checked ~ .name { text-decoration: line-through; color: var(--ink-2); }
.shop .have .name::after { content: " · 집에 있을 수도"; font-size: 13px; color: var(--accent); font-weight: 400; }
.buylink { font-size: 13px; color: var(--primary); text-decoration: none; }

/* ---------- 11. 인쇄 (식단표·장보기) ---------- */
@media print {
  .topbar, .tabbar, .no-print, .weeknav { display: none !important; }
  body { background: #fff; font-size: 12pt; }
  .wrap { max-width: none; padding: 0; }
  .plan { box-shadow: none; border: 1px solid #999; }
  .plan td a { font-size: 10.5pt; }
  .card, .shop, .prep li { box-shadow: none; border: 1px solid #ccc; }
}

/* ---------- 12. 넓은 화면 ---------- */
@media (min-width: 560px) {
  .plan td a { font-size: 15px; }
  .plan td a + a { font-size: 13.5px; }
  .plan .day { width: 52px; }
}

/* ---------- 13. 사진 있음 / 없음 ----------
   사진 있음: <figure class="photo has-photo"><img …><figcaption class="made-badge">…</figcaption></figure>
   사진 없음: <figure class="photo no-photo"><svg class="illus">…분류별 그림…</svg><figcaption>…</figcaption></figure>
   어느 쪽이든 칸 크기(4:3)가 같아서 화면이 흔들리지 않음. */
.photo { position: relative; margin: 14px 0; padding: 0; display: block; }
.photo img, .photo .illus { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo.no-photo figcaption {
  position: absolute; left: 12px; bottom: 12px; font-size: 13px; color: var(--ink-2);
  background: color-mix(in srgb, var(--surface) 85%, transparent); padding: 4px 10px; border-radius: 999px;
}
.made-badge {
  position: absolute; left: 12px; bottom: 12px; display: inline-flex; align-items: center; gap: 6px;
  font-size: 14px; font-weight: 700; color: #fff; background: rgba(0,0,0,.55); padding: 6px 12px; border-radius: 999px;
}
.photo-note { background: var(--surface); border-left: 4px solid var(--primary); border-radius: var(--radius-sm); padding: 12px 14px; margin: 0 0 12px; font-size: 16px; }
.photo-note span { display: block; font-size: 13px; color: var(--ink-2); margin-top: 2px; }
.ritem .thumb { overflow: hidden; }
.ritem .thumb .illus { width: 100%; height: 100%; }

/* ---------- 05 개발 추가 ---------- */
/* 짧은이름(7~8글자)이 좁은 칸에서도 일주일이 한 화면에 들어오게 */
.plan th, .plan td { padding: 5px 3px; }
.plan td a { font-size: 13px; line-height: 1.28; word-break: keep-all; overflow-wrap: anywhere; }
.plan td a + a { font-size: 11.5px; margin-top: 2px; }
.plan td a::before { width: 6px; height: 6px; margin-right: 2px; }
@media (min-width: 560px) { .plan td a { font-size: 15px; } .plan td a + a { font-size: 13.5px; } .plan th, .plan td { padding: 6px 4px; } }
.plan td .plus { display: block; margin-top: 2px; font-size: 11px; color: var(--ink-2); }
.today-title { display: flex; justify-content: space-between; align-items: baseline; }
.plain-list { padding-left: 20px; margin: 0 0 12px; } .plain-list li { margin: 6px 0; }
.week-card { display: grid; gap: 2px; text-decoration: none; } .week-card b { font-size: 19px; font-family: var(--font-head); font-weight: var(--head-weight); }
.week-card small { color: var(--ink-2); font-size: 14px; }
.ritem .thumb img { width: 100%; height: 100%; object-fit: cover; }
.more-photos { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 0 12px; } .more-photos .photo { margin: 0; }
.shop .buylink { display: block; padding: 0 14px 10px 54px; margin-top: -6px; }
.buy ul { list-style: none; padding: 0; margin: 6px 0 0; } .buy li { padding: 6px 0; }
.foot-links { font-size: 13px; color: var(--ink-2); } .foot-links a { color: var(--ink-2); }
.steps.safety li { padding-bottom: 16px; }
.step-photo { position: relative; margin: 10px 0 0; border-radius: var(--radius-sm); overflow: hidden; aspect-ratio: 4 / 3; background: var(--surface-2); max-width: 480px; }
.step-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.step-photo figcaption { position: absolute; right: 6px; bottom: 6px; font-size: 11px; line-height: 1; padding: 4px 6px; border-radius: 6px; background: rgba(0,0,0,.55); color: #fff; }
[hidden] { display: none !important; }
.coll-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.coll { display: grid; gap: 4px; text-decoration: none; padding: 14px; }
.coll b { font-size: 17px; font-family: var(--font-head); font-weight: var(--head-weight); color: var(--ink); }
.coll small { color: var(--ink-2); font-size: 13.5px; line-height: 1.35; }
.chip.pick { cursor: pointer; }
.chip.pick.on { background: var(--primary); color: #fff; box-shadow: none; }
.chip.pick.on .muted { color: rgba(255,255,255,.85); }
.pick-result { margin-top: 14px; }
.pick-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
.disclose { font-size: 13px; color: var(--ink-2); margin: 8px 2px 0; }
@media print {
  .foot-links, .notice { font-size: 9pt; }
  .foot-links, .related, .more-photos, .buy, .step-photo { display: none !important; }
  .photo { aspect-ratio: auto; height: 6cm; width: 8cm; margin: 6px 0; }
  .photo .made-badge, .photo.no-photo figcaption { display: none; }
  .steps li { padding-bottom: 6px; }
  .box { padding: 8px 12px; margin: 6px 0; }
  .prep li, .box, .shop li, .plan tr { break-inside: avoid; page-break-inside: avoid; }
  h2 { break-after: avoid; margin: 14px 0 6px; }
}
