:root {
  --bg: #090d14;
  --bg-elevated: #111824;
  --panel: #151e2e;
  --panel-alt: #1b273b;
  --border: #26364f;
  --border-highlight: #374e70;
  --text: #f0f6fc;
  --text-muted: #93a6be;
  --emerald: #38f2b8;
  --emerald-dark: #07291f;
  --emerald-soft: rgba(56, 242, 184, 0.14);
  --indigo: #928aff;
  --indigo-soft: rgba(146, 138, 255, 0.16);
  --amber: #f7b955;
  --amber-soft: rgba(247, 185, 85, 0.15);
  --danger: #ff6b81;
  --danger-soft: rgba(255, 107, 129, 0.15);
  --radius-lg: 22px;
  --radius-md: 15px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  background: radial-gradient(circle at 50% -10%, #16243a 0%, var(--bg) 55%);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  min-height: 100vh;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button {
  background: var(--panel-alt);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 11px 15px;
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.08s ease, border-color 0.15s ease, background 0.15s ease;
}

button:hover:not(:disabled) {
  border-color: var(--border-highlight);
}

button:active:not(:disabled) {
  transform: scale(0.97);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

button.primary {
  background: linear-gradient(135deg, #38f2b8 0%, #24cfa0 100%);
  color: var(--emerald-dark);
  border: 0;
  font-weight: 800;
}

button.indigo {
  background: var(--indigo-soft);
  color: #c9c4ff;
  border-color: rgba(146, 138, 255, 0.4);
}

button.amber {
  background: var(--amber-soft);
  color: var(--amber);
  border-color: rgba(247, 185, 85, 0.4);
}

button.danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: rgba(255, 107, 129, 0.35);
}

button.ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
}

input, select, textarea {
  width: 100%;
  background: #0c121c;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 13px;
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--emerald);
  box-shadow: 0 0 0 2px rgba(56, 242, 184, 0.2);
}

textarea {
  resize: vertical;
  min-height: 72px;
}

label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  display: block;
  margin-bottom: 5px;
}

h1 {
  font-size: 28px;
  letter-spacing: -0.8px;
  margin: 4px 0 8px;
}

h2 {
  font-size: 19px;
  letter-spacing: -0.3px;
  margin: 0 0 10px;
}

h3 {
  font-size: 16px;
  margin: 0 0 6px;
}

p {
  margin: 6px 0 10px;
}

.muted {
  color: var(--text-muted);
}

.small {
  font-size: 13px;
}

.tiny {
  font-size: 11px;
  color: var(--text-muted);
}

.eyebrow {
  color: var(--emerald);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.8px;
  text-transform: uppercase;
}

/* Header & Layout */
.topbar {
  max-width: 1020px;
  margin: 0 auto;
  padding: 16px 20px 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.brand {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: -0.8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--emerald-soft);
  border: 1px solid rgba(56, 242, 184, 0.4);
  display: grid;
  place-content: center;
  color: var(--emerald);
  font-weight: 900;
}

.brand span {
  color: var(--emerald);
}

.profile-switcher {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--panel);
  padding: 4px;
  border-radius: 14px;
  border: 1px solid var(--border);
}

.profile-btn {
  padding: 7px 13px;
  border-radius: 10px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
}

.profile-btn.active {
  background: var(--emerald);
  color: var(--emerald-dark);
}

.wrap {
  max-width: 1020px;
  margin: 0 auto;
  padding: 16px 20px 115px;
}

/* Cards & Grids */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin: 14px 0;
}

.hero {
  background: linear-gradient(135deg, #172e36 0%, #141e2f 60%, #1f1d36 100%);
  border: 1px solid #355863;
  border-radius: 24px;
  padding: 24px;
  margin: 16px 0;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.28);
}

