/* ============================================================================
   GYM PLANNER — Design System
   Dark-first. Token di :root = tema gelap (default).
   [data-theme="light"] menimpa token; mode "system" ikut prefers-color-scheme.
   Font: Barlow Condensed (display) + Barlow (body) — self-hosted.
   ========================================================================== */

@import url('/assets/fonts/barlow.css');

/* ---- 1. TOKENS ----------------------------------------------------------- */
:root {
  /* Permukaan (gelap, biru-baja — bukan hitam murni: hindari OLED smear) */
  --bg:        #0E1216;
  --surface:   #151B21;
  --surface-2: #1C242D;
  --surface-3: #232E38;
  --border:    #2A3541;
  --border-soft: #222B34;

  /* Teks */
  --ink:   #EEF3F7;
  --ink-2: #B7C2CC;
  --ink-3: #7E8C99;

  /* Merek: oranye energi */
  --primary:      #F97316;
  --primary-hi:   #FB8B3C;
  --on-primary:   #1A0E02;
  --primary-wash: rgba(249, 115, 22, .12);

  /* Semantik */
  --go:        #2FC468;   /* set selesai, sukses */
  --go-wash:   rgba(47, 196, 104, .13);
  --danger:    #EF4444;
  --danger-wash: rgba(239, 68, 68, .12);
  --warn:      #EAB308;
  --warn-wash: rgba(234, 179, 8, .12);

  --ring: var(--primary);

  /* Elevasi */
  --shadow-1: 0 1px 2px rgba(0,0,0,.35);
  --shadow-2: 0 4px 14px -4px rgba(0,0,0,.45);
  --shadow-3: 0 16px 40px -12px rgba(0,0,0,.6);

  /* Bentuk & ruang */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 24px; --sp-6: 32px; --sp-7: 48px; --sp-8: 64px;

  /* Tipografi */
  --font-display: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --font-body: 'Barlow', 'Segoe UI', system-ui, sans-serif;

  /* Lapisan tetap */
  --nav-h: 64px;
  --topbar-h: 56px;

  /* Cahaya ambien (anti-monoton) */
  --glow-a: rgba(249, 115, 22, .13);
  --glow-b: rgba(47, 196, 104, .06);

  color-scheme: dark;
}

[data-theme="light"] {
  --bg:        #F2F4F7;
  --surface:   #FFFFFF;
  --surface-2: #F7F9FB;
  --surface-3: #EDF1F5;
  --border:    #D6DDE4;
  --border-soft: #E3E8EE;

  --ink:   #16202A;
  --ink-2: #45535F;
  --ink-3: #6E7D8A;

  --primary:      #EA6A0E;
  --primary-hi:   #F97316;
  --on-primary:   #2B1403;   /* teks gelap di atas oranye: kontras jauh lebih aman daripada putih */
  --primary-wash: rgba(234, 106, 14, .1);

  --go:      #16A34A;
  --go-wash: rgba(22, 163, 74, .1);
  --danger:  #DC2626;
  --danger-wash: rgba(220, 38, 38, .08);
  --warn:    #A16207;
  --warn-wash: rgba(161, 98, 7, .1);

  --shadow-1: 0 1px 2px rgba(22,32,42,.06);
  --shadow-2: 0 4px 14px -4px rgba(22,32,42,.12);
  --shadow-3: 0 16px 40px -12px rgba(22,32,42,.18);

  --glow-a: rgba(234, 106, 14, .07);
  --glow-b: rgba(22, 163, 74, .04);

  color-scheme: light;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]):not([data-theme="light"]).theme-system {
    --bg:        #F2F4F7;
    --surface:   #FFFFFF;
    --surface-2: #F7F9FB;
    --surface-3: #EDF1F5;
    --border:    #D6DDE4;
    --border-soft: #E3E8EE;
    --ink:   #16202A;
    --ink-2: #45535F;
    --ink-3: #6E7D8A;
    --primary:      #EA6A0E;
    --primary-hi:   #F97316;
    --on-primary:   #2B1403;
    --primary-wash: rgba(234, 106, 14, .1);
    --go:      #16A34A;
    --go-wash: rgba(22, 163, 74, .1);
    --danger:  #DC2626;
    --danger-wash: rgba(220, 38, 38, .08);
    --warn:    #A16207;
    --warn-wash: rgba(161, 98, 7, .1);
    --shadow-1: 0 1px 2px rgba(22,32,42,.06);
    --shadow-2: 0 4px 14px -4px rgba(22,32,42,.12);
    --shadow-3: 0 16px 40px -12px rgba(22,32,42,.18);
    --glow-a: rgba(234, 106, 14, .07);
    --glow-b: rgba(22, 163, 74, .04);
    color-scheme: light;
  }
}

