/* Workout — hand-written CSS design system.
 *
 * Mobile-first, native-feeling SPA chrome. Automatic light/dark via
 * prefers-color-scheme (no toggle — follows the OS). Everything is driven by
 * the custom properties on :root, so components extend without re-deriving
 * colours, spacing, or type.
 */

/* ---------- design tokens ---------- */

:root {
  /* palette — light: warm paper, ember accent */
  --bg: #f4f2ee;
  --surface: #ffffff;
  --surface-2: #f1efea;
  --fg: #1a1816;
  --muted: #5e5a53;
  --faint: #7a756b;
  --border: #e4e0d8;
  --field-bg: #fbfaf7;
  --field-border: #9b958a;
  --accent: #c2410c;
  --accent-fg: #ffffff;
  --accent-weak: #fde9dc;
  --danger: #c81e1e;
  --danger-weak: #fde8e8;
  --success: #15803d;
  --success-weak: #e3f4e8;
  --warn: #a35c00;
  --solid-success: #15803d;
  --solid-danger: #b91c1c;

  /* <select>'s chevron, as a data URI — its stroke colour can't reference a
     custom property directly, so the whole icon is swapped per theme instead. */
  --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%238a857b' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");

  /* nav link tones (text colour; tints are derived with color-mix) */
  --t-violet: #6d3fd6;
  --t-blue: #1f5fd1;
  --t-teal: #0b7a73;
  --t-amber: #9a5600;
  --t-green: #2a7a2e;
  --t-rose: #b5245c;

  /* elevation */
  --shadow-1: 0 1px 2px rgba(40, 30, 20, 0.06), 0 1px 3px rgba(40, 30, 20, 0.07);
  --shadow-2: 0 12px 32px -12px rgba(40, 30, 20, 0.28);

  /* type */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --fs-xs: 0.75rem;
  --fs-sm: 0.875rem;
  --fs-md: 1rem;
  --fs-lg: 1.25rem;
  --fs-xl: 1.75rem;

  /* spacing scale */
  --s-1: 0.25rem;
  --s-2: 0.5rem;
  --s-3: 0.75rem;
  --s-4: 1rem;
  --s-5: 1.5rem;
  --s-6: 2rem;
  --s-7: 3rem;

  /* radii */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --r-full: 999px;

  /* layout */
  --content-max: 48rem;
  --shell-max: 64rem;
  --gutter: 1rem;

  --transition: 160ms ease;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0d10;
    --surface: #16181d;
    --surface-2: #1e2127;
    --fg: #eceef2;
    --muted: #a4abb6;
    --faint: #7d8593;
    --border: #2a2f38;
    --field-bg: #0c0e12;
    --field-border: #5d6573;
    --accent: #ff8a57;
    --accent-fg: #1b0b04;
    --accent-weak: #3a1e12;
    --danger: #ff6b5e;
    --danger-weak: #3a1b19;
    --success: #4cd98a;
    --success-weak: #13291c;
    --warn: #ffb84d;
    --solid-success: #1f7f4d;
    --solid-danger: #c2362c;
    --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23a4abb6' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    --t-violet: #b8a3ff;
    --t-blue: #8ab4ff;
    --t-teal: #6fe0d4;
    --t-amber: #ffc66b;
    --t-green: #8fe39a;
    --t-rose: #ff9ab8;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-2: 0 14px 36px -12px rgba(0, 0, 0, 0.7);
  }
}

/* ---------- reset ---------- */

* {
  box-sizing: border-box;
}

/* The author display rules below must not override the hidden attribute. */
[hidden] {
  display: none !important;
}

/* Selected text uses the app's accent instead of the browser's default blue. */
::selection {
  background: var(--accent-weak);
  color: var(--accent);
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  font-size: var(--fs-md);
  background:
    radial-gradient(900px 420px at 0% -10%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 70%),
    var(--bg);
  color: var(--fg);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  overscroll-behavior-y: none;
}

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

a {
  color: inherit;
  text-decoration: none;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

/* ---------- a11y utilities ---------- */

.skip-link {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translate(-50%, -120%);
  z-index: 100;
  margin-top: var(--s-2);
  padding: var(--s-2) var(--s-4);
  background: var(--accent);
  color: var(--accent-fg);
  border-radius: var(--r-md);
  font-weight: 600;
  transition: transform var(--transition);
}

.skip-link:focus {
  transform: translate(-50%, 0);
}

/* The view container takes focus on navigation; it should never show a ring. */
.view:focus {
  outline: none;
}

/* ---------- boot placeholder ---------- */

.boot {
  min-height: 100dvh;
  display: grid;
  place-content: center;
  text-align: center;
  gap: var(--s-1);
}

.boot h1 {
  font-size: var(--fs-lg);
  letter-spacing: -0.02em;
}

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

.noscript-msg {
  padding: var(--s-4);
  text-align: center;
}

/* ---------- app shell ---------- */

#app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* Top bar: brand and actions on one row, nav links on a second row that
 * scrolls sideways on phones. Becomes a single row on wider screens. */
.appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding-top: env(safe-area-inset-top);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--border);
}

