/* Atlas — Cohesive Architectural Titanium & Signal Ember Design System
   Modeled strictly on Apple's Liquid Glass & Human Interface Guidelines (iOS 27):
   - Functional Liquid Glass layer floating cleanly above opaque content surfaces
   - Crystal-clear optical lensing + Fresnel rim + interactive droplet magnification
   - Soft Scroll Edge Effects (scrollEdgeEffectStyle)
   - Concentric geometry (outer radius = inner radius + padding)
   - One unmistakable signature color line: Obsidian Carbon / Warm Limestone + Atlas Signal Ember */

:root {
  color-scheme: light dark;

  /* Warm Architectural Limestone (Light) */
  --canvas: #f5f4f0;
  --card: #ffffff;
  --surface-2: #eeece6;
  --subtle: rgba(17, 17, 19, 0.065);
  --subtle-strong: rgba(17, 17, 19, 0.12);
  --fg: #111113;
  --fg-secondary: #48484c;
  --fg-inverse: #ffffff;
  --muted: #6c6c70;
  --tertiary: #8e8e93;
  --hairline: rgba(17, 17, 19, 0.08);
  --card-border: rgba(17, 17, 19, 0.07);

  /* Signature Atlas Color Line — ONE Hero Accent + Warm Metallic Titanium + Completion Green */
  --accent: #ea4c16;
  --accent-bright: #ff6b2c;
  --accent-soft: rgba(234, 76, 22, 0.11);
  --accent-border: rgba(234, 76, 22, 0.26);
  --accent-glow: 0 10px 28px rgba(234, 76, 22, 0.24);
  --titanium-gold: #b8844c;
  --titanium-gold-soft: rgba(184, 132, 76, 0.14);
  --green: #22b55b;
  --green-soft: rgba(34, 181, 91, 0.13);
  --red: #e53935;

  /* Authentic Apple Liquid Glass Surfaces (Crystal-clear translucent, NOT heavy tinted frost) */
  --glass-bg: rgba(255, 255, 255, 0.56);
  --glass-bg-elevated: rgba(255, 255, 255, 0.72);
  --glass-rim-top: rgba(255, 255, 255, 0.92);
  --glass-rim-bottom: rgba(17, 17, 19, 0.10);
  --glass-shadow: 0 12px 38px rgba(17, 17, 19, 0.10), 0 2px 6px rgba(17, 17, 19, 0.05);
  --lens-rest-bg: rgba(17, 17, 19, 0.065);
  --lens-droplet-bg: rgba(255, 255, 255, 0.42);
  --scroll-edge-fade: rgba(245, 244, 240, 0.86);

  /* Concentric Geometry Tokens */
  --radius-card: 22px;
  --radius-md: 16px;
  --radius-inner: 12px;
  --radius-sm: 10px;
  --radius-pill: 9999px;

  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", sans-serif;
  --font-rounded: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --canvas: #0a0a0b;
    --card: #141416;
    --surface-2: #1e1e22;
    --subtle: rgba(255, 255, 255, 0.08);
    --subtle-strong: rgba(255, 255, 255, 0.14);
    --fg: #f7f6f3;
    --fg-secondary: #d4d2cd;
    --fg-inverse: #0a0a0b;
    --muted: #989792;
    --tertiary: #666562;
    --hairline: rgba(255, 255, 255, 0.085);
    --card-border: rgba(255, 255, 255, 0.075);

    --accent: #ff6b2c;
    --accent-bright: #ff8547;
    --accent-soft: rgba(255, 107, 44, 0.14);
    --accent-border: rgba(255, 107, 44, 0.30);
    --accent-glow: 0 10px 30px rgba(255, 90, 31, 0.28);
    --titanium-gold: #dfb380;
    --titanium-gold-soft: rgba(223, 179, 128, 0.14);
    --green: #30d158;
    --green-soft: rgba(48, 209, 88, 0.14);
    --red: #ff453a;

    --glass-bg: rgba(28, 28, 30, 0.46);
    --glass-bg-elevated: rgba(36, 36, 40, 0.62);
    --glass-rim-top: rgba(255, 255, 255, 0.26);
    --glass-rim-bottom: rgba(255, 255, 255, 0.06);
    --glass-shadow: 0 16px 44px rgba(0, 0, 0, 0.62), 0 2px 8px rgba(0, 0, 0, 0.36);
    --lens-rest-bg: rgba(255, 255, 255, 0.11);
    --lens-droplet-bg: rgba(255, 255, 255, 0.16);
    --scroll-edge-fade: rgba(10, 10, 11, 0.88);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #0a0a0b;
  --card: #141416;
  --surface-2: #1e1e22;
  --subtle: rgba(255, 255, 255, 0.08);
  --subtle-strong: rgba(255, 255, 255, 0.14);
  --fg: #f7f6f3;
  --fg-secondary: #d4d2cd;
  --fg-inverse: #0a0a0b;
  --muted: #989792;
  --tertiary: #666562;
  --hairline: rgba(255, 255, 255, 0.085);
  --card-border: rgba(255, 255, 255, 0.075);

  --accent: #ff6b2c;
  --accent-bright: #ff8547;
  --accent-soft: rgba(255, 107, 44, 0.14);
  --accent-border: rgba(255, 107, 44, 0.30);
  --accent-glow: 0 10px 30px rgba(255, 90, 31, 0.28);
  --titanium-gold: #dfb380;
  --titanium-gold-soft: rgba(223, 179, 128, 0.14);
  --green: #30d158;
  --green-soft: rgba(48, 209, 88, 0.14);
  --red: #ff453a;

  --glass-bg: rgba(28, 28, 30, 0.46);
  --glass-bg-elevated: rgba(36, 36, 40, 0.62);
  --glass-rim-top: rgba(255, 255, 255, 0.26);
  --glass-rim-bottom: rgba(255, 255, 255, 0.06);
  --glass-shadow: 0 16px 44px rgba(0, 0, 0, 0.62), 0 2px 8px rgba(0, 0, 0, 0.36);
  --lens-rest-bg: rgba(255, 255, 255, 0.11);
  --lens-droplet-bg: rgba(255, 255, 255, 0.16);
  --scroll-edge-fade: rgba(10, 10, 11, 0.88);
}

