*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --red:     #DC2626;
  --red-dim: #991B1B;
  --yellow:  #F5C518;
  --black:   #0D0D0D;
  --dark1:   #111111;
  --dark2:   #181818;
  --dark3:   #222222;
  --dark4:   #2E2E2E;
  --white:   #F0F0F0;
  --gray1:   #999999;
  --gray2:   #555555;
  --font-en: 'Barlow Condensed', sans-serif;
  --font-ar: 'Tajawal', sans-serif;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-ar);
  background: var(--black);
  color: var(--white);
  min-height: 100vh;
  direction: rtl;
  overflow-x: hidden;
  position: relative;
}

/* ── NOISE TEXTURE ── */
.noise {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 0;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 200px 200px;
}

/* ── PROGRESS BAR ── */
.progress-track {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--dark3);
  z-index: 100;
}

.progress-fill {
  height: 100%;
  background: var(--red);
  width: 0%;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── HEADER ── */
.header {
  position: relative;
  z-index: 10;
  padding: 28px 32px 24px;
  border-bottom: 1px solid var(--dark3);
}

.header-inner {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: block;
  width: 10px;
  height: 10px;
  background: var(--red);
  border-radius: 50%;
  box-shadow: 0 0 12px var(--red);
}

.brand-name {
  font-family: var(--font-en);
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--white);
  display: flex;
  flex-direction: column;
  line-height: 1;
  gap: 3px;
}

.brand-ar {
  font-family: var(--font-ar);
  font-size: 0.7rem;
  font-weight: 400;
  letter-spacing: 0;
  color: var(--gray1);
}

.step-counter {
  font-family: var(--font-en);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--gray2);
}

/* ── MAIN ── */
.main {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 32px 80px;
}

/* ── STEPS ── */
.step {
  display: none;
  padding-top: 64px;
  animation: stepIn 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.step.active { display: block; }

@keyframes stepIn {
  from {
    opacity: 0;
    transform: translateX(24px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.step-label {
  font-family: var(--font-en);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--red);
  text-transform: uppercase;
  margin-bottom: 16px;
}

.step-heading {
  font-family: var(--font-ar);
  font-size: clamp(2.4rem, 7vw, 4rem);
  font-weight: 900;
  line-height: 1.05;
  color: var(--white);
  margin-bottom: 52px;
}

.dot { color: var(--red); }

/* ── UNDERLINE INPUT ── */
.input-wrap {
  position: relative;
  margin-bottom: 12px;
}

.underline-input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-en);
  font-size: clamp(3.5rem, 14vw, 7rem);
  font-weight: 900;
  color: var(--white);
  padding: 0 0 16px 0;
  direction: ltr;
  text-align: right;
  -moz-appearance: textfield;
}

.underline-input::-webkit-outer-spin-button,
.underline-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
}

.underline-input::placeholder {
  color: var(--dark4);
}

.underline-label {
  position: absolute;
  bottom: 20px;
  left: 0;
  font-family: var(--font-ar);
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--gray2);
  pointer-events: none;
}

.underline-bar {
  height: 1px;
  background: var(--dark3);
  position: relative;
  overflow: hidden;
}

.underline-progress {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: 0%;
  background: var(--red);
  transition: width 0.3s ease;
}

.underline-input:focus ~ .underline-label { color: var(--gray1); }
.underline-input:focus ~ .underline-bar .underline-progress { width: 100%; }

.input-sub {
  font-size: 0.82rem;
  color: var(--gray2);
  font-weight: 300;
  margin-bottom: 44px;
  margin-top: 10px;
}

/* ── BUTTONS ── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  background: var(--red);
  color: var(--white);
  border: none;
  font-family: var(--font-ar);
  font-size: 1rem;
  font-weight: 700;
  padding: 16px 32px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: background 0.2s, transform 0.15s;
  clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 12px 100%, 0 calc(100% - 12px));
}

.btn-primary:hover {
  background: var(--red-dim);
  transform: translateY(-2px);
}

.btn-primary:active { transform: translateY(0); }

.btn-arrow {
  font-size: 1.1rem;
  line-height: 1;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--dark3);
  color: var(--gray1);
  font-family: var(--font-ar);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 14px 28px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

.btn-ghost:hover {
  border-color: var(--gray2);
  color: var(--white);
}

.nav-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 40px;
  flex-direction: row-reverse;
}

/* ── GOAL GRID ── */
.goal-grid {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.goal-btn {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  grid-template-rows: auto auto;
  align-items: center;
  gap: 0 20px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--dark3);
  padding: 22px 0;
  cursor: pointer;
  text-align: right;
  color: var(--white);
  transition: padding-right 0.2s, background 0.2s;
  position: relative;
}

.goal-btn::before {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 0;
  background: var(--red);
  opacity: 0.06;
  transition: width 0.3s;
}

.goal-btn:hover::before,
.goal-btn.selected::before {
  width: 100%;
}

.goal-btn:hover { padding-right: 12px; }
.goal-btn.selected { padding-right: 12px; border-color: var(--red); }

.goal-tag {
  font-family: var(--font-en);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--gray2);
  grid-row: 1 / 3;
  transition: color 0.2s;
}

.goal-btn.selected .goal-tag { color: var(--red); }

.goal-name {
  font-family: var(--font-ar);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--white);
  grid-column: 2;
  grid-row: 1;
}

.goal-desc {
  font-family: var(--font-ar);
  font-size: 0.8rem;
  font-weight: 300;
  color: var(--gray1);
  grid-column: 2;
  grid-row: 2;
  margin-top: 4px;
}

.goal-ratio {
  font-family: var(--font-en);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--gray2);
  grid-row: 1 / 3;
  white-space: nowrap;
  transition: color 0.2s;
}

