*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root,
[data-theme="dark"] {
  --bg: #1a1f24;
  --bg-panel: #242b32;
  --bg-input: #2d3640;
  --text: #e8edf2;
  --text-muted: #7a8794;
  --accent: #00e5ff;
  --accent-glow: rgba(0, 229, 255, 0.45);
  --accent-on: #0a1218;
  --rest: #ffb347;
  --rest-glow: rgba(255, 179, 71, 0.4);
  --danger: #ff5c5c;
  --segment-inactive: #3d4a56;
  --overlay-bg: rgba(10, 14, 18, 0.92);
  --backdrop: rgba(0, 0, 0, 0.65);
  --radius: 12px;
  --font-mono: "Share Tech Mono", "Courier New", monospace;
  --clock-col: 70;
}

[data-theme="light"] {
  --bg: #eef1f5;
  --bg-panel: #ffffff;
  --bg-input: #dde3ea;
  --text: #1a2332;
  --text-muted: #5a6a7e;
  --accent: #0077cc;
  --accent-glow: rgba(0, 119, 204, 0.25);
  --accent-on: #ffffff;
  --rest: #d97706;
  --rest-glow: rgba(217, 119, 6, 0.3);
  --danger: #dc2626;
  --segment-inactive: #c5d0dc;
  --overlay-bg: rgba(255, 255, 255, 0.94);
  --backdrop: rgba(26, 35, 50, 0.35);
}

[data-theme="neon"] {
  --bg: #080c10;
  --bg-panel: #101820;
  --bg-input: #182228;
  --text: #e0fff4;
  --text-muted: #6b9e8a;
  --accent: #39ff14;
  --accent-glow: rgba(57, 255, 20, 0.5);
  --accent-on: #041008;
  --rest: #ff2d95;
  --rest-glow: rgba(255, 45, 149, 0.45);
  --danger: #ff3355;
  --segment-inactive: #1e3d32;
  --overlay-bg: rgba(4, 8, 6, 0.94);
  --backdrop: rgba(0, 0, 0, 0.75);
}

[data-theme="amber"] {
  --bg: #1c1410;
  --bg-panel: #2a1f18;
  --bg-input: #3a2c22;
  --text: #fff4e6;
  --text-muted: #b8956f;
  --accent: #ff9500;
  --accent-glow: rgba(255, 149, 0, 0.45);
  --accent-on: #1c1008;
  --rest: #ffd60a;
  --rest-glow: rgba(255, 214, 10, 0.35);
  --danger: #ff6b4a;
  --segment-inactive: #4a3828;
  --overlay-bg: rgba(20, 12, 8, 0.92);
  --backdrop: rgba(0, 0, 0, 0.65);
}

[data-theme="ocean"] {
  --bg: #0a1628;
  --bg-panel: #122240;
  --bg-input: #1a3050;
  --text: #e8f4ff;
  --text-muted: #7aa3c4;
  --accent: #2dd4bf;
  --accent-glow: rgba(45, 212, 191, 0.45);
  --accent-on: #042028;
  --rest: #60a5fa;
  --rest-glow: rgba(96, 165, 250, 0.4);
  --danger: #f87171;
  --segment-inactive: #1e4060;
  --overlay-bg: rgba(6, 14, 28, 0.92);
  --backdrop: rgba(0, 0, 0, 0.65);
}

html,
body {
  height: 100%;
  height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}

html:has(body[data-page="about"]),
html:has(body[data-page="bar-calculator"]) {
  height: 100%;
  height: 100dvh;
  overflow: hidden;
}

body[data-page="about"],
body[data-page="bar-calculator"] {
  height: 100%;
  height: 100dvh;
  overflow: hidden;
}

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

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

.screen.active {
  display: flex;
}

/* ── Setup ── */

/* ── Site nav ── */

.site-nav {
  display: flex;
  gap: 0.35rem;
  padding: 0.65rem 1rem;
  padding-top: max(0.65rem, env(safe-area-inset-top));
  background: var(--bg-panel);
  border-bottom: 1px solid var(--bg-input);
  overflow-x: auto;
  flex-shrink: 0;
}

