:root {
  --bg: #f6f1e8;
  --bg-soft: #fff9ef;
  --panel: #fffdf7;
  --ink: #0f2d3f;
  --ink-soft: #345a71;
  --line: #e5d7c0;
  --accent: #cb5238;
  --accent-2: #1f8a74;
  --accent-3: #c7932f;
  --shadow: 0 12px 30px rgba(15, 45, 63, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Manrope", "Avenir Next", "Segoe UI", sans-serif;
  background: radial-gradient(circle at 10% 12%, #fff6dd, transparent 32%),
    radial-gradient(circle at 88% 8%, #dcf3ea, transparent 29%),
    linear-gradient(170deg, var(--bg), #fefbf4 45%, #f4ecdc);
  min-height: 100vh;
  padding-bottom: calc(5rem + env(safe-area-inset-bottom));
}

section {
  scroll-margin-top: 4.8rem;
}

.container {
  width: min(1080px, calc(100% - 1rem));
  margin: 0 auto;
}

.ambient {
  position: fixed;
  border-radius: 999px;
  filter: blur(34px);
  opacity: 0.22;
  pointer-events: none;
  z-index: -1;
}

.ambient-one {
  width: 250px;
  height: 250px;
  top: -120px;
  left: -90px;
  background: #ffd9b0;
}

.ambient-two {
  width: 260px;
  height: 260px;
  top: 20%;
  right: -100px;
  background: #c9eadf;
}

h1,
h2,
h3,
h4 {
  margin: 0;
}

h1,
h2 {
  font-family: "Bebas Neue", "Franklin Gothic Medium", sans-serif;
  letter-spacing: 0.03em;
}

.hero {
  padding: 1.8rem 0 1rem;
}

.eyebrow {
  display: inline-block;
  margin: 0 0 0.45rem;
  padding: 0.35rem 0.78rem;
  border-radius: 999px;
  border: 1px solid rgba(203, 82, 56, 0.24);
  background: rgba(255, 247, 236, 0.85);
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

h1 {
  font-size: clamp(0.65rem, 4vw, 1.12rem);
  line-height: 0.9;
  margin-bottom: 0.58rem;
}

.brand-mark .brand-gym {
  color: #1f8a74;
}

.brand-mark .brand-raged {
  color: #cb5238;
}

.brand-mark {
  display: inline-flex;
  align-items: baseline;
  gap: 0.08em;
  font-family: "Manrope", "Avenir Next", "Segoe UI", sans-serif;
  letter-spacing: 0;
  text-transform: none;
}

.brand-mark .brand-gym {
  font-family: "Barlow Condensed", "Manrope", sans-serif;
  font-weight: 800;
  letter-spacing: 0.015em;
}

.brand-mark .brand-raged {
  display: inline-block;
  font-family: "Archivo Black", "Manrope", sans-serif;
  font-weight: 400;
  letter-spacing: 0.01em;
  transform: skewX(-8deg);
  text-shadow: 0.04em 0.03em 0 rgba(15, 45, 63, 0.18);
}

.lead {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.55;
  font-size: 0.93rem;
}

.hero-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.9rem;
}

.hero-pills span {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.76);
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.31rem 0.6rem;
}

.hero-actions {
  margin-top: 0.95rem;
  display: flex;
  gap: 0.56rem;
  align-items: center;
  flex-wrap: wrap;
}

.jump-btn,
.install-btn {
  min-height: 2.5rem;
  border-radius: 12px;
  border: 1px solid rgba(203, 82, 56, 0.28);
  padding: 0.52rem 0.82rem;
  text-decoration: none;
  font-size: 0.84rem;
  font-weight: 800;
  cursor: pointer;
}

.jump-btn {
  color: #fff;
  background: linear-gradient(135deg, #0f2d3f, #2b5e77);
  border-color: transparent;
}

.install-btn {
  color: var(--ink);
  background: linear-gradient(180deg, #fff2dd, #ffe9cc);
}

.top-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9;
  border-top: 1px solid rgba(229, 215, 192, 0.92);
  background: rgba(255, 252, 244, 0.97);
  backdrop-filter: blur(12px);
  padding-bottom: env(safe-area-inset-bottom);
}

.nav-inner {
  display: flex;
  gap: 0.48rem;
  overflow-x: auto;
  white-space: nowrap;
  padding: 0.58rem 0 0.72rem;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
}

.nav-inner::-webkit-scrollbar {
  display: none;
}

.nav-inner a,
.tab-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2rem;
  padding: 0.36rem 0.62rem;
  border-radius: 10px;
  border: 1px solid rgba(229, 215, 192, 0.96);
  background: #fff;
  text-decoration: none;
  color: var(--ink);
  font-weight: 700;
  font-size: 0.74rem;
  cursor: pointer;
  font-family: inherit;
  scroll-snap-align: center;
}

.nav-inner a:hover,
.tab-btn:hover {
  border-color: rgba(203, 82, 56, 0.46);
  color: var(--accent);
}

main {
  display: grid;
  gap: 0.8rem;
  padding: 0.38rem 0 1.4rem;
}

.panel {
  border-radius: 16px;
  border: 1px solid rgba(229, 215, 192, 0.94);
  background: linear-gradient(180deg, var(--panel), #fff7e8);
  box-shadow: var(--shadow);
  padding: 0.86rem;
}

.section-head {
  margin-bottom: 0.68rem;
}

.section-head h2 {
  font-size: clamp(1.5rem, 9vw, 2.25rem);
}

.section-head p {
  margin: 0.18rem 0 0;
  color: var(--ink-soft);
  line-height: 1.48;
  font-size: 0.86rem;
}

.order-list {
  margin: 0;
  padding-left: 1.1rem;
  display: grid;
  gap: 0.42rem;
  color: var(--ink-soft);
  font-size: 0.88rem;
  line-height: 1.5;
}

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

.stat-card {
  border: 1px solid rgba(229, 215, 192, 0.95);
  border-radius: 12px;
  padding: 0.65rem;
  background: rgba(255, 255, 255, 0.87);
}

.stat-value {
  margin: 0;
  font-size: 1.22rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1.1;
}

.stat-label {
  margin: 0.21rem 0 0;
  color: var(--ink-soft);
  font-size: 0.73rem;
  line-height: 1.33;
}

.logic-grid,
.program-grid,
.rules-grid,
.audit-grid {
  display: grid;
  gap: 0.58rem;
}

.logic-grid article {
  border-radius: 12px;
  border: 1px solid rgba(229, 215, 192, 0.9);
  background: #fffef7;
  padding: 0.68rem;
}

.program-grid {
  min-width: 0;
}

.plan-tabs {
  display: flex;
  gap: 0.38rem;
  overflow-x: auto;
  white-space: nowrap;
  padding: 0.04rem 0.2rem 0.22rem 0.06rem;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
}

.plan-tabs::-webkit-scrollbar {
  display: none;
}

.plan-tab-btn {
  flex: 0 0 auto;
  min-height: 2rem;
  padding: 0.33rem 0.62rem;
  border-radius: 999px;
  border: 1px solid rgba(229, 215, 192, 0.96);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  scroll-snap-align: center;
}

.plan-tab-btn.is-active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, #0f2d3f, #2b5e77);
}

.plan-summary-card {
  border-radius: 12px;
  border: 1px solid rgba(229, 215, 192, 0.95);
  background: #fffef8;
  padding: 0.66rem;
  min-width: 0;
}

.plan-summary-card h3 {
  font-size: 1rem;
  margin: 0 0 0.2rem;
}

.plan-summary-card p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.8rem;
  line-height: 1.42;
}

.plan-summary-actions {
  margin-top: 0.52rem;
  display: flex;
  align-items: center;
  gap: 0.48rem;
  flex-wrap: wrap;
}

.plan-activate-btn {
  min-height: 2.05rem;
  border-radius: 999px;
  border: 1px solid rgba(31, 138, 116, 0.42);
  background: #fff;
  color: #135f4f;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 0.34rem 0.74rem;
}

.plan-activate-btn.is-active {
  border-color: transparent;
  color: #fff;
  background: linear-gradient(135deg, #1f8a74, #26745f);
}

.plan-follow-state {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.74rem;
  line-height: 1.35;
}

.plan-block {
  min-width: 0;
  padding: 0.58rem;
}

.block-head {
  margin: 0 0 0.45rem;
}

.block-head h3 {
  margin: 0;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
}

.plan-accordion {
  border-radius: 12px;
  border: 1px solid rgba(229, 215, 192, 0.92);
  background: rgba(255, 253, 247, 0.9);
  overflow: hidden;
  min-width: 0;
}

.plan-accordion > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.62rem;
  font-size: 0.84rem;
  font-weight: 800;
  color: var(--ink);
}

.plan-accordion > summary::-webkit-details-marker {
  display: none;
}

.plan-accordion .accordion-indicator::before {
  content: "+";
  color: var(--ink-soft);
  font-weight: 800;
}

.plan-accordion[open] .accordion-indicator::before {
  content: "-";
}

.plan-accordion[open] .plan-block {
  border-top: 1px solid rgba(229, 215, 192, 0.92);
}

.program-day-tabs {
  display: flex;
  gap: 0.36rem;
  overflow-x: auto;
  white-space: nowrap;
  padding: 0 0.2rem 0.16rem 0.06rem;
  margin-bottom: 0.54rem;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
  scroll-padding-inline: 0.2rem;
}

.program-day-tabs::-webkit-scrollbar {
  display: none;
}

.program-day-tab-btn {
  flex: 0 0 auto;
  min-height: 2rem;
  padding: 0.33rem 0.58rem;
  border-radius: 999px;
  border: 1px solid rgba(229, 215, 192, 0.96);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  scroll-snap-align: center;
}

.program-day-tab-btn.is-active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, #0f2d3f, #2b5e77);
}

.program-day-content {
  display: block;
}

.logic-grid h3 {
  margin-bottom: 0.2rem;
  font-size: 0.96rem;
}

.logic-grid p {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.42;
  font-size: 0.82rem;
}

.day-card {
  border: 1px solid rgba(229, 215, 192, 0.94);
  border-radius: 13px;
  background: #fffdf7;
  padding: 0.68rem;
  display: grid;
  gap: 0.58rem;
}

.day-card.training {
  border-top: 3px solid var(--accent);
}

.day-card.recovery {
  border-top: 3px solid var(--accent-2);
}

.day-card.rest {
  border-top: 3px solid var(--accent-3);
}

.day-head {
  display: grid;
  gap: 0.18rem;
}

.day-head .day {
  font-weight: 800;
  font-size: 1.03rem;
}

.day-head .focus {
  color: var(--ink-soft);
  font-size: 0.82rem;
  line-height: 1.4;
}

.day-session-status {
  margin: 0;
  border-radius: 10px;
  border: 1px solid rgba(31, 138, 116, 0.34);
  background: rgba(223, 247, 241, 0.45);
  color: #135f4f;
  font-size: 0.75rem;
  line-height: 1.38;
  padding: 0.44rem 0.52rem;
}

.lift-list,
.task-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.58rem;
}