/* ---- 2. RESET & DASAR ---------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  /* JANGAN memberi <html> warna latar. Warna body inilah yang dipakai sebagai
     latar kanvas, dan itu yang membuat lapisan cahaya `body::before` (§20)
     tampil di atasnya, bukan tertutup. */
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}

img, svg, video { max-width: 100%; display: block; }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .015em;
  line-height: 1.05;
  margin: 0 0 var(--sp-3);
  text-wrap: balance;
}
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }
h4 { font-size: 1.02rem; letter-spacing: .04em; }

p { margin: 0 0 var(--sp-4); }

a { color: var(--primary-hi); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
  border-radius: 4px;
}

button { font-family: inherit; }

::selection { background: var(--primary); color: var(--on-primary); }

/* Angka sejajar di kolom (beban, rep, timer) */
.tnum { font-variant-numeric: tabular-nums; }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---- 3. SHELL APLIKASI --------------------------------------------------- */
.app-shell {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 var(--sp-4) calc(var(--nav-h) + var(--sp-6) + env(safe-area-inset-bottom));
  min-height: 100dvh;
}

@media (min-width: 900px) {
  .app-shell { max-width: 960px; }
}

.page-head { padding: var(--sp-5) 0 var(--sp-4); }
.page-title { margin-bottom: 2px; }
.page-sub { color: var(--ink-3); font-size: .92rem; margin: 0; }

/* ---- 4. TOPBAR ----------------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  margin: 0 calc(-1 * var(--sp-4));
  padding: 0 var(--sp-4);
  padding-top: env(safe-area-inset-top);
  /* Latar buram TANPA backdrop-filter: batang ini menempel saat digulir, dan
     blur di belakangnya harus dihitung ulang tiap frame — itu penyebab utama
     scroll patah-patah di perangkat ber-GPU sederhana. */
  background: var(--bg);
  border-bottom: 1px solid var(--border-soft);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--ink);
}
.topbar-brand .ic { color: var(--primary); }

.topbar-actions { display: flex; align-items: center; gap: var(--sp-2); }

/* Jam live di tengah topbar */
.topbar-clock {
  position: absolute;
  left: 50%;
  translate: -50% 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.1;
  pointer-events: none;
}
.clock-time {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: .05em;
}
.clock-date { font-size: .62rem; color: var(--ink-3); letter-spacing: .04em; text-transform: uppercase; }

/* Dropdown profil */
.dropdown { position: relative; }
.avatar-btn { border: 1px solid var(--border); cursor: pointer; padding: 0; }
.avatar-btn:hover { border-color: var(--ink-3); }
.dropdown.open .avatar-btn { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-wash); }

.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  z-index: 80;
  min-width: 230px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  padding: var(--sp-2);
  display: none;
}
.dropdown.open .dropdown-menu {
  display: block;
  animation: dropdown-in .18s cubic-bezier(.16, 1, .3, 1);
}
@keyframes dropdown-in {
  from { opacity: 0; transform: translateY(-6px) scale(.98); }
  to   { opacity: 1; transform: none; }
}

.dropdown-head {
  display: flex;
  flex-direction: column;
  padding: var(--sp-2) var(--sp-3) var(--sp-3);
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: var(--sp-2);
}
.dropdown-name { font-weight: 700; font-family: var(--font-display); font-size: 1.05rem; text-transform: uppercase; letter-spacing: .03em; }
.dropdown-email { font-size: .78rem; color: var(--ink-3); }

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  min-height: 44px;
  padding: 0 var(--sp-3);
  border: none;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink-2);
  font-family: var(--font-body);
  font-size: .95rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background .12s ease, color .12s ease;
}
.dropdown-item:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.dropdown-item .ic { color: var(--ink-3); }
.dropdown-item:hover .ic { color: var(--primary-hi); }
.dropdown-item-danger { color: var(--danger); }
.dropdown-item-danger .ic { color: var(--danger); }
.dropdown-item-danger:hover { background: var(--danger-wash); color: var(--danger); }
.dropdown-item-danger:hover .ic { color: var(--danger); }
.dropdown-sep { height: 1px; background: var(--border-soft); margin: var(--sp-2) var(--sp-2); }

.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--ink-2);
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: .95rem;
  text-transform: uppercase;
  overflow: hidden;
  border: 1px solid var(--border);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ---- 5. BOTTOM NAV + FAB -------------------------------------------------- */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 50;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);       /* lihat catatan di .topbar: tanpa blur */
  border-top: 1px solid var(--border-soft);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: stretch;
}

