:root {
  color-scheme: dark;
  --bg: #111111;
  --panel: #1d1d1b;
  --panel-strong: #262521;
  --text: #f4f1e8;
  --muted: #b8b2a4;
  --accent: #9adf50;
  --accent-strong: #c6ff6f;
  --warn: #ffb257;
  --danger: #ff6b6b;
  --line: rgba(244, 241, 232, 0.16);
  --shadow: rgba(0, 0, 0, 0.32);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
}

body {
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
}

button {
  font: inherit;
}

.appShell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100vh;
  height: 100svh;
  background: var(--bg);
}

.topBar,
.controlBar {
  display: grid;
  align-items: center;
  gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) 14px 10px;
  background: rgba(17, 17, 17, 0.94);
  border-bottom: 1px solid var(--line);
  z-index: 2;
}

.topBar {
  grid-template-columns: 1fr auto auto;
}

.controlBar {
  grid-template-columns: 56px 74px 56px;
  justify-content: center;
  padding: 10px 14px max(10px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.counter,
.wakeStatus {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--panel);
  border-radius: 8px;
  padding: 0 12px;
  font-size: 14px;
  line-height: 1;
}

.wakeStatus[data-mode="active"] {
  color: #10140d;
  background: var(--accent);
  border-color: transparent;
}

.wakeStatus[data-mode="warning"] {
  color: #16100a;
  background: var(--warn);
  border-color: transparent;
}

.wakeStatus[data-mode="error"] {
  color: #180a0a;
  background: var(--danger);
  border-color: transparent;
}

.iconButton,
.primaryButton,
.stopButton {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--panel-strong);
  min-height: 44px;
  min-width: 44px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.iconButton {
  display: grid;
  place-items: center;
  width: 48px;
  height: 44px;
  font-weight: 800;
  line-height: 1;
}

.primaryButton {
  padding: 0 26px;
  min-height: 52px;
  color: #10140d;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 800;
}

.stopButton {
  width: 74px;
  height: 44px;
  color: #180a0a;
  background: var(--danger);
  border-color: transparent;
  font-weight: 800;
}

.iconButton:active,
.primaryButton:active,
.stopButton:active {
  transform: translateY(1px);
}

.stage {
  display: grid;
  min-height: 0;
  outline: none;
}

.startPanel {
  min-height: 100%;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 18px;
  padding: 28px;
}

.startPanel h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.08;
  font-weight: 850;
  letter-spacing: 0;
}

.slide {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
}

.mediaFrame {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  overflow: hidden;
  background: #0b0b0a;
  cursor: pointer;
}

.exerciseImage {
  display: block;
  width: 100%;
  height: 100%;
  max-height: 100%;
  object-fit: contain;
  padding: 8px;
  background: #0b0b0a;
}

.imageFallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  color: var(--muted);
  background:
    linear-gradient(135deg, rgba(154, 223, 80, 0.12), transparent 34%),
    linear-gradient(315deg, rgba(255, 178, 87, 0.12), transparent 36%),
    #111111;
  text-align: center;
  font-size: 18px;
  line-height: 1.35;
}

.captionPanel {
  --title-size: 22px;
  --text-size: 17px;
  display: grid;
  gap: 8px;
  padding: 16px 18px 18px;
  max-height: 34svh;
  overflow: hidden;
  background: var(--panel);
  border-top: 1px solid var(--line);
  box-shadow: 0 -12px 28px var(--shadow);
}

.captionPanel:empty,
.captionPanel[hidden] {
  display: none;
}

.captionPanel h2,
.captionPanel p {
  margin: 0;
}

.captionPanel h2 {
  font-size: var(--title-size, 22px);
  line-height: 1.16;
  font-weight: 800;
  letter-spacing: 0;
}

.captionPanel p {
  color: var(--muted);
  font-size: var(--text-size, 17px);
  line-height: 1.34;
}

@media (orientation: landscape) and (min-width: 720px) {
  .slide {
    grid-template-columns: minmax(0, 1fr) minmax(260px, 34vw);
    grid-template-rows: minmax(0, 1fr);
  }

  .captionPanel {
    align-content: end;
    max-height: none;
    border-top: 0;
    border-left: 1px solid var(--line);
    box-shadow: -12px 0 28px var(--shadow);
  }
}

@media (orientation: portrait) {
  .topBar {
    padding-top: max(8px, env(safe-area-inset-top));
    padding-bottom: 8px;
  }

  .controlBar {
    padding-top: 8px;
  }

  .captionPanel {
    --title-size: 21px;
    --text-size: 16px;
  }
}

@media (max-width: 360px) {
  .captionPanel {
    --title-size: 20px;
    --text-size: 16px;
  }

  .counter,
  .wakeStatus {
    padding: 0 9px;
    font-size: 13px;
  }
}
