:root {
  --green: #5cb433;
  --green-dark: #429328;
  --green-soft: #edf8df;
  --orange: #ff9f1f;
  --ink: #151515;
  --muted: #666b72;
  --line: #ece7d9;
  --paper: #fffdf8;
  --soft: #f7f2e4;
  --shadow: 0 14px 34px rgba(55, 42, 20, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 8%, rgba(255, 255, 255, 0.98) 0 20%, transparent 42%),
    linear-gradient(135deg, #fbf8ef, #eee6d7);
  color: var(--ink);
}

button {
  font: inherit;
}

.phone-shell {
  width: min(100vw, 430px);
  min-height: min(100vh, 860px);
  position: relative;
  overflow: visible;
  background:
    radial-gradient(circle at 50% 2%, rgba(255, 255, 255, 0.98), transparent 44%),
    linear-gradient(180deg, #fff 0%, #fbf7ec 100%);
  border: 1px solid #d8d1c1;
  border-radius: 34px;
  box-shadow: 0 22px 60px rgba(41, 32, 15, 0.24);
  padding: 8px 18px calc(124px + env(safe-area-inset-bottom, 0px));
}

.icon-button {
  justify-self: end;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid #ddd7ca;
  background: rgba(255, 255, 255, 0.72);
  font-weight: 800;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
  animation: rise 0.22s ease-out;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.cat-hero {
  position: relative;
  height: 238px;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.hero-cat-art {
  position: relative;
  z-index: 2;
  width: 294px;
  height: 294px;
  object-fit: contain;
  object-position: center;
  transform: translateY(-20px);
  filter: drop-shadow(0 10px 18px rgba(55, 42, 20, 0.08));
}

.party::before {
  content: "";
  position: absolute;
  width: 245px;
  height: 245px;
  border-radius: 50%;
  background: #f4f0d6;
  opacity: 0.8;
}

.cat-hero::before {
  content: "";
  position: absolute;
  width: 218px;
  height: 218px;
  border-radius: 50%;
  background: #f7f3df;
  opacity: 0.42;
  transform: translateY(12px);
}

[data-screen="home"] > .cat-hero {
  height: 210px;
}

[data-screen="home"] .hero-cat-art {
  transform: translateY(-30px);
}

[data-screen="home"] > .primary-action {
  position: relative;
  top: -4px;
  z-index: 4;
  margin-top: -18px;
  margin-bottom: -4px;
}

.heart-bubble {
  position: absolute;
  right: 20px;
  top: 28px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--green);
  font-size: 28px;
  background: white;
  border: 1px solid #e5dfc2;
  box-shadow: var(--shadow);
  z-index: 4;
}

.cat {
  width: 210px;
  height: 230px;
  position: relative;
  z-index: 2;
}

.head {
  position: absolute;
  inset: 38px 12px 0;
  background: #fff;
  border: 5px solid #111;
  border-radius: 48% 48% 44% 44%;
  overflow: hidden;
}

.ear {
  position: absolute;
  top: 15px;
  width: 56px;
  height: 72px;
  background: #fff;
  border: 5px solid #111;
  border-radius: 14px 70% 14px 14px;
  transform: rotate(-14deg);
  z-index: 1;
}

.ear::after {
  content: "";
  position: absolute;
  inset: 15px 14px;
  background: #ff8936;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

.ear.left {
  left: 28px;
}

.ear.right {
  right: 28px;
  transform: rotate(14deg) scaleX(-1);
}

.patch {
  position: absolute;
  right: -5px;
  top: -8px;
  width: 82px;
  height: 78px;
  background: var(--orange);
  border-bottom-left-radius: 70%;
}

.eye {
  position: absolute;
  top: 82px;
  width: 34px;
  height: 18px;
  border-top: 5px solid #111;
  border-radius: 50%;
}

.eye.left {
  left: 45px;
}

.eye.right {
  right: 45px;
}

.nose {
  position: absolute;
  left: 50%;
  top: 99px;
  width: 18px;
  height: 13px;
  background: #111;
  border-radius: 50%;
  transform: translateX(-50%);
}

.mouth {
  position: absolute;
  left: 50%;
  top: 112px;
  width: 30px;
  height: 24px;
  border: 4px solid #111;
  border-top: 0;
  border-radius: 0 0 22px 22px;
  transform: translateX(-50%);
  background: #ff8a6d;
}

.whisker {
  position: absolute;
  width: 46px;
  height: 4px;
  background: #111;
  border-radius: 99px;
}

.w1 {
  left: 12px;
  top: 104px;
  transform: rotate(6deg);
}

.w2 {
  left: 8px;
  top: 126px;
  transform: rotate(-10deg);
}

.w3 {
  right: 12px;
  top: 104px;
  transform: rotate(-6deg);
}

.w4 {
  right: 8px;
  top: 126px;
  transform: rotate(10deg);
}

.bowl {
  position: absolute;
  left: 44px;
  bottom: 0;
  width: 122px;
  height: 62px;
  background: #66bd40;
  border: 5px solid #111;
  border-radius: 18px 18px 45px 45px;
  z-index: 3;
}

.bowl::before {
  content: "";
  position: absolute;
  left: 18px;
  right: 18px;
  top: -34px;
  height: 42px;
  background: white;
  border: 5px solid #111;
  border-radius: 50%;
}

.bowl span {
  position: absolute;
  top: -18px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #111;
  z-index: 4;
}

.bowl span:nth-child(1) { left: 39px; }
.bowl span:nth-child(2) { left: 56px; }
.bowl span:nth-child(3) { left: 73px; }

.status-row,
.calorie-card,
.tip-card,
.meal-card,
.streak-card,
.mission-card {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.status-row {
  min-height: 74px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 13px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.status-cat-icon {
  width: 56px;
  height: 56px;
  object-fit: contain;
  border-radius: 50%;
  filter: drop-shadow(0 5px 10px rgba(72, 157, 43, 0.18));
}

.status-row span,
.tip-card small,
.meal-card small,
.mission-card small {
  display: block;
  color: var(--muted);
  margin-top: 3px;
}

.round-icon {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: white;
  font-size: 21px;
  font-weight: 800;
}

.happy,
.fire {
  background: linear-gradient(145deg, #78c64b, #42a52d);
}

.fire {
  background: transparent;
  box-shadow: none;
}

.fire img {
  width: 62px;
  height: 62px;
  object-fit: contain;
  display: block;
}

.calorie-card {
  margin-top: 16px;
  padding: 20px 16px;
}

.water-strip {
  width: 100%;
  min-height: 72px;
  margin-top: 10px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid #dcecf3;
  border-radius: 16px;
  background: rgba(248, 253, 255, 0.94);
  box-shadow: 0 8px 20px rgba(39, 123, 162, 0.1);
}

.water-drop {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #e5f7fd;
  font-size: 21px;
}

.water-content {
  min-width: 0;
}

.water-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
}

.water-heading strong {
  font-size: 15px;
}

.water-heading span {
  white-space: nowrap;
  color: #4d6975;
}

.water-progress {
  height: 7px;
  margin-top: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: #dfeff4;
}

.water-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #43bde7, #75d7ef);
  transition: width 0.24s ease;
}

.water-content small {
  display: block;
  margin-top: 3px;
  color: #71838a;
  font-size: 10px;
}

.water-actions {
  display: flex;
  align-items: center;
  gap: 5px;
}

.water-actions button {
  height: 32px;
  min-width: 32px;
  padding: 0 8px;
  border: 1px solid #b9dce8;
  border-radius: 9px;
  background: white;
  color: #258cb3;
  font-size: 13px;
  font-weight: 800;
}

.water-actions button:first-child {
  padding: 0;
  font-size: 20px;
}

.water-actions button:disabled {
  opacity: 0.38;
}

.card-top {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 13px;
  align-items: center;
}

.calorie-card strong {
  display: block;
  font-size: 32px;
  line-height: 1.1;
}

.calorie-card em {
  color: #2b2b2b;
  font-size: 20px;
  font-style: normal;
  font-weight: 500;
}

.progress-line {
  height: 13px;
  margin-top: 12px;
  border-radius: 999px;
  background: #eeeade;
  overflow: hidden;
}

.progress-line span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), #69c33b);
}

.macro-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.macro-grid > span {
  min-width: 0;
  display: grid;
  grid-template-columns: 17px auto auto;
  align-items: baseline;
  justify-content: center;
  column-gap: 5px;
  white-space: nowrap;
  line-height: 1.1;
  font-weight: 500;
}

.macro-grid b {
  color: var(--green-dark);
  font-size: 18px;
  font-weight: 650;
  text-align: right;
  min-width: 17px;
}

.macro-current {
  color: #262626;
  font-size: 14px;
  font-weight: 700;
  margin-left: 0;
}

.macro-grid small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.macro-grid > span:nth-child(2) b,
.macro-grid > span:nth-child(3) b {
  color: #f28b17;
}

.primary-action {
  width: 100%;
  height: 52px;
  margin-top: 16px;
  border: 0;
  border-radius: 17px;
  color: white;
  background: linear-gradient(180deg, #6fc444, #49a52d);
  box-shadow: 0 9px 18px rgba(72, 157, 43, 0.24);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 19px;
  font-weight: 650;
}

.primary-action {
  line-height: 1;
}

.action-plus,
.action-label {
  transform: translateY(-3px);
}

.primary-action .action-plus {
  display: inline-grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 50%;
  background: white;
  color: var(--green);
  position: relative;
  font-size: 0;
  line-height: 0;
  flex: 0 0 22px;
}

.primary-action .action-plus::before,
.primary-action .action-plus::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 12px;
  height: 3px;
  border-radius: 999px;
  background: var(--green);
  transform: translate(-50%, -50%);
}

.primary-action .action-plus::after {
  transform: translate(-50%, -50%) rotate(90deg);
}

.primary-action .action-label {
  display: inline-block;
  line-height: 1;
}

.add-food-menu {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  max-height: 0;
  margin-top: 0;
  opacity: 0;
  overflow: hidden;
  transform: translateY(-8px);
  transition: max-height 0.22s ease, margin-top 0.22s ease, opacity 0.18s ease, transform 0.22s ease;
}

.add-food-menu.open {
  max-height: 340px;
  margin-top: 12px;
  opacity: 1;
  transform: translateY(0);
}

.add-food-menu button {
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.84);
  box-shadow: 0 8px 18px rgba(55, 42, 20, 0.1);
  color: #202020;
  font-size: 15px;
  font-weight: 800;
}

.add-food-menu span {
  display: block;
  margin-bottom: 6px;
  color: var(--green);
  font-size: 28px;
}

.tip-card {
  min-height: 74px;
  margin-top: 16px;
  display: grid;
  grid-template-columns: 34px 1fr 58px;
  align-items: center;
  gap: 12px;
  padding: 11px 10px 11px 14px;
  background: #faf8e8;
  box-shadow: 0 8px 18px rgba(55, 42, 20, 0.1);
  overflow: hidden;
  position: relative;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.diary-insight {
  cursor: pointer;
}

.diary-insight > div {
  min-width: 0;
  align-self: center;
}

.diary-insight strong {
  display: block;
  line-height: 1.2;
}

.diary-insight small {
  display: block;
  margin-top: 4px;
  line-height: 1.3;
}

.diary-insight-advice {
  margin-top: 8px !important;
  padding-top: 8px;
  border-top: 1px solid #e7dfc8;
  color: #4f773b !important;
  font-weight: 700;
}

.diary-insight-advice[hidden] {
  display: none;
}

.diary-insight[aria-expanded="true"] {
  min-height: 98px;
}

.personal-foods {
  grid-column: 1 / -1;
  min-width: 0;
}

.personal-foods[hidden] {
  display: none;
}

.personal-foods-title {
  display: block;
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.personal-food-list {
  display: grid;
  gap: 7px;
}

.add-food-menu .personal-food-button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 8px 13px;
  border-radius: 13px;
  text-align: left;
}

.add-food-menu .personal-food-button span {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: #202020;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.add-food-menu .personal-food-button small {
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 800;
}

.referral-status-row {
  min-height: 86px;
}

.referral-status-row .status-cat-icon {
  width: 62px;
  height: 62px;
  transform: scale(1.25);
}

.referral-status-row span {
  max-width: 220px;
  line-height: 1.28;
}

.tip-paw {
  width: 31px;
  height: 31px;
  object-fit: contain;
  transform: rotate(-8deg);
}

.tip-cat {
  width: 74px;
  height: 70px;
  object-fit: contain;
  justify-self: end;
  align-self: end;
  margin-right: -16px;
  margin-bottom: -20px;
}

.day-switch {
  height: 54px;
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
}

.day-arrow {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: #f0ebdd;
  font-size: 28px;
  line-height: 1;
}

.day-arrow:disabled {
  opacity: 0.35;
  cursor: default;
}

.date-label {
  min-width: 112px;
  height: 34px;
  border: 0;
  border-radius: 999px;
  background: #f7f1e2;
  color: var(--ink);
  font-size: 18px;
  font-weight: 800;
  padding: 0 14px;
}

.date-picker {
  position: absolute;
  left: 40px;
  top: 10px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.mini-calendar {
  position: absolute;
  left: 0;
  top: 46px;
  z-index: 30;
  width: min(318px, calc(100vw - 42px));
  padding: 12px;
  border: 1px solid #eadfca;
  border-radius: 18px;
  background: rgba(255, 252, 246, 0.98);
  box-shadow: 0 18px 34px rgba(55, 42, 20, 0.16);
}

.calendar-head {
  display: grid;
  grid-template-columns: 36px 1fr 36px;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.calendar-head strong {
  text-align: center;
  font-size: 15px;
  text-transform: capitalize;
}

.calendar-head button,
.calendar-grid button {
  border: 0;
  font: inherit;
}

.calendar-head button {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #f1eadc;
  font-size: 22px;
  font-weight: 900;
}

.calendar-week,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
}

.calendar-week {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}

.calendar-grid button {
  position: relative;
  min-width: 0;
  height: 34px;
  border-radius: 11px;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.calendar-grid button.muted {
  color: #b8afa0;
}

.calendar-grid button:disabled {
  color: #c8c1b5;
  opacity: 0.45;
  cursor: default;
}

.calendar-grid button.has-data {
  background: #e4f8d7;
  color: var(--green-dark);
}

.calendar-grid button.has-data::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 4px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--green);
  transform: translateX(-50%);
}

.calendar-grid button.has-freeze {
  background: #e7f7fb;
  color: #2786a0;
}

.calendar-grid button.has-freeze::after {
  content: "❄";
  position: absolute;
  right: 2px;
  top: 1px;
  font-size: 9px;
  line-height: 1;
}

.calendar-grid button.selected {
  outline: 2px solid var(--green);
  outline-offset: -2px;
}

.calendar-grid button.in-range {
  border-radius: 8px;
  background: #eef9e7;
}

.calendar-grid button.range-start,
.calendar-grid button.range-end {
  background: var(--green);
  color: white;
  outline: 0;
}

.calendar-grid button.range-start::after,
.calendar-grid button.range-end::after {
  background: white;
}

.calendar-period-actions {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #eee4d2;
}

.calendar-period-actions small {
  color: var(--muted);
  text-align: center;
}

.calendar-period-actions div {
  display: grid;
  grid-template-columns: 0.75fr 1.25fr;
  gap: 8px;
}

.calendar-period-actions button {
  min-height: 38px;
  border: 0;
  border-radius: 12px;
  background: var(--green);
  color: white;
  font: inherit;
  font-size: 13px;
  font-weight: 900;
}

.calendar-period-actions button.calendar-cancel {
  background: #f1eadc;
  color: var(--ink);
}

.calendar-period-actions button:disabled {
  opacity: 0.45;
}

.period-report-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  align-items: end;
  padding: 14px;
  background: rgba(24, 22, 18, 0.34);
}

.period-report-modal[hidden] {
  display: none;
}

.period-report-sheet {
  width: min(100%, 394px);
  max-height: calc(100vh - 28px);
  margin: 0 auto;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: #fffdf8;
  box-shadow: 0 22px 50px rgba(31, 24, 11, 0.24);
}

.period-report-sheet header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.period-report-sheet header small,
.period-report-sheet header strong {
  display: block;
}

.period-report-sheet header small {
  color: var(--muted);
  font-size: 12px;
}

.period-report-sheet header strong {
  margin-top: 2px;
  font-size: 24px;
}

.period-report-sheet header button {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border: 0;
  border-radius: 50%;
  background: #f1eadc;
  color: var(--ink);
  font-size: 26px;
  line-height: 1;
}

.period-report-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
  margin: 18px 0;
}

.period-report-days span {
  display: grid;
  place-items: center;
  min-width: 0;
  height: 49px;
  border-radius: 12px;
  background: #f4efe4;
  color: #948d80;
}

.period-report-days span.active {
  background: #e4f8d7;
  color: var(--green-dark);
}

.period-report-days span.frozen {
  background: #e7f7fb;
  color: #2786a0;
}

.period-report-days small {
  font-size: 9px;
  text-transform: capitalize;
}

.period-report-days b {
  font-size: 15px;
}

.period-report-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.period-report-grid span {
  min-width: 0;
  padding: 12px;
  border-radius: 12px;
  background: #f8f3e7;
}

.period-report-grid small,
.period-report-grid strong {
  display: block;
}

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

.period-report-grid strong {
  margin-top: 4px;
  color: var(--green-dark);
  font-size: 20px;
}

.period-report-detail,
.period-report-empty {
  margin: 12px 0 0;
  padding-top: 12px;
  border-top: 1px solid #eee4d2;
  font-size: 14px;
  font-weight: 700;
}

.period-report-empty {
  color: var(--muted);
  text-align: center;
}

.peek {
  position: absolute;
  right: 28px;
  bottom: -22px;
  transform: rotate(-4deg);
  z-index: 1;
}

.peek-art {
  position: absolute;
  right: 18px;
  bottom: -24px;
  width: 76px;
  height: 76px;
  object-fit: contain;
  object-position: center;
  z-index: 1;
}

.diary-summary {
  position: relative;
  z-index: 2;
  margin-top: 8px;
}

.diary-summary > small {
  font-weight: 700;
}

.boxed > span {
  padding: 12px 8px;
  border-radius: 12px;
  background: #faf6ec;
  flex-wrap: wrap;
  row-gap: 4px;
}

.boxed .macro-percent {
  flex-basis: 100%;
  font-size: 12px;
}

h2 {
  margin: 22px 8px 10px;
  font-size: 18px;
}

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

.meal-card {
  overflow: hidden;
}

.meal-toggle {
  width: 100%;
  min-height: 78px;
  border: 0;
  display: grid;
  grid-template-columns: 60px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 15px;
  background: transparent;
  text-align: left;
}

.meal-emoji {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #fbf5e9;
  overflow: hidden;
}

.meal-emoji img {
  width: 58px;
  height: 58px;
  object-fit: contain;
  object-position: center;
}

.meal-toggle strong {
  color: var(--green-dark);
  font-size: 19px;
  white-space: nowrap;
}

.meal-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  max-height: 0;
  padding: 0 14px;
  border-top: 1px solid transparent;
  opacity: 0;
  overflow: hidden;
  transform: translateY(-6px);
  transition: max-height 0.22s ease, padding 0.22s ease, opacity 0.18s ease, transform 0.22s ease;
}

