:root {
  color-scheme: dark;
  --bg: #0f172a;
  --bg-soft: #111c32;
  --surface: #162033;
  --surface-2: #1b2740;
  --surface-3: #243452;
  --border: #334464;
  --border-soft: rgba(191, 219, 254, .16);
  --text: #f8fafc;
  --muted: #b6c4d9;
  --muted-2: #86a0bd;
  --blue: #3b82f6;
  --blue-2: #60a5fa;
  --green: #22c55e;
  --green-2: #86efac;
  --danger: #ff5b6e;
  --success: #3ddc97;
  --shadow: 0 16px 42px rgba(2, 8, 23, .22);
  --radius: 12px;
  --space-1: 8px;
  --space-2: 12px;
  --space-3: 16px;
  --space-4: 24px;
  --space-5: 32px;
  --space-6: 48px;
  --sidebar-width: 248px;
  --content-max: 1180px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  background: linear-gradient(180deg, #0f172a 0%, #111c32 52%, #0f172a 100%);
  font-size: 16px;
  line-height: 1.5;
}

body.modal-open {
  overflow: hidden;
}

img,
svg,
canvas {
  max-width: 100%;
}

a {
  color: var(--blue-2);
  text-decoration: none;
}

a:hover {
  color: #9be4ff;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  color: var(--text);
  line-height: 1.12;
  letter-spacing: 0;
}

h1 {
  margin-bottom: var(--space-2);
  font-size: clamp(2rem, 5vw, 4.5rem);
}

h2 {
  margin-bottom: var(--space-2);
  font-size: clamp(1.15rem, 2vw, 1.45rem);
}

h3 {
  margin-bottom: var(--space-1);
  font-size: 1rem;
}

p {
  margin-bottom: var(--space-3);
  color: var(--muted);
  line-height: 1.65;
}

strong,
b {
  overflow-wrap: anywhere;
}

main,
section,
article,
header,
footer,
nav {
  min-width: 0;
}

/* Shell and layout */
.public-shell,
.app-shell,
.site-footer {
  width: min(var(--content-max), calc(100% - 32px));
  margin-inline: auto;
}

.public-shell,
.app-shell {
  padding: var(--space-3) 0 88px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
  min-width: 0;
}

.topbar-actions,
.button-row,
.hero-actions,
.tag-row,
.inline-form {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  min-width: 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
  color: var(--text);
  font-size: 1.14rem;
  font-weight: 800;
  white-space: nowrap;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  flex: 0 0 50px;
  overflow: hidden;
  border-radius: 12px;
  background: transparent;
  box-shadow: 0 12px 26px rgba(59, 130, 246, .24);
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.page-heading,
.workout-log-heading,
.workout-start,
.completion-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  min-width: 0;
}

.page-heading > div,
.workout-log-heading > div,
.workout-start > div,
.completion-hero > div {
  min-width: 0;
}

.page-heading h1,
.workout-log-heading h1,
.completion-hero h1 {
  font-size: clamp(2rem, 4vw, 3rem);
}

.section-grid,
.pricing-grid,
.card-grid,
.records-grid,
.metrics-grid,
.content-grid {
  display: grid;
  gap: var(--space-3);
  align-items: stretch;
  min-width: 0;
}

.section-grid,
.pricing-grid,
.card-grid,
.records-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr));
}

.metrics-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: var(--space-4);
}

.content-grid {
  grid-template-columns: 1fr;
}

/* Components */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  min-height: 42px;
  max-width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: .93rem;
  font-weight: 750;
  line-height: 1.1;
  text-align: center;
  white-space: normal;
  overflow-wrap: anywhere;
  cursor: pointer;
  transition: transform .16s ease, border-color .16s ease, background .16s ease, box-shadow .16s ease, color .16s ease;
}

.button:hover {
  transform: translateY(-1px);
  border-color: rgba(88, 199, 255, .42);
  background: var(--surface-3);
  color: var(--text);
}

.button:active {
  transform: translateY(0);
  box-shadow: none;
}

