.chart-controls,
.analysis-period-btns,
.notes-range-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  padding: 2px 2px 8px;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: visible;
  scrollbar-width: none;
  -ms-overflow-style: none;
  background: transparent;
}

.chart-controls::-webkit-scrollbar,
.analysis-period-btns::-webkit-scrollbar,
.notes-range-row::-webkit-scrollbar {
  display: none;
}

.chart-btn,
.analysis-period-btn,
.notes-range-btn {
  flex: 0 0 auto;
  position: relative;
  z-index: 1;
}

.range-picker-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: -4px 0 16px;
}

.range-picker-row input[type=date],
.date-picker-row input[type=date],
.notes-date-row input[type=date] {
  width: 100%;
  min-width: 0;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  background: var(--card);
  box-shadow: var(--shadow-sm);
}

.chart-btn,
.analysis-period-btn,
.notes-range-btn {
  padding: 8px 16px;
  border: 2px solid var(--border);
  border-radius: 20px;
  background: var(--card);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  transition: all .2s;
  box-shadow: var(--shadow-sm);
}

.chart-btn.active,
.analysis-period-btn.active,
.notes-range-btn.active {
  background: var(--text);
  color: white;
  border-color: var(--text);
  box-shadow: 0 2px 8px rgba(17,24,39,.2);
}

.ctrl-segment {
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 16px;
  padding: 14px 16px 12px;
  border: 1px solid rgba(0,0,0,.06);
  border-radius: 18px;
  background: var(--card, #fff);
  box-shadow: var(--shadow-sm, 0 2px 8px rgba(0,0,0,.06));
}

.ctrl-segment-label {
  margin-bottom: 10px;
  color: var(--text-secondary, #999);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.ai-segment {
  border-color: rgba(202,166,75,.18);
  box-shadow: 0 2px 10px rgba(154,116,40,.08), inset 0 1px 0 rgba(255,255,255,.8);
}

.ctrl-segment .chart-controls,
.ctrl-segment .analysis-period-btns,
.ctrl-segment .notes-range-row,
.ctrl-segment .notes-date-row,
.ctrl-segment .analysis-ai-actions,
.ctrl-segment .notes-ai-actions {
  margin-bottom: 0;
}

.ctrl-segment .range-picker-row {
  margin-top: 10px;
  margin-bottom: 0;
}

.ctrl-segment .notes-date-row {
  margin-bottom: 10px;
}

.period-select-label {
  margin-bottom: 6px;
  color: var(--text-secondary, #888);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.chart-wrap {
  position: relative;
  overflow: visible;
  margin-bottom: 18px;
}

#chart-canvas {
  width: 100%;
  border-radius: 22px;
  background: var(--card);
  display: block;
  box-shadow: var(--shadow-sm);
  min-height: 220px;
}

.chart-tooltip {
  position: fixed;
  background: var(--text);
  color: white;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  pointer-events: none;
  white-space: nowrap;
  z-index: 1000;
  transform: translate(-50%, calc(-100% - 10px));
  box-shadow: 0 4px 12px rgba(0,0,0,.2);
}

.chart-summary {
  display: block;
  margin-bottom: 14px;
}

.chart-details-card,
.analysis-ai-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-top: 14px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}

.chart-details-title {
  font-size: 14px;
  font-weight: 800;
  margin-bottom: 12px;
}

.chart-details-body {
  font-size: 13px;
  line-height: 1.65;
}

.date-picker-row,
.notes-date-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}

.analysis-ai-actions,
.notes-ai-actions {
  display: flex;
  justify-content: center;
  align-items: stretch;
  gap: 10px;
  margin: 6px 0 16px;
  flex-wrap: wrap;
}

.analysis-ai-btn {
  width: auto;
  min-width: 148px;
  padding: 10px 14px;
  box-shadow: none;
}

.analysis-ai-main-btn {
  background: rgba(17,24,39,.05);
  color: #4b5563;
  border: 1px solid rgba(17,24,39,.08);
  font-size: 12px;
  font-weight: 700;
}

.analysis-ai-pro-btn {
  background: rgba(124,58,237,.08);
  color: #6d28d9;
  border: 1px solid rgba(124,58,237,.18);
  font-size: 12px;
  font-weight: 800;
}

.analysis-ai-btn:disabled {
  opacity: .6;
  cursor: not-allowed;
}

.analysis-ai-title {
  font-size: 15px;
  font-weight: 800;
  margin-bottom: 10px;
}

.analysis-ai-text {
  font-size: 14px;
  line-height: 1.75;
  white-space: pre-wrap;
}