.lift-item {
  border-radius: 10px;
  border: 1px solid rgba(229, 215, 192, 0.95);
  background: #fff;
  padding: 0.58rem;
  display: grid;
  gap: 0.52rem;
}

.lift-item.is-active-lift {
  border-color: rgba(31, 138, 116, 0.48);
  box-shadow: 0 0 0 2px rgba(31, 138, 116, 0.14);
}

.lift-item.is-complete-lift {
  border-color: rgba(31, 138, 116, 0.28);
  background: linear-gradient(180deg, #fff, #f7fff9);
}

.lift-item h4 {
  margin-bottom: 0.12rem;
  font-size: 0.93rem;
}

.lift-meta {
  margin: 0;
  font-size: 0.72rem;
  color: var(--ink-soft);
  line-height: 1.36;
}

.lift-prev-reference {
  margin: 0.16rem 0 0;
  color: #135f4f;
  font-size: 0.72rem;
  line-height: 1.36;
}

.lift-details,
.lift-reason {
  margin: 0.24rem 0 0;
  font-size: 0.76rem;
  line-height: 1.42;
}

.lift-details {
  color: var(--ink-soft);
}

.lift-reason {
  color: var(--ink);
}

.alt-exercise-btn {
  display: inline;
  border: 0;
  background: transparent;
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  font: inherit;
  font-size: inherit;
  line-height: inherit;
  padding: 0;
  cursor: pointer;
}

.alt-exercise-btn.is-active {
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
}

.alt-exercise-text {
  color: var(--ink-soft);
}

.alt-sep {
  color: var(--ink-soft);
}

.lift-load-visual {
  margin-top: 0.36rem;
  min-height: 2rem;
  border-radius: 9px;
  border: 1px solid rgba(229, 215, 192, 0.95);
  background: #fff8eb;
  color: var(--ink);
  font-size: 0.71rem;
  font-weight: 700;
  padding: 0.3rem 0.56rem;
  cursor: pointer;
}

.lift-log-panel {
  margin-top: 0.4rem;
  border: 1px solid rgba(229, 215, 192, 0.95);
  border-radius: 10px;
  background: #fffaf0;
  padding: 0.5rem;
  display: grid;
  gap: 0.45rem;
}

.lift-log-last {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.72rem;
  line-height: 1.38;
}

.lift-set-guide {
  margin: 0;
  color: #135f4f;
  font-size: 0.74rem;
  line-height: 1.38;
  font-weight: 800;
}

.lift-log-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.42rem;
}

