:root {
  color-scheme: light;
  --bg: #f3f6f1;
  --paper: #fffdf7;
  --paper-soft: #eef4eb;
  --ink: #302924;
  --muted: #766a60;
  --line: rgba(74, 92, 78, .2);
  --clay: #d37f72;
  --clay-soft: #f1c5ba;
  --sage: #638b72;
  --sage-soft: #dfead9;
  --sky-soft: #dbeef0;
  --shadow: 0 22px 46px rgba(58, 75, 61, .12);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(255, 255, 255, .34) 1px, transparent 1px),
    linear-gradient(90deg, rgba(99, 139, 114, .05) 1px, transparent 1px),
    linear-gradient(180deg, #f7fbf6 0%, var(--bg) 48%, #f7f0eb 100%);
  background-size: 100% 28px, 30px 100%, auto;
  font-family: "Segoe UI", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  overflow-x: hidden;
}

button,
input {
  min-width: 0;
  font: inherit;
}

button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 242, .88);
  color: var(--ink);
  font-weight: 760;
  cursor: pointer;
  transition: transform .14s ease, border-color .14s ease, background .14s ease;
}

button:hover {
  transform: translateY(-1px);
  border-color: rgba(201, 121, 104, .72);
  background: #fffdf7;
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid rgba(114, 141, 120, .55);
  outline-offset: 3px;
}

.suite-topbar {
  position: static;
}

.suite-app-brand {
  text-transform: none;
}

.suite-app-mark {
  border-radius: 8px;
}

.shell {
  width: min(500px, calc(100vw - 28px));
  max-width: calc(100vw - 28px);
  margin: 0 auto;
  min-height: calc(100svh - 61px);
  display: grid;
  align-items: center;
  padding: clamp(8px, 1.4svh, 16px) 0;
}

.zen-card {
  display: grid;
  gap: clamp(7px, 1.15svh, 12px);
  padding: clamp(12px, 2.2svh, 20px);
  border: 0;
  border-radius: 8px;
  background: transparent;
  box-shadow: none;
  overflow: visible;
}

.zen-card > * {
  min-width: 0;
}

.cat-scene {
  position: relative;
  display: grid;
  place-items: center;
  min-height: clamp(150px, 24svh, 206px);
  padding-top: 0;
}

.pulse-ring {
  position: absolute;
  width: clamp(142px, 22svh, 184px);
  height: clamp(142px, 22svh, 184px);
  border: 1px solid rgba(114, 141, 120, .28);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(219, 238, 240, .46), rgba(223, 234, 217, .34) 64%, transparent 65%);
  transform: scale(.96);
  transition: transform 120ms ease, opacity 120ms ease;
}

.cat-dancer {
  --dance-dir: 1;
  --shift-x: 0px;
  --lift: 0px;
  --tilt: 0deg;
  --head-tilt: 0deg;
  --tail-swing: 14deg;
  --left-paw: -18deg;
  --right-paw: 18deg;
  --left-foot: -7deg;
  --right-foot: 7deg;
  position: relative;
  z-index: 2;
  width: min(100%, clamp(178px, 26svh, 238px));
  aspect-ratio: 1;
  transform: translate(var(--shift-x), var(--lift)) rotate(var(--tilt));
  transform-origin: 50% 84%;
  transition: transform var(--motion-ms, 560ms) cubic-bezier(.22, .74, .16, 1), filter 180ms ease;
  will-change: transform, filter;
}

.cat-dancer.motion-1 {
  --shift-x: -4px;
  --lift: -7px;
  --tilt: -1.4deg;
  --head-tilt: 7deg;
  --tail-swing: -26deg;
  --left-paw: -48deg;
  --right-paw: 12deg;
  --left-foot: -14deg;
  --right-foot: 9deg;
}

.cat-dancer.motion-2 {
  --shift-x: 4px;
  --lift: -4px;
  --tilt: 1.4deg;
  --head-tilt: -6deg;
  --tail-swing: 30deg;
  --left-paw: -10deg;
  --right-paw: 50deg;
  --left-foot: -4deg;
  --right-foot: 16deg;
}

.cat-dancer.motion-3 {
  --shift-x: 0px;
  --lift: -9px;
  --tilt: 0deg;
  --head-tilt: 0deg;
  --tail-swing: 12deg;
  --left-paw: -58deg;
  --right-paw: 58deg;
  --left-foot: -17deg;
  --right-foot: 17deg;
}

