:root {
  --bg: #fff;
  --ink: #172322;
  --muted: #78847d;
  --green: #25634f;
  --pale: #f1f6f2;
  --line: #e1e7e4;
  --red: #b44435;
  --tg-top: 0px;
  --tg-bottom: 0px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-synthesis: none;
  font-size: 16px;
  line-height: 1.45;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  padding: 0 0 calc(100px + max(env(safe-area-inset-bottom), var(--tg-bottom)));
  -webkit-tap-highlight-color: transparent;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
button,
a,
input,
select,
textarea {
  touch-action: manipulation;
}
button,
a {
  -webkit-tap-highlight-color: transparent;
}
button {
  cursor: pointer;
  border: 0;
  background: none;
}
button:disabled {
  cursor: default;
  opacity: 0.45;
}
input:disabled {
  opacity: 1;
  -webkit-text-fill-color: var(--muted);
}
a {
  color: var(--green);
  text-decoration: none;
}
button:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 3px solid #8ab8a5;
  outline-offset: 3px;
}
h1,
h2,
h3,
p {
  margin: 0;
}
h1 {
  font-size: 30px;
  line-height: 1.15;
  letter-spacing: -0.8px;
  font-weight: 750;
}
h2 {
  font-size: 19px;
  line-height: 1.3;
  font-weight: 700;
  letter-spacing: -0.3px;
}
h3 {
  font-size: 17px;
  line-height: 1.4;
  font-weight: 650;
}
p {
  margin: 8px 0 16px;
}
small,
.hint {
  font-size: 13px;
  line-height: 1.45;
}
small {
  display: block;
  color: var(--muted);
}
svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
#app {
  max-width: 720px;
  margin: auto;
  padding: calc(24px + var(--tg-top)) 20px 10px;
}
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}
.app-header p {
  color: var(--muted);
  margin: 4px 0 0;
  font-size: 15px;
}
.icon-button {
  display: inline-flex;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
  font-size: 30px;
}
.assistant-button {
  border: 1px solid var(--line);
}
.primary,
.secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 650;
  line-height: 1.3;
  text-align: center;
}
.primary {
  background: var(--green);
  color: white;
  border: 1.5px solid var(--green);
}
.secondary {
  color: var(--green);
  background: white;
  border: 1.5px solid var(--green);
}
.wide {
  width: 100%;
}
.actions {
  display: flex;
  gap: 10px;
  margin: 16px 0;
}
.actions > * {
  flex: 1;
}
.text-button {
  min-height: 44px;
  padding: 10px 0;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--green);
  font-size: 14px;
  font-weight: 600;
  text-align: left;
}
.muted,
.hint {
  color: var(--muted);
}
.hint {
  margin: 10px 0 16px;
}
.lead {
  font-size: 17px;
  color: var(--muted);
  margin: 0 0 24px;
}
.energy {
  background: var(--pale);
  padding: 20px;
  border-radius: 20px;
  margin-bottom: 16px;
}
.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  gap: 12px;
}
.section-title svg {
  width: 19px;
  height: 19px;
  color: var(--muted);
}
.calories {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  font-variant-numeric: tabular-nums;
  font-size: 30px;
  letter-spacing: -1px;
  gap: 3px;
}
.calories strong {
  font-size: 40px;
  line-height: 1.2;
  font-weight: 750;
}
.calories > span {
  color: #58645e;
}
.calories small {
  display: inline;
  font-size: 17px;
  letter-spacing: 0;
  margin-left: 3px;
}
.calories .calorie-goal {
  margin-left: auto;
  font-size: 14px;
  letter-spacing: 0;
}
.bar {
  height: 9px;
  border-radius: 20px;
  background: #d9e2dc;
  margin: 17px 0 20px;
  overflow: hidden;
}
.bar i {
  display: block;
  max-width: 100%;
  height: 100%;
  border-radius: 20px;
  background: var(--green);
  transition: width 0.35s ease;
}
.macros {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 16px 0 20px;
  font-variant-numeric: tabular-nums;
}
.macros > div + div {
  border-left: 1px solid var(--line);
  padding-left: 12px;
}
.macros small {
  margin-bottom: 3px;
  font-size: 12px;
}
.macros span {
  font-size: 13px;
  color: #58645e;
  white-space: nowrap;
}
.macros b {
  color: var(--ink);
  font-size: 17px;
}
.home-section {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  margin: 14px 0;
}
.home-section .section-title {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.home-section h3 {
  margin: 0 0 3px;
}
.home-section p {
  color: #68726d;
  font-size: 14px;
  margin: 4px 0 16px;
}
.home-section .wide {
  min-height: 46px;
}
#nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 760px;
  z-index: 10;
  background: rgba(255, 255, 255, 0.97);
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  padding: 8px 8px
    calc(8px + max(env(safe-area-inset-bottom), var(--tg-bottom)));
  backdrop-filter: blur(12px);
}
#nav[hidden] {
  display: none;
}
#nav button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  color: #7a837e;
  padding: 5px 0;
  min-height: 52px;
  font-size: 10px;
  line-height: 1.2;
  font-weight: 500;
}
#nav button svg {
  width: 24px;
  height: 24px;
}
#nav button.active {
  color: var(--green);
  font-weight: 700;
}
#nav button.active svg {
  stroke-width: 2.3;
}
.date-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f7f8f8;
  border-radius: 12px;
  padding: 1px 0;
  margin-bottom: 16px;
}
.date-label {
  position: relative;
  font-weight: 650;
  font-size: 15px;
  cursor: pointer;
}
.date-label input {
  position: absolute;
  inset: 0;
  width: 100%;
  opacity: 0;
  cursor: pointer;
}
.meal-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-align: left;
  width: 100%;
  padding: 17px 4px;
  border-top: 1px solid var(--line);
  gap: 12px;
}
.meal-row svg {
  width: 18px;
  color: var(--muted);
}
.meal-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.meal-copy strong {
  font-size: 16px;
  font-weight: 650;
  overflow-wrap: anywhere;
}
.meal-copy > span {
  font-size: 14px;
  color: #66716a;
}
.meal-copy small {
  font-size: 12px;
}
.meal-copy em {
  font-size: 13px;
  font-style: normal;
  color: #947027;
}
.meal-row.draft {
  border: 0;
  border-radius: 14px;
  background: var(--pale);
  padding: 16px;
  margin: 10px 0 16px;
}
.meal-list {
  margin-bottom: 18px;
}
.draft-notice {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  font-size: 14px;
  padding: 8px 2px;
  color: var(--green);
}
.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin: 16px 0;
  min-width: 0;
}
.field > span {
  font-size: 13px;
  color: #56625b;
  font-weight: 550;
}
input,
select,
textarea {
  border: 1px solid #d7dfda;
  background: #fafcfb;
  border-radius: 10px;
  min-height: 46px;
  padding: 11px 12px;
  width: 100%;
  outline: none;
  font-size: 16px;
}
input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 2px #25634f14;
}
input::placeholder,
textarea::placeholder {
  color: #9aa49d;
}
textarea {
  resize: vertical;
}
input[type="date"] {
  min-width: 0;
  appearance: none;
  -webkit-appearance: none;
}
input[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}
input::-webkit-inner-spin-button,
input::-webkit-outer-spin-button {
  appearance: none;
  margin: 0;
}
select {
  appearance: auto;
}
form > h2 {
  margin: 28px 0 8px;
}
form > .primary {
  margin-top: 14px;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 14px;
}
.form-grid .field {
  margin: 10px 0;
}
.tabs {
  display: flex;
  background: #f4f6f5;
  border-radius: 10px;
  padding: 3px;
  gap: 3px;
  overflow: auto;
  margin-bottom: 16px;
}
.tabs button {
  flex: 1;
  padding: 12px 8px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 8px;
  min-width: 65px;
  line-height: 1.2;
}
.tabs button.selected {
  background: var(--green);
  color: white;
}
.small-tabs {
  margin: 0 0 20px;
}
.training-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.training-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}
.training-heading button {
  flex-shrink: 0;
}
.exercise {
  border: 1px solid var(--line);
  border-radius: 12px;
  margin: 12px 0;
  overflow: hidden;
}
.exercise summary {
  display: flex;
  list-style: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  cursor: pointer;
}
.exercise summary::-webkit-details-marker {
  display: none;
}
.exercise summary strong {
  font-size: 16px;
  line-height: 1.3;
}
.exercise summary small {
  font-size: 12px;
  margin-top: 3px;
}
.exercise summary svg {
  width: 18px;
  height: 18px;
  transform: rotate(90deg);
  color: var(--muted);
}
.exercise[open] summary svg {
  transform: rotate(-90deg);
}
.exercise[open] summary {
  padding-bottom: 12px;
}
.exercise-content {
  padding: 0 12px 12px;
}
.exercise-content > .hint,
.previous {
  font-size: 12px;
  margin: 0 3px 12px;
  line-height: 1.5;
  color: #68746d;
}
.set-labels,
.set-row {
  display: grid;
  grid-template-columns: minmax(102px, 1.4fr) minmax(48px, 0.8fr) minmax(
      55px,
      0.8fr
    ) 38px;
  gap: 8px;
  align-items: center;
}
.set-labels {
  border-top: 1px solid var(--line);
  padding: 12px 0 6px;
  color: var(--muted);
  font-size: 11px;
}
.set-row {
  padding: 9px 0;
  border-bottom: 1px solid #eff2f0;
}
.set-row:last-of-type {
  border-bottom: 0;
}
.set-row input {
  padding: 8px 6px;
  min-width: 0;
  height: 42px;
  min-height: 42px;
  border-radius: 7px;
  text-align: center;
  font-size: 15px;
}
.set-kind {
  display: flex;
  align-items: center;
  gap: 8px;
}
.set-kind > b {
  font-size: 13px;
  min-width: 8px;
}
.set-kind small {
  font-size: 10px;
  line-height: 1.3;
  color: #68746d;
}
.set-kind em {
  display: block;
  font-style: normal;
  color: #8c978f;
  font-size: 10px;
}
.set-check {
  width: 38px;
  height: 42px;
  border-radius: 9px;
  border: 1px solid var(--green);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--green);
  padding: 8px;
}
.set-check svg {
  width: 20px;
  height: 20px;
}
.set-check.saved {
  border: 0;
  border-radius: 50%;
  background: var(--green);
  color: white;
  width: 26px;
  height: 26px;
  padding: 4px;
  margin: auto;
  opacity: 1;
}
.set-check.saved svg {
  width: 18px;
}
.set-row:not(.done) button:disabled {
  opacity: 0.2;
}
.undo-set {
  font-size: 12px;
  min-height: 38px;
}
.exercise-list {
  margin-bottom: 20px;
}
.prose {
  white-space: pre-wrap;
  line-height: 1.65;
  font-size: 14px;
  color: #4f5e55;
  overflow-wrap: anywhere;
}
.note,
.error {
  padding: 14px;
  border-radius: 12px;
  background: #faf5e9;
  font-size: 14px;
  white-space: pre-wrap;
}
.error,
.inline-error {
  color: var(--red);
}
.inline-error:empty {
  display: none;
}
.inline-error {
  font-size: 14px;
  white-space: pre-wrap;
  margin-top: 14px;
}
.danger {
  color: var(--red);
  border-color: #d5aaa3;
}
.danger-fill {
  background: var(--red);
  border-color: var(--red);
}
.empty {
  padding: 22px 6px;
  color: var(--muted);
  text-align: center;
  font-size: 15px;
}
.empty p {
  margin-bottom: 16px;
}
.list-button {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 16px 0;
  gap: 12px;
  min-height: 52px;
  font-size: 15px;
}
.list-button svg {
  color: var(--muted);
  width: 18px;
}
.list-button small {
  margin-top: 4px;
  font-size: 12px;
}
.list-button > span:last-child:not(:first-child) {
  color: var(--muted);
  font-size: 13px;
}
.profile-summary {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 0 24px;
}
.profile-summary p {
  margin: 4px 0 0;
  font-size: 14px;
  color: var(--muted);
}
.avatar,
.welcome-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  background: var(--pale);
  color: var(--green);
  border-radius: 18px;
}
.settings {
  margin-top: 32px;
}
.plan-day,
.guide,
.history {
  border-bottom: 1px solid var(--line);
  padding: 16px 0;
}
.plan-day summary,
.guide summary,
.history summary {
  cursor: pointer;
  font-size: 16px;
  font-weight: 650;
}
.plan-day p {
  font-size: 14px;
  margin: 12px 0;
}
.guide .prose,
.history > div {
  margin-top: 16px;
}
.review {
  padding: 22px 0;
}
.review .prose {
  margin-top: 16px;
}
.progress-chart {
  margin-top: 26px;
  background: var(--pale);
  border-radius: 20px;
  padding: 20px;
}
.progress-chart .section-title {
  margin-bottom: 10px;
}
.progress-chart .muted {
  font-size: 12px;
}
.weight-value {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -1px;
}
.weight-value small {
  display: inline;
  font-size: 17px;
  font-weight: 400;
}
.weight-chart {
  width: 100%;
  height: auto;
  stroke: var(--green);
  stroke-width: 2.4;
  overflow: visible;
  margin-top: 12px;
}
.weight-chart circle {
  fill: var(--green);
  stroke: white;
  stroke-width: 1.5;
}
.weight-chart .chart-axis {
  stroke: #d7e1da;
  stroke-width: 1;
}
.chart-dates {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
}
.history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #edf1ee;
  padding: 12px 0;
  font-size: 14px;
  gap: 16px;
}
.history-row > span {
  color: #69746d;
  font-size: 13px;
}
.history-row small {
  font-size: 11px;
}
.welcome {
  padding: 22px 0 28px;
}
.welcome h2 {
  font-size: 26px;
  line-height: 1.25;
  margin: 24px 0 12px;
  letter-spacing: -0.5px;
}
.welcome p {
  color: var(--muted);
  margin-bottom: 24px;
}
.boot,
.boot-error {
  min-height: 65vh;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  text-align: center;
  padding: 24px;
  gap: 16px;
}
.boot-error p {
  max-width: 400px;
  margin: 0 0 8px;
}
.boot-error h1 {
  font-size: 28px;
}
.spinner {
  display: inline-block;
  flex-shrink: 0;
  width: 19px;
  height: 19px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
#toast {
  position: fixed;
  bottom: calc(96px + max(env(safe-area-inset-bottom), var(--tg-bottom)));
  left: 50%;
  transform: translateX(-50%);
  background: #243c31;
  color: white;
  border-radius: 14px;
  padding: 14px 18px;
  width: max-content;
  max-width: calc(100% - 32px);
  z-index: 100;
  font-size: 14px;
  box-shadow: 0 8px 30px #17232225;
}
dialog {
  position: fixed;
  inset: auto 0 0;
  margin: 0 auto;
  width: 100%;
  max-width: 720px;
  max-height: calc(100dvh - 28px - var(--tg-top));
  padding: 0;
  border: 0;
  border-radius: 24px 24px 0 0;
  color: var(--ink);
  background: white;
  overscroll-behavior: contain;
}
dialog::backdrop {
  background: #13251f66;
  backdrop-filter: blur(2px);
}
.sheet-head {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 10px 24px;
  background: white;
  border-bottom: 1px solid var(--line);
}
.sheet-head h2 {
  font-size: 20px;
}
.sheet-head .icon-button {
  background: #f3f6f4;
  font-size: 26px;
  width: 36px;
  height: 36px;
}
#sheet-body {
  padding: 8px 24px calc(28px + env(safe-area-inset-bottom));
  overflow-wrap: anywhere;
}
.photo-actions {
  display: flex;
  gap: 10px;
  margin: 16px 0;
}
.file-button {
  position: relative;
  flex: 1;
  font-size: 13px;
  cursor: pointer;
  overflow: hidden;
}
.file-button input {
  position: absolute;
  opacity: 0;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}
