:root {
  color-scheme: light;
  --bg: #f4f4f1;
  --card: #ffffff;
  --ink: #1c1c1a;
  --muted: #6f6f6a;
  --accent: #c3341a;
  --border: #e3e2dc;
  --card-radius: 12px;
  --btn-radius: 8px;
  --card-padding: 14px;
  --base-font-size: 16px;
  /* Text color for anything with a var(--ink) background (e.g. Log Set) -
     kept as a separate token, not a hardcoded #fff, so Dark mode (which
     flips --ink from near-black to near-white) can swap this too instead
     of leaving white-on-white text. */
  --ink-contrast: #ffffff;
}

/* The Developer Dashboard's Dark mode toggle (see app.js applyDevTheme())
   sets --bg/--card/--ink/--muted/--border directly as inline custom
   properties on <html> rather than through a stylesheet rule here - an
   inline custom property always wins the cascade over any selector, so a
   CSS-only override on html[data-dev-theme="dark"] would never actually
   be visible once those same five are also inline-set for light mode. */

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

/* Browser surfaces nobody drew by hand still carry the design - theme
   them from the palette instead of leaving the OS/browser default blue. */
::selection { background: var(--accent); color: #fff; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

html { -webkit-text-size-adjust: 100%; height: 100%; font-size: var(--base-font-size); }

body {
  margin: 0;
  font-family: Barlow, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 16px;
  padding-top: calc(8px + env(safe-area-inset-top, 0px));
  border-bottom: 1px solid var(--border);
  background: var(--card);
}

.topbar h1 {
  font-family: "Barlow Condensed", sans-serif;
  font-weight: 700;
  letter-spacing: 0.02em;
  font-size: 1.15rem;
  margin: 0;
  white-space: nowrap;
  text-transform: uppercase;
}

.user-box { display: flex; align-items: center; gap: 12px; font-size: 0.9rem; color: var(--muted); min-width: 0; }
#userEmail { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 45vw; }
.link-btn {
  background: none; border: none; color: var(--accent); cursor: pointer;
  font-size: 0.9rem; padding: 6px 0; text-decoration: underline;
  touch-action: manipulation;
}

.settings-wrap { position: relative; }
.icon-btn {
  background: none; border: 1px solid var(--border); border-radius: 8px;
  width: 36px; height: 36px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; touch-action: manipulation; color: var(--ink);
}
.icon-btn svg { width: 20px; height: 20px; }
.settings-menu {
  position: absolute; right: 0; top: calc(100% + 6px);
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12); min-width: 190px; overflow: hidden; z-index: 20;
}
.menu-item {
  display: block; width: 100%; text-align: left; padding: 12px 14px;
  background: none; border: none; cursor: pointer; font-size: 0.9rem;
  color: var(--ink); touch-action: manipulation;
}
.menu-item:hover { background: var(--bg); }
.menu-item.danger { color: #c0392b; }
.menu-item + .menu-item { border-top: 1px solid var(--border); }
.menu-toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; font-size: 0.9rem; color: var(--ink);
  border-bottom: 1px solid var(--border);
}

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45);
  display: flex; align-items: center; justify-content: center;
  padding: 16px; z-index: 50;
}
.modal-card { background: var(--card); border-radius: var(--card-radius); padding: 20px; max-width: 340px; width: 100%; }
.modal-card p { margin: 0 0 18px; font-size: 0.95rem; color: var(--ink); }
.modal-card label {
  display: block; text-align: left; font-size: 0.85rem; color: var(--muted);
  margin: -6px 0 16px;
}
.modal-card input {
  display: block; width: 100%; margin-top: 6px; padding: 10px; min-height: 44px;
  border-radius: 8px; border: 1px solid var(--border); font-size: 16px;
}
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.modal-btn {
  padding: 10px 16px; min-height: 44px; border-radius: var(--btn-radius); border: 1px solid var(--border);
  background: var(--bg); cursor: pointer; font-size: 0.9rem; touch-action: manipulation;
}
.modal-btn.danger { background: var(--accent); color: #fff; border-color: var(--accent); }

.hidden { display: none !important; }

main {
  flex: 1 1 auto;
  min-height: 0;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.screen { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; overflow-y: auto; }

#appScreen { overflow-y: hidden; }

#categoriesView, #exercisesView, #historyView, #aboutView, #routinesView, #routineEditorView {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
}

.routine-header { display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; }
.routine-primary, .routine-actions button, .routine-add button, .routine-item-controls button { border:1px solid var(--border); border-radius:var(--btn-radius); padding:10px 14px; min-height:44px; background:var(--card); color:var(--ink); cursor:pointer; font:inherit; }
.routine-primary, .routine-actions .routine-primary { background:var(--accent); color:#fff; border-color:var(--accent); font-weight:700; }
#openRoutinesBtn { align-self:flex-start; margin:4px 0 16px; }
.routine-list, .routine-editor-items { display:grid; gap:12px; }
.routine-card, .routine-editor, .routine-item { min-width:0; background:var(--card); border:1px solid var(--border); border-radius:var(--card-radius); padding:16px; }
.routine-card h3, .routine-item h4 { margin:0 0 6px; }
.routine-card p, .routine-editor p { color:var(--muted); }
.routine-actions, .routine-item-controls { display:flex; gap:8px; flex-wrap:wrap; }
.routine-actions .danger { color:#c0392b; }
.routine-editor label { display:flex; flex-direction:column; gap:5px; color:var(--ink); font-size:.9rem; }
.routine-editor input, .routine-editor select { width:100%; min-height:44px; padding:8px; border:1px solid var(--border); border-radius:var(--btn-radius); background:var(--card); color:var(--ink); font:inherit; }
.routine-add { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,2fr) auto; gap:10px; align-items:end; }
.routine-add label { min-width:0; }
.routine-item-targets { display:grid; grid-template-columns:1fr 1fr; gap:10px; margin:12px 0; }
.routine-target-field { min-width:0; }
.routine-target-field label { margin-bottom:5px; }
.routine-stepper { display:flex; align-items:stretch; min-width:0; }
.routine-stepper button { flex:0 0 40px; min-height:44px; padding:0; border:1px solid var(--border); background:var(--bg); color:var(--ink); font-family:inherit; font-size:1.25rem; font-weight:600; line-height:1; cursor:pointer; touch-action:manipulation; }
.routine-stepper button:first-child { border-radius:var(--btn-radius) 0 0 var(--btn-radius); }
.routine-stepper button:last-child { border-radius:0 var(--btn-radius) var(--btn-radius) 0; }
.routine-stepper button:disabled { opacity:.4; cursor:default; }
.routine-editor .routine-stepper input { flex:1 1 0; min-width:0; border-radius:0; text-align:center; padding:8px 2px; appearance:textfield; -moz-appearance:textfield; }
.routine-stepper input::-webkit-inner-spin-button, .routine-stepper input::-webkit-outer-spin-button { -webkit-appearance:none; margin:0; }
@media(max-width:600px) { .routine-add { grid-template-columns:1fr; } .routine-actions button { flex:1 1 auto; } }

.back-btn {
  flex-shrink: 0;
  align-self: flex-start;
  display: flex; align-items: center; gap: 4px;
  background: none; border: none; color: var(--accent);
  font-size: 0.9rem; font-weight: 600; cursor: pointer; padding: 8px 0 12px;
  touch-action: manipulation;
}
.back-btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.view-title {
  font-family: "Barlow Condensed", sans-serif;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin: 4px 0 4px;
  font-size: 1.4rem;
}
.view-subtitle { color: var(--muted); margin: 0 0 16px; font-size: 0.92rem; }

.auth-card {
  max-width: 380px;
  margin: 40px auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  padding: 24px;
}

.auth-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tab-btn {
  flex: 1; padding: 10px 8px; min-height: 44px; border-radius: var(--btn-radius); border: 1px solid var(--border);
  background: var(--bg); cursor: pointer; font-size: 0.95rem; touch-action: manipulation;
}
.tab-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--muted); }
.auth-form input, textarea {
  padding: 10px; border-radius: 8px; border: 1px solid var(--border); font-size: 16px;
  min-height: 44px;
}
.auth-form button[type="submit"] {
  flex-shrink: 0;
  border-radius: var(--btn-radius); border: none; background: var(--accent);
  color: #fff; cursor: pointer; margin-top: 4px; touch-action: manipulation;
  width: 100%; padding: 12px; min-height: 46px; font-size: 1rem;
}
.auth-form button[type="submit"]:hover { opacity: 0.92; }
.auth-form .link-btn { align-self: flex-start; }

