/* v8 — 종류 카드 격자·예측 폭. v6 — v5 + 즐겨찾기 그래프 캐러셀·장 볼 날짜 칩. v5 — 모바일 앱 화면(홈 리스트·상세 그래프·하단 장바구니 바·시트). 2026-10-28 */
:root {
  --bg: #f5f6f8; --outer: #e9ecf1; --paper: #ffffff; --ink: #191f28; --sub: #4e5968; --muted: #8b95a1; --line: #eceef1; --grid: #eef0f3;
  --accent: #12883e; --accent-bg: #e6f5ea; --accent-ink: #12883e; --up: #f04452; --up-bg: #ffeef0; --down: #3182f6; --down-bg: #e8f3ff; --chip: #f2f4f6;
  --s1: #3182f6; --s2: #c46f12; --shadow: 0 2px 10px rgba(20, 30, 50, .06);
  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111215; --outer: #0a0b0d; --paper: #1d1f23; --ink: #f2f4f6; --sub: #c3c9d0; --muted: #8b95a1; --line: #2c2f35; --grid: #2a2d32;
    --accent: #1d8549; --accent-bg: #16301f; --accent-ink: #4cc27e; --up: #ff6b78; --up-bg: #3a1c21; --down: #4c94f8; --down-bg: #17283f; --chip: #2a2d32;
    --s1: #4c94f8; --s2: #c9781a; --shadow: 0 2px 10px rgba(0, 0, 0, .3);
  }
}
:root[data-theme="dark"] {
  --bg: #111215; --outer: #0a0b0d; --paper: #1d1f23; --ink: #f2f4f6; --sub: #c3c9d0; --muted: #8b95a1; --line: #2c2f35; --grid: #2a2d32;
  --accent: #1d8549; --accent-bg: #16301f; --accent-ink: #4cc27e; --up: #ff6b78; --up-bg: #3a1c21; --down: #4c94f8; --down-bg: #17283f; --chip: #2a2d32;
  --s1: #4c94f8; --s2: #c9781a; --shadow: 0 2px 10px rgba(0, 0, 0, .3);
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); line-height: 1.45; -webkit-font-smoothing: antialiased; letter-spacing: -0.01em; }
button { font-family: inherit; color: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.up { color: var(--up); } .down { color: var(--down); } .flat { color: var(--muted); }
b, .num { font-variant-numeric: tabular-nums; }

/* 앱 틀: 휴대폰 폭. 데스크톱은 가운데 휴대폰 카드 */
.app { position: relative; max-width: 440px; margin: 0 auto; min-height: 100vh; background: var(--bg); }
@media (min-width: 700px) {
  html, body { background: var(--outer); }
  .app { margin: 24px auto; min-height: calc(100vh - 48px); border-radius: 32px; box-shadow: 0 10px 40px rgba(20, 30, 50, .12); overflow: hidden; }
}
.view { padding: 0 20px 112px; }

/* 상단 */
.top { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 17px; letter-spacing: -0.03em; }
.logo { width: 22px; height: 22px; border-radius: 7px; background: var(--accent); position: relative; }
.logo::before { content: ""; position: absolute; left: 6px; top: 3px; width: 9px; height: 7px; border-radius: 9px 0 9px 0; background: #b6e8c4; transform: rotate(-12deg); }
.logo::after { content: ""; position: absolute; left: 5px; right: 5px; top: 10px; height: 3px; border-radius: 2px; background: #fff; box-shadow: 0 -5px 0 -0px rgba(255,255,255,.55); }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; border: 0; background: transparent; color: var(--ink); }
.icon-btn:active { background: var(--chip); }
.hello { margin: 0 0 12px; }
.hello .asof { margin: 0 0 4px; font-size: 13px; color: var(--muted); }
.hello h1 { margin: 0; font-size: 21px; line-height: 1.3; font-weight: 800; letter-spacing: -0.035em; }
.search { display: flex; align-items: center; gap: 8px; height: 46px; padding: 0 14px; border-radius: 14px; background: var(--paper); color: var(--muted); box-shadow: var(--shadow); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font: inherit; font-size: 15px; color: var(--ink); }

.sec-h { display: flex; align-items: baseline; justify-content: space-between; margin: 22px 0 10px; }
.sec-h h2 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -0.03em; }
.sec-h .hint { font-size: 12px; color: var(--muted); }

/* 종류 아이콘 카드 (가로) */
.cats { display: flex; gap: 10px; overflow-x: auto; margin: 0 -20px; padding: 2px 20px 6px; scrollbar-width: none; }
.cats::-webkit-scrollbar { display: none; }
.cat { flex: none; width: 68px; padding: 8px 4px 7px; border: 1.5px solid transparent; border-radius: 16px; background: var(--paper); box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--sub); }
.cat .ic { width: 30px; height: 30px; }
.cat[aria-selected="true"] { border-color: var(--accent); color: var(--accent-ink); }

/* 품목 리스트 (My Assets 형) */
.assets { background: var(--paper); border-radius: 20px; box-shadow: var(--shadow); padding: 4px 0; }
.asset { display: grid; grid-template-columns: 44px 1fr 56px auto auto; align-items: center; gap: 10px; padding: 11px 12px 11px 14px; }
.asset + .asset { border-top: 1px solid var(--line); }
.asset .open { display: contents; text-align: left; background: none; border: 0; padding: 0; }
.ic-wrap { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--chip); }
.ic-wrap .ic { width: 30px; height: 30px; }
.a-name { min-width: 0; }
.a-name b { display: block; font-size: 15px; font-weight: 700; white-space: nowrap; }
.a-name small { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.a-name small .fc { font-weight: 700; }
.badge { display: inline-block; margin-left: 4px; padding: 1px 6px; border-radius: 6px; font-size: 11px; font-weight: 700; vertical-align: 1px; }
.b-wait { background: var(--down-bg); color: var(--down); }
.b-buy { background: var(--up-bg); color: var(--up); }
.b-either { background: var(--chip); color: var(--muted); }
.spark { width: 64px; height: 28px; display: block; }
.a-price { text-align: right; }
.a-price b { display: block; font-size: 15px; font-weight: 700; }
.a-price small { display: block; font-size: 11px; color: var(--muted); }
.add { width: 34px; height: 34px; border: 0; border-radius: 11px; background: var(--accent); color: #fff; font-size: 22px; line-height: 1; display: grid; place-items: center; font-weight: 500; }
.add.in { background: var(--accent-bg); color: var(--accent-ink); font-size: 14px; font-weight: 800; }
.empty { padding: 24px; text-align: center; color: var(--muted); font-size: 14px; }

.link-card { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; padding: 16px 18px; background: var(--paper); border-radius: 18px; box-shadow: var(--shadow); }
.link-card b { display: block; font-size: 15px; }
.link-card small { display: block; font-size: 12px; color: var(--muted); }
.arrow { font-size: 24px; color: var(--muted); }
.foot { margin: 18px 2px 0; font-size: 11.5px; color: var(--muted); }
.foot p { margin: 0 0 4px; }

/* 하단 고정 장바구니 바 */
.cartbar { position: fixed; z-index: 20; left: 50%; transform: translateX(-50%); bottom: 0; width: 100%; max-width: 440px; display: flex; align-items: center; gap: 10px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: var(--paper); border-top: 1px solid var(--line); box-shadow: 0 -4px 20px rgba(20, 30, 50, .06); }
@media (min-width: 700px) { .cartbar { border-radius: 20px 20px 0 0; } }
.bag { position: relative; width: 44px; height: 44px; border: 0; border-radius: 14px; background: var(--accent-bg); color: var(--accent-ink); display: grid; place-items: center; flex: none; padding: 0; }
.bag i { position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--up); color: #fff; font-style: normal; font-size: 11px; font-weight: 800; display: grid; place-items: center; border: 2px solid var(--paper); }
.cb-sum { flex: 1; min-width: 0; cursor: pointer; }
.cb-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.cb-sum small { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cb-sum b { display: block; white-space: nowrap; font-size: 19px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.2; }
.save-btn { flex: none; height: 46px; padding: 0 13px; border: 0; border-radius: 14px; background: var(--accent); color: #fff; font-size: 14px; font-weight: 700; }
.save-btn:disabled { opacity: .4; cursor: default; }
body.on-detail .cartbar { display: none; }

/* 장바구니 시트 */
.scrim { position: fixed; inset: 0; z-index: 30; background: rgba(0, 0, 0, .35); }
.sheet { position: fixed; z-index: 31; left: 50%; bottom: 0; transform: translateX(-50%); width: 100%; max-width: 440px; max-height: 86vh; display: flex; flex-direction: column; background: var(--paper); border-radius: 24px 24px 0 0; box-shadow: 0 -10px 40px rgba(0, 0, 0, .15); animation: up .22s ease-out; }
@media (min-width: 700px) { .sheet { max-height: calc(100vh - 60px); } }
@keyframes up { from { transform: translate(-50%, 40px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } }
.grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 8px auto 0; }
.sh-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 12px 0 20px; }
.sh-head h2 { margin: 0; font-size: 19px; font-weight: 800; }
.sh-total { padding: 4px 20px 12px; }
.sh-total small { display: block; font-size: 13px; color: var(--muted); }
.sh-total .sh-row { display: flex; align-items: center; gap: 10px; }
.sh-total b { display: block; font-size: 30px; font-weight: 800; letter-spacing: -0.035em; }
.sh-total span { display: block; font-size: 13px; color: var(--sub); }
.sh-body { overflow-y: auto; padding: 0 20px 8px; }
.grp { margin: 6px 0 12px; }
.grp h3 { display: flex; justify-content: space-between; margin: 0 0 4px; font-size: 14px; font-weight: 700; }
.grp h3 span { font-size: 12px; font-weight: 500; color: var(--muted); }
.line { display: grid; grid-template-columns: 36px 1fr auto auto; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.line .ic-wrap { width: 36px; height: 36px; } .line .ic-wrap .ic { width: 24px; height: 24px; }
.line .nm b { display: block; font-size: 15px; }
.line .nm small { display: block; font-size: 12px; color: var(--muted); }
.line .pr { font-weight: 700; font-size: 15px; text-align: right; min-width: 64px; }
.qty { display: inline-flex; align-items: center; gap: 2px; background: var(--chip); border-radius: 10px; }
.qty button { width: 30px; height: 30px; border: 0; background: transparent; font-size: 17px; }
.qty b { min-width: 16px; text-align: center; font-size: 14px; }
.sh-foot { display: flex; gap: 10px; padding: 10px 16px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.ghost-btn { flex: none; height: 52px; padding: 0 18px; border: 0; border-radius: 14px; background: var(--chip); font-size: 15px; font-weight: 700; color: var(--sub); }
.big-btn { flex: 1; height: 52px; border: 0; border-radius: 14px; background: var(--accent); color: #fff; font-size: 16px; font-weight: 700; }
.big-btn:disabled { opacity: .4; }

/* 상세 */
.nav .ttl { text-align: center; }
.nav .ttl b { display: block; font-size: 16px; }
.nav .ttl small { display: block; font-size: 12px; color: var(--muted); }
.pager { width: 40px; text-align: right; font-size: 12px; color: var(--muted); }
.drow { display: flex; justify-content: space-between; font-size: 13px; margin-top: 6px; }
.bigprice { margin: 2px 0 8px; font-size: 34px; font-weight: 800; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.dchips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; }
.pill { padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; background: var(--chip); color: var(--sub); }
.pill.down { background: var(--down-bg); color: var(--down); }
.pill.up { background: var(--up-bg); color: var(--up); }
.pill.soft { font-weight: 600; }
.tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.tabs button { flex: 1; height: 34px; border: 0; border-radius: 999px; background: var(--chip); color: var(--sub); font-size: 13px; font-weight: 600; }
.tabs button[aria-selected="true"] { background: var(--accent); color: #fff; }
.legend { display: flex; gap: 12px; font-size: 12px; color: var(--sub); margin-bottom: 4px; }
.legend i { display: inline-block; width: 16px; height: 0; border-top: 2px solid var(--s1); vertical-align: middle; margin-right: 4px; }
.legend .l2 { border-top: 2px dashed var(--s2); }
.legend .l3 { width: 9px; height: 9px; border: 2px solid var(--s1); border-radius: 50%; background: var(--paper); }
.plot { position: relative; margin: 0 -6px; }
.plot canvas { display: block; width: 100%; height: 230px; touch-action: pan-y; }
.tip { position: absolute; top: 4px; width: 130px; padding: 6px 9px; border-radius: 10px; background: var(--ink); color: var(--paper); font-size: 12px; line-height: 1.4; pointer-events: none; }
.card { background: var(--paper); border-radius: 18px; box-shadow: var(--shadow); padding: 14px 16px; margin-top: 14px; }
.card h3 { margin: 0 0 6px; font-size: 15px; }
.why ul { margin: 0; padding-left: 18px; font-size: 13.5px; color: var(--sub); }
.why li { margin: 3px 0; }
.swipe-hint { text-align: center; font-size: 12px; color: var(--muted); margin: 12px 0 0; }
.dock { position: fixed; z-index: 20; left: 50%; transform: translateX(-50%); bottom: 0; width: 100%; max-width: 440px; display: flex; gap: 10px; align-items: center; padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--bg) 70%, transparent); }

.stepper { display: flex; align-items: center; height: 52px; background: var(--paper); border-radius: 14px; box-shadow: var(--shadow); }
.stepper button { width: 44px; height: 52px; border: 0; background: transparent; font-size: 20px; }
.stepper b { min-width: 20px; text-align: center; }

/* 정확도 */
.ibody .card:first-child { margin-top: 4px; }
.scroll { overflow-x: auto; margin: 8px -4px; }
.tbl { border-collapse: collapse; font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tbl th, .tbl td { padding: 6px 7px; border-bottom: 1px solid var(--line); text-align: right; }
.tbl th:first-child, .tbl td:first-child { text-align: left; position: sticky; left: 0; background: var(--paper); }
.tbl th { color: var(--muted); font-weight: 600; }
.method { padding-left: 18px; color: var(--sub); margin: 0; }
.method li { margin: 4px 0; }

/* v6: 날짜 칩 */
.date-chip { flex: none; display: inline-flex; align-items: center; gap: 2px; height: 26px; padding: 0 6px 0 9px; border: 0; border-radius: 999px; background: var(--chip); color: var(--sub); font-size: 12px; font-weight: 700; white-space: nowrap; }
.date-chip.fc { background: var(--accent-bg); color: var(--accent-ink); }
.sh-note { margin: 0; padding: 0 20px 10px; font-size: 13px; color: var(--muted); }
.cal { margin: 0 0 14px; }
.cal h3 { display: flex; justify-content: space-between; margin: 0 0 6px; font-size: 14px; }
.cal h3 span { font-size: 12px; font-weight: 500; color: var(--muted); }
.cal-row { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-row button { height: 50px; border: 0; border-radius: 12px; background: var(--chip); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; font-size: 15px; font-weight: 700; color: var(--ink); }
.cal-row button small { font-size: 10.5px; font-weight: 500; color: var(--muted); }
.cal-row button.fc { background: var(--accent-bg); }
.cal-row button.today small { color: var(--accent-ink); font-weight: 700; }
.cal-row button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.cal-row button[aria-pressed="true"] small { color: #fff; }
.cal-head { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 4px; font-size: 11px; color: var(--muted); text-align: center; }

/* v6: 즐겨찾기 */
.fav { margin-bottom: 12px; }
.sec-h.tight { margin: 0 0 8px; }
.text-btn { border: 0; background: none; color: var(--accent-ink); font-size: 13px; font-weight: 700; padding: 4px; }
.fav-empty { position: relative; } /* 10-28 v7: 빈 상태도 실제 카드와 같은 높이(흐린 카드가 흐름 안에서 높이를 잡음) + 점 줄 자리 → 고른 뒤 레이아웃 이동 없음 */
.fav-blur { padding: 2px 0 4px; filter: blur(3px); opacity: .45; pointer-events: none; }  /* fav-track 위아래 여백과 같게 */
.fav-blur .fcard { width: 100%; cursor: default; }
.fav-empty .fav-pick { white-space: nowrap; position: absolute; left: 50%; top: calc(50% - 7px); transform: translate(-50%, -50%); }
.fav-pick { position: relative; display: inline-flex; align-items: center; gap: 6px; height: 46px; padding: 0 18px; border: 0; border-radius: 14px; background: var(--accent); color: #fff; font-size: 15px; font-weight: 700; box-shadow: 0 6px 16px rgba(18, 136, 62, .28); }
.fav-track { display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; margin: 0 -20px; padding: 2px 20px 4px; scroll-padding: 0 20px; scrollbar-width: none; }
.fav-track::-webkit-scrollbar { display: none; }
.fcard { flex: none; width: calc(100% - 28px); scroll-snap-align: start; background: var(--paper); border-radius: 20px; box-shadow: var(--shadow); padding: 14px 16px 10px; cursor: pointer; text-align: left; border: 0; }
.fav-track .fcard:only-child { width: 100%; }
.fc-top { display: flex; align-items: center; gap: 8px; }
.fc-top .ic-wrap { width: 30px; height: 30px; } .fc-top .ic-wrap .ic { width: 21px; height: 21px; }
.fc-top b { font-size: 15px; } .fc-top small { font-size: 12px; color: var(--muted); }
.fc-mid { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-top: 4px; }
.fc-mid strong { font-size: 25px; font-weight: 800; letter-spacing: -0.035em; font-variant-numeric: tabular-nums; }
.fc-mid strong small { font-size: 12px; font-weight: 500; color: var(--muted); margin-left: 4px; letter-spacing: 0; }
.fcard svg.mini { display: block; width: 100%; height: 64px; margin-top: 4px; }
.dots { display: flex; justify-content: center; gap: 6px; margin-top: 8px; min-height: 6px; }
.dots button { width: 6px; height: 6px; padding: 0; border: 0; border-radius: 3px; background: var(--line); }
.dots button.on { width: 16px; background: var(--accent); }

/* v6: 목록 행 = 클릭 가능한 div, 아이콘 모서리에 별 */
.asset { cursor: pointer; }
.ic-box { position: relative; width: 44px; height: 44px; }
.star-mini { position: absolute; right: -6px; bottom: -5px; width: 24px; height: 24px; padding: 0; border: 0; border-radius: 50%; background: var(--paper); box-shadow: 0 1px 4px rgba(0, 0, 0, .15); display: grid; place-items: center; color: #c4cad2; }
.star-mini[aria-pressed="true"], .star[aria-pressed="true"] { color: #f5b301; }
.pick-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 0; border: 0; border-top: 1px solid var(--line); background: none; text-align: left; font-size: 15px; font-weight: 700; }
.pick-row small { display: block; font-size: 12px; font-weight: 500; color: var(--muted); }
.pick-row .chk { margin-left: auto; width: 24px; height: 24px; border-radius: 8px; border: 2px solid var(--line); display: grid; place-items: center; color: transparent; }
.pick-row[aria-pressed="true"] .chk { background: var(--accent); border-color: var(--accent); color: #fff; }

.cats { margin-top: 12px; }

/* v8 — 종류 카드 9개(전체+8종류)를 한눈에: 5칸 격자로 줄바꿈(가로 스크롤 없음), 칸마다 품목 수 */
.cats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; overflow: visible; margin: 12px 0 0; padding: 2px 0 6px; }
.cat { width: auto; min-width: 0; padding: 8px 2px 6px; gap: 3px; }
.cat span { white-space: nowrap; font-size: 11.5px; letter-spacing: -0.03em; }
.cat small { font-size: 10.5px; font-weight: 500; color: var(--muted); line-height: 1; }
.cat[aria-selected="true"] small { color: var(--accent-ink); }
.why .risk { margin: 8px 0 0; padding-top: 8px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }
.why .risk b { font-weight: 700; color: var(--sub); }
.why .risk .rk-hi { color: var(--up); }

/* 품목 시세 줄 담기 수량: − 수 + (0 아래로 안 내려감) */
.step { display: inline-flex; align-items: center; gap: 2px; background: var(--chip); border-radius: 11px; padding: 2px; }
.step .add, .step .mn { width: 30px; height: 30px; border-radius: 9px; font-size: 19px; }
.step .mn { border: 0; background: transparent; color: var(--ink); display: grid; place-items: center; line-height: 1; }
.step .mn:disabled { color: var(--muted); opacity: .35; cursor: default; }
.step b { min-width: 16px; text-align: center; font-size: 14px; font-weight: 800; color: var(--muted); }
.step.in b { color: var(--accent-ink); }
@media (max-width: 420px) {
  .asset { grid-template-columns: 40px 1fr 44px auto auto; gap: 7px; padding: 10px 10px 10px 12px; }
  .ic-box { width: 40px; height: 40px; }
  .spark { width: 44px; }
  .step .add, .step .mn { width: 27px; height: 28px; font-size: 18px; }
  .step b { min-width: 12px; }
}
/* 담기 + 버튼: 빨강(장바구니 담기 강조) */
.step .add { background: #e5484d; color: #fff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .step .add { background: #e5484d; } }
