/* ═══════════════════════════════════════════════
   DESIGN TOKENS — Tempa v1.2.10
   ═══════════════════════════════════════════════ */
:root {
  /* Surfaces */
  --bg:       #0E1312;
  --s1:       #151B19;
  --s2:       #1C2421;
  --s3:       #26302B;
  --line:     #2C3531;
  --line2:    #3A453F;
  --backdrop: #0A0E0D; /* behind the app column on tablet and desktop */

  /* Text */
  --t-hi:     #EDF0EE;
  --t-mid:    #A6AEAB;
  --t-lo:     #848D88; /* ≥4.5:1 on --bg and --s2, so small meta text stays legible */
  --t-dis:    #474F4B;

  /* Emerald Scale */
  --em600:    #00674F;
  --em500:    #007E60;
  --em400:    #16A37C;
  --em300:    #36C79B;
  --em-tint:  #16A37C1F;
  --em300-tint: #36C79B24;

  /* Forge-Heat Accents */
  --steel:    #6E93B0;
  --amber:    #E0A23C;
  --ember:    #E2562B;
  --copper:   #C16E4E;
  --red:      #DD4B3A;

  /* Chart */
  --chart:    #3E4A45;
  /* Categorical chart slots, in this order; validated for CVD and 3:1 on --s1 */
  --viz-1:    #16A37C;
  --viz-2:    #5B8FD6;
  --viz-3:    #C16E4E;
  /* Metric colours: one fixed colour per metric on every screen that shows it */
  --m-dur:    var(--em300);
  --m-vol:    var(--viz-2);
  --m-sets:   var(--copper);
  --m-pr:     var(--amber);
  --m-rest:   var(--steel);

  /* CTA */
  --cta-ink:  #F2FBF8;

  /* Layout */
  --app-max:  560px;
  --nav-h:    calc(68px + env(safe-area-inset-bottom, 0px));

  /* Fonts */
  --ff-d: 'Space Grotesk', sans-serif;
  --ff-b: 'General Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --ff-m: 'JetBrains Mono', monospace;

  /* Type scale — the only font sizes client and coach pages use.
     11 is for uppercase/mono labels and badges only; running text starts at 12. */
  --fs-label:   11px;
  --fs-caption: 12px;
  --fs-meta:    13px;
  --fs-sm:      14px;
  --fs-body:    15px;
  --fs-lg:      16px;
  --fs-title:   18px;
  --fs-h2:      22px;
  --fs-h1:      28px;
  --fs-display: 36px; /* stat numbers */
  --fs-hero:    48px; /* one headline number per screen */

  /* Legacy aliases — migrate pages to canonical tokens above */
  --paper: var(--s1);
  --card: var(--s2);
  --ink: var(--t-hi);
  --ink2: var(--t-mid);
  --muted: var(--t-lo);
  --emerald: var(--em400);
  --emerald-ignition: var(--em500);
  --emerald-deep: var(--em600);
}
/* ═══════════════════════════════════════════════
   THEMES (Profil → Tampilan). Forge is :root above. Every theme keeps the meaning of colour:
   --em500 is the primary button; --em300/--em400 stay green for Online and success; --copper is Onsite;
   --amber is "needs action". Chosen on <html data-theme="…"> by parts/favicon.php.
   ═══════════════════════════════════════════════ */
:root { color-scheme: dark; }
:root[data-theme="daylight"] {
  color-scheme: light;
  --bg: #F4F6F5; --s1: #FFFFFF; --s2: #EDF1EF; --s3: #DDE4E0; --line: #E0E6E3; --line2: #C9D2CD; --backdrop: #E3E8E5;
  --t-hi: #111D18; --t-mid: #46534D; --t-lo: #5F6B65; --t-dis: #A3ACA7;
  --em600: #005C46; --em500: #007E60; --em400: #0B8A67; --em300: #007A5C; --em-tint: #007E601A; --em300-tint: #007A5C1F;
  --steel: #45708F; --amber: #9A6208; --ember: #B9411A; --copper: #A24F2E; --red: #BF3626;
  --chart: #D4DBD7; --viz-1: #0B8A67; --viz-2: #3567B5; --viz-3: #A24F2E;
  --cta-ink: #FFFFFF;
}
:root[data-theme="berry"] {
  color-scheme: light;
  --bg: #FAF7F2; --s1: #FFFFFF; --s2: #F2ECE3; --s3: #E4DACB; --line: #E8E0D4; --line2: #D5C9B8; --backdrop: #EEE7DC;
  --t-hi: #2A0E1F; --t-mid: #5C4350; --t-lo: #75606B; --t-dis: #B8AAB1;
  --em600: #561339; --em500: #6B1A48; --em400: #0E7F60; --em300: #0B7759; --em-tint: #0E7F601A; --em300-tint: #0B77591F;
  --steel: #4F6F8A; --amber: #9A6208; --ember: #B4421C; --copper: #A0502F; --red: #B8352A;
  --chart: #DDD3C5; --viz-1: #0E7F60; --viz-2: #3D63A8; --viz-3: #A0502F;
  --cta-ink: #FAF7F2;
}
:root[data-theme="peach"] {
  color-scheme: light;
  --bg: #FFF6F1; --s1: #FFFFFF; --s2: #FCE9DF; --s3: #F5D6C6; --line: #F4E0D5; --line2: #E8C8B7; --backdrop: #F6E6DC;
  --t-hi: #3A2018; --t-mid: #67463A; --t-lo: #7F6054; --t-dis: #C2A89D;
  --em600: #B4442D; --em500: #CF5238; --em400: #0E7F60; --em300: #0B7759; --em-tint: #0E7F601A; --em300-tint: #0B77591F;
  --steel: #4F6F8A; --amber: #9A6208; --ember: #B4421C; --copper: #8E5A2B; --red: #B8352A;
  --chart: #F0D9CC; --viz-1: #0E7F60; --viz-2: #3D63A8; --viz-3: #8E5A2B;
  --cta-ink: #FFFFFF;
}


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

