/* ===== CSS Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-card: #1c2333;
  --bg-hover: #242d3d;
  --border: #30363d;
  --border-light: #21262d;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;
  --accent: #F7931A;
  --accent-dim: rgba(247, 147, 26, 0.15);
  --accent-glow: rgba(247, 147, 26, 0.3);
  --green: #3fb950;
  --green-dim: rgba(63, 185, 80, 0.15);
  --red: #f85149;
  --red-dim: rgba(248, 81, 73, 0.15);
  --blue: #58a6ff;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 4px 12px rgba(0,0,0,0.2);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --max-width: 1100px;
}

html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
}

/* ===== Header ===== */
.site-header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
  font-weight: 700;
  font-size: 1.1rem;
  text-decoration: none;
}
.logo:hover { text-decoration: none; }

.main-nav {
  display: flex;
  gap: 24px;
}

.main-nav a {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  transition: color 0.2s;
}
.main-nav a:hover { color: var(--text-primary); text-decoration: none; }

/* ===== Hero / Price Section ===== */
.hero-section {
  padding: 48px 0 40px;
  background: linear-gradient(180deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
}

.price-hero {
  text-align: center;
  max-width: 600px;
  margin: 0 auto;
}

.price-label {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 8px;
  letter-spacing: 0.5px;
}

.price-display {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 2px;
  margin-bottom: 12px;
}

.currency-symbol {
  font-size: 2rem;
  font-weight: 300;
  color: var(--accent);
  margin-top: 8px;
}

.price-value {
  font-size: 4rem;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  letter-spacing: -1px;
  line-height: 1;
}

.price-change {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 12px;
}

.price-change.up {
  background: var(--green-dim);
  color: var(--green);
}

.price-change.down {
  background: var(--red-dim);
  color: var(--red);
}

.change-icon { font-size: 0.8rem; }

.price-updated {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-bottom: 24px;
}

.hero-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s;
  font-family: var(--font);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover { background: #e07d0e; text-decoration: none; }

.btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--bg-hover); color: var(--text-primary); text-decoration: none; }

/* ===== Section Styles ===== */
.section-header {
  margin-bottom: 24px;
}

.section-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.section-subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* ===== Chart Section ===== */
.chart-section {
  padding: 40px 0;
}

.chart-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.tf-btn {
  padding: 6px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font);
}

.tf-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.tf-btn.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: var(--accent);
}

.chart-wrapper {
  position: relative;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  overflow: hidden;
}

#price-chart {
  width: 100%;
  height: auto;
  display: block;
}

.chart-tooltip {
  position: absolute;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 0.8rem;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 10;
  box-shadow: var(--shadow);
}

.chart-tooltip.visible { opacity: 1; }
.tooltip-date { display: block; color: var(--text-muted); }
.tooltip-price { display: block; color: var(--text-primary); font-weight: 700; font-size: 0.9rem; }

.chart-legend {
  margin-top: 12px;
  display: flex;
  gap: 16px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
}

/* ===== Stats Section ===== */
.stats-section {
  padding: 32px 0;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

/* ===== Snapshots Section ===== */
.snapshots-section {
  padding: 48px 0;
}

.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.snapshot-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.snapshot-table th {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-weight: 600;
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.snapshot-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
}

.snapshot-table tr:last-child td { border-bottom: none; }
.snapshot-table tr:hover td { background: var(--bg-hover); }

.price-cell {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

.snapshot-note {
  margin-top: 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ===== Mistakes Section ===== */
.mistakes-section {
  padding: 48px 0;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
}

.mistakes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
}

.mistake-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: border-color 0.2s;
}

.mistake-card:hover { border-color: var(--accent); }

.mistake-icon {
  font-size: 1.5rem;
  margin-bottom: 12px;
}

.mistake-card h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.mistake-card p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ===== Glossary Section ===== */
.glossary-section {
  padding: 48px 0;
}

.glossary-list {
  display: grid;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.glossary-item {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-light);
}

.glossary-item:last-child { border-bottom: none; }

.glossary-item dt {
  font-weight: 700;
  font-size: 1rem;
  color: var(--accent);
  margin-bottom: 4px;
}

.glossary-item dd {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ===== Storage Section ===== */
.storage-section {
  padding: 48px 0;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
}

.storage-card {
  display: flex;
  align-items: center;
  gap: 32px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
}

.storage-content { flex: 1; }

.storage-content h2 {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.storage-content p {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 8px;
}

.storage-note {
  color: var(--text-muted) !important;
  font-size: 0.85rem !important;
}

.storage-icon {
  flex-shrink: 0;
  color: var(--accent);
}

/* ===== Footer ===== */
.site-footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 40px 0 24px;
}

.footer-top {
  display: flex;
  justify-content: space-between;
  gap: 40px;
  flex-wrap: wrap;
  margin-bottom: 32px;
}

.footer-brand { max-width: 280px; }
.footer-brand .logo { margin-bottom: 8px; }
.footer-brand p { font-size: 0.85rem; color: var(--text-muted); }

.footer-links {
  display: flex;
  gap: 40px;
  flex-wrap: wrap;
}

.footer-col h4 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.footer-col a {
  display: block;
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-decoration: none;
}
.footer-col a:hover { color: var(--text-primary); text-decoration: underline; }

.footer-bottom {
  border-top: 1px solid var(--border);
  padding-top: 20px;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .site-header .container { height: 52px; }
  .main-nav { gap: 16px; }
  .main-nav a { font-size: 0.8rem; }
  .price-value { font-size: 2.8rem; }
  .currency-symbol { font-size: 1.4rem; }
  .hero-section { padding: 32px 0 28px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .mistakes-grid { grid-template-columns: 1fr; }
  .storage-card { flex-direction: column; text-align: center; }
  .footer-top { flex-direction: column; gap: 24px; }
  .footer-links { gap: 24px; }
}

@media (max-width: 480px) {
  .price-value { font-size: 2.2rem; }
  .hero-actions { flex-direction: column; align-items: center; }
  .btn { width: 100%; justify-content: center; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 12px; }
  .stat-value { font-size: 1rem; }
}

/* ===== Print Styles ===== */
@media print {
  body { background: #fff; color: #000; }
  .site-header, .site-footer, .chart-controls, .hero-actions, .storage-section, .mistakes-section, .glossary-section { display: none; }
  .hero-section { background: none; padding: 20px 0; }
  .price-value { color: #000; font-size: 2.5rem; }
  .price-label, .price-updated { color: #666; }
  .stats-section { background: none; border: none; padding: 16px 0; }
  .stat-card { border: 1px solid #ddd; background: #f9f9f9; }
  .stat-value { color: #000; }
  .snapshots-section { padding: 16px 0; }
  .snapshot-table th { background: #f0f0f0; color: #333; }
  .snapshot-table td { color: #000; }
  .price-cell { color: #F7931A; }
  .chart-wrapper { border: 1px solid #ddd; }
}

/* ===== Focus Styles ===== */
*:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }


/* Factory-injected deployment helpers. The AI owns the site design above this block. */
.ad-unit {
  width: min(100%, 720px);
  min-height: 120px;
  margin: 24px auto;
  display: block;
}

.legal-page {
  width: min(900px, calc(100% - 32px));
  margin: 40px auto;
}

.factory-fallback-nav {
  width: min(900px, calc(100% - 32px));
  margin: 24px auto 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  font-size: 0.95rem;
}

.factory-fallback-nav a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid currentColor;
}