.site-nav a {
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}

.site-nav a:hover,
.site-nav a.active {
  color: var(--accent);
  background: rgba(0, 229, 255, 0.08);
}

.site-nav-theme {
  margin-left: auto;
  width: 40px;
  height: 40px;
  font-size: 1.1rem;
}

.site-nav--minimal {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 10;
  background: transparent;
  border: none;
}

#setup-screen,
#remote-screen {
  padding: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.setup-flow {
  padding: 0 1.25rem 2rem;
  padding-bottom: max(2rem, env(safe-area-inset-bottom));
}

#setup-screen .setup-header,
#remote-screen .setup-header,
#remote-screen .remote-connect {
  padding-left: 0;
  padding-right: 0;
}

#setup-screen .setup-header {
  padding-top: 1rem;
}

#remote-screen .setup-header {
  padding-top: 0.75rem;
}

.workout-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1rem;
}

.workout-list-empty {
  padding: 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  background: var(--bg-panel);
  border-radius: var(--radius);
  border: 1px dashed var(--bg-input);
}

#btn-add-block {
  margin-top: 0.65rem;
}

.workout-block-toolbar {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  padding: 0.5rem 0.6rem;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--bg-input);
}

.block-type-field {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.block-type-field span {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.block-type-field select,
.setup-select,
.settings-field select {
  width: 100%;
  min-height: 2.5rem;
  padding: 0.55rem 2.25rem 0.55rem 0.75rem;
  border: 1px solid var(--bg-input);
  border-radius: 8px;
  background-color: var(--bg-input);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%237a8794' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 12px 8px;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
}

.block-type-field select:hover,
.setup-select:hover,
.settings-field select:hover {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--bg-input));
}

.block-type-field select:focus,
.setup-select:focus,
.settings-field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent);
}

.block-type-field select option,
.setup-select option,
.settings-field select option {
  background: var(--bg-panel);
  color: var(--text);
}

.workout-block-order {
  flex-shrink: 0;
  width: 1.75rem;
  height: 1.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--bg-input);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.btn-remove-block {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 8px;
  background: rgba(255, 92, 92, 0.15);
  color: var(--danger);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.workout-block {
  padding: 0.75rem;
  background: var(--bg-panel);
  border-radius: var(--radius);
  border: 1px solid var(--bg-input);
}

.workout-block--empty {
  padding-bottom: 0.65rem;
}

.workout-block--empty .panel-config {
  margin-bottom: 0.5rem;
}

.workout-block-title {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--accent);
  margin-bottom: 0.15rem;
}

.workout-block-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.workout-block--empty .workout-block-hint {
  margin-bottom: 0.35rem;
}

.workout-block .panel-config {
  margin-bottom: 0.65rem;
  padding: 0.5rem 0.65rem;
  background: var(--bg-input);
  border-radius: 8px;
}

@media (max-width: 520px) {
  .workout-block:not(.workout-block--empty) {
    overflow-x: auto;
  }

  .exercise-list-header,
  .exercise-item,
  .exercise-item--with-rest {
    min-width: 420px;
  }
}

