.macro-page,
.macro-page *,
.macro-page *::before,
.macro-page *::after {
  box-sizing: border-box;
}

.macro-page {
  width: auto;
  max-width: calc(100vw - var(--sidebar-width));
  min-height: 100vh;
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow-x: hidden;
}

.macro-shell {
  width: 100%;
  max-width: 1480px;
  margin: 0 auto;
  padding: 0 20px 110px;
}

.macro-hero {
  padding: 12px 20px 0;
  margin: 0 0 28px;
}

.macro-hero h2 {
  margin: 0;
  font-size: clamp(34px, 4.8vw, 54px);
  line-height: 1.02;
  letter-spacing: -0.05em;
  color: #f6fbff;
}

.macro-hero p {
  margin: 10px 0 0;
  max-width: 760px;
  color: #92a7bc;
  font-size: 18px;
  line-height: 1.6;
}

.hero-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 18px;
}

.hero-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 999px;
  background: rgba(16, 29, 40, 0.78);
  border: 1px solid rgba(117, 195, 255, 0.14);
  color: #d9efff;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.01em;
  box-shadow: 0 18px 38px rgba(0, 0, 0, 0.18);
}

.hero-chip i {
  color: #70caff;
}

.macro-layout {
  display: grid;
  grid-template-columns: minmax(300px, 430px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.macro-main,
.macro-side {
  display: grid;
  gap: 24px;
  min-width: 0;
}

.macro-card,
.input-grid-2,
.input-grid-3,
.sources-grid,


.macro-card {
  background: linear-gradient(180deg, rgba(28, 40, 51, 0.98), rgba(22, 33, 43, 0.98));
  border: 1px solid rgba(92, 170, 226, 0.12);
  border-radius: 26px;
  box-shadow: 0 24px 54px rgba(0, 0, 0, 0.22);
}

.input-card,
.result-card,
.sources-card,
.distribution-card {
  padding: 28px;
}

.field-row {
  position: relative;
  padding-bottom: 24px;
}

.height-split-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: start;
}

.height-split-grid .field-row {
  position: relative;
  padding-bottom: 24px;
}

.field-row.fit-field .error-msg {
  position: static;
  left: auto;
  right: auto;
  bottom: auto;
  min-height: 18px;
  margin: 0;
}

.height-split-grid.fit-grid-2 {
  gap: 10px;
}

.height-split-grid.fit-grid-2 .field-row.fit-field {
  padding: 0;
}

.unit-toggle.fit-segmented,
.toggle-row.fit-segmented,
.input-shell.fit-control,
.select-shell.fit-control,
.custom-select.fit-control,
.custom-select.fit-control .custom-select-trigger {
  width: 100%;
  min-width: 0;
}

/* Error message absolute positioning */
.error-msg {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  font-size: 12px;
  line-height: 1.35;
  color: var(--danger);
  pointer-events: none;
}

/* Hide meal cards with hidden attribute */
.meal-card[hidden] {
  display: none !important;
}

.field-note {
  font-size: 12px;
  color: #78c8f5;
  font-style: italic;
}

/* ─── Unit Toggle ─── */
.unit-toggle {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 6px;
  background: rgba(16, 27, 39, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 18px;
}

.unit-btn {
  min-height: 50px;
  border: none;
  border-radius: 14px;
  background: transparent;
  color: #8ea2b7;
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
  transition: all 0.24s ease;
}

.unit-btn.active {
  background: linear-gradient(135deg, #63b7e8, #5a95d8);
  color: #07131d;
  box-shadow: 0 16px 30px rgba(90, 149, 216, 0.18);
}

.input-unit {
  position: static !important;
  right: auto !important;
  display: inline-flex !important;
  align-items: center;
  justify-content: flex-end;
  flex: 0 0 auto;
  min-width: 22px;
  color: #7d92a8;
  font-size: 14px;
  font-weight: 800;
  text-transform: lowercase;
  pointer-events: none;
}

.custom-select {
  position: relative;
  width: 100%;
  min-width: 0;
}

.premium-standard .macro-page .custom-select-trigger {
  min-height: auto;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

.custom-select.open .custom-select-options {
  max-height: 320px;
  opacity: 1;
  pointer-events: auto;
  display: block;
  gap: 0;
}

.custom-select-option.selected {
  background: rgba(95, 176, 228, 0.2);
  color: #6ec8f0;
  transform: none;
}

.primary-action,
.save-btn {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.primary-action {
  min-height: 72px;
  padding: 0 24px;
  border: none;
  border-radius: 20px;
  font-size: 20px;
  font-weight: 900;
  background: linear-gradient(135deg, #63b7e8, #5a9ade);
  color: #07131d;
  box-shadow: 0 22px 40px rgba(90, 154, 222, 0.25);
}

.primary-action:hover,
.save-btn:hover {
  transform: translateY(-1px);
}

.save-btn,
.secondary-action {
  margin-top: 18px;
  min-height: 54px;
  padding: 0 18px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: #d8edf9;
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.secondary-action {
  margin-top: 0;
  min-height: 58px;
  font-size: 18px;
}

.secondary-action:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.secondary-action:not(:disabled):hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.06);
}

.target-eyebrow {
  margin: 0 0 10px;
  color: #88a7c5;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.target-value-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 16px;
}

#res-calories {
  font-size: clamp(54px, 8vw, 92px);
  line-height: 0.9;
  font-weight: 1000;
  letter-spacing: -0.07em;
  color: #f5fbff;
}

.target-unit {
  margin-bottom: 10px;
  color: #81a2bf;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.target-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.target-badge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.05);
  color: #dbeeff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.insight-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.insight-item {
  min-height: 92px;
  padding: 16px;
  border-radius: 20px;
  background: rgba(11, 20, 29, 0.46);
  border: 1px solid rgba(255, 255, 255, 0.04);
  display: grid;
  gap: 8px;
  align-content: start;
}

.insight-item span {
  color: #87a0b8;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.insight-item strong {
  color: #f4fbff;
  font-size: 24px;
  line-height: 1.05;
  letter-spacing: -0.04em;
}

.macro-panel {
  padding: 18px;
  border-radius: 22px;
  background: rgba(11, 21, 32, 0.58);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.macro-title {
  margin: 0 0 14px;
  color: #eef7ff;
  font-size: 16px;
  font-weight: 900;
}

.macro-bar {
  display: flex;
  width: 100%;
  min-height: 16px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.macro-segment {
  height: 16px;
  transition: width 0.35s ease;
}

.macro-segment.protein {
  background: linear-gradient(90deg, #ff8d5c, #ff6d59);
}

.macro-segment.carb {
  background: linear-gradient(90deg, #6ac5ff, #5e8dff);
}

.macro-segment.fat {
  background: linear-gradient(90deg, #ffd876, #ffb84d);
}

.macro-legend {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.macro-pill {
  min-height: 70px;
  padding: 14px;
  border-radius: 18px;
  display: grid;
  gap: 6px;
  align-content: start;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.macro-pill span {
  font-size: 12px;
  font-weight: 800;
  color: #8aa4bb;
  letter-spacing: 0.02em;
}

.macro-pill strong {
  font-size: 22px;
  line-height: 1;
  letter-spacing: -0.04em;
  color: #f4fbff;
}

.macro-pill.protein strong {
  color: #ff9867;
}

.macro-pill.carb strong {
  color: #7ccfff;
}

.macro-pill.fat strong {
  color: #ffd47a;
}

.macro-copy {
  margin-top: 12px;
  color: #95abc0;
  font-size: 14px;
  line-height: 1.7;
}

.sources-card-title,
.distribution-title {
  margin: 0;
  color: #eef7ff;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.premium-standard .macro-page .sources-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.premium-standard .macro-page .distribution-grid.five-meals {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.premium-standard .macro-page .source-card {
  border-radius: 16px;
  overflow: hidden;
  background: rgba(17, 28, 40, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.06);
  min-height: 0;
  padding: 0;
  display: block;
}

.premium-standard .macro-page .source-thumb {
  height: 104px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 42px;
  width: 100%;
  border-radius: 0;
  background:
    radial-gradient(circle at 50% 28%, rgba(255, 255, 255, 0.2), transparent 36%),
    linear-gradient(135deg, rgba(110, 183, 240, 0.22), rgba(16, 25, 39, 0.92));
  box-shadow: none;
}

.premium-standard .macro-page .source-body {
  padding: 10px 12px 12px;
  display: grid;
  gap: 4px;
  min-width: 0;
}

.premium-standard .macro-page .source-body strong {
  color: #f4fbff;
  font-size: 14px;
  font-weight: 900;
}

.premium-standard .macro-page .source-body span {
  color: #7fbff1;
  font-size: 11px;
  line-height: 1.45;
}

.distribution-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.meal-chip {
  min-height: 40px;
  padding: 0 18px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: #8ea5bb;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
  transition: all 0.2s ease;
}

.meal-chip.active {
  background: linear-gradient(135deg, #79d6ff, #6d8eff);
  color: #07121a;
  box-shadow: 0 14px 26px rgba(95, 165, 255, 0.24);
}




.meal-card {
  min-height: 156px;
  padding: 18px;
  border-radius: 22px;
  background: rgba(11, 21, 32, 0.52);
  border: 1px solid rgba(255, 255, 255, 0.04);
  display: grid;
  gap: 10px;
  align-content: start;
}

.meal-card span {
  color: #8ea8c0;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.meal-card strong {
  color: #f3fbff;
  font-size: 26px;
  line-height: 1;
  letter-spacing: -0.05em;
}

.meal-card p {
  margin: 0;
  color: #98adc1;
  font-size: 13px;
  line-height: 1.6;
}

/* ─── Card Title (BMR Standard) ─── */
.card-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 22px;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #eef8ff;
}

/* ─── Height Split Grid (BMR Standard) ─── */
.height-split-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.height-split-grid[hidden] {
  display: none !important;
}

/* ─── Error Messages (BMR Standard) ─── */
.field-error {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  color: #ff835d;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.35;
}

.field-error i {
  flex: 0 0 auto;
  font-size: 12px;
}

.field-has-error .input-shell {
  border-color: rgba(236, 98, 98, 0.8);
  box-shadow: 0 0 0 1px rgba(236, 98, 98, 0.12);
}

/* ─── Form Actions ─── */
.form-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

@media (max-width: 1180px) {
  .macro-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 1023px) {
  .macro-page {
    width: 100%;
    max-width: 100%;
    margin-left: 0;
  }

  .macro-shell {
    padding: 0 16px 96px;
  }

  .macro-hero {
    padding: 8px 0 0;
    margin-bottom: 20px;
  }

  .macro-hero h2 {
    font-size: 38px;
  }

  .macro-hero p {
    font-size: 17px;
  }

  .input-card,
  .result-card,
  .sources-card,
  .distribution-card {
    padding: 22px;
  }

  .input-grid-3,
  .input-grid-2,



  .target-value-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .target-unit {
    margin-bottom: 0;
  }
}

@media (max-width: 420px) {
  .macro-shell {
    padding: 0 12px 92px;
  }

  .macro-hero h2 {
    font-size: 32px;
  }

  .macro-hero p {
    font-size: 16px;
  }

  .hero-chips {
    gap: 8px;
  }

  .custom-select-trigger {
    font-size: 14px;
  }

  .goal-option {
    min-height: 54px;
    font-size: 14px;
  }

  .sources-grid,

  .meal-card {
    min-height: auto;
  }
}

@media (max-width: 1179px) {
  .premium-standard .macro-page {
    width: 100%;
    max-width: 100%;
    margin-left: 0;
  }

  .premium-standard .macro-page .page-header {
    padding: 16px 16px 12px;
    gap: 12px;
    margin: 0 0 12px;
  }


  .premium-standard .macro-page .macro-shell {
    padding: 0 16px 96px;
  }

  .premium-standard .macro-page .macro-hero {
    padding: 8px 0 0;
    margin-bottom: 20px;
  }

  .premium-standard .macro-page .macro-hero h2 {
    font-size: 38px;
  }

  .premium-standard .macro-page .macro-hero p {
    font-size: 17px;
  }

  .premium-standard .macro-page .macro-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .premium-standard .macro-page .input-card,
  .premium-standard .macro-page .result-card,
  .premium-standard .macro-page .sources-card,
  .premium-standard .macro-page .distribution-card {
    padding: 22px;
  }

  .premium-standard .macro-page .input-grid-2,
  .premium-standard .macro-page .input-grid-3,
  .premium-standard .macro-page .insight-grid,
  .premium-standard .macro-page .macro-legend {
    grid-template-columns: 1fr;
  }

  .premium-standard .macro-page .height-split-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .premium-standard .macro-page .distribution-head {
    flex-direction: column;
    align-items: stretch;
  }

  .premium-standard .macro-page .premium-standard .macro-page .distribution-grid,
  .premium-standard .macro-page .sources-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .premium-standard .macro-page .form-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .premium-standard .macro-page .form-actions .primary-action,
  .premium-standard .macro-page .form-actions .secondary-action,
  .premium-standard .macro-page .form-actions button {
    width: 100%;
    min-width: 0;
    justify-content: center;
  }

  .premium-standard .macro-page .custom-select-trigger span,
  .premium-standard .macro-page .goal-option {
    white-space: normal;
    line-height: 1.35;
  }

  .premium-standard .macro-page .target-value-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .premium-standard .macro-page .target-unit {
    margin-bottom: 0;
  }
}

@media (max-width: 640px) {
  .premium-standard .macro-page .macro-shell {
    padding: 0 14px 92px;
  }

  .premium-standard .macro-page .page-header {
    padding: 14px 14px 10px;
  }

  .premium-standard .macro-page .macro-hero h2 {
    font-size: 32px;
  }

  .premium-standard .macro-page .macro-hero p {
    font-size: 16px;
  }

  .premium-standard .macro-page .input-card,
  .premium-standard .macro-page .result-card,
  .premium-standard .macro-page .sources-card,
  .premium-standard .macro-page .distribution-card {
    padding: 20px;
  }

  .premium-standard .macro-page .hero-chips {
    gap: 8px;
  }

  .premium-standard .macro-page .hero-chip {
    width: 100%;
    justify-content: center;
  }

  .premium-standard .macro-page .toggle-chip,
  .premium-standard .macro-page .unit-btn {
    font-size: 16px;
    min-height: 52px;
  }

  .premium-standard .macro-page .input-shell,
  .premium-standard .macro-page .select-shell {
    min-height: 60px;
    padding: 0 14px;
  }

  .premium-standard .macro-page .input-shell input {
    font-size: 26px;
  }

  .premium-standard .macro-page .custom-select-trigger {
    font-size: 14px;
  }

  .premium-standard .macro-page .input-grid-2,
  .premium-standard .macro-page .input-grid-3,
  .premium-standard .macro-page .distribution-grid,
  .premium-standard .macro-page .insight-grid,
  .premium-standard .macro-page .macro-legend {
    grid-template-columns: 1fr;
  }

  .premium-standard .macro-page .height-split-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .premium-standard .macro-page .sources-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .premium-standard .macro-page .target-badges {
    gap: 8px;
  }

  .premium-standard .macro-page .meal-card {
    min-height: auto;
  }

  .premium-standard .macro-page .source-card {
    min-height: 0;
    padding: 0;
  }
}

@media (max-width: 420px) {
  .premium-standard .macro-page .macro-shell {
    padding: 0 12px 88px;
  }

  .premium-standard .macro-page .page-header {
    padding: 14px 12px 10px;
  }

  .premium-standard .macro-page .macro-hero h2 {
    font-size: 29px;
  }

  .premium-standard .macro-page .macro-hero p {
    font-size: 15px;
  }

  .premium-standard .macro-page .sources-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .premium-standard .macro-page .distribution-grid.five-meals {
    grid-template-columns: 1fr;
  }
}

.embed-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(5, 10, 18, .72);
  z-index: 9999
}

.embed-modal.is-open {
  display: flex
}

.embed-dialog {
  width: min(720px, 100%);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .35);
  overflow: hidden
}

.embed-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, .06)
}

.embed-dialog-head h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 900;
  color: #eef8ff
}

.embed-dialog-close {
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, .06);
  color: #dcefff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center
}

.embed-dialog-body {
  padding: 22px 24px 24px;
  display: grid;
  gap: 16px
}

.embed-dialog-body p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.7
}

.embed-code-box {
  width: 100%;
  min-height: 220px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, .08);
  background: rgba(7, 14, 22, .92);
  color: #eef8ff;
  padding: 16px;
  font: 13px/1.6 Consolas, "Courier New", monospace;
  resize: vertical
}

.embed-dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap
}

.embed-copy-btn {
  min-height: 48px;
  padding: 0 18px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, #63b7e8, #4f94f2);
  color: #07131d;
  font-size: 14px;
  font-weight: 900;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 10px
}

.embed-copy-status {
  font-size: 13px;
  color: var(--text-secondary)
}