:root[data-theme="light"] {
  color-scheme: light;
}

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

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--canvas);
  color: var(--fg);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}

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

button {
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
}

.metric {
  font-family: var(--font-rounded);
  font-variant-numeric: tabular-nums;
}

/* App Shell */
.app-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.sidebar { display: none; }

.main-area {
  flex: 1;
  min-width: 0;
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: calc(var(--safe-top) + 14px) 16px calc(var(--safe-bottom) + 150px);
}

/* Soft Scroll Edge Effects (Apple Liquid Glass scrollEdgeEffectStyle(.soft)) */
.scroll-edge-top {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: calc(var(--safe-top) + 42px);
  background: linear-gradient(180deg, var(--scroll-edge-fade) 0%, transparent 100%);
  pointer-events: none;
  z-index: 34;
}

.scroll-edge-bottom {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--safe-bottom) + 122px);
  background: linear-gradient(180deg, transparent 0%, var(--scroll-edge-fade) 72%, var(--canvas) 100%);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  mask-image: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.72) 55%, #000 100%);
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.72) 55%, #000 100%);
  pointer-events: none;
  z-index: 35;
}

/* Top Navigation Bar */
.nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Authentic Liquid Glass Circular Control */
.glass-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--glass-bg);
  border: 1px solid var(--glass-rim-bottom);
  box-shadow:
    var(--glass-shadow),
    0 1px 0.5px var(--glass-rim-top) inset,
    0 -1px 0.5px var(--glass-rim-bottom) inset;
  backdrop-filter: blur(24px) saturate(185%);
  -webkit-backdrop-filter: blur(24px) saturate(185%);
  transition: transform 0.2s cubic-bezier(0.32, 1.35, 0.48, 1), background 0.16s ease;
}

