/* 본전탐정 디자인: 남색(탐정) + 금색(동전) */
:root {
  --navy: #1b2540;
  --navy-2: #2b3a63;
  --navy-3: #3d4f82;
  --gold: #f5b82e;
  --gold-2: #ffd36b;
  --gold-soft: #fff5db;
  --green: #12a36b;
  --green-soft: #e2f7ee;
  --red: #e0524d;
  --red-soft: #fdecea;
  --amber: #b07400;
  --bg: #f3f4f8;
  --card: #ffffff;
  --text: #1a2135;
  --muted: #6c7590;
  --line: #e4e7ef;
  --field: #f7f8fb;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(20, 30, 60, .05), 0 6px 20px rgba(20, 30, 60, .06);
  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1424;
    --card: #182036;
    --text: #e9ecf5;
    --muted: #97a0ba;
    --line: #2a3452;
    --field: #111829;
    --gold-soft: #3a2f12;
    --green-soft: #12352a;
    --red-soft: #3a1c1c;
    --amber: #f0b44a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  background: var(--bg); color: var(--text);
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  letter-spacing: -0.2px;
}
button, input, select { font-family: inherit; }

/* ---------- 머리 ---------- */
.top {
  position: relative; overflow: hidden;
  background: radial-gradient(120% 140% at 100% 0%, var(--navy-3) 0%, var(--navy-2) 35%, var(--navy) 75%);
  color: #fff;
  padding: calc(18px + env(safe-area-inset-top)) 20px 22px;
}
.top::after { /* 동전 장식 */
  content: ""; position: absolute; right: -40px; top: -40px; width: 170px; height: 170px; border-radius: 50%;
  border: 18px solid rgba(245, 184, 46, .14);
}
.top-inner { max-width: 640px; margin: 0 auto; display: flex; align-items: center; gap: 14px; position: relative; z-index: 1; }
.top .logo { width: 48px; height: 48px; border-radius: 14px; box-shadow: 0 4px 14px rgba(0, 0, 0, .3); }
.top h1 { margin: 0; font-size: 1.45rem; font-weight: 800; letter-spacing: -0.8px; }
.top h1 em { font-style: normal; color: var(--gold); }
.tagline { margin: 3px 0 0; font-size: .83rem; opacity: .78; }

main { max-width: 640px; margin: 0 auto; padding: 16px 14px; }
.tab { display: none; animation: fade .25s ease; }
.tab.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.intro { margin: 4px 4px 14px; }
.intro h2 { margin: 0 0 4px; font-size: 1.2rem; font-weight: 800; letter-spacing: -0.5px; }
.intro p { margin: 0; color: var(--muted); font-size: .9rem; line-height: 1.55; }

.card {
  background: var(--card); border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px;
  box-shadow: var(--shadow);
  border: 2px solid transparent;
  transition: border-color .2s ease, transform .2s ease;
}
.card h3 { margin: 0 0 8px; font-size: 1rem; font-weight: 800; }
.hint { color: var(--muted); font-size: .85rem; line-height: 1.55; margin: 4px 0; }
ul.hint { padding-left: 18px; }

/* ---------- 입력 ---------- */
label { display: block; font-size: .78rem; font-weight: 600; color: var(--muted); }
label.inline { display: inline-flex; align-items: center; gap: 6px; margin-right: 14px; font-size: .9rem; color: var(--text); font-weight: 500; }
label.check { margin: 6px 0; }
input, select {
  width: 100%; margin-top: 5px; padding: 11px 12px; font-size: 1rem;
  border: 1.5px solid var(--line); border-radius: 12px; background: var(--field); color: var(--text);
  transition: border-color .15s ease, background .15s ease;
}
input::placeholder { color: var(--muted); opacity: .6; }
input[type=radio], input[type=checkbox] { width: 18px; height: 18px; margin: 0; accent-color: var(--navy-2); }
input:focus, select:focus { outline: none; border-color: var(--gold); background: var(--card); }

