:root {
  --page: #f8f5ff;
  --page-deep: #f0eaff;
  --card: rgba(255, 255, 255, 0.88);
  --card-solid: #ffffff;
  --purple-900: #4d416f;
  --purple-800: #5e4f87;
  --purple-700: #6e5da0;
  --purple-600: #8872c5;
  --purple-500: #a28adf;
  --purple-300: #cfbef5;
  --purple-200: #e2d8fb;
  --purple-100: #f0eaff;
  --ink: #39334a;
  --muted: #7c748f;
  --line: rgba(112, 91, 159, 0.14);
  --shadow: 0 24px 70px rgba(85, 66, 132, 0.18);
  --font: Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

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

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: var(--font);
  background:
    radial-gradient(circle at 16% 10%, rgba(220, 203, 255, 0.72), transparent 30%),
    radial-gradient(circle at 85% 82%, rgba(205, 225, 255, 0.55), transparent 34%),
    linear-gradient(145deg, var(--page), #fbfaff 52%, var(--page-deep));
  overflow-x: hidden;
}

button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.ambient {
  position: fixed;
  z-index: 0;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  filter: blur(4px);
  opacity: 0.45;
  pointer-events: none;
}
.ambient-one { top: -120px; left: -80px; background: #d9c8ff; }
.ambient-two { right: -130px; bottom: -130px; background: #cfdefd; }

.sparkles { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.sparkles i {
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(143, 120, 207, 0.38);
  box-shadow: 0 0 12px rgba(143, 120, 207, 0.35);
  animation: twinkle 4s ease-in-out infinite;
}
.sparkles i:nth-child(1) { top: 13%; left: 10%; }
.sparkles i:nth-child(2) { top: 24%; right: 14%; animation-delay: .7s; }
.sparkles i:nth-child(3) { top: 68%; left: 12%; animation-delay: 1.4s; }
.sparkles i:nth-child(4) { top: 82%; right: 18%; animation-delay: 2.1s; }
.sparkles i:nth-child(5) { top: 43%; left: 4%; animation-delay: 2.8s; }
.sparkles i:nth-child(6) { top: 52%; right: 5%; animation-delay: 3.4s; }

.page-shell {
  position: relative;
  z-index: 1;
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 34px 18px;
}

.meal-widget {
  width: min(100%, 720px);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 38px;
  padding: 28px;
  background: var(--card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
}

.hero {
  display: grid;
  grid-template-columns: 76px 1fr 44px;
  gap: 18px;
  align-items: center;
}

.brand-mark {
  display: grid;
  width: 76px;
  height: 76px;
  place-items: center;
  border-radius: 26px;
  background: linear-gradient(145deg, #f2ecff, #e1d5fb);
  box-shadow: inset 0 0 0 1px rgba(112, 91, 159, 0.08), 0 12px 28px rgba(111, 88, 166, 0.16);
}
.brand-mark svg { width: 68px; transform: translateY(2px); }

.eyebrow {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 5px;
  color: var(--purple-700);
  font-size: .82rem;
  font-weight: 700;
  letter-spacing: .02em;
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9bd5b5;
  box-shadow: 0 0 0 4px rgba(155, 213, 181, 0.18);
}
.hero h1 { margin: 0; color: var(--purple-900); font-size: clamp(1.6rem, 4.8vw, 2.25rem); letter-spacing: -.04em; }
.subtitle { margin: 7px 0 0; color: var(--muted); font-size: .92rem; }

.refresh-button, .round-button {
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  color: var(--purple-700);
  background: rgba(255,255,255,.76);
  cursor: pointer;
  transition: transform .2s ease, background .2s ease, box-shadow .2s ease;
}
.refresh-button { width: 44px; height: 44px; border-radius: 16px; }
.round-button { width: 44px; height: 44px; border-radius: 50%; }
.refresh-button:hover, .round-button:hover { transform: translateY(-2px); background: white; box-shadow: 0 8px 20px rgba(94,79,135,.12); }
.refresh-button:active, .round-button:active { transform: translateY(0) scale(.96); }
.refresh-button svg, .round-button svg { width: 21px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.refresh-button.is-spinning svg { animation: spin .75s linear infinite; }

.date-toolbar {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  gap: 12px;
  align-items: center;
  margin-top: 28px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(242, 237, 255, .72);
}
.date-display { border: 0; color: var(--ink); background: transparent; cursor: pointer; }
.date-display span { display: block; }
#dateHeadline { color: var(--purple-900); font-size: 1.08rem; font-weight: 800; letter-spacing: -.02em; }
#dateSubline { margin-top: 3px; color: var(--muted); font-size: .78rem; }

.week-strip {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 7px;
  margin-top: 16px;
}
.day-button {
  min-width: 0;
  border: 1px solid transparent;
  border-radius: 18px;
  padding: 10px 4px 9px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  transition: transform .18s ease, color .18s ease, background .18s ease, border-color .18s ease;
}
.day-button:hover { transform: translateY(-2px); color: var(--purple-800); background: rgba(239,233,255,.78); }
.day-button .weekday { display: block; font-size: .72rem; font-weight: 600; }
.day-button .day-number { display: grid; width: 32px; height: 32px; margin: 5px auto 0; place-items: center; border-radius: 12px; font-size: .88rem; font-weight: 800; }
.day-button.has-meal::after { content: ""; display: block; width: 4px; height: 4px; margin: 5px auto 0; border-radius: 50%; background: var(--purple-400, #b29be8); }
.day-button.is-selected { color: white; background: linear-gradient(145deg, #a991e2, #806ac0); box-shadow: 0 10px 24px rgba(105, 82, 164, .22); }
.day-button.is-selected .day-number { background: rgba(255,255,255,.15); }
.day-button.is-selected::after { background: white; }
.day-button.is-sunday:not(.is-selected) { color: #bc7c94; }
.day-button.is-saturday:not(.is-selected) { color: #7487bd; }

.content-card {
  min-height: 330px;
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 30px;
  padding: 26px;
  background: var(--card-solid);
  box-shadow: 0 16px 42px rgba(72, 57, 110, .09);
}

.section-heading { display: flex; justify-content: space-between; gap: 16px; align-items: flex-end; }
.meal-label { display: inline-flex; align-items: center; min-height: 26px; padding: 0 10px; border-radius: 999px; color: var(--purple-700); background: var(--purple-100); font-size: .74rem; font-weight: 800; }
.section-heading h2, .empty-state h2, .error-state h2 { margin: 8px 0 0; color: var(--purple-900); font-size: 1.38rem; letter-spacing: -.03em; }
.calorie-chip { flex: 0 0 auto; border-radius: 999px; padding: 7px 11px; color: #7a678e; background: #f7f1fb; font-size: .75rem; font-weight: 700; }

.menu-list { display: grid; gap: 10px; margin: 22px 0 0; padding: 0; list-style: none; }
.menu-item {
  display: grid;
  grid-template-columns: 42px minmax(0,1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 60px;
  border: 1px solid rgba(112, 91, 159, .1);
  border-radius: 20px;
  padding: 9px 14px 9px 10px;
  background: linear-gradient(135deg, #fcfbff, #f7f3ff);
  animation: rise .42s both;
}
.menu-icon { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 15px; background: white; box-shadow: 0 6px 18px rgba(89, 67, 137, .09); font-size: 1.28rem; }
.menu-name { min-width: 0; color: #473e58; font-size: .98rem; font-weight: 700; word-break: keep-all; }
.allergen-badges { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; }
.allergen-badge { display: grid; min-width: 22px; height: 22px; place-items: center; border-radius: 8px; color: #826ea6; background: #eee7fb; font-size: .66rem; font-weight: 700; }

.allergy-note { margin-top: 18px; border-top: 1px dashed var(--line); padding-top: 15px; color: var(--muted); }
.allergy-note summary { width: fit-content; color: var(--purple-700); cursor: pointer; font-size: .78rem; font-weight: 700; }
.allergy-note p { margin: 10px 0 0; font-size: .72rem; line-height: 1.75; }

.loading-state, .empty-state, .error-state { display: grid; min-height: 275px; place-items: center; align-content: center; text-align: center; }
.loading-state p, .empty-state p, .error-state p { max-width: 420px; margin: 11px auto 0; color: var(--muted); font-size: .9rem; line-height: 1.6; word-break: keep-all; }
.bowl-loader { position: relative; display: flex; justify-content: center; gap: 5px; width: 74px; height: 64px; border-radius: 0 0 38px 38px; border-bottom: 10px solid var(--purple-300); }
.bowl-loader::after { content: ""; position: absolute; bottom: -14px; width: 62px; height: 6px; border-radius: 50%; background: rgba(91,73,137,.09); }
.bowl-loader span { width: 5px; height: 25px; border-radius: 999px; background: var(--purple-300); animation: steam 1.5s ease-in-out infinite; }
.bowl-loader span:nth-child(2) { animation-delay: .22s; }
.bowl-loader span:nth-child(3) { animation-delay: .44s; }
.empty-illustration { font-size: 3rem; filter: drop-shadow(0 8px 12px rgba(97,75,145,.13)); }

.primary-button {
  margin-top: 18px;
  border: 0;
  border-radius: 14px;
  padding: 11px 18px;
  color: white;
  background: linear-gradient(135deg, #a58ee1, #826cc3);
  box-shadow: 0 9px 22px rgba(105,82,164,.2);
  cursor: pointer;
  font-weight: 700;
}

.widget-footer { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 16px; color: var(--muted); font-size: .72rem; }
.widget-footer > div { display: flex; align-items: center; gap: 7px; }
.source-badge { border-radius: 999px; padding: 5px 8px; color: var(--purple-700); background: var(--purple-100); font-weight: 700; }
.widget-footer button { border: 0; color: var(--purple-700); background: transparent; cursor: pointer; font-weight: 700; }

.hidden { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@keyframes twinkle { 0%, 100% { transform: scale(.7); opacity: .25; } 50% { transform: scale(1.3); opacity: .8; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes steam { 0%, 100% { transform: translateY(10px) scaleY(.55); opacity: 0; } 40% { opacity: .85; } 70% { transform: translateY(-6px) scaleY(1); opacity: 0; } }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

@media (max-width: 620px) {
  .page-shell { place-items: start center; padding: 14px 10px; }
  .meal-widget { border-radius: 28px; padding: 18px 14px; }
  .hero { grid-template-columns: 62px 1fr 40px; gap: 12px; }
  .brand-mark { width: 62px; height: 62px; border-radius: 21px; }
  .brand-mark svg { width: 57px; }
  .subtitle { display: none; }
  .refresh-button { width: 40px; height: 40px; border-radius: 14px; }
  .date-toolbar { margin-top: 20px; padding: 9px; border-radius: 20px; }
  .round-button { width: 40px; height: 40px; }
  .week-strip { gap: 2px; }
  .day-button { border-radius: 15px; padding-inline: 1px; }
  .day-button .day-number { width: 29px; height: 29px; }
  .content-card { min-height: 315px; border-radius: 25px; padding: 20px 15px; }
  .menu-item { grid-template-columns: 39px minmax(0,1fr); padding-right: 10px; }
  .menu-icon { width: 39px; height: 39px; }
  .allergen-badges { grid-column: 2; justify-content: flex-start; }
  .widget-footer { padding: 0 3px; }
  .widget-footer > div > span:last-child { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