.glass-circle:active {
  transform: scale(1.08);
  background: var(--glass-bg-elevated);
}

.page-title {
  margin: 4px 0 20px;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.028em;
  line-height: 1.08;
}

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 28px 0 14px;
}

.section-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.text-action {
  font-size: 15px;
  font-weight: 600;
  color: var(--accent);
  padding: 6px 4px;
}

/* Opaque Content Surfaces (Apple HIG: Keep content layer clean & legible) */
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-card);
  padding: 18px;
}

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

.adaptive-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.adaptive-grid > *,
.duo-split > * {
  min-width: 0;
}

.duo-split {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  align-items: start;
}

/* Metric Tiles */
.metric-tile {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-card);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.metric-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.metric-icon-badge {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.metric-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.1;
  color: var(--fg);
}

.metric-sub {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}

.goal-track {
  height: 6px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  margin-top: 4px;
}

.goal-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-bright));
  transition: width 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Primary & Secondary Actions */
.btn-prominent {
  width: 100%;
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 22px;
  border-radius: var(--radius-pill);
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-bright) 100%);
  color: #ffffff;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.01em;
  box-shadow: var(--accent-glow), 0 1px 0 rgba(255, 255, 255, 0.28) inset;
  transition: transform 0.16s cubic-bezier(0.32, 1.3, 0.48, 1), filter 0.15s ease;
}

.btn-prominent:active { transform: scale(0.985); filter: brightness(1.06); }

.btn-glass {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-inner);
  background: var(--surface-2);
  border: 1px solid var(--card-border);
  font-size: 15px;
  font-weight: 600;
  color: var(--fg);
  transition: transform 0.14s ease, background 0.14s ease, border-color 0.14s ease;
}

.btn-glass.accent {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent);
}

.btn-glass.full { width: 100%; }
.btn-glass:active { transform: scale(0.98); }

.btn-subtle {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 13px;
  font-weight: 600;
  color: var(--fg-secondary);
}

.btn-subtle.full { width: 100%; min-height: 42px; }

.btn-danger {
  color: var(--red);
  font-size: 15px;
  font-weight: 600;
  padding: 10px 12px;
}

/* Routine Cards — Editorial Clarity & Unmistakable Exercise Legibility */
.routine-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-card);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.routine-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.routine-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 4px;
}

.routine-name {
  margin: 0;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--fg);
  line-height: 1.15;
}

.routine-note {
  margin: 4px 0 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}

.routine-list {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--hairline);
}

.routine-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--hairline);
}

.routine-row:last-child { border-bottom: none; }

.routine-ex-name {
  font-size: 15px;
  font-weight: 560;
  color: var(--fg);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scheme-pill {
  flex-shrink: 0;
  padding: 3px 9px;
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--fg-secondary);
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}

.routine-more {
  font-size: 13px;
  font-weight: 550;
  color: var(--muted);
  padding-top: 4px;
}

.pr-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--titanium-gold-soft);
  color: var(--titanium-gold);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--fg-secondary);
  font-size: 12px;
  font-weight: 600;
}

/* ==========================================================================
   AUTHENTIC APPLE LIQUID GLASS BOTTOM DOCK (Official iOS 26/27 Specification)
   - Main 3-tab floating Liquid Glass capsule (Train · History · Progress)
   - Detached circular trailing Search / Exercises Liquid Glass orb (Tab(role: .search))
   - Resting translucent platter + Optical magnifying droplet on press/scrub
   - True scroll-down collapse: main tab bar shrinks to single orb & moves
     active workout accessory inline beside it (tabBarMinimizeBehavior(.onScrollDown))
   - Search mode morph: main tab bar collapses to leading pill while search bar
     expands at the bottom edge above the keyboard
   ========================================================================== */
