/* 코스트코 매입 노트 (웹앱). 화면 기준은 docs/PLAN.md 7번 '화면 크기 기준'. 샘플(prototype/)에서 옮겨 왔어요. */
:root {
  --bg: #f2f4f1; --surface: #ffffff; --ink: #1b2420; --muted: #4c5953; --line: #dce2de;
  --accent: #0e6a58; --accent-ink: #ffffff; --accent-soft: #e2f1ec;
  --tag: #ffe066; --tag-ink: #2a2200;
  --ok: #127a3f; --ok-bg: #e3f4e9; --warn: #9a5a00; --warn-bg: #fff1d6; --bad: #a12f2f; --bad-bg: #f8e4e2;
  --scrim: rgba(10, 16, 14, .55);
  --font-body: system-ui, "Noto Sans KR", "Apple SD Gothic Neo", sans-serif;
  --font-num: system-ui, "Noto Sans KR", "Apple SD Gothic Neo", sans-serif;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #111614; --surface: #1a211f; --ink: #e7eee9; --muted: #9babA3; --line: #2b3531;
  --accent: #3cc2a2; --accent-ink: #05241d; --accent-soft: #163029; --tag: #f2cf4a; --tag-ink: #1d1700;
  --ok: #6fd99a; --ok-bg: #173326; --warn: #f0b75a; --warn-bg: #3a2c12; --bad: #f0a29a; --bad-bg: #3a1f1d;
  --scrim: rgba(0, 0, 0, .7); color-scheme: dark; } }
:root[data-theme="dark"] {
  --bg: #111614; --surface: #1a211f; --ink: #e7eee9; --muted: #9babA3; --line: #2b3531;
  --accent: #3cc2a2; --accent-ink: #05241d; --accent-soft: #163029; --tag: #f2cf4a; --tag-ink: #1d1700;
  --ok: #6fd99a; --ok-bg: #173326; --warn: #f0b75a; --warn-bg: #3a2c12; --bad: #f0a29a; --bad-bg: #3a1f1d;
  --scrim: rgba(0, 0, 0, .7); color-scheme: dark; }

/* 어르신 기준: 본문 18px(앱에서는 18sp), 보조 글자도 15px 아래로 안 내림, 누르는 것은 48px 이상 */
html { font-size: 18px; }
body { background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 1rem; line-height: 1.5; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--surface); }
.wrap { max-width: 720px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }

/* 앱바 */
.appbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--surface); border-bottom: 1px solid var(--line); }
.appbar .wrap { padding-block: 10px; display: grid; gap: 8px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
h1 { margin: 0; font-family: var(--font-num); font-size: 1.25rem; font-weight: 700; }
.sub { font-size: .9rem; color: var(--muted); align-self: center; }
.sub .new { color: var(--ok); }
.sub > * { white-space: nowrap; }  /* ' · ' 에서만 줄바꿈 */
.appbar .row { flex-wrap: nowrap; align-items: flex-start; }
.appbar .row > .sub { flex: 1; min-width: 0; }
.appbar .row .row { flex: none; }
.badge-sample { font-size: .8rem; font-weight: 700; background: var(--warn-bg); color: var(--warn); padding: 2px 8px; border-radius: 99px; }
.reset { border: 0; background: none; color: var(--muted); font-size: .85rem; text-decoration: underline; cursor: pointer; padding: 0 6px; min-height: 48px; }

/* 화면 공통 */
main .wrap { padding-block: 14px 140px; display: grid; gap: 14px; }
h2 { margin: 0; font-family: var(--font-num); font-size: 1.2rem; }
.lead { margin: 0; color: var(--muted); font-size: .9rem; }
.notice { background: var(--accent-soft); border-radius: 12px; padding: 12px 14px; display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: start; font-size: .9rem; }
.notice .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); margin-top: 8px; }
/* 필터·정렬: 버튼 하나 + 지금 고른 조건 (✕로 바로 풀기) */
/* 업데이트·지점·분류: 정렬과 같은 드롭다운 (안드로이드에서는 큰 선택 창이 열려요) */
.cond { display: grid; grid-template-columns: repeat(auto-fit, minmax(9em, 1fr)); gap: 10px; }  /* 글자를 키우면 한 줄씩 */
.cond .wide { grid-column: 1 / -1; }
.cond label { display: grid; gap: 4px; min-width: 0; }
.cond label > span { font-weight: 700; font-size: .85rem; color: var(--muted); }
.fsel { width: 100%; min-width: 0; min-height: 52px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); font-weight: 700; padding: 0 10px; }
.fsel.on { border-color: var(--accent); background: var(--accent-soft); }  /* 처음 값이 아니면 눈에 띄게 */
/* 정렬: 목록 제목 옆 드롭다운 (안드로이드에서는 큰 선택 창이 열려요) */
.sortsel { margin-left: auto; font-weight: 700; align-self: center; min-height: 48px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); font-weight: 600; font-size: .9rem; padding: 0 10px; }
.hint { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 6px 10px 14px; font-size: .9rem; color: var(--muted); }
.sec { display: grid; gap: 8px; }
.sec > h3 { margin: 6px 0 0; font-size: 1.05rem; display: flex; gap: 8px; align-items: baseline; }
.sec > h3 small { color: var(--muted); font-weight: 400; }
details.low { border: 1px dashed var(--line); border-radius: 12px; padding: 4px 12px; }
details.low > summary { cursor: pointer; min-height: 52px; display: flex; align-items: center; color: var(--muted); font-weight: 500; }
details.low[open] { padding-bottom: 12px; }
details.low .sec { margin-top: 6px; }

