/* Theme tokens live here. Components only consume vars — never hard-code theme hex. */
:root,
[data-theme="default"] {
  color-scheme: light;
  --bg: #f3f0ea;
  --surface: #fffdf9;
  --ink: #1c1916;
  --muted: #5f574f;
  --heading: var(--ink);
  --line: #8f867a;
  --line-soft: #e3dbd0;
  --accent: #9a3412;
  --accent-ink: #fff7f2;
  --hot: #9a3412;
  --ice: transparent;
  --danger: #9f1239;
  --notice-bg: #dcfce7;
  --notice-ink: #14532d;
  --notice-border: #15803d;
  --alert-bg: #ffe4e6;
  --alert-ink: #881337;
  --alert-border: #be123c;
  --font: ui-sans-serif, "Avenir Next", "Segoe UI", sans-serif;
  --display: var(--font);
  --radius: 12px;
  --shadow: 0 1px 0 color-mix(in srgb, var(--ink) 4%, transparent);
  --shadow-elevated: 0 6px 20px color-mix(in srgb, var(--ink) 12%, transparent);
  --overlay: color-mix(in srgb, var(--ink) 55%, transparent);
  --video-bg: #000;
  --glow-1: color-mix(in srgb, var(--hot) 12%, transparent);
  --glow-2: transparent;
  --panel-border: var(--line-soft);
  --panel-inset: transparent;
  --panel-shadow: var(--shadow);
  --btn-primary-bg: var(--accent);
  --btn-primary-shadow: none;
  --nav-bg: var(--surface);
  --nav-border: var(--line-soft);
  --mark-shadow: none;
  --heading-tracking: -0.02em;
  --heading-transform: none;
}

