:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-border: rgba(15, 23, 42, 0.06);
  --text: #111827;
  --muted: rgba(17, 24, 39, 0.55);
  --positive: #22c55e;
  --negative: #ef4444;
  --dot: #f97316;
  --font: "Inter", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.viewport {
  max-width: 1100px;
  margin: 0 auto;
  padding: 48px 32px 64px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.header h1 {
  margin: 0;
  font-size: 30px;
  font-weight: 700;
}

.header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.selectors {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.selectors label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.selectors select {
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--surface-border);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  min-width: 200px;
  outline: none;
}

.selectors select:focus {
  border-color: rgba(34, 197, 94, 0.45);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18);
}

.chart-card {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 28px;
  padding: 28px 32px 36px;
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.08);
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.chart-meta {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
}

#portfolio-value {
  margin: 0;
  font-size: 38px;
  font-weight: 700;
}

#portfolio-change {
  margin: 6px 0 0;
  font-size: 15px;
  color: var(--muted);
}

.horizons {
  display: flex;
  gap: 12px;
}

.horizons button {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 18px;
  padding: 6px 16px;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.horizons button.active {
  color: var(--positive);
  border-color: rgba(34, 197, 94, 0.25);
  background: rgba(34, 197, 94, 0.12);
}

.chart-wrapper {
  position: relative;
  height: 440px;
}

#portfolio-chart {
  width: 100%;
  height: 100%;
}

.chart-tooltip {
  position: absolute;
  pointer-events: auto;
  min-width: 320px;
  max-width: 360px;
  background: #ffffff;
  color: #111827;
  border-radius: 16px;
  border: 1px solid rgba(100, 116, 139, 0.25);
  padding: 16px 18px;
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 20;
  max-height: 320px;
  overflow-y: auto;
}

.chart-tooltip.visible {
  opacity: 1;
}

.chart-tooltip h4 {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 600;
}

.chart-tooltip ul {
  margin: 0;
  padding-left: 0;
  list-style: none;
  font-size: 13px;
}

.chart-tooltip hr {
  border: none;
  border-top: 1px solid rgba(148, 163, 184, 0.3);
  margin: 12px 0;
}

.tooltip-episode h4 {
  margin-bottom: 8px;
}

.chart-tooltip a {
  color: #1d4ed8;
  text-decoration: underline;
}

.tooltip-action {
  margin-bottom: 6px;
}

.tooltip-action-btn {
  pointer-events: auto;
  background: none;
  border: none;
  color: #111827;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  width: 100%;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.18s ease;
}

.tooltip-action-btn:hover,
.tooltip-action-btn:focus {
  background: rgba(148, 163, 184, 0.2);
}

.tooltip-rationale-wrapper {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.2s ease;
  pointer-events: none;
}

.tooltip-rationale-wrapper.expanded {
  max-height: 200px;
  pointer-events: auto;
}

.tooltip-rationale {
  margin: 6px 8px 0;
  color: #475569;
  font-size: 12px;
  line-height: 1.4;
}

.tooltip-hold {
  padding: 4px 6px 0;
  font-size: 13px;
  font-weight: 600;
  color: #1f2937;
}

.episodes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-top: 18px;
}

.channel-info-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
}

.channel-info-row .episode-card {
  height: 100%;
}

.episode-card {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 18px;
  padding: 20px 24px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.06);
}

.channel-summary-card {
  grid-column: 1 / -1;
}

.latest-episode-card {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%);
  border: 2px solid #3b82f6;
  border-radius: 18px;
  padding: 24px 28px;
  box-shadow: 0 20px 60px rgba(59, 130, 246, 0.12);
}

.latest-episode-header {
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(59, 130, 246, 0.2);
}

.latest-episode-header h3 {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 700;
  color: #1e293b;
}

.latest-episode-header h3 a {
  color: #3b82f6;
  text-decoration: none;
  transition: color 0.2s ease;
}

.latest-episode-header h3 a:hover,
.latest-episode-header h3 a:focus {
  color: #2563eb;
  text-decoration: underline;
}

.latest-episode-date {
  font-size: 13px;
  color: #64748b;
  font-weight: 500;
}

.latest-episode-stocks {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.latest-stock-item {
  padding: 14px 18px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  transition: all 0.2s ease;
}

.latest-stock-item:hover {
  border-color: #cbd5e1;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}

.latest-stock-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.latest-stock-symbol {
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
  font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
}

.latest-stock-sentiment {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.latest-stock-sentiment[data-tone="bullish"] {
  background: #dcfce7;
  color: #15803d;
}

.latest-stock-sentiment[data-tone="bearish"] {
  background: #fee2e2;
  color: #991b1b;
}

.latest-stock-sentiment[data-tone="neutral"] {
  background: #f1f5f9;
  color: #475569;
}

.latest-stock-confidence {
  font-size: 13px;
  color: #64748b;
  font-weight: 500;
}

.latest-stock-rationale {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  color: #475569;
}

.channel-summary-body p {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
}

.channel-summary-list {
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px 18px;
}

.channel-summary-item {
  background: rgba(15, 23, 42, 0.03);
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  padding: 12px 16px;
}

.channel-summary-symbol {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  color: #0f172a;
  margin-bottom: 6px;
}

.channel-summary-tag {
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.16);
  color: #1d4ed8;
}

.channel-summary-tag[data-tone="bearish"] {
  background: rgba(239, 68, 68, 0.16);
  color: #b91c1c;
}

.channel-summary-tag[data-tone="neutral"] {
  background: rgba(148, 163, 184, 0.18);
  color: #475569;
}

.channel-summary-metrics {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

.episode-card h3 {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 600;
}

.episode-card h3 a {
  color: inherit;
  text-decoration: none;
}

.episode-card h3 a:hover,
.episode-card h3 a:focus {
  text-decoration: underline;
}

.episode-card p {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
}

@media (max-width: 768px) {
  .viewport {
    padding: 36px 20px 48px;
  }
  .header {
    flex-direction: column;
    align-items: flex-start;
  }
  .chart-wrapper {
    height: 360px;
  }
  .channel-info-row {
    grid-template-columns: 1fr;
  }
}