.button:disabled,
.button[aria-disabled="true"] {
  opacity: .55;
  cursor: not-allowed;
  transform: none;
}

.button.primary {
  border-color: transparent;
  background: linear-gradient(135deg, var(--blue), #2563eb);
  box-shadow: 0 12px 28px rgba(59, 130, 246, .22);
}

.button.primary:hover {
  background: linear-gradient(135deg, #60a5fa, #3b82f6);
}

.button.ghost {
  background: rgba(255, 255, 255, .045);
}

.button.danger {
  border-color: rgba(255, 91, 110, .42);
  background: rgba(255, 91, 110, .12);
  color: white;
}

.button.danger:hover {
  background: rgba(255, 91, 110, .2);
}

.button.large {
  min-height: 50px;
  padding: 12px 20px;
  font-size: 1rem;
}

.button.full {
  width: 100%;
}

.button-row > form,
.button-row > .button {
  flex: 0 1 auto;
}

.button-row > form .button {
  width: 100%;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
  cursor: pointer;
  transition: transform .16s ease, border-color .16s ease, background .16s ease, color .16s ease;
}

.icon-button svg {
  width: 18px;
  height: 18px;
}

.icon-button:hover {
  transform: translateY(-1px);
  border-color: rgba(88, 199, 255, .5);
  background: var(--surface-3);
}

.icon-button.danger {
  border-color: rgba(255, 91, 110, .34);
  color: #ff98a5;
}

.icon-button.danger:hover {
  border-color: rgba(255, 91, 110, .58);
  background: rgba(255, 91, 110, .12);
  color: white;
}

.feature-card,
.price-card,
.panel,
.routine-card,
.record-card,
.recommendation-card,
.metric-card,
.form-card,
.workout-card,
.empty-state,
.testimonials article {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  height: 100%;
  min-width: 0;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(27, 39, 64, .94), rgba(22, 32, 51, .92));
  box-shadow: 0 1px 0 rgba(255, 255, 255, .04) inset, var(--shadow);
  padding: var(--space-4);
}

.card-grid > .routine-card,
.card-grid > .recommendation-card,
.pricing-grid > .price-card,
.section-grid > .feature-card,
.records-grid > .record-card,
.metrics-grid > .metric-card,
.content-grid > .panel,
.content-grid > article,
.card-grid > article,
.section-grid > article,
.pricing-grid > article,
.records-grid > article {
  height: 100%;
}

.panel > :last-child,
.routine-card p,
.recommendation-card p,
.feature-card p,
.price-card p,
.workout-card p {
  margin-bottom: 0;
}

.routine-card .button-row,
.workout-card .button,
.recommendation-card .button,
.price-card .button,
.feature-card .button {
  margin-top: auto;
}

.recommendation-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-1);
}

.recommendation-stats span {
  min-width: 0;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .035);
  padding: 8px 9px;
  color: var(--muted);
  font-size: .78rem;
  line-height: 1.2;
}

.recommendation-stats strong {
  display: block;
  margin-top: 2px;
  color: var(--text);
  font-size: .92rem;
}

.routine-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-2);
}

.routine-list-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, auto);
  align-items: center;
  gap: var(--space-5);
  padding: var(--space-3) var(--space-4);
  min-height: 154px;
}

.routine-card-body {
  display: grid;
  gap: var(--space-2);
  min-width: 0;
}

.routine-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  min-width: 0;
}

.routine-card-header h2 {
  margin-bottom: 0;
  font-size: clamp(1.18rem, 1.8vw, 1.45rem);
}

.routine-kicker {
  display: block;
  margin-bottom: 4px;
  color: var(--blue-2);
  font-size: .72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.routine-count {
  display: inline-grid;
  place-items: center;
  min-width: 72px;
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: rgba(34, 197, 94, .1);
  color: var(--text);
  text-align: center;
}

.routine-count strong {
  font-size: 1.25rem;
  line-height: 1;
}

.routine-count small {
  font-size: .76rem;
}

.routine-description {
  max-width: 760px;
  font-size: .95rem;
}

.routine-side {
  display: grid;
  justify-items: end;
  gap: var(--space-3);
}

.routine-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-1);
  flex-wrap: wrap;
}