.lift-log-fields label,
.lift-log-panel > label {
  display: grid;
  gap: 0.18rem;
  color: var(--ink-soft);
  font-size: 0.7rem;
  font-weight: 700;
}

.lift-log-fields input,
.lift-log-fields select,
.lift-log-panel input {
  font: inherit;
  min-height: 2rem;
  border-radius: 9px;
  border: 1px solid rgba(229, 215, 192, 0.95);
  background: #fff;
  color: var(--ink);
  padding: 0.32rem 0.48rem;
}

.lift-log-actions {
  display: flex;
  gap: 0.38rem;
  flex-wrap: wrap;
}

.lift-log-save,
.lift-log-history-btn {
  min-height: 2rem;
  border-radius: 9px;
  border: 1px solid rgba(229, 215, 192, 0.95);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 0.32rem 0.6rem;
  cursor: pointer;
}

.lift-log-save:disabled,
.lift-log-history-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.lift-log-save {
  background: linear-gradient(180deg, #f7fff9, #e7f7ef);
  border-color: rgba(31, 138, 116, 0.35);
  color: #135f4f;
}

.lift-log-history {
  border-top: 1px dashed rgba(229, 215, 192, 0.95);
  padding-top: 0.32rem;
}

.lift-log-history-row,
.lift-log-history-empty {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.69rem;
  line-height: 1.4;
}

body.modal-open {
  overflow: hidden;
}

.tab-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.visual-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
}

