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

:root {
  --bg: #0e0e0e;
  --bg-alt: #1a1a1a;
  --text: #e6e6e6;
  --text-dim: #b0b0b0;
  --primary: #ff8c42;
  --primary-dim: #d17334;
  --accent: #ffb070;
  --border: #6e6e6e;
  --border-dim: #2a2a2a;
  --border-strong: #ff8c42;
  --danger: #ff4444;
  --touch: 48px;
  --radius: 0px;
}

html, body {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Courier New", Courier, monospace;
  font-size: 16px;
  line-height: 1.5;
}

a { color: var(--text-dim); text-decoration: none; }
a:hover { color: var(--primary); }

/* ---- Container matches rest of site ---- */
.container {
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
  background: var(--bg-alt);
  border: 1px solid var(--border-dim);
  min-height: 100vh;
}

/* ---- Header ---- */
.lift-header {
  text-align: center;
  padding: 8px;
  border-bottom: 1px solid var(--border-dim);
}

.lift-header h1 {
  margin: 0;
  color: var(--primary);
  letter-spacing: 2px;
  font-size: 1.5rem;
}

.lift-header .subtitle {
  color: var(--text-dim);
  font-size: 13px;
}

/* ---- Nav ---- */
.lift-nav {
  text-align: center;
  background: var(--bg);
  padding: 6px;
  border-bottom: 1px solid var(--border-dim);
  font-size: 14px;
}

.lift-nav a { color: var(--text-dim); }
.lift-nav a:hover { color: var(--primary); }
.lift-nav .active { color: var(--primary); }

/* ---- Page body ---- */
.lift-body {
  padding: 16px;
}

/* ---- Section heading ---- */
.section-head {
  color: var(--text-dim);
  font-size: 11px;
  letter-spacing: 0.12em;
  border-bottom: 1px solid var(--border-dim);
  padding-bottom: 4px;
  margin-bottom: 10px;
  margin-top: 0;
}

/* ---- Boxes ---- */
.box {
  border: none;
  border-bottom: 1px solid #1e1e1e;
  padding: 14px 16px;
  margin-bottom: 0;
  background: transparent;
}

.box h3 {
  margin-top: 0;
  color: var(--text-dim);
  font-size: 11px;
  letter-spacing: 0.12em;
  border-bottom: 1px solid var(--border-dim);
  padding-bottom: 4px;
  margin-bottom: 12px;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--touch);
  padding: 0 16px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .08em;
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
  width: 100%;
  text-align: center;
}

.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn:active { background: var(--bg); }
.btn:disabled { opacity: .4; cursor: not-allowed; }

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #0e0e0e;
}

.btn-primary:hover {
  background: var(--primary-dim);
  border-color: var(--primary-dim);
  color: #0e0e0e;
}

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

.btn-danger:hover { background: var(--danger); color: #0e0e0e; }

.btn-sm {
  min-height: 30px;
  font-size: 11px;
  padding: 0 10px;
  width: auto;
}

.btn-row {
  display: flex;
  gap: 8px;
}

/* ---- Form fields ---- */
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.field label {
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.field input, .field select {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  height: var(--touch);
  padding: 0 10px;
  width: 100%;
  outline: none;
  transition: border-color .15s;
}

.field input:focus, .field select:focus { border-color: var(--primary); }

/* ---- Exercise list ---- */
.ex-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-dim);
}

.ex-item:last-child { border-bottom: none; }

.ex-check {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

.ex-info { flex: 1; min-width: 0; }
.ex-name { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ex-meta { font-size: 11px; color: var(--text-dim); }

/* ---- Stepper ---- */
.stepper {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
  width: 100%;
}

.stepper-btn {
  width: 52px;
  height: 52px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 1.6rem;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stepper-btn:hover { border-color: var(--primary); color: var(--primary); }
.stepper-btn:active { background: var(--border-dim); }

.stepper .val-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.stepper .val {
  font-size: 2.8rem;
  font-weight: 900;
  color: var(--primary);
  text-align: center;
  line-height: 1;
  width: 100%;
}

.stepper .unit {
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
  margin-top: 2px;
}

/* ---- Progress dots ---- */
.dots {
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
}

.dot {
  width: 10px;
  height: 10px;
  border: 1px solid var(--border);
  background: transparent;
  transition: background .2s, border-color .2s;
}

.dot.done { background: var(--primary); border-color: var(--primary); }
.dot.current { background: var(--primary); border-color: var(--primary); box-shadow: 0 0 0 2px rgba(255,140,66,.3); }

/* ---- Big display number ---- */
.big-num {
  font-size: 4.5rem;
  font-weight: 900;
  line-height: 1;
  text-align: center;
  color: var(--primary);
}

.big-label {
  text-align: center;
  color: var(--text-dim);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-top: 4px;
}

/* ---- Sheet (slide-up panel) ---- */
.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  z-index: 10;
  display: none;
}

.sheet-overlay.open { display: block; }

.sheet {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%) translateY(100%);
  width: 100%;
  max-width: 760px;
  background: var(--bg-alt);
  border-top: 2px solid var(--primary);
  padding: 16px 16px 32px;
  z-index: 11;
  transition: transform .25s ease;
}

.sheet.open { transform: translateX(-50%) translateY(0); }

.sheet h3 {
  color: var(--primary);
  font-size: 11px;
  letter-spacing: 0.12em;
  border-bottom: 1px solid var(--border-dim);
  padding-bottom: 6px;
  margin-bottom: 14px;
}

/* ---- History ---- */
.workout-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-dim);
  cursor: pointer;
}