html {
  background: var(--bg);
  min-height: 100vh;
  min-height: 100dvh;
}

body {
  font-family: var(--ff-b);
  color: var(--t-mid);
  font-size: var(--fs-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ── Centered form wrapper ── */
.wrap {
  max-width: 520px;
  margin: auto;
  width: 100%;
  padding: 24px 20px;
}

/* ── Card (form container) ── */
.card {
  background: var(--s1);
  border-radius: 12px;
  padding: clamp(32px, 5vw, 48px);
  border: 1px solid var(--line);
}

.card h1 {
  font-family: var(--ff-d);
  font-weight: 700;
  font-size: clamp(1.5rem, 4vw, 2rem);
  letter-spacing: -.025em;
  line-height: 1.1;
  margin-bottom: 8px;
  color: var(--t-hi);
}

.card > p {
  color: var(--t-mid);
  font-size: var(--fs-body);
  line-height: 1.6;
  margin-bottom: 28px;
}

/* ── Logo inside card ── */
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
  text-decoration: none;
  color: var(--t-hi);
}

.logo svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  color: var(--em400);
}

.logo span {
  font-family: var(--ff-d);
  font-weight: 700;
  font-size: var(--fs-title);
  letter-spacing: -.02em;
}

.logo img {
  height: 18px;
  width: auto;
  display: block;
}

/* ── App bar (dashboard pages) ── */
.appbar {
  background: var(--bg);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  color: var(--t-hi);
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--line);
}

.appbar-group {
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 10;
}

.appbar-stack {
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
}

.appbar-titles {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.appbar-title {
  font-family: var(--ff-d);
  font-weight: 700;
  font-size: var(--fs-title);
  color: var(--t-hi);
  letter-spacing: -.01em;
  line-height: 1.3;
}

.appbar-subtitle {
  font-size: var(--fs-caption);
  color: var(--t-mid);
  line-height: 1.45;
}

.appbar.spread {
  justify-content: space-between;
}

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

.appbar .brand svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--t-hi);
}

.appbar .brand img {
  height: 18px;
  width: auto;
  display: block;
}

.appbar .logout {
  font-size: var(--fs-caption);
  font-weight: 600;
  color: var(--t-mid);
  text-decoration: none;
  padding: 6px 12px;
  border: 1px solid var(--line2);
  border-radius: 5px;
  transition: all .15s;
}

.appbar .logout:hover {
  color: var(--cta-ink);
  border-color: var(--t-lo);
}

/* ── Dashboard layout ── */
.dash {
  padding: 24px 20px;
  flex: 1;
  overflow-y: auto;
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
}

.page-title {
  font-family: var(--ff-d);
  font-weight: 700;
  font-size: var(--fs-h2);
  letter-spacing: -.025em;
  margin-bottom: 20px;
  color: var(--t-hi);
}

/* ── Form fields ── */
.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-family: var(--ff-m);
  font-size: var(--fs-label);
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--t-lo);
  margin-bottom: 6px;
}

.input {
  width: 100%;
  height: 48px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  font-family: var(--ff-b);
  font-size: var(--fs-body);
  color: var(--t-hi);
  background: var(--s1);
  outline: none;
  transition: border-color .2s;
  -webkit-appearance: none;
  box-sizing: border-box;
}

.input:focus {
  border-color: var(--em400);
  background: var(--s2);
}

.input::placeholder {
  color: var(--t-dis);
}

textarea.input {
  height: auto;
  min-height: 80px;
  padding: 12px 16px;
  resize: vertical;
  font-family: var(--ff-b);
}

select.input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236C7570' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 44px;
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ── Radio List ── */
.radio-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.radio-list.radio-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.radio-item {
  position: relative;
}