.routine-actions .button {
  min-width: 86px;
  min-height: 40px;
}

.panel > .inline-form {
  margin-top: 0;
}

.panel + .panel,
.panel + .card-grid,
.card-grid + .panel,
.content-grid + .panel,
.metrics-grid + .panel {
  margin-top: var(--space-4);
}

.content-grid > .panel + .panel,
.card-grid > .panel + .panel,
.section-grid > .panel + .panel,
.pricing-grid > .panel + .panel,
.records-grid > .panel + .panel {
  margin-top: 0;
}

.panel-heading,
.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
  min-width: 0;
}

.panel-heading > *,
.card-top > * {
  min-width: 0;
}

.card-top span,
.panel-heading span {
  flex: 0 0 auto;
}

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-width: 0;
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border-soft);
}

.list-row:first-child {
  padding-top: 0;
}

.list-row:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.list-row > div {
  min-width: 0;
}

.list-row span,
td span,
small {
  display: block;
  color: var(--muted);
}

.user-chip,
.pill,
.tag-row span,
.previous-chip,
.plan-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  max-width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  background: rgba(255, 255, 255, .04);
  color: var(--muted);
  font-size: .84rem;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.plan-badge {
  border-color: rgba(59, 130, 246, .24);
  background: rgba(59, 130, 246, .12);
  color: #bfdbfe;
  font-size: .78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.plan-badge.paid {
  border-color: rgba(34, 197, 94, .36);
  background: rgba(34, 197, 94, .14);
  color: #bbf7d0;
}

.plan-badge.free {
  border-color: rgba(96, 165, 250, .28);
}

.tag-row {
  gap: var(--space-1);
}

.metric-card strong,
.price-card strong {
  display: block;
  margin: var(--space-1) 0 0;
  font-size: clamp(1.55rem, 4vw, 2.1rem);
  line-height: 1;
}

.price-card strong span {
  display: inline;
  color: var(--muted);
  font-size: .9rem;
}

.price-card.featured {
  border-color: rgba(59, 130, 246, .38);
  background: linear-gradient(180deg, rgba(35, 50, 82, .98), rgba(22, 42, 70, .94));
}

.feature-list {
  display: grid;
  gap: 9px;
  margin: 0 0 var(--space-3);
  padding: 0;
  color: var(--muted);
  list-style: none;
}

.feature-list li {
  position: relative;
  min-width: 0;
  padding-left: 26px;
  overflow-wrap: anywhere;
}

.feature-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: .45em;
  width: 11px;
  height: 11px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--green), var(--blue));
  box-shadow: 0 0 0 4px rgba(34, 197, 94, .1);
}

.upgrade-banner,
.plan-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-width: 0;
  margin-bottom: var(--space-4);
  border: 1px solid rgba(59, 130, 246, .28);
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(59, 130, 246, .18), rgba(34, 197, 94, .1));
  box-shadow: var(--shadow);
  padding: var(--space-4);
}

.upgrade-banner h2,
.upgrade-banner p,
.plan-panel h2,
.plan-panel p {
  margin-bottom: 0;
}

.upgrade-banner > div,
.plan-panel > div {
  min-width: 0;
}

.plan-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
  align-items: stretch;
  gap: var(--space-4);
}

.plan-panel-main {
  display: grid;
  align-content: center;
  gap: var(--space-2);
}

.plan-panel-top,
.upgrade-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2);
  min-width: 0;
}

.plan-panel-top .eyebrow,
.upgrade-card-head h2,
.upgrade-card-head p {
  margin-bottom: 0;
}

.plan-panel h2 {
  margin-bottom: 0;
}

.plan-limit-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-2);
  margin-top: var(--space-1);
}

.plan-limit-grid span,
.plan-panel-cta,
.value-badge {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .045);
}