[data-theme="streets-of-rage"] {
  color-scheme: dark;
  --bg: #100712;
  --surface: #1b0e22;
  --ink: #f6f0ff;
  --muted: #c9b6d8;
  --heading: var(--ink);
  --line: #83639e;
  --line-soft: #3d2752;
  --accent: #ffe14a;
  --accent-ink: #160910;
  --hot: #ff2d95;
  --ice: #2de2e6;
  --danger: #ff5d4a;
  --notice-bg: #123b32;
  --notice-ink: #b6f7df;
  --notice-border: #34d399;
  --alert-bg: #501a32;
  --alert-ink: #ffe4e6;
  --alert-border: #fb7185;
  --font: "Avenir Next", "Segoe UI", sans-serif;
  --display: Impact, "Arial Black", "Avenir Next Condensed", sans-serif;
  --radius: 4px;
  --shadow: none;
  --shadow-elevated: 0 6px 20px color-mix(in srgb, #000 40%, transparent);
  --overlay: color-mix(in srgb, #000 65%, transparent);
  --glow-1: color-mix(in srgb, var(--hot) 18%, transparent);
  --glow-2: color-mix(in srgb, var(--ice) 12%, transparent);
  --panel-border: color-mix(in srgb, var(--hot) 55%, var(--line));
  --panel-inset: color-mix(in srgb, var(--ice) 35%, transparent);
  --panel-shadow: inset 0 0 0 1px var(--panel-inset);
  --btn-primary-bg: var(--accent);
  --btn-primary-shadow: 3px 3px 0 var(--hot);
  --nav-bg: var(--surface);
  --heading-tracking: 0.04em;
  --heading-transform: uppercase;
}

[data-theme="barbie-pink"] {
  color-scheme: light;
  --bg: #ffe4f1;
  --surface: #fff7fb;
  /* Darker ink/muted for WCAG contrast on pink surfaces */
  --ink: #2a0619;
  --muted: #4a152e;
  --heading: color-mix(in srgb, var(--accent) 55%, var(--ink));
  --line: #c45a96;
  --line-soft: #efb8d4;
  --accent: #ad1457;
  --accent-ink: #fff5fa;
  --hot: #c2185b;
  --ice: #a8841f;
  --danger: #9f1239;
  --notice-bg: #e8f8ef;
  --notice-ink: #14532d;
  --notice-border: #34d399;
  --alert-bg: #ffe0ec;
  --alert-ink: #831843;
  --alert-border: #c2185b;
  --font: "Avenir Next", "Segoe UI", ui-rounded, sans-serif;
  --display: "Avenir Next", "Segoe UI", ui-rounded, sans-serif;
  --radius: 18px;
  --shadow: 0 8px 24px color-mix(in srgb, var(--accent) 18%, transparent);
  --shadow-elevated: 0 8px 24px color-mix(in srgb, var(--accent) 22%, transparent);
  --glow-1: color-mix(in srgb, var(--hot) 28%, transparent);
  --glow-2: color-mix(in srgb, var(--ice) 35%, transparent);
  --panel-border: color-mix(in srgb, var(--hot) 40%, var(--line-soft));
  --panel-inset: color-mix(in srgb, var(--surface) 70%, #fff);
  --panel-shadow: var(--shadow), inset 0 0 0 1px var(--panel-inset);
  --btn-primary-bg: linear-gradient(180deg, color-mix(in srgb, var(--hot) 18%, var(--accent)), var(--accent));
  --btn-primary-shadow: 0 4px 0 color-mix(in srgb, var(--accent) 55%, var(--ink));
  --nav-bg: color-mix(in srgb, var(--surface) 88%, var(--hot));
  --nav-border: color-mix(in srgb, var(--hot) 35%, var(--line-soft));
  --mark-shadow: 0 1px 0 color-mix(in srgb, #fff 55%, transparent);
  --heading-tracking: 0.01em;
}

* { box-sizing: border-box; }

html { background: var(--bg); scroll-padding-top: 5.5rem; }

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--ink);
  background:
    radial-gradient(circle at top right, var(--glow-1), transparent 28rem),
    radial-gradient(circle at bottom left, var(--glow-2), transparent 22rem),
    var(--bg);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.45;
  overflow-x: clip;
}

a { color: var(--hot); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { color: var(--ink); }
.panel-head > a, .lede a { display: inline-flex; align-items: center; min-height: 44px; }

h1, h2, h3 {
  font-family: var(--display);
  font-weight: 650;
  letter-spacing: var(--heading-tracking);
  text-transform: var(--heading-transform);
  line-height: 1.1;
  margin: 0 0 0.4rem;
  color: var(--heading);
}

h1 { font-size: clamp(1.8rem, 3vw, 2.4rem); }
h2 { font-size: 1.15rem; }

p { margin: 0 0 1rem; }

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

:target, [id] { scroll-margin-top: 5.5rem; }

:focus-visible {
  outline: 2px solid var(--hot);
  outline-offset: 2px;
}
::placeholder { color: var(--muted); opacity: 1; }

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

.skip-link {
  position: absolute;
  inset: 0.5rem auto auto 0.5rem;
  z-index: 5;
  padding: 0.55rem 0.9rem;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  text-decoration: none;
  transform: translateY(-150%);
}
.skip-link:focus {
  transform: none;
}

.mark {
  font-family: var(--display);
  font-weight: 750;
  color: var(--heading);
  letter-spacing: var(--heading-tracking);
  text-transform: var(--heading-transform);
  text-shadow: var(--mark-shadow);
  text-decoration: none;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: center;
  padding: 0.75rem max(1.25rem, env(safe-area-inset-right, 0px)) 0.75rem max(1.25rem, env(safe-area-inset-left, 0px));
  border-bottom: 1px solid var(--nav-border);
  background: var(--nav-bg);
  position: sticky;
  top: 0;
  z-index: 2;
}

.nav-panel, .nav-end, .actions, .auth-links, .auth-brand, .page-head, .panel-head, .search {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

.nav-panel { flex: 1; gap: 0.6rem 1rem; }
.nav-panel a, .nav-meta {
  color: var(--muted);
  text-decoration: none;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 0 0.5rem;
  border-radius: 8px;
}
.nav-panel a.is-active { color: var(--ink); box-shadow: inset 0 -2px 0 var(--hot); }
.nav-end { margin-left: auto; display: flex; align-items: center; gap: 0.35rem; }
.nav-sign-out {
  color: var(--muted);
  background: transparent;
  border: 0;
  font: inherit;
  cursor: pointer;
  min-height: 44px;
  padding: 0 0.5rem;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
}
.nav-sign-out:hover { color: var(--ink); background: color-mix(in srgb, var(--hot) 8%, transparent); }
.banner-panel { border-color: color-mix(in srgb, var(--hot) 35%, var(--line-soft)); }
.banner-panel .lede { margin-bottom: 0.75rem; }
.stack-form {
  display: grid;
  gap: 0.75rem;
  margin: 0 0 0.75rem;
}
.stack-form .field { margin-bottom: 0; }
.stack-form .btn,
.stack-form input[type="submit"] {
  justify-self: start;
  width: auto;
  min-width: 8rem;
}
.workout-page .stack-form .btn,
.workout-page .stack-form input[type="submit"] {
  width: auto;
  max-width: none;
}
.public-footer {
  width: min(920px, calc(100% - 2rem));
  margin: 0 auto 2rem;
  color: var(--muted);
  font-size: 0.9rem;
}
.cta-panel { padding: 1.5rem; }
.pitch { margin: 0 0 1.2rem; padding-left: 1.2rem; }
.pitch li { margin-bottom: 0.3rem; }
.sharing { display: grid; gap: 0.75rem; }
.sharing h2 { margin: 0; }
.sharing label, .share-box label { font-size: 0.9rem; color: var(--ink); }
.share-box { display: grid; gap: 0.35rem; }
.share-row { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.share-row input { flex: 1 1 16rem; }
.share-row .btn { gap: 0.4rem; }
.share-row svg { width: 1.1rem; height: 1.1rem; }
select.compact { width: auto; }
fieldset.field { border: 0; margin: 0 0 0.9rem; padding: 0; }
fieldset.field legend { font-size: 0.9rem; color: var(--ink); margin-bottom: 0.35rem; }
.choice-group { margin-bottom: 1rem; }
.choice-group legend { margin-bottom: 0.5rem; }
.choice-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
}
.choice {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 2.75rem;
  margin: 0;
  padding: 0.35rem 0.5rem;
  border-radius: 8px;
  color: var(--ink);
  cursor: pointer;
  line-height: 1.2;
}
.choice + .choice { margin-top: 0; }
.choice:hover { background: color-mix(in srgb, var(--hot) 8%, transparent); }
.choice input { width: auto; min-height: 0; margin: 0; flex-shrink: 0; }
.choice-group .hint { margin-top: 0.5rem; }
.public-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-left: auto;
  padding-right: 0.15rem;
}
.public-nav a:not(.btn) { color: var(--muted); text-decoration: none; min-height: 44px; display: inline-flex; align-items: center; padding: 0 0.35rem; }
.nav-meta { font-size: 0.92rem; }

.burger {
  display: none;
  position: relative;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 2.75rem;
  min-width: 2.75rem;
  min-height: 2.75rem;
  margin-left: auto;
  padding: 0.65rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  flex-shrink: 0;
}
.burger:focus-visible {
  outline: 2px solid var(--hot);
  outline-offset: 2px;
}
.burger span:not(.sr) {
  display: block;
  height: 2px;
  width: 100%;
  background: currentColor;
}

.shell {
  width: min(920px, calc(100% - 1.5rem));
  margin: 1rem auto 2.5rem;
  min-width: 0;
}

.page-head, .panel-head {
  justify-content: space-between;
  align-items: end;
  margin-bottom: 1rem;
  gap: 0.75rem;
  min-width: 0;
}
.page-head > div:first-child,
.panel-head > :first-child {
  min-width: 0;
  flex: 1 1 auto;
}
.page-head h1,
.panel-head h2 {
  overflow-wrap: anywhere;
  word-break: break-word;
}
.page-head .actions,
.panel-head .dropdown {
  flex-shrink: 0;
}
.lede, .empty, .notes { color: var(--muted); overflow-wrap: anywhere; }


.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
}

.stat, .panel, .auth-card {
  background: var(--surface);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--panel-shadow);
}

.stat {
  color: inherit;
  text-decoration: none;
  padding: 1rem;
  min-height: 92px;
}
.stat span { display: block; color: var(--muted); font-size: 0.9rem; }
.stat strong { font-size: 1.8rem; font-family: var(--display); }

.panel { padding: 1rem 1.1rem 1.2rem; margin-bottom: 1rem; }

.rows, .sets { list-style: none; margin: 0; padding: 0; }
.rows li, .sets li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
  border-top: 1px solid var(--line-soft);
  min-height: 56px;
  min-width: 0;
}
.rows a, .sets li div, .sets .round-body {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  color: inherit;
  text-decoration: none;
  padding: 0.7rem 0;
  min-width: 0;
  flex: 1 1 auto;
}
.rows a strong {
  overflow-wrap: anywhere;
  word-break: break-word;
}
.rows .actions {
  flex-shrink: 0;
  align-items: center;
}
.rows a span, .sets span { color: var(--muted); font-size: 0.92rem; }
.sets .round-summary { overflow-wrap: anywhere; }
.sets .dropdown { flex-shrink: 0; align-self: flex-start; margin-top: 0.35rem; }

