:root {
  color-scheme: light;
  --bg: #fbf8f0;
  --surface: #fffefa;
  --surface-soft: #f0f3ed;
  --surface-warm: #fff4df;
  --ink: #17382f;
  --muted: #71807c;
  --muted-strong: #4f645c;
  --line: #e3e7df;
  --sage: #9bb9a4;
  --sage-deep: #5f8f7c;
  --sage-pale: #e7f0e9;
  --coral: #ea8067;
  --coral-pale: #fff0e8;
  --amber: #e39e22;
  --amber-pale: #fff5df;
  --lavender: #6d83c0;
  --lavender-pale: #f0effb;
  --shadow-sm: 0 3px 14px rgba(43, 63, 54, 0.045);
  --shadow: 0 16px 40px rgba(43, 63, 54, 0.08);
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --content-width: 1100px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(95, 143, 124, 0.35);
  outline-offset: 2px;
}

.app-shell {
  min-height: 100vh;
}

.app-main {
  width: min(100% - 32px, var(--content-width));
  margin: 0 auto;
  padding: 30px 0 112px;
}

.page-stack {
  display: grid;
  gap: 22px;
}

.topbar,
.section-heading,
.inline-between,
.meal-card__header,
.history-row__header,
.management-row,
.modal-header,
.chart-header,
.range-switch,
.summary-row,
.nav-item,
.hero-title-row {
  display: flex;
  align-items: center;
}

.topbar,
.section-heading,
.inline-between,
.meal-card__header,
.history-row__header,
.management-row,
.modal-header,
.chart-header,
.summary-row,
.hero-title-row {
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--sage-deep);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(28px, 5vw, 42px);
  line-height: 1.08;
  letter-spacing: -0.045em;
}

h2 {
  margin-bottom: 0;
  font-size: 21px;
  line-height: 1.2;
  letter-spacing: -0.025em;
}

h3 {
  margin-bottom: 0;
  font-size: 16px;
  line-height: 1.3;
}

.muted,
.section-copy,
.card-copy,
.modal-copy,
.empty-copy {
  color: var(--muted);
}

.section-copy,
.card-copy,
.modal-copy,
.empty-copy {
  margin: 6px 0 0;
  font-size: 13px;
  line-height: 1.55;
}

.topbar__date {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.topbar__mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 15px;
  color: #fff;
  background: var(--ink);
  box-shadow: 0 8px 18px rgba(36, 48, 45, 0.14);
  font-size: 21px;
}

.hero {
  position: relative;
  overflow: hidden;
  padding: clamp(23px, 5vw, 38px);
  border-radius: var(--radius-lg);
  color: #fbfffb;
  background:
    radial-gradient(circle at 90% 5%, rgba(255, 255, 255, 0.22), transparent 13rem),
    linear-gradient(135deg, #345d52 0%, #5f8f7c 100%);
  box-shadow: var(--shadow);
}

.hero::after {
  position: absolute;
  right: -22px;
  bottom: -46px;
  width: 190px;
  height: 190px;
  border: 1px solid rgba(255, 255, 255, 0.17);
  border-radius: 50%;
  content: "";
  box-shadow: 0 0 0 25px rgba(255, 255, 255, 0.06), 0 0 0 50px rgba(255, 255, 255, 0.04);
}

.hero__content {
  position: relative;
  z-index: 1;
  max-width: 630px;
}

.hero .eyebrow,
.hero .card-copy {
  color: rgba(251, 255, 251, 0.72);
}

.hero h1 {
  max-width: 600px;
  font-size: clamp(26px, 5vw, 40px);
}

.hero__footer {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 22px;
  margin-top: 28px;
}

.hero__footer .primary-button {
  color: var(--ink);
  background: #f8fcf8;
}

.hero__footer .primary-button:hover {
  background: #fff;
}

.hero__stat {
  color: rgba(251, 255, 251, 0.84);
  font-size: 13px;
}

.hero__stat strong {
  display: block;
  color: #fff;
  font-size: 22px;
  line-height: 1;
}

.button,
.primary-button,
.secondary-button,
.text-button,
.icon-button,
.danger-button {
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, color 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.button:hover,
.primary-button:hover,
.secondary-button:hover,
.text-button:hover,
.icon-button:hover,
.danger-button:hover {
  transform: translateY(-1px);
}

.primary-button,
.secondary-button,
.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 13px;
  font-size: 13px;
  font-weight: 800;
}

.primary-button {
  color: #fff;
  background: var(--ink);
  box-shadow: 0 7px 16px rgba(36, 48, 45, 0.15);
}

.secondary-button {
  color: var(--muted-strong);
  background: var(--surface-soft);
}

.secondary-button:hover {
  color: var(--ink);
  background: #e1ebe2;
}

.danger-button {
  color: #a94c37;
  background: var(--coral-pale);
}

.text-button {
  padding: 5px 0;
  color: var(--sage-deep);
  background: transparent;
  font-size: 13px;
  font-weight: 800;
}

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

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  color: var(--muted-strong);
  background: var(--surface-soft);
  font-size: 19px;
}