.plan-limit-grid span {
  min-width: 0;
  padding: var(--space-2);
  color: var(--muted);
  font-size: .88rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.plan-limit-grid strong {
  display: block;
  margin-bottom: 2px;
  color: var(--text);
  font-size: 1.35rem;
  line-height: 1;
}

.plan-panel-cta {
  display: grid;
  align-content: center;
  gap: var(--space-2);
  padding: var(--space-3);
}

.plan-panel-cta strong {
  font-size: 1.1rem;
}

.plan-panel-cta span {
  color: var(--muted);
}

.plan-panel-cta .button {
  width: 100%;
  margin-top: var(--space-1);
}

.plan-panel-cta.paid {
  border-color: rgba(34, 197, 94, .24);
  background: rgba(34, 197, 94, .08);
}

.upgrade-heading {
  margin-bottom: var(--space-4);
}

.upgrade-heading p {
  max-width: 780px;
  margin-bottom: 0;
}

.upgrade-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
}

.upgrade-grid + .comparison-panel {
  margin-top: var(--space-4);
}

.upgrade-grid .price-card {
  gap: var(--space-4);
  min-height: 390px;
  padding: var(--space-5);
}

.upgrade-grid .price-card strong {
  margin: 0;
  font-size: clamp(2.4rem, 4vw, 3.4rem);
}

.upgrade-grid .price-card form {
  margin-top: auto;
}

.upgrade-card-head p {
  margin-top: 6px;
  color: var(--muted);
}

.value-badge {
  flex: 0 0 auto;
  padding: 7px 10px;
  color: var(--green-2);
  font-size: .78rem;
  font-weight: 850;
}

.pricing-table-wrap {
  margin-top: var(--space-4);
  overflow-x: auto;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .025);
}

.pricing-table-wrap.compact {
  margin-top: 0;
}

.pricing-table {
  min-width: 680px;
}

.pricing-table td:nth-child(3),
.pricing-table th:nth-child(3) {
  color: var(--text);
}

.empty-state {
  display: grid;
  place-items: center;
  gap: var(--space-1);
  min-height: 170px;
  text-align: center;
}

.empty-state.wide {
  grid-column: 1 / -1;
}

.is-hidden {
  display: none !important;
}

.empty-state p {
  max-width: 520px;
  margin-bottom: 0;
}

.panel > .empty-state {
  align-items: start;
  justify-items: start;
  place-items: start;
  height: auto;
  min-height: 0;
  padding: 0;
  border: 0;
  box-shadow: none;
  background: transparent;
  text-align: left;
}

.panel > .empty-state h2,
.panel > .empty-state h3 {
  margin-bottom: var(--space-1);
}

.panel > .empty-state p {
  max-width: 100%;
}

.flash-stack {
  display: grid;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.flash {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .05);
  padding: var(--space-2) var(--space-3);
  overflow-wrap: anywhere;
}

.flash.success {
  border-color: rgba(61, 220, 151, .42);
  color: var(--success);
}

.flash.error {
  border-color: rgba(255, 91, 110, .5);
  color: var(--danger);
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  padding-top: var(--space-4);
  color: var(--muted);
}

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