.appbar-inner {
  max-width: var(--shell-max);
  margin: 0 auto;
  padding: 0 var(--gutter);
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "brand actions"
    "nav nav";
  align-items: center;
}

.appbar-brand {
  grid-area: brand;
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  height: 3.25rem;
  font-weight: 800;
  font-size: var(--fs-lg);
  letter-spacing: -0.02em;
}

.brand-mark {
  width: 0.4rem;
  height: 1.1rem;
  border-radius: var(--r-full);
  background: var(--accent);
}

.appbar-actions {
  grid-area: actions;
  display: flex;
  align-items: center;
  gap: var(--s-3);
}

.nav {
  grid-area: nav;
  display: flex;
  gap: var(--s-2);
  overflow-x: auto;
  padding: 0 0 var(--s-3);
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

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

/* Each link is tinted with its own tone. Selected = solid accent; hover lifts. */
.nav-link {
  --tone: var(--t-blue);
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  padding: var(--s-2) var(--s-4);
  border-radius: var(--r-full);
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--tone);
  background: color-mix(in srgb, var(--tone) 14%, transparent);
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition), color var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.nav-link[data-tone="violet"] { --tone: var(--t-violet); }
.nav-link[data-tone="blue"] { --tone: var(--t-blue); }
.nav-link[data-tone="teal"] { --tone: var(--t-teal); }
.nav-link[data-tone="amber"] { --tone: var(--t-amber); }
.nav-link[data-tone="green"] { --tone: var(--t-green); }
.nav-link[data-tone="rose"] { --tone: var(--t-rose); }

.nav-link:hover:not([aria-current="page"]) {
  background: color-mix(in srgb, var(--tone) 26%, transparent);
  transform: translateY(-1px);
  box-shadow: var(--shadow-1);
}

.nav-link[aria-current="page"] {
  background: var(--accent);
  color: var(--accent-fg);
  box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--accent) 70%, transparent);
}

.view {
  flex: 1;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--s-5) var(--gutter) var(--s-7);
}

/* Auth screens hide the chrome and centre their card. */
body[data-mode="auth"] .appbar {
  display: none;
}

body[data-mode="auth"] .view {
  max-width: none;
  padding: var(--gutter);
  padding-bottom: calc(env(safe-area-inset-bottom) + var(--s-5));
  display: grid;
  place-items: center;
}

/* ---------- sync pill ---------- */

.sync-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-1) var(--s-3);
  border-radius: var(--r-full);
  font: inherit;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: border-color var(--transition);
}

.sync-pill:hover {
  border-color: var(--accent);
}

.sync-pill:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--faint);
}

.sync-pill[data-state="online"] .sync-dot {
  background: var(--success);
}
.sync-pill[data-state="offline"] .sync-dot {
  background: var(--warn);
}
.sync-pill[data-state="syncing"] .sync-dot {
  background: var(--accent);
  animation: pulse 1.1s ease-in-out infinite;
}
.sync-pill[data-state="synced"] .sync-dot {
  background: var(--success);
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

/* ---------- page primitives ---------- */

.page {
  display: flex;
  flex-direction: column;
  gap: var(--s-5);
}

.page-head {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
}

.page-title {
  font-size: var(--fs-xl);
  font-weight: 750;
  letter-spacing: -0.025em;
  line-height: 1.2;
}

.eyebrow {
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- dashboard (home) ---------- */

.hero {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  padding: var(--s-5);
  border-radius: var(--r-lg);
  background: var(--accent);
  color: var(--accent-fg);
}

.hero-eyebrow {
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.85;
}

.hero-title {
  font-size: var(--fs-xl);
  font-weight: 750;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin-top: var(--s-1);
}

.hero-meta {
  font-size: var(--fs-sm);
  opacity: 0.9;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  margin-top: var(--s-4);
}

/* Scoped under .hero so they beat the generic .btn colours declared later. */
.hero .hero-btn {
  background: var(--accent-fg);
  color: var(--accent);
  box-shadow: none;
}

.hero .hero-btn:hover {
  filter: brightness(1.05);
}

.hero .btn-glass {
  background: color-mix(in srgb, var(--accent-fg) 14%, transparent);
  color: var(--accent-fg);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent-fg) 35%, transparent);
}

.hero .btn-glass:hover {
  background: color-mix(in srgb, var(--accent-fg) 22%, transparent);
}

.dashboard .stat-tiles {
  margin-top: calc(-1 * var(--s-1));
}

.dash-section {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

.dash-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-3);
}

.section-title {
  font-size: var(--fs-md);
  font-weight: 750;
  letter-spacing: -0.01em;
}

.section-link {
  font-size: var(--fs-sm);
  font-weight: 650;
  color: var(--accent);
}