.template-hint {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.header-actions,
.toolbar-actions {
  display: flex;
  gap: 0.45rem;
  flex-shrink: 0;
  align-items: center;
}

.setup-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.subtitle {
  color: var(--text-muted);
  margin-top: 0.25rem;
  font-size: 0.95rem;
}

.block-tabs {
  display: flex;
  gap: 0.5rem;
  margin: 1rem 0 0.75rem;
}

.block-tab {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 2px solid var(--bg-input);
  border-radius: var(--radius);
  background: var(--bg-panel);
  color: var(--text-muted);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.block-tab.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(0, 229, 255, 0.08);
}

.setup-panels {
  position: relative;
  min-height: 0;
}

.setup-panel {
  display: none;
}

.setup-panel.active {
  display: block;
}

.panel-config {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.65rem;
  padding: 0.5rem 0.65rem;
  background: var(--bg-panel);
  border-radius: var(--radius);
}

.panel-config label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.panel-config select,
.panel-config input,
.exercise-row input,
.exercise-item input,
.global-settings input {
  padding: 0.45rem 0.5rem;
  border: 1px solid var(--bg-input);
  border-radius: 6px;
  background: var(--bg-input);
  color: var(--text);
  font-size: 0.9rem;
}

.panel-config select {
  min-height: 2.25rem;
  padding: 0.45rem 2rem 0.45rem 0.55rem;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-color: var(--bg-input);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%237a8794' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.55rem center;
  background-size: 12px 8px;
  cursor: pointer;
  font-weight: 600;
}

.panel-config select option {
  background: var(--bg-panel);
  color: var(--text);
}

.panel-config select:focus,
.panel-config input:focus,
.exercise-row input:focus,
.exercise-item input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.exercise-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
}

.exercise-list-header {
  display: grid;
  grid-template-columns: 1.5rem minmax(80px, 1fr) 3.5rem 3.5rem 4rem 3.5rem 2rem;
  gap: 0.35rem;
  padding: 0 0.15rem 0.25rem;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.exercise-list-header span:nth-child(n + 3) {
  text-align: center;
}

.exercise-list-header--no-rest {
  grid-template-columns: 1.5rem minmax(80px, 1fr) 3.5rem 3.5rem 4rem 2rem;
}

.exercise-list-header--no-rest span:nth-child(6) {
  display: none;
}

.exercise-item {
  display: grid;
  grid-template-columns: 1.5rem minmax(80px, 1fr) 3.5rem 3.5rem 4rem 2rem;
  gap: 0.35rem;
  align-items: center;
  padding: 0.25rem 0.15rem;
  background: var(--bg);
  border-radius: 6px;
}

.exercise-item-num {
  flex-shrink: 0;
  width: 1.35rem;
  height: 1.35rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--bg-panel);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
}

.exercise-item-name {
  min-width: 0;
}

.exercise-item-weight,
.exercise-item-reps,
.exercise-item-rest {
  min-width: 0;
  text-align: center;
}

.exercise-item--with-rest {
  grid-template-columns: 1.5rem minmax(80px, 1fr) 3.5rem 3.5rem 4rem 3.5rem 2rem;
}

.btn-remove--compact {
  width: 2rem;
  height: 2rem;
  min-width: 2rem;
  padding: 0;
  font-size: 1.15rem;
}

.exercise-row {
  display: grid;
  grid-template-columns: 1fr 100px 44px;
  gap: 0.5rem;
  align-items: center;
}

.exercise-row--weights {
  grid-template-columns: 1fr 90px 80px 80px 44px;
}

.exercise-row .weight-field {
  font-size: 0.9rem;
}

.exercise-row input {
  width: 100%;
}

.btn-remove {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 8px;
  background: rgba(255, 92, 92, 0.15);
  color: var(--danger);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.btn-add {
  margin-top: 0.75rem;
  padding: 0.65rem 1rem;
  border: 2px dashed var(--bg-input);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.95rem;
  cursor: pointer;
  width: 100%;
}

.btn-add:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.global-settings {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--bg-panel);
  border-radius: var(--radius);
}

.global-settings label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
}

.global-settings input[type="number"],
.global-settings select,
.wod-templates select {
  max-width: 100%;
  padding: 0.65rem 2.25rem 0.65rem 0.75rem;
  border: 1px solid var(--bg-input);
  border-radius: 8px;
  background-color: var(--bg-input);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%237a8794' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 12px 8px;
  color: var(--text);
  font-size: 1rem;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  cursor: pointer;
}

.global-settings select option,
.wod-templates select option {
  background: var(--bg-panel);
  color: var(--text);
}

.wod-templates {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--bg-panel);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.wod-templates label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
}