.badge {
  font-size: 0.85rem;
  color: var(--muted);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  padding: 0.25rem 0.6rem;
  white-space: nowrap;
}
.badge-done { color: var(--ink); background: color-mix(in srgb, var(--hot) 10%, var(--surface)); }

.field { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 0.9rem; flex: 1 1 8rem; min-width: 0; }
.field label { font-size: 1rem; color: var(--ink); font-weight: 550; }
.split {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  min-width: 0;
}
.split > .field { flex: 1 1 7rem; }
[hidden] { display: none !important; }

input, select, textarea {
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 44px;
  padding: 0.55rem 0.75rem;
  width: 100%;
  max-width: 100%;
  font-size: 1rem; /* avoid iOS zoom on focus */
}
textarea { min-height: 6rem; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--hot);
  outline-offset: 1px;
  border-color: var(--hot);
}

.btn, button, input[type="submit"] {
  font: inherit;
  cursor: pointer;
  min-height: 2.75rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 0.55rem 0.9rem;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}
.btn-primary, input[type="submit"].btn-primary {
  background: var(--btn-primary-bg);
  color: var(--accent-ink);
  border-color: transparent;
  box-shadow: var(--btn-primary-shadow);
  font-weight: 650;
}
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover, .btn-ghost:focus-visible { color: var(--ink); background: color-mix(in srgb, var(--hot) 8%, transparent); }
.btn-icon {
  position: relative;
  width: 2.75rem;
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding: 0;
}
.btn-icon svg { width: 1.2rem; height: 1.2rem; flex-shrink: 0; }
/* Expand hit area to 48×48 on coarse pointers without changing visual size */
.touch-expand {
  position: absolute;
  top: 50%;
  left: 50%;
  width: max(100%, 3rem);
  height: max(100%, 3rem);
  transform: translate(-50%, -50%);
  pointer-events: auto;
}
@media (pointer: fine) {
  .touch-expand { display: none; }
}

