html,
body {
  min-height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
  margin: 0;
  padding: 0;
  background: #FFFFFF;
  color: #1C1C1E;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -webkit-overflow-scrolling: touch;
}

* {
  box-sizing: border-box;
}

body.app-shell {
  min-height: 100vh;
  background: #FFFFFF;
}

body.app-shell,
body.app-shell section,
body.app-shell nav,
body.app-shell p,
body.app-shell h1,
body.app-shell h2,
body.app-shell h3,
body.app-shell span,
body.app-shell button,
body.app-shell a,
body.app-shell div {
  user-select: none;
}

input,
textarea,
select {
  user-select: text;
}

main.app-screen {
  width: min(100%, 460px);
  margin: 0 auto;
  min-height: 100dvh;
  padding: calc(16px + env(safe-area-inset-top)) 28px calc(20px + env(safe-area-inset-bottom));
}

.app-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  min-height: 44px;
}

.app-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
  color: #1C1C1E;
}

.app-brand-mark {
  width: 36px;
  height: 36px;
  display: block;
  object-fit: contain;
  border-radius: 12px;
}

.app-brand-wordmark {
  height: 18px;
  width: auto;
  display: block;
}

.app-card {
  background: #FFFFFF;
  border: 0;
  box-shadow: none;
  border-radius: 24px;
  padding: 0;
}

.app-glass {
  background: #FFFFFF;
  backdrop-filter: none;
}

.app-hero {
  margin-bottom: 30px;
}

.app-kicker {
  display: inline-block;
  padding: 7px 12px;
  border-radius: 999px;
  background: #F5F6FA;
  color: #8E8E93;
  border: 0;
  font-size: 12px;
  font-weight: 600;
}

.app-title {
  margin: 14px 0 8px;
  font-size: 34px;
  line-height: 1.08;
  font-weight: 800;
  color: #1C1C1E;
  letter-spacing: -0.04em;
}

.app-subtitle {
  margin: 0;
  color: #8E8E93;
  font-size: 16px;
  line-height: 1.45;
  font-weight: 500;
}

.app-stack {
  display: grid;
  gap: 14px;
}

.app-grid {
  display: grid;
  gap: 14px;
}

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

.app-label {
  display: grid;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: #1C1C1E;
}

.app-input,
.app-select,
.app-textarea {
  width: 100%;
  min-height: 54px;
  border: 0;
  background: #F5F6FA;
  border-radius: 18px;
  padding: 16px 18px;
  font-size: 16px;
  color: #1C1C1E;
  outline: none;
  transition: box-shadow 0.2s ease, background 0.2s ease;
  appearance: none;
}

.app-textarea {
  min-height: 112px;
  resize: vertical;
}

.app-input::placeholder,
.app-textarea::placeholder {
  color: #8E8E93;
}

.app-input:focus,
.app-select:focus,
.app-textarea:focus {
  background: #FFFFFF;
  box-shadow: 0 0 0 2px #006db5;
}

