:root {
  color-scheme: dark;
  --bg: #101214;
  --panel: #1c1e22;
  --line: #34373d;
  --muted: #90949c;
  --subtle: #737780;
  --text: #f7f7f4;
  --gold: #e0b74a;
  --gold-soft: #f4e0a0;
  --rise: #ff6573;
  --fall: #42d392;
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button { font: inherit; }

.page {
  width: min(100%, 720px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 26px 16px 36px;
}

.topbar,
.panel-topline,
.chart-title-row,
.news-heading,
.expanded-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar { margin-bottom: 16px; }

.eyebrow,
.section-kicker {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 1.8px;
}

h1,
h2,
p { margin-top: 0; }

h1 { margin-bottom: 0; font-size: 22px; }
h2 { margin-bottom: 0; font-size: 18px; }

.status {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #a5a9b1;
  font-size: 13px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--fall);
}

.status-dot.updating { background: var(--gold); }
.status-dot.offline { background: var(--rise); }

.quote-panel,
.chart-panel,
.news-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.quote-panel { padding: 20px; }

.section-kicker { margin-bottom: 0; }

.updated {
  margin: 4px 0 0;
  color: var(--subtle);
  font-size: 11px;
}

.icon-button {
  display: inline-grid;
  width: 36px;
  height: 36px;
  place-items: center;
  padding: 0;
  border: 1px solid var(--gold);
  border-radius: 50%;
  background: var(--gold);
  color: var(--bg);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}

.icon-button:disabled { opacity: .5; cursor: wait; }
.icon-button:active { transform: scale(.94); }

.price-line {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-top: 22px;
}

.main-price {
  color: var(--text);
  font-size: clamp(42px, 13vw, 72px);
  font-weight: 700;
  line-height: 1;
}

.unit { color: var(--muted); font-size: 13px; }

.quote-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  color: #aeb2ba;
  font-size: 13px;
}

.rise { color: var(--rise) !important; }
.fall { color: var(--fall) !important; }
.flat { color: #aeb2ba; }

.chart-panel,
.news-panel { margin-top: 16px; padding: 18px 12px 16px; }

.chart-heading { min-width: 0; }
.chart-title-row { min-width: 0; align-items: baseline; }
.chart-title-row h2 { white-space: nowrap; }

.chart-stats {
  display: flex;
  min-width: 0;
  align-items: baseline;
  gap: 10px;
  overflow: hidden;
  white-space: nowrap;
  font-size: 12px;
}

.selected-point {
  overflow: hidden;
  color: var(--gold-soft);
  text-overflow: ellipsis;
}

.opening-price {
  margin: 6px 0 0;
  color: var(--subtle);
  font-size: 12px;
}

.period-tabs {
  display: flex;
  gap: 4px;
  margin: 16px 0 8px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.period-tab {
  flex: 1;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  line-height: 28px;
}

.period-tab.active { background: var(--gold-soft); color: var(--bg); }

.canvas-wrap { width: 100%; height: 270px; }
#trendCanvas { display: block; width: 100%; height: 100%; touch-action: none; }

.chart-status,
.chart-source {
  min-height: 18px;
  margin: 7px 0 0;
  padding: 0 6px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.chart-status { color: var(--gold); }

.news-heading { align-items: end; margin-bottom: 12px; }
.news-filter { color: var(--gold); font-size: 12px; }
.news-list { border-top: 1px solid var(--line); }

.news-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
  padding: 12px 4px;
  border-bottom: 1px solid #2a2d32;
  cursor: pointer;
}

.news-item:active { opacity: .65; }
.news-topic { flex: 0 0 auto; color: var(--muted); font-size: 11px; }
.news-title { min-width: 0; overflow: hidden; color: #d8dbe0; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }

.news-expanded { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.expanded-topic { color: var(--gold); font-size: 13px; }
.expanded-content { margin: 12px 0 0; color: #d8dbe0; font-size: 15px; line-height: 1.7; overflow-wrap: anywhere; }
.text-button { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 12px; }
.empty-state { margin: 0; padding: 16px 4px; color: var(--subtle); font-size: 13px; }
.notice { margin: 16px 0 0; color: var(--gold); font-size: 13px; text-align: center; }
.footer { margin-top: 22px; color: var(--subtle); font-size: 11px; text-align: center; }

@media (max-width: 380px) {
  .page { padding-inline: 12px; }
  .quote-panel { padding: 16px; }
  .chart-stats { gap: 6px; font-size: 11px; }
  .canvas-wrap { height: 245px; }
}