.meal-card.open .meal-actions {
  max-height: 280px;
  padding: 0 14px 14px;
  border-top-color: #f0eadc;
  opacity: 1;
  transform: translateY(0);
}

.diary-add-food {
  display: grid;
  gap: 7px;
  margin: 12px 4px 4px;
}

.diary-add-food[hidden] {
  display: none;
}

.diary-add-food > small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.diary-add-food > div {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.diary-add-food button {
  min-height: 42px;
  border: 1px solid #dcefd1;
  border-radius: 8px;
  background: #f4fbef;
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 800;
}

.dish-list {
  grid-column: 1 / -1;
  display: grid;
  gap: 7px;
  padding-top: 12px;
}

.dish-list span {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: baseline;
  min-height: 28px;
  padding: 0 2px;
}

.dish-list b {
  font-size: 14px;
}

.dish-list small {
  color: var(--muted);
  font-size: 12px;
}

.dish-list strong {
  color: var(--green-dark);
  font-size: 13px;
  white-space: nowrap;
}

.meal-actions button {
  min-height: 38px;
  border: 1px solid #e9e1cf;
  border-radius: 12px;
  background: #fbf7eb;
  color: #303030;
  font-size: 13px;
  font-weight: 800;
}

.meal-actions button:disabled {
  opacity: 0.55;
  cursor: wait;
}

.meal-actions .danger {
  color: #c6432b;
  background: #fff2ee;
  border-color: #f2d4ca;
}

.wide {
  margin-top: 10px;
  grid-template-columns: 34px 1fr 96px;
  column-gap: 10px;
  padding-right: 12px;
}

.wide .tip-cat {
  width: 90px;
  height: 84px;
  margin-right: 2px;
  margin-bottom: -24px;
}

.party {
  height: 292px;
  display: grid;
  place-items: center;
  position: relative;
  margin-top: -24px;
  margin-bottom: 0;
  overflow: hidden;
}

.mission-cat-art {
  position: relative;
  z-index: 2;
  width: 368px;
  max-width: none;
  height: 310px;
  object-fit: contain;
  object-position: center;
  transform: translateY(20px);
  filter: drop-shadow(0 12px 20px rgba(55, 42, 20, 0.08));
}

.party > span {
  position: absolute;
  color: var(--green);
  font-size: 28px;
}

.party > span:nth-child(1) { left: 20px; top: 82px; color: #ffc22f; }
.party > span:nth-child(2) { right: 28px; top: 92px; color: #ffc22f; }
.party > span:nth-child(3) { left: 42px; bottom: 58px; }
.party > span:nth-child(4) { right: 54px; bottom: 56px; }

.medal {
  transform: scale(0.9);
}

.coin {
  position: absolute;
  left: 78px;
  bottom: 10px;
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #ffc54c;
  border: 5px solid #111;
  color: #d57800;
  font-size: 32px;
  z-index: 4;
}

.streak-card {
  position: relative;
  z-index: 5;
  width: min(324px, calc(100% - 56px));
  margin: -38px auto 0;
  display: grid;
  grid-template-rows: auto auto;
  align-items: center;
  justify-content: center;
  row-gap: 4px;
  min-height: 68px;
  font-size: 20px;
  padding: 8px 14px;
  line-height: 1.05;
}

.streak-main {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  white-space: nowrap;
}

.streak-card strong {
  color: var(--green-dark);
}

.streak-card b {
  color: #ff771b;
}

.streak-freeze-indicator {
  display: block;
  width: 100%;
  color: #2786a0;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
}

.streak-freeze-indicator[hidden],
.streak-rescue-card[hidden],
.streak-rescue-actions[hidden],
.streak-rescue-actions button[hidden] {
  display: none;
}

.streak-rescue-card {
  min-height: 104px;
  margin-top: 10px;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  align-items: center;
  gap: 11px;
  padding: 12px 14px;
  border: 1px solid #ccecf4;
  border-radius: 18px;
  background: #eefaff;
  box-shadow: 0 8px 18px rgba(39, 134, 160, 0.1);
}

.streak-rescue-card.saved {
  min-height: 76px;
}

.streak-rescue-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #d9f3fb;
  font-size: 25px;
}

.streak-rescue-card strong,
.streak-rescue-card small {
  display: block;
}

.streak-rescue-card strong {
  margin-bottom: 3px;
  font-size: 15px;
}

.streak-rescue-card small {
  color: #58727a;
  font-size: 12px;
  line-height: 1.3;
}

.streak-rescue-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-top: 9px;
}

.streak-rescue-actions button {
  min-width: 0;
  min-height: 34px;
  padding: 6px 8px;
  border: 1px solid #b8dfe9;
  border-radius: 11px;
  background: #fff;
  color: #246e82;
  font-size: 11px;
  font-weight: 800;
}

.streak-rescue-actions .freeze-action {
  background: #dff6fc;
}

.mission-card {
  margin-top: 10px;
  min-height: 84px;
  display: grid;
  grid-template-columns: 52px 1fr auto;
  align-items: center;
  column-gap: 12px;
  padding: 10px 14px;
  background: #f7f9e8;
  cursor: pointer;
}

.mission-card:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 3px;
}