.app-button {
  min-height: 60px;
  border: 0;
  border-radius: 16px;
  padding: 16px 18px;
  background: #006db5;
  color: #FFFFFF;
  font-size: 17px;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.app-button:disabled {
  opacity: 0.7;
}

.app-button-secondary {
  background: #F5F6FA;
  color: #1C1C1E;
}

.app-button-light {
  background: #FFFFFF;
  color: #006db5;
}

.app-inline-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.app-inline-actions > * {
  flex: 1;
}

.app-status {
  display: none;
  border-radius: 16px;
  padding: 13px 14px;
  font-size: 14px;
  line-height: 1.5;
}

.app-status.is-visible {
  display: block;
}

.app-status.is-success,
.app-status.is-loading {
  background: rgba(0, 109, 181, 0.10);
  color: #1C1C1E;
}

.app-status.is-error {
  background: rgba(255, 59, 48, 0.12);
  color: #1C1C1E;
}

.app-link {
  color: #006db5;
  text-decoration: none;
  font-weight: 700;
}

.app-link-row {
  text-align: center;
  color: #8E8E93;
  font-size: 14px;
  margin-top: 18px;
}

.welcome-screen {
  height: 100dvh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.welcome-brand-row {
  display: flex;
  justify-content: center;
  padding-top: 14px;
}

.welcome-visual {
  margin: 44px auto 34px;
  width: min(76vw, 300px);
  aspect-ratio: 0.72;
  border-radius: 34px;
  display: grid;
  place-items: center;
  color: #8E8E93;
  text-align: center;
  padding: 24px;
  font-size: 14px;
  line-height: 1.5;
}

.welcome-copy {
  margin-top: auto;
  padding-bottom: 10px;
}

.welcome-title {
  margin: 0 0 12px;
  color: #1C1C1E;
  font-size: 44px;
  line-height: 0.98;
  font-weight: 800;
  letter-spacing: -0.05em;
}

.welcome-subtitle {
  margin: 0;
  color: #8E8E93;
  font-size: 18px;
  line-height: 1.35;
  font-weight: 600;
}

.welcome-actions {
  display: grid;
  gap: 12px;
  margin-top: 28px;
}

.onboarding-screen {
  height: 100dvh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.onboarding-top {
  display: grid;
  grid-template-columns: 44px 1fr 56px;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}

.onboarding-icon-button {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 999px;
  background: #F5F6FA;
  color: #1C1C1E;
  display: grid;
  place-items: center;
  font-size: 24px;
  text-decoration: none;
}

.onboarding-skip {
  color: #1C1C1E;
  text-decoration: none;
  font-size: 15px;
  font-weight: 700;
  text-align: right;
}

.onboarding-progress {
  height: 5px;
  border-radius: 999px;
  background: #F0F1F5;
  overflow: hidden;
}

.onboarding-progress-bar {
  display: block;
  height: 100%;
  width: 25%;
  border-radius: inherit;
  background: #006db5;
  transition: width 0.2s ease;
}

.app-step-panel {
  display: none;
  flex: 1;
}

.app-step-panel.is-active {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
}

.app-step-heading {
  margin: 0;
  font-size: 34px;
  line-height: 1.08;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.app-step-text {
  margin: 0 0 34px;
  color: #8E8E93;
  font-size: 16px;
  line-height: 1.45;
  font-weight: 600;
}

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

.option-card {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 58px;
  padding: 16px;
  border-radius: 15px;
  background: #F5F6FA;
  color: #1C1C1E;
  font-size: 17px;
  font-weight: 800;
  text-align: center;
}

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

.option-card:has(input:checked) {
  background: #006db5;
  color: #FFFFFF;
}

.onboarding-fields {
  display: grid;
  gap: 12px;
}

.onboarding-bottom {
  margin-top: auto;
  padding-top: 28px;
}

@supports not selector(:has(*)) {
  .option-card.is-selected {
    background: #006db5;
    color: #FFFFFF;
  }
}

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

.app-stat,
.app-nav a {
  background: #F5F6FA;
  border-radius: 18px;
  border: 0;
  padding: 16px;
}

.app-stat-label {
  font-size: 12px;
  color: #8E8E93;
  margin-bottom: 8px;
}

.app-stat-value {
  font-size: 24px;
  line-height: 1.1;
  font-weight: 800;
  color: #1C1C1E;
}

.app-nav {
  display: grid;
  gap: 10px;
}

.app-nav a {
  display: block;
  min-height: 44px;
  text-decoration: none;
  color: #1C1C1E;
  font-weight: 700;
}

.app-button-small {
  min-height: 40px;
  padding: 10px 14px;
  font-size: 14px;
}

.dashboard-screen,
.meal-add-screen {
  overflow: auto;
}

.dashboard-hero {
  margin-bottom: 20px;
}

.calorie-ring {
  width: 172px;
  height: 172px;
  margin: 0 auto 4px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(#006db5 calc(var(--progress) * 1%), #F0F1F5 0);
}

.calorie-ring > div {
  width: 128px;
  height: 128px;
  border-radius: 50%;
  background: #FFFFFF;
  display: grid;
  place-items: center;
  align-content: center;
  box-shadow: inset 0 0 0 1px rgba(60, 60, 67, 0.06);
}

.calorie-ring strong {
  font-size: 34px;
  line-height: 1;
  font-weight: 800;
}

.calorie-ring span {
  color: #8E8E93;
  font-size: 13px;
  font-weight: 700;
}

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

.nutrition-ring-card {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 12px;
  border-radius: 20px;
  background: #F8F9FC;
}

.nutrition-ring {
  width: 118px;
  height: 118px;
  margin: 0;
}

.nutrition-ring > div {
  width: 86px;
  height: 86px;
}

.nutrition-ring strong {
  font-size: 24px;
}

.nutrition-ring span {
  font-size: 11px;
}

.nutrition-ring-meta {
  display: grid;
  gap: 2px;
  text-align: center;
}

.nutrition-ring-meta b {
  color: #1C1C1E;
  font-size: 14px;
  font-weight: 800;
}

.nutrition-ring-meta span {
  color: #8E8E93;
  font-size: 12px;
  font-weight: 700;
}

.dashboard-quick-nav {
  margin-top: -2px;
}

.plan-hero-card {
  text-align: center;
}

.plan-target-main {
  display: grid;
  justify-items: center;
  gap: 3px;
  padding: 12px 0 6px;
}

.plan-target-main span,
.plan-target-main b {
  color: #8E8E93;
  font-size: 13px;
  font-weight: 800;
}

.plan-target-main strong {
  color: #1C1C1E;
  font-size: 58px;
  line-height: 0.95;
  font-weight: 900;
  letter-spacing: -0.06em;
}

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

.plan-mini-card {
  display: grid;
  gap: 2px;
  padding: 14px;
  border-radius: 18px;
  background: #F5F6FA;
}

.plan-mini-card span,
.plan-mini-card b {
  color: #8E8E93;
  font-size: 12px;
  font-weight: 800;
}

.plan-mini-card strong {
  color: #1C1C1E;
  font-size: 24px;
  line-height: 1;
  font-weight: 900;
}

.profile-form {
  margin-bottom: 24px;
}

.profile-form .app-label {
  gap: 8px;
}

.macro-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.macro-row span {
  flex: 1;
  min-width: 96px;
  padding: 10px;
  border-radius: 14px;
  background: #F5F6FA;
  color: #1C1C1E;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
}

.dashboard-meals {
  margin-top: 18px;
}

.section-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-heading-row h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

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

.meal-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-radius: 18px;
  background: #F5F6FA;
  color: #1C1C1E;
  text-decoration: none;
}

.meal-card div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.meal-card strong,
.meal-card b {
  font-size: 15px;
  font-weight: 800;
}

.meal-card span {
  color: #8E8E93;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 210px;
}

.meal-card-static {
  text-decoration: none;
}

.meal-thumb {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  object-fit: cover;
  flex: 0 0 auto;
}

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

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

.history-date-group .section-heading-row span {
  color: #8E8E93;
  font-size: 13px;
  font-weight: 700;
}

.meal-detail-image {
  width: 100%;
  max-height: 260px;
  object-fit: cover;
  border-radius: 26px;
  margin-bottom: 18px;
  background: #F5F6FA;
}

.image-picker {
  min-height: 160px;
  border-radius: 22px;
  background: #F5F6FA;
  display: grid;
  place-items: center;
  padding: 16px;
  color: #8E8E93;
  font-weight: 800;
  text-align: center;
  overflow: hidden;
}

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

.image-picker img {
  display: none;
  width: 100%;
  max-height: 240px;
  object-fit: cover;
  border-radius: 16px;
}

.image-picker img.is-visible {
  display: block;
}

.image-picker img.is-visible + span,
.image-picker:has(img.is-visible) span {
  display: none;
}

@media (max-width: 420px) {
  main.app-screen {
    padding-left: 28px;
    padding-right: 28px;
  }

  .app-grid-2,
  .app-stat-grid {
    grid-template-columns: 1fr;
  }

  .welcome-title,
  .app-step-heading {
    font-size: 34px;
  }
}

@media (height <= 760px) {
  body.app-shell {
    overflow: hidden;
  }

  main.app-screen {
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
    padding-top: calc(10px + env(safe-area-inset-top));
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }

  .welcome-brand-row {
    padding-top: 4px;
  }

  .welcome-visual {
    margin: 14px auto 14px;
    width: min(58vw, 220px);
    max-height: 250px;
    padding: 12px;
  }

  .welcome-title {
    font-size: 34px;
    margin-bottom: 6px;
  }

  .welcome-subtitle {
    font-size: 15px;
  }

  .welcome-actions {
    gap: 8px;
    margin-top: 16px;
  }

  .app-button {
    min-height: 48px;
    padding: 12px 14px;
    border-radius: 14px;
    font-size: 15px;
  }

  .onboarding-top {
    grid-template-columns: 40px 1fr 48px;
    gap: 10px;
    margin-bottom: 18px;
  }

  .onboarding-icon-button {
    width: 40px;
    height: 40px;
    font-size: 22px;
  }

  .app-hero {
    margin-bottom: 18px;
  }

  .app-title,
  .app-step-heading {
    font-size: 28px;
  }

  .app-subtitle,
  .app-step-text {
    font-size: 14px;
    line-height: 1.35;
  }

  .app-step-text {
    margin-bottom: 14px;
  }

  .app-step-panel.is-active {
    gap: 10px;
  }

  .option-list,
  .onboarding-fields,
  .app-stack {
    gap: 8px;
  }

  .option-card {
    min-height: 46px;
    padding: 11px 12px;
    border-radius: 13px;
    font-size: 15px;
  }

  .app-label {
    gap: 5px;
    font-size: 12px;
  }

  .app-input,
  .app-select,
  .app-textarea {
    min-height: 44px;
    padding: 11px 13px;
    border-radius: 14px;
    font-size: 15px;
  }

  .app-textarea {
    min-height: 72px;
  }

  .onboarding-bottom {
    padding-top: 14px;
  }
}

@media (height <= 680px) {
  main.app-screen {
    padding-left: 22px;
    padding-right: 22px;
  }

  .welcome-visual {
    width: min(50vw, 170px);
    max-height: 190px;
    margin: 8px auto 10px;
  }

  .welcome-title,
  .app-step-heading,
  .app-title {
    font-size: 25px;
  }

  .welcome-actions {
    margin-top: 12px;
  }

  .onboarding-top {
    margin-bottom: 12px;
  }

  .app-step-text {
    margin-bottom: 8px;
  }

  .option-card {
    min-height: 40px;
    padding: 8px 10px;
    font-size: 14px;
  }

  .app-input,
  .app-select,
  .app-textarea {
    min-height: 39px;
    padding: 8px 11px;
    font-size: 14px;
  }

  .app-textarea {
    min-height: 58px;
  }

  .app-button {
    min-height: 44px;
  }

  .onboarding-bottom {
    padding-top: 8px;
  }
}