.visual-modal-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  padding: 0;
  background: rgba(11, 25, 35, 0.62);
  cursor: pointer;
}

.visual-modal-dialog {
  position: absolute;
  left: 50%;
  bottom: calc(4.6rem + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(430px, calc(100% - 0.72rem));
  border-radius: 14px;
  border: 1px solid rgba(229, 215, 192, 0.95);
  background: #fffef8;
  box-shadow: 0 16px 32px rgba(11, 25, 35, 0.32);
  padding: 0.68rem;
  display: grid;
  gap: 0.48rem;
}

.visual-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.visual-modal-title {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.3;
  color: var(--ink);
}

.visual-modal-close {
  min-height: 1.95rem;
  border-radius: 999px;
  border: 1px solid rgba(229, 215, 192, 0.95);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.28rem 0.62rem;
  cursor: pointer;
}

.visual-modal-image {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: contain;
  border-radius: 9px;
  border: 1px solid rgba(229, 215, 192, 0.95);
  background: #f6efe1;
}

.history-modal {
  position: fixed;
  inset: 0;
  z-index: 31;
}

.history-modal-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  padding: 0;
  background: rgba(11, 25, 35, 0.62);
  cursor: pointer;
}

.history-modal-dialog {
  position: absolute;
  left: 50%;
  bottom: calc(4.6rem + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(430px, calc(100% - 0.72rem));
  max-height: min(76vh, 640px);
  border-radius: 14px;
  border: 1px solid rgba(229, 215, 192, 0.95);
  background: #fffef8;
  box-shadow: 0 16px 32px rgba(11, 25, 35, 0.32);
  padding: 0.68rem;
  display: grid;
  gap: 0.48rem;
}

.history-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.history-modal-title {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.3;
  color: var(--ink);
}

.history-modal-close {
  min-height: 1.95rem;
  border-radius: 999px;
  border: 1px solid rgba(229, 215, 192, 0.95);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.28rem 0.62rem;
  cursor: pointer;
}

#historyModalBody {
  max-height: min(56vh, 500px);
  overflow-y: auto;
  padding-right: 0.08rem;
}

