:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f0f2f7;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e4e7ef;
  --brand: #0a1f5c;
  --accent: #3b5bdb;
  /* Korean market convention: up = red, down = blue */
  --up: #e03131;
  --up-bg: #fff0f0;
  --down: #1c7ed6;
  --down-bg: #ebf4ff;
  --shadow: 0 1px 2px rgb(15 23 42 / 4%), 0 4px 16px rgb(15 23 42 / 5%);
  --radius: 16px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1020;
    --surface: #131a2e;
    --surface-2: #1a2238;
    --text: #e8ebf3;
    --muted: #8b94ab;
    --border: #232c45;
    --brand: #c9d4ff;
    --accent: #7c93ff;
    --up: #ff6b6b;
    --up-bg: rgb(255 107 107 / 12%);
    --down: #4dabf7;
    --down-bg: rgb(77 171 247 / 12%);
    --shadow: 0 1px 2px rgb(0 0 0 / 30%);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  font-feature-settings: "tnum";
}

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

/* header */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}

.brand img { border-radius: 10px; }
.brand strong { display: block; font-size: 20px; font-weight: 800; letter-spacing: -0.02em; color: var(--brand); }
.brand small { display: block; font-size: 12px; color: var(--muted); }

.updated {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #2fb344;
  box-shadow: 0 0 0 0 rgb(47 179 68 / 50%);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  70% { box-shadow: 0 0 0 8px rgb(47 179 68 / 0%); }
  100% { box-shadow: 0 0 0 0 rgb(47 179 68 / 0%); }
}

@media (prefers-reduced-motion: reduce) {
  .live-dot { animation: none; }
}

/* cards */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.coins {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

@media (max-width: 900px) {
  .coins { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}


.coin { padding: 16px; }

.coin-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.coin-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 22px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff;
  background: var(--muted);
}

.coin-btc { background: #f7931a; }
.coin-eth { background: #627eea; }
.coin-xrp { background: #23292f; }
.coin-doge { background: #c2a633; }

@media (prefers-color-scheme: dark) {
  .coin-xrp { background: #4a5568; }
}

.coin-name { font-weight: 600; font-size: 14px; }

.pill {
  margin-left: auto;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.pill.up { color: var(--up); background: var(--up-bg); }
.pill.down { color: var(--down); background: var(--down-bg); }
.pill.flat { color: var(--muted); background: var(--surface-2); }

.coin-price {
  margin: 10px 0 12px;
  font-size: clamp(22px, 2.4vw, 26px);
  font-weight: 800;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.coin-rows {
  margin: 0;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  font-size: 13px;
}

.coin-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 0;
}

.coin-row dt {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}

.coin-row dt img { border-radius: 4px; }
.coin-row dd { margin: 0; font-weight: 600; }
.coin-row.premium { margin-top: 4px; }
.coin-row dd.up { color: var(--up); }
.coin-row dd.down { color: var(--down); }

/* chart */

.chart-card { padding: 16px; margin-bottom: 16px; }

.chart-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-bottom: 12px;
}

.chart-head h2 {
  margin: 0 auto 0 0;
  font-size: 17px;
  font-weight: 700;
}

.chart-head h2 small {
  margin-left: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}

.tabs {
  display: inline-flex;
  padding: 3px;
  border-radius: 10px;
  background: var(--surface-2);
}

.tabs button {
  border: 0;
  padding: 6px 12px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.tabs button[aria-selected="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgb(15 23 42 / 10%);
}

.tabs button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.chart-wrap {
  position: relative;
  height: 340px;
}

@media (max-width: 600px) {
  .chart-wrap { height: 260px; }
  .chart-head h2 { flex-basis: 100%; }
}

body.embed { background: var(--surface); }
body.embed .chart-wrap { height: 100vh; padding: 8px; }

/* ad */

.ad { margin-bottom: 16px; min-height: 0; }
/* AdSense marks slots it could not fill; don't leave a blank hole. */
.ad ins.adsbygoogle[data-ad-status="unfilled"] { display: none !important; }

/* footer */

.site-footer {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
}

.donate h2 { margin: 0 0 8px; font-size: 14px; color: var(--text); }
.donate ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }

.donate li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
}

.donate code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: var(--text);
  word-break: break-all;
}

.copy {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 8px;
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.copy:hover { color: var(--text); }
.copyright { margin: 16px 0 0; font-size: 12px; }
.empty { padding: 40px 0; text-align: center; color: var(--muted); }

/* Phones: keep two columns so the chart stays near the top; compact the cards. */
@media (max-width: 480px) {
  .coins { gap: 8px; }
  .coin { padding: 12px; }
  .coin-head { flex-wrap: wrap; gap: 4px 6px; }
  .coin-badge { min-width: 0; height: 20px; font-size: 10px; }
  .coin-name { font-size: 12px; }
  .pill { margin-left: 0; font-size: 11px; padding: 1px 6px; }
  .coin-price { margin: 8px 0 8px; font-size: clamp(14px, 4vw, 17px); letter-spacing: -0.03em; }
  .coin-rows { font-size: 12px; padding-top: 8px; }
  .coin-row dt .label { display: none; }
  .coin-row.premium dt { font-size: 11px; }
  .site-header .updated { font-size: 11px; padding: 4px 10px; }
  .brand small { display: none; }
}