.section-link:hover {
  text-decoration: underline;
}

/* ---------- empty state ---------- */

.empty {
  display: grid;
  gap: var(--s-2);
  place-items: center;
  text-align: center;
  padding: var(--s-6) var(--s-4);
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--field-border);
  border-radius: var(--r-lg);
}

.empty .btn {
  margin-top: var(--s-2);
}

.empty-text {
  font-weight: 650;
  color: var(--fg);
}

.empty-sub {
  font-size: var(--fs-sm);
}

/* ---------- auth card ---------- */

.auth-screen {
  width: 100%;
  display: grid;
  place-items: center;
}

.auth-card {
  width: 100%;
  max-width: 23rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
  padding: var(--s-6);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.auth-title {
  font-size: var(--fs-xl);
  font-weight: 800;
  letter-spacing: -0.03em;
}

.auth-subtitle {
  color: var(--muted);
  font-size: var(--fs-sm);
  margin-bottom: var(--s-3);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}

/* ---------- forms ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.field label {
  font-size: var(--fs-sm);
  font-weight: 650;
  color: var(--fg);
}

input,
select,
textarea {
  font: inherit;
  color: var(--fg);
  background: var(--field-bg);
  border: 1px solid var(--field-border);
  border-radius: var(--r-md);
  padding: var(--s-3);
  width: 100%;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

input::placeholder,
textarea::placeholder {
  color: var(--faint);
  opacity: 1;
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--fg);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-weak);
  background: var(--surface);
}

/* Chrome/Safari paint autofilled fields with their own opaque background
   (usually white) via internal UA styles that ignore `background`; this is
   the standard workaround — an inset box-shadow the size of the field paints
   over it in our own colour, and the long transition delays the swap so it
   doesn't visibly flash on autofill. */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--fg);
  -webkit-box-shadow: 0 0 0 1000px var(--field-bg) inset;
  box-shadow: 0 0 0 1000px var(--field-bg) inset;
  transition: background-color 600000s 0s, color 600000s 0s;
}

/* Native checkboxes, radios and selects keep their own chrome. */
input[type="checkbox"],
input[type="radio"] {
  width: auto;
}

.form-error {
  color: var(--danger);
  font-size: var(--fs-sm);
  font-weight: 600;
  background: var(--danger-weak);
  border-radius: var(--r-md);
  padding: var(--s-2) var(--s-3);
}

/* A list rendered from the offline mirror instead of a live fetch. */
.offline-notice {
  color: var(--warn);
  font-size: var(--fs-sm);
  font-weight: 600;
  background: color-mix(in srgb, var(--warn) 16%, transparent);
  border-radius: var(--r-md);
  padding: var(--s-2) var(--s-3);
  margin-bottom: var(--s-3);
}

/* A load failure (404, offline, …) replacing a builder/detail screen's body:
 * the error banner plus a way back, stacked instead of centered in a box —
 * this isn't an empty state, it's a failed load. */
.load-error {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--s-3);
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  font: inherit;
  font-weight: 650;
  line-height: 1;
  padding: var(--s-3) var(--s-4);
  min-height: 2.75rem;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--fg);
  box-shadow: inset 0 0 0 1px var(--border);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--transition), transform var(--transition),
    opacity var(--transition), box-shadow var(--transition), filter var(--transition);
}

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

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

.btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-fg);
  box-shadow: 0 4px 14px -6px color-mix(in srgb, var(--accent) 80%, transparent);
}

.btn-primary:hover {
  background: var(--accent);
  filter: brightness(1.07);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  box-shadow: none;
}

.btn-ghost:hover {
  color: var(--fg);
  background: var(--surface-2);
}

.btn-sm {
  min-height: 2.25rem;
  padding: var(--s-2) var(--s-3);
  font-size: var(--fs-sm);
}

.btn-block {
  width: 100%;
}

.btn-danger {
  color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger-weak);
  color: var(--danger);
}

/* Square icon-only button (dialog close). */
.icon-btn {
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  font: inherit;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  cursor: pointer;
}

.icon-btn:hover {
  color: var(--fg);
  background: var(--surface-2);
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + var(--s-5));
  transform: translate(-50%, 1rem);
  z-index: 40;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition), transform var(--transition);
  width: min(92vw, 26rem);
}

.toast[data-visible="true"] {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast-item {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-2);
  font-size: var(--fs-sm);
  font-weight: 650;
  background: var(--fg);
  color: var(--bg);
  text-align: left;
}

.toast-error {
  background: var(--solid-danger);
  color: #fff;
}

.toast-success {
  background: var(--solid-success);
  color: #fff;
}

/* ---------- wider screens ---------- */

@media (min-width: 48rem) {
  :root {
    --gutter: 1.5rem;
  }

  .appbar-inner {
    grid-template-columns: auto 1fr auto;
    grid-template-areas: "brand nav actions";
    column-gap: var(--s-5);
  }

  .appbar-brand {
    height: 3.5rem;
  }

  .nav {
    justify-content: flex-start;
    padding: 0;
  }

  .stat-tiles {
    grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  }
}

