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(124px + 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;
}

.weight-log-card b {
  color: #8E8E93;
  font-size: 14px;
}

.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;
}

.diary-shell main.app-screen {
  width: min(100%, 430px);
  padding: calc(14px + env(safe-area-inset-top)) 18px calc(92px + env(safe-area-inset-bottom));
}

.diary-screen {
  display: grid;
  gap: 16px;
}

.diary-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-top: 4px;
}

.diary-header h1 {
  margin: 10px 0 0;
  font-size: 28px;
  line-height: 1.1;
  font-weight: 900;
  letter-spacing: -0.04em;
}

.diary-icon-button {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 999px;
  background: #F5F6FA;
  color: #006db5;
  font-size: 16px;
  font-weight: 900;
  text-decoration: none;
  display: grid;
  place-items: center;
}

.diary-date-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #8E8E93;
  font-size: 14px;
  font-weight: 800;
}

.diary-date-nav a {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #F5F6FA;
  color: #8E8E93;
  text-decoration: none;
}

.diary-calorie-card {
  border-radius: 30px;
  padding: 20px;
  background: linear-gradient(160deg, #0088d4 0%, #006db5 56%, #005a9e 100%);
  color: #FFFFFF;
  box-shadow: 0 22px 44px rgba(0, 109, 181, 0.22);
  display: grid;
  gap: 16px;
  position: relative;
  overflow: hidden;
}

.diary-calorie-card::after {
  content: '';
  position: absolute;
  width: 160px;
  height: 160px;
  right: -58px;
  top: -70px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.10);
}

.diary-card-label {
  position: relative;
  z-index: 1;
  width: max-content;
  padding: 7px 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  color: rgba(255, 255, 255, 0.92);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.01em;
}

.diary-calorie-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  justify-content: space-between;
  gap: 18px;
  position: relative;
  z-index: 1;
}

.diary-calorie-row span,
.diary-calorie-meta span {
  display: block;
  font-size: 14px;
  font-weight: 800;
  opacity: 0.88;
}

.diary-calorie-row strong {
  display: block;
  margin-top: 8px;
  font-size: 52px;
  line-height: 0.95;
  font-weight: 900;
  letter-spacing: -0.06em;
}

.diary-calorie-row b {
  display: block;
  margin-top: 4px;
  font-size: 18px;
  font-weight: 800;
  opacity: 0.9;
}

.diary-progress {
  width: 100%;
  height: 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  overflow: hidden;
  position: relative;
  z-index: 1;
}

.diary-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: rgba(255, 255, 255, 0.95);
}

.diary-calorie-card.is-over {
  background: linear-gradient(180deg, #ff7a59 0%, #ef4444 100%);
}

.diary-calorie-card.is-over .diary-progress span {
  background: rgba(255, 244, 240, 0.98);
}

.diary-calorie-warning {
  margin: 0;
  position: relative;
  z-index: 1;
  color: rgba(255, 255, 255, 0.92);
  font-size: 13px;
  line-height: 1.5;
  font-weight: 700;
}

.diary-calorie-card.is-over .diary-calorie-meta > * {
  background: rgba(255, 255, 255, 0.18);
}

.diary-calorie-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: center;
  gap: 8px;
  position: relative;
  z-index: 1;
}

.diary-calorie-meta > * {
  min-height: 42px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.14);
  display: flex !important;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 6px 8px;
}

.diary-calorie-meta strong {
  font-size: 14px;
  font-weight: 900;
}

.diary-macro-card,
.diary-ai-card,
.diary-meal-card {
  border-radius: 26px;
  background: #FFFFFF;
  border: 1px solid rgba(232, 234, 241, 0.75);
  box-shadow: 0 12px 34px rgba(16, 24, 40, 0.07);
  padding: 18px;
}

.diary-macro-card,
.diary-ai-card {
  display: grid;
  gap: 16px;
}

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

.diary-quick-actions a {
  min-height: 54px;
  border-radius: 18px;
  background: #FFFFFF;
  border: 1px solid rgba(0, 109, 181, 0.10);
  box-shadow: 0 8px 20px rgba(16, 24, 40, 0.05);
  color: #006db5;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 13px;
  font-weight: 900;
}