.bnav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 44px;
  color: var(--ink-3);
  font-size: .68rem;
  font-weight: 500;
  letter-spacing: .02em;
  cursor: pointer;
  transition: color .15s ease;
}
.bnav-item:hover { color: var(--ink-2); text-decoration: none; }
.bnav-item.active { color: var(--primary-hi); }
.bnav-item .ic { width: 22px; height: 22px; }

.bnav-fab {
  align-self: center;
  justify-self: center;
  width: 54px; height: 54px;
  margin-top: -26px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(145deg, var(--primary-hi), var(--primary));
  color: var(--on-primary);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 6px 20px -4px rgba(249, 115, 22, .55);
  transition: transform .15s ease, box-shadow .15s ease;
}
.bnav-fab:hover { transform: translateY(-2px); box-shadow: 0 10px 26px -6px rgba(249, 115, 22, .65); }
.bnav-fab:active { transform: scale(.96); }
.bnav-fab .ic { width: 26px; height: 26px; }

/* ---- 6. TOMBOL ------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 44px;
  padding: 10px 20px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  font-family: var(--font-body);
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s ease, border-color .15s ease, color .15s ease,
              transform .12s ease, box-shadow .15s ease, opacity .15s ease;
  user-select: none;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-primary {
  background: linear-gradient(145deg, var(--primary-hi), var(--primary));
  color: var(--on-primary);
  box-shadow: 0 4px 14px -4px rgba(249, 115, 22, .45);
}
.btn-primary:hover { filter: brightness(1.06); }

.btn-go { background: var(--go); color: #08150C; }
.btn-go:hover { filter: brightness(1.08); }

.btn-outline { background: transparent; border-color: var(--border); color: var(--ink); }
.btn-outline:hover { border-color: var(--ink-3); background: var(--surface-2); }

.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }

.btn-danger { background: var(--danger-wash); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-sm { min-height: 36px; padding: 6px 14px; font-size: .87rem; border-radius: var(--r-sm); }
.btn-lg { min-height: 54px; padding: 14px 28px; font-size: 1.05rem; border-radius: var(--r-lg); }
.btn-block { width: 100%; }

.btn-icon {
  min-width: 44px; min-height: 44px;
  padding: 0;
  border-radius: var(--r-md);
  background: transparent;
  border: none;
  color: var(--ink-2);
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.btn-icon:hover { background: var(--surface-2); color: var(--ink); }

/* Tombol tema: matahari & bulan ditumpuk di sel grid yang sama, lalu yang
   sesuai tema aktif diputar masuk. Dipakai di topbar app, auth, dan landing. */
.theme-form { display: flex; }
.theme-toggle { position: relative; overflow: hidden; }
.theme-toggle .theme-ic {
  grid-area: 1 / 1;
  display: grid;
  place-items: center;
  transition: rotate .35s cubic-bezier(.34,1.4,.64,1), opacity .2s ease, scale .35s ease;
}
.theme-toggle .ic { width: 20px; height: 20px; }
[data-theme="dark"] .theme-toggle .theme-ic-moon,
[data-theme="light"] .theme-toggle .theme-ic-sun {
  opacity: 0; rotate: -70deg; scale: .5; pointer-events: none;
}
[data-theme="dark"] .theme-toggle .theme-ic-sun,
[data-theme="light"] .theme-toggle .theme-ic-moon {
  opacity: 1; rotate: 0deg; scale: 1;
}
[data-theme="dark"] .theme-toggle:hover { color: var(--warn); }
[data-theme="light"] .theme-toggle:hover { color: var(--primary); }
@media (prefers-reduced-motion: reduce) {
  .theme-toggle .theme-ic { transition: none; rotate: none !important; scale: none !important; }
}

/* ---- 7. FORM -------------------------------------------------------------- */
.field { margin-bottom: var(--sp-4); }

.label {
  display: block;
  font-size: .84rem;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: var(--sp-2);
  letter-spacing: .01em;
}

.input, .select, .textarea {
  width: 100%;
  min-height: 46px;
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--ink);
  font-family: inherit;
  font-size: 1rem;                /* >=16px: cegah zoom otomatis iOS */
  transition: border-color .15s ease, box-shadow .15s ease;
}
.textarea { min-height: 90px; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--ink-3); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-wash);
}
.input[aria-invalid="true"], .select[aria-invalid="true"] {
  border-color: var(--danger);
}

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237E8C99' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 38px;
}

