/* v3 — 장보기 메모 느낌 + 한 화면 배치(sticky 장바구니, 그래프 캐러셀). 2026-10-28 */
:root {
  --desk: #efe5cf; --paper: #fffcf3; --rule: #dfe7f0; --margin: #f0b4a8;
  --ink: #2a2620; --muted: #6f6556; --line: #e4dccb; --grid: #ebe4d4;
  --green: #2f7d4f; --red: #c2452d;
  --s1: #2c5aa0; --s2: #b8742a;
  --note-now: #fff1a8; --note-later: #d6f0dc; --tape: rgba(222, 205, 160, .75);
  --tag: #ffe3d6; --tag-line: #e3a98f; --tag-on: #ffe25a; --tag-on-line: #c9ad2a;
  --hand: "Gaegu", "Nanum Pen Script", cursive;
  --sans: "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --desk: #1d1a15; --paper: #2a2620; --rule: #36352f; --margin: #6b3b33;
    --ink: #f1ead9; --muted: #b3a891; --line: #463f33; --grid: #3a352c;
    --green: #7fd09c; --red: #f08c74; --s1: #5b8fe0; --s2: #c07a30;
    --note-now: #4a4322; --note-later: #23402c; --tape: rgba(120, 110, 80, .7);
    --tag: #4a3226; --tag-line: #7a5140; --tag-on: #6d5d14; --tag-on-line: #a08a2a;
  }
}
:root[data-theme="dark"] {
  --desk: #1d1a15; --paper: #2a2620; --rule: #36352f; --margin: #6b3b33;
  --ink: #f1ead9; --muted: #b3a891; --line: #463f33; --grid: #3a352c;
  --green: #7fd09c; --red: #f08c74; --s1: #5b8fe0; --s2: #c07a30;
  --note-now: #4a4322; --note-later: #23402c; --tape: rgba(120, 110, 80, .7);
  --tag: #4a3226; --tag-line: #7a5140; --tag-on: #6d5d14; --tag-on-line: #a08a2a;
}
* { box-sizing: border-box; }
html { background: var(--desk); }
body {
  margin: 0; color: var(--ink); font-family: var(--sans); line-height: 1.45; background-color: var(--desk);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.4 0 0 0 0 0.3 0 0 0 0 0.15 0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}
button { font-family: inherit; color: inherit; }
.hand, h1, h2, h3, .chip, .name, .nm, .badge, .save-btn, summary, .tbl td:first-child { font-family: var(--hand); font-weight: 700; letter-spacing: -0.05em; }