.form-error { flex-shrink: 0; color: #c0392b; font-size: 0.85rem; min-height: 1em; margin: 6px 0 0; }
.form-success { flex-shrink: 0; color: #2e7d32; font-size: 0.85rem; min-height: 1em; margin: 6px 0 0; }

.divider { display: flex; align-items: center; gap: 10px; margin: 18px 0 12px; color: var(--muted); font-size: 0.8rem; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

#googleBtn { display: flex; justify-content: center; }
.hint { font-size: 0.75rem; color: var(--muted); text-align: center; margin-top: 8px; }

/* ---------- Categories ---------- */
.categories-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.category-card {
  --cat-color: #888;
  position: relative;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--border);
  border-top: 4px solid var(--cat-color);
  /* Square top corners where the flat accent border sits - a rounded
     corner under a straight-edged border reads as a rendering glitch,
     not an accent. Bottom corners keep the card's own radius. */
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  border-bottom-left-radius: var(--card-radius);
  border-bottom-right-radius: var(--card-radius);
  padding: 20px 18px 44px;
  cursor: pointer;
  font: inherit;
  color: var(--ink);
  touch-action: manipulation;
  min-height: 120px;
}
.category-card:hover { box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08); }
.category-card h3 {
  margin: 0 0 6px;
  font-family: "Barlow Condensed", sans-serif;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 1.1rem;
}
.category-card p { margin: 0; color: var(--muted); font-size: 0.85rem; line-height: 1.4; }
.category-card .card-arrow {
  position: absolute; right: 16px; bottom: 14px;
  color: var(--cat-color); display: flex;
}
.category-card .card-arrow svg { width: 20px; height: 20px; }

/* ---------- Exercises ---------- */
.exercises-list { display: flex; flex-direction: column; gap: 12px; }
.exercise-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--card-radius);
  padding: var(--card-padding) calc(var(--card-padding) + 2px);
  display: flex; gap: 14px; align-items: flex-start;
  border-left: 5px solid transparent; transition: border-left-color 0.15s ease;
}
/* Developer Dashboard "color-code exercise cards" toggle - app.js sets
   --cat-accent per card to its workout's own color. */
