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

:root {
  --bg: #0a0a0a;
  --surface: #141414;
  --surface2: #1c1c1c;
  --text: #f0ede6;
  --muted: #666;
  --dim: #2a2a2a;
  --cat-overkropp: #e8ff47;
  --cat-underkropp: #47c8ff;
  --cat-core: #ff8c47;
  --cat-kondition: #ff4f6d;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html,
body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "DM Sans", sans-serif;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

/* ── VIEWS ── */
.view {
  display: none;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}
.view.active {
  display: flex;
}

/* ── SCROLL AREA ── */
.scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.scroll::-webkit-scrollbar {
  display: none;
}

/* ── TOPBAR ── */
.topbar {
  padding: 20px 20px 12px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-shrink: 0;
}
.topbar-back {
  width: 40px;
  height: 40px;
  background: var(--surface);
  border-radius: 12px;
  border: none;
  color: var(--text);
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.topbar-title {
  font-family: "Bebas Neue", sans-serif;
  font-size: 28px;
  letter-spacing: 1px;
  line-height: 1;
}

/* ── HOME ── */
.home-header {
  padding: 32px 24px 20px;
  flex-shrink: 0;
}
.home-eyebrow {
  font-size: 11px;
  letter-spacing: 4px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.home-title {
  /* Barlow Condensed: smalare än DM Sans, bra för rubrik utan att ta hela bredden på mobil */
  font-family: "Barlow Condensed", "DM Sans", sans-serif;
  font-size: clamp(1.75rem, 6.2vw, 2.5rem);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: 0.01em;
}
.home-title span {
  display: block;
}

.cat-grid {
  padding: 8px 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cat-card {
  background: var(--surface);
  border-radius: 20px;
  padding: 22px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  border: 1px solid transparent;
  transition:
    transform 0.15s,
    border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.cat-card:active {
  transform: scale(0.97);
}

.cat-icon {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  flex-shrink: 0;
}
.cat-info {
  flex: 1;
}
.cat-name {
  font-family: "Bebas Neue", sans-serif;
  font-size: 24px;
  letter-spacing: 0.5px;
  line-height: 1;
  margin-bottom: 4px;
}
.cat-count {
  font-size: 13px;
  color: var(--muted);
}
.cat-arrow {
  color: var(--muted);
  font-size: 20px;
}

/* ── CATEGORY VIEW ── */
.cat-hero {
  padding: 8px 20px 24px;
  flex-shrink: 0;
}
.cat-hero-icon {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  margin-bottom: 14px;
}
.cat-hero-name {
  font-family: "Bebas Neue", sans-serif;
  font-size: 44px;
  letter-spacing: 1px;
  line-height: 1;
}
.cat-hero-sub {
  font-size: 14px;
  color: var(--muted);
  margin-top: 4px;
}

.ex-list {
  padding: 0 16px 32px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ex-row {
  background: var(--surface);
  border-radius: 16px;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: transform 0.15s;
}
.ex-row:active {
  transform: scale(0.97);
}

.ex-num {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--dim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}
.ex-info {
  flex: 1;
}
.ex-name {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 2px;
}
.ex-meta {
  font-size: 13px;
  color: var(--muted);
}
.ex-play {
  font-size: 26px;
  opacity: 0.7;
}

/* ── EXERCISE VIEW ── */
.ex-image-wrap {
  margin: 0 16px 20px;
  border-radius: 20px;
  overflow: hidden;
  height: 210px;
  background: var(--surface);
  flex-shrink: 0;
  position: relative;
}
.ex-image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.ex-image-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--dim);
}
.ex-image-placeholder .ph-icon {
  font-size: 40px;
}
.ex-image-placeholder .ph-text {
  font-size: 13px;
  color: var(--muted);
}
.ex-image-placeholder .ph-hint {
  font-size: 11px;
  color: var(--dim);
  max-width: 200px;
  text-align: center;
}

.ex-detail-body {
  padding: 0 20px;
}

.ex-detail-name {
  font-family: "Bebas Neue", sans-serif;
  font-size: 36px;
  letter-spacing: 0.5px;
  line-height: 1.05;
  margin-bottom: 8px;
}
.ex-detail-desc {
  font-size: 15px;
  color: #999;
  line-height: 1.6;
  margin-bottom: 16px;
}

.ex-instructions-wrap {
  margin-bottom: 20px;
}
.ex-instructions-kicker {
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.ex-detail-instructions {
  font-size: 14px;
  color: #aaa;
  line-height: 1.55;
  white-space: pre-line;
  user-select: text;
  -webkit-user-select: text;
}

.stats-row {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
}
.stat-box {
  flex: 1;
  background: var(--surface);
  border-radius: 14px;
  padding: 14px 10px;
  text-align: center;
}
.stat-val {
  font-family: "Bebas Neue", sans-serif;
  font-size: 28px;
  line-height: 1;
}
.stat-lbl {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 1.5px;
  font-weight: 600;
  margin-top: 2px;
}

/* ── AUDIO PLAYER ── */
.player {
  background: var(--surface);
  border-radius: 20px;
  padding: 20px;
  margin-bottom: 20px;
}
.player-label {
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 16px;
}
.player-filename {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.progress-track {
  height: 4px;
  background: var(--dim);
  border-radius: 2px;
  margin-bottom: 8px;
  cursor: pointer;
  position: relative;
}
.progress-fill {
  height: 100%;
  border-radius: 2px;
  width: 0%;
  transition: width 0.2s linear;
}
.time-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 18px;
}

.player-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}
.ctrl-btn {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--surface2);
  border: none;
  color: var(--muted);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.1s;
}
.ctrl-btn:active {
  transform: scale(0.93);
}

.play-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.1s;
  color: #000;
}
.play-btn:active {
  transform: scale(0.93);
}
.play-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.player-no-audio {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  padding: 12px 0;
  line-height: 1.6;
}
.player-no-audio code {
  font-size: 11px;
  background: var(--surface2);
  padding: 2px 6px;
  border-radius: 4px;
  color: #999;
}

/* ── NAV ROW ── */
.nav-row {
  display: flex;
  gap: 10px;
  padding: 0 20px 12px;
  flex-shrink: 0;
}
.nav-btn {
  flex: 1;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--dim);
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  font-family: "DM Sans", sans-serif;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: transform 0.12s;
}
.nav-btn:active {
  transform: scale(0.97);
}
.nav-btn:disabled {
  opacity: 0.25;
  pointer-events: none;
}
.nav-btn.next {
  background: var(--surface);
}

/* ── SLIDE ANIM ── */
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(24px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}
.view.active {
  animation: slideIn 0.22s ease;
}

/* ── SCROLL DETAIL ── */
#view-exercise .scroll {
  padding-top: 4px;
}