/* 상단 바 + 장바구니 요약(항상 떠 있음) */
.sticky { position: sticky; top: 0; z-index: 10; background: var(--desk); box-shadow: 0 4px 10px -8px rgba(60,40,10,.5); }
.bar { max-width: 1200px; margin: 0 auto; padding: 8px 16px 2px; display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
h1 { margin: 0; font-size: 30px; line-height: 1.1; white-space: nowrap; }
h1 .mark { background: linear-gradient(transparent 58%, var(--tag-on) 58%, var(--tag-on) 92%, transparent 92%); padding: 0 3px; }
.asof { margin: 0; color: var(--muted); font-size: 11px; text-align: right; }
.cartbar {
  max-width: 1200px; margin: 0 auto; padding: 6px 16px 8px; display: flex; align-items: center; gap: 10px;
}
.cartbar .sum { flex: 1; min-width: 0; font-size: 14px; line-height: 1.3; }
.cartbar .sum b { display: block; font-size: 15px; }
.cartbar .sum span { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.save-btn {
  flex: none; padding: 6px 14px; border: 2px solid var(--ink); border-radius: 12px 5px 12px 5px; background: var(--ink); color: var(--paper);
  font-size: 21px; line-height: 1.1; cursor: pointer; box-shadow: 2px 2px 0 var(--tag-on);
}
.save-btn:disabled { opacity: .45; cursor: default; }

/* 종이 한 장 */
.grid { max-width: 1200px; margin: 0 auto; padding: 8px 16px 0; display: grid; gap: 12px; }
.sheet {
  position: relative; background-color: var(--paper); border-radius: 3px; padding: 10px 12px 10px 30px; min-width: 0;
  background-image:
    linear-gradient(90deg, transparent 20px, var(--margin) 20px, var(--margin) 21.5px, transparent 21.5px),
    repeating-linear-gradient(180deg, transparent 0 27px, var(--rule) 27px 28px);
  box-shadow: 0 1px 0 rgba(0,0,0,.04), 0 6px 14px -8px rgba(60,40,10,.35);
}
h2 { font-size: 22px; line-height: 26px; margin: 0 0 6px; }
.no { color: var(--red); margin-right: 3px; }
h3 { font-size: 19px; line-height: 22px; margin: 0 0 2px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 11px; margin: 4px 0 0; }
.unit { color: var(--muted); font-size: 11px; font-weight: 400; font-family: var(--sans); letter-spacing: 0; }
.up { color: var(--red); } .down { color: var(--green); }

/* 1. 가격표 스티커 */
.chips { display: flex; flex-wrap: wrap; gap: 6px 6px; }
.chip {
  position: relative; border: 1.5px solid var(--tag-line); background: var(--tag); border-radius: 5px 13px 13px 5px;
  padding: 1px 10px 1px 17px; font-size: 18px; line-height: 1.25; cursor: pointer;
}
.chip::before { content: ""; position: absolute; left: 6px; top: 50%; width: 5px; height: 5px; margin-top: -2.5px; border-radius: 50%; background: var(--paper); border: 1px solid var(--tag-line); }
.chip.on { background: var(--tag-on); border-color: var(--tag-on-line); }
.chip.on::after { content: "✓"; position: absolute; right: -5px; top: -9px; color: var(--green); font-size: 18px; transform: rotate(8deg); }

/* 2. 두 묶음(포스트잇) */
.note { position: relative; padding: 6px 8px 4px; margin-top: 8px; border-radius: 2px 2px 12px 2px; box-shadow: 0 4px 8px -5px rgba(60,40,10,.4); }
.note.now { background: var(--note-now); }
.note.later { background: var(--note-later); }
.note::before { content: ""; position: absolute; top: -7px; right: 18px; width: 52px; height: 14px; background: var(--tape); transform: rotate(4deg); }
.note.later h3 { color: var(--green); }
.note.now h3 { color: var(--red); }
.cline { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto 54px; align-items: center; gap: 6px; padding: 3px 0; border-top: 1px dashed rgba(0,0,0,.14); }
.cline.cur { background: rgba(255,255,255,.45); box-shadow: inset 3px 0 0 var(--s1); }
.nmb { border: 0; background: none; padding: 0 0 0 4px; text-align: left; cursor: pointer; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nm { font-size: 20px; margin-right: 4px; }
.fc { font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.badge { font-size: 15px; line-height: 1.1; padding: 0 6px; border: 1.5px solid currentColor; border-radius: 8px 3px 8px 3px; white-space: nowrap; transform: rotate(-2deg); }
.b-buy { color: var(--red); }
.b-wait { color: var(--green); }
.b-either { color: var(--muted); }
.qty { display: inline-flex; align-items: center; gap: 2px; }
.qty button { width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--ink); background: transparent; font-size: 15px; line-height: 1; padding: 0; cursor: pointer; }
.qty b { min-width: 16px; text-align: center; font-size: 13px; }
.pr { text-align: right; font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; }
.none { margin: 2px 0 4px 4px; }

/* 3. 그래프 캐러셀 */
.chead { display: flex; justify-content: space-between; align-items: center; }
.cnav button { width: 30px; height: 30px; border-radius: 50%; border: 1.5px solid var(--ink); background: var(--paper); font-size: 20px; line-height: 1; padding: 0 0 2px; cursor: pointer; margin-left: 4px; }
.carousel { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; -webkit-overflow-scrolling: touch; outline: none; }
.carousel::-webkit-scrollbar { display: none; }
.slide { flex: 0 0 100%; scroll-snap-align: start; min-width: 0; padding: 0 2px; }
.slide .row { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.name { font-size: 23px; }
.facts { margin: 0; font-size: 13px; font-variant-numeric: tabular-nums; }
.plot { position: relative; }
.plot canvas { width: 100%; height: 128px; display: block; touch-action: pan-x pan-y; }
.tip { position: absolute; top: 0; width: 120px; padding: 4px 6px; background: var(--ink); color: var(--paper); font-size: 11px; line-height: 1.35; border-radius: 6px; pointer-events: none; }
.why { margin: 0; font-size: 11px; color: var(--muted); }
.dots { display: flex; justify-content: center; gap: 6px; padding-top: 4px; flex-wrap: wrap; }
.dots button { width: 8px; height: 8px; border-radius: 50%; border: 0; padding: 0; background: var(--line); cursor: pointer; }
.dots button.on { background: var(--s1); width: 18px; border-radius: 4px; }

/* 4. 접어 둔 검증 표 */
.more summary { font-size: 19px; cursor: pointer; list-style: none; }
.more summary::-webkit-details-marker { display: none; }
.more summary::after { content: " ▾"; font-family: var(--sans); font-size: 12px; color: var(--muted); }
.scroll { overflow-x: auto; }
.tbl { border-collapse: collapse; width: 100%; font-size: 12px; font-variant-numeric: tabular-nums; }
.tbl th, .tbl td { border-bottom: 1px dashed var(--line); padding: 4px; text-align: right; white-space: nowrap; }
.tbl th:first-child, .tbl td:first-child { text-align: left; font-size: 16px; }
.method { padding-left: 18px; margin: 6px 0 0; }
.foot { max-width: 1200px; margin: 0 auto; padding: 8px 16px 18px; font-size: 11px; color: var(--muted); }
.foot p { margin: 2px 0; }

/* 데스크톱: 두 칸 */
@media (min-width: 900px) {
  .grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); grid-template-areas: "pick charts" "list charts" "more more"; align-items: start; }
  .pick { grid-area: pick; } .list { grid-area: list; } .charts { grid-area: charts; } .more { grid-area: more; }
  .plot canvas { height: 300px; }
  .facts { font-size: 15px; } .why { font-size: 13px; }
  h1 { font-size: 34px; } .asof { font-size: 13px; }
}
/* v3 압축 */
.chip { font-size: 17px; padding: 0 8px 0 15px; }
.chip::before { left: 5px; }
.chips { gap: 6px 5px; }
.plot canvas { height: 108px; }
.legend { display: flex; gap: 10px; font-size: 11px; color: var(--muted); margin: 2px 0 0; flex-wrap: wrap; }
.legend i { display: inline-block; width: 16px; height: 0; vertical-align: middle; margin-right: 4px; }
.legend .l1 { border-top: 2px solid var(--s1); }
.legend .l2 { border-top: 2px dashed var(--s2); }
.legend .l3 { width: 9px; height: 9px; border: 2px solid var(--s1); border-radius: 50%; }
.asof { white-space: nowrap; }
@media (min-width: 900px) { .plot canvas { height: 300px; } }
@media (min-width: 900px) {
  .grid { gap: 16px; padding-top: 14px; }
  .sheet { padding: 14px 18px 14px 40px; background-position: 6px 0, 0 0; }
  h2 { font-size: 28px; line-height: 32px; } h3 { font-size: 23px; }
  .chip { font-size: 22px; padding: 2px 12px 2px 19px; }
  .chips { gap: 8px 8px; }
  .nm { font-size: 24px; } .fc, .pr { font-size: 15px; } .badge { font-size: 18px; }
  .qty button { width: 28px; height: 28px; } .qty b { font-size: 15px; }
  .cline { padding: 5px 0; }
  .name { font-size: 30px; } .legend { font-size: 13px; }
  .cartbar .sum b { font-size: 18px; } .cartbar .sum span { font-size: 14px; }
  .save-btn { font-size: 26px; padding: 6px 20px; }
  .plot canvas { height: 380px; }
  .tiny { font-size: 12px; }
}