.diary-ai-heading {
  display: grid;
  gap: 4px;
}

.diary-ai-heading span {
  color: #006db5;
  font-size: 12px;
  font-weight: 900;
}

.diary-ai-heading strong {
  color: #1C1C1E;
  font-size: 18px;
  font-weight: 900;
}

.diary-ai-actions {
  display: grid;
  gap: 10px;
}

.diary-ai-actions form {
  display: block;
}

.diary-ai-btn {
  width: 100%;
  min-height: 52px;
  border: 0;
  border-radius: 16px;
  background: #006db5;
  color: #FFFFFF;
  font-size: 16px;
  font-weight: 800;
  padding: 14px 16px;
  text-decoration: none;
  display: flex;
  justify-content: center;
  align-items: center;
}

.diary-ai-btn-alt {
  background: rgba(0, 109, 181, 0.08);
  color: #006db5;
  text-decoration: none;
}

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

.diary-macro-item {
  display: grid;
  gap: 8px;
  justify-items: center;
  text-align: center;
}

.diary-macro-ring {
  width: 78px;
  height: 78px;
  border-radius: 50%;
  background: conic-gradient(#006db5 calc(var(--progress) * 1%), #E8EAF1 0);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  place-items: center;
  position: relative;
}

.diary-macro-ring::before {
  content: '';
  position: absolute;
  inset: 8px;
  background: #FFFFFF;
  border-radius: 50%;
}

.diary-macro-ring strong,
.diary-macro-ring span {
  position: relative;
  z-index: 1;
}

.diary-macro-ring strong {
  font-size: 18px;
  line-height: 1;
  font-weight: 900;
}

.diary-macro-ring span {
  color: #8E8E93;
  font-size: 11px;
  font-weight: 700;
}

.diary-macro-item b {
  color: #1C1C1E;
  font-size: 13px;
  font-weight: 800;
}

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

.meal-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.diary-meal-card {
  display: grid;
  gap: 14px;
  padding: 20px;
}

.diary-meal-top {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
}

.diary-meal-check {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 4px solid #E8EAF1;
}

.diary-meal-top strong {
  font-size: 18px;
  font-weight: 900;
  color: #1C1C1E;
}

.diary-meal-top b {
  color: #8E8E93;
  font-size: 13px;
  font-weight: 800;
}

.diary-meal-card p {
  margin: 0;
  color: #8E8E93;
  font-size: 14px;
  font-weight: 600;
}

.diary-empty-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.diary-empty-row span {
  font-size: 28px;
}

.diary-empty-row a,
.diary-add-more {
  min-height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  background: rgba(0, 109, 181, 0.08);
  color: #006db5;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 14px;
}

.diary-plus {
  width: 66px;
  height: 66px;
  border-radius: 50%;
  background: linear-gradient(180deg, #0088d4 0%, #006db5 100%);
  color: #FFFFFF !important;
  display: grid;
  place-items: center;
  margin: -24px auto 0;
  font-size: 32px !important;
  line-height: 1;
  box-shadow: 0 14px 26px rgba(0, 109, 181, 0.35);
}

.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-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.meal-detail-actions form {
  margin: 0;
}

.meal-action-button {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: #F5F6FA;
  color: #1C1C1E;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.meal-action-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.meal-action-button:active {
  transform: scale(0.96);
}

.meal-action-button-danger {
  background: #FFF1F2;
  color: #E11D48;
}

body.has-open-modal {
  overflow: hidden;
}

.app-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  align-items: end;
  justify-items: center;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.app-modal.is-open {
  pointer-events: auto;
  opacity: 1;
}

.app-modal-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(15, 23, 42, 0.38);
  backdrop-filter: blur(8px);
}

.app-modal-panel {
  position: relative;
  width: min(100%, 428px);
  max-height: min(78dvh, 620px);
  overflow: auto;
  border-radius: 30px;
  background: #FFFFFF;
  padding: 22px;
  box-shadow: 0 28px 70px rgba(15, 23, 42, 0.24);
  transform: translateY(18px) scale(0.98);
  transition: transform 0.22s ease;
}

.app-modal.is-open .app-modal-panel {
  transform: translateY(0) scale(1);
}

.app-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.app-modal-header h2 {
  margin: 4px 0 0;
  font-size: 24px;
  line-height: 1.1;
}

.app-modal-close {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 16px;
  background: #F5F6FA;
  color: #1C1C1E;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

.diary-bottom-nav {
  position: fixed;
  left: 4vw;
  right: 4vw;
  bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 10px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.12);
  backdrop-filter: blur(18px);
}

.diary-bottom-nav a {
  position: relative;
  min-height: 52px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  color: #9aa4b2;
  text-decoration: none;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.diary-bottom-nav a.is-active {
  background: #eef6ff;
  color: #0f172a;
}

.diary-bottom-nav a.is-active .nav-icon {
  transform: translateY(-1px);
}

.diary-bottom-nav a:active {
  transform: scale(0.97);
}

.nav-icon {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  line-height: 1;
}

.nav-icon svg {
  width: 23px;
  height: 23px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.diary-bottom-nav a[href="/plan"] .nav-icon svg {
  fill: currentColor;
  stroke-width: 1.6;
}

.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;
}

.next-meal-suggestion-card {
  border-radius: 24px;
  background: rgb(1 108 181);
  padding: 16px;
  color: #FFFFFF;
  display: grid;
  gap: 12px;
}

.next-meal-suggestion-card strong {
  display: block;
  font-size: 20px;
}

.next-meal-suggestion-card p,
.next-meal-suggestion-card ul {
  margin: 0;
  color: rgba(255, 255, 255, 0.78);
  font-size: 14px;
  line-height: 1.55;
}

.next-meal-suggestion-card ul {
  padding-left: 18px;
}

.next-meal-suggestion-card small {
  color: rgba(255, 255, 255, 0.58);
  font-weight: 700;
}

.next-meal-regenerate {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 4px;
}

.next-meal-regenerate small {
  color: rgb(0 0 0 / 52%);
  font-size: 12px;
  font-weight: 700;
}

.next-meal-regenerate-btn {
  border: 0;
  background: none;
  color: rgb(0 0 0 / 72%);
  font-size: 13px;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  padding: 6px 0;
}

.next-meal-regenerate-btn:active {
  opacity: 0.6;
}

.next-meal-modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.next-meal-modal-actions .diary-ai-btn {
  flex: 1;
}

.next-meal-history {
  margin-top: 4px;
}

.next-meal-history summary {
  color: rgba(255, 255, 255, 0.62);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  padding: 8px 0;
  list-style: none;
}

.next-meal-history summary::-webkit-details-marker {
  display: none;
}

.next-meal-history summary::before {
  content: '▸ ';
}

.next-meal-history[open] summary::before {
  content: '▾ ';
}

.next-meal-history .next-meal-suggestion-old {
  opacity: 0.7;
  margin-top: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

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

.next-meal-macro-row span {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  padding: 7px 10px;
  color: rgba(255, 255, 255, 0.86);
  font-size: 12px;
  font-weight: 800;
}

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

.analytics-metric-card {
  min-height: 118px;
  border-radius: 20px;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: inset 0 0 0 1px rgb(0 109 181 / 15%);
}

.analytics-metric-card span,
.analytics-metric-card b {
  color: #64748B;
  font-size: 12px;
  font-weight: 800;
}

.analytics-metric-card strong {
  color: #0F172A;
  font-size: 28px;
  line-height: 1;
}

.analytics-report-ready {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: 18px;
  background: #F0FDF4;
}

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

.section-heading-row span {
  font-size: 14px;
  color: grey;
}

.analytics-report-ready > span {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: #34D399;
  box-shadow: 0 0 0 6px rgba(52, 211, 153, 0.14);
}

.analytics-report-ready strong,
.analytics-report-ready small {
  display: block;
}

.analytics-report-ready small {
  color: #64748B;
  margin-top: 3px;
}

.analytics-chart-card {
  overflow: hidden;
}

.analytics-line-chart {
  border-radius: 24px;
  background: linear-gradient(180deg, #F8FBFF 0%, #FFFFFF 100%);
  padding: 10px 0 0;
  overflow: hidden;
}

.analytics-line-chart svg line {
  stroke: #E8EEF5;
  stroke-width: 1;
}

.analytics-line-chart .target-line {
  stroke: #CBD5E1;
  stroke-width: 3;
  stroke-dasharray: 6 6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.analytics-line-chart .kcal-line {
  stroke: #006DB5;
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 10px 10px rgba(0, 109, 181, 0.18));
}

.analytics-chart-legend {
  display: flex;
  gap: 14px;
  color: #64748B;
  font-size: 12px;
  font-weight: 800;
}

.analytics-chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.analytics-chart-legend i {
  width: 18px;
  height: 4px;
  border-radius: 999px;
}

.analytics-chart-legend .is-kcal {
  background: #006DB5;
}

.analytics-chart-legend .is-target {
  background: #CBD5E1;
}

.analytics-label-row {
  overflow-x: auto;
  padding-bottom: 2px;
}

.analytics-goal-bar {
  height: 18px;
  border-radius: 999px;
  background: #EEF2F7;
  overflow: hidden;
}

.analytics-goal-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #006DB5, #40B7FF);
}

.analytics-macro-bars {
  display: grid;
  gap: 16px;
}

.analytics-macro-bar {
  display: grid;
  gap: 8px;
}

.analytics-macro-bar > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.analytics-macro-bar strong {
  color: #111827;
}

.analytics-macro-bar span {
  color: #8E8E93;
  font-weight: 800;
}

.analytics-macro-bar b {
  height: 12px;
  border-radius: 999px;
  background: #F1F5F9;
  overflow: hidden;
}

.analytics-macro-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #0F172A;
}

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

.analytics-report-item {
  min-height: 68px;
  border-radius: 20px;
  background: #F8FAFC;
  color: #111827;
  text-decoration: none;
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.analytics-report-item strong,
.analytics-report-item span {
  display: block;
}

.analytics-report-item span {
  color: #8E8E93;
  font-size: 13px;
  font-weight: 800;
  margin-top: 4px;
}

.analytics-report-item b {
  min-width: 42px;
  height: 42px;
  border-radius: 16px;
  background: #E9F4FF;
  color: #006DB5;
  display: grid;
  place-items: center;
}

@media (max-width: 420px) {
  .analytics-summary-grid {
    grid-template-columns: 1fr;
  }

  .analytics-metric-card {
    min-height: 92px;
  }
  main.app-screen {
    padding-left: 28px;
    padding-right: 28px;
  }

  .diary-shell main.app-screen {
    padding-left: 16px;
    padding-right: 16px;
  }

  .diary-calorie-row {
    gap: 12px;
  }

  .diary-calorie-row strong {
    font-size: 44px;
  }

  .diary-calorie-meta {
    grid-template-columns: 1fr;
  }

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

  .diary-macro-ring {
    width: 70px;
    height: 70px;
  }

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

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

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

  body.app-shell:not(.diary-shell) 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));
  }

  .diary-shell {
    overflow: auto;
  }

  .diary-shell main.app-screen {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }

  .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;
  }
}