.template-save-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.template-save-row input {
  flex: 1;
  min-width: 140px;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--bg-input);
  border-radius: 8px;
  background: var(--bg-input);
  color: var(--text);
  font-size: 1rem;
}

.workout-preview {
  font-size: 0.95rem;
  color: var(--accent);
  margin: 0;
}

.btn-inline {
  display: inline-block;
  width: auto;
  margin-top: 0;
  min-width: auto;
}

.btn-danger-text {
  color: var(--danger);
  border-color: rgba(255, 92, 92, 0.35);
}

.btn-control.btn-accent {
  border-color: var(--accent);
  color: var(--accent);
}

.remote-amrap {
  padding: 0.75rem;
  background: var(--bg-panel);
  border-radius: var(--radius);
  text-align: center;
}

.btn-icon {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border: 2px solid var(--bg-input);
  border-radius: var(--radius);
  background: var(--bg-panel);
  color: var(--text);
  font-size: 1.35rem;
  cursor: pointer;
}

/* ── Settings menu ── */

.settings-menu {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.settings-menu.hidden {
  display: none;
}

.settings-backdrop {
  position: absolute;
  inset: 0;
  border: none;
  background: var(--backdrop);
  cursor: pointer;
}

.settings-panel {
  position: relative;
  z-index: 1;
  width: min(440px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-panel);
  border: 1px solid var(--bg-input);
  border-radius: var(--radius);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--bg-input);
}

.settings-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
}