.bottom-dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 0 16px calc(var(--safe-bottom) + 14px);
  pointer-events: none;
}

.dock-row {
  width: 100%;
  max-width: 448px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

/* Floating Liquid Glass Active Workout Accessory (tabViewBottomAccessory) */
.mini-session-wrap {
  width: 100%;
  max-width: 448px;
  display: flex;
  justify-content: center;
  transition: transform 0.36s cubic-bezier(0.28, 1.16, 0.36, 1), opacity 0.24s ease;
}

.mini-session-bar {
  pointer-events: auto;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  border-radius: var(--radius-pill);
  background: var(--glass-bg);
  border: 1px solid var(--glass-rim-bottom);
  box-shadow:
    var(--glass-shadow),
    0 1.5px 1px var(--glass-rim-top) inset,
    0 -1px 1px var(--glass-rim-bottom) inset;
  backdrop-filter: blur(28px) saturate(200%) brightness(1.03);
  -webkit-backdrop-filter: blur(28px) saturate(200%) brightness(1.03);
  text-align: left;
  transition: transform 0.24s cubic-bezier(0.28, 1.25, 0.44, 1);
}

.mini-session-bar:active { transform: scale(0.98); }

/* When scrolled down with an active workout: move accessory inline beside the compact tab orb */
.bottom-dock.has-accessory.dock-minimized {
  flex-direction: row;
  justify-content: center;
  align-items: center;
  gap: 10px;
}

.bottom-dock.has-accessory.dock-minimized .dock-row {
  width: auto;
  max-width: none;
  flex-shrink: 0;
  order: 1;
}

.bottom-dock.has-accessory.dock-minimized .mini-session-wrap {
  order: 2;
  flex: 1;
  min-width: 0;
  max-width: 310px;
}

.bottom-dock.has-accessory.dock-minimized .mini-session-bar {
  height: 58px;
  padding: 8px 14px;
}

.live-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
  box-shadow: 0 0 0 4px var(--green-soft);
}

.mini-session-meta { flex: 1; min-width: 0; }

.mini-session-title {
  font-size: 15px;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mini-session-time {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}

.rest-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

/* Main 3-Tab Crystal-Clear Apple Liquid Glass Capsule */
.tab-bar {
  pointer-events: auto;
  position: relative;
  flex: 1;
  min-width: 0;
  max-width: 364px;
  height: 62px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 4px;
  border-radius: var(--radius-pill);
  background: var(--glass-bg);
  border: 1px solid var(--glass-rim-bottom);
  box-shadow:
    var(--glass-shadow),
    0 1.5px 1px var(--glass-rim-top) inset,
    0 -1px 1px var(--glass-rim-bottom) inset;
  backdrop-filter: blur(32px) saturate(215%) brightness(1.05);
  -webkit-backdrop-filter: blur(32px) saturate(215%) brightness(1.05);
  touch-action: pan-y;
  transition:
    flex 0.42s cubic-bezier(0.28, 1.16, 0.36, 1),
    width 0.42s cubic-bezier(0.28, 1.16, 0.36, 1),
    max-width 0.42s cubic-bezier(0.28, 1.16, 0.36, 1),
    transform 0.38s cubic-bezier(0.28, 1.16, 0.36, 1);
  overflow: visible;
}

/* Specular Fresnel highlight streak across top curvature of the Liquid Glass pill */
.tab-bar::before {
  content: "";
  position: absolute;
  inset: 1px 20px auto 20px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--glass-rim-top), transparent);
  opacity: 0.9;
  pointer-events: none;
  z-index: 3;
}

/* True iOS 27 tabBarMinimizeBehavior(.onScrollDown) & Search-active collapse: compact single orb */
.tab-bar.minimized,
.dock-row.search-active .tab-bar {
  flex: 0 0 62px;
  width: 62px;
  max-width: 62px;
  grid-template-columns: 1fr;
}

