:root {
  color-scheme: light;
  --ink: #172424;
  --muted: #64716f;
  --line: #dce3e1;
  --surface: #ffffff;
  --canvas: #f3f6f5;
  --teal-950: #173c3b;
  --teal-700: #2f746a;
  --teal-500: #4f9585;
  --teal-100: #dcece7;
  --coral: #cf6d56;
  --coral-soft: #f4e2dc;
  --amber: #c78e2e;
  --amber-soft: #f5ead5;
  --blue: #4f7897;
  --blue-soft: #dfe9f0;
  --danger: #b34242;
  --shadow: 0 10px 30px rgba(23, 60, 59, 0.08);
  --sidebar-width: 232px;
  --bottom-nav-height: 68px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--canvas);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  color: inherit;
}

button,
label[for],
.meal-row {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(79, 149, 133, 0.25);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #e8efed;
}

.login-panel {
  width: min(100%, 390px);
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

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

.brand-mark {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--teal-950);
  border-radius: 8px;
  font-size: 19px;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand strong {
  font-size: 17px;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.brand-login {
  margin-bottom: 36px;
}

.brand-login .brand-mark {
  width: 48px;
  height: 48px;
  flex-basis: 48px;
  font-size: 22px;
}

.brand-login strong {
  font-size: 22px;
}

.login-form label,
.field > span {
  display: block;
  margin-bottom: 7px;
  color: #3b4a48;
  font-size: 13px;
  font-weight: 650;
}

.password-field,
.unit-field {
  position: relative;
}

input,
textarea {
  width: 100%;
  color: var(--ink);
  background: #fff;
  border: 1px solid #cbd5d2;
  border-radius: 6px;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

input {
  height: 46px;
  padding: 0 13px;
}

textarea {
  min-height: 96px;
  padding: 12px 13px;
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: var(--teal-500);
  box-shadow: 0 0 0 3px rgba(79, 149, 133, 0.12);
  outline: none;
}

.password-field input {
  padding-right: 48px;
}

.password-field .icon-button {
  position: absolute;
  top: 3px;
  right: 3px;
}

.form-error {
  min-height: 19px;
  margin: 8px 0 10px;
  color: var(--danger);
  font-size: 13px;
}

.button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  transition: background-color 150ms ease, border-color 150ms ease, transform 100ms ease;
}

.button:active,
.icon-button:active,
.quick-action:active {
  transform: translateY(1px);
}

.button svg {
  width: 17px;
  height: 17px;
}

.button-wide {
  width: 100%;
}

.button-primary {
  color: #fff;
  background: var(--teal-950);
}

.button-primary:hover {
  background: #24514f;
}

.button-secondary {
  color: var(--teal-950);
  background: #fff;
  border-color: #cbd5d2;
}

.button-secondary:hover {
  border-color: var(--teal-500);
}

.button-danger {
  color: var(--danger);
  background: #fff;
  border-color: #e5c6c6;
}

.icon-button {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  color: #51605e;
  background: transparent;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}

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

.icon-button svg {
  width: 20px;
  height: 20px;
  stroke-width: 2;
}

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

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  padding: 24px 16px 18px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.sidebar .brand {
  padding: 0 8px 25px;
}

.primary-nav {
  display: grid;
  gap: 4px;
}

.nav-item {
  width: 100%;
  height: 44px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 12px;
  color: #50605d;
  background: transparent;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 650;
  text-align: left;
}

.nav-item:hover {
  color: var(--ink);
  background: #f0f4f2;
}

.nav-item.active {
  color: #fff;
  background: var(--teal-950);
}

.nav-item svg {
  width: 19px;
  height: 19px;
}

.sidebar-status {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  font-size: 12px;
}

.status-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  background: var(--amber);
  border-radius: 50%;
}

.status-dot.online {
  background: #3f986f;
}

.status-dot.offline {
  background: var(--danger);
}

.logout-button {
  margin-top: 4px;
}

.main-content {
  min-height: 100vh;
  margin-left: var(--sidebar-width);
  padding: 0 40px 56px;
}

.topbar {
  min-height: 92px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--line);
}