.dropdown { position: relative; }
.dropdown summary { list-style: none; }
.dropdown summary::-webkit-details-marker,
.dropdown summary::marker { display: none; content: ""; }
.dropdown-panel {
  position: absolute;
  inset: 100% 0 auto auto;
  z-index: 20;
  min-width: max(12.5rem, max-content);
  width: max-content;
  max-width: min(22rem, calc(100vw - 1.5rem));
  padding: 0.35rem;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-elevated);
}
.dropdown-panel .button_to { display: block; width: 100%; margin: 0; }
.dropdown-panel .button_to .dropdown-item { width: 100%; }
.dropdown-item {
  width: 100%;
  justify-content: flex-start;
  gap: 0.55rem;
  background: transparent;
  border: 0;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  padding: 0.45rem 0.7rem;
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
  font: inherit;
  cursor: pointer;
  text-align: left;
}
.dropdown-item svg { width: 1.1rem; height: 1.1rem; }
.dropdown-item:hover, .dropdown-item:focus-visible { background: color-mix(in srgb, var(--hot) 12%, var(--surface)); }
.dropdown summary:focus-visible { outline: 2px solid var(--hot); outline-offset: 2px; }

.sets .round-summary { color: var(--ink); font-size: 1rem; }
.round-note { margin: 0.15rem 0 0; color: var(--muted); }
.round-video {
  display: block;
  width: min(100%, 22rem);
  margin-top: 0.4rem;
  border-radius: 8px;
  background: var(--video-bg);
}
.exercise-demo-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
}
.exercise-demo {
  margin: 0;
}
.exercise-demo-video {
  width: 100%;
  max-width: 28rem;
  margin-top: 0;
  aspect-ratio: 16 / 9;
  object-fit: contain;
}
.exercise-demo figcaption {
  margin-top: 0.35rem;
  font-size: 0.9rem;
  color: var(--muted);
}
.round-form { margin-top: 0.75rem; min-width: 0; }
.round-form-fields {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}
.round-form-legend {
  font-size: 1rem;
  font-weight: 650;
  color: var(--ink);
  margin: 0 0 0.5rem;
  padding: 0;
}
.round-kind-field { margin-bottom: 0.65rem; }
.round-fields-stack { min-width: 0; }
.round-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin: 0 0 0.65rem;
}
.round-fields[hidden] { display: none; }
.round-fields > .field {
  flex: 1 1 6.5rem;
  margin-bottom: 0;
  min-width: 0;
}
.round-form-actions { margin-top: 0.25rem; }
.round-form-actions .btn-primary { width: 100%; }
.lift { min-width: 0; overflow: visible; margin: 0; }
.lifts, #lifts {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  min-width: 0;
  margin-bottom: 1.25rem;
}
.lift .sets { margin-top: 0.35rem; }
.lift .panel-head { margin-bottom: 0.15rem; }
.lift .disclosure { margin-top: 0.85rem; border-top: 1px solid var(--line-soft); padding-top: 0.65rem; }
.disclosure {
  margin-bottom: 1rem;
}
.disclosure-summary {
  cursor: pointer;
  list-style: none;
  font-weight: 650;
  font-size: 1rem;
  min-height: 2.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--ink);
}
.disclosure-summary::-webkit-details-marker,
.disclosure-summary::marker { display: none; content: ""; }
.disclosure-summary::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
  flex-shrink: 0;
}
.disclosure[open] > .disclosure-summary::before {
  transform: rotate(45deg);
}
.disclosure-body {
  padding: 0.75rem 0 0.25rem;
}
.disclosure.panel > .disclosure-summary {
  padding: 0.15rem 0;
}
.disclosure.panel > .disclosure-body {
  padding-top: 0.5rem;
}
#add-exercise .btn-primary,
.disclosure-body .btn-primary {
  width: 100%;
  max-width: 20rem;
}
.round-form { margin-top: 0; }
.upload-progress { display: grid; gap: 0.3rem; }
.upload-progress progress { width: 100%; height: 0.6rem; accent-color: var(--accent); }
.field-error { margin: 0; font-size: 0.9rem; color: var(--danger); }
input[aria-invalid="true"], select[aria-invalid="true"], lexxy-editor[aria-invalid="true"] { border-color: var(--danger); }
.errors {
  display: block;
  margin: 0 0 0.85rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--danger);
  border-radius: 8px;
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 8%, var(--surface));
  font-family: var(--font);
  font-size: 0.95rem;
  line-height: 1.4;
  max-width: 100%;
  width: 100%;
  box-sizing: border-box;
  overflow-wrap: anywhere;
  overflow: visible;
}
.errors p {
  margin: 0 0 0.35rem;
  padding: 0;
  color: inherit;
  font-family: inherit;
}
.errors p:last-child { margin-bottom: 0; }
.errors ul {
  margin: 0;
  padding-left: 1.15rem;
  list-style: disc;
}
.errors li { margin: 0.15rem 0; }
.errors a { color: inherit; }
.hint { margin: 0; font-size: 0.9rem; color: var(--muted); }
.log-flags { display: inline-flex; gap: 0.35rem; color: var(--muted); }
.log-flags svg { width: 1rem; height: 1rem; }
.history { list-style: none; margin: 0; padding: 0; }
.history > li { padding-block: 0.75rem; border-top: 1px solid var(--line-soft); }
.history > li:first-child { border-top: 0; }
.history h3 { font-size: 1rem; margin: 0; }
.rows .actions { flex-wrap: nowrap; }
.btn-danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.button_to { display: inline; margin: 0; }
.search { margin-bottom: 1rem; align-items: end; }
.search .field { margin-bottom: 0; flex: 0 1 auto; }
.search input { min-width: 14rem; }
.search select { width: auto; min-width: 8rem; }
.library-filters { align-items: end; gap: 0.6rem; }
.library-filters .field { flex: 1 1 8rem; min-width: 7rem; }
.library-filters .field:first-child {
  flex: 2 1 14rem;
  min-width: min(100%, 14rem);
}
.library-filters .field:first-child input { min-width: 0; width: 100%; }
.pagy-info { margin: 0 0 0.75rem; }
.pagy-nav {
  display: flex;
  justify-content: center;
  margin: 1rem 0 0.5rem;
}
.pagy {
  --H: 20;
  --S: 70;
  --L: 40;
  --B: 1;
  --A: 1;
  --spacing: 0.25rem;
  --padding: 0.65rem;
  --rounding: 0.5rem;
  --border-width: 1px;
  --font-size: 0.95rem;
  --font-weight: 600;
  --line-height: 1.4;
  color: var(--ink);
  font-size: var(--font-size);
  line-height: var(--line-height);
  font-weight: var(--font-weight);
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  justify-content: center;
}
.pagy a:not([role="separator"]) {
  display: block;
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  color: var(--ink);
  padding: 0.4rem 0.75rem;
  min-height: 2.75rem;
  min-width: 2.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}