.task-list li {
  border-radius: 10px;
  border: 1px dashed rgba(31, 138, 116, 0.36);
  background: rgba(223, 247, 241, 0.48);
  padding: 0.5rem 0.56rem;
  font-size: 0.82rem;
  line-height: 1.38;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
}

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

th,
td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 0.56rem 0.6rem;
  vertical-align: top;
}

th {
  background: #fff6e6;
  font-size: 0.78rem;
}

td {
  font-size: 0.8rem;
  line-height: 1.43;
}

.rule-card {
  border-radius: 12px;
  border: 1px solid rgba(229, 215, 192, 0.95);
  background: #fffef8;
  padding: 0.68rem;
}

.rule-card h3 {
  margin-bottom: 0.36rem;
  font-size: 0.95rem;
}

.rule-card ul {
  margin: 0;
  padding-left: 1rem;
  color: var(--ink-soft);
  line-height: 1.48;
  font-size: 0.82rem;
}

.filters {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.56rem;
  align-items: end;
  margin-bottom: 0.68rem;
}

.filters label {
  display: grid;
  gap: 0.24rem;
  color: var(--ink-soft);
  font-size: 0.74rem;
  font-weight: 700;
}

.filters input,
.filters select,
.filters button {
  font: inherit;
  min-height: 2.4rem;
  border-radius: 10px;
  border: 1px solid rgba(229, 215, 192, 0.96);
  background: #fff;
  color: var(--ink);
  padding: 0.45rem 0.58rem;
}

.filters input:focus,
.filters select:focus {
  outline: 2px solid rgba(31, 138, 116, 0.25);
  outline-offset: 1px;
}

