/*
  50주 식탁
  색은 밥상 그림(table.svg)에서 가져왔다. 짙은 초록 식탁보, 밥알색, 달걀노른자.
  화려한 요소는 이번 주 머리 띠(식탁) 하나뿐이고, 나머지는 흰 바탕에 조용하게 둔다.
*/
:root {
  color-scheme: light;
  --bg: #f4f6f3;
  --surface: #ffffff;
  --ink: #1d2621;
  --muted: #56615a;
  --line: #d8ded7;
  --soft: #e7efe8;
  --table: #224638;
  --table-deep: #19372c;
  --rice: #f6edd2;
  --yolk: #e6a837;
  --focus: #b8741a;
  --radius-control: 8px;
  --radius-block: 14px;
  font-family: "Pretendard Variable", Pretendard, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans CJK KR", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.55;
  word-break: keep-all;
}
button, input, select { font: inherit; color: inherit; }
button, select { cursor: pointer; }
button:disabled { cursor: default; }
a { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[tabindex="-1"]:focus { outline: none; }

.wrap { width: min(1040px, calc(100% - 48px)); margin-inline: auto; }
.sr-only, .skip:not(:focus) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.skip:focus { position: fixed; top: 10px; left: 10px; z-index: 20; padding: 10px; background: var(--surface); }
.mobile-only { display: none; }

/* 머리글 */
.top-inner { display: flex; align-items: center; min-height: 68px; }
.brand { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -.04em; }
.brand a { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand img { width: 32px; height: 32px; }

/* 주차 고르기와 검색 */
.explorer { margin-top: 8px; scroll-margin-top: 12px; }
.week-nav {
  display: grid;
  grid-template-columns: minmax(100px, 132px) minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.week-nav label:not(.sr-only) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.week-nav select {
  width: 100%;
  min-height: 44px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface);
  font-size: 15px;
  font-weight: 700;
}
.week-nav nav { display: flex; flex-wrap: wrap; gap: 4px; }
.week-nav nav button {
  min-height: 44px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--radius-control);
  background: none;
  font-size: 15px;
}
.week-nav nav button:hover { background: var(--soft); }
.week-nav nav button[aria-current] { background: var(--table); color: var(--rice); font-weight: 800; }

.tool-row { display: flex; justify-content: flex-end; margin-bottom: 16px; }
.search {
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(100%, 390px);
  min-height: 46px;
  padding: 0 4px 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface);
}
.search:focus-within { border-color: var(--table); box-shadow: 0 0 0 2px var(--soft); }
.search svg { flex: none; width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 1.8; }
.search input { width: 100%; min-width: 0; padding: 11px 0; border: 0; outline: none; background: none; font-size: 16px; }
.search input::-webkit-search-cancel-button { display: none; }
.search button {
  flex: 0 0 44px;
  height: 44px;
  border: 0;
  border-radius: var(--radius-control);
  background: none;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
}

/* 이번 주 머리 띠: 식탁보 위에 차린 밥상 */
.browser { display: grid; gap: 16px; }
.detail { min-width: 0; }
.detail-head {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
  min-height: 210px;
  padding: 28px 32px;
  padding-right: min(46%, 440px);
  border-radius: var(--radius-block);
  background: var(--table) url("table.svg") no-repeat right -24px center / auto 122%;
  color: var(--rice);
}
.detail-head :focus-visible { outline-color: var(--yolk); }
.section-kicker { margin: 0; min-height: 22px; font-size: 15px; font-weight: 700; color: var(--yolk); }
.detail-head h2 { margin: 2px 0 0; font-size: clamp(34px, 5vw, 48px); line-height: 1.12; letter-spacing: -.05em; }
.week-fallback { margin: 8px 0 0; font-size: 14px; color: var(--rice); opacity: .85; }
.link-button {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 4px;
}
.detail-actions { display: flex; align-items: center; gap: 8px; }
.pdf {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  margin-right: 8px;
  font-size: 15px;
  font-weight: 700;
  text-underline-offset: 4px;
  white-space: nowrap;
}
.arrows { display: flex; gap: 6px; }
.arrows button {
  width: 44px;
  height: 44px;
  border: 1px solid rgba(246, 237, 210, .4);
  border-radius: var(--radius-control);
  background: transparent;
  font-size: 18px;
}
.arrows button:hover:not(:disabled) { background: rgba(246, 237, 210, .12); }
.arrows button:disabled { opacity: .3; }