body.dev-colorize .exercise-card { border-left-color: var(--cat-accent, var(--accent)); }
.exercise-media {
  flex: 0 0 84px; width: 84px; height: 100px; border-radius: var(--card-radius); background: var(--bg);
  display: flex; align-items: center; justify-content: center; color: var(--ink); overflow: hidden;
}
.exercise-figure-svg { width: 100%; height: 100%; }
.exercise-photo { width: 100%; height: 100%; object-fit: contain; display: block; cursor: zoom-in; }

.lightbox-overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.9);
  display: flex; align-items: center; justify-content: center;
  padding: 10px; z-index: 60; cursor: zoom-out;
}
.lightbox-overlay img {
  width: auto; height: auto; max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 10px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5); cursor: default;
}
.lightbox-close {
  position: absolute; top: 10px; right: 10px; background: rgba(0, 0, 0, 0.5);
  border: none; border-radius: 50%; width: 40px; height: 40px;
  color: #fff; cursor: pointer; padding: 0;
  display: flex; align-items: center; justify-content: center;
  touch-action: manipulation;
}
.lightbox-close svg { width: 20px; height: 20px; }
.exercise-body { flex: 1 1 auto; min-width: 0; }
.exercise-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.exercise-head h3 { margin: 0; font-size: 1.02rem; }
.video-link { font-size: 0.82rem; color: var(--accent); text-decoration: none; font-weight: 600; white-space: nowrap; }
.video-link:hover { text-decoration: underline; }
.exercise-description { margin: 6px 0 0; font-size: 0.85rem; color: var(--muted); line-height: 1.45; }

.exercise-targets { display: flex; gap: 16px; margin: 10px 0; }
.exercise-targets label {
  display: flex; flex-direction: column; gap: 4px; font-size: 0.78rem; color: var(--muted);
  flex: 1 1 0;
}
.exercise-targets input {
  padding: 8px; border-radius: 8px; border: 1px solid var(--border); font-size: 16px; width: 100%;
}

