:root {
  color-scheme: dark;
  --bg: #06181a;
  --bg-soft: #0c2226;
  --panel: rgba(9, 35, 39, 0.84);
  --panel-border: rgba(174, 217, 201, 0.12);
  --text: #edf7f3;
  --muted: #9cb7b1;
  --accent: #4fd4bc;
  --accent-2: #f1c998;
  --danger: #ff8f8f;
  --shadow: 0 30px 80px rgba(0, 0, 0, 0.28);
  --radius: 24px;
  --page-gutter: 16px;
  --keyboard-offset: 0px;
  --keyboard-scroll-padding: 0px;
}

html {
  -webkit-text-size-adjust: 100%;
  height: 100%;
  background: var(--bg);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  font-family: "Plus Jakarta Sans", sans-serif;
  background:
    radial-gradient(circle at top right, rgba(79, 212, 188, 0.24), transparent 28%),
    radial-gradient(circle at bottom left, rgba(241, 201, 152, 0.15), transparent 22%),
    linear-gradient(180deg, #041012 0%, #07191c 100%);
  color: var(--text);
  min-height: 100%;
  min-height: 100dvh;
  overscroll-behavior-y: none;
  touch-action: manipulation;
}

button,
input,
textarea,
select {
  font: inherit;
}

.hidden {
  display: none !important;
}

.app-shell {
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  padding:
    max(var(--page-gutter), env(safe-area-inset-top))
    max(var(--page-gutter), env(safe-area-inset-right))
    calc(var(--composer-height, 120px) + 32px + var(--keyboard-scroll-padding, 0px))
    max(var(--page-gutter), env(safe-area-inset-left));
  box-sizing: border-box;
}

#app {
  width: 100%;
  min-width: 0;
}

html.is-standalone .topbar {
  padding-top: max(4px, env(safe-area-inset-top));
}