/* 저녁 식단 / 장보기 탭 */
.tabs { display: flex; gap: 24px; margin-top: 8px; border-bottom: 1px solid var(--line); }
.tabs button {
  min-height: 48px;
  padding: 0 2px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: none;
  color: var(--muted);
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
}
.tabs button:hover { color: var(--ink); }
.tabs button[aria-current] { border-bottom-color: var(--table); color: var(--table); font-weight: 800; }
#panel { padding-top: 18px; }

/* 월~금 저녁 */
.weekday-recipes {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface);
}
.weekday-recipes > * + * { border-left: 1px solid var(--line); }
.recipe-choice, .missing-recipe {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 0;
  background: transparent;
  text-align: left;
  text-decoration: none;
}
.recipe-choice:hover, .missing-recipe:hover { background: var(--soft); }
.recipe-choice[aria-expanded="true"] { background: var(--soft); color: var(--table); box-shadow: inset 0 -3px var(--table); }
.recipe-choice-title, .missing-recipe strong { min-width: 0; font-size: 17px; font-weight: 700; line-height: 1.45; overflow-wrap: anywhere; }
.weekday-choice, .weekday-recipes .missing-recipe {
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 6px;
  min-height: 120px;
  padding: 14px;
}
.day-label { font-size: 14px; font-weight: 700; color: var(--muted); white-space: nowrap; }
.missing-note { margin-top: auto; font-size: 13px; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }

/* 오늘: 위쪽 노른자색 띠와 "오늘" 표시 */
.today-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--table);
  color: var(--rice);
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
  line-height: 1.6;
  vertical-align: 1px;
}
.weekday-recipes .is-today { box-shadow: inset 0 4px var(--yolk); }
.weekday-recipes .is-today[aria-expanded="true"] { box-shadow: inset 0 4px var(--yolk), inset 0 -3px var(--table); }
.weekday-recipes .is-today .day-label { color: var(--ink); }
.weekend.is-today b { color: var(--ink); }

.weekend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 0; padding: 12px 2px; border-bottom: 1px solid var(--line); font-size: 15px; }
.weekend b { color: var(--muted); }

/* 반찬과 그 밖의 요리 */
.week-recipes { margin-top: 24px; }
.week-recipes h4 { display: flex; align-items: baseline; gap: 8px; margin: 0 0 8px; font-size: 18px; }
.week-recipes h4 small { font-size: 14px; font-weight: 600; color: var(--muted); }
.side-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; border-top: 1px solid var(--line); }
.side-list .recipe-choice { min-height: 50px; padding-inline: 8px; border-bottom: 1px solid var(--line); }
.side-list .recipe-choice[aria-expanded="true"] { box-shadow: inset 3px 0 var(--table); }
.side-list .tag { display: none; }