.hint { font-size: .8rem; color: var(--ink-3); margin-top: var(--sp-1); }

.field-error {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .82rem;
  color: var(--danger);
  margin-top: var(--sp-1);
}
.field-error .ic { width: 14px; height: 14px; flex: none; }

/* Nomor kecil untuk kg/rep (dipakai builder & sesi) */
.input-num {
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  padding-left: 6px;
  padding-right: 6px;
}

/* Switch */
.switch { position: relative; display: inline-flex; align-items: center; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.switch-track {
  width: 46px; height: 27px;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  transition: background .18s ease, border-color .18s ease;
}
.switch-thumb {
  position: absolute;
  top: 50%; left: 3px;
  translate: 0 -50%;
  width: 21px; height: 21px;
  border-radius: 50%;
  background: var(--ink-3);
  transition: left .18s ease, background .18s ease;
}
.switch input:checked ~ .switch-track { background: var(--primary-wash); border-color: var(--primary); }
.switch input:checked ~ .switch-thumb { left: 22px; background: var(--primary); }
.switch input:focus-visible ~ .switch-track { outline: 2px solid var(--ring); outline-offset: 2px; }

/* Segmented control (kg/lb, bahasa, tema) */
.segmented {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 3px;
  gap: 2px;
}
.segmented label { position: relative; }
.segmented input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.segmented span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 4px 16px;
  border-radius: calc(var(--r-md) - 4px);
  font-size: .88rem;
  font-weight: 600;
  color: var(--ink-3);
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.segmented input:checked + span { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
.segmented input:focus-visible + span { outline: 2px solid var(--ring); }

/* ---- 8. KARTU & LIST ------------------------------------------------------ */
.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
}
.card-pad { padding: var(--sp-4); }
.card + .card { margin-top: var(--sp-3); }

.card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}
.card-title h3 { margin: 0; }

a.card { color: inherit; display: block; transition: border-color .15s ease, transform .15s ease; cursor: pointer; }
a.card:hover { text-decoration: none; border-color: var(--border); transform: translateY(-1px); }

.list-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  min-height: 56px;
  border-bottom: 1px solid var(--border-soft);
  color: inherit;
}
.list-item:last-child { border-bottom: none; }
a.list-item { cursor: pointer; transition: background .15s ease; }
a.list-item:hover { background: var(--surface-2); text-decoration: none; }
.list-item-body { flex: 1; min-width: 0; }
.list-item-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item-sub { font-size: .82rem; color: var(--ink-3); }

/* Stat tile (beranda & progres) */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-3); }
@media (min-width: 640px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
}
.stat-value {
  font-family: var(--font-display);
  font-size: 1.85rem;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.stat-label { font-size: .78rem; color: var(--ink-3); margin-top: 4px; letter-spacing: .02em; }
.stat-tile .ic { color: var(--primary); margin-bottom: var(--sp-2); }

/* ---- 9. CHIP & BADGE ------------------------------------------------------ */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--ink-2);
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
  user-select: none;
  text-decoration: none;
}
.chip:hover { border-color: var(--ink-3); text-decoration: none; }
.chip.active {
  background: var(--primary-wash);
  border-color: var(--primary);
  color: var(--primary-hi);
}
.chip-row { display: flex; gap: var(--sp-2); overflow-x: auto; padding-bottom: var(--sp-2); scrollbar-width: none; }
.chip-row::-webkit-scrollbar { display: none; }
.chip-row .chip { flex: none; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.badge-pr { background: var(--primary); color: var(--on-primary); }
.badge-go { background: var(--go-wash); color: var(--go); }
.badge-muted { background: var(--surface-3); color: var(--ink-2); }
.badge-warn { background: var(--warn-wash); color: var(--warn); }
.badge-danger { background: var(--danger-wash); color: var(--danger); }

/* ---- 10. PAPAN MINGGU (routine builder) -----------------------------------
   Gaya papan Senin–Minggu (kelas .wk-*) tinggal di app/Views/routine/index.php
   karena hanya halaman itu yang memakainya — sama seperti halaman landing dan
   editor hari. Nomor seksi sengaja dipertahankan supaya rujukan §11 dst. tetap
   cocok dengan CONVENTIONS.md. */

/* ---- 11. MODE LATIHAN AKTIF ------------------------------------------------
   Aturan: dipakai satu tangan sambil berdiri.
   Target sentuh centang set = 56px. Angka besar, tabular-nums.
--------------------------------------------------------------------------- */
.focus-shell {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 var(--sp-4) calc(140px + env(safe-area-inset-bottom));
}

.focus-topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  height: var(--topbar-h);
  margin: 0 calc(-1 * var(--sp-4));
  padding: 0 var(--sp-4);
  background: var(--bg);            /* lihat catatan di .topbar: tanpa blur */
  border-bottom: 1px solid var(--border-soft);
}