.hero h2 {
  font-size: 28px;
  margin: 6px 0;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.flex {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

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

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

/* Badges & Chips */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 999px;
  background: #213247;
  color: #c9e2f5;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 11px;
}

.chip.emerald {
  background: var(--emerald-soft);
  color: var(--emerald);
  border: 1px solid rgba(56, 242, 184, 0.3);
}

.chip.indigo {
  background: var(--indigo-soft);
  color: #c5bfff;
  border: 1px solid rgba(146, 138, 255, 0.3);
}

.chip.amber {
  background: var(--amber-soft);
  color: var(--amber);
  border: 1px solid rgba(247, 185, 85, 0.35);
}

.chip.danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.listitem {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.listitem:last-child {
  border-bottom: 0;
}

/* Alerts & Banners */
.notice {
  border-left: 3px solid var(--indigo);
  background: rgba(146, 138, 255, 0.1);
  padding: 12px 15px;
  border-radius: 10px;
  color: #dcd8ff;
  margin: 12px 0;
}

.backoff-banner {
  border-left: 4px solid var(--amber);
  background: rgba(247, 185, 85, 0.12);
  padding: 14px 16px;
  border-radius: 14px;
  margin: 12px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.readonly-banner {
  background: linear-gradient(90deg, rgba(146, 138, 255, 0.2), rgba(56, 242, 184, 0.12));
  border: 1px solid rgba(146, 138, 255, 0.45);
  border-radius: 16px;
  padding: 14px 18px;
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.net-error-toast {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: #3a121b;
  border: 1px solid var(--danger);
  color: #ffd6dc;
  padding: 12px 18px;
  border-radius: 14px;
  z-index: 100;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.55);
  max-width: 92vw;
  font-weight: 600;
}

/* Workout & Set Cards */
.ex-pills {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 4px 0 10px;
}

.ex-pill {
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 12px;
  white-space: nowrap;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.ex-pill.current {
  border-color: var(--emerald);
  color: var(--emerald);
  background: var(--emerald-soft);
}

.ex-pill.done {
  background: #14332a;
  color: var(--emerald);
}

.cue-box {
  padding: 14px 16px;
  border: 1px dashed #3a5472;
  border-radius: 14px;
  background: #0e1724;
  margin: 12px 0;
}

.set-card {
  padding: 16px;
  margin: 12px 0;
  border-radius: 18px;
  background: #0e1622;
  border: 1px solid var(--border);
  transition: border-color 0.2s ease;
}

.set-card.saved {
  border-color: #2f8569;
  background: linear-gradient(180deg, #0e1a22 0%, #0d1d1c 100%);
}

.set-card.unsaved {
  border-style: dashed;
  border-color: #465a75;
}

.set-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  gap: 8px;
  flex-wrap: wrap;
}

.set-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 86px;
  gap: 10px;
}

.numrow {
  display: flex;
  gap: 6px;
  align-items: center;
}

.numrow button {
  flex: 0 0 42px;
  height: 44px;
  padding: 0;
  display: grid;
  place-content: center;
  font-size: 18px;
  font-weight: 800;
}

.numrow input {
  text-align: center;
  font-size: 19px;
  font-weight: 800;
  height: 44px;
  padding: 6px 4px;
}

/* Days Selector */
.days-picker {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.day-btn {
  flex: 1;
  min-width: 44px;
  text-align: center;
  padding: 10px 6px;
  border-radius: 11px;
  font-size: 13px;
  background: #0c121c;
}

.day-btn.selected {
  background: var(--emerald);
  color: var(--emerald-dark);
  border-color: var(--emerald);
  font-weight: 800;
}

/* Catalog Grid */
.catalogue-top {
  display: grid;
  grid-template-columns: 1fr 180px 160px;
  gap: 10px;
}

.catalogue-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.ex-tile {
  background: #121c2b;
  border: 1px solid var(--border);
  border-radius: 17px;
  padding: 16px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  transition: border-color 0.15s ease, transform 0.1s ease;
}

.ex-tile:hover {
  border-color: var(--emerald);
}

/* Bottom Sheet & Modal */
.sheetbg {
  position: fixed;
  inset: 0;
  background: rgba(3, 6, 12, 0.82);
  backdrop-filter: blur(6px);
  z-index: 40;
  display: flex;
  justify-content: center;
  align-items: flex-end;
}

.sheet {
  background: #111a28;
  border: 1px solid #354c68;
  border-radius: 24px 24px 0 0;
  padding: 20px;
  width: min(780px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  padding-bottom: calc(26px + env(safe-area-inset-bottom));
}

.sheethead {
  position: sticky;
  top: -20px;
  background: #111a28;
  padding: 12px 0;
  z-index: 3;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}

/* Fullscreen Timer Watch */
.timerbg {
  position: fixed;
  inset: 0;
  background: rgba(4, 7, 13, 0.9);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}

.timerbox {
  width: min(420px, 100%);
  text-align: center;
  background: #111a27;
  border: 2px solid #2e4760;
  border-radius: 28px;
  padding: 28px 22px;
  transition: box-shadow 0.25s ease, border-color 0.25s ease;
}

.timerbox.finished {
  border-color: var(--emerald);
  box-shadow: 0 0 55px rgba(56, 242, 184, 0.45);
}

.clock-ring {
  width: 230px;
  height: 230px;
  margin: 16px auto 22px;
  border-radius: 50%;
  border: 10px solid var(--emerald);
  display: grid;
  place-content: center;
  font-size: 54px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  background: radial-gradient(circle, #162436 0%, #0d1520 100%);
}

.clock-ring small {
  font-size: 12px;
  letter-spacing: 2.5px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(13, 19, 30, 0.94);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  z-index: 25;
  padding: 6px max(6px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom));
}

.bottom-nav button {
  background: transparent;
  border: 0;
  color: var(--text-muted);
  flex: 1;
  max-width: 150px;
  padding: 6px 2px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 10px;
}

.bottom-nav button.active {
  color: var(--emerald);
}

.bottom-nav b {
  display: block;
  font-size: 20px;
  line-height: 1.3;
}

@media (max-width: 640px) {
  .grid, .grid-3, .catalogue-grid, .catalogue-top {
    grid-template-columns: 1fr;
  }
  .set-grid {
    grid-template-columns: 1fr 1fr 70px;
  }
  .numrow button {
    flex-basis: 36px;
  }
  .hero h2 {
    font-size: 24px;
  }
  .bottom-nav button {
    font-size: 10px;
    padding: 5px 1px;
  }
  .bottom-nav b {
    font-size: 18px;
  }
}

/* =========================================================================
   3D BIOMECHANICAL GIFS & STRUCTURED MOVEMENT RECOMMENDATIONS
   ========================================================================= */
.gif-3d-frame {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid #2b4561;
  background: #0a1019;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 12px 0;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.38);
}

.gif-3d-frame img {
  width: 100%;
  max-width: 390px;
  height: auto;
  display: block;
  border-radius: 12px;
}

.gif-3d-thumb {
  width: 100%;
  height: 155px;
  border-radius: 13px;
  overflow: hidden;
  border: 1px solid #263c56;
  background: #0b111b;
  position: relative;
}

.gif-3d-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gif-3d-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(11, 18, 28, 0.85);
  border: 1px solid rgba(56, 242, 184, 0.45);
  color: var(--emerald);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.7px;
  padding: 3px 8px;
  border-radius: 999px;
}

.movement-guide-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0;
}

.movement-guide-item {
  background: #0d1623;
  border: 1px solid #24374f;
  border-radius: 13px;
  padding: 12px 14px;
}

.movement-guide-item .mg-title {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--emerald);
  margin-bottom: 5px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.movement-guide-item.warn .mg-title {
  color: var(--amber);
}

.movement-guide-item p {
  font-size: 13px;
  line-height: 1.45;
  color: #dce7f5;
  margin: 0;
}

/* =========================================================================
   NUTRITION & MACRONUTRITION DASHBOARD
   ========================================================================= */
.nutri-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.nutri-kpi {
  background: #0e1726;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 12px;
  text-align: center;
}

.nutri-kpi .val {
  font-size: 22px;
  font-weight: 900;
  color: var(--text);
  margin: 4px 0 2px;
}

.nutri-kpi.highlight {
  border-color: rgba(56, 242, 184, 0.5);
  background: linear-gradient(180deg, rgba(56, 242, 184, 0.12), #0e1726);
}

.nutri-kpi.highlight .val {
  color: var(--emerald);
}

.macro-bar-stack {
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  display: flex;
  background: #0b111c;
  margin: 10px 0 8px;
  border: 1px solid #253850;
}

.macro-seg-prot {
  background: #38f2b8;
}

.macro-seg-carb {
  background: #928aff;
}

.macro-seg-fat {
  background: #f7b955;
}

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

.macro-pillar {
  background: #0c1420;
  border: 1px solid #22344b;
  border-radius: 12px;
  padding: 10px;
  text-align: center;
}

.macro-pillar b {
  display: block;
  font-size: 18px;
  font-weight: 900;
}

.day-card-on {
  border-color: rgba(56, 242, 184, 0.45);
  background: linear-gradient(165deg, rgba(56, 242, 184, 0.08) 0%, #111a28 65%);
}

.day-card-off {
  border-color: rgba(146, 138, 255, 0.45);
  background: linear-gradient(165deg, rgba(146, 138, 255, 0.08) 0%, #111a28 65%);
}

.meal-slot-card {
  background: #0e1724;
  border: 1px solid #25374f;
  border-radius: 14px;
  padding: 13px 15px;
  margin: 8px 0;
}

@media (max-width: 640px) {
  .movement-guide-grid {
    grid-template-columns: 1fr;
  }
  .nutri-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