.btn-close {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 8px;
  background: var(--bg-input);
  color: var(--text-muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.settings-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.settings-section h3 {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.layout-presets {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.layout-preset {
  padding: 0.85rem 1rem;
  border: 2px solid var(--bg-input);
  border-radius: 8px;
  background: var(--bg-input);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.layout-preset.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(0, 229, 255, 0.1);
}

.settings-range {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.85rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.settings-range strong {
  color: var(--accent);
}

.settings-range input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.settings-toggle {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0;
  font-size: 0.95rem;
  color: var(--text);
  cursor: pointer;
}

.settings-toggle input[type="checkbox"] {
  width: 1.15rem;
  height: 1.15rem;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.settings-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.5rem;
  font-size: 0.95rem;
  color: var(--text);
}

.settings-field input[type="number"] {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--bg-input);
  border-radius: 8px;
  background: var(--bg-input);
  color: var(--text);
  font-size: 1rem;
}

.settings-field small {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.btn-secondary {
  display: block;
  width: 100%;
  margin-top: 0.65rem;
  padding: 0.75rem 1rem;
  border: 2px solid var(--bg-input);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-secondary:active {
  border-color: var(--accent);
  color: var(--accent);
}

.setup-start-bar {
  margin: 1.25rem 0 0;
  padding: 1rem;
  background: var(--bg-panel);
  border-radius: var(--radius);
  border: 2px solid var(--accent);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.setup-start-bar .btn-primary {
  width: 100%;
  max-width: 360px;
}

.setup-start-bar .workout-preview {
  text-align: center;
}

.setup-footer {
  margin-top: 1.5rem;
  display: flex;
  justify-content: center;
}

.btn-primary {
  padding: 1rem 2.5rem;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-on);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  min-width: 220px;
}

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

/* ── Timer (landscape-first) ── */

#timer-screen {
  background: var(--bg);
  height: 100%;
  max-height: 100dvh;
}

.timer-toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.75rem;
  padding: 0.35rem 1rem 0;
  flex-shrink: 0;
}

.timer-layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, calc(var(--clock-col) * 1%)) minmax(0, 1fr);
  gap: 0;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
  padding: 0.25rem 1rem 0.5rem;
}

.timer-clock-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  min-height: 0;
  overflow: hidden;
}

.block-badge {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.phase-label {
  font-size: 1.4rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-bottom: 1rem;
  color: var(--accent);
}

.phase-label.rest {
  color: var(--rest);
}

.clock-wrapper {
  position: relative;
  width: min(100%, 32dvh, 420px);
  height: min(100%, 32dvh, 420px);
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 1;
  flex-shrink: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.progress-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.progress-ring .segment {
  fill: var(--segment-inactive);
  transition: fill 0.12s ease;
}

.progress-ring .segment.active {
  fill: var(--accent);
  filter: drop-shadow(0 0 4px var(--accent-glow));
}

.progress-ring.rest .segment.active {
  fill: var(--rest);
  filter: drop-shadow(0 0 4px var(--rest-glow));
}

.clock-display {
  position: relative;
  z-index: 1;
  font-family: var(--font-mono);
  font-size: clamp(3.5rem, 14vh, 8.5rem);
  line-height: 1;
  letter-spacing: 0.02em;
  display: flex;
  align-items: baseline;
}

.clock-min {
  color: var(--text-muted);
}

.clock-sep {
  color: var(--text-muted);
  margin: 0 0.05em;
}

.clock-sec {
  color: var(--accent);
  text-shadow: 0 0 20px var(--accent-glow), 0 0 40px var(--accent-glow);
}

.clock-display.rest .clock-sec {
  color: var(--rest);
  text-shadow: 0 0 20px var(--rest-glow), 0 0 40px var(--rest-glow);
}

.clock-display.count-up .clock-min,
.clock-display.count-up .clock-sec {
  color: var(--accent);
  text-shadow: 0 0 20px var(--accent-glow), 0 0 40px var(--accent-glow);
}

.round-info {
  margin-top: 1.25rem;
  font-size: 1.1rem;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.amrap-rounds {
  margin-top: 1rem;
  text-align: center;
}

.round-counter {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 0.35rem;
}

.round-counter span {
  font-family: var(--font-mono);
  font-size: clamp(2rem, 5vw, 3.5rem);
  color: var(--accent);
  min-width: 2ch;
}

.btn-round {
  width: 52px;
  height: 52px;
  border: 2px solid var(--bg-input);
  border-radius: 50%;
  background: var(--bg-panel);
  color: var(--accent);
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
}

.timer-exercise-area {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  border-left: 1px solid var(--bg-input);
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.exercise-now,
.exercise-next,
.exercise-list-panel {
  padding: 1.25rem 1.5rem;
  background: var(--bg-panel);
  border-radius: var(--radius);
  flex: 1;
  min-height: 0;
}

.exercise-now {
  border-left: 4px solid var(--accent);
}

.exercise-next {
  border-left: 4px solid var(--segment-inactive);
  opacity: 0.85;
}

.label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.exercise-now h2 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 800;
  line-height: 1.1;
  word-break: break-word;
}

.exercise-next h3 {
  font-size: clamp(1.4rem, 3.5vw, 2.2rem);
  font-weight: 600;
  line-height: 1.2;
  word-break: break-word;
}

.reps {
  margin-top: 0.5rem;
  font-family: var(--font-mono);
  font-size: clamp(1.2rem, 3vw, 2rem);
  color: var(--accent);
}

.exercise-list-panel ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  max-height: none;
  overflow-y: visible;
}

.exercise-list-panel li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  background: var(--bg-input);
  font-size: clamp(1rem, 2.2vw, 1.35rem);
}

.exercise-list-panel li.current {
  background: rgba(0, 229, 255, 0.12);
  border: 1px solid rgba(0, 229, 255, 0.35);
}

.exercise-list-panel li .item-reps {
  font-family: var(--font-mono);
  color: var(--accent);
  white-space: nowrap;
}

.hidden {
  display: none !important;
}

.timer-controls {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.65rem;
  padding: 0.6rem 1rem;
  padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
  border-top: 1px solid var(--bg-input);
  flex-shrink: 0;
  background: var(--bg);
}

.btn-control {
  padding: 0.85rem 1.75rem;
  border: 2px solid var(--bg-input);
  border-radius: var(--radius);
  background: var(--bg-panel);
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  min-width: 120px;
}

.btn-skip-clock {
  margin-top: 0.65rem;
  min-width: 140px;
}

.timer-controls .btn-control {
  flex: 1;
  max-width: 180px;
}

.btn-control.btn-danger {
  border-color: rgba(255, 92, 92, 0.4);
  color: var(--danger);
}

/* ── Finished ── */

#finished-screen {
  align-items: center;
  justify-content: center;
}

.finished-content {
  text-align: center;
  padding: 2rem;
}

.finished-content h1 {
  font-size: 2.5rem;
  margin-bottom: 1rem;
  color: var(--accent);
}

.finished-content p {
  color: var(--text-muted);
  font-size: 1.2rem;
  margin-bottom: 2rem;
}

/* ── Prep overlay ── */

.prep-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--overlay-bg);
}