.tab-bar.minimized .tab-btn:not(.active),
.dock-row.search-active .tab-bar .tab-btn:not(.last-main) {
  display: none;
}

.tab-bar.minimized .tab-btn span,
.dock-row.search-active .tab-bar .tab-btn span {
  display: none;
}

.tab-bar.minimized .tab-glass-lens,
.dock-row.search-active .tab-bar .tab-glass-lens {
  opacity: 0;
}

/* Detached Circular Trailing Search Orb (Apple iOS 26/27 Tab(role: .search)) */
.tab-search-orb {
  pointer-events: auto;
  position: relative;
  flex: 0 0 62px;
  width: 62px;
  height: 62px;
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0;
  background: var(--glass-bg);
  border: 1px solid var(--glass-rim-bottom);
  box-shadow:
    var(--glass-shadow),
    0 1.5px 1px var(--glass-rim-top) inset,
    0 -1px 1px var(--glass-rim-bottom) inset;
  backdrop-filter: blur(32px) saturate(215%) brightness(1.05);
  -webkit-backdrop-filter: blur(32px) saturate(215%) brightness(1.05);
  color: var(--fg);
  transition:
    flex 0.42s cubic-bezier(0.28, 1.16, 0.36, 1),
    width 0.42s cubic-bezier(0.28, 1.16, 0.36, 1),
    padding 0.32s ease,
    transform 0.24s cubic-bezier(0.32, 1.35, 0.48, 1),
    border-color 0.22s ease,
    color 0.2s ease;
}

.tab-search-orb::before {
  content: "";
  position: absolute;
  inset: 1px 14px auto 14px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--glass-rim-top), transparent);
  opacity: 0.9;
  pointer-events: none;
}

.tab-search-orb:active {
  transform: scale(1.09);
  background: var(--glass-bg-elevated);
}

.tab-search-orb .dock-search-input {
  display: none;
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  outline: none;
  font-size: 16px;
  font-weight: 500;
  color: var(--fg);
}

.tab-search-orb .dock-search-clear {
  display: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  background: var(--subtle-strong);
  color: var(--fg-secondary);
  flex-shrink: 0;
}

/* When Search / Exercises tab is active, the trailing orb morphs into Apple's bottom Liquid Glass Search Pill! */
.dock-row.search-active .tab-search-orb {
  flex: 1;
  width: auto;
  max-width: 364px;
  padding: 0 14px 0 18px;
  justify-content: flex-start;
  border-color: var(--accent-border);
  color: var(--accent);
}

.dock-row.search-active .tab-search-orb .dock-search-input {
  display: block;
}

.dock-row.search-active .tab-search-orb .dock-search-clear.visible {
  display: inline-flex;
}

.bottom-dock.has-accessory.dock-minimized .tab-search-orb {
  display: none;
}

/* Optical Liquid Glass Selection Platter -> Morphs into Magnifying Droplet on Touch/Scrub */
.tab-glass-lens {
  position: absolute;
  top: 4px;
  left: 4px;
  bottom: 4px;
  width: calc((100% - 8px) / 3);
  border-radius: var(--radius-pill);
  background: var(--lens-rest-bg);
  border: 1px solid transparent;
  box-shadow: 0 1px 0.5px rgba(255, 255, 255, 0.14) inset;
  transform: translate3d(calc(var(--lens-index, 0) * 100%), 0, 0) scale(1);
  transition:
    transform 0.5s cubic-bezier(0.26, 1.28, 0.38, 1),
    opacity 0.2s ease,
    background 0.22s ease,
    border-color 0.22s ease,
    box-shadow 0.24s ease;
  will-change: transform;
  pointer-events: none;
  z-index: 0;
}