.eyebrow {
  margin-bottom: var(--space-1);
  color: var(--green-2);
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

/* Navigation */
.sidebar {
  display: none;
}

.sidebar-plan {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  min-width: 0;
  padding: var(--space-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .035);
}

.sidebar-plan a {
  flex: 0 0 auto;
  font-size: .82rem;
  font-weight: 800;
}

.bottom-nav {
  position: fixed;
  left: var(--space-2);
  right: var(--space-2);
  bottom: var(--space-2);
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(34px, 1fr));
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(13, 19, 32, .94);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.bottom-nav a {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 44px;
  padding: 8px 6px;
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

.bottom-nav-icon {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
}

.bottom-nav-icon svg {
  display: block;
  width: 21px;
  height: 21px;
}

.bottom-nav-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.bottom-nav a:hover {
  background: rgba(59, 130, 246, .16);
  color: var(--text);
}

.bottom-nav a.active {
  background: linear-gradient(135deg, rgba(59, 130, 246, .22), rgba(34, 197, 94, .14));
  color: var(--text);
}

/* Landing page */
.hero {
  display: grid;
  align-items: center;
  gap: var(--space-5);
  min-height: calc(100vh - 120px);
  padding: var(--space-4) 0 var(--space-6);
}

.hero-copy p {
  max-width: 650px;
  font-size: 1.08rem;
}

.screenshot-stack {
  display: grid;
  gap: var(--space-3);
  min-width: 0;
}

.product-shot {
  min-width: 0;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #111827, #0a0f1a);
  box-shadow: var(--shadow);
}

.main-shot {
  display: grid;
  gap: var(--space-3);
  min-height: 300px;
  padding: var(--space-4);
}

.mini-shot {
  display: grid;
  gap: var(--space-1);
  padding: var(--space-3);
}

.mini-shot strong {
  font-size: clamp(1.75rem, 5vw, 2.2rem);
  line-height: 1;
}

.shot-header {
  display: flex;
  gap: var(--space-1);
}

.shot-header span {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--border);
}

.metric-row {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  min-width: 0;
}

.chart-bars {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  align-items: end;
  gap: var(--space-2);
  min-height: 150px;
}

.chart-bars i {
  display: block;
  border-radius: 7px 7px 0 0;
  background: linear-gradient(180deg, var(--green-2), var(--blue));
}

.chart-bars i:nth-child(1) { height: 45%; }
.chart-bars i:nth-child(2) { height: 70%; }
.chart-bars i:nth-child(3) { height: 58%; }
.chart-bars i:nth-child(4) { height: 86%; }
.chart-bars i:nth-child(5) { height: 76%; }
.chart-bars i:nth-child(6) { height: 95%; }

.pricing,
.faq,
.cta-band,
.testimonials {
  margin: var(--space-6) 0;
}

.testimonials {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: var(--space-3);
  align-items: stretch;
}

.faq details {
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border-soft);
}

.faq summary {
  cursor: pointer;
  font-weight: 750;
}

.cta-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(59, 130, 246, .2), rgba(34, 197, 94, .12));
}

.cta-band h2 {
  margin-bottom: 0;
}

/* Forms */
form {
  margin: 0;
}

.logout-form {
  display: inline-flex;
}

.logout-button {
  white-space: nowrap;
}

.logout-icon {
  display: none;
  place-items: center;
  width: 18px;
  height: 18px;
}

.logout-icon svg {
  display: block;
  width: 18px;
  height: 18px;
}

label {
  display: grid;
  gap: var(--space-1);
  min-width: 0;
  color: var(--muted);
  font-size: .92rem;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #0f172a;
  color: var(--text);
  padding: 11px 12px;
  font: inherit;
  line-height: 1.3;
  outline: none;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(88, 199, 255, .7);
  box-shadow: 0 0 0 3px rgba(47, 128, 255, .16);
}

input:disabled,
textarea:disabled,
select:disabled {
  opacity: .6;
  cursor: not-allowed;
}

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

.auth-panel {
  display: grid;
  place-items: center;
  min-height: 70vh;
}

.form-card {
  display: grid;
  gap: var(--space-3);
  width: min(460px, 100%);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
}

.full-field,
.wide-field {
  grid-column: 1 / -1;
}

.builder-form,
.workout-log-form {
  display: grid;
  gap: var(--space-4);
}

.exercise-builder {
  display: grid;
  gap: var(--space-3);
}

.exercise-builder > .empty-state {
  height: auto;
}

.exercise-row {
  display: grid;
  grid-template-columns: 1fr;
  align-items: end;
  gap: var(--space-2);
  min-width: 0;
  padding: var(--space-3);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .035);
}

.exercise-picker-field {
  align-self: stretch;
}

.exercise-choice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #0f172a;
  color: var(--text);
  padding: 11px 12px;
  font: inherit;
  font-weight: 750;
  text-align: left;
  cursor: pointer;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

.exercise-choice::after {
  content: "+";
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  color: var(--blue-2);
}