.meal-detail-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.meal-detail-delete-button {
  border: none;
  background: rgba(255, 255, 255, 0.8);
  color: #ef4444;
  cursor: pointer;
}

.notification-settings-card {
  margin-top: 16px;
}

.notification-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.notification-toggle-row:last-of-type {
  border-bottom: 0;
}

.notification-toggle-row strong {
  display: block;
  font-size: 14px;
  color: #0F172A;
}

.notification-toggle-row small {
  display: block;
  font-size: 12px;
  color: #64748B;
  margin-top: 2px;
}

.app-toggle-btn {
  position: relative;
  width: 48px;
  height: 28px;
  border-radius: 999px;
  border: 0;
  background: #CBD5E1;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s;
}

.app-toggle-btn span {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: #FFFFFF;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  transition: transform 0.2s;
}

.app-toggle-btn.is-active {
  background: #006DB5;
}

.app-toggle-btn.is-active span {
  transform: translateX(20px);
}

.app-toggle-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.settings-menu-card {
  gap: 0;
}

.settings-menu-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 4px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  text-decoration: none;
  color: inherit;
  transition: background 0.15s;
}

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

.settings-menu-item:active {
  background: rgba(0, 109, 181, 0.04);
}

.settings-menu-icon {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: linear-gradient(180deg, #F0F7FF 0%, #E8F2FF 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.settings-menu-icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: #006DB5;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.settings-menu-item div {
  flex: 1;
  min-width: 0;
}

.settings-menu-item strong {
  display: block;
  font-size: 14px;
  color: #0F172A;
}

.settings-menu-item small {
  display: block;
  font-size: 12px;
  color: #64748B;
  margin-top: 2px;
}

.settings-menu-arrow {
  font-size: 20px;
  color: #94A3B8;
  font-weight: 300;
}

.settings-logout-btn {
  color: #EF4444;
  border-color: #FEE2E2;
  text-align: center;
}

.test-notif-devices {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.test-notif-device {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #F8FAFC;
  cursor: pointer;
  transition: background 0.15s;
}

.test-notif-device:has(input:checked) {
  background: #EFF6FF;
  box-shadow: inset 0 0 0 1.5px #006DB5;
}

.test-notif-device input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #006DB5;
  flex-shrink: 0;
}

.test-notif-device strong {
  display: block;
  font-size: 14px;
  color: #0F172A;
}

.test-notif-device small {
  display: block;
  font-size: 12px;
  color: #64748B;
  margin-top: 2px;
}

.notification-prompt-panel p {
  margin: 0;
  color: #475569;
  line-height: 1.6;
}

.notification-prompt-checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
  color: #334155;
  font-size: 14px;
  font-weight: 600;
}