.radio-item input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.radio-item label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  cursor: pointer;
  font-size: var(--fs-sm);
  font-weight: 500;
  font-family: var(--ff-b);
  text-transform: none;
  letter-spacing: normal;
  color: var(--t-mid);
  background: var(--s1);
  transition: all .2s;
  user-select: none;
  min-height: 48px;
}

.radio-item label .r-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--t-lo);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .2s;
}

.radio-item label .r-dot::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--t-hi);
  opacity: 0;
  transition: opacity .15s;
}

.radio-item input:checked + label {
  border-color: var(--t-hi);
  background: var(--s2);
  color: var(--t-hi);
}

.radio-item input:checked + label .r-dot {
  border-color: var(--t-hi);
}

.radio-item input:checked + label .r-dot::after {
  opacity: 1;
}

/* ── Check List ── */
.check-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.check-item {
  position: relative;
}

.check-item input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.check-item label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: 9px;
  cursor: pointer;
  font-size: var(--fs-sm);
  font-weight: 500;
  font-family: var(--ff-b);
  text-transform: none;
  letter-spacing: normal;
  color: var(--t-mid);
  background: var(--s1);
  transition: all .2s;
  user-select: none;
  min-height: 42px;
}

.check-item label:hover {
  border-color: var(--em400);
}

.check-item label .c-box {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  border: 1.5px solid var(--line2);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .2s;
  background: var(--s1);
}

.check-item label .c-box::after {
  content: "";
  width: 10px;
  height: 6px;
  border-left: 2px solid var(--t-hi);
  border-bottom: 2px solid var(--t-hi);
  transform: rotate(-45deg);
  margin-top: -2px;
  opacity: 0;
  transition: opacity .15s;
}

.check-item input:checked + label {
  border-color: var(--em400);
  background: var(--em-tint);
  color: var(--t-hi);
}

.check-item input:checked + label .c-box {
  border-color: var(--em400);
  background: var(--em400);
}

.check-item input:checked + label .c-box::after {
  opacity: 1;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 52px;
  padding: 12px 20px;
  border-radius: 999px;
  font-family: var(--ff-d);
  font-weight: 600;
  font-size: var(--fs-body);
  border: none;
  cursor: pointer;
  transition: all .2s;
  background: var(--em500);
  color: var(--cta-ink);
  margin-top: 6px;
  text-decoration: none;
}

.btn:hover {
  background: var(--em600);
}

.btn:active {
  transform: scale(.97);
}

.btn:disabled {
  opacity: .5;
  cursor: not-allowed;
  transform: none;
}

.btn-outline {
  background: transparent;
  color: var(--t-hi);
  border: 1.5px solid var(--line2);
}

.btn-outline:hover {
  border-color: var(--em400);
  background: var(--em-tint);
}

.btn-ghost {
  background: transparent;
  color: var(--em400);
}

.btn-destructive {
  background: color-mix(in srgb, var(--red) 15%, transparent);
  color: var(--red);
  border: 1px solid color-mix(in srgb, var(--red) 25%, transparent);
}

.btn-sm {
  width: auto;
  padding: 7px 14px;
  font-size: var(--fs-meta);
  border-radius: 7px;
}

/* ── Password Toggle ── */
.pw-wrap {
  position: relative;
}

.pw-wrap .input {
  padding-right: 44px;
}

.pw-toggle {
  position: absolute;
  right: 1px;
  top: 1px;
  bottom: 1px;
  width: 36px;
  border: none;
  background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--t-lo);
  border-radius: 0 8px 8px 0;
  transition: color .15s;
  font-size: var(--fs-title);
  line-height: 1;
  padding: 0;
}

.pw-toggle:hover {
  color: var(--t-hi);
}

/* ── Messages ── */
.msg {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: var(--fs-sm);
  line-height: 1.5;
  margin-bottom: 20px;
  display: none;
}

.msg.show {
  display: block;
}

.msg.success {
  background: color-mix(in srgb, var(--em400) 12%, transparent);
  color: var(--em300);
  border: 1px solid color-mix(in srgb, var(--em400) 20%, transparent);
}

.msg.error {
  background: color-mix(in srgb, var(--red) 12%, transparent);
  color: var(--red);
  border: 1px solid color-mix(in srgb, var(--red) 20%, transparent);
}

/* ── Misc ── */
.hint {
  font-size: var(--fs-caption);
  color: var(--t-lo);
  margin-top: 4px;
}

.badge {
  display: inline-block;
  font-family: var(--ff-m);
  font-size: var(--fs-label);
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.badge.active {
  background: color-mix(in srgb, var(--em400) 15%, transparent);
  color: var(--em400);
}

.switch-link {
  text-align: center;
  margin-top: 20px;
  font-size: var(--fs-meta);
  color: var(--t-mid);
}

.switch-link a {
  color: var(--em400);
  font-weight: 600;
  text-decoration: none;
}

.switch-link a:hover {
  text-decoration: underline;
}

/* ── Utility ── */
.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.label-hint {
  font-family: var(--ff-m);
  font-size: var(--fs-label);
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--t-lo);
}

