/* ===== 코인봇 — 밝고 깔끔한 핀테크 스타일 ===== */
:root {
  --bg: #f2f4f6;
  --card: #ffffff;
  --text: #191f28;
  --sub: #6b7684;
  --muted: #8b95a1;
  --line: #e5e8eb;
  --soft: #f9fafb;
  --primary: #3182f6;
  --primary-soft: #e8f3ff;
  --up: #f04452;
  --up-soft: #fff0f1;
  --down: #3182f6;
  --down-soft: #eaf2fe;
  --ok: #03b26c;
  --warn: #f59f00;
  --s-upbit: #2a78d6;
  --s-bithumb: #eb6834;
  --s-total: #1baf7a;
  --radius: 20px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .03), 0 4px 16px rgba(0, 0, 0, .04);
  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
button, input, select { font-family: inherit; font-size: inherit; color: inherit; }
a { color: var(--primary); text-decoration: none; }
.hidden { display: none !important; }
.up { color: var(--up); } .down { color: var(--down); } .flat { color: var(--muted); }
.sub { color: var(--sub); } .muted { color: var(--muted); }
.small { font-size: 13px; } .tiny { font-size: 12px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ----- 헤더 ----- */
.topbar {
  position: sticky; top: 0; z-index: 20; background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(180%) blur(12px); -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner { max-width: 1180px; margin: 0 auto; height: 64px; padding: 0 20px; display: flex; align-items: center; gap: 28px; }
.brand { color: var(--text); display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; letter-spacing: -.3px; white-space: nowrap; }
.brand-logo { width: 32px; height: 32px; border-radius: 10px; background: linear-gradient(135deg, #3182f6, #6a5cff); display: grid; place-items: center; color: #fff; font-size: 16px; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a { padding: 8px 14px; border-radius: 10px; color: var(--sub); font-weight: 600; font-size: 15px; }
.nav a:hover { background: var(--soft); color: var(--text); }
.nav a.active { color: var(--text); background: var(--bg); }
.top-right { display: flex; align-items: center; gap: 10px; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--soft); font-size: 13px; font-weight: 600; color: var(--sub); white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(3, 178, 108, .18); }
.dot.wait { background: var(--warn); }
.seg { display: inline-flex; background: var(--bg); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; font-weight: 600; font-size: 13px; color: var(--sub); cursor: pointer; }
.seg button.on { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .08); }

/* ----- 본문 ----- */
main { max-width: 1180px; margin: 0 auto; padding: 24px 20px 120px; }
.page-title { font-size: 26px; font-weight: 800; letter-spacing: -.5px; margin: 4px 0 18px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1.6fr 1fr; }
.grid-2e { grid-template-columns: 1fr 1fr; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; min-width: 0; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-t { font-size: 18px; font-weight: 700; letter-spacing: -.3px; margin: 0; }
.link { color: var(--sub); font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.link:hover { color: var(--text); }
.empty { text-align: center; padding: 28px 12px; color: var(--muted); font-size: 14px; }

/* 히어로 */
.hero { display: grid; grid-template-columns: 1fr auto; gap: 8px 24px; align-items: end; }
.hero-label { color: var(--sub); font-weight: 600; font-size: 15px; }
.hero-num { font-size: 40px; font-weight: 800; letter-spacing: -1.2px; line-height: 1.15; }
.hero-num .won { font-size: 26px; font-weight: 700; margin-left: 2px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 8px; font-weight: 700; font-size: 14px; }
.chip.up { background: var(--up-soft); } .chip.down { background: var(--down-soft); } .chip.flat { background: var(--soft); }
.hero-stats { display: flex; gap: 28px; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.stat .k { color: var(--sub); font-size: 13px; font-weight: 600; }
.stat .v { font-size: 18px; font-weight: 700; margin-top: 2px; }
.ex-split { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.ex-chip { display: flex; align-items: center; gap: 8px; background: var(--soft); border-radius: 12px; padding: 10px 14px; font-size: 14px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }

/* 차트 */
.chart-box { position: relative; width: 100%; height: 260px; margin-top: 18px; }
.chart-box.tall { height: 420px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--sub); margin-top: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.legend i.mk { width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-radius: 0; }
.legend i.mk.buy { border-bottom: 8px solid var(--up); }
.legend i.mk.sell { border-top: 8px solid var(--down); }

/* 리스트 (토스형) */
.list { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: 14px; padding: 12px 4px; border-radius: 12px; }
.row + .row { border-top: 1px solid var(--soft); }
.row:hover { background: var(--soft); }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 13px; flex: none; letter-spacing: -.3px; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-end { text-align: right; flex: none; }
.row-end .a { font-weight: 700; font-size: 15px; }
.row-end .b { font-size: 13px; font-weight: 600; }
.tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; background: var(--soft); color: var(--sub); margin-left: 6px; vertical-align: 1px; }
.tag.bot { background: var(--primary-soft); color: var(--primary); }
.tag.held { background: #eefaf4; color: var(--ok); }
.tag.buy { background: var(--up-soft); color: var(--up); }
.tag.sell { background: var(--down-soft); color: var(--down); }

/* 실시간 시세 */
.tick-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.conn { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 600; }
.search { position: relative; }
.search input { width: 220px; border: 1px solid var(--line); background: var(--soft); border-radius: 12px; padding: 9px 12px 9px 34px; outline: none; }
.search input:focus { border-color: var(--primary); background: #fff; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.suggest { position: absolute; top: calc(100% + 6px); left: 0; right: 0; min-width: 260px; background: #fff; border-radius: 14px; box-shadow: 0 8px 28px rgba(0, 0, 0, .12); padding: 6px; z-index: 30; max-height: 320px; overflow: auto; }
.suggest div { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; cursor: pointer; font-size: 14px; }
.suggest div:hover, .suggest div.sel { background: var(--soft); }
.ticks { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.tick { position: relative; background: var(--soft); border-radius: 16px; padding: 14px 16px; transition: background-color .5s ease; min-width: 0; }
.tick.fu { background: var(--up-soft); transition: none; }
.tick.fd { background: var(--down-soft); transition: none; }
.tick-top { display: flex; align-items: center; gap: 8px; }
.tick-name { font-weight: 700; font-size: 14px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tick-ex { font-size: 11px; color: var(--muted); font-weight: 600; }
.tick-price { font-size: 20px; font-weight: 800; letter-spacing: -.4px; margin-top: 6px; }
.tick-chg { font-size: 13px; font-weight: 700; }
.tick-x { position: absolute; top: 8px; right: 8px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 13px; line-height: 22px; }
.tick-x:hover { background: rgba(0, 0, 0, .06); color: var(--text); }
.tick .tag { margin-left: 0; }

/* 종목 차트 */
.chart-card { padding-bottom: 18px; }
.ch-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.ch-name { font-size: 18px; font-weight: 800; letter-spacing: -.3px; }
.ch-name .tag { vertical-align: 3px; }
.ch-price { font-size: 28px; font-weight: 800; letter-spacing: -.6px; line-height: 1.25; margin-top: 2px; }
.ch-ohlc { margin-top: 2px; min-height: 18px; }
.ch-ctrl { display: flex; gap: 10px; flex-wrap: wrap; margin: 16px 0 10px; }
.seg.scroll { overflow-x: auto; max-width: 100%; }
.seg.scroll button { flex: none; }
.chips.ind { margin: 0 0 6px; }
.chips.ind .chipbtn { padding: 6px 12px; font-size: 13px; }
.ch-legend { margin: 6px 0 4px; min-height: 20px; }
.pane { position: relative; width: 100%; }
.pane.main { height: 400px; }
.pane.sub { height: 130px; }
.pane-wrap { border-top: 1px solid var(--soft); margin-top: 4px; padding-top: 6px; }
.pane-label { font-size: 12px; font-weight: 700; color: var(--sub); margin: 0 0 2px 2px; }
.chip-coin { display: inline-flex; align-items: center; gap: 6px; }
.chip-coin small { font-weight: 600; opacity: .7; }
.tick { cursor: pointer; }

/* 표 */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: 13px; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px; border-bottom: 1px solid var(--soft); white-space: nowrap; }
th.r, td.r { text-align: right; }

/* 필터 칩 */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chipbtn { border: 0; background: #fff; padding: 8px 14px; border-radius: 999px; font-weight: 600; font-size: 14px; color: var(--sub); cursor: pointer; box-shadow: inset 0 0 0 1px var(--line); }
.chipbtn.on { background: var(--text); color: #fff; box-shadow: none; }
.day { font-size: 13px; font-weight: 700; color: var(--sub); margin: 18px 4px 4px; }

/* 폼 */
.form { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.field label { display: block; font-size: 13px; color: var(--sub); font-weight: 600; margin-bottom: 6px; }
.field input, .field select { width: 100%; border: 1px solid var(--line); background: var(--soft); border-radius: 12px; padding: 10px 12px; outline: none; }
.field input:focus, .field select:focus { border-color: var(--primary); background: #fff; }
.btn { border: 0; border-radius: 14px; padding: 12px 20px; font-weight: 700; font-size: 15px; cursor: pointer; background: var(--primary); color: #fff; }
.btn:hover { filter: brightness(.96); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: var(--soft); color: var(--text); }
.btn.block { width: 100%; }
details.params { margin-top: 14px; }
details.params summary { cursor: pointer; color: var(--sub); font-weight: 600; font-size: 14px; }

/* 설정 */
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 10px 16px; font-size: 14px; }
.kv .k { color: var(--sub); }
.log { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; white-space: pre-wrap; background: var(--soft); border-radius: 12px; padding: 12px 14px; max-height: 420px; overflow: auto; line-height: 1.55; }
.log .err { color: var(--up); }

/* 로그인 */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login { width: 100%; max-width: 380px; background: #fff; border-radius: 24px; box-shadow: var(--shadow); padding: 36px 28px; text-align: center; }
.login .brand { justify-content: center; font-size: 22px; margin-bottom: 6px; }
.login p { color: var(--sub); margin: 0 0 24px; font-size: 14px; }
.login input[type=password] { width: 100%; border: 1px solid var(--line); background: var(--soft); border-radius: 14px; padding: 14px 16px; font-size: 16px; outline: none; margin-bottom: 12px; }
.login input[type=password]:focus { border-color: var(--primary); background: #fff; }
.check { display: flex; align-items: center; gap: 8px; justify-content: center; font-size: 14px; color: var(--sub); margin: 4px 0 18px; }
.err-msg { color: var(--up); font-size: 14px; margin-top: 12px; min-height: 20px; }

/* 토스트 */
.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: rgba(25, 31, 40, .92); color: #fff; padding: 12px 18px; border-radius: 14px; font-size: 14px; z-index: 50; box-shadow: 0 6px 20px rgba(0, 0, 0, .2); max-width: calc(100% - 40px); }

/* 하단 탭 (모바일) */
.tabbar { display: none; }

@media (max-width: 900px) {
  .grid-2, .grid-2e { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .nav { display: none; }
  .topbar-inner { height: 56px; gap: 12px; padding: 0 16px; }
  .brand { font-size: 17px; }
  .brand-logo { width: 28px; height: 28px; font-size: 14px; border-radius: 9px; }
  .top-right { margin-left: auto; }
  .status-pill .txt { display: none; }
  main { padding: 16px 16px 110px; }
  .page-title { font-size: 22px; margin-bottom: 14px; }
  .card { padding: 20px 18px; border-radius: 18px; }
  .hero { grid-template-columns: 1fr; }
  .hero-num { font-size: 34px; }
  .hero-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
  .ex-split { display: grid; grid-template-columns: 1fr; }
  .ex-chip { justify-content: flex-start; }
  .chart-box { height: 220px; }
  .chart-box.tall { height: 340px; }
  .ticks { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tick { padding: 12px 12px; }
  .tick-price { font-size: 17px; }
  .search input { width: 100%; }
  .search { flex: 1 1 100%; }
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: rgba(255, 255, 255, .96);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted); font-size: 11px; font-weight: 600; padding: 4px 0; }
  .tabbar a.active { color: var(--text); }
  .tabbar svg { width: 22px; height: 22px; }
  .kv { grid-template-columns: 110px 1fr; }
  .pane.main { height: 320px; }
  .pane.sub { height: 110px; }
  .ch-price { font-size: 24px; }
  .ch-head .search { flex: 1 1 100%; }
  #chartCoins { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
  #chartCoins .chipbtn { flex: none; }
}