.file-button svg {
  width: 20px;
}
.photo-list {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 4px 0;
}
.photo-list > div {
  position: relative;
  flex-shrink: 0;
}
.photo-list img {
  width: 82px;
  height: 100px;
  object-fit: cover;
  border-radius: 10px;
}
.photo-list button {
  position: absolute;
  right: 4px;
  top: 4px;
  color: white;
  background: #172322b3;
  border-radius: 50%;
  width: 26px;
  height: 26px;
  padding: 4px;
}
.photo-list svg {
  width: 18px;
  height: 18px;
}
.food-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.food-item h3 {
  font-size: 17px;
}
.food-item .field {
  margin: 10px 0;
}
.food-item > p.muted {
  font-size: 14px;
  margin: 8px 0;
}
.food-item .hint {
  font-size: 12px;
  margin: 6px 0 8px;
}
.conversation {
  padding: 10px 0;
}
.message {
  padding: 14px;
  background: var(--pale);
  border-radius: 14px;
  margin: 10px 20px 10px 0;
  font-size: 14px;
}
.message.mine {
  background: #f3f4f5;
  margin: 10px 0 10px 20px;
}
.message p {
  margin: 5px 0 0;
  white-space: pre-wrap;
}
.message small {
  font-size: 11px;
}
code {
  font-size: 13px;
  word-break: break-all;
}
.modal-open {
  overflow: hidden;
}
@media (min-width: 700px) {
  #app {
    padding-top: 36px;
  }
  .app-header {
    margin-bottom: 30px;
  }
  .calories strong {
    font-size: 46px;
  }
  .calories {
    font-size: 34px;
  }
  .macros span {
    font-size: 16px;
  }
  .macros b {
    font-size: 20px;
  }
  .energy {
    padding: 26px;
  }
  .home-section {
    padding: 22px;
  }
  .set-labels,
  .set-row {
    grid-template-columns: 2fr 1fr 1fr 44px;
  }
  .set-kind small {
    font-size: 13px;
  }
  dialog {
    inset: 30px 0 auto;
    max-height: calc(100dvh - 60px);
    border-radius: 24px;
  }
  .set-check {
    width: 44px;
  }
  #nav button {
    font-size: 12px;
  }
}
@media (max-width: 360px) {
  #app {
    padding-left: 14px;
    padding-right: 14px;
  }
  .calories strong {
    font-size: 34px;
  }
  .calories {
    font-size: 24px;
  }
  .macros {
    gap: 7px;
  }
  .macros > div + div {
    padding-left: 7px;
  }
  .macros span {
    font-size: 11px;
  }
  .macros b {
    font-size: 15px;
  }
  #sheet-body {
    padding-left: 18px;
    padding-right: 18px;
  }
  .set-labels,
  .set-row {
    grid-template-columns: 98px minmax(40px, 1fr) minmax(45px, 1fr) 32px;
    gap: 5px;
  }
  .set-check {
    width: 32px;
  }
  .photo-actions {
    flex-direction: column;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *:before,
  *:after {
    animation-duration: 0.01ms !important;
    transition: none !important;
  }
}
.energy .section-title {
  margin-bottom: 10px;
}
.energy .bar {
  margin: 15px 0 16px;
}
.energy .macros {
  margin: 14px 0 16px;
}
.home-section {
  padding: 16px;
}
.home-section .section-title {
  padding-bottom: 10px;
  margin-bottom: 10px;
}
.home-section p {
  margin-bottom: 12px;
}
.duration {
  margin: 8px 0 16px;
  color: var(--muted);
  font-size: 12px;
}
.duration summary {
  cursor: pointer;
}
.set-kind small {
  font-size: 11px;
}
.set-kind em {
  font-size: 11px;
}

.source-confirm { display: flex; align-items: flex-start; gap: 12px; margin: 20px 0; line-height: 1.5; }
.source-confirm input { width: 22px; height: 22px; flex: 0 0 22px; margin-top: 2px; accent-color: var(--accent); }
#catalog-food { margin-bottom: 18px; }
#catalog-results .meal-row { width: 100%; text-align: left; }