.analysis-score-card {
  margin-bottom: 16px;
  padding: 20px 20px 14px;
  border: 1px solid rgba(202,166,75,.18);
  border-radius: 22px;
  background: var(--card, #fff);
  box-shadow: 0 4px 18px rgba(154,116,40,.10), inset 0 1px 0 rgba(255,255,255,.8);
  text-align: center;
}

.analysis-score-card .analysis-score {
  padding: 0;
  margin-bottom: 4px;
}

.analysis-score-card.positive {
  background: linear-gradient(160deg, rgba(230,255,238,.95), rgba(255,255,255,.9));
  border-color: rgba(34,197,94,.22);
  box-shadow: 0 4px 18px rgba(34,197,94,.10), inset 0 1px 0 rgba(255,255,255,.8);
}

.analysis-score-card.negative {
  background: linear-gradient(160deg, rgba(255,235,235,.95), rgba(255,255,255,.9));
  border-color: rgba(190,60,60,.18);
  box-shadow: 0 4px 18px rgba(190,60,60,.08), inset 0 1px 0 rgba(255,255,255,.8);
}

.analysis-score-card .analysis-date-label {
  margin-bottom: 0;
  text-align: center;
}

.analysis-score {
  font-size: 52px;
  font-weight: 800;
  text-align: center;
  padding: 10px 0 8px;
  line-height: 1;
  letter-spacing: -2px;
}

.analysis-date-label,
.notes-days-count {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--muted);
}

.notes-tabs {
  display: flex;
  margin-bottom: 20px;
  background: linear-gradient(180deg, #fffdf7 0%, #fff9ea 100%);
  border-radius: var(--radius);
  padding: 4px;
  gap: 3px;
  flex-wrap: wrap;
}

.notes-tab {
  flex: 1 1 calc(20% - 3px);
  padding: 10px 4px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  border-radius: 10px;
  transition: all .2s;
}

.notes-tab.active {
  background: #fff3cf;
  color: #6b4d00;
}

.notes-range-btn {
  border-radius: 999px;
}

.notes-recent-block {
  margin-bottom: 16px;
}

.notes-recent-card,
.notes-entry,
.profile-section {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}

.notes-recent-card {
  border-left: 4px solid var(--border);
  cursor: pointer;
  background: linear-gradient(180deg, #fffdf8 0%, #fffaf0 100%);
}

.notes-recent-card.type-diary { border-left-color: #d6aa21; }
.notes-recent-card.type-dreams { border-left-color: #c89f1e; }
.notes-recent-card.type-todayGoals { border-left-color: #d99c1f; }
.notes-recent-card.type-wishes { border-left-color: #e0b832; }
.notes-recent-card.type-ideas { border-left-color: #e7c75a; }

.notes-recent-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.notes-recent-title {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.4;
  flex: 1;
}

.notes-recent-date,
.notes-entry-date {
  font-size: 11px;
  color: var(--muted);
  font-weight: 800;
  margin-top: 8px;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.notes-recent-text {
  display: none;
  margin-top: 12px;
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
}

.notes-recent-card.open .notes-recent-text {
  display: block;
}

.notes-entry-title {
  font-size: 16px;
  font-weight: 800;
  margin: 8px 0;
}

.notes-entry-text {
  font-size: 15px;
  line-height: 1.8;
  white-space: pre-wrap;
}

.chart-summary-grid,
.chart-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.chart-stat {
  position: relative;
  min-width: 0;
  padding: 14px 14px 13px;
  border-radius: 16px;
  border: 1px solid rgba(202,166,75,.16);
  background:
    radial-gradient(circle at top right, rgba(202,166,75,.10), transparent 28%),
    linear-gradient(180deg, rgba(255,250,241,.98) 0%, rgba(247,238,216,.94) 100%);
  box-shadow: 0 10px 22px rgba(56, 39, 10, 0.06);
  overflow: hidden;
}

.chart-stat::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, #d7b86a 0%, #9a7428 48%, #0f6b52 100%);
  opacity: .95;
}

.chart-stat-lbl {
  font-size: 11px;
  line-height: 1.25;
  text-transform: uppercase;
  letter-spacing: .5px;
  font-weight: 800;
  color: #8a6928;
  margin-bottom: 8px;
}

.chart-stat-val {
  font-size: 20px;
  line-height: 1.15;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: #23180c;
  word-break: break-word;
}

.chart-stat-sub {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.5;
  color: #5c4a26;
}

.chart-stat.positive .chart-stat-val,
.chart-stat-val.positive {
  color: #0f6b52;
}

.chart-stat.negative .chart-stat-val,
.chart-stat-val.negative {
  color: #7b2f1b;
}

.chart-stat.neutral .chart-stat-val,
.chart-stat-val.neutral {
  color: #6e6246;
}

@media (max-width: 700px) {
  .notes-tab { flex: 1 1 calc(50% - 3px); }
}

@media (max-width: 640px) {
  .analysis-ai-actions,
  .notes-ai-actions {
    justify-content: stretch;
  }

  .analysis-ai-btn {
    width: 100%;
    min-width: 0;
  }

  .range-picker-row {
    grid-template-columns: 1fr;
  }

  .notes-tab {
    flex: 1 1 calc(50% - 3px);
  }

  .chart-stat {
    min-width: calc(50% - 4px);
    padding: 10px 6px;
  }

  .chart-stat-val {
    font-size: 13px;
  }

  .chart-stat-lbl {
    font-size: 9px;
  }

  .chart-details-title {
    font-size: 13px;
  }

  .chart-details-body {
    font-size: 12px;
    line-height: 1.55;
  }
}