.topbar h1 {
  margin: 3px 0 0;
  font-size: 24px;
  line-height: 1.2;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.profile-button {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--coral);
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.page {
  display: none;
  max-width: 1120px;
  margin: 0 auto;
  padding-top: 28px;
}

.page.active {
  display: block;
}

.date-toolbar {
  width: fit-content;
  display: flex;
  align-items: center;
  gap: 2px;
  margin-bottom: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.date-button {
  min-width: 180px;
  min-height: 46px;
  padding: 5px 14px;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.date-button span,
.date-button small {
  display: block;
}

.date-button span {
  font-weight: 750;
}

.date-button small {
  margin-top: 1px;
  color: var(--muted);
  font-size: 11px;
}

.daily-overview {
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(440px, 1.2fr);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.calorie-overview {
  padding: 24px;
  border-right: 1px solid var(--line);
}

.section-heading {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.section-heading h2 {
  margin: 3px 0 0;
  font-size: 18px;
  line-height: 1.25;
}

.compact-heading {
  margin-bottom: 26px;
}

.compact-heading h2 {
  font-size: 31px;
}

.compact-heading h2 small {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.range-label,
.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 9px;
  color: var(--teal-950);
  background: var(--teal-100);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 750;
}

.progress-track,
.mini-track {
  overflow: hidden;
  background: #e5eae8;
  border-radius: 4px;
}

.progress-track {
  height: 10px;
}

.progress-track span,
.mini-track span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--teal-500);
  transition: width 280ms ease;
}

.progress-track span.over,
.mini-track span.over {
  background: var(--coral);
}

.progress-caption {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
}

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

.macro-cell {
  min-width: 0;
  min-height: 126px;
  padding: 20px;
}

.macro-cell:nth-child(odd) {
  border-right: 1px solid var(--line);
}

.macro-cell:nth-child(-n + 2) {
  border-bottom: 1px solid var(--line);
}

.macro-label {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.macro-label > span {
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

.macro-protein .macro-label > span,
.macro-protein .mini-track span {
  background: var(--teal-500);
}

.macro-fat .macro-label > span,
.macro-fat .mini-track span {
  background: var(--coral);
}

.macro-carbs .macro-label > span,
.macro-carbs .mini-track span {
  background: var(--amber);
}

.macro-fiber .macro-label > span,
.macro-fiber .mini-track span {
  background: var(--blue);
}

.macro-cell strong {
  display: block;
  margin-top: 9px;
  font-size: 21px;
}

.macro-cell small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.mini-track {
  height: 5px;
  margin-top: 12px;
}

.quick-actions {
  display: grid;
  grid-template-columns: 1.3fr repeat(3, 1fr);
  gap: 10px;
}

.day-actions {
  margin-top: 14px;
}

.secondary-actions {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  padding-top: 10px;
}

.more-actions {
  margin-top: 8px;
}

.more-actions summary,
.guidance-details summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  list-style: none;
}

.more-actions summary::-webkit-details-marker,
.guidance-details summary::-webkit-details-marker {
  display: none;
}

.more-actions summary {
  min-height: 42px;
  padding: 0 12px;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
}

.more-actions summary svg,
.guidance-details summary svg {
  width: 17px;
  height: 17px;
  transition: transform 160ms ease;
}

.more-actions[open] summary svg,
.guidance-details[open] summary svg {
  transform: rotate(180deg);
}

.quick-action {
  min-width: 0;
  min-height: 70px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
}

.quick-action:hover {
  border-color: #aabbb6;
}

.quick-action > svg {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  color: var(--teal-700);
}

.quick-action span {
  min-width: 0;
}

.quick-action strong,
.quick-action small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quick-action strong {
  font-size: 13px;
}

.quick-action small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.primary-action {
  color: #fff;
  background: var(--teal-950);
  border-color: var(--teal-950);
}

.primary-action > svg,
.primary-action small {
  color: #d6e5e1;
}

.content-section {
  margin-top: 26px;
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.meal-timeline,
.diary-list {
  display: grid;
  gap: 2px;
}

.meal-row {
  min-width: 0;
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px 8px;
  border-bottom: 1px solid #e7ecea;
  cursor: pointer;
}

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

.meal-row:hover {
  background: #f7f9f8;
}

.meal-row:focus-visible {
  outline: 2px solid var(--teal-700);
  outline-offset: -2px;
}

.meal-time {
  color: var(--teal-700);
  font-size: 10px;
  font-weight: 750;
  white-space: nowrap;
}

.meal-thumb {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: var(--teal-700);
  background: var(--teal-100);
  border-radius: 6px;
}

.meal-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.meal-thumb svg {
  width: 22px;
  height: 22px;
}

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

.meal-heading-line {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.meal-heading-line strong {
  min-width: 0;
}

.meal-main strong,
.meal-main small {
  display: block;
}

.meal-main strong {
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meal-main small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.meal-side {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
}

.meal-calories {
  font-size: 13px;
  font-weight: 750;
  white-space: nowrap;
}

.meal-repeat-button {
  width: 34px;
  height: 34px;
  flex-basis: 34px;
  color: var(--teal-700);
}

.meal-repeat-button svg {
  width: 17px;
  height: 17px;
}

.accuracy-badge {
  width: fit-content;
  display: inline-flex;
  margin-top: 6px;
  padding: 3px 6px;
  color: var(--teal-950);
  background: var(--teal-100);
  border-radius: 5px;
  font-size: 10px;
  font-weight: 750;
  text-align: center;
}

.accuracy-badge.low {
  color: #784d1f;
  background: var(--amber-soft);
}

.empty-state {
  min-height: 190px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  color: var(--muted);
  text-align: center;
}

.empty-state svg {
  width: 30px;
  height: 30px;
  color: #94a39f;
}

.empty-state strong {
  color: #43514f;
  font-size: 14px;
}

.empty-state span {
  font-size: 12px;
}

.diary-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
}

.diary-date-copy {
  min-width: 132px;
  display: grid;
  gap: 2px;
}

.diary-date-copy small {
  color: var(--muted);
  font-size: 10px;
}

.diary-date-copy strong {
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.diary-toolbar input {
  width: 150px;
}

.diary-toolbar .button {
  margin-left: auto;
}

.week-strip {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 5px;
  margin-bottom: 12px;
}

.week-day {
  min-width: 0;
  min-height: 58px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}

.week-day span {
  font-size: 9px;
  text-transform: uppercase;
}

.week-day strong {
  font-size: 15px;
}

.week-day.today:not(.active) strong {
  color: var(--coral);
}

.week-day.active {
  color: #fff;
  background: var(--teal-950);
  border-color: var(--teal-950);
}

.diary-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.diary-stat {
  min-width: 0;
  padding: 16px 18px;
  border-right: 1px solid var(--line);
}

.diary-stat:last-child {
  border-right: 0;
}

.diary-stat small,
.diary-stat strong {
  display: block;
}

.diary-stat small {
  color: var(--muted);
  font-size: 11px;
}

.diary-stat strong {
  margin-top: 4px;
  font-size: 18px;
}

.diary-list {
  margin-top: 16px;
  padding: 8px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric-block {
  min-width: 0;
  min-height: 94px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: transparent;
  border: 0;
  border-right: 1px solid var(--line);
  cursor: pointer;
  text-align: left;
}

.metric-block:last-child {
  border-right: 0;
}

.metric-block:hover {
  background: #f7f9f8;
}

.metric-icon {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: grid;
  place-items: center;
  color: var(--teal-700);
  background: var(--teal-100);
  border-radius: 6px;
}

.metric-icon.coral {
  color: var(--coral);
  background: var(--coral-soft);
}

.metric-icon.amber {
  color: var(--amber);
  background: var(--amber-soft);
}

.metric-icon.blue {
  color: var(--blue);
  background: var(--blue-soft);
}

.metric-icon svg {
  width: 19px;
  height: 19px;
}

.metric-block small,
.metric-block strong {
  display: block;
  white-space: nowrap;
}

.metric-block small {
  color: var(--muted);
  font-size: 11px;
}

.metric-block strong {
  margin-top: 4px;
  font-size: 18px;
}

.measurement-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.measurement-item {
  min-width: 0;
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 15px;
  color: inherit;
  background: transparent;
  border: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  text-align: left;
}

.measurement-item:nth-child(3n) {
  border-right: 0;
}

.measurement-item:nth-last-child(-n + 3) {
  border-bottom: 0;
}

.measurement-item:hover {
  background: #f7f9f8;
}

.measurement-item span {
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.measurement-item strong {
  flex: 0 0 auto;
  font-size: 15px;
  white-space: nowrap;
}

.composition-grid .measurement-item:last-child {
  border-bottom: 0;
}

.data-note {
  margin: 13px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.chart-container {
  width: 100%;
  height: 260px;
  overflow: hidden;
}

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

.chart-grid {
  stroke: #e4eae8;
  stroke-width: 1;
}

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

.chart-area {
  fill: rgba(79, 149, 133, 0.12);
}

.chart-point {
  fill: #fff;
  stroke: var(--teal-700);
  stroke-width: 3;
}

.chart-label {
  fill: var(--muted);
  font-family: inherit;
  font-size: 11px;
}

.chart-empty {
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
}

.week-table,
.target-table {
  display: grid;
}

.week-table > div,
.target-table > div {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid #e6ebe9;
}

.week-table > div:last-child,
.target-table > div:last-child {
  border-bottom: 0;
}

.week-table span,
.target-table span {
  color: var(--muted);
  font-size: 13px;
}

.week-table strong,
.target-table strong {
  font-size: 14px;
  text-align: right;
}

.plan-header-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  padding: 24px;
  color: #fff;
  background: var(--teal-950);
  border-radius: 8px;
}

.plan-header-band h2 {
  margin: 4px 0 7px;
  font-size: 22px;
}

.plan-header-band p:last-child {
  max-width: 620px;
  margin: 0;
  color: #cbdcda;
  font-size: 13px;
}

.plan-header-band .eyebrow {
  color: #b7d0cb;
}

.plan-target {
  min-width: 160px;
  padding-left: 24px;
  border-left: 1px solid rgba(255, 255, 255, 0.2);
}

.plan-target span,
.plan-target strong,
.plan-target small {
  display: block;
}

.plan-target span,
.plan-target small {
  color: #cbdcda;
  font-size: 11px;
}

.plan-target strong {
  margin: 5px 0 3px;
  font-size: 19px;
}

.target-table {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 30px;
}

.workout-list {
  display: grid;
}

.workout-row {
  min-width: 0;
  min-height: 68px;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 13px;
  border-bottom: 1px solid #e6ebe9;
}

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

.workout-day {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: var(--teal-950);
  background: var(--teal-100);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 800;
}

.workout-day.coral {
  color: var(--coral);
  background: var(--coral-soft);
}

.workout-day.amber {
  color: #835a15;
  background: var(--amber-soft);
}

.workout-row strong,
.workout-row small {
  display: block;
}

.workout-row strong {
  font-size: 14px;
}

.workout-row small {
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workout-row > span:last-child {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.chat-page {
  max-width: 900px;
  height: calc(100vh - 92px);
  padding-top: 18px;
}

.chat-page.active {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.chat-toolbar {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.chat-toolbar > div {
  display: flex;
  align-items: center;
  gap: 10px;
}

.assistant-avatar {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--teal-950);
  border-radius: 8px;
}

.assistant-avatar svg {
  width: 18px;
  height: 18px;
}

.chat-toolbar strong,
.chat-toolbar small {
  display: block;
}

.chat-toolbar strong {
  font-size: 14px;
}

.chat-toolbar small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.chat-messages {
  min-height: 0;
  overflow-y: auto;
  padding: 24px 2px;
  scrollbar-width: thin;
}

.chat-welcome {
  max-width: 600px;
  margin: 9vh auto 0;
  text-align: center;
}

.chat-welcome > strong,
.chat-welcome > span {
  display: block;
}

.chat-welcome > strong {
  font-size: 21px;
}

.chat-welcome > span {
  margin-top: 9px;
  color: var(--muted);
  line-height: 1.6;
}

.suggestion-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 22px;
}

.suggestion-row button {
  min-height: 36px;
  padding: 0 12px;
  color: #40514e;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}

.chat-message {
  max-width: 76%;
  margin-bottom: 16px;
}

.chat-message.user {
  margin-left: auto;
}

.chat-bubble {
  padding: 11px 13px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.chat-message-text:empty {
  display: none;
}

.chat-bubble.attachment-only .chat-attachment-image,
.chat-bubble.attachment-only .chat-file-card {
  margin-bottom: 0;
}

.chat-attachment-image {
  width: min(330px, 100%);
  display: block;
  overflow: hidden;
  margin-bottom: 9px;
  background: #edf3f1;
  border: 1px solid rgba(23, 60, 59, 0.13);
  border-radius: 6px;
}

.chat-attachment-image img {
  width: 100%;
  max-height: 360px;
  display: block;
  object-fit: cover;
}

.chat-file-card {
  min-width: min(310px, 100%);
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 9px;
  margin-bottom: 9px;
  padding: 9px;
  color: var(--ink);
  text-decoration: none;
  background: #f3f7f6;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.chat-file-card > span:first-child {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  color: var(--teal-950);
  background: var(--mint-100);
  border-radius: 6px;
}

.chat-file-card svg {
  width: 17px;
  height: 17px;
}

.chat-file-card__copy,
.chat-file-card__copy strong,
.chat-file-card__copy small {
  min-width: 0;
  display: block;
}

.chat-file-card__copy strong {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-file-card__copy small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.chat-message.user .chat-attachment-image,
.chat-message.user .chat-file-card {
  border-color: rgba(255, 255, 255, 0.22);
}

.chat-message.user .chat-file-card {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.chat-message.user .chat-file-card > span:first-child {
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
}

.chat-message.user .chat-file-card__copy small {
  color: rgba(255, 255, 255, 0.7);
}

.chat-message.user .chat-bubble {
  color: #fff;
  background: var(--teal-950);
  border-color: var(--teal-950);
}

.chat-message time {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
}

.chat-message.user time {
  text-align: right;
}

.chat-message.typing .chat-bubble {
  color: var(--muted);
  font-style: italic;
}

.chat-composer {
  min-height: 68px;
  display: block;
  padding: 10px;
  background: #fff;
  border: 1px solid #cbd5d2;
  border-radius: 8px;
  box-shadow: 0 7px 22px rgba(23, 60, 59, 0.07);
}

.chat-composer-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.chat-composer-row textarea {
  min-height: 40px;
  max-height: 140px;
  padding: 9px 6px;
  border: 0;
  box-shadow: none;
  resize: none;
}

.chat-composer-row textarea:focus {
  box-shadow: none;
}

.attachment-button {
  flex: 0 0 auto;
  color: #45625f;
  background: #edf3f1;
}

.chat-attachment-preview {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 34px;
  align-items: center;
  gap: 9px;
  margin-bottom: 8px;
  padding: 8px;
  background: #f4f7f6;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.chat-attachment-preview[hidden] {
  display: none;
}

.chat-attachment-preview__thumb {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: var(--teal-950);
  background: var(--mint-100);
  border-radius: 6px;
}

.chat-attachment-preview__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-attachment-preview__thumb svg {
  width: 18px;
  height: 18px;
}

.chat-attachment-preview__copy,
.chat-attachment-preview__copy strong,
.chat-attachment-preview__copy small {
  min-width: 0;
  display: block;
}

.chat-attachment-preview__copy strong {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-attachment-preview__copy small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.chat-composer.sending .attachment-button,
.chat-composer.sending .send-button {
  pointer-events: none;
  opacity: 0.55;
}

.send-button {
  color: #fff;
  background: var(--teal-950);
}

.send-button:hover {
  color: #fff;
  background: #24514f;
}

.bottom-nav {
  display: none;
}

.modal {
  width: min(94vw, 620px);
  max-height: min(90vh, 820px);
  padding: 0;
  overflow: hidden;
  background: transparent;
  border: 0;
}

.modal::backdrop {
  background: rgba(16, 29, 29, 0.52);
}

.modal-shell {
  max-height: min(90vh, 820px);
  display: flex;
  flex-direction: column;
  margin: 0;
  overflow: hidden;
  background: var(--surface);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(10, 28, 27, 0.24);
}

.small-modal {
  max-width: 440px;
  margin: auto;
}

.modal-header,
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 17px 20px;
}

.modal-header {
  border-bottom: 1px solid var(--line);
}

.modal-header h2 {
  margin: 3px 0 0;
  font-size: 19px;
}

.modal-body {
  display: grid;
  gap: 16px;
  padding: 20px;
  overflow-y: auto;
}

.modal-footer {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
}

.split-footer {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
}

.photo-drop {
  position: relative;
  min-height: 220px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #eef3f1;
  border: 1px dashed #aebdb9;
  border-radius: 8px;
  cursor: pointer;
}

.photo-stage {
  position: relative;
}

.photo-selected-badge {
  position: absolute;
  left: 12px;
  bottom: 12px;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 9px;
  color: var(--teal-950);
  background: rgba(255, 255, 255, 0.94);
  border-radius: 5px;
  font-size: 11px;
  font-weight: 750;
  box-shadow: 0 3px 10px rgba(23, 60, 59, 0.1);
}

.photo-selected-badge svg {
  width: 14px;
  height: 14px;
}

.photo-remove-button {
  position: absolute;
  top: 10px;
  right: 10px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 3px 12px rgba(23, 60, 59, 0.12);
}

.photo-drop input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.photo-drop img {
  width: 100%;
  max-height: 360px;
  object-fit: contain;
}

.photo-placeholder {
  display: grid;
  place-items: center;
  gap: 7px;
  color: var(--muted);
  text-align: center;
}

.photo-placeholder svg {
  width: 30px;
  height: 30px;
  color: var(--teal-700);
}

.photo-placeholder strong {
  color: #374846;
  font-size: 14px;
}

.photo-placeholder small {
  font-size: 11px;
}

.meal-analysis-status {
  min-height: 72px;
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  color: var(--teal-950);
  background: #e6f1ed;
  border: 1px solid #b9d2c9;
  border-radius: 8px;
}

.meal-analysis-status[hidden] {
  display: none;
}

.meal-analysis-status > span:last-child {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.meal-analysis-status strong,
.meal-analysis-status small {
  display: block;
  overflow-wrap: anywhere;
}

.meal-analysis-status strong {
  font-size: 14px;
}

.meal-analysis-status small {
  color: #526b66;
  font-size: 12px;
  line-height: 1.4;
}

.meal-status-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid rgba(23, 60, 59, 0.2);
  border-top-color: var(--teal-950);
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
}

#mealForm[aria-busy="true"] .photo-drop {
  cursor: default;
}

#mealSubmit:disabled {
  opacity: 0.78;
}

.field {
  display: block;
}

.unit-field input {
  padding-right: 78px;
}

.unit-field span {
  position: absolute;
  top: 0;
  right: 13px;
  height: 46px;
  display: flex;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

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

.loading-layer {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 13px;
  color: #fff;
  background: rgba(18, 37, 36, 0.72);
}

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid rgba(255, 255, 255, 0.28);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 120;
  max-width: min(360px, calc(100vw - 32px));
  padding: 11px 14px;
  color: #fff;
  background: var(--teal-950);
  border-radius: 6px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  background: var(--danger);
}

.chat-composer.sending {
  opacity: 0.72;
  pointer-events: none;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.brand-mark {
  overflow: hidden;
  padding: 0;
  background: var(--teal-950);
}

.brand-mark img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.guidance-panel {
  margin-bottom: 14px;
  padding: 22px;
  color: #f8fbfa;
  background: var(--teal-950);
  border: 1px solid #315553;
  border-radius: 8px;
}

.guidance-main {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  align-items: start;
  gap: 15px;
}

.guidance-icon {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  color: var(--teal-950);
  background: #bcded3;
  border-radius: 8px;
}

.guidance-icon svg {
  width: 23px;
  height: 23px;
}

.guidance-panel .eyebrow {
  color: #a8c8c1;
}

.guidance-panel h2 {
  margin: 3px 0 6px;
  font-size: 21px;
}

.guidance-panel p {
  margin: 0;
  color: #cfdfdc;
  line-height: 1.5;
}

.guidance-panel #guidanceTiming {
  display: block;
  margin-top: 8px;
  color: #fff;
  font-size: 13px;
}

.guidance-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 20px;
}

.guidance-add-button {
  min-height: 44px;
  color: var(--teal-950);
  background: #bcded3;
  border-color: #bcded3;
}

.guidance-add-button:hover {
  background: #d0e7e0;
}

.guidance-details {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.guidance-details summary {
  min-height: 28px;
  color: #dbe9e6;
  font-size: 12px;
  font-weight: 750;
}

.guidance-columns {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  gap: 24px;
  margin-top: 14px;
  padding-top: 0;
}

.guidance-columns h3 {
  margin: 0 0 10px;
  color: #a8c8c1;
  font-size: 11px;
  text-transform: uppercase;
}

.guidance-columns ul {
  display: grid;
  gap: 7px;
  margin: 0;
  padding-left: 18px;
  color: #f7fbfa;
  font-size: 13px;
  line-height: 1.35;
}

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

.meal-option {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 18px;
  gap: 2px 10px;
  padding: 9px 10px;
  color: #fff;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
}

.meal-option strong,
.meal-option small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meal-option strong {
  font-size: 12px;
}

.meal-option small {
  grid-column: 1;
  color: #bcd0cc;
  font-size: 10px;
}

.meal-option svg {
  grid-column: 2;
  grid-row: 1 / span 2;
  width: 16px;
  height: 16px;
  align-self: center;
}

.guidance-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.guidance-actions .button-secondary {
  color: #fff;
  background: transparent;
  border-color: rgba(255, 255, 255, 0.28);
}

.guidance-actions .button-primary {
  color: var(--teal-950);
  background: #bcded3;
  border-color: #bcded3;
}

.favorite-star {
  width: 14px;
  height: 14px;
  margin-right: 5px;
  color: var(--amber);
  fill: currentColor;
  vertical-align: -2px;
}

.meal-job {
  cursor: default;
}

.meal-job.pending {
  background: #f3f8f6;
}

.meal-row.just-added {
  animation: meal-highlight 1.8s ease;
}

@keyframes meal-highlight {
  0%, 35% {
    background: #dcece7;
    box-shadow: inset 3px 0 0 var(--teal-500);
  }
  100% {
    background: transparent;
    box-shadow: inset 0 0 0 transparent;
  }
}

.meal-job.failed {
  background: #fff7f5;
}

.analysis-chip,
.job-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  white-space: nowrap;
}

.analysis-chip {
  color: var(--teal-700);
  font-size: 11px;
  font-weight: 750;
}

.analysis-chip .meal-status-spinner {
  width: 16px;
  height: 16px;
  border-width: 2px;
}

.mini-action {
  min-height: 30px;
  padding: 0 9px;
  color: var(--teal-950);
  background: #fff;
  border: 1px solid #aebfba;
  border-radius: 5px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
}

.mini-action.danger {
  width: 30px;
  padding: 0;
  color: var(--danger);
}

.mini-action svg {
  width: 14px;
  height: 14px;
}

.weekly-report {
  margin-bottom: 22px;
  padding: 22px;
  background: #fff;
  border: 1px solid var(--line);
  border-top: 4px solid var(--coral);
  border-radius: 8px;
}

.report-status {
  padding: 5px 8px;
  color: #5c5f47;
  background: var(--amber-soft);
  border-radius: 5px;
  font-size: 11px;
  font-weight: 750;
}

.report-status.on_track {
  color: var(--teal-950);
  background: var(--teal-100);
}

.report-status.fast {
  color: var(--danger);
  background: #f8e1de;
}

.report-conclusion {
  max-width: 760px;
  margin: -5px 0 18px;
  color: var(--muted);
  line-height: 1.5;
}

.report-metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
}

.report-metric {
  min-width: 0;
  padding: 14px;
  border-right: 1px solid var(--line);
}

.report-metric:last-child {
  border-right: 0;
}

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

.report-metric small,
.report-metric span {
  color: var(--muted);
  font-size: 10px;
}

.report-metric strong {
  margin: 7px 0 5px;
  overflow-wrap: anywhere;
  font-size: 16px;
}

.report-footer {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-top: 18px;
}

.report-footer small {
  color: var(--muted);
  font-size: 11px;
}

.report-footer ol {
  margin: 7px 0 0;
  padding-left: 18px;
  line-height: 1.6;
}

.segmented {
  display: inline-grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  padding: 3px;
  background: #e6ecea;
  border-radius: 7px;
}

.segmented button {
  min-height: 36px;
  padding: 0 14px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 5px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.segmented button.active {
  color: var(--ink);
  background: #fff;
  box-shadow: 0 1px 4px rgba(23, 60, 59, 0.12);
}

.plan-tabs {
  width: min(100%, 460px);
  margin-top: 14px;
}

.plan-panel {
  display: none;
}

.plan-panel.active {
  display: block;
}

.workout-start span {
  font-size: 11px;
}

.workout-history {
  display: grid;
}

.workout-history-item {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 40px;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.workout-history-item:last-child {
  border-bottom: 0;
}

.workout-history-item strong,
.workout-history-item small,
.workout-history-item em {
  display: block;
}

.workout-history-item small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.workout-history-item em {
  margin-top: 5px;
  color: var(--teal-700);
  font-size: 11px;
  font-style: normal;
}

.empty-inline {
  padding: 12px 0;
  color: var(--muted);
  font-size: 12px;
}

.day-selector {
  display: grid;
  grid-template-columns: repeat(7, minmax(42px, 1fr));
  gap: 6px;
  overflow-x: auto;
}

.day-selector button {
  min-height: 38px;
  color: var(--muted);
  background: #f4f7f6;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  font-weight: 700;
}

.day-selector button.active {
  color: #fff;
  background: var(--teal-950);
  border-color: var(--teal-950);
}

.menu-day {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.menu-meal {
  min-width: 0;
  min-height: 58px;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: #f5f8f7;
  border: 1px solid #e1e8e5;
  border-radius: 6px;
}

.menu-meal span {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  color: var(--coral);
  background: var(--coral-soft);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 800;
}

.menu-meal strong {
  font-size: 12px;
  line-height: 1.35;
}

.recipe-list,
.recent-meal-list {
  display: grid;
}

.recipe-item,
.recent-meal {
  min-width: 0;
  min-height: 62px;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 20px;
  align-items: center;
  gap: 11px;
  padding: 8px 4px;
  color: inherit;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  text-align: left;
}

.recipe-item:last-child,
.recent-meal:last-child {
  border-bottom: 0;
}

.recipe-item strong,
.recipe-item small,
.recent-meal strong,
.recent-meal small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recipe-item strong,
.recent-meal strong {
  font-size: 13px;
}

.recipe-item small,
.recent-meal small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
}

.recipe-icon,
.recent-meal-icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  color: var(--teal-700);
  background: var(--teal-100);
  border-radius: 6px;
}

.recipe-icon svg,
.recent-meal-icon svg {
  width: 17px;
  height: 17px;
}

.recent-meal.active {
  padding-inline: 8px;
  background: #edf5f2;
}

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

.shopping-group h3 {
  margin: 0 0 8px;
  font-size: 13px;
}

.shopping-item {
  min-height: 38px;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  border-bottom: 1px solid #edf1f0;
  cursor: pointer;
  font-size: 12px;
}

.shopping-item input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.shopping-check {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  color: transparent;
  border: 1px solid #aebcb8;
  border-radius: 4px;
}

.shopping-check svg {
  width: 13px;
  height: 13px;
}

.shopping-item.checked {
  color: #88928f;
  text-decoration: line-through;
}

.shopping-item.checked .shopping-check {
  color: #fff;
  background: var(--teal-700);
  border-color: var(--teal-700);
}

.pantry-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 110px 90px 150px 40px;
  gap: 8px;
}

.primary-icon {
  color: #fff;
  background: var(--teal-950);
}

.pantry-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 22px;
  margin-top: 12px;
}

.pantry-item {
  min-width: 0;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid var(--line);
}

.pantry-item strong,
.pantry-item small {
  display: block;
}

.pantry-item strong {
  font-size: 13px;
}

.pantry-item small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.edit-actions,
.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

#favoriteMealButton.active {
  color: #855a13;
  background: var(--amber-soft);
  border-color: #d9bc84;
}

.repeat-options {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.selected-repeat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 15px;
  padding: 12px;
  background: #f3f7f6;
  border-radius: 6px;
}

.selected-repeat small,
.selected-repeat strong {
  display: block;
}

.selected-repeat small {
  color: var(--muted);
  font-size: 10px;
}

.selected-repeat strong {
  margin-top: 3px;
  font-size: 13px;
}

.selected-repeat b {
  color: var(--teal-700);
  font-size: 12px;
}

.portion-picker {
  width: 100%;
  margin-bottom: 14px;
}

.checkin-tabs {
  width: 100%;
  margin-bottom: 16px;
}

.checkin-fields,
.settings-grid,
.workout-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 11px;
}

.checkin-note {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.45;
}

.wide-modal {
  width: min(1040px, calc(100vw - 32px));
}

.exercise-editor {
  display: grid;
  gap: 8px;
  margin: 15px 0;
}

.exercise-row {
  display: grid;
  grid-template-columns: 28px minmax(200px, 2fr) 90px 110px minmax(110px, 1fr) 90px;
  align-items: end;
  gap: 8px;
  padding: 10px;
  background: #f4f7f6;
  border: 1px solid #e3e9e7;
  border-radius: 6px;
}

.exercise-number {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  margin-bottom: 10px;
  color: #fff;
  background: var(--teal-700);
  border-radius: 5px;
  font-size: 11px;
  font-weight: 800;
}

.exercise-row input {
  height: 40px;
}

.recipe-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.recipe-facts span {
  padding: 6px 8px;
  color: #425250;
  background: #eef3f1;
  border-radius: 5px;
  font-size: 11px;
}

.recipe-detail h3 {
  margin: 20px 0 8px;
  font-size: 14px;
}

.recipe-detail ul,
.recipe-detail ol {
  margin: 0;
  padding-left: 20px;
  line-height: 1.65;
}

.settings-sections {
  gap: 0;
}

.settings-sections section {
  padding: 17px 0;
  border-bottom: 1px solid var(--line);
}

.settings-sections section:first-child {
  padding-top: 0;
}

.settings-sections section:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.settings-sections h3 {
  margin: 0 0 12px;
  font-size: 14px;
}

.settings-actions .button {
  text-decoration: none;
}

.settings-actions .disabled {
  opacity: 0.45;
}

.settings-sections section > small {
  display: block;
  margin-top: 9px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.4;
}

.usage-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.usage-strip > div {
  padding: 12px;
  border-right: 1px solid var(--line);
}

.usage-strip > div:last-child {
  border-right: 0;
}

.usage-strip small,
.usage-strip strong {
  display: block;
}

.usage-strip small {
  color: var(--muted);
  font-size: 10px;
}

.usage-strip strong {
  margin-top: 5px;
  font-size: 17px;
}

@media (max-width: 980px) {
  :root {
    --sidebar-width: 82px;
  }

  .sidebar {
    padding: 20px 11px;
  }

  .sidebar .brand {
    justify-content: center;
    padding: 0 0 24px;
  }

  .sidebar .brand > span:last-child,
  .nav-item span,
  .sidebar-status span:last-child {
    display: none;
  }

  .nav-item {
    justify-content: center;
    padding: 0;
  }

  .sidebar-status {
    justify-content: center;
  }

  .main-content {
    padding-inline: 26px;
  }

  .daily-overview {
    grid-template-columns: 1fr;
  }

  .calorie-overview {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .secondary-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

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

  .measurement-item,
  .measurement-item:nth-child(3n) {
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
  }

  .measurement-item:nth-child(2n) {
    border-right: 0;
  }

  .measurement-item:nth-last-child(-n + 2) {
    border-bottom: 0;
  }

  .measurement-item:nth-last-child(2):nth-child(even) {
    border-bottom: 1px solid var(--line);
  }

  .metric-block:nth-child(2) {
    border-right: 0;
  }

  .metric-block:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 700px) {
  body {
    background: #f5f7f6;
  }

  .login-screen {
    place-items: end center;
    padding: 0;
  }

  .login-panel {
    width: 100%;
    min-height: 56vh;
    padding: 30px 22px max(30px, env(safe-area-inset-bottom));
    border: 0;
    border-radius: 8px 8px 0 0;
    box-shadow: 0 -10px 30px rgba(23, 60, 59, 0.09);
  }

  .sidebar {
    display: none;
  }

  .main-content {
    margin: 0;
    padding: 0 14px calc(var(--bottom-nav-height) + 22px + env(safe-area-inset-bottom));
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    min-height: 72px;
    margin: 0 -14px;
    padding: 0 14px;
    background: rgba(245, 247, 246, 0.96);
    backdrop-filter: blur(10px);
  }

  .topbar h1 {
    font-size: 20px;
  }

  .topbar-actions .icon-button {
    display: none;
  }

  .page {
    padding-top: 14px;
  }

  .date-toolbar {
    width: 100%;
    justify-content: space-between;
  }

  .date-button {
    flex: 1;
    min-width: 0;
  }

  .daily-overview {
    border-radius: 6px;
  }

  .calorie-overview {
    padding: 19px;
  }

  .compact-heading {
    margin-bottom: 20px;
  }

  .compact-heading h2 {
    font-size: 28px;
  }

  .macro-cell {
    min-height: 94px;
    padding: 13px 11px;
  }

  .macro-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .macro-cell:nth-child(odd),
  .macro-cell:nth-child(-n + 2) {
    border-bottom: 0;
    border-right: 1px solid var(--line);
  }

  .macro-cell:last-child {
    border-right: 0;
  }

  .macro-label {
    gap: 4px;
    font-size: 10px;
  }

  .macro-label > span {
    width: 6px;
    height: 6px;
  }

  .macro-cell strong {
    margin-top: 7px;
    font-size: 17px;
  }

  .macro-cell small {
    overflow: hidden;
    font-size: 9px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mini-track {
    margin-top: 9px;
  }

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

  .primary-action {
    grid-column: auto;
  }

  .core-actions .quick-action {
    min-height: 66px;
    display: flex;
    justify-content: flex-start;
    gap: 10px;
    padding: 10px 12px;
    text-align: left;
  }

  .secondary-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .secondary-actions .quick-action {
    min-height: 76px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 6px;
    padding: 8px 4px;
    text-align: center;
  }

  .secondary-actions .quick-action small {
    max-width: 94px;
  }

  .content-section:not(.meals-section) {
    margin-top: 18px;
    padding: 17px 14px;
  }

  .meals-section {
    margin-top: 22px;
    padding: 0;
    background: transparent;
    border: 0;
  }

  .meal-timeline,
  .diary-list {
    gap: 8px;
  }

  .meal-row {
    grid-template-columns: 50px minmax(0, 1fr) auto;
    gap: 10px;
    padding: 10px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
  }

  .meal-thumb {
    width: 50px;
    height: 50px;
  }

  .accuracy-badge {
    display: none;
  }

  .meal-calories {
    font-size: 11px;
  }

  .meal-side {
    display: grid;
    justify-items: end;
    gap: 3px;
  }

  .meal-repeat-button {
    width: 30px;
    height: 30px;
    flex-basis: 30px;
  }

  .diary-toolbar {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) 40px;
    gap: 7px;
    margin-bottom: 10px;
  }

  .diary-toolbar [data-date-shift="-1"] {
    grid-column: 1;
    grid-row: 1;
  }

  .diary-date-copy {
    grid-column: 2;
    grid-row: 1;
    align-self: center;
    text-align: center;
  }

  .diary-toolbar input {
    width: 100%;
    min-width: 0;
    grid-column: 1 / 3;
    grid-row: 2;
  }

  .diary-toolbar [data-date-shift="1"] {
    grid-column: 3;
    grid-row: 1;
  }

  .diary-toolbar .button {
    width: 40px;
    grid-column: 3;
    grid-row: 2;
    margin-left: 0;
    padding: 0;
    font-size: 0;
  }

  .diary-toolbar .button svg {
    width: 19px;
    height: 19px;
  }

  .week-strip {
    gap: 4px;
  }

  .week-day {
    min-height: 52px;
    padding: 0;
  }

  .diary-summary {
    position: sticky;
    top: 78px;
    z-index: 8;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    box-shadow: 0 6px 16px rgba(23, 60, 59, 0.06);
  }

  .diary-stat {
    min-height: 66px;
    padding: 11px 7px;
    border-bottom: 0;
    text-align: center;
  }

  .diary-stat:nth-child(2) {
    border-right: 1px solid var(--line);
  }

  .diary-stat small {
    font-size: 9px;
  }

  .diary-stat strong {
    font-size: 14px;
  }

  .diary-list {
    margin-top: 12px;
    padding: 0;
    background: transparent;
    border: 0;
  }

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

  .metric-block {
    min-height: 82px;
    padding: 13px 10px;
  }

  .measurement-grid {
    grid-template-columns: 1fr;
  }

  .measurement-item,
  .measurement-item:nth-child(2n),
  .measurement-item:nth-child(3n),
  .measurement-item:nth-last-child(-n + 2),
  .measurement-item:nth-last-child(2):nth-child(even) {
    min-height: 56px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .measurement-item:last-child {
    border-bottom: 0;
  }

  .metric-icon {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
  }

  .chart-container {
    height: 220px;
  }

  .plan-header-band {
    align-items: flex-start;
    gap: 16px;
    padding: 20px;
  }

  .plan-header-band h2 {
    font-size: 19px;
  }

  .plan-target {
    min-width: 105px;
    padding-left: 14px;
  }

  .target-table {
    grid-template-columns: 1fr;
  }

  .workout-row {
    grid-template-columns: 34px minmax(0, 1fr);
    padding: 8px 0;
  }

  .workout-row > span:last-child {
    display: none;
  }

  .chat-page {
    height: calc(100vh - 72px - var(--bottom-nav-height) - env(safe-area-inset-bottom));
    padding-top: 0;
  }

  .chat-messages {
    padding: 18px 0;
  }

  .chat-message {
    max-width: 88%;
  }

  .chat-welcome {
    margin-top: 7vh;
  }

  .suggestion-row {
    display: grid;
  }

  .bottom-nav {
    position: fixed;
    inset: auto 0 0;
    z-index: 30;
    height: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom));
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    padding: 6px 4px env(safe-area-inset-bottom);
    background: rgba(255, 255, 255, 0.98);
    border-top: 1px solid var(--line);
    box-shadow: 0 -6px 18px rgba(23, 60, 59, 0.06);
  }

  .bottom-nav button {
    min-width: 0;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 3px;
    padding: 0;
    color: #788582;
    background: transparent;
    border: 0;
    cursor: pointer;
    font-size: 9px;
  }

  .bottom-nav button.active {
    color: var(--teal-950);
  }

  .bottom-nav svg {
    width: 20px;
    height: 20px;
  }

  .modal {
    width: 100%;
    max-height: 94vh;
    margin: auto 0 0;
  }

  .modal-shell,
  .small-modal {
    width: 100%;
    max-height: 94vh;
    border-radius: 8px 8px 0 0;
  }

  .photo-drop {
    min-height: 190px;
  }

  .modal-footer {
    padding-bottom: max(17px, env(safe-area-inset-bottom));
  }

  .split-footer {
    grid-template-columns: auto 1fr auto;
  }

  .split-footer .button-secondary {
    display: none;
  }

  .edit-grid {
    gap: 9px;
  }

  .toast {
    right: 16px;
    bottom: calc(var(--bottom-nav-height) + 16px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 390px) {
  .main-content {
    padding-inline: 10px;
  }

  .topbar {
    margin-inline: -10px;
    padding-inline: 10px;
  }

  .calorie-overview {
    padding: 16px;
  }

  .macro-cell {
    padding: 12px 8px;
  }

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

  .meal-row {
    grid-template-columns: 46px minmax(0, 1fr) auto;
    gap: 8px;
    padding: 9px 8px;
  }

  .meal-thumb {
    width: 46px;
    height: 46px;
  }

  .meal-heading-line {
    gap: 6px;
  }

  .meal-main strong {
    font-size: 13px;
  }
}

@media (max-width: 980px) {
  .report-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .report-metric:nth-child(3) {
    border-right: 0;
  }

  .report-metric:nth-child(-n + 3) {
    border-bottom: 1px solid var(--line);
  }

  .exercise-row {
    grid-template-columns: 28px minmax(200px, 2fr) repeat(2, minmax(90px, 1fr));
  }

  .exercise-row .field:nth-last-child(-n + 2) {
    grid-column: span 2;
  }

  .pantry-form {
    grid-template-columns: minmax(180px, 1fr) 100px 80px 40px;
  }

  .pantry-form #pantryExpires {
    grid-column: 1 / -1;
  }
}

@media (max-width: 700px) {
  .guidance-panel {
    padding: 17px 15px;
  }

  .guidance-head {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .guidance-main {
    grid-template-columns: 40px minmax(0, 1fr);
    gap: 11px;
  }

  .guidance-icon {
    width: 40px;
    height: 40px;
  }

  .guidance-panel h2 {
    font-size: 17px;
    line-height: 1.25;
  }

  .guidance-add-button {
    width: 100%;
  }

  .guidance-columns {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .guidance-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .guidance-actions .button-primary {
    grid-column: 1 / -1;
  }

  .meal-job {
    grid-template-columns: 50px minmax(0, 1fr) auto;
  }

  .meal-job .accuracy-badge {
    display: none;
  }

  .analysis-chip {
    font-size: 0;
  }

  .analysis-chip .meal-status-spinner {
    width: 20px;
    height: 20px;
  }

  .job-actions {
    display: grid;
    grid-template-columns: auto 30px;
  }

  .job-actions .mini-action:first-child {
    display: none;
  }

  .weekly-report {
    padding: 17px 14px;
  }

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

  .report-metric,
  .report-metric:nth-child(3) {
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
  }

  .report-metric:nth-child(2n) {
    border-right: 0;
  }

  .report-metric:last-child {
    grid-column: 1 / -1;
    border-right: 0;
    border-bottom: 0;
  }

  .report-footer {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }

  .report-footer .button {
    width: 100%;
  }

  .plan-tabs {
    position: sticky;
    top: 76px;
    z-index: 8;
    width: 100%;
    margin-top: 10px;
  }

  .workout-start {
    grid-column: 2;
    justify-self: start;
    margin-bottom: 5px;
  }

  .workout-start span {
    display: inline !important;
  }

  .menu-day,
  .shopping-list,
  .pantry-list {
    grid-template-columns: 1fr;
  }

  .day-selector {
    grid-template-columns: repeat(7, 46px);
    padding-bottom: 3px;
  }

  .pantry-form {
    grid-template-columns: minmax(0, 1fr) 72px 68px 40px;
  }

  .pantry-form #pantryExpires {
    grid-column: 1 / -1;
  }

  .checkin-fields,
  .settings-grid,
  .workout-meta-grid {
    grid-template-columns: 1fr;
  }

  .exercise-row {
    position: relative;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: end;
  }

  .exercise-row .exercise-number {
    position: absolute;
    top: 32px;
    left: 10px;
    margin: 0;
  }

  .exercise-row .exercise-name {
    grid-column: 1 / -1;
  }

  .exercise-row .exercise-name input {
    padding-left: 45px;
  }

  .exercise-row .field:nth-child(4),
  .exercise-row .field:nth-child(5),
  .exercise-row .field:nth-child(6) {
    grid-column: span 1;
  }

  .exercise-row .field:nth-last-child(-n + 2) {
    grid-column: span 1;
  }

  .wide-modal {
    width: 100%;
  }

  .selected-repeat {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media print {
  body * {
    visibility: hidden;
  }

  #weeklyReport,
  #weeklyReport * {
    visibility: visible;
  }

  #weeklyReport {
    position: absolute;
    inset: 20px;
    margin: 0;
    border-top-width: 1px;
  }

  #printReportButton {
    display: none;
  }
}
