.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;
}

.ctrl-segment .chart-period-select-wrap,
.ctrl-segment .analysis-period-select-wrap,
.ctrl-segment .notes-period-select-wrap {
  margin-bottom: 0;
}

.chart-period-select-wrap,
.analysis-period-select-wrap,
.notes-period-select-wrap {
  margin: 0 0 16px;
}

.chart-period-select,
.analysis-period-select,
.notes-period-select {
  width: 100%;
  min-height: 48px;
  border-radius: 16px;
  border: 1px solid rgba(202,166,75,.24);
  background: rgba(255,250,241,.92);
  color: #20150a;
  font-size: 15px;
  font-weight: 800;
  padding: 12px 14px;
  box-shadow:
    0 10px 22px rgba(154,116,40,.06),
    inset 0 1px 0 rgba(255,250,241,.82);
}

.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: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-content: stretch;
  align-items: stretch;
  gap: 16px;
  margin: 0;
  flex-wrap: wrap;
}

.analysis-ai-btn {
  width: 100%;
  min-width: 0;
  min-height: 56px;
  padding: 15px 18px;
  box-shadow: none;
}

.analysis-ai-main-btn {
  background: linear-gradient(180deg, rgba(255, 248, 232, 0.98), rgba(249, 239, 210, 0.94));
  color: #2b2113;
  border: 1px solid rgba(202, 166, 75, 0.24);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -0.01em;
  box-shadow:
    0 12px 26px rgba(154, 116, 40, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.82);
}

.analysis-ai-main-inner {
  display: grid;
  justify-items: center;
  gap: 4px;
}

.analysis-ai-main-badge {
  font-size: 11px;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(122, 93, 41, 0.86);
}

.analysis-ai-main-copy {
  font-size: 15px;
  line-height: 1.3;
  font-weight: 900;
  color: #2b2113;
}

.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-offer {
  display: grid;
  gap: 9px;
  margin: 18px 0 4px;
  padding: 16px 16px 15px;
  border-radius: 16px;
  border: 1px solid rgba(202, 166, 75, 0.14);
  background: linear-gradient(180deg, rgba(255, 252, 246, 0.88), rgba(255, 248, 232, 0.78));
}

.analysis-ai-offer-kicker {
  font-size: 11px;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8a6928;
}

.analysis-ai-offer-title {
  font-size: 13px;
  line-height: 1.6;
  font-weight: 700;
  color: #3e2f1a;
}

.analysis-ai-offer-meta {
  display: grid;
  gap: 4px;
  font-size: 12px;
  line-height: 1.55;
  color: #6b5a38;
}

.analysis-ai-offer-price {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  color: #6f5422;
}

.analysis-ai-offer-price strong {
  color: #7a5d29;
  font-weight: 900;
}

.analysis-ai-offer-copy {
  color: #75613d;
}

.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-hero-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.analysis-hero-card {
  border: 1px solid rgba(202,166,75,.22);
  border-radius: 18px;
  padding: 14px 14px 13px;
  background:
    linear-gradient(180deg, rgba(255,250,241,.92), rgba(250,244,231,.88));
  box-shadow:
    0 10px 22px rgba(154,116,40,.08),
    inset 0 1px 0 rgba(255,250,241,.82);
}

.analysis-hero-label {
  font-size: 12px;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: .02em;
  color: #7a5d29;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.analysis-hero-value {
  font-size: 22px;
  line-height: 1.1;
  font-weight: 900;
  color: #20150a;
  word-break: break-word;
}

.analysis-hero-card.positive .analysis-hero-value {
  color: #137a3e;
}

.analysis-hero-card.negative .analysis-hero-value {
  color: #b43737;
}

.analysis-rich-text {
  color: var(--text);
  line-height: 1.7;
  white-space: pre-wrap;
}

.analysis-pretty-list {
  display: grid;
  gap: 10px;
}

.analysis-pretty-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255,250,241,.72);
  border: 1px solid rgba(202,166,75,.14);
}

.analysis-pretty-row.positive {
  background: rgba(30,150,80,.08);
  border-color: rgba(30,150,80,.16);
}

.analysis-pretty-row.negative {
  background: rgba(190,60,60,.08);
  border-color: rgba(190,60,60,.16);
}

.analysis-pretty-emoji {
  font-size: 20px;
  line-height: 1;
  margin-top: 2px;
}

.analysis-pretty-main {
  min-width: 0;
}

.analysis-pretty-title {
  font-size: 15px;
  line-height: 1.35;
  font-weight: 800;
  color: #20150a;
  word-break: break-word;
}

.analysis-pretty-sub {
  margin-top: 4px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
  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);
}

#analysis-body {
  display: grid;
  gap: 16px;
  align-content: start;
}

.notes-ai-meta {
  margin-top: -4px;
  margin-bottom: 0;
}

.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 {
  display: grid;
  gap: 12px;
  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);
  background: linear-gradient(180deg, #fffdf8 0%, #fffaf0 100%);
  margin-bottom: 0;
}

.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-trigger {
  width: 100%;
  border: none;
  background: transparent;
  font: inherit;
  padding: 0;
  display: grid;
  gap: 8px;
  text-align: left;
  color: inherit;
  cursor: pointer;
}

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

.notes-recent-arrow {
  flex-shrink: 0;
  color: var(--muted);
  transition: transform 0.2s ease;
}

.notes-recent-card.open .notes-recent-arrow {
  transform: rotate(180deg);
}

.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: block;
  margin-top: 0;
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
}

.notes-recent-panel-inner {
  padding-top: 12px;
}

.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;
  }

  .analysis-ai-offer {
    padding: 13px 14px;
  }

  .analysis-hero-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .analysis-hero-card {
    padding: 12px;
    border-radius: 16px;
  }

  .analysis-hero-value {
    font-size: 20px;
  }

  .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;
  }
}