.workout-timer {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: .04em;
  color: var(--primary-hi);
}

/* Kartu gerakan dalam sesi */
.exercise-card { margin-top: var(--sp-3); }
.exercise-card .card-title h3 { font-size: 1.25rem; }
.exercise-target { font-size: .8rem; color: var(--ink-3); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Grid set: no | terakhir | kg | rep | centang */
.set-grid {
  display: grid;
  grid-template-columns: 2rem minmax(4.4rem, 1fr) 4.4rem 4rem 56px;
  gap: var(--sp-2);
  align-items: center;
}
.set-grid-head {
  font-size: .66rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.set-num {
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--ink-3);
}
.set-prev {
  font-size: .8rem;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.set-grid .input-num { min-height: 48px; font-size: 1.05rem; }

/* Tombol centang set — 56px, di atas standar 44px */
.set-check {
  width: 56px; height: 56px;
  border-radius: var(--r-md);
  border: 1.5px solid var(--border);
  background: var(--surface-2);
  color: var(--ink-3);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease, transform .12s ease;
}
.set-check:active { transform: scale(.94); }
.set-check .ic { width: 24px; height: 24px; }
.set-check.done {
  background: var(--go);
  border-color: var(--go);
  color: #08150C;
}

/* Baris set selesai */
.set-row-done .input-num {
  background: var(--go-wash);
  border-color: color-mix(in srgb, var(--go) 45%, var(--border));
  color: var(--go);
}
.set-row-done .set-num { color: var(--go); }

/* Set pemanasan / dropset */
.set-type-warmup .set-num { color: var(--warn); }
.set-type-drop .set-num { color: var(--primary-hi); }

/* Bar istirahat melayang */
.rest-bar {
  position: fixed;
  left: 50%;
  translate: -50% 0;
  bottom: calc(var(--sp-4) + env(safe-area-inset-bottom));
  z-index: 60;
  width: min(600px, calc(100vw - var(--sp-5)));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
}
.rest-bar[hidden] { display: none; }
.rest-time {
  font-family: var(--font-display);
  font-size: 1.9rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--primary-hi);
  line-height: 1;
}
.rest-label { font-size: .68rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.rest-actions { display: flex; gap: var(--sp-2); }

/* Progress bar tipis di rest bar */
.rest-progress {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 3px;
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  overflow: hidden;
  background: var(--border-soft);
}
.rest-progress > span {
  display: block;
  height: 100%;
  background: var(--primary);
  transition: width 1s linear;
}

/* ---- 12. HEATMAP KONSISTENSI ---------------------------------------------- */
.heatmap { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.heat-cell {
  aspect-ratio: 1;
  border-radius: 4px;
  background: var(--surface-3);
}
.heat-cell[data-level="1"] { background: color-mix(in srgb, var(--primary) 25%, var(--surface-3)); }
.heat-cell[data-level="2"] { background: color-mix(in srgb, var(--primary) 50%, var(--surface-3)); }
.heat-cell[data-level="3"] { background: color-mix(in srgb, var(--primary) 75%, var(--surface-3)); }
.heat-cell[data-level="4"] { background: var(--primary); }

/* Ring target mingguan (SVG <circle> pakai stroke-dasharray dari server/JS) */
.ring { --size: 64px; width: var(--size); height: var(--size); }
.ring circle { fill: none; stroke-width: 6; }
.ring .ring-bg { stroke: var(--surface-3); }
.ring .ring-val { stroke: var(--primary); stroke-linecap: round; transform: rotate(-90deg); transform-origin: center; }

/* ---- 13. MODAL ------------------------------------------------------------ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(8, 11, 14, .66);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: grid;
  place-items: end center;
  padding: var(--sp-4);
}
@media (min-width: 640px) { .modal-backdrop { place-items: center; } }
.modal-backdrop[hidden] { display: none; }

.modal {
  width: min(560px, 100%);
  max-height: min(82dvh, 720px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  animation: modal-in .22s cubic-bezier(.16, 1, .3, 1);
}
/* Di layar kecil modal jadi lembar-bawah selebar layar penuh: lebih pas untuk
   jempol, dan tidak menyisakan ruang di kiri/kanan yang bisa membuatnya
   terlihat melenceng.
   HARUS ditulis SESUDAH aturan .modal di atas — spesifisitasnya sama, jadi
   kalau ditaruh lebih dulu justru aturan di ataslah yang menang. */
@media (max-width: 639px) {
  .modal-backdrop { padding: 0; }
  .modal {
    /* DIPAKU ke tepi viewport, bukan dipusatkan lewat grid. Elemen yang
       dipusatkan masih bisa berakhir di luar layar kalau halaman sempat bisa
       digulir mendatar; yang dipaku left:0/right:0 tidak pernah bisa. */
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-width: none;
    max-height: min(88dvh, 760px);
    border-bottom: 0;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(24px) scale(.98); }
  to   { opacity: 1; transform: none; }
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border-bottom: 1px solid var(--border-soft);
}
.modal-head h3 { margin: 0; }
.modal-body { padding: var(--sp-4); overflow-y: auto; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--border-soft);
}

/* ---- 14. TOAST ------------------------------------------------------------ */
.toasts {
  position: fixed;
  top: calc(var(--sp-4) + env(safe-area-inset-top));
  left: 50%;
  translate: -50% 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  width: min(420px, calc(100vw - var(--sp-6)));
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--ink);
  font-size: .92rem;
  font-weight: 500;
  box-shadow: var(--shadow-2);
  animation: toast-in .25s cubic-bezier(.16, 1, .3, 1);
  pointer-events: auto;
}
.toast .ic { flex: none; }
.toast-success .ic { color: var(--go); }
.toast-error .ic { color: var(--danger); }
.toast-info .ic { color: var(--primary-hi); }
.toast.leaving { animation: toast-out .18s ease forwards; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-12px); }
  to   { opacity: 1; transform: none; }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateY(-8px); }
}