/* ---------- exercise picker + library ---------- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-3);
}

.toolbar .search {
  flex: 1 1 10rem;
  min-width: 0;
}

.toolbar .tag-filter {
  flex: 0 1 10rem;
  width: auto;
}

input.search {
  -webkit-appearance: none;
  appearance: none;
  padding-left: var(--s-4);
  border-radius: var(--r-full);
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  font-size: var(--fs-sm);
  color: var(--muted);
  white-space: nowrap;
  cursor: pointer;
}

.checkbox input {
  width: auto;
  accent-color: var(--accent);
}

.picker,
.picker-list {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}

.muted-line {
  color: var(--muted);
  padding: var(--s-3) 0;
}

.ex-section {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.list-subhead {
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--faint);
  margin-top: var(--s-2);
}

.ex-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.ex-item {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  width: 100%;
  transition: border-color var(--transition);
  text-align: left;
  padding: var(--s-3) var(--s-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
}

.ex-li {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.ex-item:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}

/* The pick area is a button in select mode and a plain block in browse mode. */
.ex-pick {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 0;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.ex-pick:active {
  transform: scale(0.99);
}

.ex-pick-static {
  cursor: default;
}

.ex-added {
  flex: 0 0 auto;
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--success);
  background: var(--success-weak);
  padding: 3px var(--s-2);
  border-radius: var(--r-full);
  white-space: nowrap;
}

.ex-item[data-deleted="true"] {
  opacity: 0.6;
}

.ex-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.ex-title {
  font-weight: 650;
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

.ex-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--s-2);
}

.ex-tags {
  font-size: var(--fs-xs);
  color: var(--muted);
}

.ex-badge {
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 2px var(--s-2);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--muted);
}

.ex-badge[data-type="strength"] {
  background: var(--accent-weak);
  color: var(--accent);
}
.ex-badge[data-type="bodyweight"] {
  background: var(--success-weak);
  color: var(--success);
}
.ex-badge[data-type="timed"] {
  background: color-mix(in srgb, var(--warn) 18%, transparent);
  color: var(--warn);
}
.ex-badge[data-type="cardio"] {
  background: var(--danger-weak);
  color: var(--danger);
}

.ex-flag {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--danger);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.ex-add {
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  font-size: 1.25rem;
  line-height: 1;
  color: var(--accent-fg);
  background: var(--accent);
  border-radius: var(--r-full);
}

.ex-actions {
  flex: 0 0 auto;
  display: flex;
  gap: var(--s-1);
}

/* ---------- tag editor ---------- */

.tag-editor {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-2);
  border: 1px solid var(--field-border);
  border-radius: var(--r-md);
  background: var(--field-bg);
}

.tag-editor:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-weak);
}

.tag-chips {
  display: contents;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  padding: 2px var(--s-1) 2px var(--s-2);
  border-radius: var(--r-full);
  background: var(--accent-weak);
  color: var(--accent);
  font-size: var(--fs-sm);
  font-weight: 650;
}

.tag-chip-x {
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0 2px;
}

.tag-input {
  flex: 1 1 6rem;
  min-width: 6rem;
  border: none;
  background: transparent;
  padding: var(--s-1);
  box-shadow: none;
}

.tag-input:focus {
  outline: none;
  box-shadow: none;
}

/* ---------- dialog ---------- */

.dialog {
  width: min(28rem, calc(100vw - 2 * var(--gutter)));
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--fg);
  box-shadow: var(--shadow-2);
  padding: 0;
}

.dialog::backdrop {
  background: rgba(12, 10, 8, 0.55);
  backdrop-filter: blur(3px);
}

.dialog-form {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  padding: var(--s-5);
}

.dialog-title {
  font-size: var(--fs-lg);
  font-weight: 750;
  letter-spacing: -0.02em;
}

.dialog .field > span {
  font-size: var(--fs-sm);
  font-weight: 650;
  color: var(--fg);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--s-2);
  margin-top: var(--s-2);
}

/* A delete in a footer goes to the far left, away from Cancel and Save. */
.dialog-actions .btn-danger {
  margin-right: auto;
}

/* ---------- programs list ---------- */

.row-between {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

.card-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

.program-card {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
  transition: border-color var(--transition), transform var(--transition);
}

.program-card:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}

.program-card-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Used as a <button> on the admin Users card (tap the card to expand/collapse)
   instead of an <a>; reset the button chrome to match. */
button.program-card-main {
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.program-card-name {
  font-weight: 650;
}

.program-card-main:hover .program-card-name {
  color: var(--accent);
}

.program-card-meta {
  display: flex;
  gap: var(--s-2);
  font-size: var(--fs-sm);
  color: var(--muted);
}

.program-card-notes {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 14rem;
}

.program-card-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: var(--s-1);
}

