:root {
  --bg-main: #09090b;
  --bg-card: #141417;
  --bg-subtle: #1c1c21;
  --border: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(139, 92, 246, 0.4);
  --text-main: #f4f4f5;
  --text-muted: #a1a1aa;
  --text-subtle: #71717a;
  --primary: #8b5cf6;
  --primary-hover: #7c3aed;
  --primary-glow: rgba(139, 92, 246, 0.25);
  --accent-cyan: #06b6d4;
  --accent-amber: #f59e0b;
  --accent-emerald: #10b981;
  --accent-rose: #f43f5e;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.45;
  font-size: 13px;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.insights-container {
  max-width: 100%;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Header & Tabs */
.insights-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

.brand-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.01em;
}

.icon-sparkle {
  color: var(--primary);
  font-size: 14px;
}

.tab-nav {
  display: flex;
  gap: 4px;
  background: var(--bg-card);
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.tab-btn:hover {
  color: var(--text-main);
}

.tab-btn.active {
  background: var(--bg-subtle);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* Panels */
.tab-panel {
  display: none;
  animation: fadeIn 0.2s ease forwards;
}

.tab-panel.active {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Prompt Card */
.prompt-card {
  background: linear-gradient(145deg, rgba(28, 28, 35, 0.6) 0%, rgba(20, 20, 24, 0.8) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  position: relative;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.prompt-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  flex-wrap: wrap;
  gap: 6px;
}

.badge {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(139, 92, 246, 0.15);
  color: #a78bfa;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid rgba(139, 92, 246, 0.3);
}

.theme-tag {
  font-size: 11px;
  color: var(--text-subtle);
}

.prompt-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.select-filter {
  background: var(--bg-card);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 11px;
  padding: 2px 6px;
  cursor: pointer;
  outline: none;
}

.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 2px 8px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.icon-btn:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.2);
}

.prompt-quote {
  font-size: 13.5px;
  font-weight: 500;
  color: #ececee;
  line-height: 1.4;
  letter-spacing: -0.01em;
  border-left: 2px solid var(--primary);
  padding-left: 10px;
  margin: 4px 0 2px 0;
}

/* Check-in Form */
.checkin-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.group-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-subtle);
}

/* Mood Selector */
.mood-selector {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.mood-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 6px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.mood-btn .emoji {
  font-size: 16px;
}

.mood-btn .label {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 500;
}

.mood-btn:hover {
  border-color: rgba(255, 255, 255, 0.2);
  background: var(--bg-subtle);
}

.mood-btn.active {
  border-color: var(--primary);
  background: rgba(139, 92, 246, 0.12);
  box-shadow: 0 0 10px var(--primary-glow);
}

.mood-btn.active .label {
  color: #fff;
  font-weight: 600;
}

/* Energy Slider */
.energy-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.energy-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-cyan);
}

.energy-slider {
  width: 100%;
  accent-color: var(--accent-cyan);
  cursor: pointer;
  margin: 2px 0;
}

.slider-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 9.5px;
  color: var(--text-subtle);
}

/* Notes Textarea */
.notes-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.subtle-count {
  font-size: 10px;
  color: var(--text-subtle);
}

.reflection-textarea {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-main);
  padding: 8px 10px;
  font-size: 12px;
  font-family: inherit;
  resize: vertical;
  min-height: 52px;
  outline: none;
  transition: border-color 0.15s ease;
}

.reflection-textarea:focus {
  border-color: var(--border-focus);
}

/* Actions Row */
.form-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
  border: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px var(--primary-glow);
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--bg-subtle);
  color: var(--text-main);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  border-color: rgba(255, 255, 255, 0.25);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover {
  color: var(--text-main);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 11px;
}

.save-status {
  font-size: 11px;
  min-height: 14px;
  font-weight: 500;
  transition: opacity 0.2s ease;
}

.save-status.success {
  color: var(--accent-emerald);
}

/* Add Custom Prompt Modal */
.add-prompt-panel {
  margin-top: 8px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px;
}

.add-prompt-panel.hidden {
  display: none;
}

.add-prompt-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.add-prompt-header h4 {
  font-size: 12px;
  font-weight: 600;
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-subtle);
  font-size: 16px;
  cursor: pointer;
}

.text-input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  padding: 5px 8px;
  font-size: 11px;
  margin-bottom: 6px;
  outline: none;
}

.input-row {
  display: flex;
  gap: 6px;
}

/* Tab 2: Trajectory & Chart */
.trends-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.timeframe-toggle {
  display: flex;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 2px;
  border: 1px solid var(--border);
}

.timeframe-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  cursor: pointer;
}

.timeframe-btn.active {
  background: var(--bg-subtle);
  color: #fff;
  font-weight: 600;
}

.chart-legend-custom {
  display: flex;
  gap: 10px;
  font-size: 11px;
  color: var(--text-muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.dot-mood { background: var(--accent-cyan); }
.dot-energy { background: var(--accent-amber); }

.chart-wrapper {
  position: relative;
  height: 160px;
  width: 100%;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 8px;
  border: 1px solid var(--border);
}

.mood-breakdown-row {
  display: flex;
  justify-content: space-around;
  padding: 6px;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  font-size: 11px;
}

.breakdown-chip {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Tab 3: KPI & Heatmap */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

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

.kpi-icon {
  font-size: 20px;
}

.kpi-content {
  display: flex;
  flex-direction: column;
}

.kpi-number {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.1;
  color: #fff;
}

.kpi-label {
  font-size: 10px;
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.heatmap-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.section-title {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.heatmap-grid {
  display: grid;
  grid-template-columns: repeat(15, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 4px;
}

.heatmap-cell {
  aspect-ratio: 1;
  border-radius: 3px;
  background: var(--bg-subtle);
  transition: transform 0.1s ease;
  position: relative;
}

.heatmap-cell:hover {
  transform: scale(1.15);
  z-index: 10;
}

.heatmap-cell.lvl-0 { background: #1c1c24; }
.heatmap-cell.lvl-1 { background: #3b1d6e; }
.heatmap-cell.lvl-2 { background: #6d28d9; }
.heatmap-cell.lvl-3 { background: #8b5cf6; box-shadow: 0 0 6px var(--primary-glow); }

.heatmap-legend {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  font-size: 10px;
  color: var(--text-subtle);
}

.heatmap-legend .cell {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}
.heatmap-legend .lvl-0 { background: #1c1c24; }
.heatmap-legend .lvl-1 { background: #3b1d6e; }
.heatmap-legend .lvl-2 { background: #6d28d9; }
.heatmap-legend .lvl-3 { background: #8b5cf6; }