.pagy a[href]:hover {
  background: color-mix(in srgb, var(--hot) 12%, var(--surface));
  color: var(--ink);
}
.pagy a[aria-current] {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
}
.pagy a:not([href]) {
  opacity: 0.55;
  cursor: default;
}
.rows-plain li { justify-content: flex-start; gap: 0.75rem; padding: 0.55rem 0; min-height: 44px; }

.flash {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border: 1px solid var(--notice-border);
  border-inline-start-width: 4px;
  background: var(--notice-bg);
  color: var(--notice-ink);
  border-radius: 8px;
  padding: 0.7rem 0.8rem;
  margin-bottom: 1rem;
}
.flash-alert { border-color: var(--alert-border); background: var(--alert-bg); color: var(--alert-ink); }
.flash-icon { display: inline-flex; flex-shrink: 0; }
.flash-icon svg, .flash-dismiss svg { width: 1.25rem; height: 1.25rem; }
.flash-message { flex: 1; min-width: 0; overflow-wrap: anywhere; font-weight: 600; }
.flash-dismiss {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid currentColor;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  cursor: pointer;
}
.flash-dismiss[hidden] { display: none; }
.flash-dismiss:hover { background: color-mix(in srgb, currentColor 12%, transparent); }
.flash-dismiss:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }

