:root {
  --bg-deep: #0f1221;
  --bg-card: rgba(28, 32, 55, 0.72);
  --border: rgba(255, 255, 255, 0.1);
  --text: #eef0f7;
  --text-muted: #9aa3c2;
  --accent: #7c6cf5;
  --accent-2: #4fd1c5;
  --warm: #f6ad55;
  --danger: #fc8181;
  --success: #68d391;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  --radius: 18px;
  --font: "Noto Sans SC", "DM Sans", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg-deep);
  line-height: 1.55;
}

.bg-gradient {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(ellipse 80% 60% at 20% 10%, rgba(124, 108, 245, 0.35), transparent),
    radial-gradient(ellipse 60% 50% at 85% 70%, rgba(79, 209, 197, 0.2), transparent),
    radial-gradient(circle at 50% 100%, rgba(246, 173, 85, 0.12), transparent 45%),
    var(--bg-deep);
}

.floating-shapes {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.5;
  background-image:
    radial-gradient(circle at 10% 40%, rgba(255, 255, 255, 0.04) 0 2px, transparent 3px),
    radial-gradient(circle at 70% 20%, rgba(255, 255, 255, 0.03) 0 1.5px, transparent 2.5px);
  background-size: 100px 100px, 140px 140px;
}

.site-header {
  max-width: 720px;
  margin: 0 auto;
  padding: 3rem 1.25rem 1.5rem;
  text-align: center;
}

.title {
  margin: 0;
  font-size: clamp(1.65rem, 5vw, 2.35rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.title-accent {
  background: linear-gradient(120deg, var(--accent-2), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.subtitle {
  margin: 1rem 0 0;
  color: var(--text-muted);
  font-size: 0.95rem;
  max-width: 36em;
  margin-left: auto;
  margin-right: auto;
}

.main {
  max-width: 840px;
  margin: 0 auto;
  padding: 0 1.25rem 3rem;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.35rem 1.35rem 1.5rem;
  margin-bottom: 1.25rem;
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

.section-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 1rem;
  font-size: 1.15rem;
  font-weight: 600;
}

.section-icon {
  font-size: 1.35rem;
  line-height: 1;
}

.profile-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.field-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(15, 18, 33, 0.65);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
}

.input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.chip-row {
  display: flex;
  gap: 0.5rem;
}

.chip {
  flex: 1;
  padding: 0.55rem 0.75rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(15, 18, 33, 0.5);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, background 0.15s;
}

.chip:hover {
  border-color: rgba(124, 108, 245, 0.5);
}

.chip.is-selected {
  background: linear-gradient(135deg, rgba(124, 108, 245, 0.35), rgba(79, 209, 197, 0.2));
  border-color: var(--accent);
  font-weight: 600;
}

.hint {
  margin: 0 0 1rem;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.hint-strong {
  color: var(--accent-2);
  font-weight: 600;
}

.meal-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.meal-tab {
  padding: 0.5rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(15, 18, 33, 0.45);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
}

.meal-tab:hover {
  color: var(--text);
  border-color: rgba(124, 108, 245, 0.4);
}

.meal-tab.is-active {
  color: var(--text);
  background: linear-gradient(135deg, rgba(124, 108, 245, 0.45), rgba(79, 209, 197, 0.25));
  border-color: rgba(124, 108, 245, 0.6);
  font-weight: 600;
}

.meal-panel {
  display: none;
}

.meal-panel.is-visible {
  display: block;
}

.food-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 0.65rem;
}

.food-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 0.85rem 0.45rem 0.65rem;
  border-radius: 16px;
  border: 2px solid var(--border);
  background: rgba(15, 18, 33, 0.55);
  cursor: pointer;
  transition: transform 0.18s, box-shadow 0.18s, border-color 0.18s, background 0.18s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.food-card:hover {
  transform: translateY(-2px);
  border-color: rgba(124, 108, 245, 0.35);
}

.food-card.is-active {
  border-color: var(--accent-2);
  background: linear-gradient(160deg, rgba(79, 209, 197, 0.18), rgba(124, 108, 245, 0.12));
  box-shadow: 0 8px 28px rgba(79, 209, 197, 0.15);
}

.food-card .icon {
  font-size: 2.1rem;
  line-height: 1.1;
  margin-bottom: 0.35rem;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.25));
}

.food-card .name {
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.25;
  margin: 0 0 0.2rem;
}

.food-card .unit-cal {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin: 0;
}

.food-card .count-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  min-width: 1.45rem;
  height: 1.45rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  display: none;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.food-card.is-active .count-badge {
  display: flex;
}

.food-card .btn-less {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 1.45rem;
  height: 1.45rem;
  border-radius: 999px;
  border: none;
  background: rgba(252, 129, 129, 0.35);
  color: #fff;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s;
}

.food-card.is-active .btn-less {
  display: flex;
}

.food-card .btn-less:hover {
  background: rgba(252, 129, 129, 0.65);
}

.field-steps {
  margin-bottom: 1.25rem;
}

.steps-readout {
  color: var(--accent-2);
  font-weight: 700;
}

.range {
  width: 100%;
  margin-top: 0.5rem;
  accent-color: var(--accent);
  height: 6px;
}

.subheading {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0 0 0.75rem;
}

.exercise-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  gap: 0.65rem;
}

.cta-wrap {
  text-align: center;
  margin: 1.75rem 0;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.95rem 2.25rem;
  font-size: 1.05rem;
  font-weight: 600;
  font-family: inherit;
  color: #0f1221;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  background: linear-gradient(120deg, var(--accent-2), var(--accent));
  box-shadow: 0 12px 32px rgba(124, 108, 245, 0.35);
  transition: transform 0.15s, box-shadow 0.15s;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 40px rgba(124, 108, 245, 0.45);
}

.btn-primary:active {
  transform: translateY(0);
}

.site-footer {
  text-align: center;
  padding: 0 1.25rem 2rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  opacity: 0.85;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(8, 10, 20, 0.72);
  backdrop-filter: blur(8px);
}

.modal-overlay[hidden] {
  display: none;
}

.modal {
  width: 100%;
  max-width: 400px;
  padding: 2rem 1.5rem 1.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: linear-gradient(165deg, rgba(36, 40, 68, 0.98), rgba(22, 25, 45, 0.98));
  box-shadow: var(--shadow);
  text-align: center;
  animation: popIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(12px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-emoji {
  font-size: 3rem;
  line-height: 1;
  margin-bottom: 0.5rem;
}

.modal-title {
  margin: 0 0 0.65rem;
  font-size: 1.35rem;
}

.modal-body {
  margin: 0 0 1rem;
  font-size: 1rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.modal-body strong {
  color: var(--text);
}

.modal-stats {
  text-align: left;
  font-size: 0.85rem;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.2);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  margin-bottom: 1.25rem;
  line-height: 1.65;
}

.modal-stats .row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.modal-stats .val {
  color: var(--accent-2);
  font-weight: 600;
}

.text-surplus {
  color: var(--warm) !important;
}

.text-deficit {
  color: var(--success) !important;
}

.btn-close {
  width: 100%;
  padding: 0.75rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(124, 108, 245, 0.25);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-close:hover {
  background: rgba(124, 108, 245, 0.4);
}

@media (min-width: 600px) {
  .food-grid {
    grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  }
}