.cat-dancer.motion-4 {
  --shift-x: 3px;
  --lift: -3px;
  --tilt: 1.8deg;
  --head-tilt: 10deg;
  --tail-swing: 36deg;
  --left-paw: 8deg;
  --right-paw: 34deg;
  --left-foot: 12deg;
  --right-foot: -8deg;
}

body:not(.is-running) .cat-dancer {
  --shift-x: 0px;
  --lift: 0px;
  --tilt: 0deg;
  --head-tilt: 0deg;
  --tail-swing: 14deg;
  --left-paw: -18deg;
  --right-paw: 18deg;
  --left-foot: -7deg;
  --right-foot: 7deg;
}

body.is-beating .pulse-ring {
  opacity: .5;
  transform: scale(1.05);
}

.cat-shadow {
  position: absolute;
  left: 50%;
  bottom: 28px;
  width: 128px;
  height: 22px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: rgba(80, 60, 45, .13);
  filter: blur(2px);
  transition: transform var(--motion-ms, 560ms) cubic-bezier(.22, .74, .16, 1), width var(--motion-ms, 560ms) cubic-bezier(.22, .74, .16, 1), opacity 180ms ease;
}

body.is-running .cat-shadow {
  width: 112px;
  transform: translateX(calc(-50% + var(--shift-x))) scaleX(1.06);
}

.photo-cat {
  position: absolute;
  inset: -2px;
  z-index: 3;
  filter: drop-shadow(0 21px 26px rgba(66, 48, 36, .18));
  transform-origin: 50% 82%;
}

body.is-running .photo-cat {
  animation: photo-sway var(--phrase-ms, 2500ms) cubic-bezier(.42, 0, .18, 1) infinite;
}

.cat-frame {
  position: absolute;
  inset: 0;
  background-image: url("./assets/cat-dance-cutout.webp");
  background-repeat: no-repeat;
  background-size: 400% 200%;
  transform: scale(1.045);
  transition: opacity var(--fade-ms, 660ms) cubic-bezier(.28, .72, .16, 1);
  will-change: opacity;
}

.cat-frame.current {
  opacity: 1;
}

.cat-frame.previous {
  opacity: 0;
}

.cat-frame.previous.visible {
  opacity: .72;
}

.cat-frame.pose-1 { background-position: 0% 0%; }
.cat-frame.pose-2 { background-position: 33.333% 0%; }
.cat-frame.pose-3 { background-position: 66.667% 0%; }
.cat-frame.pose-4 { background-position: 100% 0%; }
.cat-frame.pose-5 { background-position: 0% 100%; }
.cat-frame.pose-6 { background-position: 33.333% 100%; }
.cat-frame.pose-7 { background-position: 66.667% 100%; }
.cat-frame.pose-8 { background-position: 100% 100%; }

@keyframes photo-sway {
  0%, 100% {
    transform: translate3d(-3px, 0, 0) rotate(-1.2deg);
  }

  25% {
    transform: translate3d(2px, -7px, 0) rotate(.9deg);
  }

  50% {
    transform: translate3d(4px, -3px, 0) rotate(1.3deg);
  }

  75% {
    transform: translate3d(-1px, -8px, 0) rotate(-.8deg);
  }
}

.tempo-readout {
  display: grid;
  justify-items: center;
  gap: 5px;
  text-align: center;
}

h1 {
  max-width: 100%;
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(34px, 8vw, 50px);
  font-weight: 500;
  line-height: .96;
  letter-spacing: 0;
  white-space: nowrap;
}

.state,
.credit,
.slider-row span,
.segmented legend {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 640;
  line-height: 1.3;
}

.tempo-number {
  display: grid;
  place-items: center;
  margin-top: clamp(3px, .8svh, 8px);
}

#bpmValue {
  font-size: clamp(74px, 14vw, 98px);
  font-weight: 780;
  line-height: .86;
  font-variant-numeric: tabular-nums;
}