/* Specular Fresnel inner rim inside the optical droplet */
.tab-glass-lens::before {
  content: "";
  position: absolute;
  inset: 1px 12% auto 12%;
  height: 45%;
  border-radius: var(--radius-pill);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.48), rgba(255, 255, 255, 0));
  opacity: 0;
  transition: opacity 0.2s ease;
}

/* Active Optical Lensing State (during tap transition or finger scrub — genuine Liquid Glass physics!) */
.tab-glass-lens.lensing,
.tab-glass-lens.scrubbing {
  background: var(--lens-droplet-bg);
  border-color: var(--glass-rim-top);
  box-shadow:
    0 14px 32px rgba(0, 0, 0, 0.28),
    0 1.5px 1.5px rgba(255, 255, 255, 0.72) inset,
    0 -1.5px 2px rgba(255, 107, 44, 0.22) inset;
  backdrop-filter: blur(5px) brightness(1.18) saturate(215%);
  -webkit-backdrop-filter: blur(5px) brightness(1.18) saturate(215%);
}

.tab-glass-lens.lensing::before,
.tab-glass-lens.scrubbing::before {
  opacity: 1;
}

.tab-glass-lens.scrubbing {
  transition: background 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.tab-btn {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 4px;
  border-radius: var(--radius-pill);
  color: var(--muted);
  font-size: 11px;
  font-weight: 550;
  transition: color 0.2s ease, transform 0.28s cubic-bezier(0.32, 1.35, 0.48, 1);
  user-select: none;
  -webkit-user-select: none;
}

.tab-btn svg {
  transition: transform 0.32s cubic-bezier(0.32, 1.4, 0.48, 1);
}

.tab-btn.active {
  color: var(--accent);
  font-weight: 650;
}

.tab-btn.active svg {
  transform: scale(1.08);
}

.tab-btn:active {
  transform: scale(0.95);
}

/* Search & Filter Chips */
.search-box {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-inner);
  background: var(--card);
  border: 1px solid var(--card-border);
  margin-bottom: 14px;
}

.search-box input {
  border: none;
  background: transparent;
  outline: none;
  width: 100%;
  font-size: 16px;
}

.chip-strip {
  display: flex;
  gap: 8px;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  padding-bottom: 14px;
  scrollbar-width: none;
}

.chip-strip::-webkit-scrollbar { display: none; }

.chip {
  flex-shrink: 0;
  min-height: 36px;
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  background: var(--card);
  color: var(--fg-secondary);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--card-border);
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

.chip.active {
  background: var(--accent);
  color: #ffffff;
  border-color: transparent;
}

/* Lists — Crisp High-Contrast Exercise Rows */
.list-group {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-card);
  overflow: hidden;
}

.list-item {
  width: 100%;
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  text-align: left;
  border-bottom: 1px solid var(--hairline);
  transition: background 0.14s ease;
}

.list-item:last-child { border-bottom: none; }
.list-item.selected { background: var(--accent-soft); }
.list-item:active { background: var(--subtle); }

.item-title {
  font-size: 16px;
  font-weight: 620;
  color: var(--fg);
  line-height: 1.25;
}

.item-sub {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  margin-top: 3px;
}

/* Modal Sheets */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(0, 0, 0, 0.52);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet {
  width: 100%;
  max-width: 980px;
  height: 94dvh;
  background: var(--canvas);
  border-radius: 28px 28px 0 0;
  border-top: 1px solid var(--card-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 -14px 48px rgba(0, 0, 0, 0.36);
}

.sheet.compact {
  height: auto;
  max-height: 88dvh;
  max-width: 560px;
  /* Apple Adopting Liquid Glass: inset half-sheets float off display edges with rounder concentric corners */
  width: calc(100% - 20px);
  margin: 0 10px calc(var(--safe-bottom) + 10px);
  border-radius: 32px;
  border: 1px solid var(--glass-rim-top);
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  background: var(--glass-bg-elevated);
  border-bottom: 1px solid var(--hairline);
  backdrop-filter: blur(26px) saturate(190%);
  -webkit-backdrop-filter: blur(26px) saturate(190%);
}

.sheet-title {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
  text-align: center;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sheet-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px calc(var(--safe-bottom) + 104px);
}

/* Active Workout — High-Legibility 44pt Gym Ergonomics */
.telemetry-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-card);
  margin-bottom: 16px;
}