.filters button {
  background: linear-gradient(180deg, #fff4df, #ffe9cb);
  font-weight: 800;
}

.results-meta {
  margin: 0.2rem 0 0.68rem;
  color: var(--ink-soft);
  font-size: 0.78rem;
}

.profile-grid {
  display: grid;
  gap: 0.58rem;
}

.profile-card {
  border-radius: 12px;
  border: 1px solid rgba(229, 215, 192, 0.95);
  background: #fffef8;
  padding: 0.68rem;
  display: grid;
  gap: 0.44rem;
}

.profile-card h3 {
  font-size: 0.96rem;
}

.profile-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.profile-muted {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.74rem;
  line-height: 1.38;
}

.profile-muted.is-error {
  color: #9b2b2b;
}

.profile-form {
  display: grid;
  gap: 0.45rem;
}

.profile-form label,
.profile-inline-search {
  display: grid;
  gap: 0.2rem;
  color: var(--ink-soft);
  font-size: 0.74rem;
  font-weight: 700;
}

.profile-inline-fields {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.42rem;
}

.auth-mobile-fields {
  grid-template-columns: 120px minmax(0, 1fr);
}

.profile-inline-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.profile-form input,
.profile-form select,
.profile-form button,
.profile-inline-search input,
.profile-card-head button {
  font: inherit;
  min-height: 2.2rem;
  border-radius: 10px;
  border: 1px solid rgba(229, 215, 192, 0.96);
  background: #fff;
  color: var(--ink);
  padding: 0.4rem 0.56rem;
}

.profile-form button,
.profile-card-head button {
  background: linear-gradient(180deg, #fff4df, #ffe9cb);
  font-weight: 800;
  cursor: pointer;
}

.compact-inline-fields {
  grid-template-columns: minmax(0, 1fr) 82px;
}

.metric-log-grid {
  display: grid;
  gap: 0.44rem;
}

.metric-log-row {
  display: grid;
  gap: 0.2rem;
}

.metric-label {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.74rem;
  font-weight: 700;
}

.metric-log-fields {
  display: grid;
  gap: 0.34rem;
  align-items: center;
}

.metric-log-fields-weight {
  grid-template-columns: minmax(0, 1fr) 70px auto;
}

.metric-log-fields-single {
  grid-template-columns: minmax(0, 1fr) auto;
}

.metric-log-fields-bp {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
}

.metric-log-fields-measure {
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr) auto;
}

.metric-log-btn {
  min-height: 2.05rem;
  border-radius: 9px;
  border: 1px solid rgba(229, 215, 192, 0.95);
  background: linear-gradient(180deg, #fff4df, #ffe9cb);
  color: var(--ink);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 0.28rem 0.56rem;
  cursor: pointer;
  white-space: nowrap;
}

.measurement-guide {
  margin: 0;
  padding-left: 1rem;
  color: var(--ink-soft);
  font-size: 0.72rem;
  line-height: 1.45;
  display: grid;
  gap: 0.14rem;
}

.measurement-guide-wrap {
  border-radius: 10px;
  border: 1px solid rgba(229, 215, 192, 0.95);
  background: #fff;
  padding: 0.42rem 0.5rem;
}

.measurement-guide-wrap > summary {
  cursor: pointer;
  color: var(--ink-soft);
  font-size: 0.74rem;
  font-weight: 800;
}

.measurement-guide-wrap[open] > summary {
  margin-bottom: 0.28rem;
}

.chart-stack {
  display: grid;
  gap: 0.48rem;
}

.profile-chart-block {
  border-radius: 10px;
  border: 1px solid rgba(229, 215, 192, 0.95);
  background: #fff;
  padding: 0.46rem;
  display: grid;
  gap: 0.3rem;
}

.chart-title {
  margin: 0;
  font-size: 0.72rem;
  color: var(--ink-soft);
  font-weight: 800;
}

.profile-chart {
  min-height: 72px;
}

.chart-empty {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.72rem;
  line-height: 1.35;
}

.sparkline {
  width: 100%;
  height: 88px;
  display: block;
}

.sparkline-bg {
  fill: #fffaf0;
  stroke: rgba(229, 215, 192, 0.95);
}

.sparkline-area {
  fill: rgba(31, 138, 116, 0.14);
}

.sparkline-line {
  fill: none;
  stroke: #1f8a74;
  stroke-width: 2;
}

.sparkline-line-secondary {
  fill: none;
  stroke: #b94b4b;
  stroke-width: 2;
}

.sparkline-point {
  fill: #1f8a74;
}

.sparkline-point-secondary {
  fill: #b94b4b;
}

.sparkline-caption {
  margin: 0.12rem 0 0;
  color: var(--ink-soft);
  font-size: 0.69rem;
}

.bmi-chart {
  border-radius: 10px;
  border: 1px solid rgba(229, 215, 192, 0.95);
  background: #fff;
  padding: 0.46rem;
  display: grid;
  gap: 0.36rem;
}

.bmi-bar-wrap {
  position: relative;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  display: grid;
  grid-template-columns: 22fr 28fr 25fr 25fr;
}

.bmi-segment-under {
  background: #7cb6ff;
}

.bmi-segment-normal {
  background: #34a853;
}

.bmi-segment-over {
  background: #fbbc05;
}

.bmi-segment-obese {
  background: #ea4335;
}

.bmi-marker {
  position: absolute;
  top: -3px;
  width: 2px;
  height: 18px;
  background: #0f2d3f;
}

.bmi-labels {
  margin: 0;
  font-size: 0.68rem;
  color: var(--ink-soft);
  display: flex;
  justify-content: space-between;
  gap: 0.2rem;
}

.measurement-bars {
  display: grid;
  gap: 0.36rem;
}

.measurement-row {
  display: grid;
  gap: 0.14rem;
}

.measurement-meta {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.68rem;
}

.measurement-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: #f6efe1;
  overflow: hidden;
}

.measurement-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #1f8a74, #2b5e77);
}

.history-list {
  display: grid;
  gap: 0.42rem;
}

.history-item {
  border-radius: 10px;
  border: 1px solid rgba(229, 215, 192, 0.94);
  background: #fff;
  padding: 0.5rem;
  display: grid;
  gap: 0.16rem;
}

.history-title {
  margin: 0;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 800;
}

.history-value {
  margin: 0;
  color: #135f4f;
  font-size: 0.76rem;
  font-weight: 800;
}

.history-soft {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.72rem;
  line-height: 1.35;
}

.empty-state {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.74rem;
  line-height: 1.38;
}

.exercise-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.56rem;
}

