/* 기준: ../DESIGN.md
   휴대폰 앱처럼: 위 이름 줄, 가운데 한 화면, 아래 탭 3개(오늘 · 이번 주 · 장보기).
   넓은 화면에서도 같은 구성을 가운데 560px 열로. */
:root {
  --ground: #ffffff;
  --surface: #f4f4f2;
  --raised: #ffffff;
  --border: #e7e6e2;
  --text: #1c1c1a;
  --muted: #64645f;
  --accent: #1b6e66;
  --accent-tint: #e2efec;
  --active: #ebebe8;
  --faint: #b8b7b1;
  --hand: "Gaegu", "Pretendard Variable", sans-serif;
  --sans: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", sans-serif;
  --tabs-h: 64px;
  --top-h: 52px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ground: #121212; --surface: #1d1d1c; --raised: #252524; --border: #313130;
    --text: #f3f2ee; --muted: #b3b3ae; --accent: #6cc2b6; --accent-tint: #1c302d; --active: #2b2b2a; --faint: #5a5a56;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--ground); color: var(--text); font: 400 16px/1.55 var(--sans); letter-spacing: -0.01em; -webkit-tap-highlight-color: transparent; }
h1, h2, p, dl, dd, ol, ul { margin: 0; }
ol, ul { padding: 0; list-style: none; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.hand { font-family: var(--hand); font-weight: 700; letter-spacing: 0; }

/* 위 이름 줄 */
.top { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 10px; max-width: 560px; margin: 0 auto; height: calc(var(--top-h) + env(safe-area-inset-top)); padding: 0 20px; padding-top: env(safe-area-inset-top); background: var(--ground); }
.mark-btn { flex: none; padding: 0; border: 0; border-radius: 50%; background: none; cursor: pointer; line-height: 0; }
.mark { flex: none; width: 32px; height: 32px; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 2px var(--ground), 0 0 0 3.5px var(--accent); }
.top-name { font: 700 22px/1 var(--hand); }
.top-range { margin-left: auto; color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }

.views { max-width: 560px; margin: 0 auto; padding: 8px 20px calc(var(--tabs-h) + 32px + env(safe-area-inset-bottom)); }
.view h2 { font-size: 26px; line-height: 1.2; margin: 36px 0 12px; }
.view h2:first-child { margin-top: 12px; }
.sub { color: var(--muted); font-size: 14px; margin: -6px 0 12px; }

/* 오늘 */
.when { margin-top: 20px; color: var(--accent); font-size: 15px; font-weight: 600; }
#view-today h1 { margin-top: 4px; font-size: 40px; line-height: 1.15; word-break: keep-all; text-wrap: balance; }
.kid { display: flex; gap: 12px; margin-top: 18px; font-size: 16px; word-break: keep-all; }
.kid-label { flex: none; padding: 1px 10px; border-radius: 999px; background: var(--accent-tint); color: var(--accent); font-size: 14px; font-weight: 700; line-height: 1.6; height: fit-content; }
.recipe-btn { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 56px; margin-top: 20px; padding: 0 18px; border: 0; border-radius: 18px; background: var(--text); color: var(--ground); font-size: 17px; font-weight: 600; cursor: pointer; touch-action: manipulation; transition: opacity .15s; }
.recipe-btn:hover { opacity: .88; }
.recipe-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.rb-time { margin-left: auto; font-size: 15px; font-weight: 500; opacity: .75; }
.rb-time::after { content: "  ›"; }
.next { margin-top: 28px; padding: 16px 18px; border-radius: 18px; background: var(--surface); }
.next-when { color: var(--muted); font-size: 14px; }
.next-menu { margin-top: 2px; font-size: 17px; font-weight: 500; word-break: keep-all; }
.shop-link { display: flex; align-items: center; gap: 12px; width: 100%; margin-top: 12px; padding: 16px 18px; border: 0; border-radius: 18px; background: var(--surface); text-align: left; cursor: pointer; touch-action: manipulation; transition: background-color .15s; }
.shop-link:hover { background: var(--active); }
.sl-title { display: block; font-size: 17px; font-weight: 600; }
.sl-sub { display: block; color: var(--muted); font-size: 14px; }
.sl-total { margin-left: auto; font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sl-total::after { content: "›"; margin-left: 10px; color: var(--muted); font-weight: 400; }

/* 이번 주 */
.days { display: grid; }
.days li { border-top: 1px solid var(--border); }
.days li:first-child { border-top: 0; }
.days li.past { opacity: .5; }
.days li.is-today { margin: 0 -12px; border-radius: 14px; border-top-color: transparent; background: var(--accent-tint); }
.days li.is-today .day { padding-left: 12px; padding-right: 12px; }
.days li.is-today + li { border-top-color: transparent; }
.day { display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: start; width: 100%; padding: 14px 0; border: 0; background: none; text-align: left; cursor: pointer; touch-action: manipulation; }
.day:hover .d-menu { text-decoration: underline; text-underline-offset: 3px; }
.d-what { display: grid; }
.d-go { color: var(--muted); font-size: 13px; white-space: nowrap; padding-top: 2px; }
.d-go::after { content: " ›"; }
.d-when { display: grid; line-height: 1.2; }
.d-day { font: 700 24px/1 var(--hand); }
.is-today .d-day { color: var(--accent); }
.d-date { margin-top: 4px; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.d-menu { font-size: 16px; font-weight: 500; word-break: keep-all; }
.d-kid { margin-top: 2px; color: var(--muted); font-size: 14px; word-break: keep-all; }

/* 재료 언제 쓰나: 재료 이름 + 토~금 7칸 */
#uses { display: grid; gap: 10px; }
.u-card { padding: 6px 14px 10px; border-radius: 18px; background: var(--surface); }
.u-title { padding: 10px 0 4px; color: var(--muted); font-size: 13px; font-weight: 600; }
.u-card.fresh .u-title { color: var(--accent); }
.u-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px; min-height: 44px; padding: 4px 0; }
.u-name { font-size: 15px; font-weight: 500; line-height: 1.3; word-break: keep-all; }
.u-days { display: grid; grid-template-columns: repeat(7, 26px); gap: 4px; }
.u-days span { display: grid; place-items: center; height: 30px; border-radius: 8px; background: var(--ground); color: var(--faint); font-size: 12px; font-weight: 600; }
.u-days span.on { background: var(--text); color: var(--ground); }
.u-card.fresh .u-days span.on { background: var(--accent); color: #fff; }
.u-days span.is-today { box-shadow: inset 0 0 0 2px var(--accent); }

.plain { display: grid; }
.plain li { padding: 12px 0; border-top: 1px solid var(--border); }
.plain li:first-child { border-top: 0; }
.r-top { display: flex; gap: 12px; align-items: baseline; }
.r-name { font-size: 16px; font-weight: 500; word-break: keep-all; }
.r-side { margin-left: auto; color: var(--muted); font-size: 14px; white-space: nowrap; }
.r-sub { margin-top: 2px; font-size: 15px; word-break: keep-all; }
.r-sub.muted { font-size: 14px; }

/* 장보기 */
.shop-sticky { position: sticky; z-index: 1; top: calc(var(--top-h) + env(safe-area-inset-top)); margin: 0 -4px; padding: 0 4px 2px; background: var(--ground); }
.shop-sticky .shop-head h2 { margin-top: 8px; }
.shop-sticky .progress { margin-bottom: 8px; }
.shop-head { display: flex; align-items: baseline; gap: 8px; }
.count { margin-left: auto; color: var(--muted); font-size: 15px; font-variant-numeric: tabular-nums; }
.progress { height: 6px; margin: 0 0 14px; border-radius: 999px; background: var(--surface); overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--accent); transition: width .2s; }
.sticky-sentinel { height: 1px; margin-bottom: -1px; }
.shop-sticky { transition: box-shadow .15s; }
.shop-sticky.stuck { box-shadow: 0 10px 12px -12px rgba(0, 0, 0, .45); }
/* 장보기 묶음: 묶음마다 회색 카드, 머리는 굵게(이름·개수·소계), 품목은 카드 안 줄 */
.g-card { margin-top: 12px; padding: 0 14px 4px; border-radius: 18px; background: var(--surface); }
.g-card:first-child { margin-top: 4px; }
.g-head { display: flex; align-items: baseline; gap: 6px; padding: 14px 0 10px; border-bottom: 1.5px solid var(--text); }
.g-name { font-size: 16px; font-weight: 700; }
.g-count { color: var(--muted); font-size: 13px; font-weight: 500; }
.g-sum { margin-left: auto; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.g-card .item { padding: 10px 0; }
.g-card .box { background: var(--ground); }
.items { display: grid; }
.item { display: grid; grid-template-columns: 28px 1fr auto; gap: 12px; align-items: center; width: 100%; min-height: 60px; padding: 10px 4px; border: 0; border-top: 1px solid var(--border); background: none; text-align: left; cursor: pointer; touch-action: manipulation; }
.items .item:first-child { border-top: 0; }
.item:hover .box { border-color: var(--accent); }
.box { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--border); display: grid; place-items: center; transition: background-color .15s, border-color .15s; }
.box::after { content: ""; width: 6px; height: 11px; margin-top: -3px; border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg); opacity: 0; }
.item[aria-pressed="true"] .box { background: var(--accent); border-color: var(--accent); }
.item[aria-pressed="true"] .box::after { opacity: 1; }
.item[aria-pressed="true"] .i-name, .item[aria-pressed="true"] .price { color: var(--muted); text-decoration: line-through; }
.i-name { font-size: 17px; font-weight: 500; word-break: keep-all; }
.i-qty { display: block; color: var(--muted); font-size: 14px; }
.price { font-size: 16px; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.price .est { color: var(--muted); }
.tag { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px; background: var(--accent-tint); color: var(--accent); font-size: 12px; font-weight: 600; vertical-align: 2px; white-space: nowrap; }
.tag.store { background: var(--surface); color: var(--text); font-weight: 600; }
.shop-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; padding-top: 14px; border-top: 2px solid var(--text); font-size: 16px; }
.shop-foot b { font-weight: 700; font-variant-numeric: tabular-nums; }
.shop-foot .muted { font-size: 13px; }
.ghost { min-height: 44px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--border); background: transparent; font-size: 14px; cursor: pointer; touch-action: manipulation; }
.ghost:hover { border-color: var(--text); }

.sec-head { display: flex; align-items: center; gap: 12px; }
.sec-head .ghost { margin: 36px 0 12px auto; }
.ghost.small { min-height: 36px; padding: 0 14px; font-size: 14px; }
.primary { min-height: 44px; padding: 0 22px; border: 0; border-radius: 999px; background: var(--text); color: var(--ground); font-size: 15px; font-weight: 600; cursor: pointer; touch-action: manipulation; }
.primary:disabled { opacity: .6; }
.left-form { display: grid; gap: 10px; }
#leftFields { display: grid; gap: 8px; }
.lf-row { display: grid; grid-template-columns: 1fr 1fr 36px; gap: 6px; padding: 10px; border-radius: 14px; background: var(--surface); }
.lf-row input { min-width: 0; height: 44px; padding: 0 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--ground); color: var(--text); font: inherit; font-size: 16px; }
.lf-row input:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.lf-row input[name="note"] { grid-column: 1 / 3; }
.lf-del { width: 36px; height: 44px; border: 0; border-radius: 10px; background: none; color: var(--muted); font-size: 22px; cursor: pointer; }
.lf-del:hover { background: var(--active); color: var(--text); }
.ghost.add { justify-self: start; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; }
.sub.warn { color: #b42318; }

/* 조리법 시트 */
.sheet { width: 100%; max-width: 560px; max-height: 88dvh; margin: auto auto 0; padding: 0; border: 0; border-radius: 24px 24px 0 0; background: var(--ground); color: var(--text); overflow: hidden; }
.sheet[open] { display: flex; flex-direction: column; }
.sheet::backdrop { background: rgba(0, 0, 0, .4); }
.sheet-grip { width: 40px; height: 5px; margin: 10px auto 0; border-radius: 999px; background: var(--border); }
.sheet.tip .sheet-body { padding-top: 16px; }
.sheet.tip h2 { margin: 0 0 16px; font-size: 28px; }
.tip-note { margin-top: 14px; }
.sheet-head { display: flex; align-items: flex-start; gap: 12px; padding: 12px 20px 8px; }
.rc-when { color: var(--accent); font-size: 14px; font-weight: 600; }
.sheet-head h2 { margin: 2px 0 0; font-size: 30px; line-height: 1.15; word-break: keep-all; }
.sheet-close { flex: none; display: grid; place-items: center; width: 44px; height: 44px; margin: -4px -8px 0 auto; border: 0; border-radius: 50%; background: var(--surface); cursor: pointer; }
.sheet-close svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.sheet-body { overflow-y: auto; padding: 4px 20px calc(28px + env(safe-area-inset-bottom)); overscroll-behavior: contain; }
.rc-kid { display: flex; gap: 12px; padding: 12px 14px; border-radius: 14px; background: var(--accent-tint); font-size: 15px; word-break: keep-all; }
.sheet-body h3 { margin: 22px 0 8px; font-size: 15px; font-weight: 700; }
.rc-ing { display: grid; gap: 6px; }
.rc-ing li { padding-left: 14px; position: relative; font-size: 15px; word-break: keep-all; }
.rc-ing li::before { content: ""; position: absolute; left: 0; top: .65em; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.rc-steps { display: grid; gap: 14px; counter-reset: step; }
.rc-steps li { display: grid; grid-template-columns: 28px 1fr; gap: 10px; font-size: 16px; line-height: 1.5; word-break: keep-all; counter-increment: step; }
.rc-steps li::before { content: counter(step); display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--text); color: var(--ground); font-size: 13px; font-weight: 700; }
.rc-src { margin-top: 16px; color: var(--muted); font-size: 13px; word-break: keep-all; }
.rc-src a { color: var(--accent); }

/* 이번 주 할인 · 구매 고려 카드 */
.deals { display: grid; gap: 8px; }
.deal { padding: 14px 16px; border-radius: 16px; background: var(--surface); }
.deals.consider .deal { background: var(--ground); border: 1.5px dashed var(--border); }
.d-top { display: flex; align-items: flex-start; gap: 10px; }
.d-name { font-size: 16px; font-weight: 700; word-break: keep-all; }
.d-when { flex: none; margin-left: auto; padding: 2px 9px; border-radius: 999px; background: var(--ground); color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap; }
.deals.consider .d-when { background: var(--surface); }
.d-main { margin-top: 6px; color: var(--accent); font-size: 15px; font-weight: 700; word-break: keep-all; }
.d-sub { margin-top: 4px; color: var(--muted); font-size: 13px; word-break: keep-all; }

/* 평가 */
.rate { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--border); }
.rate h3 { margin-top: 0 !important; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; border-radius: 14px; background: var(--surface); }
.seg button { min-height: 44px; border: 0; border-radius: 10px; background: none; color: var(--muted); font-size: 15px; font-weight: 600; cursor: pointer; touch-action: manipulation; }
.seg button[aria-pressed="true"] { background: var(--text); color: var(--ground); }
#rateScore button[data-score="good"][aria-pressed="true"] { background: var(--accent); color: #fff; }
.rate-q { margin: 16px 0 8px; font-size: 14px; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { min-height: 40px; padding: 0 14px; border: 1px solid var(--border); border-radius: 999px; background: var(--ground); color: var(--text); font-size: 14px; cursor: pointer; touch-action: manipulation; }
.chips button[aria-pressed="true"] { border-color: var(--text); background: var(--text); color: var(--ground); }
.rate-input { width: 100%; height: 48px; margin-top: 10px; padding: 0 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--ground); color: var(--text); font: inherit; font-size: 16px; }
.rate-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.primary.wide { width: 100%; min-height: 50px; margin-top: 14px; }
#rateMsg { margin: 8px 0 0; }
.ask-rate { display: flex; align-items: center; gap: 12px; width: 100%; margin-top: 12px; padding: 16px 18px; border: 2px dashed var(--accent); border-radius: 18px; background: none; text-align: left; cursor: pointer; touch-action: manipulation; }
.ar-when { display: block; color: var(--accent); font-size: 14px; font-weight: 600; }
.ar-menu { display: block; font-size: 16px; font-weight: 500; word-break: keep-all; }
.ar-go { margin-left: auto; color: var(--accent); font-size: 15px; font-weight: 600; white-space: nowrap; }
.d-rate { display: inline-block; margin-top: 4px; padding: 0 8px; border-radius: 999px; background: var(--surface); color: var(--muted); font-size: 12px; font-weight: 600; width: fit-content; }
.d-rate.good { background: var(--accent-tint); color: var(--accent); }
.d-rate.bad { background: #fdecea; color: #7a1d14; }

@media (min-width: 600px) { .sheet { margin: auto; border-radius: 24px; } .sheet-grip { display: none; } }

/* 지출 */
.money-sum { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.money-sum > div { display: grid; gap: 2px; padding: 14px 16px; border-radius: 18px; background: var(--surface); }
.ms-label { color: var(--muted); font-size: 13px; }
.ms-value { font-size: 15px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ms-value b, .ms-value span { font-size: 24px; color: var(--text); font-weight: 600; }
#mDiff { margin: 10px 0 0; }
.receipt-btn { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 56px; margin-top: 20px; border-radius: 18px; background: var(--text); color: var(--ground); font-size: 17px; font-weight: 600; cursor: pointer; touch-action: manipulation; }
.receipt-btn:hover { opacity: .88; }
.receipt-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
#rcFile:focus-visible + * , .receipt-btn:focus-within { outline: 2px solid var(--accent); }
#rcStatus { margin: 8px 0 0; }
#rcStatus.pending { color: var(--accent); font-weight: 600; }
.m-form { display: grid; gap: 8px; margin: 20px 0 8px; padding: 14px; border-radius: 18px; background: var(--surface); }
.m-form input:not([type="radio"]) { min-width: 0; height: 48px; padding: 0 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--ground); color: var(--text); font: inherit; font-size: 16px; }
.m-form input:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.m-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.m-kind { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 12px; background: var(--ground); }
.m-kind input { position: absolute; opacity: 0; pointer-events: none; }
.m-kind span { display: grid; place-items: center; height: 40px; border-radius: 9px; color: var(--muted); font-size: 15px; font-weight: 600; cursor: pointer; }
.m-kind input:checked + span { background: var(--text); color: var(--ground); }
.m-kind input:focus-visible + span { outline: 2px solid var(--accent); }
.m-form .primary { min-height: 48px; }
.m-form .sub { margin: 0; }
.m-item { display: grid; grid-template-columns: 1fr auto 40px; gap: 8px; align-items: center; }
.m-open { display: grid; gap: 2px; padding: 4px 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; touch-action: manipulation; }
.m-open .r-sub::after { content: " ›"; display: inline-block; transition: transform .15s; }
.m-item.open .m-open .r-sub::after { transform: rotate(90deg); }
.m-item > div > .r-name, .m-open .r-name { display: block; }
.m-item > div > .r-sub, .m-open .r-sub { display: block; }
.m-lines { grid-column: 1 / -1; display: grid; gap: 6px; margin: 4px 0 6px; padding: 12px 14px; border-radius: 14px; background: var(--surface); font-size: 14px; }
.m-lines li, .plain .m-lines li { display: flex; justify-content: space-between; gap: 12px; padding: 0; border: 0; }
.m-lines li span:first-child { word-break: keep-all; }
.m-lines .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.m-lines .m-gap { padding-top: 6px; border-top: 1px dashed var(--border); color: var(--muted); }
.m-item .r-sub { margin: 0; }
.m-amt { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.m-del { width: 40px; height: 40px; border: 0; border-radius: 10px; background: none; color: var(--muted); font-size: 20px; cursor: pointer; }
.m-del:hover { background: var(--active); color: var(--text); }
.chip { display: inline-block; margin-right: 6px; padding: 0 8px; border-radius: 999px; background: var(--surface); color: var(--muted); font-size: 12px; font-weight: 600; vertical-align: 1px; }
.chip.shop { background: var(--accent-tint); color: var(--accent); }
.weeks { display: grid; gap: 10px; }
.weeks li { display: grid; grid-template-columns: 74px 1fr auto; gap: 10px; align-items: center; font-size: 14px; }
.weeks .w-bar { height: 10px; border-radius: 999px; background: var(--surface); overflow: hidden; }
.weeks .w-bar span { display: block; height: 100%; border-radius: inherit; background: var(--text); }
.weeks li.is-now .w-bar span { background: var(--accent); }
.weeks li.is-now .w-label { color: var(--accent); font-weight: 700; }
.weeks .w-label { padding: 0; border: 0; background: none; color: var(--text); font-size: 14px; text-align: left; text-decoration: underline; text-decoration-color: var(--border); text-underline-offset: 3px; cursor: pointer; min-height: 32px; }
.weeks .w-total { font-variant-numeric: tabular-nums; font-weight: 600; }

.diag { display: block; margin-top: 6px; font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums; }
.notify { display: flex; align-items: center; gap: 12px; margin-top: 28px; padding: 16px 18px; border-radius: 18px; background: var(--accent-tint); }
.notify > div { flex: 1; min-width: 0; }
.nt-title { font-size: 16px; font-weight: 600; }
.nt-sub { margin-top: 2px; color: var(--muted); font-size: 13px; word-break: keep-all; }
.notify .primary { flex: none; }
.notify.on { background: var(--surface); }
.notify.on .primary { background: transparent; color: var(--text); border: 1px solid var(--border); }
.foot { margin-top: 40px; color: var(--muted); font-size: 13px; }
.err { color: var(--muted); }

/* 아래 탭 */
.tabs { position: fixed; z-index: 3; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(4, 1fr); max-width: 560px; margin: 0 auto; padding: 6px 12px env(safe-area-inset-bottom); background: var(--ground); border-top: 1px solid var(--border); }
.tabs button { position: relative; display: grid; justify-items: center; gap: 2px; min-height: var(--tabs-h); padding: 8px 0 6px; border: 0; border-radius: 14px; background: none; color: var(--muted); font-size: 13px; font-weight: 500; cursor: pointer; touch-action: manipulation; }
.tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tabs button[aria-selected="true"] { color: var(--text); font-weight: 700; }
.tabs button[aria-selected="true"] svg { stroke: var(--accent); stroke-width: 2; }
.tabs button:hover { background: var(--surface); }
.badge { position: absolute; top: 6px; left: calc(50% + 8px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; font-variant-numeric: tabular-nums; }

@media (min-width: 600px) {
  .views { padding-bottom: calc(var(--tabs-h) + 56px + env(safe-area-inset-bottom)); }
  .tabs { bottom: 16px; border: 1px solid var(--border); border-radius: 22px; padding: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  .shop-link, .box, .progress span, .recipe-btn { transition: none; }
}

/* ── iPhone Duo ─────────────────────────────────────────
   WebKit이 밝힌 사파리 화면 크기(CSS px): 바깥 세로 382×580~618, 바깥 가로 594×368~406,
   안쪽 세로 669×867~902, 안쪽 가로 951×585~620, 안쪽 두 창 나란히 385×571~609.
   애플 가이드: 가로일 때 막대는 옆으로, 안쪽 세로는 아래 막대 유지, 펼친 화면은 두 칸, 접힌 가운데는 비우기. */

/* 세로가 짧은 화면(바깥 화면 세로 580~618): 위 이름 줄과 아래 탭을 낮게 */
@media (orientation: portrait) and (max-height: 700px) {
  :root { --tabs-h: 54px; --top-h: 44px; }
  .tabs { padding-top: 4px; }
  .tabs button { padding: 5px 0 4px; font-size: 12px; }
  .tabs svg { width: 22px; height: 22px; }
  #view-today h1 { font-size: 34px; }
  .when { margin-top: 12px; }
}

/* 가로(바깥 594×368, 안쪽 951×585): 탭 막대를 오른쪽 세로로, 세로 공간은 전부 내용에 */
@media (orientation: landscape) {
  .tabs { left: auto; right: max(8px, env(safe-area-inset-right)); top: 50%; bottom: auto; transform: translateY(-50%);
    grid-template-columns: none; grid-auto-flow: row; width: 76px; max-width: none; margin: 0; padding: 6px;
    border: 1px solid var(--border); border-radius: 22px; }
  .tabs button { min-height: 60px; padding: 6px 0; }
  .views { padding-bottom: calc(32px + env(safe-area-inset-bottom)); }
  .top, .views { padding-right: calc(20px + 84px + env(safe-area-inset-right)); }
}
@media (orientation: landscape) and (max-height: 420px) {
  :root { --top-h: 40px; }
  .tabs button { min-height: 52px; font-size: 12px; }
  .tabs svg { width: 22px; height: 22px; }
  #view-today h1 { font-size: 30px; }
}

/* 한 칸 화면에서는 두 칸 묶음(pane)을 풀어서, 장보기 머리 고정이 탭 끝까지 유지되게 */
@media (max-width: 639px) { .pane { display: contents; } }

/* 펼친 안쪽 화면(세로 669, 가로 951): 탭마다 두 칸(짝수 칸) */
@media (min-width: 640px) {
  .top, .views { max-width: 1080px; }
  .view:not([hidden]) { display: grid; grid-template-columns: 1fr 1fr; column-gap: 32px; align-items: start; }
  .pane { min-width: 0; }
  .pane-b > h2:first-child, .pane-b > .sec-head:first-child .ghost { margin-top: 12px; }
  #view-today .pane-b { padding-top: 20px; }
  #view-today .pane-b > :first-child { margin-top: 0; }
  #view-money .pane-b { padding-top: 12px; }
  .sheet { max-width: 640px; }
}
@media (min-width: 900px) { .view:not([hidden]) { column-gap: 48px; } }

/* 책처럼 반쯤 접었을 때(사파리 27.1 미리보기 기능, 기능 플래그 켜야 동작): 각 칸을 한 구역에, 접힌 부분은 비움 */
@media (horizontal-viewport-segments: 2) {
  .top, .views { max-width: none; }
  .view:not([hidden]) {
    grid-template-columns: env(viewport-segment-width 0 0) env(viewport-segment-width 1 0);
    column-gap: calc(env(viewport-segment-left 1 0) - env(viewport-segment-right 0 0));
    margin: 0 -20px;
  }
  .pane { padding: 0 20px; }
}
/* 노트북처럼 접었을 때(위아래 두 구역): 내용은 위 구역, 탭 막대는 아래 구역 */
@media (vertical-viewport-segments: 2) {
  .views { padding-bottom: calc(env(viewport-segment-height 0 1) + 24px); }
}

/* 접은 바깥 화면 세로(실측 373×678): 아래 탭은 그대로 두고, 좌우 여백을 줄여 내용이 화면을 꽉 채우게.
   (시간·와이파이 세로줄은 iOS가 페이지 밖에 두기 때문에 웹은 거기에 아무것도 넣을 수 없음) */
@media (orientation: portrait) and (max-width: 384px) and (min-aspect-ratio: 1/2) {
  .top { padding-left: 12px; padding-right: 12px; }
  .views { padding-left: 12px; padding-right: 12px; }
  .tabs { padding: 2px 4px calc(env(safe-area-inset-bottom) * 0.3); }
  .tabs button { min-height: 48px; padding: 4px 0 2px; gap: 1px; border-radius: 12px; }
  .tabs svg { width: 22px; height: 22px; }
  :root { --tabs-h: 48px; }
  #view-today h1 { font-size: 36px; }
  .u-card { padding-left: 10px; padding-right: 10px; }
}