.auth-shell {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.auth-card { width: min(100%, 26rem); padding: 1.4rem; }
.auth-brand { justify-content: space-between; margin-bottom: 1rem; }
.auth-brand .mark { margin: 0; }
.auth-brand select { width: auto; min-width: 9.5rem; }
.auth-card h1 { margin: 0 0 1.15rem; }
.flash:focus-visible, .errors:focus-visible { outline: 2px solid var(--hot); outline-offset: 2px; }
.auth-links { gap: 0.75rem 1.25rem; margin-top: 1rem; }
.auth-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0.35rem 0.15rem;
}
.inline-form {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  min-width: 0;
}
.inline-form input[type="number"] { width: 6.5rem; }
.inline-form input[type="text"],
.inline-form select {
  flex: 1 1 10rem;
  min-width: 0;
}
.inline-form .btn,
.inline-form input[type="submit"] {
  flex-shrink: 0;
}
.theme-preview select { width: auto; min-width: 9.5rem; }

/* Below ~lg: mobile shell, hamburger nav, stacked workout chrome */
@media (max-width: 63.9375rem) {
  .stat-grid { grid-template-columns: 1fr; }
  .shell {
    width: min(920px, calc(100% - 1rem));
    margin: 0.75rem auto 2rem;
  }
  .panel { padding: 0.85rem 0.85rem 1rem; }

  .page-head {
    align-items: stretch;
    flex-direction: column;
  }
  .page-head-copy { width: 100%; min-width: 0; }
  .page-head-actions {
    width: 100%;
    display: flex;
    flex-wrap: nowrap;
    gap: 0.5rem;
    align-items: center;
  }
  .page-head-actions .page-head-primary,
  .page-head-actions .button_to.page-head-primary,
  .page-head-actions form.page-head-primary {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
  }
  .page-head-actions .page-head-primary .btn,
  .page-head-actions form.page-head-primary button {
    width: 100%;
  }
  .page-head-actions > .dropdown {
    flex: 0 0 auto;
    margin-left: 0;
  }

  .panel-head {
    align-items: flex-start;
    gap: 0.5rem;
  }
  .panel-head > div:first-child { flex: 1 1 auto; min-width: 0; }
  .panel-head h2 { font-size: 1.05rem; margin-bottom: 0; }
  .panel-head .dropdown { margin-top: 0; }

  .split > .field {
    flex: 1 1 calc(50% - 0.5rem);
    min-width: 6.5rem;
  }

  /* Workout builder: keep kind fields readable without huge empty gaps */
  .workout-page .round-fields {
    gap: 0.5rem;
  }
  .workout-page .round-fields > .field {
    flex: 1 1 calc(50% - 0.5rem);
    min-width: 7rem;
  }
  .workout-page .round-form-actions .btn-primary,
  .workout-page #add-exercise .btn-primary {
    width: 100%;
    max-width: none;
  }
  .workout-page turbo-frame.inline-editor .inline-round-fields > .field,
  .workout-page turbo-frame.inline-editor .split.inline-round-fields > .field {
    flex: 1 1 calc(50% - 0.5rem);
  }
  .workout-page turbo-frame.inline-editor .form-actions {
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: flex-end;
  }
  .workout-page turbo-frame.inline-editor .form-actions > .btn,
  .workout-page turbo-frame.inline-editor .form-actions > a.btn,
  .workout-page turbo-frame.inline-editor .form-actions > input[type="submit"],
  .workout-page turbo-frame.inline-editor .form-actions > button {
    width: auto !important;
    max-width: none;
    flex: 0 0 auto;
  }
  .workout-page .sets li {
    align-items: flex-start;
  }
  .workout-page .round-video {
    width: 100%;
    max-width: 100%;
  }
  .workout-page .stack-form .btn,
  .workout-page .stack-form input[type="submit"] {
    width: 100%;
  }
  .workout-page .cta-panel .actions {
    flex-direction: column;
    align-items: stretch;
  }
  .workout-page .cta-panel .actions .btn {
    width: 100%;
  }

  .search {
    align-items: stretch;
    flex-direction: column;
  }
  .search .field { width: 100%; }
  .search input { min-width: 0; width: 100%; }
  .search .btn { width: 100%; }

  .share-row { flex-direction: column; }
  .share-row input,
  .share-row .btn { width: 100%; flex: none; }

  .inline-form {
    flex-direction: column;
    align-items: stretch;
  }
  .inline-form input,
  .inline-form select,
  .inline-form .btn,
  .inline-form input[type="submit"] {
    width: 100%;
  }

  .dropdown-panel {
    inset: 100% 0 auto auto;
    right: 0;
    left: auto;
  }

  .modal {
    max-width: calc(100vw - 1rem);
    margin: 0.5rem;
  }
  .modal-card {
    padding: 0.85rem;
    max-height: calc(100dvh - 1.5rem);
  }

  .burger { display: inline-flex; }
  .nav {
    position: sticky;
    top: 0;
    z-index: 3;
    padding-inline: 1rem;
  }
  .nav-panel {
    position: absolute;
    inset: 100% 0 auto 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0.35rem;
    padding: 0.6rem 1rem 0.9rem;
    border-bottom: 1px solid var(--line-soft);
    background: var(--surface);
    max-height: calc(100dvh - 3.5rem);
    overflow-y: auto;
  }
  .nav.has-js:not(.is-open) .nav-panel { display: none; }
  .nav:not(.has-js) .nav-panel { position: static; }
  .nav:not(.has-js) .burger { display: none; }
  .nav-end {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    margin-left: 0;
    margin-top: 0.35rem;
    padding-top: 0.35rem;
    border-top: 1px solid var(--line-soft);
  }
  .nav-panel a,
  .nav-meta,
  .nav-end .nav-sign-out,
  .nav-end .button_to {
    width: 100%;
  }
  .nav-panel a,
  .nav-end .nav-sign-out {
    justify-content: flex-start;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    padding: 0 0.5rem;
    border-radius: 8px;
    color: var(--muted);
    text-decoration: none;
    background: transparent;
    border: 0;
    font: inherit;
    cursor: pointer;
    box-shadow: inset 3px 0 0 transparent;
  }
  .nav-panel a.is-active {
    color: var(--ink);
    box-shadow: inset 3px 0 0 var(--hot);
  }
  .nav-end .button_to { display: block; margin: 0; }
  .nav-end .nav-sign-out { width: 100%; }
}