/* ---- 15. TABEL ------------------------------------------------------------ */
.table-wrap { overflow-x: auto; border: 1px solid var(--border-soft); border-radius: var(--r-lg); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; min-width: 480px; }
.table th {
  text-align: left;
  padding: var(--sp-3) var(--sp-4);
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--ink-3);
  border-bottom: 1px solid var(--border-soft);
  background: var(--surface-2);
  white-space: nowrap;
}
.table td { padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }

/* ---- 16. EMPTY STATE & SKELETON ------------------------------------------- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--sp-2);
  padding: var(--sp-7) var(--sp-5);
  color: var(--ink-3);
}
.empty .ic { width: 44px; height: 44px; opacity: .5; }
.empty-title { font-weight: 600; color: var(--ink-2); font-size: 1.02rem; }
.empty p { max-width: 34ch; margin: 0; font-size: .9rem; }
.empty .btn { margin-top: var(--sp-3); }

.skeleton {
  border-radius: var(--r-sm);
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---- 17. LAYOUT AUTH ------------------------------------------------------ */
.auth-wrap {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: var(--sp-5) var(--sp-4);
  background:
    radial-gradient(60% 40% at 85% -10%, var(--primary-wash), transparent 70%),
    var(--bg);
}
/* Tombol tema + bahasa mengambang di pojok halaman auth */
.auth-float {
  position: absolute;
  z-index: 10;
  top: calc(env(safe-area-inset-top) + var(--sp-3));
  right: var(--sp-3);
  display: flex;
  align-items: center;
  gap: var(--sp-1);
}
.auth-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
  padding: var(--sp-6) var(--sp-5);
}
.auth-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: var(--sp-5);
}
.auth-logo .ic { width: 28px; height: 28px; color: var(--primary); }
.auth-foot { text-align: center; font-size: .9rem; color: var(--ink-3); margin-top: var(--sp-4); }

/* Stepper onboarding */
.steps { display: flex; gap: var(--sp-2); margin-bottom: var(--sp-5); }
.step-dot { flex: 1; height: 4px; border-radius: 999px; background: var(--surface-3); }
.step-dot.active { background: var(--primary); }

/* ---- 18. IKON & UTILITAS --------------------------------------------------- */
.ic { width: 20px; height: 20px; flex: none; }
.ic-sm { width: 16px; height: 16px; }
.ic-lg { width: 24px; height: 24px; }

.flex { display: flex; }
.items-center { align-items: center; }
.items-end { align-items: flex-end; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; min-width: 0; }
.gap-1 { gap: var(--sp-1); } .gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); } .gap-4 { gap: var(--sp-4); }

.mt-2 { margin-top: var(--sp-2); } .mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); } .mt-5 { margin-top: var(--sp-5); }
.mt-6 { margin-top: var(--sp-6); }
.mb-2 { margin-bottom: var(--sp-2); } .mb-3 { margin-bottom: var(--sp-3); }
.mb-4 { margin-bottom: var(--sp-4); } .mb-5 { margin-bottom: var(--sp-5); }