.notification-prompt-checkbox input {
  width: 16px;
  height: 16px;
  accent-color: #006DB5;
}

.should-eat-card {
  display: grid;
  gap: 12px;
}

.should-eat-subtitle {
  margin: 0;
  color: #64748B;
  font-size: 14px;
  line-height: 1.55;
}

.should-eat-form {
  display: grid;
  gap: 10px;
}

.should-eat-input {
  min-height: 96px;
}

.should-eat-image-picker {
  min-height: 120px;
  border-radius: 18px;
}

.should-eat-result-card {
  display: grid;
  gap: 10px;
  text-align: left;
}

.should-eat-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
}

.should-eat-badge.is-green {
  background: #DCFCE7;
  color: #166534;
}

.should-eat-badge.is-yellow {
  background: #FEF3C7;
  color: #92400E;
}

.should-eat-badge.is-red {
  background: #FEE2E2;
  color: #B91C1C;
}

.should-eat-result-card strong {
  font-size: 18px;
  color: #0F172A;
}

.should-eat-result-card p,
.should-eat-result-card ul,
.should-eat-result-card small,
.should-eat-result-card b {
  margin: 0;
  color: #334155;
  line-height: 1.55;
}

.should-eat-result-card ul {
  padding-left: 18px;
}

.should-eat-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.should-eat-tags span {
  border-radius: 999px;
  background: #EEF6FF;
  color: #006DB5;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 800;
}

.meal-card-pending {
  border: 1px solid #D6EFFF;
  background: linear-gradient(180deg, #F8FCFF 0%, #EEF6FF 100%);
}

.meal-pending-indicator,
.meal-failed-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  font-size: 12px;
  font-weight: 700;
}

.meal-pending-indicator {
  color: #006DB5;
}

.meal-pending-indicator i {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(0, 109, 181, 0.2);
  border-top-color: #006DB5;
  border-radius: 50%;
  animation: meal-pending-spin 0.8s linear infinite;
}

.meal-failed-indicator {
  color: #B91C1C;
}

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