/* ── Opt Pill (select button) ── */
.opt-pill {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 14px;
  border-radius: 999px;
  height: 44px;
  width: max-content;
  background: var(--s2);
  border: 1.5px solid var(--line);
  cursor: pointer;
  transition: border-color .15s;
  font-size: var(--fs-sm);
  color: var(--t-mid);
  font-weight: 500;
  user-select: none;
}

/* Selected = light pill, so emerald stays for the screen's one primary action. */
.opt-pill:has(input:checked) {
  border-color: var(--t-hi);
  color: var(--bg);
  background: var(--t-hi);
  font-weight: 600;
}

.opt-pill input { display: none; }

/* Segmented variant (less rounding, for side-by-side choices) */
.opt-pill-seg { border-radius: 999px; }

/* Flex-wrap grid for pills */
.opt-pill-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ── Opt Checkbox (checkbox card) ── */
.opt-cb {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--s1);
  border: 1.5px solid var(--line);
  cursor: pointer;
  transition: border-color .15s;
  font-size: var(--fs-meta);
  color: var(--t-mid);
  font-weight: 500;
  user-select: none;
}

.opt-cb:has(input:checked) {
  border-color: var(--t-hi);
  color: var(--t-hi);
  background: var(--s2);
}

.opt-cb input { display: none; }

.cb-box {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  border-radius: 5px;
  border: 1.5px solid var(--t-lo);
  background: var(--s1);
  position: relative;
  transition: border-color .15s, background .15s;
}

.opt-cb:has(input:checked) .cb-box {
  border-color: var(--t-hi);
  background: var(--t-hi);
}

.opt-cb:has(input:checked) .cb-box::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 5px;
  width: 5px;
  height: 9px;
  border: solid var(--bg);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* 2-column grid for checkbox cards */
.opt-cb-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* ── Progress Segments ── */
.progress {
  display: flex;
  gap: 4px;
}

.progress-seg {
  flex: 1;
  height: 3px;
  border-radius: 2px;
  background: var(--s3);
}

.progress-seg.filled { background: var(--steel); }

/* ── Back Button (rounded box) ── */
.back-btn {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 12px;
  background: var(--s1);
  border: 1px solid var(--line);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--t-hi);
  text-decoration: none;
}

.back-btn:active { opacity: .7; }
.back-btn[hidden] { visibility: hidden; }

/* ── Tempa Header (onboarding / nav style) ── */
.tempa-header {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 16px 12px;
  min-height: 56px;
  background: var(--bg);
}

.tempa-title {
  position: absolute;
  /* clear the 40px back/close buttons on both sides; long names (exercise titles) end in … */
  left: 64px; right: 64px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  pointer-events: none;
  font-family: var(--ff-d);
  font-size: var(--fs-title);
  font-weight: 700;
  color: var(--t-hi);
  letter-spacing: -.01em;
}

/* ── Bottom Bar (fixed CTA) ── */
.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 3;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px));
}

/* ── Bottom Navigation ── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 90;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  min-height: var(--nav-h);
  background: color-mix(in srgb, var(--bg) 96%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding: 6px 4px calc(12px + env(safe-area-inset-bottom, 0px));
}

.bottom-nav--5 {
  grid-template-columns: repeat(5, 1fr);
}

/* Installed web app (Add to Home Screen) only. Without viewport-fit=cover the safe-area insets read 0,
   yet iOS still overlays the status bar blur at the top and the home indicator at the bottom. */
@media (display-mode: standalone) {
  /* iOS draws a soft blur under the status bar that reaches ~30px into the page (seen on the Beranda
     date and avatar, clear only while pulling down). Start content below it; the blur then covers
     plain background only. */
  body { padding-top: 20px; }
  :root { --nav-h: calc(82px + env(safe-area-inset-bottom, 0px)); }
  .bottom-nav { padding-bottom: max(26px, calc(12px + env(safe-area-inset-bottom, 0px))); }
  .ui-cta { padding-bottom: max(26px, calc(14px + env(safe-area-inset-bottom, 0px))); }
}

.bottom-nav__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: color .2s;
}

.bottom-nav__icon {
  width: 24px;
  height: 24px;
  box-sizing: content-box;
  padding: 4px 16px;
  border-radius: 999px;
  color: var(--t-lo);
  transition: color .2s, background-color .2s;
}

.bottom-nav__label {
  font-family: var(--ff-b);
  font-size: var(--fs-label);
  font-weight: 500;
  letter-spacing: .01em;
  line-height: 1;
  color: var(--t-lo);
  transition: color .2s;
}

/* Active state */
.bottom-nav__item.is-active .bottom-nav__icon {
  color: var(--t-hi);
  background: var(--s3);
}

.bottom-nav__item.is-active .bottom-nav__label {
  color: var(--t-hi);
}

/* ── Mobile: full-screen card ── */
@media (max-width: 480px) {
  .wrap {
    padding: 0;
  }

  .card {
    border: none;
    border-radius: 0;
  }
}