.exercise-card {
  border-radius: 12px;
  border: 1px solid rgba(229, 215, 192, 0.95);
  background: #fff;
  overflow: hidden;
  display: grid;
}

.exercise-media {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: contain;
  border-bottom: 1px solid var(--line);
  background: #f6efe1;
}

.exercise-body {
  padding: 0.56rem;
  display: grid;
  gap: 0.3rem;
}

.exercise-title {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.34;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.34rem;
}

.badge {
  border-radius: 999px;
  background: rgba(15, 45, 63, 0.08);
  color: var(--ink);
  font-size: 0.67rem;
  font-weight: 700;
  padding: 0.2rem 0.42rem;
}

.badge.alt {
  background: rgba(31, 138, 116, 0.14);
}

.exercise-instructions {
  margin: 0.05rem 0 0;
  color: var(--ink-soft);
  font-size: 0.74rem;
  line-height: 1.4;
}

.exercise-instructions ol {
  margin: 0.35rem 0 0;
  padding-left: 1rem;
}

.pager {
  margin-top: 0.68rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.pager button {
  min-height: 2.15rem;
  min-width: 5.8rem;
  border-radius: 10px;
  border: 1px solid rgba(229, 215, 192, 0.96);
  background: #fff;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
}

.pager button:disabled {
  opacity: 0.5;
}

#pageInfo {
  color: var(--ink-soft);
  font-size: 0.78rem;
}

.audit-card {
  border-radius: 10px;
  border: 1px solid rgba(229, 215, 192, 0.95);
  background: #fff;
  padding: 0.62rem;
}