html.is-standalone .pin-gate {
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

.pin-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.pin-card,
.panel,
.hero,
.composer {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  backdrop-filter: blur(22px);
  box-shadow: var(--shadow);
}

.pin-card {
  width: min(100%, 420px);
  padding: 28px;
}

.pin-card h1,
.topbar h1,
.hero h2 {
  margin: 0;
  font-family: "Fraunces", serif;
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.7rem;
  color: var(--accent);
}

.muted {
  color: var(--muted);
}

.pin-form,
.settings-form {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.form-field {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 10px 12px;
  align-items: center;
}

.form-field.form-field-stack {
  grid-template-columns: 1fr;
  align-items: stretch;
}

.field-label {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.3;
}

.form-field.form-field-stack .field-label {
  margin-bottom: 2px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border-radius: 16px;
  padding: 14px 16px;
}

textarea {
  resize: vertical;
  min-height: 56px;
}

button {
  border: none;
  border-radius: 16px;
  padding: 14px 18px;
  background: linear-gradient(135deg, var(--accent), #2b8f8b);
  color: #062021;
  font-weight: 800;
}

.ghost-button {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.icon-button {
  width: 42px;
  min-width: 42px;
  height: 42px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  line-height: 1;
  border-radius: 14px;
}

.icon-button.is-spinning {
  animation: refresh-spin 0.7s linear infinite;
  opacity: 0.85;
}

@keyframes refresh-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.error-text {
  min-height: 20px;
  color: var(--danger);
}

.panel.collapsible > .panel-heading {
  position: relative;
  display: block;
  width: 100%;
  margin: 0 0 0;
  padding: 0 28px 0 0;
  background: transparent;
  border: none;
  box-shadow: none;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.panel.collapsible > .panel-heading:has(.panel-heading-actions) {
  padding-right: 64px;
}

.panel.collapsible > .panel-heading:focus-visible {
  outline: 2px solid rgba(79, 212, 188, 0.55);
  outline-offset: 4px;
  border-radius: 10px;
}

.panel.collapsible > .panel-heading h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.35;
}

button.collapse-arrow {
  position: absolute;
  top: 0;
  right: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 4px;
  min-width: 28px;
  width: 28px;
  height: 28px;
  background: transparent !important;
  background-image: none !important;
  color: var(--muted) !important;
  border: none !important;
  border-radius: 8px;
  box-shadow: none !important;
  font-size: inherit;
  font-weight: inherit;
  line-height: 1;
  cursor: pointer;
}

.panel-heading-actions {
  position: absolute;
  top: 0;
  right: 0;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.panel-heading-actions .collapse-arrow {
  position: static;
}

button.insight-refresh {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 4px;
  min-width: 28px;
  width: 28px;
  height: 28px;
  background: transparent !important;
  background-image: none !important;
  color: var(--muted) !important;
  border: none !important;
  border-radius: 8px;
  box-shadow: none !important;
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
}

button.insight-refresh:hover,
button.collapse-arrow:hover {
  color: var(--accent) !important;
}

button.insight-refresh.is-spinning {
  animation: refresh-spin 0.7s linear infinite;
  pointer-events: none;
}

button.collapse-arrow:active {
  transform: none;
}

.collapse-icon {
  display: block;
  transition: transform 0.18s ease;
  transform: rotate(180deg);
}

.panel.collapsible.is-collapsed .collapse-icon {
  transform: rotate(0deg);
}

.panel.collapsible.is-collapsed .panel-body {
  display: none;
}

.panel.collapsible.is-collapsed > .panel-heading {
  margin-bottom: 0;
}

.panel.collapsible:not(.is-collapsed) > .panel-heading {
  margin-bottom: 14px;
}

.panel-body {
  margin-top: 0;
}

.subheading {
  font-weight: 700;
  color: var(--accent-2);
  margin-bottom: 8px;
}

.improvement-card {
  border-color: rgba(79, 212, 188, 0.35) !important;
  background: rgba(79, 212, 188, 0.08) !important;
}

.topbar,
.composer-tools,
.topbar-actions,
.hero-grid,
.tabs {
  display: flex;
  align-items: center;
}

.topbar,
.topbar-actions,
.composer-tools {
  justify-content: space-between;
  gap: 12px;
}

.topbar {
  padding: 8px 0 20px;
  width: 100%;
  box-sizing: border-box;
}

.pill,
.upload-chip,
.tab,
.proposal-chip {
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.05);
  border-radius: 999px;
  padding: 10px 14px;
}

.hero {
  padding: 22px;
  display: grid;
  gap: 18px;
  margin-bottom: 16px;
  width: 100%;
  box-sizing: border-box;
}

.hero-grid {
  gap: 12px;
  flex-wrap: wrap;
}

.stat-card {
  flex: 1 1 140px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 18px;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-card span {
  display: block;
  color: var(--muted);
  margin-bottom: 8px;
}

.tabs {
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 12px;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
  width: 100%;
  box-sizing: border-box;
}

.tab {
  scroll-snap-align: start;
  color: var(--text);
  white-space: nowrap;
}

.tab.is-active {
  background: rgba(79, 212, 188, 0.18);
  border-color: rgba(79, 212, 188, 0.4);
}

.panel-group {
  display: grid;
  gap: 14px;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.panel-group--today {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  min-width: 0;
}

.panel-group--today > .panel-stack {
  display: contents;
}

.panel-group--today > .panel[data-collapse="nutrition"] {
  order: 1;
}

.panel-group--today > .panel[data-collapse="more-nutrition"] {
  order: 2;
}

.panel-group--today > .panel[data-collapse="micronutrients"] {
  order: 3;
}

.panel-group--today > .panel[data-collapse="office"] {
  order: 4;
}

.panel-group--today > .panel[data-collapse="home"] {
  order: 5;
}

.panel-group--today > .panel[data-collapse="timeline"] {
  order: 6;
}

.panel-group--today > .panel[data-collapse="insights"] {
  order: 7;
}

.panel-group--today > .panel[data-collapse="latest-reply"] {
  order: 8;
}

.panel {
  padding: 18px;
  align-self: start;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.metric-list,
.exercise-list,
.insights-list,
.timeline,
.chat-thread,
.history-summary,
.image-preview,
.proposal-chips {
  display: grid;
  gap: 12px;
}

.metric-card,
.exercise-row,
.timeline-item,
.chat-message,
.proposal-chip {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 18px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.metric-head,
.exercise-top,
.timeline-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.timeline-time {
  flex-shrink: 0;
  white-space: nowrap;
}

.timeline-food-list {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.92rem;
}

.timeline-food-list li {
  margin: 4px 0;
}

.metric-toggle {
  display: block;
  width: 100%;
  background: transparent !important;
  color: inherit;
  text-align: left;
  padding: 0;
  border-radius: 0;
  font-weight: inherit;
  box-shadow: none;
}

.nutrient-card {
  cursor: pointer;
}

.nutrient-card .metric-head span.muted {
  white-space: nowrap;
}

.nutrient-card.is-over {
  border-color: rgba(241, 160, 120, 0.45);
  background: rgba(241, 160, 120, 0.08);
}

.nutrient-card.is-status-green {
  border-color: rgba(79, 212, 188, 0.42);
  background: rgba(79, 212, 188, 0.08);
}

.nutrient-card.is-status-yellow {
  border-color: rgba(241, 201, 152, 0.5);
  background: rgba(241, 201, 152, 0.1);
}

.nutrient-card.is-status-red {
  border-color: rgba(255, 143, 143, 0.5);
  background: rgba(255, 143, 143, 0.1);
}

.nutrient-card.is-status-green .progress > span {
  background: linear-gradient(90deg, #3fd3a5, #8dffcf);
}

.nutrient-card.is-status-yellow .progress > span {
  background: linear-gradient(90deg, #f1c998, #ffd9a8);
}

.nutrient-card.is-status-red .progress > span {
  background: linear-gradient(90deg, #ff8f8f, #ffb4b4);
}

.score-meta {
  display: grid;
  gap: 4px;
  margin-top: 8px;
}

.score-pct {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
}

.score-status {
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text);
}

.score-status.is-complete {
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.score-status.is-over {
  color: #f1c998;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.score-status.is-pending {
  color: var(--muted);
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
}

.score-note {
  font-size: 0.85rem;
  font-weight: 500;
}

.item-icon {
  margin-right: 4px;
}

.contribution-list {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}

.contribution-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.92rem;
}

.exercise-row {
  display: block;
}

.exercise-body {
  width: 100%;
}

.exercise-row.is-complete {
  border-color: rgba(79, 212, 188, 0.55);
  background: rgba(79, 212, 188, 0.12);
  box-shadow: 0 0 0 1px rgba(79, 212, 188, 0.18);
}

.panel.exercise-group-panel.exercise-group-complete {
  border-color: rgba(79, 212, 188, 0.6);
  background: rgba(79, 212, 188, 0.1);
  box-shadow: 0 0 0 1px rgba(79, 212, 188, 0.22);
}

.panel.exercise-group-panel.exercise-group-complete > .panel-heading h3 {
  color: #8ef0dc;
}

.exercise-group-tick,
.exercise-name-tick {
  color: #3dd6b5;
  font-weight: 800;
  line-height: 1;
}

.exercise-group-tick {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.35rem;
  margin-right: 2px;
  border-radius: 50%;
  background: rgba(61, 214, 181, 0.22);
  font-size: 0.85rem;
  vertical-align: middle;
}

.exercise-name-tick {
  margin-right: 4px;
  font-size: 0.95rem;
}

.exercise-row.is-overachieved {
  border-color: rgba(241, 201, 152, 0.55);
  background: rgba(241, 201, 152, 0.1);
}

.exercise-total {
  white-space: nowrap;
  font-weight: 600;
}

.exercise-status {
  white-space: nowrap;
  font-weight: 700;
  color: var(--accent);
}

.positive-note {
  margin-top: 8px;
  color: var(--accent);
  font-weight: 700;
  font-size: 0.92rem;
}

.progress {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
  margin-top: 10px;
}

.progress-full {
  width: 100%;
  margin-left: 0;
  margin-right: 0;
}

.progress > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.exercise-row.is-complete .progress > span {
  background: linear-gradient(90deg, #3fd3a5, #8dffcf);
}

.timeline-item img {
  width: 100%;
  border-radius: 16px;
  margin-top: 12px;
}

.composer-wrap {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  padding:
    8px
    max(var(--page-gutter), env(safe-area-inset-right))
    calc(8px + env(safe-area-inset-bottom))
    max(var(--page-gutter), env(safe-area-inset-left));
  background: linear-gradient(180deg, rgba(6, 24, 26, 0), rgba(6, 24, 26, 0.98) 28%);
  transform: translateY(calc(-1 * var(--keyboard-offset, 0px)));
  transition: transform 0.15s ease-out;
  will-change: transform;
  box-sizing: border-box;
}

.composer {
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  padding: 6px;
  display: grid !important;
  grid-template-columns: 42px minmax(0, 1fr) 42px;
  grid-template-rows: auto;
  align-items: end;
  gap: 8px;
  box-sizing: border-box;
}

.composer #messageInput {
  grid-column: 2;
  grid-row: 1;
  width: auto !important;
  min-width: 0 !important;
  max-width: 100%;
  min-height: 42px !important;
  max-height: 120px;
  height: 42px;
  resize: none !important;
  overflow-y: auto;
  line-height: 1.35;
  padding: 10px 12px !important;
  border-radius: 14px;
  margin: 0 !important;
  box-sizing: border-box;
}

.camera-btn,
#sendButton {
  grid-row: 1;
  width: 42px !important;
  height: 42px !important;
  min-width: 42px !important;
  max-width: 42px !important;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  padding: 0 !important;
  margin: 0 !important;
  border-radius: 14px;
  cursor: pointer;
  font-size: 1.15rem;
  line-height: 1;
  box-sizing: border-box;
}

.camera-btn {
  grid-column: 1;
  background: rgba(255, 255, 255, 0.05) !important;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text);
}

#sendButton {
  grid-column: 3;
  background: linear-gradient(135deg, var(--accent), #2b8f8b);
  color: #062021;
  font-weight: 800;
}

.upload-chip {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.image-preview {
  width: 100%;
  max-width: 920px;
  margin: 0 auto 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  box-sizing: border-box;
}

.image-preview:empty {
  display: none;
}

.proposal-chips {
  width: 100%;
  max-width: 920px;
  margin: 0 auto 8px;
  box-sizing: border-box;
}

.proposal-chips:empty {
  display: none;
}

.proposal-chip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.proposal-chip button {
  padding: 10px 12px;
  font-size: 0.9rem;
}

.chat-thread {
  max-height: min(70vh, 640px);
  overflow-y: auto;
  padding-right: 4px;
}

.chat-message.assistant {
  border-color: rgba(241, 201, 152, 0.18);
}

.doctor-insight-lead {
  margin: 0 0 12px;
  font-size: 0.9rem;
  line-height: 1.45;
}

.doctor-insight-body {
  margin: 0;
}

.doctor-insight-card {
  border-color: rgba(79, 212, 188, 0.32) !important;
  background: rgba(79, 212, 188, 0.07) !important;
}

.doctor-insight-prose p {
  margin: 0 0 12px;
  line-height: 1.55;
}

.doctor-insight-prose p:last-child {
  margin-bottom: 0;
}

.doctor-insight-heading {
  margin: 14px 0 8px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent);
}

.doctor-insight-heading:first-child {
  margin-top: 0;
}

.doctor-insight-list {
  margin: 0 0 12px 18px;
  padding: 0;
  line-height: 1.5;
}

.health-summary-meta {
  margin: 0 0 10px;
  font-size: 0.85rem;
}

.health-summary-card {
  margin: 0;
}

.latest-chat-reply {
  display: grid;
  gap: 0;
}

.latest-chat-reply .latest-reply-content {
  line-height: 1.55;
  word-break: break-word;
}

.latest-chat-reply .latest-reply-content p {
  margin: 0 0 10px;
}

.latest-chat-reply .latest-reply-content p:last-child {
  margin-bottom: 0;
}

.latest-chat-reply .chat-message {
  margin: 0;
}

.insight-info-card {
  border-color: rgba(79, 212, 188, 0.28) !important;
  background: rgba(79, 212, 188, 0.06) !important;
}

.insight-info-card p {
  margin: 0 0 8px;
}

.insight-info-card p:last-child {
  margin-bottom: 0;
}

.insight-reply {
  border-color: rgba(241, 201, 152, 0.35) !important;
  background: rgba(241, 201, 152, 0.06) !important;
}

.insight-reply p {
  margin: 0 0 8px;
}

.insight-reply p:last-child {
  margin-bottom: 0;
}

@media (max-width: 767px) {
  .metric-head,
  .exercise-top {
    flex-wrap: wrap;
  }

  .nutrient-card .metric-head span.muted,
  .exercise-total {
    white-space: normal;
    text-align: right;
    margin-left: auto;
  }

  .score-status {
    word-break: break-word;
  }
}

@media (min-width: 768px) {
  .hero {
    grid-template-columns: 1.35fr 1fr;
    align-items: center;
  }

  .panel-group {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }

  .panel-group--today {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }

  .panel-group--today > .panel-stack {
    display: flex;
    flex-direction: column;
    gap: 14px;
    align-items: stretch;
    min-width: 0;
  }

  .panel-group--today > .panel-stack .panel {
    flex: 0 0 auto;
    width: 100%;
  }

  .panel-group--today > .panel[data-collapse="insights"],
  .panel-group--today > .panel[data-collapse="latest-reply"] {
    grid-column: 1 / -1;
    order: unset;
  }

  .panel-group--today > .panel[data-collapse="nutrition"],
  .panel-group--today > .panel[data-collapse="more-nutrition"],
  .panel-group--today > .panel[data-collapse="micronutrients"],
  .panel-group--today > .panel[data-collapse="office"],
  .panel-group--today > .panel[data-collapse="home"],
  .panel-group--today > .panel[data-collapse="timeline"] {
    order: unset;
  }

  #section-today .panel:last-child,
  #section-settings .panel,
  #section-chat .panel,
  #section-profile .panel,
  #section-health .panel {
    grid-column: 1 / -1;
  }

  .analytics-grid--charts,
  .analytics-grid--trends {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #section-history.panel-group,
  #section-trends.panel-group,
  .analytics-section.panel-group {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    grid-template-columns: unset;
  }

  #section-history.panel-group > *,
  #section-trends.panel-group > *,
  .analytics-section.panel-group > * {
    width: 100%;
    max-width: 100%;
    grid-column: 1 / -1;
  }
}

@media (min-width: 1024px) {
  .app-shell:has(#section-history:not(.hidden)),
  .app-shell:has(#section-trends:not(.hidden)) {
    max-width: min(1180px, 100%);
  }

  .analytics-grid--charts,
  .analytics-grid--trends {
    grid-template-columns: 1fr;
  }
}

/* —— Analytics: History & Trends —— */
#section-history,
#section-trends,
.analytics-section {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 16px;
  padding-bottom: 24px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

#section-history > *,
#section-trends > *,
.analytics-section > * {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.analytics-section .panel,
.analytics-section .analytics-card {
  align-self: stretch;
}

.analytics-hero {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 4px 2px 8px;
}

.analytics-hero--trends {
  margin-top: 4px;
}

.analytics-eyebrow {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}

.analytics-headline {
  margin: 4px 0 0;
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.analytics-sub {
  margin: 6px 0 0;
  font-size: 0.92rem;
  max-width: 36rem;
  line-height: 1.45;
}

.range-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.range-pill {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.12s;
}

.range-pill:hover {
  background: rgba(255, 255, 255, 0.08);
}

.range-pill.is-active {
  background: rgba(79, 212, 188, 0.18);
  border-color: rgba(79, 212, 188, 0.55);
  color: #b8fff0;
}

.analytics-kpi-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

@media (min-width: 640px) {
  .analytics-kpi-row {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .analytics-hero {
    flex-direction: row;
    align-items: flex-end;
    justify-content: space-between;
  }
}

.analytics-kpi {
  background: linear-gradient(145deg, rgba(79, 212, 188, 0.12), rgba(255, 255, 255, 0.03));
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 12px 14px;
}

.analytics-kpi strong {
  display: block;
  font-size: 1.35rem;
  line-height: 1.1;
  margin-top: 4px;
}

.analytics-kpi span {
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.analytics-kpi .kpi-delta {
  font-size: 0.8rem;
  margin-top: 6px;
  font-weight: 600;
}

.analytics-kpi .kpi-delta.is-up {
  color: #4fd4bc;
}

.analytics-kpi .kpi-delta.is-down {
  color: #f1c998;
}

.analytics-grid {
  display: grid;
  gap: 14px;
}

.analytics-card {
  padding: 0;
  overflow: hidden;
}

.analytics-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 0;
}

.analytics-card-head h3 {
  margin: 0;
  font-size: 1rem;
}

.analytics-card-hint {
  font-size: 0.78rem;
}

.chart-wrap {
  padding: 8px 12px 16px;
  min-height: 160px;
  width: 100%;
  position: relative;
}

.chart-wrap canvas {
  display: block;
  width: 100% !important;
  max-width: 100%;
}

.chart-wrap--tall {
  min-height: 240px;
}

.chart-wrap--square {
  max-width: 280px;
  margin: 0 auto;
}

.analytics-card--wide {
  grid-column: 1 / -1;
}

.history-jump {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.78rem;
}

.history-jump input[type="date"] {
  font-size: 0.85rem;
  padding: 6px 8px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
}

.history-day-cards {
  display: grid;
  gap: 10px;
  padding: 12px 16px 16px;
  max-height: 420px;
  overflow-y: auto;
}

.history-day-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  text-align: left;
  width: 100%;
  color: inherit;
  font: inherit;
  transition: border-color 0.15s, background 0.15s;
}

.history-day-card:hover {
  border-color: rgba(79, 212, 188, 0.45);
  background: rgba(79, 212, 188, 0.08);
}

.history-day-card.is-active {
  border-color: rgba(79, 212, 188, 0.65);
  box-shadow: 0 0 0 1px rgba(79, 212, 188, 0.2);
}

.history-day-card__date {
  font-weight: 700;
}

.history-day-card__meta {
  grid-column: 1 / -1;
  font-size: 0.85rem;
  color: var(--muted);
}

.history-day-card__badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
}

.history-day-card__badge.is-good {
  background: rgba(79, 212, 188, 0.2);
  color: #9ef5e4;
}

.consistency-heatmap {
  padding: 12px 16px 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.heat-cell {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  position: relative;
}

.heat-cell[data-level="0"] {
  background: rgba(255, 255, 255, 0.04);
}

.heat-cell[data-level="1"] {
  background: rgba(79, 212, 188, 0.15);
}

.heat-cell[data-level="2"] {
  background: rgba(79, 212, 188, 0.35);
}

.heat-cell[data-level="3"] {
  background: rgba(79, 212, 188, 0.55);
}

.heat-cell[data-level="4"] {
  background: rgba(79, 212, 188, 0.85);
}

.heat-cell[title] {
  cursor: help;
}

.heat-legend {
  width: 100%;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 8px;
}

/* —— Exercise hub —— */
.exercise-day-focus {
  margin: 0 0 12px;
  font-size: 0.88rem;
  line-height: 1.45;
}

.exercise-hub {
  display: grid;
  gap: 16px;
}

.exercise-hub-hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
}

.exercise-hub-kicker {
  margin: 0 0 4px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.exercise-hub-hero h2 {
  margin: 0;
  font-size: 1.45rem;
}

.exercise-focus-ring {
  position: relative;
  width: 108px;
  height: 108px;
  flex-shrink: 0;
}

.exercise-focus-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.exercise-ring-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 10;
}

.exercise-ring-progress {
  fill: none;
  stroke: var(--accent);
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.35s ease;
}

.exercise-ring-label {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 1.15rem;
}

.exercise-week-strip {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  overflow-x: auto;
}

.exercise-week-pill {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 8px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  color: inherit;
  text-align: left;
  cursor: pointer;
  min-width: 0;
}

.exercise-week-pill.is-selected {
  border-color: rgba(79, 212, 188, 0.65);
  background: rgba(79, 212, 188, 0.12);
}

.exercise-week-pill.is-today {
  box-shadow: inset 0 0 0 1px rgba(241, 201, 152, 0.35);
}

.exercise-week-pill.is-rest {
  opacity: 0.85;
}

.exercise-week-pill-day {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 700;
}

.exercise-week-pill-label {
  font-size: 0.72rem;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.exercise-week-pill-pct {
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--accent);
}

.exercise-hub-groups {
  display: grid;
  gap: 18px;
}

.exercise-hub-group-title {
  margin: 0 0 10px;
  font-size: 0.95rem;
}

.exercise-calendar-nav {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.exercise-calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.exercise-cal-head {
  text-align: center;
  font-size: 0.72rem;
  color: var(--muted);
  padding: 4px 0 8px;
  font-weight: 700;
}

.exercise-cal-cell {
  min-height: 72px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.02);
  color: inherit;
  padding: 6px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  cursor: pointer;
}

.exercise-cal-cell.is-empty {
  border: none;
  background: transparent;
  cursor: default;
  min-height: 0;
}

.exercise-cal-cell.is-selected {
  border-color: rgba(79, 212, 188, 0.7);
  box-shadow: 0 0 0 1px rgba(79, 212, 188, 0.25);
}

.exercise-cal-cell.is-today .exercise-cal-day {
  color: var(--gold);
}

.exercise-cal-cell.tone-high {
  background: rgba(79, 212, 188, 0.22);
}

.exercise-cal-cell.tone-mid {
  background: rgba(241, 201, 152, 0.16);
}

.exercise-cal-cell.tone-low {
  background: rgba(232, 165, 152, 0.12);
}

.exercise-cal-cell.tone-rest {
  background: rgba(168, 180, 255, 0.1);
}

.exercise-cal-day {
  font-weight: 800;
  font-size: 0.9rem;
}

.exercise-cal-mini {
  font-size: 0.62rem;
  color: var(--muted);
  line-height: 1.2;
}

.exercise-cal-pct {
  margin-top: auto;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
}

.exercise-calendar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
  font-size: 0.78rem;
  color: var(--muted);
}

.exercise-calendar-legend .dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 4px;
}

.dot-high { background: rgba(79, 212, 188, 0.85); }
.dot-mid { background: rgba(241, 201, 152, 0.85); }
.dot-low { background: rgba(232, 165, 152, 0.85); }
.dot-rest { background: rgba(168, 180, 255, 0.85); }

.exercise-day-detail-group {
  margin-top: 14px;
}

.exercise-day-detail-group h4 {
  margin: 0 0 8px;
  font-size: 0.9rem;
}

.exercise-day-detail-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.88rem;
}

.exercise-day-detail-row.is-complete {
  color: var(--accent);
}

.exercise-day-detail-row .score-status {
  grid-column: 1 / -1;
  font-size: 0.78rem;
}

.exercise-plan-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.exercise-plan-card {
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  padding: 12px 14px;
}

.exercise-plan-card.is-rest {
  border-color: rgba(168, 180, 255, 0.2);
}

.exercise-plan-card header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.exercise-plan-card p {
  margin: 6px 0 0;
  font-size: 0.84rem;
  line-height: 1.45;
}

@media (max-width: 720px) {
  .exercise-hub-hero-top {
    flex-direction: column;
    align-items: flex-start;
  }

  .exercise-week-strip {
    grid-template-columns: repeat(7, minmax(92px, 1fr));
  }

  .exercise-cal-cell {
    min-height: 58px;
    padding: 4px;
  }
}
