:root {
  color-scheme: light;
  --bg: #f3f6fa;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #657382;
  --line: #d9e2ec;
  --accent: #0c63ce;
  --green: #0b8f5a;
  --red: #cf3434;
  --amber: #a66b00;
  --shadow: 0 14px 38px rgba(28, 45, 72, 0.11);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(12, 99, 206, 0.1), transparent 300px),
    var(--bg);
  color: var(--ink);
  font-family:
    "Pretendard",
    "Noto Sans KR",
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

button {
  font: inherit;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 44px;
}

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

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 1.08;
}

.toolbar {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.8);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 5px rgba(11, 143, 90, 0.12);
}

#refreshButton,
.range-tabs button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fafc;
  color: var(--ink);
  cursor: pointer;
  font-weight: 750;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease;
}

#refreshButton {
  padding: 0 12px;
}

#refreshButton:hover,
.range-tabs button:hover,
.range-tabs button.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

#refreshButton:disabled {
  cursor: progress;
  opacity: 0.55;
}

.summary {
  display: grid;
  grid-template-columns: 1.35fr 1fr 0.65fr;
  gap: 12px;
  margin-bottom: 18px;
}

.summary div,
.market-card,
.chart-workspace {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.summary div {
  display: flex;
  min-height: 72px;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  padding: 14px 16px;
}

.summary span,
.region,
.source,
.meta-row,
.note {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
}

.summary strong {
  font-size: 0.96rem;
}

.market-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.market-card {
  display: flex;
  min-height: 178px;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  padding: 18px;
  cursor: pointer;
  transition:
    border-color 160ms ease,
    transform 160ms ease,
    box-shadow 160ms ease;
}

.market-card:hover,
.market-card.active {
  border-color: rgba(12, 99, 206, 0.55);
  box-shadow: 0 15px 30px rgba(12, 99, 206, 0.12);
  transform: translateY(-2px);
}

.card-top,
.price-row,
.meta-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.region,
.source {
  display: block;
  text-transform: uppercase;
}

.source {
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fafc;
  white-space: nowrap;
}

.market-card h2 {
  margin-top: 7px;
  font-size: 1.12rem;
  line-height: 1.25;
}

.price-row {
  align-items: flex-end;
}

.price {
  font-size: clamp(1.8rem, 4vw, 2.35rem);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.change {
  padding-bottom: 3px;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 800;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.change[data-direction="up"] {
  color: var(--red);
}

.change[data-direction="down"] {
  color: var(--accent);
}

.note {
  padding-top: 8px;
  border-top: 1px solid var(--line);
  color: var(--amber);
}

.chart-workspace {
  min-height: 590px;
  padding: 18px;
}

.chart-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.chart-header h2 {
  font-size: 1.55rem;
}

.range-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.range-tabs button {
  min-width: 58px;
  padding: 0 12px;
}

.chart {
  display: grid;
  width: 100%;
  height: 500px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.loading {
  color: var(--muted);
  font-weight: 750;
}

.loading.error {
  color: var(--red);
}

.line-chart {
  width: 100%;
  height: 100%;
}

.grid-line,
.axis-line {
  fill: none;
  stroke: #e8eef5;
  stroke-width: 1;
}

.axis-line {
  stroke: #d9e2ec;
}

.area {
  fill: rgba(11, 143, 90, 0.11);
}

.line {
  fill: none;
  stroke: var(--green);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 4;
}

.line-chart.down .area {
  fill: rgba(12, 99, 206, 0.11);
}

.line-chart.down .line {
  stroke: var(--accent);
}

.axis {
  fill: var(--muted);
  font-size: 16px;
  font-weight: 700;
}

.y-axis {
  text-anchor: end;
  font-variant-numeric: tabular-nums;
}

.axis.end {
  text-anchor: end;
}

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

@media (max-width: 680px) {
  .shell {
    width: min(100% - 20px, 1180px);
    padding-top: 18px;
  }

  .topbar,
  .chart-header {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar {
    align-self: flex-start;
    flex-wrap: wrap;
  }

  .summary,
  .market-grid {
    grid-template-columns: 1fr;
  }

  .market-card {
    min-height: 164px;
    padding: 15px;
  }

  .price {
    font-size: 2rem;
  }

  .price-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .change {
    text-align: left;
  }

  .chart-workspace {
    min-height: 520px;
    padding: 12px;
  }

  .chart {
    height: 400px;
  }

  .range-tabs {
    justify-content: stretch;
  }

  .range-tabs button {
    flex: 1 1 72px;
  }
}



  .top-menu {
    position: sticky;
    top: 0;
    z-index: 1000;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    background: #111827;
    color: #fff;
    border-bottom: 1px solid #374151;
  }

  .top-menu .menu-right {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
  }

  .top-menu a {
    color: #e5e7eb;
    text-decoration: none;
    padding: 4px 8px;
    border-radius: 4px;
  }

  .top-menu a:hover {
    background: #374151;
    color: #fff;
  }





  .notice-footer {
    margin-top: 24px;
    padding: 16px;
    border-top: 1px solid #ddd;
    background: #f9fafb;
  }

  .notice-footer h3 {
    margin: 0 0 10px;
    font-size: 16px;
    font-weight: 600;
  }

  .notice-box {
    width: 100%;
    min-height: 120px;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 8px;
    resize: vertical;
    font-size: 14px;
    box-sizing: border-box;
  }