.slider-row {
  display: grid;
  gap: 7px;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 40px;
  padding: 0;
  accent-color: var(--clay);
  background: transparent;
  cursor: ew-resize;
  touch-action: pan-y;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 10px;
  border-radius: 999px;
  background:
    linear-gradient(90deg, var(--sage) 0 var(--tempo-fill, 31%), rgba(255, 255, 255, .72) var(--tempo-fill, 31%) 100%),
    linear-gradient(90deg, var(--clay-soft), var(--sky-soft));
  box-shadow: inset 0 0 0 1px rgba(74, 92, 78, .12);
}

input[type="range"]::-webkit-slider-thumb {
  width: 30px;
  height: 30px;
  margin-top: -10px;
  border: 3px solid #fffdf7;
  border-radius: 50%;
  background: linear-gradient(145deg, #e28e81, var(--clay));
  box-shadow: 0 6px 16px rgba(68, 50, 42, .2);
  -webkit-appearance: none;
}

input[type="range"]::-moz-range-track {
  height: 10px;
  border-radius: 999px;
  background:
    linear-gradient(90deg, var(--sage) 0 var(--tempo-fill, 31%), rgba(255, 255, 255, .72) var(--tempo-fill, 31%) 100%),
    linear-gradient(90deg, var(--clay-soft), var(--sky-soft));
  box-shadow: inset 0 0 0 1px rgba(74, 92, 78, .12);
}

input[type="range"]::-moz-range-thumb {
  width: 26px;
  height: 26px;
  border: 3px solid #fffdf7;
  border-radius: 50%;
  background: linear-gradient(145deg, #e28e81, var(--clay));
  box-shadow: 0 6px 16px rgba(68, 50, 42, .2);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: center;
  gap: 8px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.segmented legend {
  grid-column: 1 / -1;
  padding: 0;
}

.segmented label {
  min-width: 0;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: grid;
  min-height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 242, .68);
  color: var(--muted);
  font-size: 15px;
  font-weight: 740;
}

.segmented input:checked + span {
  border-color: rgba(114, 141, 120, .66);
  background: rgba(223, 232, 217, .7);
  color: var(--ink);
}

.beat-dots {
  display: grid;
  grid-template-columns: repeat(var(--beats, 4), minmax(0, 1fr));
  gap: 8px;
  padding: 2px 0;
}

.beat-dot {
  height: 9px;
  border-radius: 999px;
  background: rgba(88, 70, 58, .18);
  transition: background 100ms ease, transform 100ms ease;
}

.beat-dot.active {
  background: var(--sage);
  transform: scaleY(1.8);
}

.actions {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, .75fr);
  gap: 8px;
}

.actions button {
  min-height: 44px;
  font-size: 16px;
}

.primary {
  min-height: 46px;
  border-color: var(--ink);
  background: var(--ink);
  color: #fff8ee;
  font-size: 17px;
}

.primary[aria-pressed="true"] {
  border-color: rgba(114, 141, 120, .9);
  background: var(--sage);
  color: #fffdf7;
}

.state {
  min-height: 16px;
  text-align: center;
}

.credit {
  text-align: center;
  font-size: 10px;
  color: rgba(118, 106, 96, .84);
  overflow-wrap: anywhere;
}

.credit a {
  color: inherit;
  text-decoration-color: rgba(118, 106, 96, .42);
  text-underline-offset: 3px;
}

@media (max-width: 520px) {
  .shell {
    width: min(calc(100vw - 20px), 390px);
    max-width: calc(100vw - 20px);
    padding: 16px 0 18px;
  }

  .zen-card {
    gap: 13px;
    padding: 16px 12px 18px;
    border: 1px solid var(--line);
    background:
      linear-gradient(160deg, rgba(255, 253, 247, .98), rgba(238, 244, 235, .92)),
      var(--paper);
    box-shadow: var(--shadow);
    overflow: hidden;
  }

  h1 {
    font-size: clamp(32px, 9.5vw, 40px);
  }

  .cat-scene {
    min-height: 214px;
  }

  .pulse-ring {
    width: 188px;
    height: 188px;
  }

  .cat-dancer {
    width: min(100%, 226px);
  }

  #bpmValue {
    font-size: clamp(78px, 20vw, 92px);
  }

  .slider-row span,
  .segmented legend,
  .state {
    font-size: 16px;
  }

  .segmented span {
    min-height: 50px;
    font-size: 18px;
  }

  .actions {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .actions button {
    min-height: 58px;
    font-size: 19px;
  }

  .primary {
    min-height: 62px;
    font-size: 21px;
  }
}