.mission-icon {
  width: 50px;
  height: 48px;
  display: grid;
  place-items: center start;
}

.mission-icon img {
  width: 50px;
  height: 50px;
  display: block;
  object-fit: contain;
}

.achievements-title {
  margin-top: 18px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.achievements-title small {
  color: var(--muted);
}

.referral-card {
  background: #f3f8e9;
}

.referral-icon {
  overflow: hidden;
  border-radius: 50%;
}

.referral-icon img {
  transform: scale(1.12);
}

.mission-card p {
  margin: 5px 0 0;
  color: #5f6a4f;
  font-size: 12px;
  line-height: 1.28;
  font-weight: 600;
}

.mission-card p[hidden] {
  display: none;
}

.achievement-pager {
  width: fit-content;
  display: grid;
  grid-template-columns: 28px auto 28px;
  align-items: center;
  gap: 7px;
  margin: 2px auto 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.achievement-pager button {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: #f1eadc;
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
  font-weight: 900;
}

.achievement-pager button:disabled {
  opacity: 0.35;
}

.badges {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0 8px;
  align-items: stretch;
}

.badges span {
  min-width: 0;
  display: grid;
  justify-items: center;
  align-content: start;
  grid-template-rows: 76px 28px;
  gap: 4px;
  min-height: 108px;
  text-align: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.badges span[hidden] {
  display: none;
}

.badges b {
  width: 74px;
  height: 74px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  background: transparent;
  box-shadow: 0 8px 14px rgba(55, 42, 20, 0.08);
}

.badges b img {
  width: 74px;
  height: 74px;
  display: block;
  object-fit: contain;
}

.badges small {
  color: #3e3e3e;
  font-size: 10px;
  line-height: 1.15;
  font-weight: 700;
  display: grid;
  align-items: start;
}

.badges span.locked b {
  filter: grayscale(1);
  opacity: 0.42;
  box-shadow: none;
}

.badges span.locked small {
  color: #9a958c;
}

.lower {
  margin-top: 24px;
}

.missions-hero {
  height: 215px;
}

.missions-hero .mission-cat-art {
  width: 315px;
  height: 260px;
  transform: translateY(-18px);
}

.profile-hero,
.profile-panel {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.profile-hero {
  position: relative;
  min-height: 98px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 14px;
  overflow: hidden;
}

.avatar {
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: transparent;
  overflow: hidden;
}

.avatar img {
  width: 88px;
  height: 88px;
  display: block;
  object-fit: cover;
}

.profile-hero h2 {
  margin: 0;
  font-size: 20px;
}

.profile-hero p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.profile-hero p b,
.profile-panel strong,
.profile-stats strong {
  color: var(--green-dark);
}

.profile-cat-art {
  width: 88px;
  height: 88px;
  object-fit: contain;
  object-position: center;
  margin-right: 2px;
}

.profile-heart {
  position: absolute;
  right: 10px;
  top: 16px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: white;
  color: var(--green);
  box-shadow: 0 6px 14px rgba(55, 42, 20, 0.12);
}

.profile-panel {
  margin-top: 12px;
  padding: 14px;
}

.home-progress-panel {
  margin-top: 12px;
}

.profile-menu {
  width: 100%;
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.profile-menu-button {
  width: 100%;
  min-height: 66px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  color: #242424;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.profile-menu-button:active {
  transform: translateY(1px);
}

.profile-menu-button > span:first-child {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: #edf8df;
  overflow: hidden;
}

.profile-menu-button > span:first-child img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.profile-menu-button > span:nth-child(2) {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.profile-menu-button strong {
  font-size: 16px;
}

.profile-menu-button small {
  color: var(--muted);
  font-size: 12px;
}

.profile-menu-button > b {
  color: var(--green-dark);
  font-size: 28px;
  line-height: 1;
}

.community-button > span:first-child img {
  width: 25px;
  height: 25px;
  filter: invert(48%) sepia(71%) saturate(593%) hue-rotate(55deg) brightness(88%) contrast(88%);
}

.profile-popup {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: end center;
  padding: 18px;
  background: rgba(24, 22, 18, 0.34);
}

.profile-popup[hidden] {
  display: none;
}

.profile-popup-open {
  overflow: hidden;
}

.profile-popup-sheet {
  width: min(100%, 394px);
  max-height: min(78vh, 620px);
  overflow-y: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: #fffdf8;
  box-shadow: 0 22px 50px rgba(31, 24, 11, 0.24);
}

.profile-popup-sheet > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 2px 10px 8px;
}

.profile-popup-sheet > header h2 {
  margin: 0;
  font-size: 20px;
}

.profile-popup-sheet > header button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: #f3eddf;
  color: #333;
  font-size: 25px;
  line-height: 1;
}

.profile-popup-panel {
  margin-top: 0;
  box-shadow: none;
}

.profile-panel[data-soon-update] {
  cursor: pointer;
}

.profile-panel[data-soon-update]:active {
  transform: translateY(1px);
}

.profile-panel h2 {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 10px;
  padding-left: 8px;
  font-size: 17px;
}

.profile-panel h2 span,
.profile-panel button > span,
.profile-field > span {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border-radius: 9px;
  background: #edf8df;
  color: var(--green-dark);
  overflow: hidden;
}

.profile-panel h2 span img,
.profile-panel button > span img,
.profile-field > span img {
  width: 30px;
  height: 30px;
  display: block;
  object-fit: contain;
  object-position: center;
}

.profile-panel h2 span img[src*="profile-goals"],
.profile-panel button > span img[src*="profile-calorie-goal"],
.profile-panel button > span img[src*="profile-protein-goal"] {
  width: 36px;
  height: 36px;
}

.profile-water-symbol {
  width: 13px;
  height: 17px;
  display: block;
  border-radius: 65% 35% 65% 35%;
  background: var(--green);
  transform: rotate(45deg);
  box-shadow: inset -2px -2px 0 rgba(56, 130, 34, 0.18);
}

.profile-panel h2 span img[src*="profile-goals-symbol"] {
  width: 21px;
  height: 21px;
}

.profile-panel button {
  width: 100%;
  min-height: 42px;
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 11px;
  padding-left: 8px;
  border: 0;
  border-top: 1px dashed #eee5d5;
  background: transparent;
  text-align: left;
  color: #2b2b2b;
  font-weight: 600;
}

.profile-panel button:first-of-type {
  border-top: 0;
}

.profile-panel button b {
  color: #8b8b8b;
  font-size: 24px;
  line-height: 1;
}

.profile-field {
  min-height: 44px;
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 11px;
  padding-left: 8px;
  border-top: 1px dashed #eee5d5;
}

.profile-field:first-of-type {
  border-top: 0;
}

.profile-field label {
  font-weight: 600;
}

.profile-field div {
  color: var(--green-dark);
  font-weight: 800;
}

.profile-field input,
.profile-field select {
  width: 74px;
  height: 32px;
  border: 1px solid #ded4bf;
  border-radius: 10px;
  padding: 0 8px;
  background: #fbf7eb;
  color: var(--green-dark);
  font: inherit;
  font-weight: 800;
  text-align: right;
}

.profile-field select {
  width: 112px;
  text-align: left;
}

.profile-field select[data-profile-goal] {
  width: 176px;
  font-size: 13px;
}

.reminder-panel > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #333;
  font-size: 15px;
}

.reminder-panel {
  display: grid;
  gap: 14px;
}

.reminder-row {
  gap: 12px;
}

.reminder-row > span {
  line-height: 1.25;
}

.water-reminder-row {
  padding-top: 10px;
  border-top: 1px dashed #eadfcb;
}

.water-reminder-copy {
  display: grid;
  gap: 3px;
}

.water-reminder-copy b {
  font-size: 14px;
}

.water-reminder-copy small {
  max-width: 225px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
}

.reminder-time-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 10px;
  border-top: 1px dashed #eadfcb;
  color: #333;
  font-size: 15px;
  font-weight: 700;
}

.reminder-time-row input {
  width: 112px;
  height: 36px;
  border: 1px solid #ded4bf;
  border-radius: 12px;
  padding: 0 8px;
  background: #fbf7eb;
  color: var(--green-dark);
  font: inherit;
  font-weight: 800;
  text-align: center;
}

.reminder-time-row input:disabled {
  opacity: 0.45;
}

.switch input {
  position: absolute;
  opacity: 0;
}

.switch span {
  width: 48px;
  height: 30px;
  display: block;
  border-radius: 999px;
  background: #d8d8d8;
  position: relative;
}

.switch span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: white;
  transition: transform 0.18s ease;
}

.switch input:checked + span {
  background: linear-gradient(180deg, #6fc444, #49a52d);
}

.switch input:checked + span::after {
  transform: translateX(18px);
}

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

.profile-stats > span {
  min-height: 78px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  grid-template-rows: 1fr 1fr;
  align-items: center;
  gap: 2px 6px;
  padding: 8px;
  border-radius: 14px;
  background: #faf5e8;
}

.profile-stats b {
  grid-row: 1 / 3;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.profile-stats b img {
  width: 26px;
  height: 26px;
  display: block;
  object-fit: contain;
  object-position: center;
}

.profile-stats b img[src*="profile-streak"] {
  width: 26px;
  height: 26px;
}

.profile-stats b img[src*="profile-achievements"] {
  width: 26px;
  height: 26px;
}

.profile-stats small {
  color: var(--muted);
  font-size: 9px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.profile-stats strong {
  font-size: 15px;
  line-height: 1.1;
  white-space: normal;
}

.profile-stats strong span {
  display: inline;
  min-height: 0;
  padding: 0;
  border-radius: 0;
  background: transparent;
}

.tabbar {
  position: fixed;
  left: 50%;
  right: auto;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 40;
  width: calc(min(100vw, 430px) - 36px);
  min-height: 80px;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  padding: 8px 7px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 12px 26px rgba(55, 42, 20, 0.13);
}

.tabbar button {
  border: 0;
  border-radius: 16px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  display: grid;
  place-items: center;
  gap: 3px;
}

.tab-icon {
  display: block;
  width: 40px;
  height: 40px;
  object-fit: contain;
  filter: grayscale(1) saturate(0) opacity(0.72);
}

.tabbar button.active {
  color: var(--green-dark);
}

.tabbar button.active .tab-icon {
  filter: invert(48%) sepia(71%) saturate(593%) hue-rotate(55deg) brightness(88%) contrast(88%);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  min-width: 230px;
  max-width: min(340px, calc(100vw - 32px));
  padding: 14px 18px;
  border-radius: 22px;
  color: white;
  background: rgba(25, 25, 25, 0.9);
  text-align: center;
  white-space: pre-line;
  line-height: 1.32;
  overflow-wrap: anywhere;
  transform: translate(-50%, 120px);
  transition: transform 0.22s ease;
  pointer-events: none;
  z-index: 40;
}

.toast.show {
  transform: translate(-50%, 0);
}

.onboarding-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(24, 22, 18, 0.32);
}

.onboarding-modal[hidden] {
  display: none;
}

.onboarding-sheet {
  width: min(100%, 394px);
  display: grid;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: #fffdf8;
  box-shadow: 0 22px 50px rgba(31, 24, 11, 0.24);
}

.onboarding-sheet strong {
  display: block;
  font-size: 22px;
}

.onboarding-sheet small {
  color: var(--muted);
}

.onboarding-sheet label {
  display: grid;
  gap: 6px;
  color: #3a3a3a;
  font-size: 13px;
  font-weight: 800;
}

.onboarding-sheet input,
.onboarding-sheet select,
.onboarding-sheet textarea {
  width: 100%;
  border: 1px solid #ded4bf;
  border-radius: 13px;
  background: #fbf7eb;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
}

.onboarding-sheet input,
.onboarding-sheet select {
  height: 44px;
  padding: 0 12px;
}

.onboarding-sheet input::placeholder,
.onboarding-sheet select:invalid {
  color: #8a8478;
}

.onboarding-sheet .onboarding-field-error {
  border-color: #e5483f;
  background: #fff4f2;
  box-shadow: 0 0 0 2px rgba(229, 72, 63, 0.13);
}

.onboarding-error {
  color: #cf332c;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
}

.onboarding-sheet textarea {
  min-height: 104px;
  resize: vertical;
  padding: 12px;
  line-height: 1.35;
}

.onboarding-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.onboarding-sheet button {
  min-height: 50px;
  border: 0;
  border-radius: 16px;
  color: white;
  background: linear-gradient(180deg, #6fc444, #49a52d);
  font-size: 18px;
  font-weight: 900;
}

.onboarding-sheet button:disabled {
  opacity: 0.65;
}

.food-sheet-actions {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 10px;
}

.food-sheet-actions .secondary {
  color: #4b4b4b;
  background: #f4eddc;
}

.visually-hidden-file {
  position: fixed;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 440px) {
  body {
    display: block;
    background: #fbf7ec;
  }

  .phone-shell {
    width: 100%;
    min-height: 100vh;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .cat-hero {
    height: 238px;
  }

  .party {
    height: 292px;
  }

  .hero-cat-art {
    width: 294px;
    height: 294px;
    transform: translateY(-20px);
  }

  .mission-cat-art {
    width: 368px;
    height: 310px;
  }

  .missions-hero {
    height: 215px;
  }

  .missions-hero .mission-cat-art {
    width: 315px;
    height: 260px;
    transform: translateY(-18px);
  }

  .add-food-menu {
    gap: 8px;
  }

  .add-food-menu button {
    min-height: 72px;
    font-size: 14px;
  }

  .badges {
    gap: 0 5px;
  }

  .badges b {
    width: 74px;
    height: 74px;
  }

  .badges b img {
    width: 74px;
    height: 74px;
  }
}