/* ═══════════════════════════════════════════════
   APP COLUMN — tablets & desktop
   The app keeps a phone-width reading column so lines stay short.
   ═══════════════════════════════════════════════ */
@media (min-width: 640px) {
  html {
    background: var(--backdrop);
  }

  body {
    width: 100%;
    max-width: var(--app-max);
    margin: 0 auto;
    background: var(--bg);
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
    box-shadow: 0 0 60px rgba(0, 0, 0, .35);
  }

  /* Fixed bars stay inside the column. !important beats inline left/right:0. */
  .bottom-nav, .bottom-bar, .sp-fixed, .ses-bottom, .ex-bottom, .sel-bottom, .gp-bottom,
  .detail-fixed, .detail-fixed--builder, .new-ex-bottom, .bk-bottom, .cp-bottom {
    left: max(0px, calc(50% - var(--app-max) / 2 + 1px)) !important;
    right: max(0px, calc(50% - var(--app-max) / 2 + 1px)) !important;
  }
}

/* Coach nav extras: only shown as a rail (tablet) or sidebar (PC). */
.bottom-nav__brand, .bottom-nav__me { display: none; }
.bottom-nav--wide-only { display: none; }

/* ═══════════════════════════════════════════════
   COACH APP — tablet & PC (body.coach-page)
   The coach works at a desk too, so the app fills the screen instead of a phone column:
   600–1023px a rail on the left, 1024px and up a sidebar (Material: rail for medium, drawer
   for expanded; Apple HIG: a sidebar replaces the tab bar on iPad). Content is a centred
   column (--cw-max) beside the nav; screens that use two columns set body.cw-wide.
   ═══════════════════════════════════════════════ */