/* Favourite heart: outlined when off, filled in the accent colour when on. */
.fav-toggle {
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  color: var(--faint);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: color var(--transition), background var(--transition);
}

.fav-toggle:hover {
  color: var(--accent);
  background: var(--surface-2);
}

.fav-toggle[aria-pressed="true"] {
  color: var(--accent);
}

.fav-toggle[aria-pressed="true"] path {
  fill: currentColor;
}

.fav-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.fav-host {
  flex: 0 0 auto;
}

/* ---------- program builder ---------- */

.builder-head {
  gap: var(--s-3);
}

.back-link {
  font-size: var(--fs-sm);
  font-weight: 650;
  color: var(--muted);
}

.back-link:hover {
  color: var(--accent);
}

.program-name {
  font-size: var(--fs-lg);
  font-weight: 750;
  letter-spacing: -0.01em;
  padding: var(--s-2) var(--s-3);
}

.program-notes {
  resize: vertical;
}

.builder-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.builder-ex {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  padding: var(--s-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
  touch-action: pan-y;
}

.builder-ex.dragging {
  z-index: 5;
  box-shadow: var(--shadow-2);
  opacity: 0.95;
}

.builder-ex-head {
  display: flex;
  align-items: center;
  gap: var(--s-3);
}

.builder-ex-title {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--s-2);
}

.drag-handle {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: none;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--faint);
  cursor: grab;
  touch-action: none; /* let pointer-drag work on touch without scrolling */
}

.drag-handle:hover {
  color: var(--fg);
  background: var(--surface-2);
}

.drag-handle:active {
  cursor: grabbing;
  color: var(--muted);
}

.ex-notes {
  font-size: var(--fs-sm);
  padding: var(--s-2) var(--s-3);
}

.builder-ex-foot {
  display: flex;
  justify-content: flex-end;
}

/* Superset: the separator between two cards holds the "+ Superset" link. A
 * linked separator carries the accent rail, so a group reads as one bracket. */
.sup-gap {
  display: flex;
  align-items: center;
  height: 2.25rem;
  padding-left: calc(var(--s-4) - 3px);
  border-left: 3px solid transparent;
}

.sup-gap.is-linked {
  border-left-color: var(--accent);
}

.sup-link {
  font: inherit;
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: var(--s-1) var(--s-3);
  border-radius: var(--r-full);
  border: 1px dashed var(--field-border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
}

.sup-link:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.sup-link.is-on {
  border: 1px solid transparent;
  background: var(--accent-weak);
  color: var(--accent);
}

.builder-ex.sup-start,
.builder-ex.sup-mid,
.builder-ex.sup-end {
  border-left: 3px solid var(--accent);
}

.builder-ex.sup-start::before {
  content: "Superset";
  position: absolute;
  top: -0.6rem;
  right: var(--s-4);
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent-fg);
  background: var(--accent);
  padding: 1px var(--s-2);
  border-radius: var(--r-full);
}

.unsaved-note {
  margin-right: auto;
  align-self: center;
  font-size: var(--fs-sm);
  font-weight: 650;
  color: var(--warn);
}

/* Sticky so Save stays reachable while a long program is being edited. Actions sit
 * on the right; the unsaved note (when shown) takes the free space on the left. */
.builder-actions {
  display: flex;
  gap: var(--s-3);
  justify-content: flex-end;
  position: sticky;
  bottom: calc(env(safe-area-inset-bottom) + var(--s-3));
  z-index: 5;
  padding: var(--s-2);
  margin: 0 calc(-1 * var(--s-2));
  border-radius: var(--r-lg);
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.builder-actions .btn-primary,
.builder-actions .btn {
  flex: 0 0 auto;
}

/* ---------- set editor ---------- */

.set-editor {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  padding: var(--s-3);
  background: var(--surface-2);
  border-radius: var(--r-md);
}

.set-rows {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.set-row {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: var(--s-2);
}

/* Visual order: set number, Done tick, then the fields. The DOM puts the fields
 * first so Tab reaches them before the Done tick (see set-editor.js). */
.set-row > .set-num {
  order: -2;
}

.set-num {
  flex: 0 0 auto;
  align-self: center;
  width: 1.5rem;
  height: 1.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
}

.set-cell {
  flex: 1 1 4.5rem;
  min-width: 4rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.set-cell-label {
  font-size: var(--fs-xs);
  font-weight: 650;
  color: var(--muted);
}

.set-input {
  padding: var(--s-2);
  min-height: 2.75rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.set-pace {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  padding: var(--s-2);
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-weight: 600;
}

.set-remove {
  flex: 0 0 auto;
  align-self: center;
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--faint);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.set-remove:hover {
  color: var(--danger);
  background: var(--danger-weak);
}

.add-set {
  align-self: flex-start;
}

/* ---------- dialogs that host content (picker / program / workout views) ---------- */

/* Fixed-height sheet: the header and footer stay put and only the middle
 * region scrolls, so a dialog never ends up with two scrollbars. */
.dialog-wide {
  width: min(38rem, calc(100vw - 2 * var(--gutter)));
  padding: 0;
}

.dialog-wide[open] {
  display: flex;
  flex-direction: column;
  height: min(46rem, calc(100dvh - 2 * var(--gutter)));
}

.picker-dialog {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  padding: var(--s-5);
}

.picker-dialog-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
}

.picker-dialog-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* In the add-exercise sheet the list is the single scroll region. */
.picker-dialog-body > .picker {
  flex: 1 1 auto;
  min-height: 0;
}

.picker-dialog-body > .picker > .picker-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--s-1) 0;
  scrollbar-width: thin;
  scrollbar-color: var(--field-border) transparent;
}

.video-dialog {
  width: min(38rem, calc(100vw - 2 * var(--gutter)));
}

.video-embed {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--r-md);
  overflow: hidden;
  background: #000;
}