.goal-btn.selected .goal-ratio { color: var(--yellow); }

/* ── ACTIVITY GRID ── */
.activity-grid {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.act-btn {
  display: flex;
  align-items: center;
  gap: 20px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--dark3);
  padding: 18px 0;
  cursor: pointer;
  text-align: right;
  color: var(--white);
  transition: padding-right 0.2s, background 0.2s;
  position: relative;
}

.act-btn::before {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 0;
  background: var(--red);
  opacity: 0.06;
  transition: width 0.3s;
}

.act-btn:hover::before,
.act-btn.selected::before { width: 100%; }
.act-btn:hover { padding-right: 12px; }
.act-btn.selected { padding-right: 12px; border-color: var(--red); }

.act-tag {
  font-family: var(--font-en);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--gray2);
  min-width: 24px;
  transition: color 0.2s;
}

.act-btn.selected .act-tag { color: var(--red); }

.act-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
}

.act-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--white);
}

.act-desc {
  font-size: 0.78rem;
  font-weight: 300;
  color: var(--gray1);
}

.act-mult {
  font-family: var(--font-en);
  font-size: 1rem;
  font-weight: 800;
  color: var(--gray2);
  letter-spacing: 1px;
  transition: color 0.2s;
}

.act-btn.selected .act-mult { color: var(--yellow); }

/* ── RESULTS ── */
.result-top {
  padding-top: 64px;
  margin-bottom: 48px;
}

.result-label {
  font-family: var(--font-en);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--red);
  text-transform: uppercase;
  display: block;
  margin-bottom: 20px;
}

.result-big {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 16px;
  line-height: 1;
}

.result-num {
  font-family: var(--font-en);
  font-size: clamp(5rem, 18vw, 9rem);
  font-weight: 900;
  color: var(--white);
  letter-spacing: -2px;
  line-height: 0.9;
}

.result-unit {
  font-family: var(--font-ar);
  font-size: 1.1rem;
  font-weight: 400;
  color: var(--gray1);
  padding-bottom: 14px;
}

.result-range-line {
  font-size: 0.85rem;
  font-weight: 300;
  color: var(--gray1);
}

.result-range-line strong {
  color: var(--yellow);
  font-weight: 700;
}

/* ── BAR ── */
.result-bar-wrap {
  margin-bottom: 48px;
}

.result-bar-track {
  height: 4px;
  background: var(--dark3);
  position: relative;
  margin-bottom: 10px;
}

.result-bar-fill {
  position: absolute;
  right: 0;
  top: 0;
  height: 100%;
  background: var(--red);
  width: 0%;
  transition: width 1.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.result-bar-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--gray2);
  font-weight: 400;
}

/* ── DIVIDER ── */
.divider {
  height: 1px;
  background: var(--dark3);
  margin: 44px 0;
}

/* ── SECTIONS ── */
.section-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.section-num {
  font-family: var(--font-en);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--red);
}

.section-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--white);
}

/* ── MEALS ── */
.meals-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 2px;
}

.meal-item {
  background: var(--dark2);
  border-right: 2px solid var(--red);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.meal-label {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--gray1);
}

.meal-g {
  font-family: var(--font-en);
  font-size: 2.4rem;
  font-weight: 900;
  color: var(--yellow);
  line-height: 1;
}

.meal-unit {
  font-size: 0.72rem;
  color: var(--gray2);
}

/* ── FOODS TABLE ── */
.foods-table {
  display: flex;
  flex-direction: column;
}

.food-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  border-bottom: 1px solid var(--dark3);
}

.food-row:first-child { border-top: 1px solid var(--dark3); }

.food-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.food-name {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--white);
}

.food-qty {
  font-size: 0.75rem;
  font-weight: 300;
  color: var(--gray1);
}

.food-prot {
  font-family: var(--font-en);
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--white);
  letter-spacing: -0.5px;
}

.food-prot-unit {
  font-family: var(--font-ar);
  font-size: 0.72rem;
  color: var(--gray2);
  font-weight: 300;
}

/* ── TIPS ── */
.tips-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.tip-row {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.tip-line {
  width: 2px;
  height: 40px;
  background: var(--dark4);
  flex-shrink: 0;
  margin-top: 4px;
}

.tip-line.active { background: var(--red); }

.tip-text {
  font-size: 0.88rem;
  font-weight: 300;
  color: var(--gray1);
  line-height: 1.7;
  padding-top: 2px;
}

/* ── RESET ── */
.btn-reset {
  margin-top: 52px;
  width: 100%;
  background: transparent;
  border: 1px solid var(--dark4);
  color: var(--gray1);
  font-family: var(--font-ar);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 16px;
  cursor: pointer;
  letter-spacing: 1px;
  transition: border-color 0.2s, color 0.2s;
}

.btn-reset:hover {
  border-color: var(--white);
  color: var(--white);
}

.disclaimer {
  text-align: center;
  font-size: 0.72rem;
  font-weight: 300;
  color: var(--gray2);
  margin-top: 24px;
  letter-spacing: 0.5px;
}

/* ── ERROR SHAKE ── */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-6px); }
  40%       { transform: translateX(6px); }
  60%       { transform: translateX(-4px); }
  80%       { transform: translateX(4px); }
}

.shake { animation: shake 0.35s ease; }

/* ── RESPONSIVE ── */
@media (max-width: 520px) {
  .header { padding: 20px 20px 16px; }
  .main   { padding: 0 20px 60px; }

  .goal-btn {
    grid-template-columns: 36px 1fr;
    grid-template-rows: auto auto auto;
  }

  .goal-ratio {
    grid-column: 2;
    grid-row: 3;
    margin-top: 4px;
  }

  .meals-row {
    grid-template-columns: 1fr 1fr;
  }
}