:root {
  --bg: #f3f6fb;
  --bg-accent: #e4ebf7;
  --surface: rgba(255, 255, 255, 0.92);
  --surface-strong: #ffffff;
  --ink: #151b28;
  --muted: #60708b;
  --line: #dce5f0;
  --primary: #2e6cf1;
  --primary-deep: #1f4fb3;
  --accent: #eb7c57;
  --accent-soft: #fce8e1;
  --success-soft: #e4f7ef;
  --success-ink: #13795a;
  --shadow: 0 24px 60px rgba(17, 24, 39, 0.08);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "DM Sans", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.92), transparent 28%),
    linear-gradient(180deg, #f7f9fd 0%, var(--bg) 42%, var(--bg-accent) 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(255, 255, 255, 0.1) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px);
  background-size: 30px 30px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.3), transparent 85%);
}

a {
  color: inherit;
  text-decoration: none;
}

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

.app-shell {
  width: min(100% - 24px, 460px);
  margin: 0 auto;
  padding: 18px 0 34px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.app-brand {
  display: grid;
  gap: 4px;
}

.app-brand--end {
  text-align: right;
}

.eyebrow,
.section-kicker {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--primary);
}

.app-title,
.screen-title,
.section-head h2 {
  margin: 0;
  font-family: "Fraunces", serif;
  letter-spacing: -0.03em;
  line-height: 1.02;
}

.app-title {
  font-size: 1.85rem;
}

.screen-title,
.section-head h2 {
  font-size: 2rem;
}

.screen {
  display: grid;
  gap: 16px;
}

.screen--home {
  min-height: calc(100vh - 124px);
  align-content: center;
}

.screen-card {
  position: relative;
  overflow: hidden;
  padding: 20px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: var(--radius-xl);
  background: var(--surface);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

.home-card {
  background:
    radial-gradient(circle at top right, rgba(46, 108, 241, 0.12), transparent 30%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(246, 249, 255, 0.95));
}

.login-card {
  width: min(100%, 420px);
  margin: 0 auto;
}

.icon-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid rgba(46, 108, 241, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.74);
  color: var(--primary-deep);
  font-weight: 700;
  box-shadow: 0 10px 24px rgba(17, 24, 39, 0.05);
  border: 0;
  cursor: pointer;
}

.home-actions {
  display: grid;
  gap: 12px;
}

.action-tile {
  display: grid;
  gap: 8px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(245, 248, 253, 0.92));
  box-shadow: 0 14px 28px rgba(17, 24, 39, 0.05);
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    border-color 160ms ease;
}

.action-tile:hover,
.action-tile:focus-visible {
  transform: translateY(-2px);
  border-color: rgba(46, 108, 241, 0.28);
  box-shadow: 0 18px 30px rgba(17, 24, 39, 0.08);
  outline: none;
}

.action-tile__eyebrow {
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.action-tile__title {
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--ink);
}

.action-tile__meta,
.screen-copy,
.history-item__subtitle,
.history-item__time,
.empty-state {
  color: var(--muted);
}

.form-head {
  margin-bottom: 18px;
}

.screen-copy {
  margin: 10px 0 0;
  line-height: 1.6;
}

.entry-form {
  display: grid;
  gap: 14px;
}

.field-row {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 8px;
}

.field__label {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.field__optional,
.field__hint {
  color: var(--muted);
}

.field__optional {
  font-size: 0.9rem;
  font-weight: 600;
}

.field__hint {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.4;
}

.stress-form-intro,
.stress-preview {
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

.stress-form-intro {
  background: rgba(46, 108, 241, 0.06);
  color: var(--primary-deep);
  line-height: 1.5;
  font-weight: 600;
}

.stress-scale {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(245, 248, 253, 0.92));
}

.stress-scale__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.stress-scale__title,
.stress-scale__copy {
  margin: 0;
}

.stress-scale__title {
  font-weight: 700;
}

.stress-scale__copy {
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.45;
}

.stress-scale__value {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(46, 108, 241, 0.1);
  color: var(--primary-deep);
  font-weight: 700;
  text-align: center;
}

.stress-scale__options {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.stress-scale__option {
  min-height: 54px;
  padding: 10px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-strong);
  color: var(--ink);
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
}

.stress-scale__option.is-active {
  border-color: rgba(46, 108, 241, 0.38);
  background: rgba(46, 108, 241, 0.1);
  color: var(--primary-deep);
}

.stress-preview {
  background: rgba(235, 124, 87, 0.08);
  color: var(--ink);
  font-weight: 700;
  line-height: 1.45;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 54px;
  padding: 14px 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-strong);
}