.muted { color: var(--ink-3); }
.small { font-size: .84rem; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-go { color: var(--go); }
.text-danger { color: var(--danger); }
.text-primary { color: var(--primary-hi); }
.fw-600 { font-weight: 600; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.divider { height: 1px; background: var(--border-soft); border: none; margin: var(--sp-4) 0; }

@media (max-width: 639px) { .hide-mobile { display: none !important; } }
@media (min-width: 640px) { .hide-desktop { display: none !important; } }

/* ---- 19. ANIMASI MAKNA ----------------------------------------------------- */
@keyframes pop {
  0% { transform: scale(.6); opacity: 0; }
  70% { transform: scale(1.08); }
  100% { transform: scale(1); opacity: 1; }
}
.anim-pop { animation: pop .3s cubic-bezier(.34, 1.4, .64, 1); }

@keyframes pulse-pr {
  0%, 100% { box-shadow: 0 0 0 0 rgba(249, 115, 22, .45); }
  50% { box-shadow: 0 0 0 8px rgba(249, 115, 22, 0); }
}
.anim-pr { animation: pulse-pr 1.1s ease 2; }

.stagger-in > * {
  animation: rise-in .35s cubic-bezier(.16, 1, .3, 1) backwards;
}
.stagger-in > *:nth-child(1) { animation-delay: 0ms; }
.stagger-in > *:nth-child(2) { animation-delay: 45ms; }
.stagger-in > *:nth-child(3) { animation-delay: 90ms; }
.stagger-in > *:nth-child(4) { animation-delay: 135ms; }
.stagger-in > *:nth-child(5) { animation-delay: 180ms; }
.stagger-in > *:nth-child(6) { animation-delay: 225ms; }
.stagger-in > *:nth-child(7) { animation-delay: 270ms; }
.stagger-in > *:nth-child(n+8) { animation-delay: 300ms; }
@keyframes rise-in {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

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

/* ---- 20. ATMOSFER & AKSEN (anti-monoton) ----------------------------------- */
/* Cahaya ambien lembut: oranye dari kanan-atas, hijau samar kiri-bawah.
   JANGAN pakai `background-attachment: fixed` di sini. Itu memaksa browser
   mengecat ulang seluruh latar viewport pada SETIAP frame gulir dan bikin
   scroll patah-patah. Lapisan tetap di bawah ini dapat layer komposit
   sendiri: digulir tanpa mengecat ulang apa pun. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    radial-gradient(46% 32% at 90% -8%, var(--glow-a), transparent 70%),
    radial-gradient(38% 30% at -12% 106%, var(--glow-b), transparent 72%);
}

/* Judul angka besar bergradien (dipakai stat unggulan, hero, ringkasan) */
.text-gradient {
  background: linear-gradient(115deg, var(--primary-hi), var(--primary) 55%, #E8590C);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Varian kartu dengan strip aksen kiri (kartu "hari ini", PR, resume) */
.card-accent { position: relative; overflow: hidden; }
.card-accent::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--primary-hi), var(--primary));
}
.card-accent-go::before { background: linear-gradient(180deg, var(--go), #1E9B52); }

/* Kartu "glass" di atas area ber-glow (header profil, ringkasan) */
.card-glass {
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  /* Blur kecil saja. Elemen ini ikut tergulir, jadi blur-nya dihitung ulang
     terus; 12px terasa berat di GPU sederhana, 6px hampir tak beda dilihat. */
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

/* Ikon dalam lingkaran wash berwarna — hidupkan stat & daftar fitur */
.icon-chip {
  width: 40px; height: 40px;
  flex: none;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--primary-wash);
  color: var(--primary-hi);
}
.icon-chip-go { background: var(--go-wash); color: var(--go); }
.icon-chip-warn { background: var(--warn-wash); color: var(--warn); }

/* Bento grid — tata letak modular ukuran campur (dashboard, progres, landing) */
.bento {
  display: grid;
  gap: var(--sp-3);
  grid-template-columns: repeat(2, 1fr);
  grid-auto-flow: dense;
}
@media (min-width: 720px) { .bento { grid-template-columns: repeat(4, 1fr); } }
.bento > * { min-width: 0; margin: 0; }
.bento-2w { grid-column: span 2; }
.bento-2h { grid-row: span 2; }
@media (min-width: 720px) { .bento-3w { grid-column: span 3; } .bento-4w { grid-column: span 4; } }
@media (max-width: 719px) { .bento-3w, .bento-4w { grid-column: span 2; } }

/* Label eyebrow — pengantar seksi, huruf kecil berjarak */
.eyebrow {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--primary-hi);
  margin-bottom: var(--sp-1);
}

/* Titik level kesulitan (1=pemula 2=menengah 3=lanjut) */
.diff-dots { display: inline-flex; gap: 3px; align-items: center; }
.diff-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--surface-3); }
.diff-dots[data-level="1"] i:nth-child(1) { background: var(--go); }
.diff-dots[data-level="2"] i:nth-child(-n+2) { background: var(--warn); }
.diff-dots[data-level="3"] i { background: var(--danger); }

/* Peta otot tubuh — region menyala sesuai volume latihan (data-level 0-4) */
.body-map { width: 100%; max-width: 180px; height: auto; margin: 0 auto; display: block; }
.body-map .bm-base { fill: var(--surface-2); }
.body-map [data-muscle] * , .body-map [data-muscle] path { transition: fill .35s ease; }
.body-map [data-muscle] { fill: var(--surface-3); }
.body-map [data-muscle][data-level="1"] { fill: color-mix(in srgb, var(--primary) 28%, var(--surface-3)); }
.body-map [data-muscle][data-level="2"] { fill: color-mix(in srgb, var(--primary) 52%, var(--surface-3)); }
.body-map [data-muscle][data-level="3"] { fill: color-mix(in srgb, var(--primary) 76%, var(--surface-3)); }
.body-map [data-muscle][data-level="4"] { fill: var(--primary); }

/* Bar XP / level */
.xp-bar {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}
.xp-bar > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary-hi), var(--primary));
  transition: width .6s cubic-bezier(.16, 1, .3, 1);
}
.level-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--primary-wash);
  border: 1px solid color-mix(in srgb, var(--primary) 40%, transparent);
  color: var(--primary-hi);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: .9rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}