.exercise-weight { display:flex; align-items:center; justify-content:space-between; gap:12px; margin:10px 0; }
.exercise-weight-label { font-size:.85rem; color:var(--muted); }
.exercise-weight-stepper { display:flex; align-items:stretch; flex-shrink:0; }
.exercise-weight-stepper button { width:44px; min-height:44px; border:1px solid var(--border); background:var(--bg); color:var(--ink); font-size:1.25rem; font-weight:600; cursor:pointer; touch-action:manipulation; }
.exercise-weight-stepper button:first-child { border-radius:8px 0 0 8px; }
.exercise-weight-stepper button:last-child { border-radius:0 8px 8px 0; }
.exercise-weight-stepper button:disabled { opacity:.4; cursor:default; }
.exercise-weight-stepper output { display:flex; align-items:center; justify-content:center; min-width:52px; border-top:1px solid var(--border); border-bottom:1px solid var(--border); background:var(--card); color:var(--ink); }

.exercise-progress { display: flex; align-items: center; gap: 10px; margin: 8px 0 12px; }
.progress-bar { flex: 1 1 auto; height: 8px; border-radius: 999px; background: var(--bg); overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: var(--accent); border-radius: 999px; transition: width 0.2s ease; }
.progress-label { flex-shrink: 0; font-size: 0.8rem; color: var(--muted); white-space: nowrap; }

.exercise-actions { display: flex; gap: 8px; }
.log-set-btn {
  flex: 1 1 auto; padding: 12px; min-height: 46px; border-radius: var(--btn-radius); border: none;
  background: var(--ink); color: var(--ink-contrast); font-weight: 700; font-size: 0.95rem; cursor: pointer;
  touch-action: manipulation; text-transform: uppercase; letter-spacing: 0.02em;
}
.log-set-btn:hover { opacity: 0.9; }
.log-set-btn:active { transform: scale(0.98); }
.log-set-btn:disabled { opacity: 0.6; cursor: default; }

.undo-set-btn {
  flex: 0 0 auto; padding: 12px 16px; min-height: 46px; border-radius: var(--btn-radius);
  border: 1px solid var(--border); background: var(--card); color: var(--muted);
  font-weight: 600; font-size: 0.85rem; cursor: pointer; touch-action: manipulation;
  white-space: nowrap;
}
.undo-set-btn:hover:not(:disabled) { color: #c0392b; border-color: #c0392b; }
.undo-set-btn:disabled { opacity: 0.4; cursor: default; }
.exercise-error { margin: 6px 0 0; }

/* ---------- History ---------- */
.history-panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--card-radius); padding: calc(var(--card-padding) + 6px); }

.date-range-picker { display: flex; align-items: center; flex-wrap: wrap; gap: 12px 16px; }
.date-range-picker label { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--muted); }
.date-range-picker input[type="date"], .date-range-picker select {
  padding: 6px 8px; border-radius: 6px; border: 1px solid var(--border); font-size: 0.85rem;
  font-family: inherit; background: var(--bg); color: var(--ink);
}
.date-range-picker .link-btn { font-size: 0.8rem; padding: 0; }

.history-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
.date-range-picker + .history-header { margin-top: 16px; }
.history-header h2 { margin: 0; font-size: 1rem; }
#categoryCountChart { margin-top: 8px; }

.load-more-btn {
  display: block; width: 100%; margin-top: 12px; padding: 10px; border-radius: var(--btn-radius);
  border: 1px solid var(--border); background: var(--bg); color: var(--ink);
  font-size: 0.85rem; cursor: pointer; touch-action: manipulation;
}
.load-more-btn:hover { background: var(--border); }

.about-panel {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--card-radius);
  padding: calc(var(--card-padding) + 6px); text-align: left;
}
.about-panel h2 { margin: 0 0 12px; font-size: 1.2rem; }
.about-panel h3 { font-size: 1rem; margin: 20px 0 8px; }
.about-panel p { color: var(--ink); line-height: 1.5; margin: 0 0 12px; font-size: 0.92rem; }
.about-panel ul, .about-panel ol { margin: 0 0 12px; padding-left: 20px; color: var(--ink); font-size: 0.92rem; line-height: 1.6; }
.about-panel li { margin-bottom: 4px; }

