  :root {
    color-scheme: dark;
    --gold: #bfae63;
    --gold-dim: rgba(191,174,99,0.15);
    --dark: #0a0a0a;
    --panel: #121212;
    --cream: #f3efe5;
    --ink: #141414;
    --muted: rgba(255,255,255,0.55);
    --muted-dark: rgba(20,20,20,0.6);
    --font-display: 'Oswald', sans-serif;
    --font-body: 'Barlow', sans-serif;
  }
  * { box-sizing: border-box; }
  html {
    background: var(--dark);
    min-height: 100%;
    overscroll-behavior-y: none;
  }
  body {
    margin: 0;
    min-height: 100vh;
    background: var(--dark);
    color: #fff;
    font-family: var(--font-body);
    -webkit-font-smoothing: antialiased;
    overscroll-behavior-y: none;
  }
  .wrap {
    max-width: 760px;
    margin: 0 auto;
    padding: 24px 24px 80px;
    background: var(--dark);
  }
  .eyebrow {
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 4px;
    text-transform: uppercase;
    color: var(--gold);
    margin: 0 0 10px;
  }
  h1 {
    font-family: var(--font-display);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: clamp(28px, 5vw, 40px);
    line-height: 1.1;
    margin: 0 0 14px;
  }
  h1 span { color: var(--gold); }
  .intro {
    color: var(--muted);
    font-size: 16px;
    line-height: 1.6;
    max-width: 56ch;
    margin: 0 0 40px;
  }

  .panel {
    background: var(--panel);
    border: 1px solid rgba(255,255,255,0.08);
    padding: 32px;
  }
  @media (max-width: 560px) { .panel { padding: 22px; } }

  .row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 22px; }
  .row.single { grid-template-columns: 1fr; }
  @media (max-width: 520px) { .row { grid-template-columns: 1fr; } }

  label {
    display: block;
    font-family: var(--font-display);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 8px;
  }

  .pillgroup { display: flex; gap: 8px; }
  .pill {
    flex: 1;
    padding: 12px 10px;
    text-align: center;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.18);
    color: #fff;
    font-family: var(--font-body);
    font-size: 15px;
    cursor: pointer;
    transition: all 0.15s;
  }
  .pill.active { background: var(--gold); border-color: var(--gold); color: var(--ink); font-weight: 600; }
  .pill:hover:not(.active) { border-color: var(--gold); }

  input[type="number"], select {
    width: 100%;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.18);
    color: #fff;
    font-family: var(--font-body);
    font-size: 16px;
    padding: 12px 14px;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
  }
  input[type="number"]:focus, select:focus { border-color: var(--gold); }
  select {
    background-color: #121212;
    color-scheme: dark;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23bfae63' stroke-width='2'><polyline points='6 9 12 15 18 9'/></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
  }
  /* The open dropdown list uses the browser's own styling — without
     explicit rules, some browsers render a white list that inherits
     the white text, making options invisible. Force dark on both. */
  select option {
    background: #121212;
    color: #ffffff;
  }
  select option:checked {
    background: #bfae63;
    color: #141414;
  }
  .unit-inline { display: flex; gap: 8px; }
  .unit-inline input { flex: 2; }
  .unit-inline .pillgroup { flex: 1; }

  .bf-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 4px 0 22px;
    cursor: pointer;
    user-select: none;
  }
  .checkbox {
    width: 20px; height: 20px;
    border: 1px solid rgba(255,255,255,0.3);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
  }
  .checkbox.checked { background: var(--gold); border-color: var(--gold); }
  .checkbox svg { width: 13px; height: 13px; display: none; }
  .checkbox.checked svg { display: block; }
  .bf-toggle .bf-label { font-size: 15px; color: var(--muted); }

  #bfRow { max-height: 0; overflow: hidden; transition: max-height 0.25s ease, margin 0.25s ease; margin-bottom: 0; }
  #bfRow.open { max-height: 140px; margin-bottom: 22px; }

  .calc-btn {
    width: 100%;
    background: var(--gold);
    color: var(--ink);
    border: none;
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    padding: 16px;
    cursor: pointer;
    margin-top: 10px;
    transition: opacity 0.15s;
  }
  .calc-btn:hover { opacity: 0.88; }

  /* Results */
  #results { margin-top: 40px; display: none; background: var(--dark); }
  #results.show { display: block; }

  .tdee-hero, .breakdown, .goal-grid, .caveat, .footnote {
    background: var(--dark);
  }

  .result-label {
    font-family: var(--font-display);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--gold);
    margin-bottom: 6px;
  }

  .tdee-hero { text-align: center; padding: 36px 20px 30px; border-bottom: 1px solid rgba(255,255,255,0.08); margin-bottom: 30px; }
  .tdee-number {
    font-family: var(--font-display);
    font-size: clamp(48px, 10vw, 72px);
    font-weight: 700;
    color: #fff;
    line-height: 1;
  }
  .tdee-number span { color: var(--gold); }
  .tdee-unit { font-size: 15px; color: var(--muted); margin-top: 6px; }

  .band-wrap { margin: 22px auto 0; max-width: 420px; }
  .band-track {
    position: relative;
    height: 8px;
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
    margin: 10px 0;
  }
  .band-fill {
    position: absolute;
    top: 0; bottom: 0;
    background: var(--gold-dim);
    border-left: 2px solid var(--gold);
    border-right: 2px solid var(--gold);
  }
  .band-marker {
    position: absolute;
    top: -5px;
    width: 18px; height: 18px;
    background: var(--gold);
    border-radius: 50%;
    transform: translateX(-50%);
    box-shadow: 0 0 0 4px rgba(191,174,99,0.2);
  }
  .band-labels { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }

  .breakdown { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 30px; }
  @media (max-width: 520px) { .breakdown { grid-template-columns: 1fr; } }
  .bd-card { background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.08); padding: 20px; }
  .bd-card .bd-title { font-family: var(--font-display); font-size: 13px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; margin-bottom: 8px; }
  .bd-card .bd-value { font-family: var(--font-display); font-size: 26px; font-weight: 600; color: var(--gold); }
  .bd-card .bd-note { font-size: 13px; color: var(--muted); margin-top: 6px; line-height: 1.5; }

  .goal-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; margin-bottom: 30px; }
  @media (max-width: 520px) { .goal-grid { grid-template-columns: 1fr; } }
  .goal-card { border: 1px solid rgba(255,255,255,0.1); padding: 16px; text-align: center; }
  .goal-card .goal-name { font-family: var(--font-display); font-size: 12px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
  .goal-card .goal-cals { font-family: var(--font-display); font-size: 22px; font-weight: 600; color: #fff; }

  .caveat {
    background: rgba(191,174,99,0.06);
    border-left: 3px solid var(--gold);
    padding: 18px 22px;
    font-size: 14.5px;
    line-height: 1.65;
    color: var(--muted);
  }
  .caveat strong { color: #fff; font-weight: 600; }

  .footnote {
    margin-top: 28px;
    font-size: 12.5px;
    color: rgba(255,255,255,0.35);
    line-height: 1.6;
  }
  /* Header & Navigation */
  header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--dark);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    padding: 1.5rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .logo {
    display: flex;
    align-items: center;
    text-decoration: none;
  }
  .logo img {
    height: 40px;
    width: auto;
    transition: opacity 0.3s;
  }
  .logo:hover img {
    opacity: 0.8;
  }
  nav {
    display: flex;
    gap: 2rem;
    align-items: center;
  }
  nav a {
    color: #ffffff;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: color 0.3s;
  }
  nav a:hover {
    color: var(--gold);
  }
  @media (max-width: 768px) {
    header {
      flex-direction: column;
      gap: 1rem;
    }
    nav {
      flex-wrap: wrap;
      justify-content: center;
    }
    .logo img {
      height: 32px;
    }
  }

  /* Auth Modal CSS */
  #authBackdrop {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
  }
  #authBackdrop.open {
    display: flex;
  }
  
  #authSheet {
    background: var(--panel);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    padding: 32px;
    max-width: 400px;
    width: 90%;
  }
  
  #authTitle {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 24px;
    color: #fff;
  }
  
  .auth-field {
    margin-bottom: 16px;
  }
  
  .auth-field label {
    display: block;
    font-family: var(--font-display);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 8px;
  }
  
  .auth-field input {
    width: 100%;
    padding: 12px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    color: #fff;
    font-family: var(--font-body);
    font-size: 14px;
    border-radius: 4px;
  }
  
  .auth-field input:focus {
    outline: none;
    border-color: var(--gold);
    background: rgba(255,255,255,0.08);
  }
  
  #authError {
    display: none;
    background: rgba(255, 0, 0, 0.1);
    border: 1px solid rgba(255, 0, 0, 0.3);
    color: #ff6b6b;
    padding: 12px;
    border-radius: 4px;
    font-size: 13px;
    margin-bottom: 16px;
  }
  
  #authSubmit {
    width: 100%;
    padding: 12px;
    background: var(--gold);
    color: var(--ink);
    border: none;
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    cursor: pointer;
    border-radius: 4px;
    margin-top: 8px;
  }
  
  #authSubmit:hover {
    background: #d4c368;
  }
  
  #authToggle {
    display: block;
    text-align: center;
    margin-top: 16px;
    background: none;
    border: none;
    color: var(--gold);
    font-size: 12px;
    cursor: pointer;
    text-decoration: underline;
    width: 100%;
  }
