:root {
  --bg: #0f1115;
  --bg-elevated: #171a21;
  --bg-card: #1c2029;
  --border: #2a2f3a;
  --text: #eef1f6;
  --text-dim: #9aa3b2;
  --accent: #22d3ee;
  --accent-dim: #0e7490;
  --good: #4ade80;
  --warn: #fbbf24;
  --danger: #f87171;
  --radius: 16px;
  --tabbar-h: 64px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior-y: none;
}

body {
  height: 100vh;
  height: 100dvh;
  padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* #app is a fixed-height frame (viewport minus tabbar) that scrolls its
   own content, so flex:1 children (the trainer video) have a real,
   bounded height to fill instead of growing to whatever the content wants. */
#app {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: calc(16px + var(--safe-top)) 16px 24px;
  max-width: 560px;
  margin: 0 auto;
  width: 100%;
}

h1, h2, h3 { margin: 0 0 4px; line-height: 1.25; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
p { margin: 0 0 8px; color: var(--text-dim); line-height: 1.5; }

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

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.header .back {
  font-size: 22px;
  padding: 6px 10px 6px 0;
  color: var(--text-dim);
}

.streak-card {
  display: flex;
  gap: 12px;
  background: linear-gradient(135deg, var(--accent-dim), var(--bg-card));
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
}
.streak-stat { flex: 1; text-align: center; }
.streak-stat .num { font-size: 26px; font-weight: 700; }
.streak-stat .label { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .04em; }

.section-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-dim);
  margin: 20px 0 10px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  display: block;
}
.card:active { background: var(--bg-elevated); }

.cat-card {
  display: flex;
  align-items: center;
  gap: 12px;
}
.cat-emoji { font-size: 28px; width: 40px; text-align: center; }
.cat-card .meta { flex: 1; min-width: 0; }
.cat-card .count { font-size: 13px; color: var(--text-dim); }
.chevron { color: var(--text-dim); font-size: 18px; }

.cat-empty { opacity: .5; }

.ex-list-item {
  display: flex;
  gap: 12px;
  align-items: center;
}
.thumb {
  width: 56px; height: 56px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--bg-elevated);
  flex-shrink: 0;
}
.ex-list-item .meta { flex: 1; min-width: 0; }
.ex-list-item .name { font-weight: 600; font-size: 15px; margin-bottom: 2px; }
.ex-list-item .popis {
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--accent);
  color: #04222a;
  font-weight: 700;
  font-size: 16px;
  border: none;
  border-radius: 999px;
  padding: 14px 22px;
  width: 100%;
  cursor: pointer;
}
.btn:active { opacity: .85; }
.btn.secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn.ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.btn.danger { background: var(--danger); color: #2a0a0a; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

/* Big video/image preview on the exercise detail page */
.ex-preview {
  width: 100%;
  aspect-ratio: 3/4;
  border-radius: var(--radius);
  background: var(--bg-elevated);
  margin-bottom: 16px;
  overflow: hidden;
}
.ex-preview .media-el {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.quote {
  border-left: 3px solid var(--accent);
  padding: 8px 12px;
  margin: 12px 0;
  background: var(--bg-card);
  border-radius: 0 10px 10px 0;
  font-style: italic;
  color: var(--text);
  font-size: 14px;
}

.badge {
  display: inline-block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--bg-elevated);
  color: var(--text-dim);
  border: 1px solid var(--border);
  margin-bottom: 12px;
}

/* Training runner */
.trainer {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

/* Full-height layout for the trainer/test-timer screens: video eats all
   the free vertical space, info + controls stay their natural size at
   the bottom - "use the whole screen" instead of a small fixed-size clip. */
.trainer-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  min-height: 0;
}
.trainer-progress {
  width: 100%;
  height: 4px;
  background: var(--bg-elevated);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 14px;
  flex-shrink: 0;
}
.trainer-progress-bar {
  height: 100%;
  background: var(--accent);
  transition: width .3s;
}
#tr-media, #t-media {
  flex: 1;
  min-height: 0;
  width: 100%;
  border-radius: var(--radius);
  background: var(--bg-elevated);
  margin-bottom: 12px;
  overflow: hidden;
  position: relative;
}
#tr-media .media-el, #t-media .media-el {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* Ready countdown, overlaid transparently on top of the video */
.countdown-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 96px;
  font-weight: 800;
  color: #fff;
  background: rgba(0, 0, 0, 0.4);
  text-shadow: 0 2px 20px rgba(0, 0, 0, .6);
  pointer-events: none;
}
.countdown-overlay.pulse { animation: countdown-pulse .5s ease-out; }
@keyframes countdown-pulse {
  from { transform: scale(1.5); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.trainer-info { flex-shrink: 0; width: 100%; }
.trainer-phase {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-dim);
  margin-bottom: 2px;
}
.trainer-popis {
  font-size: 13px;
  color: var(--text-dim);
  margin: 0 0 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.trainer-phase.rest { color: var(--warn); }
.trainer-exname { font-size: 16px; font-weight: 700; margin-bottom: 10px; }
.trainer-time {
  font-size: 44px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  margin-bottom: 14px;
}
.trainer-time.rest { color: var(--warn); }
.trainer-controls { width: 100%; display: flex; flex-direction: column; gap: 10px; margin-top: 8px; flex-shrink: 0; }

.empty-state {
  text-align: center;
  padding: 40px 16px;
  color: var(--text-dim);
}
.empty-state .icon { font-size: 40px; margin-bottom: 8px; }

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.history-item .date { font-weight: 600; font-size: 14px; }
.history-item .cats { font-size: 12px; color: var(--text-dim); }
.history-item .dur { font-size: 13px; color: var(--accent); }

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.settings-row:last-child { border-bottom: none; }
.stepper {
  display: flex;
  align-items: center;
  gap: 14px;
}
.stepper button {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-size: 18px;
  line-height: 1;
}
.stepper .val { min-width: 48px; text-align: center; font-weight: 700; }

.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  z-index: 10;
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 11px;
  color: var(--text-dim);
}
.tab.active { color: var(--accent); }
.tab-icon { font-size: 20px; }

.toast {
  position: fixed;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 12px);
  left: 16px; right: 16px;
  background: var(--good);
  color: #06280f;
  font-weight: 700;
  text-align: center;
  padding: 12px;
  border-radius: 12px;
  z-index: 20;
  animation: toast-in .2s ease-out;
}
@keyframes toast-in {
  from { transform: translateY(8px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