.entry-list { list-style: none; margin: 16px 0 0; padding: 0; max-height: 340px; overflow-y: auto; }
.entry-list li {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 10px 0;
  border-bottom: 1px solid var(--border); font-size: 0.85rem;
}
.entry-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 auto; }
.entry-list .entry-emotions { font-weight: 600; }
.entry-list .entry-meta { color: var(--muted); }
.entry-actions { flex-shrink: 0; display: flex; gap: 2px; }
.entry-delete-btn {
  flex-shrink: 0; background: none; border: none; color: var(--muted); cursor: pointer;
  display: flex; padding: 6px 8px; touch-action: manipulation;
}
.entry-delete-btn svg { width: 16px; height: 16px; }
.entry-delete-btn:hover { color: #c0392b; }

#historyChart { max-width: 100%; }

@media (max-width: 600px) {
  .topbar { padding: 6px 12px; padding-top: calc(6px + env(safe-area-inset-top, 0px)); }
  .topbar h1 { font-size: 1rem; }
  .user-box { gap: 8px; }
  #userEmail { max-width: 26vw; }
  main { padding: 6px 10px; }
  .auth-card { margin: 20px auto; padding: 18px; }
  .history-panel, .about-panel { padding: var(--card-padding); }
  .history-header { justify-content: flex-start; }
  .categories-cards { grid-template-columns: 1fr; }
  .exercise-targets { gap: 10px; }
  .exercise-actions { flex-direction: column; }
  .undo-set-btn { width: 100%; }
  .exercise-media { flex-basis: 64px; width: 64px; height: 76px; }
}

@media (max-width: 380px) {
  .exercise-card { flex-direction: column; }
  .exercise-media { width: 84px; height: 100px; align-self: flex-start; }
}

/* Developer Dashboard "Compact cards" toggle - a fixed override rather
   than tying into --card-padding, so it doesn't fight the Card padding
   slider's own value; unchecking it just reveals whatever the slider
   is currently set to. */
body.dev-compact .exercise-card { padding: 8px 10px; }
body.dev-compact .exercises-list { gap: 8px; }
body.dev-compact .categories-cards { gap: 8px; }
body.dev-compact .category-card { padding: 14px 14px 36px; min-height: 92px; }

/* ---------- Developer Dashboard ---------- */
.dev-panel {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--card-radius);
  padding: calc(var(--card-padding) + 6px);
}
.dev-section { margin-bottom: 26px; }
.dev-section:last-of-type { margin-bottom: 0; }
.dev-section h3 {
  margin: 0 0 14px; font-size: 0.8rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--muted);
}
.dev-section h3.dev-subheading { margin-top: 20px; }

.dev-color-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.dev-color-row { display: flex; flex-direction: column; gap: 6px; font-size: 0.8rem; color: var(--ink); }
.dev-color-row input[type="color"] {
  width: 100%; height: 40px; border: 1px solid var(--border); border-radius: var(--btn-radius);
  padding: 3px; background: var(--bg); cursor: pointer;
}

.dev-slider-row { margin-bottom: 16px; }
.dev-slider-row:last-child { margin-bottom: 0; }
.dev-slider-row label {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 0.85rem; color: var(--ink); margin-bottom: 8px;
}
.dev-slider-row label span { color: var(--muted); font-size: 0.78rem; font-variant-numeric: tabular-nums; }
.dev-slider-row input[type="range"] { width: 100%; accent-color: var(--accent); }

.dev-toggle-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.dev-toggle-row:last-child { border-bottom: none; }
.dev-toggle-row span:first-child { font-size: 0.88rem; }

.dev-switch { position: relative; display: inline-block; width: 42px; height: 24px; flex-shrink: 0; }
.dev-switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.dev-switch-track {
  position: absolute; inset: 0; background: var(--border); border-radius: 999px;
  transition: background 0.15s ease; pointer-events: none;
}
.dev-switch-track::before {
  content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: transform 0.15s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}
.dev-switch input:checked + .dev-switch-track { background: var(--accent); }
.dev-switch input:checked + .dev-switch-track::before { transform: translateX(18px); }

.dev-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 24px; }
.dev-actions button {
  padding: 11px 18px; border-radius: var(--btn-radius); border: 1px solid var(--border);
  background: var(--bg); color: var(--ink); font-size: 0.85rem; font-weight: 600;
  cursor: pointer; touch-action: manipulation;
}
.dev-actions button.primary { background: var(--ink); color: var(--ink-contrast); border-color: var(--ink); }
.dev-actions button:hover { opacity: 0.88; }
.dev-note { font-size: 0.78rem; color: var(--muted); margin: 10px 0 0; min-height: 1em; }