.icon-button:hover {
  color: var(--ink);
  background: var(--line);
}

.section-heading {
  margin-bottom: 13px;
}

.section-heading--tight {
  margin-bottom: 8px;
}

.section-heading__title {
  display: flex;
  align-items: center;
  gap: 9px;
}

.section-heading__title::before {
  width: 6px;
  height: 22px;
  border-radius: 6px;
  background: var(--sage);
  content: "";
}

.surface-card,
.meal-card,
.history-row,
.chart-card,
.management-card,
.summary-card {
  border: 1px solid rgba(226, 232, 225, 0.95);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow-sm);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.summary-card {
  padding: 18px;
}

.summary-card__value {
  display: block;
  margin-bottom: 5px;
  font-size: 25px;
  font-weight: 850;
  letter-spacing: -0.05em;
}

.summary-card__label {
  color: var(--muted);
  font-size: 12px;
}

.summary-card--sage {
  background: var(--sage-pale);
  border-color: #d3e7db;
}

.summary-card--warm {
  background: var(--surface-warm);
  border-color: #f3e5d1;
}

.summary-card--lavender {
  background: var(--lavender-pale);
  border-color: #e2dcf1;
}

.meal-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.meal-card {
  min-height: 186px;
  padding: 20px;
}

.meal-card--complete {
  border-color: #d5e7dc;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.96), rgba(241, 249, 243, 0.94));
}

.meal-card--pending {
  border-color: #f0dfbf;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.96), rgba(255, 249, 238, 0.96));
}

.meal-card__header {
  align-items: flex-start;
}

.meal-card__identity {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.meal-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 14px;
  font-size: 19px;
  background: var(--surface-soft);
}

.meal-card--complete .meal-icon {
  background: var(--sage-pale);
}

.meal-card--pending .meal-icon {
  background: var(--amber-pale);
}

.meal-card__title {
  margin: 0;
  font-size: 16px;
}

.meal-card__time {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.status-pill,
.tag-chip,
.score-chip,
.small-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 25px;
  padding: 0 9px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.status-pill--empty {
  color: var(--muted);
  background: var(--surface-soft);
}

.status-pill--pending {
  color: #9a6a29;
  background: var(--amber-pale);
}

.status-pill--complete {
  color: var(--sage-deep);
  background: var(--sage-pale);
}

.meal-card__body {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 112px;
  margin-top: 18px;
}

.meal-empty-state {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 74px;
}

.meal-empty-state p {
  max-width: 180px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.score-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.score-box {
  padding: 11px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
}

.score-box__label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 11px;
}

.score-box__value {
  font-size: 18px;
  font-weight: 850;
}

.score-box__value span {
  margin-left: 3px;
  color: var(--muted-strong);
  font-size: 11px;
  font-weight: 700;
}

.score-box--hunger .score-box__value {
  color: var(--coral);
}

.score-box--fullness .score-box__value {
  color: var(--sage-deep);
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 11px;
}

.tag-chip {
  color: var(--muted-strong);
  background: var(--surface-soft);
  font-weight: 700;
}

.tag-chip--bad {
  color: #a55743;
  background: var(--coral-pale);
}

.meal-card__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 13px;
  margin-top: 13px;
}

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

.snack-record {
  padding: 13px;
  border-radius: 15px;
  background: var(--surface-soft);
}

.snack-record__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
}

.snack-record__time {
  color: var(--muted);
  font-size: 11px;
}

.snack-record .score-pair {
  gap: 6px;
}

.snack-record .score-box {
  padding: 8px 9px;
}

.snack-record .score-box__value {
  font-size: 15px;
}

.snack-record__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 9px;
}

.helper-strip {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 15px 17px;
  border: 1px solid #e9e3d4;
  border-radius: var(--radius-sm);
  color: var(--muted-strong);
  background: rgba(251, 243, 231, 0.8);
  font-size: 12px;
  line-height: 1.55;
}

.helper-strip__icon {
  flex: 0 0 auto;
  color: var(--amber);
  font-size: 17px;
}

