:root {
  --bg: #0b0e14;
  --bg-elev: #141925;
  --bg-card: #171d2b;
  --border: #232a3b;
  --text: #e6e9f0;
  --text-dim: #8b93a7;
  --text-faint: #5a6276;
  --up: #ff4d5e;     /* 한국식: 상승 빨강 */
  --down: #3b82f6;   /* 한국식: 하락 파랑 */
  --flat: #8b93a7;
  --accent: #f0b90b; /* 바이낸스 옐로 */
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo",
    "Malgun Gothic", "Noto Sans KR", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

/* 면책 배너 */
.disclaimer {
  position: sticky;
  top: 0;
  z-index: 50;
  background: linear-gradient(90deg, #2a1d0a, #2a160a);
  border-bottom: 1px solid #4a3410;
  color: #f4d9a0;
  font-size: 13px;
  padding: 8px 16px;
  padding-top: calc(8px + env(safe-area-inset-top));
  text-align: center;
}
.disclaimer strong { color: var(--accent); }

/* 헤더 */
.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 20px 12px;
}
/* 붓글씨 로고 */
.logo-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1;
}
.logo-img {
  height: 70px; /* 100px 이미지를 70px display */
  width: auto;
  object-fit: contain;
}
.logo-kr {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: -0.5px;
  line-height: 1;
}
.logo-en {
  font-size: 13px;
  font-style: italic;
  color: var(--text-faint);
  letter-spacing: 0.12em;
  margin-top: 4px;
  min-height: 18px;
}
.tagline {
  margin: 8px 0 0;
  color: var(--text-dim);
  font-size: 17px;
}

/* 시계 / 장 상태 */
.clock {
  text-align: right;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 18px;
  min-width: 220px;
}
.clock-time {
  font-size: 24px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}
.clock-status {
  margin-top: 2px;
  font-size: 13px;
  font-weight: 600;
}
.clock-status.open { color: var(--up); }
.clock-status.closed { color: var(--text-dim); }
.clock-countdown {
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 12px 20px 40px;
}

/* 2:1 레이아웃 */
.layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  align-items: start;
}

/* 카드 열 */
.cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

/* 사이드바 */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 52px; /* 면책 배너 높이 */
}
.sidebar-block {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
}
.sidebar-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  margin-bottom: 8px;
}
.sidebar-note {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--text-faint);
  line-height: 1.6;
}
.sidebar-note strong { color: var(--text-dim); }
.sidebar .fx-value {
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.sidebar .fx-updated {
  font-size: 12px;
  color: var(--text-faint);
  margin-top: 2px;
}
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.card.error { opacity: 0.7; }

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.card-name {
  font-size: 18px;
  font-weight: 700;
}
.card-symbol {
  font-size: 12px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.card-body > .card-implied:first-child { margin-top: 14px; }
.card-implied {
  font-size: 38px;
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.card-implied .unit { font-size: 18px; color: var(--text-dim); margin-left: 4px; }

.card-delta {
  margin-top: 6px;
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.up { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--flat); }

/* 마감 후 추이 스파크라인 */
.card-spark { margin-top: 14px; }
/* 왼쪽 고가·저가 축 + 차트 — 라벨이 라인과 겹치지 않도록 영역을 분리 */
.spark-plot {
  display: flex;
  align-items: stretch;
  gap: 8px;
}
.card-spark svg {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  height: 56px;
}
.spark-line {
  fill: none;
  stroke: currentColor; /* svg 의 .up/.down/.flat 색을 따라감 */
  stroke-width: 1.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.spark-base {
  stroke: var(--text-faint);
  stroke-width: 1;
  stroke-dasharray: 3 3;
  opacity: 0.55;
}
.spark-dot {
  stroke: currentColor;
  stroke-width: 5;
  stroke-linecap: round;
}
.spark-axis {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex-shrink: 0;
  padding: 1px 0;
  font-size: 10px;
  line-height: 1;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.spark-caption {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-faint);
}

.card-divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0 12px;
}
.card-rows { display: grid; gap: 10px; }
.card-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  font-size: 13px;
}
.card-row .k {
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: var(--text-dim);
  white-space: nowrap;
  flex-shrink: 0;
}
.card-row .k small {
  font-size: 11px;
  color: var(--text-faint);
}
.card-row .v {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  word-break: break-all;
}
.card-row .v .v-usdt {
  font-size: 11px;
  color: var(--text-faint);
}

.card-error-msg {
  margin-top: 16px;
  font-size: 14px;
  color: var(--text-dim);
}

/* 가격·등락 + 토글을 같은 레벨(한 줄)에 배치 */
.card-implied-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}

/* 카드 접기/펼치기 */
.card-toggle {
  display: flex;
  align-items: center;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-faint);
  padding: 6px;
  margin-right: -6px;
  flex-shrink: 0;
}
.card-toggle:hover { color: var(--text-dim); }
.card-toggle .chevron {
  display: inline-block;
  transition: transform 0.25s ease;
  font-size: 18px;
  line-height: 1;
}
.card-toggle.open .chevron { transform: rotate(180deg); }

.card-detail {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.3s ease, opacity 0.25s ease;
  opacity: 0;
}
.card-detail.open {
  max-height: 480px; /* 마감 후 저·고 행 포함 */
  opacity: 1;
}

.refresh { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-dim); margin-top: 8px; }
.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-faint);
  transition: background 0.2s;
  flex-shrink: 0;
}
.dot.live { background: #22c55e; box-shadow: 0 0 8px #22c55e88; }
.dot.error { background: var(--up); }

.formula {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: #0e1320;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 12px;
  line-height: 1.7;
  margin: 0;
}

.site-footer {
  max-width: 1080px;
  margin: 0 auto;
  padding: 8px 20px 32px;
  color: var(--text-faint);
  font-size: 12px;
  text-align: center;
}
.site-footer p { margin: 4px 0; }
.site-footer a { color: var(--text-faint); text-decoration: underline; }
.site-footer a:hover { color: var(--text-dim); }

@media (max-width: 680px) {
  .site-header { padding-top: 20px; }
  .clock { width: 100%; text-align: left; }
  .card-implied { font-size: 32px; }
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .logo-img { height: 56px; }
  .logo-kr { font-size: 22px; }
}