.exercise-choice:hover,
.exercise-choice:focus {
  border-color: rgba(88, 199, 255, .7);
  background: #111c32;
  box-shadow: 0 0 0 3px rgba(47, 128, 255, .16);
  outline: none;
}

.exercise-choice span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.exercise-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-1);
  flex-wrap: wrap;
  grid-column: 1 / -1;
  align-self: end;
}

.exercise-modal[hidden] {
  display: none;
}

.exercise-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: var(--space-3);
}

.exercise-modal-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(2, 8, 23, .74);
  cursor: pointer;
}

.exercise-modal-panel {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: var(--space-3);
  width: min(860px, 100%);
  max-height: min(760px, calc(100vh - 32px));
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(27, 39, 64, .99), rgba(15, 23, 42, .99));
  box-shadow: var(--shadow);
  padding: var(--space-4);
}

.exercise-modal-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 240px);
  gap: var(--space-2);
  align-items: end;
}

.exercise-library-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr));
  grid-auto-rows: 98px;
  gap: var(--space-2);
  min-height: 0;
  overflow-y: auto;
  padding: 0 2px var(--space-2) 0;
}

.exercise-library-item {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  min-height: 0;
  height: 98px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .035);
  color: var(--text);
  padding: var(--space-2);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform .16s ease, border-color .16s ease, background .16s ease;
}

.exercise-library-item[hidden] {
  display: none;
}

.exercise-library-item:hover,
.exercise-library-item:focus {
  transform: translateY(-1px);
  border-color: rgba(88, 199, 255, .5);
  background: rgba(47, 128, 255, .12);
  outline: none;
}

.exercise-library-item strong,
.exercise-library-item span {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.exercise-library-item strong {
  display: -webkit-box;
  overflow: hidden;
  line-height: 1.28;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.exercise-library-item span {
  color: var(--muted);
  font-size: .86rem;
  line-height: 1.2;
}

.inline-form {
  align-items: end;
}

.inline-form input,
.inline-form select {
  flex: 1 1 220px;
}

.sticky-actions {
  position: sticky;
  bottom: 88px;
  z-index: 10;
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  flex-wrap: wrap;
  padding: var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(13, 19, 32, .94);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

/* Workout UI */
.exercise-card {
  display: grid;
  gap: var(--space-3);
  min-width: 0;
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border-soft);
}

.exercise-card:last-child {
  border-bottom: 0;
}

.set-targets {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-1);
}

.set-targets span {
  min-width: 0;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 9px;
  color: var(--muted);
  text-align: center;
  overflow-wrap: anywhere;
}

.timer-display {
  color: var(--blue-2);
  font-size: clamp(2.4rem, 13vw, 6rem);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  overflow-wrap: anywhere;
}

.workout-mode-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-width: 0;
  padding: var(--space-3);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .035);
}

.workout-mode-bar h2,
.workout-mode-bar p {
  margin-bottom: 0;
}

.segmented-control {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(15, 23, 42, .72);
}

.segmented-control button {
  min-height: 36px;
  min-width: 86px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: .88rem;
  font-weight: 800;
  cursor: pointer;
}

.segmented-control button.active {
  background: linear-gradient(135deg, rgba(59, 130, 246, .28), rgba(34, 197, 94, .16));
  color: var(--text);
}

.workout-stepper {
  gap: var(--space-4);
}

.stepper-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
}

.stepper-top h2,
.stepper-top p {
  margin-bottom: 0;
}

.step-progress {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, .07);
}

.step-progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--blue));
  transition: width .2s ease;
}

.step-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-3);
}

.stepper-actions {
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
}

.stepper-actions .button {
  min-width: 140px;
}

.set-grid {
  display: grid;
  gap: var(--space-1);
  min-width: 0;
  overflow-x: auto;
  padding-bottom: var(--space-1);
}

.set-row {
  display: grid;
  grid-template-columns: 48px repeat(4, minmax(112px, 1fr));
  align-items: center;
  gap: var(--space-1);
  min-width: 620px;
}