.bottom-nav {
  position: fixed;
  z-index: 20;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  width: min(100%, 620px);
  margin: 0 auto;
  padding: 10px max(12px, env(safe-area-inset-left)) calc(10px + env(safe-area-inset-bottom));
  border: 1px solid rgba(226, 232, 225, 0.96);
  border-bottom: 0;
  border-radius: 22px 22px 0 0;
  background: rgba(255, 255, 255, 0.93);
  box-shadow: 0 -10px 34px rgba(42, 58, 49, 0.08);
  backdrop-filter: blur(18px);
}

.nav-item {
  justify-content: center;
  flex-direction: column;
  gap: 4px;
  min-height: 48px;
  color: var(--muted);
  background: transparent;
  font-size: 10px;
  font-weight: 800;
  cursor: pointer;
}

.nav-item__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 9px;
  font-size: 18px;
}

.nav-item--active {
  color: var(--sage-deep);
}

.nav-item--active .nav-item__icon {
  background: var(--sage-pale);
}

.history-toolbar,
.analysis-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 17px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.76);
}

.segmented-control {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: var(--surface-soft);
}

.segmented-control button {
  min-height: 30px;
  padding: 0 10px;
  border-radius: 9px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.segmented-control button.is-active {
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 2px 8px rgba(37, 59, 49, 0.08);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.analysis-insight {
  padding: 20px 22px;
  border: 1px solid #d5e7dc;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(228, 240, 231, 0.96), rgba(255, 251, 241, 0.94));
  box-shadow: var(--shadow-sm);
}

.analysis-insight__eyebrow {
  display: block;
  margin-bottom: 7px;
  color: var(--sage-deep);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.08em;
}

.analysis-insight strong {
  display: block;
  max-width: 760px;
  font-size: clamp(18px, 2.2vw, 25px);
  line-height: 1.35;
  letter-spacing: -0.035em;
}

.analysis-insight p {
  margin: 8px 0 0;
  color: var(--muted-strong);
  font-size: 11px;
}

.analysis-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.analysis-metric {
  min-width: 0;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}

.analysis-metric strong,
.analysis-metric span,
.analysis-metric small {
  display: block;
}

.analysis-metric strong {
  margin-bottom: 4px;
  font-size: 24px;
  letter-spacing: -0.045em;
}

.analysis-metric span {
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.analysis-metric small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 10px;
}

.analysis-metric--sage { background: var(--sage-pale); border-color: #d3e7db; }
.analysis-metric--coral { background: var(--coral-pale); border-color: #f1d7cf; }
.analysis-metric--warm { background: var(--surface-warm); border-color: #f0e1c8; }
.analysis-metric--lavender { background: var(--lavender-pale); border-color: #e2dcf1; }
.analysis-metric--neutral { background: rgba(255, 255, 255, 0.76); }

.rhythm-matrix-wrap {
  overflow-x: auto;
}

.rhythm-matrix {
  width: 100%;
  min-width: 560px;
  border-collapse: separate;
  border-spacing: 7px;
}

.rhythm-matrix caption {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
  text-align: left;
}

.rhythm-matrix th {
  padding: 8px;
  color: var(--muted-strong);
  font-size: 10px;
  font-weight: 800;
  text-align: center;
}

.rhythm-matrix tbody th {
  width: 112px;
  text-align: left;
}

.rhythm-cell {
  min-width: 92px;
  height: 58px;
  padding: 8px;
  border: 1px solid transparent;
  border-radius: 12px;
  color: var(--muted);
  background: var(--surface-soft);
  text-align: center;
}

.rhythm-cell.has-value {
  color: var(--ink);
  background: var(--surface-warm);
}

.rhythm-cell.is-ideal {
  border-color: var(--sage);
  box-shadow: inset 0 0 0 1px var(--sage);
}

.rhythm-cell strong,
.rhythm-cell span {
  display: block;
}

.rhythm-cell strong {
  font-size: 16px;
}

.rhythm-cell span {
  margin-top: 2px;
  font-size: 9px;
}

.chart-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
}

.compact-empty {
  display: grid;
  gap: 5px;
  padding: 24px;
  border-radius: 14px;
  color: var(--muted-strong);
  background: var(--surface-soft);
  text-align: center;
}

.compact-empty span {
  color: var(--muted);
  font-size: 11px;
}

.history-list,
.chart-grid,
.management-stack {
  display: grid;
  gap: 14px;
}

.history-group {
  display: grid;
  gap: 9px;
}

.history-group__date {
  margin: 11px 3px 1px;
  color: var(--muted-strong);
  font-size: 13px;
  font-weight: 850;
}

.history-row {
  padding: 16px;
}

.history-row__identity {
  display: flex;
  align-items: center;
  gap: 11px;
}

.history-row__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: var(--surface-soft);
}

.history-row__title {
  margin: 0;
  font-size: 14px;
}

.history-row__time {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.history-row__body {
  margin-top: 13px;
}

.history-row__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 13px;
  margin-top: 11px;
}

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

.chart-card {
  padding: 20px;
}

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

.chart-header {
  align-items: flex-start;
  margin-bottom: 18px;
}

.chart-header__title {
  margin: 0;
  font-size: 15px;
}

.chart-header__meta {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 9px 16px;
  margin-top: 16px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted-strong);
  font-size: 11px;
}

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

.level-1 {
  background: #c9dfd1;
}

.level-2 {
  background: #e0bc7b;
}

.level-3 {
  background: #e58a72;
}

.distribution {
  display: grid;
  gap: 14px;
}

.distribution__bar {
  display: flex;
  overflow: hidden;
  min-height: 38px;
  border-radius: 12px;
  background: var(--surface-soft);
}

.distribution__segment {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  color: var(--ink);
  font-size: 11px;
  font-weight: 850;
  transition: width 240ms ease;
}

.distribution__segment.is-empty {
  width: 100% !important;
  color: var(--muted);
  background: var(--surface-soft);
  font-weight: 700;
}

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

.distribution__count {
  padding: 8px 7px;
  border-radius: 10px;
  text-align: center;
  background: var(--surface-soft);
}

.distribution__count strong {
  display: block;
  margin-bottom: 2px;
  font-size: 15px;
}

.distribution__count span {
  color: var(--muted);
  font-size: 10px;
}

.slot-comparison {
  display: grid;
  gap: 12px;
}

.slot-outcome {
  display: grid;
  grid-template-columns: minmax(90px, 1fr) repeat(3, minmax(72px, 0.7fr));
  align-items: center;
  gap: 12px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}

.slot-outcome:last-child {
  border-bottom: 0;
}

.slot-outcome__name strong,
.slot-outcome__name span {
  display: block;
}

.slot-outcome__name strong {
  font-size: 13px;
}

.slot-outcome__name span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
}

.slot-outcome__metric {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 7px;
  padding: 9px 10px;
  border-radius: 10px;
  background: var(--surface-soft);
}

.slot-outcome__metric span {
  color: var(--muted);
  font-size: 9px;
}

.slot-outcome__metric strong {
  font-size: 12px;
}

.slot-outcome--sparse {
  grid-template-columns: minmax(90px, 1fr) 3fr;
  opacity: 0.72;
}

.slot-outcome--sparse div strong,
.slot-outcome--sparse div span {
  display: block;
}

.slot-outcome--sparse div strong {
  font-size: 13px;
}

.slot-outcome--sparse div span,
.slot-outcome--sparse p {
  color: var(--muted);
  font-size: 10px;
}

.slot-outcome--sparse p {
  margin: 0;
}

.slot-row {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.slot-row:last-child {
  border-bottom: 0;
}

.slot-row.is-sparse {
  opacity: 0.68;
}

.slot-row__label {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 0;
}

.slot-row__name {
  color: var(--ink);
  font-size: 13px;
  font-weight: 850;
  line-height: 1.2;
}

.slot-row__english {
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.01em;
}

.slot-row__count {
  margin-top: 1px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  line-height: 1.2;
}

.mini-distribution {
  display: grid;
  gap: 5px;
}

.mini-distribution__label {
  color: var(--muted);
  font-size: 10px;
}

.mini-distribution__bar {
  display: flex;
  overflow: hidden;
  min-height: 15px;
  border-radius: 6px;
  background: var(--surface-soft);
}

.mini-distribution__bar span {
  min-width: 0;
}

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

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

.association-item {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(249, 251, 248, 0.72);
}

.association-item__header,
.association-item__outcomes {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.association-item__header strong {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.association-item__header span {
  flex: 0 0 auto;
  color: var(--muted-strong);
  font-size: 10px;
  font-weight: 750;
}

.association-item__outcomes {
  justify-content: flex-start;
  flex-wrap: wrap;
  margin-top: 10px;
}

.association-item__outcomes span {
  padding: 5px 8px;
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface);
  font-size: 9px;
}

.association-item__outcomes strong {
  color: var(--ink);
}

.association-item__track {
  height: 7px;
  margin-top: 11px;
  overflow: hidden;
  border-radius: 99px;
  background: var(--surface-soft);
}

.association-item__track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--sage), var(--sage-deep));
}

.association-item--bad .association-item__track span {
  background: linear-gradient(90deg, #efb19f, var(--coral));
}

.association-item__note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 9px;
}

.association-trend {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 10px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 9px;
}

.frequency-item {
  display: grid;
  grid-template-columns: minmax(90px, 0.8fr) minmax(140px, 1fr) 34px;
  align-items: center;
  gap: 11px;
}

.frequency-item__name {
  overflow: hidden;
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.frequency-item__bar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.frequency-item__bar-track {
  flex: 1;
  height: 9px;
  overflow: hidden;
  border-radius: 99px;
  background: var(--surface-soft);
}

.frequency-item__bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--sage), var(--sage-deep));
}