.telemetry-col { display: flex; flex-direction: column; gap: 3px; }
.telemetry-col.center { text-align: center; }
.telemetry-col.right { text-align: right; }
.telemetry-col span:first-child { font-size: 12px; font-weight: 600; color: var(--muted); }
.telemetry-col span:last-child { font-size: 18px; font-weight: 700; }

.exercise-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-card);
  padding: 18px;
  margin-bottom: 16px;
}

.exercise-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.exercise-card-head h3 {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--fg);
  line-height: 1.2;
}

.exercise-progress-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 5px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.ex-progress-track {
  height: 4px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  margin-bottom: 14px;
}

.ex-progress-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--green);
  transition: width 0.25s ease;
}

.set-grid-head, .set-row {
  display: grid;
  grid-template-columns: 38px 1fr 78px 66px 44px;
  gap: 8px;
  align-items: center;
}

.set-grid-head {
  font-size: 12px;
  font-weight: 620;
  color: var(--muted);
  margin-bottom: 8px;
  padding: 0 6px;
  text-align: center;
}

.set-grid-head span:nth-child(2) { text-align: left; }

.set-row {
  margin-bottom: 8px;
  padding: 5px 6px;
  border-radius: var(--radius-inner);
  transition: background 0.18s ease;
}

.set-row.done {
  background: var(--green-soft);
}

.set-badge {
  width: 38px;
  height: 42px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--fg);
  font-size: 14px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.set-badge.special {
  background: var(--accent-soft);
  color: var(--accent);
}

.set-prev {
  font-size: 13px;
  font-weight: 550;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.set-input {
  width: 100%;
  height: 44px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--fg);
  text-align: center;
  font-size: 17px;
  font-weight: 650;
  outline: none;
  transition: border-color 0.14s ease, background 0.14s ease;
}

.set-input:focus {
  border-color: var(--accent);
  background: var(--card);
}

.check-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  background: var(--surface-2);
  transition: background 0.16s ease, color 0.16s ease, transform 0.14s ease;
}

.check-btn.done {
  background: var(--green);
  color: #ffffff;
}

.check-btn:active { transform: scale(0.92); }

/* Floating Rest Timer Liquid Glass Bar inside Workout */
.rest-bar-wrap {
  position: sticky;
  bottom: 0;
  padding: 10px 16px calc(var(--safe-bottom) + 14px);
  pointer-events: none;
}

.rest-bar {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-pill);
  background: var(--glass-bg-elevated);
  border: 1px solid var(--accent-border);
  box-shadow: var(--glass-shadow), 0 1px 0.5px var(--glass-rim-top) inset;
  backdrop-filter: blur(28px) saturate(200%);
  -webkit-backdrop-filter: blur(28px) saturate(200%);
}

.rest-bar-info { flex: 1; min-width: 0; }
.rest-bar-clock { font-size: 19px; font-weight: 700; line-height: 1.1; }
.rest-bar-ex { font-size: 12px; font-weight: 500; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.rest-pill-btn {
  min-height: 36px;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  background: var(--subtle);
  font-size: 13px;
  font-weight: 650;
}

/* Forms */
.form-section { margin-bottom: 22px; }

/* Title-style section headers per Apple Adopting Liquid Glass HIG */
.form-section-title {
  font-size: 14px;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--muted);
  margin: 0 0 8px 14px;
}

.form-row {
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--hairline);
}

.form-row:last-child { border-bottom: none; }