.set-row-head {
  color: var(--muted);
  font-size: .9rem;
}

.set-row > span {
  color: var(--muted);
  font-size: .9rem;
}

.set-row.is-complete > span:first-child {
  color: var(--green-2);
  font-weight: 850;
}

.chart {
  width: 100%;
  height: 260px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--surface-2);
}

/* Tables */
.table-panel {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}

th,
td {
  padding: var(--space-3);
  border-bottom: 1px solid var(--border-soft);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: .85rem;
}

.admin-controls,
.admin-plan-form {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex-wrap: wrap;
  min-width: 0;
}

.admin-plan-form select {
  width: auto;
  min-width: 118px;
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  color: var(--muted);
  font-size: .9rem;
}

/* Tablet */
@media (min-width: 700px) {
  .public-shell,
  .app-shell {
    width: min(var(--content-max), calc(100% - 48px));
    padding-top: var(--space-4);
  }

  .hero {
    grid-template-columns: minmax(0, 1fr) minmax(320px, .85fr);
  }

  .screenshot-stack {
    grid-template-columns: minmax(0, 1fr);
  }

  .metrics-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .content-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .exercise-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .set-targets {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .exercise-card {
    grid-template-columns: minmax(0, 1fr) minmax(340px, .9fr);
    align-items: center;
  }

  .screenshot-stack {
    align-self: stretch;
  }
}

@media (min-width: 1220px) {
  .exercise-row {
    grid-template-columns: minmax(160px, 1.4fr) minmax(110px, .9fr) minmax(70px, .55fr) minmax(90px, .75fr) minmax(90px, .75fr) minmax(90px, .75fr) minmax(150px, 1.2fr) 42px;
  }
}

/* Desktop */
@media (min-width: 1020px) {
  .sidebar {
    position: fixed;
    inset: var(--space-3) auto var(--space-3) var(--space-3);
    z-index: 30;
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    width: var(--sidebar-width);
    padding: var(--space-3);
    border: 1px solid var(--border-soft);
    border-radius: 14px;
    background: rgba(13, 19, 32, .94);
    box-shadow: var(--shadow);
  }

  .side-nav {
    display: grid;
    gap: var(--space-1);
  }

  .nav-link {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-width: 0;
    min-height: 44px;
    padding: 10px 12px;
    border-radius: var(--radius);
    color: var(--muted);
    font-weight: 650;
    transition: background .16s ease, color .16s ease, transform .16s ease;
  }

  .nav-link:hover {
    transform: translateX(2px);
    background: rgba(59, 130, 246, .12);
    color: var(--text);
  }

  .nav-link.active {
    background: linear-gradient(135deg, rgba(59, 130, 246, .2), rgba(34, 197, 94, .12));
    color: var(--text);
  }

  .nav-icon {
    display: inline-grid;
    place-items: center;
    width: 22px;
    height: 22px;
    flex: 0 0 22px;
    color: var(--green-2);
  }

  .nav-icon svg {
    display: block;
    width: 20px;
    height: 20px;
  }

  .app-shell {
    width: min(var(--content-max), calc(100% - var(--sidebar-width) - 72px));
    margin-left: calc(var(--sidebar-width) + 48px);
    margin-right: var(--space-4);
    padding-top: var(--space-4);
  }

  .bottom-nav {
    display: none;
  }

  .brand.compact {
    visibility: hidden;
  }

  .sticky-actions {
    bottom: var(--space-4);
  }
}

/* Mobile */
@media (max-width: 699px) {
  .public-shell,
  .app-shell {
    width: min(100% - 24px, var(--content-max));
    padding-bottom: 104px;
  }

  .topbar {
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
  }

  .topbar-actions {
    flex: 0 0 auto;
    flex-wrap: nowrap;
    justify-content: flex-end;
    margin-left: auto;
    gap: 6px;
  }

  .topbar-actions .plan-badge {
    min-height: 34px;
    padding: 7px 10px;
    flex: 0 0 auto;
  }

  .topbar-actions .user-chip {
    display: none;
  }

  .topbar-actions .logout-form,
  .topbar-actions .logout-button {
    flex: 0 0 auto;
  }

  .topbar-actions .logout-button {
    min-height: 34px;
    padding: 7px 11px;
    border-radius: 999px;
    font-size: .82rem;
  }

  .brand.compact {
    flex: 1 1 auto;
    font-size: 1rem;
  }

  .brand.compact .brand-mark {
    width: 44px;
    height: 44px;
    flex-basis: 44px;
    border-radius: 11px;
  }

  .page-heading,
  .workout-log-heading,
  .workout-start,
  .completion-hero,
  .cta-band,
  .upgrade-banner,
  .plan-panel,
  .workout-mode-bar,
  .stepper-top,
  .stepper-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .page-heading .button,
  .workout-start .button,
  .completion-hero .button,
  .cta-band .button,
  .upgrade-banner .button,
  .plan-panel .button {
    width: 100%;
  }

  .hero {
    min-height: auto;
    padding-top: var(--space-1);
    gap: var(--space-4);
  }

  .hero-copy p {
    font-size: 1rem;
  }

  .main-shot {
    min-height: 240px;
    padding: var(--space-3);
  }

  .metrics-grid,
  .section-grid,
  .pricing-grid,
  .card-grid,
  .records-grid,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .plan-panel,
  .upgrade-grid,
  .plan-limit-grid {
    grid-template-columns: 1fr;
  }

  .upgrade-grid .price-card {
    min-height: 0;
    padding: var(--space-3);
  }

  .feature-card,
  .price-card,
  .panel,
  .routine-card,
  .record-card,
  .recommendation-card,
  .metric-card,
  .form-card,
  .workout-card,
  .empty-state,
  .testimonials article {
    height: auto;
    padding: var(--space-3);
  }

  .panel-heading,
  .card-top,
  .list-row {
    align-items: stretch;
    flex-direction: column;
  }

  .routine-list-card {
    grid-template-columns: 1fr;
    gap: var(--space-3);
    min-height: 0;
  }

  .routine-card-header {
    flex-direction: column;
  }

  .routine-side {
    justify-items: stretch;
  }

  .routine-count {
    place-items: start;
    width: 100%;
    text-align: left;
  }

  .routine-actions {
    justify-content: stretch;
    width: 100%;
  }

  .routine-actions .button {
    flex: 1 1 100%;
  }

  .button-row {
    width: 100%;
  }

  .button-row form,
  .button-row .button {
    flex: 1 1 160px;
  }

  .inline-form {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .inline-form .button,
  .inline-form input,
  .inline-form select {
    width: 100%;
  }

  .sticky-actions {
    justify-content: stretch;
  }

  .sticky-actions .button {
    flex: 1 1 160px;
  }

  .segmented-control,
  .segmented-control button,
  .stepper-actions .button {
    width: 100%;
  }

  .segmented-control {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .step-fields {
    grid-template-columns: 1fr;
  }

  .exercise-modal {
    align-items: end;
    padding: var(--space-2);
  }

  .exercise-modal-panel {
    max-height: calc(100vh - 24px);
    padding: var(--space-3);
  }

  .exercise-modal-controls {
    grid-template-columns: 1fr;
  }

  .exercise-library-list {
    grid-template-columns: 1fr;
  }

  .set-row {
    grid-template-columns: 44px repeat(4, 112px);
  }

  .timer-display {
    text-align: left;
  }

  .site-footer {
    flex-direction: column;
  }
}

@media (max-width: 430px) {
  .topbar-actions {
    gap: 5px;
  }

  .topbar-actions .plan-badge {
    min-height: 32px;
    padding: 6px 9px;
    font-size: .7rem;
  }

  .topbar-actions .logout-button {
    width: 34px;
    height: 34px;
    min-height: 34px;
    padding: 0;
  }

  .logout-button .logout-text {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
  }

  .logout-button .logout-icon {
    display: grid;
  }

  .brand.compact {
    gap: 8px;
    font-size: .96rem;
  }
}