/* Desktop: hide hamburger, show horizontal nav */
@media (min-width: 64rem) {
  .burger { display: none !important; }
  .nav-panel {
    display: flex !important;
    position: static;
    max-height: none;
    overflow: visible;
    padding: 0;
    border: 0;
    background: transparent;
  }
}

@media (max-width: 380px) {
  .split > .field {
    flex: 1 1 100%;
  }
  h1 { font-size: 1.55rem; }
  .workout-page .panel-head h2 { font-size: 1rem; }
}

@media print {
  :root, [data-theme] {
    --bg: #fff;
    --surface: #fff;
    --ink: #000;
    --muted: #333;
    --line: #bbb;
  }
  body { background: #fff; color: #000; font-size: 11pt; }
  .nav, .skip-link, .flash, .dropdown, .round-form, .no-print, .round-video, .page-head .actions, .btn, button {
    display: none !important;
  }
  .shell { width: auto; margin: 0; }
  .panel {
    border: 0;
    box-shadow: none;
    padding: 0;
    margin-bottom: 1rem;
    break-inside: avoid;
  }
  .sets li { min-height: 0; padding-block: 0.2rem; }
  .sets li div { padding: 0; }
  a { color: #000; text-decoration: none; }
}

/* Lexxy editor + rendered rich text follow the app theme */
:root, [data-theme] {
  --lexxy-color-ink: var(--ink);
  --lexxy-color-ink-medium: var(--muted);
  --lexxy-color-ink-light: var(--muted);
  --lexxy-color-ink-lighter: var(--line);
  --lexxy-color-ink-lightest: color-mix(in srgb, var(--line) 45%, var(--surface));
  --lexxy-color-ink-inverted: var(--surface);
  --lexxy-color-canvas: var(--bg);
  --lexxy-color-text: var(--ink);
  --lexxy-color-text-subtle: var(--muted);
  --lexxy-color-link: var(--hot);
  --lexxy-color-accent-dark: var(--hot);
  --lexxy-color-accent-medium: color-mix(in srgb, var(--hot) 70%, var(--surface));
  --lexxy-color-accent-light: color-mix(in srgb, var(--hot) 25%, var(--surface));
  --lexxy-color-accent-lightest: color-mix(in srgb, var(--hot) 12%, var(--surface));
  --lexxy-focus-ring-color: var(--hot);
  --lexxy-font-base: var(--font);
  --lexxy-radius: 8px;
}

lexxy-editor {
  display: block;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  min-height: 7rem;
}
lexxy-editor:focus-within { outline: 2px solid var(--hot); outline-offset: 1px; border-color: var(--hot); }
.round-note .lexxy-content, .notes .lexxy-content { color: var(--muted); }
.round-note .lexxy-content > :first-child, .notes .lexxy-content > :first-child { margin-top: 0; }
.round-note .lexxy-content > :last-child, .notes .lexxy-content > :last-child { margin-bottom: 0; }

/* Markdown headings in notes stay smaller than page headings */
.lexxy-content :is(h1, h2, h3, h4) { font-family: var(--font); letter-spacing: 0; text-transform: none; margin: 0.8em 0 0.3em; }
.lexxy-content h1 { font-size: 1.2rem; }
.lexxy-content h2 { font-size: 1.1rem; }
.lexxy-content :is(h3, h4) { font-size: 1rem; }

/* Inline editors loaded into a round via Turbo Frame */
.round-body { flex: 1 1 auto; min-width: 0; overflow: visible; width: 100%; }
/* When the editor is open, span the full round row (under the ⋮) */
.sets li:has(turbo-frame.inline-editor:not(:empty)) {
  flex-wrap: wrap;
  align-items: flex-start;
}
.sets li:has(turbo-frame.inline-editor:not(:empty)) > .round-body {
  flex: 1 1 100%;
  order: 2;
}
.sets li:has(turbo-frame.inline-editor:not(:empty)) > .dropdown {
  order: 1;
  margin-left: auto;
}
turbo-frame.inline-editor:not(:empty) {
  display: block;
  margin-top: 0.65rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--bg);
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow: visible;
}
turbo-frame.inline-editor h3 {
  font-size: 1rem;
  margin: 0 0 0.35rem;
  font-family: var(--font);
  line-height: 1.3;
}
turbo-frame.inline-editor .lede {
  margin: 0 0 0.75rem;
  font-size: 0.92rem;
}
turbo-frame.inline-editor .errors {
  margin: 0 0 0.85rem;
  padding: 0.85rem 1rem;
  box-sizing: border-box;
  overflow-wrap: anywhere;
}
turbo-frame.inline-editor .note-form,
turbo-frame.inline-editor .inline-round-form,
turbo-frame.inline-editor form {
  display: block;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
turbo-frame.inline-editor .field {
  margin-bottom: 0.65rem;
  flex: 1 1 auto;
}
turbo-frame.inline-editor .inline-round-fields,
turbo-frame.inline-editor .split.inline-round-fields {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  width: 100%;
}
turbo-frame.inline-editor .inline-round-fields > .field,
turbo-frame.inline-editor .split.inline-round-fields > .field {
  flex: 1 1 6.5rem;
  margin-bottom: 0;
  min-width: 0;
}
turbo-frame.inline-editor .form-actions {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: flex-end;
  margin-top: 0.15rem;
  width: 100%;
}
turbo-frame.inline-editor .form-actions > .btn,
turbo-frame.inline-editor .form-actions > a.btn,
turbo-frame.inline-editor .form-actions > input[type="submit"],
turbo-frame.inline-editor .form-actions > button {
  flex: 0 0 auto;
  width: auto !important;
  max-width: none;
  min-width: 5.5rem;
  min-height: 2.75rem;
}
.form-actions {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: flex-end;
  margin-top: 0.25rem;
}
.form-actions > .btn,
.form-actions > a.btn,
.form-actions > input[type="submit"],
.form-actions > button {
  flex: 0 0 auto;
  width: auto;
  max-width: none;
  min-width: 5.5rem;
  min-height: 2.75rem;
}
turbo-frame[busy] { opacity: 0.6; }

/* Shared turbo-frame modal (instructions, etc.) */
#modal:empty { display: none; }
.modal {
  border: none;
  padding: 0;
  max-width: min(36rem, calc(100vw - 2rem));
  width: 100%;
  background: transparent;
  color: inherit;
}
.modal::backdrop {
  background: var(--overlay);
}
.modal-card {
  display: grid;
  gap: 1rem;
  padding: 1rem 1.1rem 1.1rem;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-elevated);
  max-height: min(90vh, 48rem);
  overflow: auto;
}
.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}
.modal-head h2 { margin: 0; font-size: 1.25rem; }
.modal-section h3 { margin: 0 0 0.4rem; font-size: 1rem; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}
.instructions {
  margin: 0;
  padding-left: 1.25rem;
  display: grid;
  gap: 0.4rem;
}
.instructions li { padding-left: 0.15rem; }

.sets li { align-items: flex-start; }
.sets li > details { margin-top: 0.4rem; }
.eyebrow { margin-bottom: 0.2rem; font-size: 0.9rem; }

/* Exercise combobox */
.combobox { position: relative; }
.combobox-list {
  position: absolute;
  inset: 100% 0 auto 0;
  z-index: 4;
  margin: 0.25rem 0 0;
  padding: 0.3rem;
  list-style: none;
  max-height: 16rem;
  overflow-y: auto;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-elevated);
}
.combobox-option {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.55rem 0.7rem;
  min-height: 44px;
  justify-content: center;
  border-radius: 8px;
  cursor: pointer;
}
.combobox-option small { color: var(--muted); font-size: 0.85rem; }
.combobox-option.is-active, .combobox-option:hover { background: color-mix(in srgb, var(--hot) 12%, var(--surface)); }
.combobox-create { color: var(--hot); font-weight: 600; border-top: 1px solid var(--line-soft); border-radius: 0 0 8px 8px; }