/* ---------- 쇼핑몰 검색 ---------- */
.search-card label { font-size: .85rem; color: var(--text); font-weight: 800; }
.search-row input { font-size: 1.05rem; padding: 13px 14px; }
.shop-btns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 8px; }
.shop { border: 0; border-radius: 12px; padding: 11px 0; font-weight: 800; font-size: .88rem; color: #fff; cursor: pointer; }
.shop:active { transform: scale(.97); }
.shop.naver { background: #03a94d; }
.shop.coupang { background: #c8283c; }
.shop.danawa { background: #1d5fd1; }

/* ---------- 상품 카드 ---------- */
.item { --c: var(--navy-2); }
.item[data-i="1"] { --c: #7a4cc2; }
.item[data-i="2"] { --c: #0f8b8d; }
.item[data-i="3"] { --c: #c2571a; }
.item[data-i="4"] { --c: #b8326a; }
.item[data-i="5"] { --c: #4a7a1f; }
.item.best { border-color: var(--green); }
.item-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.item-head .tag {
  flex: none; width: 32px; height: 32px; border-radius: 10px;
  background: var(--c); color: #fff; display: grid; place-items: center; font-weight: 800;
}
.item-head input { flex: 1; margin: 0; font-weight: 700; background: transparent; border-color: transparent; padding: 8px 6px; font-size: 1.05rem; }
.item-head input:focus { background: var(--field); border-color: var(--gold); }
.item-head .del { flex: none; background: var(--field); border: 0; color: var(--muted); width: 32px; height: 32px; border-radius: 10px; cursor: pointer; }
.paste-row { display: flex; gap: 6px; margin-bottom: 10px; }
.paste-row input { margin: 0; flex: 1; min-width: 0; border-style: dashed; font-size: .92rem; }
.paste-btn { flex: none; border: 0; border-radius: 12px; padding: 0 14px; background: var(--gold-soft); color: var(--text); font-weight: 800; cursor: pointer; }
.paste-note { margin: -4px 2px 10px; font-size: .8rem; color: var(--green); font-weight: 600; }
.paste-note.bad { color: var(--amber); }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid .full { grid-column: 1 / -1; }
.size-row { display: flex; gap: 6px; }
.size-row input { flex: 1; min-width: 0; }
.size-row select { width: 74px; flex: none; }

.chips { display: flex; gap: 6px; }
.chip {
  flex: 1; padding: 10px 0; border-radius: 12px; border: 1.5px solid var(--line);
  background: var(--field); color: var(--muted); font-weight: 700; font-size: .9rem; cursor: pointer;
  transition: all .15s ease;
}
.chip.on { background: var(--gold); border-color: var(--gold); color: var(--navy); box-shadow: 0 3px 10px rgba(245, 184, 46, .35); }

.result { margin-top: 14px; padding-top: 12px; border-top: 1.5px dashed var(--line); font-size: .9rem; }
.result .big { font-size: 1.35rem; font-weight: 800; letter-spacing: -0.6px; display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: .75rem; font-weight: 800; margin-left: 4px; letter-spacing: 0; }
.badge.best { background: var(--green); color: #fff; }
.badge.worse { background: var(--red-soft); color: var(--red); }
.line { margin: 6px 0; color: var(--muted); line-height: 1.5; }
.line.good { color: var(--green); }
.line.bad { color: var(--red); }
.line.warn { color: var(--amber); background: var(--gold-soft); padding: 8px 10px; border-radius: 10px; }
.buy-btn { margin-top: 12px; width: 100%; }

/* ---------- 탐정의 결론 ---------- */
.verdict {
  background: linear-gradient(160deg, var(--navy-2), var(--navy));
  color: #fff; border-radius: var(--radius);
  padding: 18px; margin: 14px 0; box-shadow: 0 10px 30px rgba(27, 37, 64, .3);
}
.verdict .kicker { font-size: .75rem; font-weight: 700; letter-spacing: 1px; color: var(--gold-2); opacity: .9; }
.verdict .head { font-size: 1.35rem; font-weight: 800; margin: 2px 0 4px; letter-spacing: -0.6px; }
.verdict .sub { margin: 0 0 12px; opacity: .85; font-size: .9rem; line-height: 1.5; }
.verdict .sub b { color: var(--gold-2); }
.vbars { display: grid; gap: 8px; }
.vbar { display: grid; grid-template-columns: 7.5em 1fr auto; align-items: center; gap: 10px; font-size: .82rem; }
.vname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: .85; }
.vtrack { height: 10px; background: rgba(255, 255, 255, .12); border-radius: 999px; overflow: hidden; }
.vtrack i { display: block; height: 100%; background: rgba(255, 255, 255, .45); border-radius: 999px; transition: width .4s ease; }
.vbar.win .vtrack i { background: linear-gradient(90deg, var(--gold), var(--gold-2)); }
.vbar.win .vname, .vbar.win .vval { font-weight: 800; opacity: 1; color: var(--gold-2); }
.vval { font-variant-numeric: tabular-nums; }

/* ---------- 버튼 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 16px; border-radius: 13px; border: 0; cursor: pointer;
  font-size: .95rem; font-weight: 800; transition: transform .1s ease, filter .15s ease;
}
.btn.primary { background: var(--navy-2); color: #fff; }
.btn.ghost { background: var(--card); color: var(--text); border: 1.5px solid var(--line); }
.btn.gold { background: var(--gold); color: var(--navy); }
.btn.danger { background: var(--red); color: #fff; border-color: var(--red); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: default; }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.row-btns .btn { flex: 1; }
.file-btn { cursor: pointer; }
@media (prefers-color-scheme: dark) { .btn.primary { background: var(--gold); color: var(--navy); } }

/* ---------- 본전 게이지 ---------- */
.gauge { position: relative; }
.g-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.g-head h3 { margin: 0; font-size: 1.08rem; }
.g-head .date { color: var(--muted); font-size: .8rem; flex: none; }
.g-nums { display: flex; justify-content: space-between; align-items: flex-end; margin: 12px 0 8px; font-size: .85rem; color: var(--muted); }
.g-nums b { font-size: 1.5rem; color: var(--text); letter-spacing: -0.6px; font-variant-numeric: tabular-nums; }
.bar { height: 22px; background: var(--field); border: 1.5px solid var(--line); border-radius: 999px; overflow: hidden; position: relative; }
.bar > i {
  display: block; height: 100%; border-radius: 999px; transition: width .5s cubic-bezier(.2, .8, .2, 1);
  background: repeating-linear-gradient(-45deg, var(--gold) 0 10px, var(--gold-2) 10px 20px);
}
.bar > span { position: absolute; inset: 0; display: grid; place-items: center; font-size: .72rem; font-weight: 800; color: var(--text); }
.gauge.done { border-color: var(--green); }
.gauge.done .bar > i { background: linear-gradient(90deg, #2fcf8f, var(--green)); }
.g-msg { margin: 10px 0 0; font-size: .88rem; color: var(--muted); }
.gauge.done .g-msg { color: var(--green); font-weight: 800; }
.gauge.done::before {
  content: "본전 달성"; position: absolute; top: -9px; right: 14px;
  background: var(--green); color: #fff; font-size: .7rem; font-weight: 800; padding: 3px 9px; border-radius: 999px;
}
.g-btns { display: flex; gap: 8px; margin-top: 12px; }
.g-btns .plus { flex: 1; font-size: 1.05rem; }
.g-btns .minus { flex: none; width: 58px; }
.pop { animation: pop .35s ease; }
@keyframes pop { 40% { transform: scale(1.03); } }

.empty { text-align: center; color: var(--muted); padding: 34px 16px; font-size: .92rem; line-height: 1.7; background: var(--card); border-radius: var(--radius); border: 1.5px dashed var(--line); margin-bottom: 12px; }
.empty .em { font-size: 2.4rem; display: block; margin-bottom: 6px; }

details.form summary { cursor: pointer; font-weight: 800; color: var(--text); list-style: none; }
details.form summary::-webkit-details-marker { display: none; }
details.form summary small { color: var(--muted); font-weight: 500; }
details.form form { margin-top: 14px; display: grid; gap: 12px; }
fieldset.target { border: 1.5px solid var(--line); border-radius: 12px; padding: 12px; margin: 0; }
fieldset.target legend { font-size: .78rem; font-weight: 600; color: var(--muted); padding: 0 4px; }
.target-input { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: .9rem; }
.target-input input { flex: 1; margin: 0; min-width: 0; }
.target-input span { flex: none; }

/* ---------- 기록 ---------- */
.search { margin: 0 0 12px; background: var(--card); }
.rec { display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; padding: 14px 16px; }
.rec .name { font-weight: 800; }
.rec .meta { color: var(--muted); font-size: .8rem; }
.rec .price { text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; }
.rec .unit { text-align: right; color: var(--muted); font-size: .8rem; }
.rec .actions { grid-column: 1 / -1; display: flex; gap: 6px; justify-content: flex-end; margin-top: 6px; }
.rec .actions button { padding: 6px 12px; font-size: .78rem; }
.rec-group h4 { margin: 20px 6px 8px; font-size: .92rem; }
.rec-group h4 small { color: var(--muted); font-weight: 500; }

.danger-zone h3 { color: var(--red); }

/* ---------- 시트 ---------- */
.sheet { position: fixed; inset: 0; background: rgba(10, 14, 28, .5); display: flex; align-items: flex-end; justify-content: center; z-index: 20; backdrop-filter: blur(2px); }
.sheet[hidden] { display: none; }
.sheet-body {
  background: var(--card); width: 100%; max-width: 640px; border-radius: 22px 22px 0 0;
  padding: 22px 18px calc(18px + env(safe-area-inset-bottom)); display: grid; gap: 12px;
  animation: up .25s ease;
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-body h3 { margin: 0; font-size: 1.15rem; }

/* ---------- 토스트 ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: var(--navy); color: #fff; padding: 11px 18px; border-radius: 999px; font-size: .9rem; font-weight: 600;
  opacity: 0; pointer-events: none; transition: all .25s ease; z-index: 30; white-space: nowrap;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 하단 탭 (떠 있는 알약 모양) ---------- */
.tabs {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 10;
  bottom: calc(10px + env(safe-area-inset-bottom));
  width: min(440px, calc(100% - 24px));
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px;
  background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 6px;
  box-shadow: 0 10px 30px rgba(20, 30, 60, .18);
}
.tabs button {
  background: none; border: 0; padding: 7px 0 8px; font-size: .74rem; font-weight: 600; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 1px; cursor: pointer; border-radius: 16px;
  transition: background .2s ease, color .2s ease;
}
.tabs button span { font-size: 1.25rem; filter: grayscale(1); opacity: .55; transition: all .2s ease; }
.tabs button.active { background: var(--gold-soft); color: var(--text); font-weight: 800; }
.tabs button.active span { filter: none; opacity: 1; transform: translateY(-1px); }

@media (min-width: 700px) {
  main { padding: 24px 20px; }
}