.frequency-item--bad .frequency-item__bar-fill {
  background: linear-gradient(90deg, #efb19f, var(--coral));
}

.frequency-item__count {
  color: var(--ink);
  font-size: 13px;
  font-weight: 850;
  text-align: right;
}

.mini-trend {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 26px;
  margin-top: 5px;
}

.mini-trend__bar {
  flex: 1;
  min-width: 2px;
  height: 100%;
  border-radius: 3px 3px 1px 1px;
  background: var(--sage-pale);
}

.mini-trend__bar.has-value {
  background: var(--sage);
}

.frequency-item--bad .mini-trend__bar {
  background: var(--coral-pale);
}

.frequency-item--bad .mini-trend__bar.has-value {
  background: #edaa97;
}

.frequency-item__trend-label {
  grid-column: 1 / -1;
  margin-top: -5px;
  color: var(--muted);
  font-size: 10px;
}

.management-card {
  padding: 20px;
}

.management-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 17px;
}

.management-form {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.input,
.select {
  width: 100%;
  min-height: 42px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  outline: none;
  background: var(--surface);
}

.input::placeholder {
  color: #a2aca7;
}

.input:focus,
.select:focus {
  border-color: var(--sage);
  box-shadow: 0 0 0 4px rgba(154, 187, 172, 0.16);
}

.management-list {
  display: grid;
  gap: 8px;
}

.management-row {
  min-height: 43px;
  padding: 8px 10px 8px 13px;
  border-radius: 12px;
  background: var(--surface-soft);
}

.management-row__name {
  min-width: 0;
  overflow: hidden;
  font-size: 13px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.management-row__meta {
  margin-left: 7px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
}

.management-row__actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.is-inactive {
  opacity: 0.53;
}

.data-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.empty-state {
  padding: 40px 20px;
  border: 1px dashed #d1dbd1;
  border-radius: var(--radius-md);
  text-align: center;
  background: rgba(255, 255, 255, 0.56);
}

.empty-state__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  margin-bottom: 13px;
  border-radius: 17px;
  background: var(--sage-pale);
  font-size: 23px;
}

.empty-state h3 {
  margin-bottom: 5px;
}

.modal-backdrop {
  position: fixed;
  z-index: 40;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 14px;
  background: rgba(25, 39, 34, 0.35);
  backdrop-filter: blur(5px);
}

.modal {
  width: min(100%, 540px);
  max-height: min(86vh, 760px);
  overflow: auto;
  padding: 23px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 25px;
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(24, 44, 35, 0.25);
  animation: modal-in 180ms ease-out;
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-header {
  align-items: flex-start;
  margin-bottom: 20px;
}

.modal-header h2 {
  font-size: 23px;
}

.modal-close {
  flex: 0 0 auto;
}

.modal-section {
  margin-top: 22px;
}

.modal-section--time {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
}

.modal-section--time .modal-section__title {
  display: block;
}

.meal-time-input {
  color-scheme: light;
  background: var(--surface);
}

.modal-section--time .modal-note {
  margin: 7px 1px 0;
}

.modal-section__title {
  margin: 0 0 10px;
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.02em;
}

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

.choice-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.choice-label {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 70px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 15px;
  color: var(--muted-strong);
  background: var(--surface);
  text-align: center;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease, transform 160ms ease;
}

.choice-label:hover {
  transform: translateY(-1px);
  border-color: var(--sage);
}

.choice-input:checked + .choice-label {
  border-color: var(--sage-deep);
  color: var(--ink);
  background: var(--sage-pale);
  box-shadow: inset 0 0 0 1px var(--sage-deep);
}

.choice-label__number {
  display: block;
  margin-bottom: 4px;
  font-size: 23px;
  font-weight: 900;
  line-height: 1;
}

.choice-label__text {
  display: block;
  font-size: 11px;
  font-weight: 700;
}

.check-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.check-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.check-label {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 99px;
  color: var(--muted-strong);
  background: var(--surface);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease;
}

.check-label:hover {
  border-color: var(--sage);
}

.check-input:checked + .check-label {
  border-color: var(--sage-deep);
  color: var(--sage-deep);
  background: var(--sage-pale);
}

.check-input--bad:checked + .check-label {
  border-color: var(--coral);
  color: #a55743;
  background: var(--coral-pale);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 25px;
}

.modal-note {
  margin-top: 12px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.toast-root {
  position: fixed;
  z-index: 80;
  right: 14px;
  bottom: 92px;
  left: 14px;
  display: flex;
  justify-content: center;
  pointer-events: none;
}

.toast {
  max-width: min(100%, 410px);
  padding: 12px 16px;
  border-radius: 13px;
  color: #fff;
  background: rgba(36, 48, 45, 0.94);
  box-shadow: var(--shadow);
  font-size: 13px;
  animation: toast-in 180ms ease-out;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(7px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.noscript-card {
  max-width: 480px;
  margin: 40px auto;
  padding: 22px;
  border-radius: 18px;
  background: #fff;
  text-align: center;
}

@media (min-width: 760px) {
  .app-main {
    padding-top: 42px;
  }

  .bottom-nav {
    right: 24px;
    bottom: 20px;
    left: auto;
    width: 390px;
    padding: 8px 10px;
    border: 1px solid rgba(226, 232, 225, 0.96);
    border-radius: 22px;
  }

  .modal-backdrop {
    align-items: center;
  }
}

@media (max-width: 720px) {
  .chart-grid--two,
  .meal-list {
    grid-template-columns: 1fr;
  }

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

  .chart-card--wide {
    grid-column: auto;
  }
}

@media (max-width: 520px) {
  html,
  body,
  .app-shell {
    max-width: 100%;
    overflow-x: hidden;
  }

  .app-main {
    width: min(100% - 22px, var(--content-width));
    min-width: 0;
    padding: 20px 0 calc(116px + env(safe-area-inset-bottom));
  }

  .page-stack,
  .page-stack > *,
  .chart-card {
    min-width: 0;
  }

  .page-stack {
    gap: 18px;
  }

  .topbar {
    align-items: flex-start;
    gap: 10px;
  }

  .topbar h1 {
    font-size: clamp(27px, 9vw, 34px);
  }

  .analysis-toolbar {
    align-items: stretch;
    flex-direction: column;
    padding: 13px 14px;
  }

  .analysis-toolbar .segmented-control {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }

  .analysis-toolbar .segmented-control button {
    width: 100%;
    padding: 0 6px;
  }

  .section-heading {
    align-items: flex-start;
    gap: 8px;
  }

  .section-heading > div {
    min-width: 0;
  }

  .section-heading .small-badge {
    flex: 0 0 auto;
    margin-top: 2px;
  }

  .topbar__mark {
    width: 38px;
    height: 38px;
  }

  .hero {
    padding: 24px 20px;
  }

  .hero__footer {
    margin-top: 23px;
  }

  .summary-grid {
    gap: 8px;
  }

  .summary-card {
    padding: 14px 12px;
  }

  .summary-card__value {
    font-size: 21px;
  }

  .meal-card,
  .chart-card,
  .management-card {
    padding: 17px;
  }

  .slot-row {
    grid-template-columns: 62px minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
  }

  .analysis-insight {
    padding: 16px;
  }

  .analysis-insight strong {
    font-size: 18px;
    line-height: 1.42;
  }

  .analysis-insight p {
    line-height: 1.5;
  }

  .analysis-metric {
    padding: 14px 12px;
  }

  .analysis-metric strong {
    font-size: 21px;
  }

  .analysis-metric span {
    font-size: 11px;
  }

  .rhythm-matrix-wrap {
    width: 100%;
    overflow: visible;
  }

  .rhythm-matrix {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
    border-spacing: 3px;
  }

  .rhythm-matrix th {
    padding: 5px 2px;
    font-size: 8px;
    line-height: 1.25;
    overflow-wrap: anywhere;
  }

  .rhythm-matrix thead th:first-child,
  .rhythm-matrix tbody th {
    width: 62px;
  }

  .rhythm-matrix tbody th {
    padding-right: 4px;
  }

  .rhythm-cell {
    min-width: 0;
    height: 49px;
    padding: 5px 2px;
    border-radius: 9px;
  }

  .rhythm-cell strong {
    font-size: 14px;
  }

  .rhythm-cell span {
    font-size: 8px;
  }

  .chart-note {
    line-height: 1.5;
  }

  .slot-outcome {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .slot-outcome__name {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
  }

  .slot-outcome__name span {
    margin-top: 0;
  }

  .slot-outcome--sparse {
    grid-template-columns: 1fr;
  }

  .association-item__header {
    align-items: flex-start;
  }

  .association-item {
    padding: 12px;
  }

  .association-item__outcomes {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
  }

  .association-item__outcomes span {
    padding: 6px 5px;
    text-align: center;
  }

  .frequency-item {
    grid-template-columns: minmax(82px, 0.72fr) minmax(120px, 1fr) 29px;
    gap: 8px;
  }

  .management-form {
    align-items: stretch;
    flex-direction: column;
  }

  .modal {
    padding: 20px 17px;
    border-radius: 22px 22px 0 0;
  }
}

/* Selected Product Design direction: daily timeline */
.ui-icon {
  display: inline-block;
  flex: 0 0 auto;
  width: 1em;
  height: 1em;
  background-color: currentColor;
  -webkit-mask-image: var(--icon-image);
  mask-image: var(--icon-image);
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-size: contain;
  mask-size: contain;
}

.page-stack--record {
  gap: 28px;
  max-width: 760px;
  margin: 0 auto;
}

.page-stack--record .topbar {
  align-items: flex-start;
}

.page-stack--record .topbar h1 {
  color: var(--ink);
  font-size: clamp(36px, 10vw, 50px);
  letter-spacing: -0.075em;
}

.page-stack--record .topbar .eyebrow {
  margin-bottom: 12px;
  font-size: 14px;
  letter-spacing: 0.08em;
}

.daily-overview {
  padding: 18px 18px 16px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 254, 250, 0.72);
  box-shadow: none;
}

.daily-overview__date {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.daily-overview__date time {
  flex: 1;
  color: var(--muted-strong);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.overview-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  color: var(--sage-deep);
  background: var(--surface-soft);
}

.overview-icon .ui-icon {
  width: 20px;
  height: 20px;
}

.daily-overview__date .topbar__mark {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  color: #fff;
  background: var(--sage-deep);
  box-shadow: none;
}

.daily-overview__date .topbar__mark .ui-icon {
  width: 22px;
  height: 22px;
}

.daily-overview__stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  padding-top: 18px;
}

.daily-stat {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.daily-stat + .daily-stat {
  padding-left: 16px;
  border-left: 1px solid var(--line);
}

.daily-stat__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 50%;
}

.daily-stat__icon .ui-icon {
  width: 21px;
  height: 21px;
}

.daily-stat__icon--complete {
  color: #fff;
  background: var(--sage-deep);
}

.daily-stat__icon--history {
  color: var(--sage-deep);
  background: var(--surface-soft);
}

.daily-stat strong {
  display: block;
  margin-bottom: 2px;
  color: var(--ink);
  font-size: 28px;
  line-height: 1;
  letter-spacing: -0.05em;
}

.daily-stat span:not(.daily-stat__icon):not(.ui-icon) {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.page-stack--record .section-heading {
  margin-bottom: 12px;
}

.page-stack--record .section-heading h2 {
  font-size: 28px;
  letter-spacing: -0.06em;
}

.page-stack--record .section-copy {
  margin-top: 8px;
  font-size: 14px;
}

.page-stack--record .meal-list {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
}

.page-stack--record .meal-list::before {
  position: absolute;
  top: 30px;
  bottom: 30px;
  left: 10px;
  width: 1px;
  background: var(--line);
  content: "";
}

.page-stack--record .meal-card {
  position: relative;
  display: grid;
  grid-template-columns: 22px 58px minmax(0, 1fr) 116px;
  align-items: center;
  gap: 10px;
  min-height: 128px;
  padding: 18px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.page-stack--record .meal-card:last-child {
  border-bottom: 0;
}

.meal-card__marker {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  color: var(--muted);
  background: var(--bg);
}

.meal-card__marker .ui-icon {
  width: 18px;
  height: 18px;
}

.page-stack--record .meal-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  font-size: initial;
}

.page-stack--record .meal-icon .ui-icon {
  width: 31px;
  height: 31px;
}

.meal-card--amber .meal-card__marker,
.meal-card--amber .meal-icon,
.meal-card--amber .meal-card__cta {
  color: var(--amber);
}

.meal-card--amber .meal-icon {
  background: var(--amber-pale);
}

.meal-card--sage .meal-card__marker,
.meal-card--sage .meal-icon,
.meal-card--sage .meal-card__cta {
  color: var(--sage-deep);
}

.meal-card--sage .meal-icon {
  background: var(--surface-soft);
}

.meal-card--lavender .meal-card__marker,
.meal-card--lavender .meal-icon,
.meal-card--lavender .meal-card__cta {
  color: var(--lavender);
}

.meal-card--lavender .meal-icon {
  background: var(--lavender-pale);
}

.meal-card--coral .meal-card__marker,
.meal-card--coral .meal-icon,
.meal-card--coral .meal-card__cta {
  color: var(--coral);
}

.meal-card--coral .meal-icon {
  background: var(--coral-pale);
}

.meal-card__details {
  min-width: 0;
}

.page-stack--record .meal-card__title {
  color: var(--ink);
  font-size: 21px;
  letter-spacing: -0.04em;
}

.page-stack--record .meal-card__time {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.meal-card__status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 27px;
  margin-top: 9px;
  padding: 0 11px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.meal-card__status .ui-icon {
  width: 12px;
  height: 12px;
}

.page-stack--record .status-pill--empty,
.page-stack--record .meal-card__status.status-pill--empty {
  color: var(--muted);
  background: var(--surface-soft);
}

.meal-card__cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 58px;
  padding: 0 12px;
  border: 1.5px solid currentColor;
  border-radius: 17px;
  background: transparent;
  font-size: 13px;
  font-weight: 850;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.meal-card__cta .ui-icon {
  width: 20px;
  height: 20px;
}

.meal-card__cta:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.76);
}

.meal-card__cta--complete {
  border-color: transparent;
  color: var(--sage-deep) !important;
  background: rgba(218, 231, 220, 0.72);
}

.page-stack--record .meal-card--amber .meal-card__status.status-pill--complete,
.page-stack--record .meal-card--amber .meal-card__cta--complete {
  color: var(--amber) !important;
  background: var(--amber-pale);
}

.page-stack--record .meal-card--sage .meal-card__status.status-pill--complete,
.page-stack--record .meal-card--sage .meal-card__cta--complete {
  color: var(--sage-deep) !important;
  background: var(--sage-pale);
}

.page-stack--record .meal-card--lavender .meal-card__status.status-pill--complete,
.page-stack--record .meal-card--lavender .meal-card__cta--complete {
  color: var(--lavender) !important;
  background: var(--lavender-pale);
}

.page-stack--record .meal-card--coral .meal-card__status.status-pill--complete,
.page-stack--record .meal-card--coral .meal-card__cta--complete {
  color: var(--coral) !important;
  background: var(--coral-pale);
}

.page-stack--record .helper-strip {
  justify-content: center;
  padding: 17px 18px;
  border: 0;
  border-radius: 0;
  color: var(--sage-deep);
  background: transparent;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
}

.page-stack--record .helper-strip__icon {
  display: inline-flex;
  color: var(--sage-deep);
}

.page-stack--record .helper-strip__icon .ui-icon {
  width: 18px;
  height: 18px;
}

.history-row__icon .ui-icon,
.empty-state__icon .ui-icon,
.management-card__header .topbar__mark .ui-icon {
  width: 20px;
  height: 20px;
}

.modal-close .ui-icon {
  width: 16px;
  height: 16px;
}

@media (max-width: 520px) {
  .page-stack--record {
    gap: 24px;
  }

  .daily-overview {
    padding: 16px 15px 14px;
  }

  .daily-overview__date time {
    font-size: 14px;
  }

  .daily-overview__stats {
    gap: 10px;
  }

  .daily-stat {
    gap: 9px;
  }

  .daily-stat + .daily-stat {
    padding-left: 10px;
  }

  .daily-stat__icon {
    width: 38px;
    height: 38px;
  }

  .daily-stat__icon .ui-icon {
    width: 18px;
    height: 18px;
  }

  .daily-stat strong {
    font-size: 25px;
  }

  .page-stack--record .section-heading h2 {
    font-size: 25px;
  }

  .page-stack--record .meal-card {
    grid-template-columns: 20px 50px minmax(0, 1fr) 102px;
    gap: 8px;
    min-height: 118px;
    padding: 16px 0;
  }

  .page-stack--record .meal-icon {
    width: 50px;
    height: 50px;
  }

  .page-stack--record .meal-icon .ui-icon {
    width: 27px;
    height: 27px;
  }

  .page-stack--record .meal-card__title {
    font-size: 19px;
  }

  .page-stack--record .meal-card__time {
    font-size: 12px;
  }

  .meal-card__status {
    margin-top: 7px;
    padding: 0 9px;
    font-size: 11px;
  }

  .meal-card__cta {
    min-height: 54px;
    padding: 0 9px;
    border-radius: 15px;
    font-size: 12px;
  }

  .meal-card__cta .ui-icon {
    width: 18px;
    height: 18px;
  }
}