/* 조리법 */
.recipe-panel { min-width: 0; background: var(--surface); }
.recipe-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--line);
}
.recipe-panel-head h3 { margin: 0; font-size: 28px; line-height: 1.3; letter-spacing: -.04em; overflow-wrap: anywhere; }
.recipe-panel-meta { margin: 4px 0 0; font-size: 14px; color: var(--muted); }
.recipe-close {
  flex: none;
  min-width: 44px;
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface);
  font-size: 22px;
}
.recipe-close:hover { background: var(--soft); }
.recipe-back { display: none; }
.recipe-body { padding: 18px 22px 24px; }
.recipe-body dl { margin: 0; }
.recipe-body dl div { display: grid; gap: 4px; padding-bottom: 12px; }
.recipe-body dl div + div { padding-top: 12px; border-top: 1px solid var(--line); }
.recipe-body dt { font-size: 15px; font-weight: 700; color: var(--muted); }
.recipe-body dd { margin: 0; font-size: 17px; line-height: 1.72; overflow-wrap: anywhere; }
.method { padding-top: 14px; border-top: 1px solid var(--line); }
.method h4 { margin: 0 0 10px; font-size: 16px; color: var(--table); }
.method-intro { margin: 0 0 10px; font-size: 15px; color: var(--muted); }
.method ol { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.method li { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 8px; font-size: 17px; line-height: 1.72; overflow-wrap: anywhere; }
.step-number { padding-top: 2px; font-size: 15px; font-weight: 800; color: var(--table); }
.method-note { color: var(--muted); }
.method-note .step-number { color: var(--muted); }
.method-hint { margin: -4px 0 10px; font-size: 14px; color: var(--muted); }
.method .method-step { display: block; }
.step {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 8px;
  width: 100%;
  min-height: 44px;
  padding: 4px 6px 4px 0;
  border: 0;
  border-radius: var(--radius-control);
  background: none;
  font-size: 17px;
  line-height: 1.72;
  text-align: left;
  overflow-wrap: anywhere;
}
.step:hover { background: var(--soft); }
.step[aria-pressed="true"] { color: var(--muted); }
.step[aria-pressed="true"] > span:last-child { text-decoration: line-through; text-decoration-thickness: 1px; }
.step[aria-pressed="true"] .step-number { color: var(--muted); }
.wake-note { margin: 4px 0 0; font-size: 13px; font-weight: 600; color: var(--table); }

.recipe-others { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--line); }
.recipe-others h4 { margin: 0 0 8px; font-size: 16px; }
.other-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; }
.other-recipe {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  padding: 6px 6px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  font-size: 16px;
  font-weight: 700;
  text-align: left;
}
.other-recipe:hover { background: var(--soft); }

.recipe-source {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-top: 8px;
  color: var(--table);
  font-size: 15px;
  text-underline-offset: 4px;
}

/* 장보기 */
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; }
.panel-head h4, .subhead { margin: 0; font-size: 18px; letter-spacing: -.02em; }
.subhead { margin: 24px 0 8px; }
.muted { font-size: 14px; color: var(--muted); }
.plain-button {
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface);
  font-size: 14px;
  font-weight: 700;
}
.plain-button:hover:not(:disabled) { background: var(--soft); }
.plain-button:disabled { opacity: .45; }
.check-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 20px; border-top: 1px solid var(--line); }
.check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.check input { flex: none; width: 18px; height: 18px; accent-color: var(--table); }
.check:has(input:checked) { background: var(--soft); }
.check:has(input:checked) strong { color: var(--muted); text-decoration: line-through; }
.shopping-item { display: grid; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.shopping-item strong { font-size: 16px; }
.shopping-item small { font-size: 14px; color: var(--muted); }
.note { margin: 12px 0 0; font-size: 14px; color: var(--muted); }
.shop-count { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin: 2px 0 0; font-size: 26px; font-weight: 800; letter-spacing: -.03em; }
.shop-count small { font-size: 14px; font-weight: 500; letter-spacing: 0; color: var(--muted); }
.done-head { color: var(--muted); }
.undo {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  margin: 0 0 14px;
  padding: 8px 14px;
  border-radius: var(--radius-control);
  background: var(--soft);
  font-size: 15px;
}
.undo .link-button { min-height: 36px; color: var(--table); }

/* 장보기 탭에서는 머리 띠를 얇게: 목록이 빨리 보이게 */
.detail[data-view="shopping"] .detail-head {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px 16px;
  min-height: 0;
  padding-block: 18px;
}
.detail[data-view="shopping"] .detail-head h2 { font-size: 32px; }

/* 검색 결과 */
.results-card h3 { margin: 0 0 10px; font-size: 20px; }
.result-list { display: grid; border-top: 1px solid var(--line); }
.result {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 56px;
  padding: 10px 8px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  text-align: left;
}
.result:hover { background: var(--soft); }
.result strong { display: block; font-size: 16px; }
.result small { display: block; font-size: 14px; color: var(--muted); }
.tag {
  flex: none;
  min-width: 3.5em;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}
.more { margin-top: 10px; }
.result-group + .result-group { margin-top: 24px; }
.result-group h4 { display: flex; align-items: baseline; gap: 8px; margin: 0 0 6px; font-size: 17px; }
.result-group h4 small { font-size: 14px; font-weight: 600; color: var(--muted); }

/* 바닥글 */
.footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 24px;
  margin-top: 40px;
  margin-bottom: 28px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 14px;
  color: var(--muted);
}
.footer a { text-underline-offset: 4px; }
.footer a:hover { color: var(--ink); }