.workout-row:last-child { border-bottom: none; }
.workout-row:hover .workout-title { color: var(--primary); }

.workout-title { font-weight: 700; font-size: 14px; }
.workout-meta { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.workout-chevron { color: var(--text-dim); font-size: 11px; }

.workout-detail {
  display: none;
  padding: 8px 0 10px;
  border-bottom: 1px solid var(--border-dim);
  font-size: 13px;
}

.workout-detail.open { display: block; }

/* ---- Ko-fi panel ---- */
.kofi-panel {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease;
  border-top: 1px solid var(--border-dim);
}

.kofi-panel.open {
  max-height: 760px;
}

/* ---- Footer ---- */
.lift-footer {
  text-align: center;
  font-size: 12px;
  padding: 6px;
  border-top: 1px solid var(--border-dim);
  color: var(--text-dim);
}

/* ---- Utils ---- */
.text-center { text-align: center; }
.text-dim { color: var(--text-dim); }
.text-primary { color: var(--primary); }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.hidden { display: none !important; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

.err-msg {
  color: var(--danger);
  font-size: 12px;
  margin-top: 6px;
  min-height: 1em;
}

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  animation: spin .6s linear infinite;
  vertical-align: middle;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Bottom bar (start button + footer, sticky as one unit) ---- */
.bottom-bar {
  position: sticky;
  bottom: 0;
  background: var(--bg-alt);
}

.bottom-bar-start {
  padding: 10px;
  border-top: 1px solid var(--border-dim);
}

/* ---- Routine bar ---- */
.routine-bar {
  display: flex;
  align-items: center;
  border: 1px solid var(--border-dim);
  margin-bottom: 10px;
  overflow: hidden;
}

.routine-deselect {
  flex-shrink: 0;
  background: transparent;
  border: none;
  border-right: 1px solid var(--border-dim);
  color: var(--text-dim);
  font-family: inherit;
  font-size: 11px;
  padding: 0 10px;
  height: 36px;
  cursor: pointer;
  white-space: nowrap;
}

.routine-deselect:hover { color: var(--primary); }

.routine-bar-scroll {
  flex: 1;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 6px 8px;
  scrollbar-width: none;
}

.routine-bar-scroll::-webkit-scrollbar { display: none; }

.routine-btn {
  flex-shrink: 0;
  background: transparent;
  border: 1px solid var(--border-dim);
  color: var(--text-dim);
  font-family: inherit;
  font-size: 11px;
  padding: 4px 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .15s, color .15s;
}

.routine-btn:hover { border-color: var(--primary); color: var(--primary); }
.routine-btn.active { border-color: var(--primary); color: var(--primary); }

.routine-add {
  flex-shrink: 0;
  background: transparent;
  border: none;
  border-left: 1px solid var(--border-dim);
  color: var(--text-dim);
  font-family: inherit;
  font-size: 18px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.routine-add:hover { color: var(--primary); }

/* ---- Group checks ---- */
.group-checks {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}

.group-check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
}

.group-check-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  flex-shrink: 0;
  cursor: pointer;
}

/* ---- Toggle group ---- */
.toggle-group {
  display: flex;
}

.toggle-opt {
  flex: 1;
  min-height: 34px;
  background: transparent;
  border: 1px solid var(--border);
  border-right: none;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  padding: 0 8px;
}

.toggle-opt:last-child { border-right: 1px solid var(--border); }
.toggle-opt.active { background: var(--primary); border-color: var(--primary); color: #0e0e0e; }
.toggle-opt:hover:not(.active) { border-color: var(--primary); color: var(--primary); }

/* ---- Setting row ---- */
.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-dim);
  gap: 12px;
}

.setting-row:last-child { border-bottom: none; }
.setting-label { font-size: 13px; font-weight: 700; }
.setting-sub { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

/* ---- Rest timer ---- */
.rest-timer {
  background: var(--bg);
  border: 1px solid var(--border-dim);
  padding: 12px 14px;
  margin-top: 12px;
}

.rest-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.rest-label {
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

#rest-cd {
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--primary);
}

.rest-track {
  height: 4px;
  background: var(--border-dim);
  margin-bottom: 10px;
}

.rest-fill {
  height: 100%;
  background: var(--primary);
  transition: width 1s linear;
}

/* ---- Mobile ---- */
@media (max-width: 640px) {
  body { font-size: 14px; }
  .container { border-left: none; border-right: none; }
  .lift-body { padding: 14px; }
  .stepper .val { font-size: 2.4rem; }
  .stepper-btn { width: 48px; height: 48px; }
  .btn { font-size: 12px; }
}
