:root {
  --primary: #16a34a;
  --primary-dark: #15803d;
  --primary-dim: rgba(22, 163, 74, 0.08);
  --primary-border: rgba(22, 163, 74, 0.2);
  --bg: #f5f5f3;
  --surface: #ffffff;
  --surface-2: #f0fdf4;
  --border: #e2e8e0;
  --text: #1a1a1a;
  --text-muted: #6b7280;
  --text-light: #9ca3af;
  --green: #15803d;
  --red: #dc2626;
  --blue: #2563eb;
  --radius: 12px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */
header {
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  position: sticky;
  top: 0;
  background: rgba(245, 245, 243, 0.93);
  backdrop-filter: blur(12px);
  z-index: 10;
}
.header-inner {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.logo { display: flex; align-items: center; gap: 12px; }
.logo-icon { font-size: 28px; color: var(--primary); line-height: 1; }
h1 { font-size: 18px; font-weight: 700; color: var(--primary-dark); }
.subtitle { font-size: 12px; color: var(--text-muted); }
.header-meta { display: flex; align-items: center; gap: 8px; }
.last-updated { font-size: 12px; color: var(--text-muted); }

/* ── Main ── */
main {
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 28px 24px 56px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ── Section label ── */
.section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 12px;
}

/* ── Price Cards ── */
.price-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.price-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.price-number {
  font-size: 36px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -1px;
  line-height: 1.1;
  margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
}
.price-card-name {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.price-card-sub {
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 6px;
}
.price-change { font-size: 13px; font-weight: 600; min-height: 18px; }
.price-change.up   { color: var(--green); }
.price-change.down { color: var(--red); }

/* ── Card ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

/* ── Chart ── */
.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.chart-header h2 { font-size: 16px; font-weight: 700; }
.period-toggle { display: flex; gap: 4px; }
.toggle-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  padding: 5px 14px;
  transition: all 0.15s;
}
.toggle-btn:hover { border-color: var(--primary); color: var(--primary-dark); }
.toggle-btn.active { background: var(--primary-dim); border-color: var(--primary); color: var(--primary-dark); }
.chart-wrap { position: relative; height: 360px; }
.chart-empty { text-align: center; color: var(--text-muted); padding: 48px 0; font-size: 14px; }

/* ── AI Section wrapper ── */
#ai-section { display: flex; flex-direction: column; gap: 0; }
.ai-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}
.ai-timestamp { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ── Summary box ── */
.ai-summary-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.ai-summary-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.summary-cards { display: flex; flex-direction: column; gap: 10px; }
.summary-card {
  display: flex;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
}
.summary-card-accent {
  width: 4px;
  border-radius: 4px;
  flex-shrink: 0;
}
.summary-card-body { flex: 1; }
.summary-card-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.4px;
  margin-bottom: 5px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.summary-card-text { font-size: 14px; color: var(--text); line-height: 1.65; }

/* ── Scenarios ── */
.scenarios-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}
.scenario-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.scenario-card.base {
  border-color: var(--blue);
  border-width: 2px;
}
.scenario-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  border-radius: 20px;
  padding: 2px 10px;
  margin-bottom: 10px;
}
.scenario-card.bull .scenario-tag { background: rgba(21,128,61,0.1); color: var(--green); }
.scenario-card.base .scenario-tag { background: rgba(37,99,235,0.1); color: var(--blue); }
.scenario-card.bear .scenario-tag { background: rgba(220,38,38,0.1); color: var(--red); }
.scenario-icon { font-size: 18px; margin-bottom: 6px; display: block; }
.scenario-title { font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.scenario-price {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 10px;
  line-height: 1.1;
}
.scenario-card.bull .scenario-price { color: var(--green); }
.scenario-card.base .scenario-price { color: var(--blue); }
.scenario-card.bear .scenario-price { color: var(--red); }
.scenario-desc { font-size: 13px; color: var(--text-muted); line-height: 1.55; }

/* ── Bottom two-col grid ── */
.bottom-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}

/* ── Timeline ── */
.timeline-col .section-label { margin-bottom: 16px; }
.timeline {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.timeline-item {
  display: flex;
  gap: 14px;
  padding-bottom: 18px;
  position: relative;
}
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 18px;
  bottom: 0;
  width: 2px;
  background: var(--border);
}
.timeline-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
  margin-top: 3px;
  z-index: 1;
}
.timeline-item:first-child .timeline-dot { border-color: var(--primary); background: var(--primary); }
.timeline-item:nth-child(2) .timeline-dot { border-color: var(--primary); }
.timeline-item:nth-child(3) .timeline-dot { border-color: var(--blue); }
.timeline-item:nth-child(4) .timeline-dot { border-color: var(--blue); }
.timeline-item:nth-child(5) .timeline-dot { border-color: var(--text-light); }
.timeline-period { font-size: 12px; color: var(--text-muted); margin-bottom: 3px; }
.timeline-prediction { font-size: 14px; font-weight: 600; color: var(--text); line-height: 1.4; }

/* ── Key Factors ── */
.factors-col .section-label { margin-bottom: 16px; }
.factors-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}
.factor-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.factor-emoji { font-size: 18px; margin-bottom: 6px; display: block; }
.factor-title { font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.factor-detail { font-size: 12px; color: var(--text-muted); line-height: 1.45; }
.spread-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.spread-card-title { font-size: 13px; font-weight: 700; margin-bottom: 8px; color: var(--text); }
.spread-card-body { font-size: 13px; color: var(--text-muted); line-height: 1.55; }
.spread-card-body strong { color: var(--text); }

/* ── AI loading/error ── */
.ai-loading {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  padding: 16px 0;
}
.ai-error {
  background: rgba(220,38,38,0.05);
  border: 1px solid rgba(220,38,38,0.2);
  border-radius: 10px;
  color: var(--red);
  font-size: 14px;
  padding: 14px 18px;
}

/* ── Buttons ── */
.btn-primary {
  background: var(--primary);
  border: none;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  padding: 9px 20px;
  transition: background 0.15s;
  white-space: nowrap;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-icon {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 5px 11px;
  transition: all 0.15s;
}
.btn-icon:hover { border-color: var(--primary); color: var(--primary); }

/* ── Spinner ── */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Footer ── */
footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  padding: 20px 24px;
  border-top: 1px solid var(--border);
}
footer a { color: var(--primary); text-decoration: none; }

/* ── Utils ── */
.hidden { display: none !important; }

/* ── Responsive ── */
@media (max-width: 700px) {
  .price-cards { grid-template-columns: 1fr; }
  .scenarios-grid { grid-template-columns: 1fr; }
  .bottom-grid { grid-template-columns: 1fr; }
  .factors-grid { grid-template-columns: 1fr 1fr; }
  .price-number { font-size: 28px; }
}
