:root {
  --bg: #14171c;
  --surface: #1e222a;
  --text: #f2f4f7;
  --muted: #9aa3b2;
  --accent: #ff7a45;
  --accent-dim: #7a3a20;
  --danger: #e0554f;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

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

.screen {
  display: none;
  flex: 1;
  flex-direction: column;
  align-items: center;
  padding: max(24px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
  text-align: center;
}

.screen.active {
  display: flex;
}

h1 {
  font-size: 1.6rem;
  margin: 0 0 20px;
}

h2 {
  font-size: 1.7rem;
  margin: 16px 0 4px;
  text-transform: capitalize;
}

/* Picker */
.workout-list {
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.workout-card {
  background: var(--surface);
  border-radius: 14px;
  padding: 18px 20px;
  text-align: left;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  border: 1px solid transparent;
}

.workout-card:active {
  border-color: var(--accent);
}

.workout-card .wc-name {
  font-size: 1.15rem;
  font-weight: 600;
}

.workout-card .wc-meta {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 4px;
}

.workout-card .wc-play {
  font-size: 1.6rem;
  color: var(--accent);
}

/* Overview screen */
.overview-screen {
  justify-content: flex-start;
  position: relative;
}

.btn-back {
  align-self: flex-start;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1rem;
  padding: 4px 0;
  margin-bottom: 12px;
  cursor: pointer;
}

.btn-back:active {
  color: var(--text);
}

.overview-list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
}

.overview-row {
  background: var(--surface);
  border-radius: 14px;
  padding: 10px 14px;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 14px;
}

.overview-row img {
  width: 64px;
  height: 64px;
  flex-shrink: 0;
  object-fit: contain;
  background: #fff;
  border-radius: 10px;
}

.overview-row .ov-info {
  flex: 1;
  min-width: 0;
}

.overview-row .ov-name {
  font-weight: 600;
  font-size: 1rem;
  text-transform: capitalize;
}

.overview-row .ov-meta {
  color: var(--muted);
  font-size: 0.88rem;
  margin-top: 3px;
}

.overview-screen .btn {
  margin-top: auto;
}

.ov-last {
  color: var(--accent);
  font-size: 0.82rem;
  margin-top: 3px;
}

/* Done / log screen */
.log-hint {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 14px;
  text-align: left;
  width: 100%;
  max-width: 480px;
}

.log-inputs {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.log-input {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  border: 1px solid #333a45;
  border-radius: 8px;
  color: var(--text);
  padding: 8px 10px;
  font-size: 0.9rem;
  font-family: inherit;
}

.log-input:focus {
  outline: none;
  border-color: var(--accent);
}

#screen-done {
  justify-content: flex-start;
}

#screen-done .btn:first-of-type {
  margin-top: auto;
}

/* History screen */
.history-empty {
  color: var(--muted);
  margin-top: 40px;
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
}

.history-session {
  background: var(--surface);
  border-radius: 14px;
  padding: 14px 16px;
  text-align: left;
}

.hs-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
  gap: 10px;
}

.hs-date {
  color: var(--accent);
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
}

.hs-name {
  font-weight: 600;
}

.hs-exercises {
  list-style: none;
  margin: 0;
  padding: 0;
  color: var(--muted);
  font-size: 0.88rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hs-exercises .hs-ex-name {
  color: var(--text);
  text-transform: capitalize;
}

/* Exercise screen */
.progress {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 8px;
}

.exercise-image {
  width: 100%;
  max-width: 420px;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  background: var(--surface);
  border-radius: 16px;
}

.weight-badge {
  display: none;
  margin-top: 10px;
  padding: 4px 14px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-weight: 600;
  font-size: 0.95rem;
}

.weight-badge.visible {
  display: inline-block;
}

.set-info {
  display: flex;
  gap: 14px;
  font-size: 1.2rem;
  color: var(--muted);
  margin: 10px 0 28px;
}

#exercise-set-count {
  color: var(--text);
  font-weight: 600;
}

/* Rest screen */
.timer {
  font-size: 5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin: 20px 0;
}

.rest-next {
  color: var(--muted);
  margin-bottom: 32px;
}

/* Buttons */
.btn {
  width: 100%;
  max-width: 420px;
  padding: 18px;
  border-radius: 14px;
  border: none;
  font-size: 1.15rem;
  font-weight: 600;
  margin-top: 12px;
  cursor: pointer;
}

.btn-primary {
  background: var(--accent);
  color: #1a1200;
}

.btn-primary:active {
  background: #e0673a;
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid #333a45;
}

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

#screen-exercise, #screen-rest {
  justify-content: flex-start;
}

#screen-exercise .btn:first-of-type,
#screen-rest .btn:first-of-type {
  margin-top: auto;
}