@media (min-width: 600px) {
  body.coach-page {
    --cw-nav: 0px;
    --cw-max: 760px;
    max-width: none;
    margin: 0;
    border: 0;
    box-shadow: none;
  }
  body.coach-page.cw-wide { --cw-max: 1180px; }
  body.coach-page:has(.bottom-nav--coach) { --cw-nav: 88px; padding-left: var(--cw-nav); }
  body.coach-page .coach-scroll {
    box-sizing: border-box;
    max-width: var(--cw-max);
    margin: 0 auto;
    padding: 24px 24px 48px;
  }
  /* Sub-pages with their own wrapper keep the same centred column. */
  body.coach-page > main, body.coach-page .detail-page, body.coach-page .gp-page, body.coach-page .rc-page,
  body.coach-page .lg-page, body.coach-page .sp, body.coach-page main.vr, body.coach-page main.vd,
  body.coach-page main.rv, body.coach-page main.rd, body.coach-page main.ce {
    box-sizing: border-box;
    width: 100%;
    max-width: var(--cw-max);
    margin-left: auto;
    margin-right: auto;
  }
  /* Fixed bars sit under the content column, beside the nav. */
  body.coach-page .bottom-bar, body.coach-page .sp-fixed, body.coach-page .ses-bottom, body.coach-page .ex-bottom,
  body.coach-page .sel-bottom, body.coach-page .gp-bottom, body.coach-page .detail-fixed, body.coach-page .detail-fixed--builder,
  body.coach-page .new-ex-bottom, body.coach-page .bk-bottom, body.coach-page .cp-bottom, body.coach-page .lg-bottom {
    left: calc(var(--cw-nav) + max(0px, (100% - var(--cw-nav) - var(--cw-max)) / 2)) !important;
    right: max(0px, (100% - var(--cw-nav) - var(--cw-max)) / 2) !important;
    max-width: none;
  }
  body.coach-page .bottom-bar { bottom: 0; }

  /* Rail */
  body.coach-page .bottom-nav--coach {
    top: 0;
    bottom: 0;
    left: 0 !important;
    right: auto !important;
    width: var(--cw-nav);
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 18px 8px;
    box-sizing: border-box;
    border-top: 0;
    border-right: 1px solid var(--line);
    background: var(--bg);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  body.coach-page .bottom-nav--coach { z-index: 40; }
  body.coach-page .bottom-nav--wide-only { display: flex; }
  /* Bottom sheets of the coach pages open in the middle on a wide screen. */
  body.coach-page .sp-overlay, body.coach-page .lg-sheet, body.coach-page .sp-dialog-overlay { align-items: center; }
  body.coach-page .sp-overlay .sp-sheet, body.coach-page .lg-sheet > div { border-radius: 20px; max-width: 480px; }
  body.coach-page .bottom-nav--coach .bottom-nav__item { padding: 8px 0; }
  body.coach-page .bottom-nav--coach .bottom-nav__brand { display: flex; justify-content: center; padding: 0 0 18px; }
  body.coach-page .bottom-nav--coach .bottom-nav__logo { display: none; }
  body.coach-page .bottom-nav--coach .bottom-nav__mark { width: 30px; height: 30px; object-fit: contain; }
  body.coach-page .bottom-nav--coach .bottom-nav__item:hover .bottom-nav__icon { color: var(--t-hi); }

  /* Sheets open as a dialog in the middle instead of a full-width sheet. */
  body.coach-page .td-sheet, body.coach-page .sp-sheet { max-width: 440px; margin: 0 auto; }
}

@media (min-width: 1024px) {
  body.coach-page:has(.bottom-nav--coach) { --cw-nav: 232px; }
  body.coach-page .coach-scroll { padding: 28px 32px 56px; }
  body.coach-page.cw-wide .bottom-bar { display: flex; justify-content: flex-end; background: transparent; pointer-events: none; }
  body.coach-page.cw-wide .bottom-bar > * { width: auto !important; min-width: 260px; pointer-events: auto; }
  body.coach-page .bottom-nav--coach { padding: 22px 14px; gap: 2px; }
  body.coach-page .bottom-nav--coach .bottom-nav__brand { justify-content: flex-start; padding: 0 12px 24px; }
  body.coach-page .bottom-nav--coach .bottom-nav__logo { display: block; height: 18px; width: auto; }
  body.coach-page .bottom-nav--coach .bottom-nav__mark { display: none; }
  body.coach-page .bottom-nav--coach .bottom-nav__item {
    flex-direction: row;
    justify-content: flex-start;
    gap: 12px;
    height: 44px;
    padding: 0 12px;
    border-radius: 12px;
  }
  body.coach-page .bottom-nav--coach .bottom-nav__icon { padding: 0; background: none !important; }
  body.coach-page .bottom-nav--coach .bottom-nav__item.is-active { background: var(--s2); }
  body.coach-page .bottom-nav--coach .bottom-nav__item:hover { background: var(--s1); }
  body.coach-page .bottom-nav--coach .bottom-nav__item.is-active:hover { background: var(--s2); }
  body.coach-page .bottom-nav--coach .bottom-nav__label { font-size: var(--fs-sm); font-weight: 600; }
  body.coach-page .bottom-nav--coach .bottom-nav__me {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: auto;
    padding: 14px 12px 0;
    border-top: 1px solid var(--line);
    text-decoration: none;
  }
  body.coach-page .bottom-nav__me span {
    width: 32px;
    height: 32px;
    flex: none;
    border-radius: 50%;
    background: var(--s2);
    display: flex;
    align-items: center;
    justify-content: center;
    font: 600 var(--fs-caption) var(--ff-d);
    color: var(--t-hi);
  }
  body.coach-page .bottom-nav__me b {
    min-width: 0;
    font: 600 var(--fs-caption) var(--ff-b);
    color: var(--t-mid);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* Shared small uppercase label (dates, section kickers) */
.app-kicker, .coach-kicker {
  font-family: var(--ff-m);
  font-size: var(--fs-label);
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--t-lo);
}

/* Coach sub-page top bars use the same back button as the client app bar */
.detail-top > a:first-child, .ses-top > a:first-child, .ex-top > a:first-child,
.sel-top > a:first-child, .gp-top > a:first-child, .rc-top > a:first-child {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--s1);
  border: 1px solid var(--line);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--t-hi);
  font-size: var(--fs-h2) !important;
  line-height: 1 !important;
  padding-bottom: 3px;
  text-decoration: none;
  position: relative;
  z-index: 1;
}

/* Horizontal pill rows scroll without a visible scrollbar */
.coach-pills { scrollbar-width: none; }
.coach-pills::-webkit-scrollbar { display: none; }

.ses-top, .ex-top, .sel-top, .gp-top, .rc-top { margin-bottom: 10px; }

/* Placeholders must not look like filled-in values */
input::placeholder, textarea::placeholder { color: var(--t-dis); font-style: italic; opacity: 1; }

/* ═══════════════════════════════════════════════
   SHARED APP UI — one look for the client and coach apps
   Cards: --s1 fill, no outline, 20px radius. Outlines are kept for alerts,
   inputs and ghost buttons only. Tiles inside a card: --s2 fill, 14px radius.
   Title bar: .tempa-header (appbar-nav.php) on every page.
   ═══════════════════════════════════════════════ */