.video-embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
}

.picker-dialog-foot {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding-top: var(--s-4);
  border-top: 1px solid var(--border);
}

.picker-idle {
  display: grid;
  place-items: center;
  gap: var(--s-1);
  padding: var(--s-7) var(--s-4);
  text-align: center;
  color: var(--muted);
}

/* ---------- workout logging ---------- */

.log-meta {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

.log-date-field {
  max-width: 12rem;
}

.log-date {
  font-variant-numeric: tabular-nums;
}

/* Day-first date entry: a text field and a calendar button. The native date input
 * stays in the layout box but is invisible, so the browser can open its picker
 * from the button. */
.date-field {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
}

.date-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

.date-text {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.date-pick {
  color: var(--muted);
  border-color: var(--field-border);
  background: var(--field-bg);
}

.date-pick:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.date-native {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  border: 0;
  padding: 0;
}

.log-actions {
  justify-content: flex-end;
}

/* Done toggle: the same label and height as the field cells beside it. The real
 * checkbox stays focusable but is visually hidden behind a styled box. */
.set-cell-done {
  order: -1;
  flex: 0 0 auto;
  min-width: 0;
  width: 3rem;
  align-items: stretch;
  cursor: pointer;
}

.set-done-wrap {
  position: relative;
  display: grid;
  place-items: center;
  height: 2.75rem;
}

.set-done {
  position: absolute;
  inset: 0;
  margin: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.set-done-box {
  width: 2.25rem;
  height: 2.25rem;
  display: grid;
  place-items: center;
  border: 1.5px solid var(--field-border);
  border-radius: var(--r-full);
  background: var(--field-bg);
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
  pointer-events: none;
}

.set-done-box::after {
  content: "";
  width: 0.5rem;
  height: 0.95rem;
  margin-top: -0.15rem;
  border: solid transparent;
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg) scale(0);
  transition: transform 180ms cubic-bezier(0.2, 0.9, 0.3, 1.3), border-color var(--transition);
}

.set-cell-done:hover .set-done-box {
  border-color: var(--success);
}

.set-done:checked + .set-done-box {
  background: var(--success);
  border-color: var(--success);
}

.set-done:checked + .set-done-box::after {
  border-color: #fff;
  transform: rotate(45deg) scale(1);
}

.set-done:focus-visible + .set-done-box {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.set-done:active + .set-done-box {
  transform: scale(0.92);
}

.set-row.is-done {
  background: var(--success-weak);
  border-radius: var(--r-sm);
  padding: var(--s-1) var(--s-1);
  margin: calc(-1 * var(--s-1)) calc(-1 * var(--s-1));
}

.set-row.is-done .set-num {
  color: var(--success);
  border-color: var(--success);
}

/* ---------- history + workout detail ---------- */

.history-list {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

.history-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
  transition: border-color var(--transition), transform var(--transition);
}

.history-card:active {
  transform: scale(0.99);
}

.history-card:hover {
  border-color: var(--accent);
}

.history-card-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.history-card-date {
  font-weight: 700;
}

.history-card-name {
  font-size: var(--fs-sm);
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-card-meta {
  flex: 0 0 auto;
  font-size: var(--fs-sm);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.detail-notes {
  color: var(--muted);
  font-style: italic;
}

.detail-ex-notes {
  color: var(--muted);
  font-size: var(--fs-sm);
}

.detail-sets {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
}

.detail-set {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-2) 0;
  border-top: 1px solid var(--border);
}

.detail-set:first-child {
  border-top: none;
}

.detail-set-value {
  flex: 1 1 auto;
  font-variant-numeric: tabular-nums;
}

.detail-set.is-done .detail-set-value {
  font-weight: 600;
}

.detail-set-done {
  flex: 0 0 auto;
  width: 1.5rem;
  text-align: center;
  color: var(--success);
  font-weight: 700;
}

.detail-set-done.is-incomplete {
  color: var(--faint);
}

/* ---------- stats ---------- */

.stat-tiles {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--s-3);
}

.stat-tile {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--s-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
}

.stat-value {
  font-size: var(--fs-xl);
  font-weight: 750;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

.stat-label {
  font-size: var(--fs-sm);
  font-weight: 650;
  color: var(--fg);
}

.stat-sub {
  font-size: var(--fs-xs);
  color: var(--muted);
}

.chart-card {
  position: relative;
  margin: 0;
  padding: var(--s-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

.chart-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-2);
  flex-wrap: wrap;
}

.chart-title {
  font-size: var(--fs-md);
  font-weight: 700;
}

.chart-caption {
  font-size: var(--fs-xs);
  color: var(--muted);
}

/* column chart */
.col-chart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 150px;
  border-bottom: 1px solid var(--border);
}

.col-item {
  flex: 1 1 0;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: var(--s-1);
  cursor: default;
  border-radius: var(--r-sm);
}

.col-track {
  flex: 1 1 auto;
  width: 100%;
  display: flex;
  align-items: flex-end;
  min-height: 0;
}

.col-bar {
  width: 100%;
  min-height: 2px;
  background: var(--accent);
  border-radius: 4px 4px 0 0;
  transition: filter var(--transition);
}

.col-bar.is-zero {
  min-height: 0;
}

.col-item:hover .col-bar,
.col-item:focus-visible .col-bar {
  filter: brightness(1.12);
}

.col-x {
  font-size: 0.68rem;
  color: var(--muted);
  white-space: nowrap;
  transform: translateY(2px);
}

/* horizontal ranked bars */
.hbar-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

.hbar-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hbar-label {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-width: 0;
}

.hbar-name {
  font-size: var(--fs-sm);
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hbar-track {
  position: relative;
  height: 1.5rem;
  background: var(--surface-2);
  border-radius: var(--r-sm);
  overflow: hidden;
}

.hbar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: var(--r-sm);
}

.hbar-value {
  position: absolute;
  right: var(--s-2);
  top: 50%;
  transform: translateY(-50%);
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}

/* progression line chart */
.prog-section {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.prog-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2) var(--s-3);
}

.prog-head-label {
  font-size: var(--fs-md);
  font-weight: 700;
}

.prog-select {
  /* Sized to the longest exercise name. When that doesn't fit beside the label,
   * the header wraps and the select takes a full row, never running off the page. */
  width: auto;
  max-width: 100%;
  min-width: 0;
}

/* "Max weight lifted" lookup: its own card, since (unlike Progression) the
 * result is a line of text rather than a chart in its own card below. */
.repmax-section {
  padding: var(--s-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
}

.repmax-controls {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3);
}

.repmax-controls .field {
  flex: 1 1 10rem;
}

.repmax-result {
  padding-top: var(--s-1);
}

.repmax-value {
  display: flex;
  align-items: baseline;
  gap: var(--s-2);
}

.line-svg {
  width: 100%;
  height: auto;
  display: block;
}

.grid-line {
  stroke: var(--border);
  stroke-width: 1;
}

.axis-text,
.end-label {
  fill: var(--muted);
  font-size: 12px;
  font-family: var(--font);
}

.line-path {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.25;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.line-path.line-est {
  stroke-dasharray: 5 4;
  opacity: 0.6;
}

.line-dot {
  fill: var(--accent);
  stroke: var(--surface);
  stroke-width: 1.5;
}

.line-dot.line-est {
  opacity: 0.7;
}

.end-label.line-top {
  fill: var(--accent);
  font-weight: 700;
}

.end-label.line-est {
  fill: var(--muted);
}

/* chart tooltip */
.chart-tip {
  position: absolute;
  z-index: 10;
  transform: translate(-50%, -100%);
  background: var(--fg);
  color: var(--bg);
  padding: var(--s-1) var(--s-2);
  border-radius: var(--r-sm);
  font-size: var(--fs-xs);
  white-space: nowrap;
  pointer-events: none;
  box-shadow: var(--shadow-2);
}

.chart-tip-sub {
  opacity: 0.75;
}

/* ---------- admin UI ---------- */

.admin-users {
  display: flex;
  flex-direction: column;
}

.user-card {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

.role-badge {
  margin-left: var(--s-2);
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 1px var(--s-2);
  border-radius: var(--r-full);
  background: var(--surface-2);
  color: var(--muted);
}

.role-badge[data-role="admin"] {
  background: color-mix(in srgb, var(--t-rose) 16%, transparent);
  color: var(--t-rose);
}

.user-detail {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  padding: var(--s-4);
  background: var(--surface-2);
  border-radius: var(--r-md);
}

.user-detail-head {
  margin: 0;
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.pw-note {
  color: var(--muted);
  font-size: var(--fs-sm);
}

.pw-row {
  display: flex;
  align-items: center;
  gap: var(--s-3);
}

.pw-reveal {
  flex: 1 1 auto;
  font-family: var(--mono);
  font-size: var(--fs-lg);
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: var(--s-3);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  user-select: all;
  word-break: break-all;
}

/* ---------- offline ---------- */

.history-card.is-pending {
  cursor: default;
  border-style: dashed;
}

.history-card.is-pending:hover {
  border-color: var(--border);
}

/* ---------- exercise description (About) / video links ---------- */

.desc-toggle,
.ex-link {
  flex: 0 0 auto;
  font: inherit;
  font-size: var(--fs-xs);
  font-weight: 650;
  color: var(--muted);
  background: transparent;
  border: none;
  padding: var(--s-1) var(--s-2);
  border-radius: var(--r-sm);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: var(--field-border);
  text-underline-offset: 3px;
}

.desc-toggle:hover,
.desc-toggle[aria-expanded="true"],
.ex-link:hover {
  color: var(--accent);
  text-decoration-color: currentColor;
}

.desc-panel {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-2) var(--s-3) var(--s-4);
  background: var(--surface-2);
  border-radius: var(--r-md);
  border-left: 3px solid var(--accent);
  animation: desc-in 160ms ease-out;
}

.desc-text {
  flex: 1 1 auto;
  min-width: 0;
  font-size: var(--fs-sm);
  color: var(--fg);
  white-space: pre-line;
}

.desc-close {
  flex: 0 0 auto;
  width: 1.75rem;
  height: 1.75rem;
  font-size: 1.1rem;
}

@keyframes desc-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
}

/* ---------- last time (logging) ---------- */

.prev-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-2) var(--s-3);
  font-size: var(--fs-sm);
  background: var(--surface-2);
  border-radius: var(--r-md);
}

.prev-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.prev-label {
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.prev-sets {
  color: var(--fg);
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
}

.prev-line .btn {
  flex: 0 0 auto;
}

/* ---------- editing a logged workout's date ---------- */

.detail-date-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  flex-wrap: wrap;
}

/* ---------- destructive actions + dialog sections (admin user edit) ---------- */

.btn-danger-solid {
  background: var(--solid-danger);
  color: #fff;
  box-shadow: none;
}

.btn-danger-solid:hover {
  background: var(--solid-danger);
  filter: brightness(1.08);
}

.btn-danger-solid:disabled {
  opacity: 0.4;
}

.dialog-body {
  display: flex;
  flex-direction: column;
}

.dialog-body > .dialog-form {
  padding-bottom: var(--s-4);
  border-bottom: 1px solid var(--border);
}

.dialog-section {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--border);
}