.audit-card h3 {
  margin-bottom: 0.22rem;
  color: var(--ink-soft);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.audit-card p {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 800;
}

.audit-notes {
  margin: 0.82rem 0 0;
  padding-left: 1rem;
  color: var(--ink-soft);
  font-size: 0.8rem;
  line-height: 1.48;
}

.footer {
  padding-bottom: 1rem;
}

.footer p {
  margin: 0;
  color: var(--ink-soft);
  text-align: center;
  font-size: 0.74rem;
}

.reveal {
  opacity: 0;
  transform: translateY(14px);
  animation: reveal-up 0.62s ease forwards;
}

@keyframes reveal-up {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (min-width: 460px) {
  .stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

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

@media (min-width: 700px) {
  body {
    padding-bottom: 5.2rem;
  }

  .container {
    width: min(1080px, calc(100% - 1.6rem));
  }

  .hero {
    padding-top: 2.3rem;
  }

  .lead {
    font-size: 0.97rem;
    max-width: 62ch;
  }

  .panel {
    padding: 1rem;
  }

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

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

  .lift-item {
    grid-template-columns: 1fr;
    gap: 0.6rem;
    align-items: start;
  }

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

  .filters button {
    grid-column: span 2;
  }

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

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

@media (min-width: 900px) {
  body {
    padding-bottom: 0;
  }

  .ambient {
    opacity: 0.32;
    animation: drift 12s ease-in-out infinite alternate;
  }

  .hero {
    padding: 3.4rem 0 2rem;
  }

  .top-nav {
    position: sticky;
    top: 0;
    bottom: auto;
    border-top: 1px solid rgba(229, 215, 192, 0.75);
    border-bottom: 1px solid rgba(229, 215, 192, 0.92);
  }

  .nav-inner {
    overflow-x: visible;
    white-space: normal;
    flex-wrap: wrap;
    gap: 0.58rem;
    padding: 0.62rem 0;
  }

  .nav-inner a {
    font-size: 0.78rem;
  }

  .panel {
    border-radius: 18px;
    padding: 1.1rem;
  }

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

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

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

  .filters {
    grid-template-columns: 1.5fr repeat(3, 1fr) auto;
  }

  .filters button {
    grid-column: auto;
  }

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

  .visual-modal-dialog {
    bottom: auto;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(560px, calc(100% - 2rem));
  }

  .history-modal-dialog {
    bottom: auto;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(620px, calc(100% - 2rem));
    max-height: 82vh;
  }
}

@keyframes drift {
  from {
    transform: translate3d(0, 0, 0);
  }
  to {
    transform: translate3d(18px, 14px, 0);
  }
}

/* Mobile-only hard lock */
html,
body {
  overflow-x: hidden;
}

body {
  padding-bottom: calc(4.4rem + env(safe-area-inset-bottom));
}

.container {
  width: min(430px, calc(100% - 0.72rem));
}

.top-nav {
  position: fixed;
  bottom: 0;
  top: auto;
  left: 0;
  right: 0;
  z-index: 12;
  padding-bottom: env(safe-area-inset-bottom);
}

.nav-inner {
  display: flex;
  gap: 0.34rem;
  overflow-x: auto;
  white-space: nowrap;
  padding: 0.5rem 0.24rem 0.56rem;
  scroll-padding-inline: 0.24rem;
}

.tab-btn {
  flex: 0 0 auto;
  min-height: 1.95rem;
  padding: 0.28rem 0.5rem;
  font-size: 0.66rem;
  line-height: 1.2;
  border-radius: 999px;
}

.tab-btn.is-active {
  border-color: transparent;
  background: linear-gradient(135deg, #0f2d3f, #2b5e77);
  color: #fff;
}

.plan-tab-btn {
  min-height: 1.92rem;
  padding: 0.29rem 0.52rem;
  font-size: 0.68rem;
}

.program-day-tab-btn {
  min-height: 1.92rem;
  padding: 0.29rem 0.52rem;
  font-size: 0.68rem;
}

body.tabs-ready .tab-section {
  display: none;
}

body.tabs-ready .tab-section.is-active {
  display: block;
}

.panel,
.section-head p,
.stat-card,
.logic-grid article,
.day-card,
.lift-item,
.lift-log-panel,
.rule-card,
.exercise-card,
.exercise-body,
.audit-card,
.audit-notes,
.profile-card,
.history-item,
.lift-meta,
.lift-details,
.lift-reason,
.exercise-title,
.task-list li,
td {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.hero-actions {
  gap: 0.44rem;
}

.jump-btn,
.install-btn {
  min-height: 2.3rem;
  padding: 0.45rem 0.66rem;
  font-size: 0.78rem;
}

.stats-grid,
.logic-grid,
.program-grid,
.rules-grid,
.audit-grid,
.profile-grid,
.exercise-grid {
  grid-template-columns: 1fr;
}

.filters {
  grid-template-columns: 1fr !important;
}

.filters button {
  grid-column: auto !important;
}

.lift-item {
  grid-template-columns: 1fr;
}

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

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

.auth-mobile-fields {
  grid-template-columns: 96px minmax(0, 1fr) !important;
}

.compact-inline-fields {
  grid-template-columns: minmax(0, 1fr) 76px !important;
}

.metric-log-fields-weight {
  grid-template-columns: minmax(0, 1fr) 66px auto;
}

.metric-log-fields-single {
  grid-template-columns: minmax(0, 1fr) auto;
}

.metric-log-fields-bp {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
}

.metric-log-fields-measure {
  grid-template-columns: 1fr;
}

.profile-inline-actions {
  display: grid;
  grid-template-columns: 1fr;
}

.pager {
  gap: 0.36rem;
}

.pager button {
  min-width: 4.6rem;
  min-height: 2rem;
  font-size: 0.76rem;
}

.table-wrap {
  overflow: visible;
  border: none;
  background: transparent;
}

table,
thead,
tbody,
tr,
th,
td {
  display: block;
  width: 100%;
}

thead {
  display: none;
}

table {
  min-width: 0;
  border-collapse: separate;
}

tr {
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
  margin-bottom: 0.52rem;
  padding: 0.16rem 0.22rem;
}

td {
  border-bottom: none;
  padding: 0.34rem 0.38rem;
  font-size: 0.78rem;
  line-height: 1.38;
}

td::before {
  content: attr(data-label);
  display: block;
  margin-bottom: 0.16rem;
  color: var(--ink-soft);
  font-size: 0.68rem;
  font-weight: 800;
}

@media (max-width: 350px) {
  .container {
    width: min(430px, calc(100% - 0.5rem));
  }

  .hero-actions {
    display: grid;
    width: 100%;
    grid-template-columns: 1fr;
  }

  .jump-btn,
  .install-btn {
    width: 100%;
  }

  .tab-btn {
    font-size: 0.63rem;
  }

  td {
    font-size: 0.75rem;
  }
}