/* 넓은 화면: 주차와 검색을 한 줄에, 조리법은 고른 칸 바로 아래에 펼친다 */
@media (min-width: 1120px) {
  .browse-tools { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 16px; }
  .browse-tools .week-nav { flex: 1; margin: 0; }
  .browse-tools .tool-row { width: 320px; margin: 0; }
  .recipe-panel { margin-block: 14px; border: 1px solid var(--line); border-radius: var(--radius-control); }
  .recipe-body { max-width: 760px; }
}

/* 좁은 화면: 조리법은 화면 전체를 덮는 읽기 화면으로 연다 */
@media (width < 1120px) {
  .recipe-panel {
    position: fixed;
    inset: 0;
    z-index: 10;
    display: flex;
    flex-direction: column;
    overflow: auto;
    overscroll-behavior: contain;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .search { width: 100%; }
  body.reading-recipe { overflow: hidden; }
  .recipe-panel-head { display: contents; }
  .recipe-heading, .recipe-body { flex: none; }
  .recipe-heading { padding: 12px 18px 0; }
  .recipe-close {
    order: -1;
    align-self: flex-start;
    position: sticky;
    top: max(8px, env(safe-area-inset-top));
    z-index: 1;
    margin: 8px 18px 0;
    padding-inline: 12px;
    font-size: 15px;
    font-weight: 700;
  }
  .recipe-back { display: inline; }
  .recipe-close-icon { display: none; }
  .recipe-body { padding: 16px 18px 24px; }
}

@media (max-width: 850px) {
  .check-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .weekday-choice, .weekday-recipes .missing-recipe { padding-inline: 10px; }
}

@media (max-width: 620px) {
  .wrap { width: calc(100% - 32px); }
  .top-inner { min-height: 58px; }
  .brand { font-size: 20px; }
  .brand img { width: 28px; height: 28px; }
  .explorer { margin-top: 4px; }
  .week-nav { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; margin-bottom: 8px; }
  .week-nav nav { display: none; }
  .mobile-only { display: block; }
  .search { width: 100%; }
  .tool-row { margin-bottom: 12px; }

  .detail-head {
    gap: 14px;
    min-height: 0;
    padding: 20px 18px;
    background:
      linear-gradient(90deg, var(--table) 50%, rgba(34, 70, 56, 0) 85%),
      var(--table) url("table.svg") no-repeat right -150px center / auto 115%;
  }
  .detail-head h2 { font-size: 34px; }
  .pdf { margin-right: 4px; }

  .weekday-recipes { grid-template-columns: minmax(0, 1fr); }
  .weekday-recipes > * + * { border-left: 0; border-top: 1px solid var(--line); }
  .weekday-choice, .weekday-recipes .missing-recipe {
    display: grid;
    grid-template-columns: 3.2em minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    min-height: 58px;
  }
  .missing-note { margin: 0; max-width: 9ch; }
  .day-label { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
  .today-badge { margin-left: 0; }
  .weekday-recipes .is-today { box-shadow: inset 4px 0 var(--yolk); }
  .weekday-recipes .is-today[aria-expanded="true"] { box-shadow: inset 4px 0 var(--yolk), inset 0 -3px var(--table); }
  .side-list, .other-list { grid-template-columns: minmax(0, 1fr); }
  .check-grid { grid-template-columns: minmax(0, 1fr); }
  .detail[data-view="shopping"] .detail-head { padding-block: 14px; }
  .detail[data-view="shopping"] .detail-head h2 { font-size: 26px; }
}