.pairing-toolbar {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 5;
}

.prep-overlay span {
  font-family: var(--font-mono);
  font-size: clamp(8rem, 30vw, 16rem);
  color: var(--accent);
  text-shadow: 0 0 40px var(--accent-glow);
  animation: prep-pulse 0.8s ease infinite;
}

@keyframes prep-pulse {
  50% { transform: scale(1.06); opacity: 0.85; }
}

.clock-display.flash #clock-sec,
.clock-display.flash .clock-min {
  animation: sec-flash 0.4s ease 3;
}

@keyframes sec-flash {
  50% { color: #fff; text-shadow: 0 0 30px #fff; }
}

/* ── Landscape iPad optimization ── */

@media (orientation: landscape) and (min-width: 768px) {
  .setup-flow {
    padding-left: 2rem;
    padding-right: 2rem;
  }

  .timer-layout {
    padding: 0.25rem 1.5rem 0.5rem;
  }

  .clock-wrapper {
    width: min(100%, 42dvh, 520px);
    height: min(100%, 42dvh, 520px);
  }

  .timer-exercise-area {
    padding: 1rem 2rem;
  }
}

/* ── Pairing / Remote ── */

.pairing-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
}

.pairing-code {
  font-family: var(--font-mono);
  font-size: clamp(3.5rem, 12vw, 6rem);
  letter-spacing: 0.25em;
  color: var(--accent);
  text-shadow: 0 0 30px var(--accent-glow);
  margin: 1.5rem 0 1rem;
}

.pairing-status,
.pairing-hint {
  color: var(--text-muted);
  max-width: 420px;
}

.pairing-hint {
  margin-top: 1rem;
  font-size: 0.9rem;
}

.remote-badge {
  font-size: 0.8rem;
  color: var(--text-muted);
  opacity: 0;
  transition: opacity 0.2s;
}

.remote-badge.visible {
  opacity: 1;
  color: var(--accent);
}

.remote-connect {
  padding: 1rem;
  margin-bottom: 1rem;
  background: var(--bg-panel);
  border-radius: var(--radius);
}

.remote-connect label {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
}

.connect-row {
  display: flex;
  gap: 0.5rem;
}