/* Visual plat barbel (kalkulator plat) */
.plate-viz { display: flex; align-items: center; gap: 2px; min-height: 64px; }
.plate-viz .bar { height: 8px; background: var(--ink-3); border-radius: 4px; flex: 1; min-width: 24px; }
.plate-viz .plate {
  width: 12px;
  border-radius: 3px;
  background: var(--primary);
  border: 1px solid color-mix(in srgb, var(--ink) 20%, transparent);
}
.plate-viz .plate[data-kg="25"] { height: 64px; background: #DC2626; }
.plate-viz .plate[data-kg="20"] { height: 60px; background: #2563EB; }
.plate-viz .plate[data-kg="15"] { height: 52px; background: #EAB308; }
.plate-viz .plate[data-kg="10"] { height: 44px; background: #16A34A; }
.plate-viz .plate[data-kg="5"]  { height: 34px; background: #E7EDF2; }
.plate-viz .plate[data-kg="2.5"] { height: 26px; background: var(--ink-3); }
.plate-viz .plate[data-kg="1.25"] { height: 20px; background: var(--surface-3); }

/* Swipe hint pada baris set (geser kanan = selesai) */
.set-swipe { position: relative; touch-action: pan-y; }
.set-swipe.swiping { transition: none; }
.set-swipe.swipe-return { transition: transform .2s ease; }

/* Konfeti perayaan PR (partikel dibuat Gym.celebrate()) */
.celebrate {
  position: fixed;
  inset: 0;
  z-index: 120;
  pointer-events: none;
  overflow: hidden;
}
.celebrate i {
  position: absolute;
  top: -12px;
  width: 8px; height: 14px;
  border-radius: 2px;
  animation: confetti-fall var(--dur, 1.4s) cubic-bezier(.25,.4,.6,1) forwards;
}
@keyframes confetti-fall {
  to {
    transform: translate3d(var(--tx, 0), 105vh, 0) rotate(var(--rot, 540deg));
    opacity: .9;
  }
}

/* Kilau halus saat hover tombol utama */
@media (hover: hover) {
  .btn-primary { position: relative; overflow: hidden; }
  .btn-primary::after {
    content: '';
    position: absolute;
    top: 0; bottom: 0;
    left: -60%;
    width: 40%;
    background: linear-gradient(100deg, transparent, rgba(255,255,255,.28), transparent);
    transform: skewX(-18deg);
    transition: left .45s ease;
  }
  .btn-primary:hover::after { left: 120%; }
}

/* ---- 21. CETAK (ringkasan sesi) -------------------------------------------- */
@media print {
  .topbar, .bottom-nav, .rest-bar, .toasts { display: none !important; }
  body::before { display: none; }          /* lapisan cahaya ambien */
  body { background: #fff; color: #000; }
}