.app-home-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 16px 8px; background: var(--bg); }
.app-home-head__text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.app-greeting { font: 700 var(--fs-h2)/1.2 var(--ff-d); color: var(--t-hi); margin: 0; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-home-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.app-avatar { width: 44px; height: 44px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center; overflow: hidden; background: var(--s3); color: var(--t-hi); font: 600 var(--fs-sm) var(--ff-d); text-decoration: none; }
.app-avatar img { width: 100%; height: 100%; object-fit: cover; }
.app-section-label { font: 500 var(--fs-label) var(--ff-m); letter-spacing: .08em; text-transform: uppercase; color: var(--t-lo); margin: 20px 0 8px; }
.app-card { background: var(--s1); border-radius: 20px; padding: 16px; }
/* Pill search field; same look as .coach-search on the coach side */
.app-search { display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 14px; border-radius: 999px; background: var(--s2); color: var(--t-lo); }
.app-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--t-hi); font: var(--fs-body) var(--ff-b); }
.app-search input::placeholder { color: var(--t-lo); }
.app-bell { position: relative; display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; padding: 0; border: 0; background: none; color: var(--t-hi); cursor: pointer; flex: none; }
.app-bell svg { width: 24px; height: 24px; }
.app-bell__count { position: absolute; top: 1px; left: 21px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: var(--amber); color: #1a1405; font: 700 var(--fs-label)/16px var(--ff-b); text-align: center; border: 2px solid var(--bg); box-sizing: content-box; }

/* Profile pages and settings menus (client Profil, coach Profil) */
.app-profile-hero { display: flex; align-items: center; gap: 16px; padding: 4px 0 8px; }
.app-profile-avatar { position: relative; width: 72px; height: 72px; flex: none; padding: 0; border: 0; border-radius: 50%; background: var(--s3); color: var(--em400); display: flex; align-items: center; justify-content: center; overflow: visible; cursor: pointer; }
.app-profile-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.app-profile-avatar > svg { width: 38px; height: 38px; }
.app-profile-name { font: 700 var(--fs-h2)/1.25 var(--ff-d); color: var(--t-hi); margin: 0; }
.app-profile-sub { font-size: var(--fs-meta); color: var(--t-mid); margin: 4px 0 0; }
.app-menu { display: block; background: var(--s1); border-radius: 20px; padding: 0 16px; }
.app-menu-row { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-top: 1px solid var(--line); text-decoration: none; color: inherit; cursor: pointer; }
.app-menu-row:first-child { border-top: 0; }
.app-menu-icon { width: 36px; height: 36px; flex: none; border-radius: 10px; background: var(--s2); display: flex; align-items: center; justify-content: center; color: var(--t-hi); }
.app-menu-icon svg { width: 20px; height: 20px; }
.app-menu-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.app-menu-text strong, .app-menu-text p:first-child { font: 600 var(--fs-body)/1.3 var(--ff-d); color: var(--t-hi); margin: 0; }
.app-menu-text small, .app-menu-text p:last-child:not(:first-child) { font-size: var(--fs-caption); line-height: 1.4; color: var(--t-lo); margin: 0; }
.app-menu-chev { width: 18px; height: 18px; flex: none; color: var(--t-lo); }
.app-version { margin: 24px 0 8px; text-align: center; font: var(--fs-label) var(--ff-m); letter-spacing: .16em; text-transform: uppercase; color: var(--t-dis); }

/* Coach sub-page top bars match .tempa-header: same height, title size and back button */
html body .detail-top, html body .ses-top, html body .ex-top, html body .sel-top, html body .gp-top, html body .rc-top {
  height: auto; min-height: 56px; padding: 16px 0 12px; box-sizing: border-box; display: flex; align-items: center; position: relative;
}
html body .detail-top h1, html body .ses-top h1, html body .ex-top h1, html body .sel-top h1, html body .gp-top h1, html body .rc-top h1 {
  font: 700 var(--fs-title)/1.3 var(--ff-d); letter-spacing: -.01em; color: var(--t-hi);
}

/* Form field labels: same in both apps (onboarding style). Small uppercase mono stays for section labels. */
.app-field-label { display: block; font: 600 var(--fs-meta)/1.4 var(--ff-b); color: var(--t-hi); margin: 0 0 6px; letter-spacing: 0; text-transform: none; }

/* iOS data detectors: keep auto-linked numbers in the surrounding text style */
a[x-apple-data-detectors]{color:inherit!important;text-decoration:none!important;font:inherit!important;pointer-events:none}

/* ── UI standard (2026-11): shared pieces for client and coach ─────────────────────────── */

/* Round icon button (back, more). --glass sits over photos. */
.ui-iconbtn { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; flex: none; border-radius: 999px; background: var(--s2); border: 1px solid var(--line); color: var(--t-hi); text-decoration: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.ui-iconbtn svg { width: 22px; height: 22px; }
.ui-iconbtn--glass { background: color-mix(in srgb, var(--bg) 55%, transparent); border-color: color-mix(in srgb, var(--t-hi) 14%, transparent); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }

/* Photo hero: illustration fills the top, fades into the page, title sits on it. */
.ui-hero { position: relative; overflow: hidden; background: var(--s1); }
.ui-hero__img { display: block; width: 100%; height: 100%; object-fit: contain; }
.ui-hero__scrim { position: absolute; inset: 0; background: linear-gradient(180deg, color-mix(in srgb, var(--bg) 35%, transparent) 0%, color-mix(in srgb, var(--bg) 0%, transparent) 28%, color-mix(in srgb, var(--bg) 0%, transparent) 50%, var(--bg) 100%); pointer-events: none; }
.ui-hero__top { position: absolute; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; }
.ui-hero__body { position: absolute; left: 0; right: 0; bottom: 0; padding: 0 16px 14px; display: flex; flex-direction: column; gap: 4px; }
.ui-hero__meta { font: 500 var(--fs-caption) var(--ff-m); color: var(--t-mid); margin: 0; }
.ui-hero__title { font: 700 var(--fs-h2)/1.2 var(--ff-d); letter-spacing: -.01em; color: var(--t-hi); margin: 0; }

/* Chip row: scrolls sideways, edge-to-edge, last chip may be cut off on purpose. */
.ui-chips { display: flex; flex: none; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
.ui-chips::-webkit-scrollbar { display: none; }
.ui-chip { display: inline-flex; align-items: center; gap: 7px; flex: none; height: 40px; padding: 0 14px; border-radius: 999px; background: var(--s2); border: 1px solid var(--line); color: var(--t-hi); font: 600 var(--fs-sm) var(--ff-b); text-decoration: none; white-space: nowrap; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.ui-chip svg { width: 17px; height: 17px; flex: none; }
.ui-chip .ui-chip__num { font-family: var(--ff-m); font-weight: 600; }
.ui-chip__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--em300); flex: none; }

/* Stat: small label, big mono number in the metric's colour. */
.ui-stat { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ui-stat__label { font-size: var(--fs-meta); color: var(--t-mid); margin: 0; }
.ui-stat__value { font: 600 var(--fs-h1)/1.1 var(--ff-m); color: var(--t-hi); margin: 0; letter-spacing: -.02em; }
.ui-stat__unit { font-size: var(--fs-sm); font-weight: 500; margin-left: 2px; }
.ui-stat--dur .ui-stat__value { color: var(--m-dur); }
.ui-stat--vol .ui-stat__value { color: var(--m-vol); }
.ui-stat--sets .ui-stat__value { color: var(--m-sets); }
.ui-stat--pr .ui-stat__value { color: var(--m-pr); }
.ui-stat--rest .ui-stat__value { color: var(--m-rest); }

/* Segmented pill tabs for 2–4 views. */
.ui-tabs { display: flex; gap: 4px; padding: 4px; border-radius: 999px; background: var(--s1); border: 1px solid var(--line); }
.ui-tabs a, .ui-tabs button { flex: 1; display: flex; align-items: center; justify-content: center; height: 40px; border: 0; border-radius: 999px; background: transparent; color: var(--t-mid); font: 600 var(--fs-sm) var(--ff-b); text-decoration: none; cursor: pointer; }
.ui-tabs [aria-current="page"], .ui-tabs [aria-selected="true"] { background: var(--t-hi); color: var(--bg); }

/* Primary CTA footer: full-width pill in the thumb zone, page fades under it. */
.ui-cta { position: sticky; bottom: 0; z-index: 20; padding: 20px 16px calc(14px + env(safe-area-inset-bottom, 0px)); background: linear-gradient(180deg, color-mix(in srgb, var(--bg) 0%, transparent) 0%, var(--bg) 38%); }
.ui-cta__btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 54px; padding: 0 20px; border: 0; border-radius: 999px; background: var(--em500); color: var(--cta-ink); font: 600 var(--fs-lg) var(--ff-d); text-decoration: none; cursor: pointer; box-shadow: 0 8px 24px rgba(0, 0, 0, .35); }
.ui-cta__btn--light { background: var(--t-hi); color: var(--bg); }
.ui-cta__btn:disabled { opacity: .6; cursor: default; }

/* Segmented progress bar (week, session, program). */
.ui-progress { display: flex; gap: 4px; }
.ui-progress span { flex: 1; height: 5px; border-radius: 999px; background: var(--s3); }
.ui-progress span.is-done { background: var(--t-hi); }
.ui-progress span.is-now { background: var(--em400); }

/* Count of pending actions on a list row (coach Klien) */
.ca-count-pill { min-width: 26px; height: 26px; padding: 0 8px; box-sizing: border-box; border-radius: 999px; background: color-mix(in srgb, var(--amber) 16%, transparent); color: var(--amber); font: 700 var(--fs-caption) var(--ff-m); display: inline-flex; align-items: center; justify-content: center; flex: none; }

/* Coaching mode icon (online = screen, onsite = pin). Not a dot, so it doesn't read as "online now". */
.mode-ic { display: inline-block; flex: none; width: 12px; height: 12px; background: currentColor; -webkit-mask: var(--ic) center/contain no-repeat; mask: var(--ic) center/contain no-repeat; }
.mode-ic--on { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='2.5' y='4' width='19' height='13' rx='2.5'/%3E%3Cpath d='M8 21h8M12 17v4'/%3E%3C/svg%3E"); }
.mode-ic--os { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 21s7-6.2 7-11.5A7 7 0 0 0 5 9.5C5 14.8 12 21 12 21z'/%3E%3Ccircle cx='12' cy='9.5' r='2.5'/%3E%3C/svg%3E"); }
