:root {
  color-scheme: light;
  --posture-paper: #e66c49;
  --posture-ink: #221d22;
  --posture-muted: rgba(34, 29, 34, .5);
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  width: 100%;
  min-height: 100%;
  overflow: hidden;
  background: var(--posture-paper);
  color: var(--posture-ink);
}

body {
  min-height: 100dvh;
  background:
    radial-gradient(circle at 22% 18%, rgba(255, 238, 205, .18), transparent 0 24%, transparent 25%),
    radial-gradient(circle at 76% 70%, rgba(91, 34, 33, .1), transparent 0 30%, transparent 31%),
    repeating-linear-gradient(96deg, rgba(255,255,255,.035) 0 1px, transparent 1px 17px),
    var(--posture-paper);
}

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

.top-bar,
header.top-bar {
  --lab-line: rgba(34, 29, 34, .14);
  --lab-muted: rgba(34, 29, 34, .62);
  --lab-ink: rgba(34, 29, 34, .94);
  background: linear-gradient(to bottom, rgba(246, 144, 105, .72), rgba(230, 108, 73, .36)) !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.posture-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  cursor: ew-resize;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  outline: none;
}

.posture-stage:focus-visible {
  box-shadow: inset 0 0 0 2px rgba(34, 29, 34, .42);
}

.posture-stage::before {
  content: "";
  position: absolute;
  inset: 6% 8%;
  border: 1px solid rgba(34, 29, 34, .08);
  pointer-events: none;
}

#postureCanvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.posture-hint {
  position: absolute;
  left: 50%;
  bottom: clamp(54px, 8vh, 86px);
  margin: 0;
  transform: translateX(-50%);
  color: var(--posture-muted);
  font: 700 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .16em;
  text-transform: uppercase;
  transition: opacity 220ms ease, transform 220ms ease;
  pointer-events: none;
}

.posture-hint.is-used {
  opacity: 0;
  transform: translate(-50%, 5px);
}

.posture-meter {
  position: absolute;
  left: 50%;
  bottom: clamp(28px, 4vh, 42px);
  display: flex;
  gap: 12px;
  transform: translateX(-50%);
  pointer-events: none;
}

.posture-meter span {
  width: 5px;
  height: 5px;
  border: 1px solid rgba(34, 29, 34, .4);
  background: transparent;
  transition: background 160ms ease, transform 220ms cubic-bezier(.2,.9,.2,1.3);
}

.posture-meter span.is-active {
  background: var(--posture-ink);
  transform: rotate(45deg) scale(1.25);
}

.posture-footer {
  min-height: 38px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px calc(8px + env(safe-area-inset-bottom));
  color: rgba(34, 29, 34, .34);
  font: 700 9px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .2em;
  text-transform: uppercase;
}

.info-overlay[hidden] { display: none; }

.info-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(34, 29, 34, .64);
}

.info-modal {
  width: min(100%, 420px);
  padding: 24px;
  border: 1px solid rgba(34, 29, 34, .2) !important;
  border-radius: 0 !important;
  background: #f2d9c7 !important;
  color: var(--posture-ink);
  box-shadow: 8px 9px 0 rgba(34, 29, 34, .72);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.info-modal h2 {
  margin: 0 0 18px;
  font-size: 28px;
  text-transform: uppercase;
}

.info-modal p {
  margin: 0 0 14px;
  line-height: 1.55;
}

.info-close {
  margin-top: 8px;
  border: 1px solid currentColor;
  background: transparent;
  color: inherit;
  padding: 9px 13px;
  font: inherit;
  cursor: pointer;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 640px) {
  .top-bar,
  header.top-bar {
    min-height: 56px;
  }

  .posture-stage::before {
    inset: 5% 5%;
  }

  .posture-footer {
    padding-inline: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .posture-hint,
  .posture-meter span { transition: none; }
}