/* Expanded leg exercise library */
.exercise-filters { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; margin: 0 0 18px; }
.exercise-filters label { display: grid; gap: 6px; flex: 1 1 160px; font-size: .82rem; color: var(--muted); }
.exercise-filters input, .exercise-filters select { width: 100%; min-height: 44px; padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); color: var(--ink); font: inherit; }
#exerciseResultCount { margin: 0; font-size: .82rem; color: var(--muted); }
.exercise-library-hint { flex-basis: 100%; margin: 0; color: var(--muted); font-size: .8rem; }
.exercise-library-card .exercise-media { position: relative; flex: 0 0 240px; width: 240px; height: auto; aspect-ratio: 3 / 2; }
.exercise-library-card .exercise-photo { object-fit: contain; }
.exercise-meta { margin: 5px 0 0; font-size: .76rem; font-weight: 600; color: var(--muted); }
.exercise-video-credit { margin: 7px 0 0; font-size: .73rem; color: var(--muted); }
.exercise-video-note { margin: 5px 0 0; font-size: .76rem; line-height: 1.45; color: var(--muted); }
.exercise-photo:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
@media (max-width: 700px) {
  .exercise-library-card { flex-direction: column; }
  .exercise-library-card .exercise-media { flex: none; width: 100%; height: auto; aspect-ratio: 3 / 2; }
  .exercise-library-card .exercise-body { width: 100%; }
}

.exercise-section-banner {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 9px 14px;
  margin-bottom: 12px;
  background: var(--card);
  color: var(--ink);
  border-bottom: 2px solid var(--section-color, var(--accent));
  font-size: .9rem;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .08);
}

.exercise-section-banner .back-btn { align-self: center; padding: 8px 0; }
.exercise-section-banner .view-title { margin: 0; }

.routine-template details { margin: 12px 0; line-height: 1.55; }
.routine-template summary { cursor: pointer; font-weight: 600; }
.routine-template li { margin-bottom: 8px; }
.routine-session-notes { padding: 14px; background: var(--card); border: 1px solid var(--border); border-radius: var(--card-radius); line-height: 1.6; white-space: pre-line; flex-shrink: 0; }
.routine-prescription { font-weight: 700; color: var(--accent); }
.routine-exercise-cue { line-height: 1.5; }
.routine-actual { display: block; margin: 12px 0; font-size: .9rem; }
.routine-actual input { display: block; width: 100%; max-width: 220px; padding: 10px; margin-top: 5px; font-size: 16px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); color: var(--ink); }
.routine-editor textarea { width: 100%; padding: 10px; font: inherit; background: var(--card); color: var(--ink); border: 1px solid var(--border); border-radius: 8px; }
.routine-item-targets > label { min-width: 0; flex: 1; }

/* Always-visible equipment switcher, above the app's independent scroll views. */
.training-modes { flex: 0 0 auto; display: flex; justify-content: center; gap: 6px; padding: 8px 12px; padding-top: calc(8px + env(safe-area-inset-top, 0px)); background: var(--card); border-bottom: 1px solid var(--border); z-index: 25; }
.training-modes a { flex: 1 1 0; max-width: 190px; min-height: 44px; display: flex; align-items: center; justify-content: center; text-decoration: none; font-weight: 700; color: var(--ink); border: 1px solid var(--border); border-radius: 9px; padding: 6px 8px; font-size: .95rem; }
.training-modes a[aria-current="page"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.training-modes a:hover { box-shadow: inset 0 0 0 1px var(--accent); }
.account-mode-hint { font-size: .85rem; line-height: 1.5; color: var(--muted); }

.workout-nav { flex:0 0 auto; display:flex; justify-content:center; gap:6px; padding:8px 10px; background:var(--card); border-bottom:1px solid var(--border); z-index:25; }
.workout-nav button { flex:1 1 0; max-width:180px; min-height:44px; border:1px solid var(--border); border-radius:9px; background:var(--card); color:var(--ink); font:inherit; font-weight:700; cursor:pointer; padding:6px; }
.workout-nav button[aria-current="page"] { background:var(--accent); color:#fff; border-color:var(--accent); }
.training-badge { display:inline-block; margin-left:8px; padding:3px 8px; border:1px solid var(--border); border-radius:20px; font-size:.72rem; font-weight:600; color:var(--muted); vertical-align:middle; white-space:nowrap; }
#totalGymImportView { flex:1 1 auto; min-height:0; overflow-y:auto; }

.shared-workouts .routine-add { grid-template-columns:minmax(0,1fr) minmax(0,1fr) minmax(0,2fr) auto; }
@media(max-width:600px) { .shared-workouts .routine-add { grid-template-columns:1fr; } }