.dialog-section:last-child {
  border-bottom: none;
}

.dialog-section-title {
  font-size: var(--fs-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.dialog-danger .dialog-section-title {
  color: var(--danger);
}

.delete-confirm {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  margin-top: var(--s-2);
}

.delete-confirm .dialog-actions {
  margin-top: 0;
}

/* ---------- shared exercise list ---------- */

.exercise-list {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

.exercise-list-foot {
  display: flex;
  justify-content: flex-start;
}

.exercise-empty {
  margin: 0;
}

/* ---------- description editor: tall, scrollable, no scrollbar ---------- */

.desc-input {
  min-height: 15rem;
  line-height: 1.55;
  resize: vertical;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* legacy Edge */
}

.desc-input::-webkit-scrollbar {
  display: none; /* Chromium and Safari */
}

/* ---------- in-app confirmation ---------- */

.confirm-dialog {
  width: min(24rem, calc(100vw - 2 * var(--gutter)));
}

.confirm-text {
  color: var(--muted);
  font-size: var(--fs-sm);
}

/* ---------- assigning a program to users (admin) ---------- */

.assign-list {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  max-height: 20rem;
  overflow-y: auto;
  padding: var(--s-1);
}

.assign-row {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  cursor: pointer;
}

.assign-row:hover {
  border-color: var(--accent);
}

.assign-row input {
  width: auto;
  accent-color: var(--accent);
}

.assign-who {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.assign-name {
  font-weight: 650;
}

.assign-email {
  font-size: var(--fs-sm);
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Dropdowns: our own chevron, placed well inside the right edge, with room for
 * it in the padding so the selected text never runs underneath. */
select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 2.75rem;
  background-image: var(--select-chevron);
  background-repeat: no-repeat;
  background-position: right 1.1rem center;
  background-size: 0.75rem 0.5rem;
  cursor: pointer;
  /* Firefox tints its own built-in bits (e.g. the dropdown's selected marker)
   * with accent-color; Chromium needs the option rule below as well. */
  accent-color: var(--accent);
}

/* The selected row in the open dropdown list, in place of the browser's default
 * blue. Chromium honours this for :checked; browsers that don't (Firefox,
 * Safari) keep their own native highlight. The row the pointer is over can't be
 * styled this way in any browser — it's a native overlay the engine paints on
 * top, not a CSS background — so it stays the system colour everywhere. */
select option:checked {
  background: var(--accent-weak);
  color: var(--accent);
}