/* 상품 카드 */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: grid; grid-template-columns: 96px 1fr; gap: 12px; }
.card.on { border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
.pic { width: 96px; height: 96px; border-radius: 8px; border: 1px solid var(--line); background: #fff; padding: 0; overflow: hidden; cursor: zoom-in; }
.pic img { width: 100%; height: 100%; object-fit: contain; display: block; }
.nopic { width: 96px; height: 96px; border-radius: 8px; border: 1px dashed var(--line); display: grid; place-items: center; text-align: center; font-size: .85rem; color: var(--muted); }
.nopic.photo { cursor: zoom-in; padding: 0; overflow: hidden; border-style: solid; }
.nopic.photo img { width: 100%; height: 100%; object-fit: cover; }
.cbody { min-width: 0; display: grid; gap: 6px; align-content: start; }
/* 사진 아래 전체 폭: 지점 표시, 상품번호·기간 (사진 옆은 상품명·가격만) */
.cfull { grid-column: 1 / -1; display: grid; gap: 8px; min-width: 0; }
.cfull:empty { display: none; }
/* 할인 목록 카드: 지점·번호 두 줄 오른쪽에 '살 물건 체크' (카드 높이를 줄여 한 화면에 더 많이) */
.cfull.side { grid-template-columns: 1fr auto; align-items: center; column-gap: 10px; }
.cinfo { display: grid; gap: 8px; min-width: 0; }
.toggle.side { min-height: 0; align-self: stretch; padding: 4px 12px; line-height: 1.25; font-size: .95rem; white-space: nowrap; }
.name { font-weight: 700; line-height: 1.35; overflow-wrap: anywhere; }
.meta { font-size: .85rem; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; }
.price { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.sale { background: var(--tag); color: var(--tag-ink); font-family: var(--font-num); font-weight: 800; font-size: 1.3rem; padding: 0 8px; border-radius: 6px; }
.orig { color: var(--muted); text-decoration: line-through; font-size: .9rem; }
.off { color: var(--bad); font-weight: 700; font-size: .95rem; }
.stores { display: flex; gap: 6px; flex-wrap: wrap; }
.st { font-size: .85rem; padding: 0 12px; min-height: 34px; display: inline-flex; align-items: center; border-radius: 8px; border: 1px solid var(--line); color: var(--muted); text-decoration: none; white-space: nowrap; }
/* 지점 영상 링크는 회색(▶), '살 물건 체크'는 초록 — 색으로 구분 */
a.st { border-color: var(--line); color: var(--ink); background: var(--bg); font-weight: 600; gap: 4px; }
.st .play { font-size: .7rem; color: var(--muted); }
span.st { opacity: .55; }
a.st:hover { text-decoration: underline; }
.chip { font-size: .85rem; padding: 2px 10px; border-radius: 99px; background: var(--bg); color: var(--muted); }
.chip.ok { background: var(--ok-bg); color: var(--ok); font-weight: 700; }
.chip.warn { background: var(--warn-bg); color: var(--warn); font-weight: 700; }
.chip.bad { background: var(--bad-bg); color: var(--bad); font-weight: 700; }
.cfoot { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 10px; }
.toggle { min-height: 44px; padding: 0 20px; border-radius: 10px; border: 2px solid var(--accent); background: var(--surface); color: var(--accent); font-weight: 700; cursor: pointer; }
.toggle[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.btn { min-height: 56px; padding: 0 18px; border-radius: 12px; border: 0; background: var(--accent); color: var(--accent-ink); font-weight: 700; cursor: pointer; }
.btn.ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.wide { width: 100%; }

/* 후보 고르기 */
.match { grid-column: 1 / -1; background: var(--warn-bg); border-radius: 10px; padding: 10px; display: grid; gap: 6px; }
.match b { color: var(--warn); font-size: .9rem; }
.opt { display: grid; grid-template-columns: 22px 44px 1fr; gap: 8px; align-items: center; background: var(--surface); border-radius: 8px; padding: 6px 8px; cursor: pointer; font-size: .9rem; }
.opt input { width: 20px; height: 20px; accent-color: var(--accent); }
.opt img { width: 44px; height: 44px; object-fit: contain; background: #fff; border-radius: 6px; }
.opt .blank { width: 44px; height: 44px; }

/* 입력 */
.field { display: grid; gap: 4px; }
.field label { font-size: .9rem; color: var(--muted); }
.field input { min-height: 52px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; background: var(--bg); min-width: 0; }
.stepper { display: inline-flex; align-items: center; border: 2px solid var(--accent); border-radius: 10px; overflow: hidden; }
.stepper button { width: 52px; height: 52px; border: 0; background: none; color: var(--accent); font-size: 1.3rem; font-weight: 700; cursor: pointer; }
.stepper span { min-width: 40px; text-align: center; font-weight: 700; font-size: 1.1rem; }
.stepper .qtyin { width: 68px; height: 52px; border: 0; border-inline: 1px solid var(--line); background: var(--surface); text-align: center; font-weight: 700; font-size: 1.1rem; -moz-appearance: textfield; }
.stepper .qtyin::-webkit-inner-spin-button, .stepper .qtyin::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.check { display: flex; align-items: center; gap: 10px; min-height: 52px; cursor: pointer; font-weight: 500; }
.check input { width: 26px; height: 26px; accent-color: var(--accent); }
.stock { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; }
@media (max-width: 420px) { .stock { grid-template-columns: 1fr; } }

/* 요약 */
.sum { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sum div { display: grid; }
.sum small { color: var(--muted); font-size: .85rem; }
.sum strong { font-family: var(--font-num); font-size: 1.05rem; }
.group { display: grid; gap: 8px; }
.group h3 { margin: 4px 0 0; font-size: 1.05rem; }
.srow { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: grid; grid-template-columns: 64px 1fr; gap: 10px; align-items: center; }
.srow .pic, .srow .nopic { width: 64px; height: 64px; font-size: .75rem; }
.ch { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.ch label { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 10px; padding: 4px 14px; font-size: .95rem; cursor: pointer; min-height: 48px; }
.ch input { accent-color: var(--accent); width: 22px; height: 22px; }
.empty { text-align: center; padding: 36px 12px; color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: 12px; }
.done-box { background: var(--ok-bg); color: var(--ok); border-radius: 12px; padding: 14px; font-weight: 600; }

/* 하단 탭 + 액션 */
.dock { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom, 0px); }
.action { padding-block: 8px 0; }
.tabs { display: grid; grid-template-columns: repeat(4, 1fr); }
.tabs button { border: 0; background: none; min-height: 64px; display: grid; place-items: center; gap: 0; font-size: .85rem; color: var(--muted); cursor: pointer; padding: 6px 2px; }
.tabs button b { font-family: var(--font-num); font-size: 1.1rem; color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--accent); font-weight: 700; }
.tabs button[aria-selected="true"] b { color: var(--accent); }

/* 시트 / 확대 */
.overlay { position: fixed; inset: 0; z-index: 20; background: var(--scrim); display: grid; }
[hidden] { display: none !important; }
.zoom { place-items: center; padding: max(16px, env(safe-area-inset-top, 0px)) 16px max(16px, env(safe-area-inset-bottom, 0px)); }
.zoom figure { margin: 0; background: #fff; border-radius: 14px; padding: 12px; max-width: min(92vw, 520px); display: grid; gap: 8px; }
.zoom img { width: 100%; height: auto; max-height: 70vh; object-fit: contain; }
.zoom figcaption { color: #1b2420; font-weight: 700; font-size: 1rem; }
.zoom .zhint { color: #4c5953; font-size: .85rem; font-weight: 400; }
.sheet { align-items: end; }
.sheet .panel { background: var(--surface); border-radius: 18px 18px 0 0; max-height: 90vh; overflow: auto; padding-bottom: env(safe-area-inset-bottom, 0px); }
.sheet .wrap { padding-block: 18px; display: grid; gap: 12px; }
.shot { width: 100%; max-height: 240px; object-fit: contain; background: var(--bg); border-radius: 10px; }
.reading { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.spin { width: 18px; height: 18px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; }
@media (prefers-reduced-motion: no-preference) { .spin { animation: sp 0.8s linear infinite; } }
@keyframes sp { to { transform: rotate(360deg); } }
.found { display: grid; grid-template-columns: 64px 1fr; gap: 10px; align-items: center; background: var(--ok-bg); border-radius: 10px; padding: 10px; }
.found img { width: 64px; height: 64px; object-fit: contain; background: #fff; border-radius: 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 420px) { .grid2 { grid-template-columns: 1fr; } }
.roundhead { font-size: .9rem; font-weight: 700; color: var(--muted); padding: 6px 2px 0; }
.rec { display: grid; gap: 8px; border-top: 1px solid var(--line); padding-top: 12px; }
.rec > h3 { margin: 0; font-size: 1rem; display: flex; gap: 8px; align-items: baseline; }
.rec > h3 small { color: var(--muted); font-weight: 400; }
.logrow { display: grid; grid-template-columns: auto 1fr; gap: 10px; font-size: .9rem; padding: 6px 0; border-bottom: 1px solid var(--line); }
.logrow .num { color: var(--muted); white-space: nowrap; }
.tabs button b.due { background: var(--bad); color: #fff; border-radius: 99px; min-width: 22px; padding: 0 6px; }

/* ---------- 웹앱에서 추가 ---------- */
/* 연결 상태: 앱바 오른쪽. 누르면 바로 다시 받아요 */
.net { flex: none; border: 0; border-radius: 99px; padding: 0 12px; min-height: 40px; font-size: .85rem; font-weight: 700; cursor: pointer; background: var(--ok-bg); color: var(--ok); }
.net.wait { background: var(--accent-soft); color: var(--accent); }
.net.off { background: var(--warn-bg); color: var(--warn); }
.net.bad { background: var(--bad-bg); color: var(--bad); }
/* 반영 안 된 요청 알림 */
.alert { background: var(--bad-bg); color: var(--bad); border-radius: 12px; padding: 12px 14px; display: grid; gap: 6px; font-size: .9rem; }
.alert b { font-size: 1rem; }
.alert .btn { min-height: 48px; justify-self: start; background: var(--bad); color: #fff; }
.pendmark { font-size: .85rem; color: var(--accent); font-weight: 700; }