.connect-row input {
  flex: 1;
  padding: 0.75rem;
  border: 1px solid var(--bg-input);
  border-radius: 8px;
  background: var(--bg-input);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 1.25rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.btn-connect {
  min-width: auto;
  padding: 0.75rem 1.25rem;
  font-size: 0.95rem;
}

.remote-status {
  margin-top: 0.65rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.remote-status.connected {
  color: var(--accent);
}

.remote-controls {
  margin-top: 1.25rem;
  padding: 1rem 0 0;
  border-top: 1px solid var(--bg-input);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.remote-live {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.remote-live .btn-control {
  flex: 1;
  min-width: 90px;
}

.remote-live-status {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.95rem;
  padding: 0.5rem;
}

/* ── About page ── */

.about-page {
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.about-content {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
  padding-bottom: max(3rem, env(safe-area-inset-bottom));
  line-height: 1.65;
  width: 100%;
}

.about-content h1 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.about-lead {
  font-size: 1.1rem;
  color: var(--text-muted);
}

.about-author {
  margin-top: 0.75rem;
}

.about-content section {
  margin-top: 2rem;
}

.about-content h2 {
  font-size: 1.35rem;
  margin-bottom: 0.75rem;
  color: var(--accent);
}

.about-content h3 {
  font-size: 1.05rem;
  margin: 1rem 0 0.5rem;
}

.about-cards {
  display: grid;
  gap: 1rem;
}

.about-cards article {
  padding: 1rem;
  background: var(--bg-panel);
  border-radius: var(--radius);
}

.about-steps {
  padding-left: 1.25rem;
}

.about-steps li {
  margin-bottom: 0.65rem;
}

.about-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.about-table th,
.about-table td {
  border: 1px solid var(--bg-input);
  padding: 0.6rem 0.75rem;
  text-align: left;
}

.about-table th {
  background: var(--bg-panel);
}

.social-links {
  list-style: none;
}

.social-links a {
  color: var(--accent);
  text-decoration: none;
}

.social-links a:hover {
  text-decoration: underline;
}

.about-footer {
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--bg-input);
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ── Bar calculator ── */

.bar-calc-page .calc-panel {
  margin-top: 1.5rem;
  padding: 1rem;
  background: var(--bg-panel);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.bar-calc-page .calc-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.bar-calc-page .calc-field-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.bar-calc-page .calc-panel h2 {
  font-size: 1.2rem;
  margin-bottom: 0.25rem;
  color: var(--accent);
}

.bar-calc-page input,
.bar-calc-page select {
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--bg-input);
  border-radius: 8px;
  background: var(--bg-input);
  color: var(--text);
  font-size: 1rem;
}

.calc-bar-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.calc-bar-presets input {
  flex: 1;
  min-width: 100px;
}

.calc-result-card {
  padding: 1rem;
  border-radius: 8px;
  background: var(--bg-input);
  border-left: 4px solid var(--accent);
}

.calc-result-main {
  font-size: 1.2rem;
  margin-bottom: 0.35rem;
}

.calc-result-plates {
  font-family: var(--font-mono);
  color: var(--accent);
  font-size: 1.05rem;
}

.calc-hint {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.calc-warning {
  margin-top: 0.5rem;
  color: var(--rest);
  font-size: 0.9rem;
}

.calc-table-wrap {
  overflow-x: auto;
  margin-top: 0.5rem;
}

.calc-table {
  width: 100%;
  min-width: 480px;
}

.calc-table th,
.calc-table td {
  vertical-align: middle;
}

.calc-table th {
  white-space: nowrap;
  font-size: 0.85rem;
}

.calc-table td:last-child {
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.calc-table-empty td {
  text-align: center;
  color: var(--text-muted);
  padding: 1.25rem;
  font-style: italic;
}

@media (max-width: 640px) {
  .exercise-row--weights {
    grid-template-columns: 1fr 1fr;
  }

  .exercise-row--weights .btn-remove {
    grid-column: 2;
    justify-self: end;
  }
}

@media (orientation: portrait) {
  .timer-layout {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1.1fr) minmax(0, 0.9fr);
    overflow: hidden;
  }

  .timer-exercise-area {
    border-left: none;
    border-top: 1px solid var(--bg-input);
    justify-content: flex-start;
  }

  .clock-wrapper {
    width: min(72vw, 28dvh, 320px);
    height: min(72vw, 28dvh, 320px);
  }

  .btn-control {
    min-width: 100px;
    padding: 0.75rem 1.25rem;
  }
}

@media (max-height: 720px) and (orientation: landscape) {
  .clock-wrapper {
    width: min(100%, 26dvh, 320px);
    height: min(100%, 26dvh, 320px);
  }

  .clock-display {
    font-size: clamp(2.5rem, 11dvh, 6rem);
  }

  .phase-label {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
  }

  .exercise-now h2 {
    font-size: clamp(1.5rem, 4dvh, 2.5rem);
  }

  .timer-exercise-area {
    gap: 0.65rem;
    padding: 0.5rem 1rem;
  }
}