.checkbox-field input {
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--primary);
}

.checkbox-field span {
  font-weight: 700;
}

.field span {
  font-weight: 700;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  min-height: 54px;
  padding: 14px 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-strong);
  color: var(--ink);
}

.field textarea {
  min-height: 144px;
  resize: vertical;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: rgba(46, 108, 241, 0.48);
  box-shadow: 0 0 0 4px rgba(46, 108, 241, 0.12);
}

.secondary-button,
.primary-button {
  width: 100%;
  min-height: 54px;
  border: 0;
  border-radius: 999px;
  font-weight: 700;
  cursor: pointer;
}

.primary-button {
  border: 0;
  background: linear-gradient(135deg, var(--primary), var(--primary-deep));
  color: #f7fbff;
  box-shadow: 0 14px 28px rgba(31, 79, 179, 0.24);
}

.form-feedback {
  margin: 14px 0 0;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--success-soft);
  color: var(--success-ink);
  font-weight: 700;
}

.form-feedback--error {
  background: var(--accent-soft);
  color: var(--accent);
}

.secondary-button {
  min-height: 46px;
  background: rgba(46, 108, 241, 0.1);
  color: var(--primary-deep);
}

.secondary-button--ghost {
  background: rgba(96, 112, 139, 0.1);
  color: var(--muted);
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.72;
  box-shadow: none;
}

.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.meal-builder {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(245, 248, 253, 0.92));
}

.meal-builder__head {
  display: grid;
  gap: 6px;
}

.meal-builder__head span,
.meal-food-card__title {
  font-weight: 700;
}

.meal-builder__copy,
.meal-builder__preview,
.meal-food-card__meta {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.meal-builder__actions {
  display: grid;
  gap: 10px;
}

.meal-parse-actions {
  display: grid;
  gap: 10px;
}

.meal-parse-feedback {
  padding: 12px 14px;
  border: 1px solid rgba(46, 108, 241, 0.14);
  border-radius: var(--radius-md);
  background: rgba(46, 108, 241, 0.06);
  color: var(--primary-deep);
  line-height: 1.5;
  font-weight: 600;
}

.meal-parse-feedback--error {
  border-color: rgba(235, 124, 87, 0.18);
  background: var(--accent-soft);
  color: var(--accent);
}

.meal-builder__summary {
  margin: 0;
  color: var(--primary-deep);
  font-weight: 700;
  line-height: 1.45;
}

.meal-food-search-results,
.meal-food-selected,
.meal-food-list {
  display: grid;
  gap: 10px;
}

.meal-food-search-results {
  max-height: 18rem;
  overflow-y: auto;
}

.meal-food-selected {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(46, 108, 241, 0.06);
}

.meal-food-selected__title {
  font-weight: 700;
}

.meal-food-selected__meta {
  color: var(--muted);
  line-height: 1.5;
}

.meal-search-result {
  display: grid;
  gap: 6px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-strong);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.meal-search-result.is-active {
  border-color: rgba(46, 108, 241, 0.4);
  background: rgba(46, 108, 241, 0.08);
}

.meal-search-result__title {
  font-weight: 700;
}

.meal-search-result__meta {
  color: var(--muted);
  line-height: 1.45;
}

.meal-food-card {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-strong);
}

.meal-food-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.meal-food-card__remove {
  border: 0;
  border-radius: 999px;
  padding: 7px 11px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  cursor: pointer;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.history-chart-card {
  overflow: visible;
}

.history-chart-card .section-head {
  flex-direction: column;
  margin-bottom: 14px;
}

.chart-range-switch {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: 100%;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(46, 108, 241, 0.06);
}

.chart-range-switch--secondary {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.chart-toolbar {
  display: grid;
  gap: 12px;
}

.chart-day-nav {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
}

.chart-day-label {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--primary-deep);
  font-weight: 700;
  text-align: center;
}

.range-nav-button {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--primary-deep);
  font-size: 1.4rem;
  line-height: 1;
  box-shadow: 0 8px 18px rgba(17, 24, 39, 0.06);
  cursor: pointer;
}

.range-nav-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.range-chip {
  width: 100%;
  min-height: 34px;
  padding: 8px 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  text-align: center;
  cursor: pointer;
}

.range-chip.is-active {
  background: var(--surface-strong);
  color: var(--primary-deep);
  box-shadow: 0 8px 18px rgba(17, 24, 39, 0.08);
}

.chart-note,
.chart-summary {
  margin: 0;
  color: var(--muted);
}