.form-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-inner);
  background: var(--surface-2);
  font-size: 16px;
  outline: none;
}

.form-input:focus { border-color: var(--accent); }

.form-select {
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  background: var(--surface-2);
  font-size: 15px;
  font-weight: 550;
}

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

.stepper button {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 18px;
  font-weight: 600;
}

.switch {
  appearance: none;
  width: 50px;
  height: 30px;
  border-radius: 999px;
  background: var(--subtle-strong);
  position: relative;
  transition: background 0.18s ease;
  cursor: pointer;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s cubic-bezier(0.32, 1.3, 0.48, 1);
}

.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(20px); }
/* Transient Liquid Glass knob morphing during toggle interaction (Apple Liquid Glass Controls HIG) */
.switch:active::after {
  width: 30px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.24), 0 1px 1px rgba(255, 255, 255, 0.9) inset;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.switch:checked:active::after { transform: translateX(14px); }

/* Chart */
.chart-svg { width: 100%; height: 200px; display: block; }

/* Empty State */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
}

.empty-state h3 { margin: 12px 0 6px; color: var(--fg); font-size: 18px; font-weight: 650; }
.empty-state p { margin: 0; font-size: 14px; line-height: 1.45; }

/* Toast */
.toast-root {
  position: fixed;
  top: calc(var(--safe-top) + 14px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 120;
  pointer-events: none;
}

.toast {
  padding: 11px 18px;
  border-radius: var(--radius-pill);
  background: var(--fg);
  color: var(--fg-inverse);
  font-size: 14px;
  font-weight: 650;
  box-shadow: var(--glass-shadow);
  animation: toastIn 0.22s cubic-bezier(0.28, 1.25, 0.44, 1);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-10px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Adaptive Regular Width (Unfolded iPhone Duo / iPad / Desktop) */
@media (min-width: 768px) {
  .app-shell { flex-direction: row; }

  .sidebar {
    display: flex;
    flex-direction: column;
    width: 244px;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100dvh;
    padding: 24px 14px;
    border-right: 1px solid var(--hairline);
    background: var(--glass-bg);
    backdrop-filter: blur(28px) saturate(185%);
    -webkit-backdrop-filter: blur(28px) saturate(185%);
    gap: 6px;
  }

  .sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px 20px;
    font-size: 21px;
    font-weight: 750;
    letter-spacing: -0.025em;
  }

  .sidebar-btn {
    width: 100%;
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-inner);
    font-size: 15px;
    font-weight: 560;
    color: var(--muted);
    text-align: left;
    transition: background 0.2s ease, color 0.18s ease;
  }

  .sidebar-btn.active {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 650;
  }

  .sidebar-spacer { flex: 1; }

  .main-area { padding: 26px 32px 146px; }
  .scroll-edge-top,
  .scroll-edge-bottom { left: 244px; }
  .bottom-dock { left: 244px; }
  .nav-bar [data-action="open-settings"],
  .mobile-brand { display: none !important; }
  .nav-bar { justify-content: flex-end; }

  .adaptive-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .duo-split { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }

  .sheet-backdrop { align-items: center; padding: 24px; }
  .sheet { height: min(88dvh, 840px); border-radius: 28px; }
  .sheet.compact { width: 100%; margin: 0; border-radius: 28px; }
}

/* Apple Accessibility Parity: Reduce Transparency & Reduce Motion */
@media (prefers-reduced-transparency: reduce) {
  .tab-bar,
  .tab-search-orb,
  .mini-session-bar,
  .glass-circle,
  .rest-bar,
  .sheet-header,
  .sidebar {
    background: var(--card);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-color: var(--hairline);
  }
}

@media (prefers-reduced-motion: reduce) {
  .tab-bar,
  .tab-search-orb,
  .tab-glass-lens,
  .tab-btn,
  .mini-session-bar,
  .glass-circle,
  .switch::after {
    transition: none !important;
    animation: none !important;
  }
}