.chart-summary {
  margin-top: 6px;
  font-weight: 700;
  line-height: 1.45;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.chart-legend__item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.chart-legend__swatch {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--primary);
}

.chart-legend__swatch--measurement {
  background: var(--primary);
}

.chart-legend__swatch--meal {
  background: var(--accent);
}

.chart-legend__swatch--activity {
  border-radius: 3px;
  background: #178256;
}

.chart-card {
  margin-top: 16px;
  padding: 10px 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(244, 248, 255, 0.92));
}

.chart-stack {
  display: grid;
  gap: 10px;
}

.chart-svg {
  display: block;
  width: 100%;
  height: auto;
}

.chart-grid-line {
  stroke: rgba(96, 112, 139, 0.18);
  stroke-width: 1;
}

.chart-grid-line--vertical {
  stroke-dasharray: 4 6;
}

.chart-axis-label {
  fill: var(--muted);
  font-size: 12px;
  font-family: "DM Sans", sans-serif;
}

.chart-target-band {
  fill: rgba(32, 169, 107, 0.12);
}

.chart-target-line {
  stroke: rgba(32, 169, 107, 0.58);
  stroke-width: 1.5;
  stroke-dasharray: 5 6;
}

.chart-target-label {
  fill: #178256;
  font-size: 12px;
  font-weight: 700;
  font-family: "DM Sans", sans-serif;
}

.chart-area {
  fill: rgba(46, 108, 241, 0.14);
}

.chart-line {
  fill: none;
  stroke: var(--primary);
  stroke-width: 3;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.chart-point {
  fill: var(--surface-strong);
  stroke: var(--primary-deep);
  stroke-width: 2;
}

.chart-timeline-svg {
  margin-top: -2px;
}

.chart-timeline-panel {
  stroke-width: 1;
}

.chart-timeline-panel--activity {
  fill: rgba(23, 130, 86, 0.06);
  stroke: rgba(23, 130, 86, 0.14);
}

.chart-timeline-panel--meal {
  fill: rgba(235, 124, 87, 0.06);
  stroke: rgba(235, 124, 87, 0.14);
}

.chart-subplot-label {
  fill: var(--muted);
  font-size: 11px;
  font-weight: 700;
  font-family: "DM Sans", sans-serif;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.chart-activity-bar {
  fill: rgba(23, 130, 86, 0.78);
}

.chart-activity-label {
  fill: #178256;
  font-size: 10px;
  font-weight: 700;
  font-family: "DM Sans", sans-serif;
}

.chart-meal-marker {
  fill: #fff3ee;
  stroke: var(--accent);
  stroke-width: 2;
}

.chart-meal-label {
  fill: var(--accent);
  font-size: 10px;
  font-weight: 700;
  font-family: "DM Sans", sans-serif;
}

.count-pill {
  min-width: 44px;
  padding: 7px 11px;
  border-radius: 999px;
  background: rgba(46, 108, 241, 0.1);
  color: var(--primary-deep);
  text-align: center;
  font-weight: 700;
}

.history-list {
  display: grid;
  gap: 12px;
}

.history-list--scrollable {
  max-height: 24rem;
  overflow-y: auto;
  padding-right: 4px;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.history-list--scrollable::-webkit-scrollbar {
  width: 8px;
}

.history-list--scrollable::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(96, 112, 139, 0.3);
}

.history-item {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.78);
}

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

.history-item__meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.history-item__body {
  font-size: 1rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

.history-item__action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(46, 108, 241, 0.1);
  color: var(--primary-deep);
  font-size: 0.92rem;
  font-weight: 700;
}

.entry-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.empty-state {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
}

@media (min-width: 760px) {
  .app-shell {
    width: min(100% - 32px, 960px);
    padding-top: 28px;
  }

  .screen--stack {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .history-chart-card {
    grid-column: 1 / -1;
  }

  .chart-toolbar {
    grid-template-columns: repeat(2, minmax(0, max-content));
    justify-content: space-between;
    align-items: center;
  }

  .history-chart-card .section-head {
    flex-direction: row;
    margin-bottom: 18px;
  }

  .history-list--scrollable {
    max-height: 28rem;
  }

  .chart-range-switch {
    display: inline-flex;
    align-items: center;
    width: auto;
  }

  .range-chip {
    width: auto;
  }

  .field-row {
    grid-template-columns: 1.2fr 0.8fr;
  }

  .screen-card {
    padding: 24px;
  }

  .home-card {
    width: min(100%, 520px);
    margin: 0 auto;
  }
}
