:root {
  color-scheme: dark;

  --bg: #0A0A0B;
  --text: #F2F2F2;
  --text-secondary: #9A9A9E;
  --text-muted: #8A8A8E;
  --spec-text: #C7C7CA;
  --rule: #232325;

  /* The app's Instrument palette. */
  --panel: #0E0E0F;
  --label: #EDEAE4;
  --label-secondary: #A6A39D;
  --label-tertiary: #7A7772;
  --label-dim: #8E8A84;
  --label-faint: #3A3937;
  --amber: #FFB020;
  --amber-ink: #1A1206;
  --amber-plate: #2A2112;
  --amber-rim: #574624;
  --stop: #E5484D;
  --extend: #C9C5BE;

  --sans: "Stack Sans Text", system-ui, -apple-system, sans-serif;
  --serif: "Instrument Serif", Georgia, serif;

  /* Key motion, after Instrument.Motion: a quick firm press, a springy release. */
  --key-down: 140ms cubic-bezier(0.2, 0.9, 0.3, 1);
  --key-up: 380ms cubic-bezier(0.3, 1.7, 0.5, 1);

  /* Where the stage's pieces sit. The stage is scaled to fit its column. */
  --stage-w: 700;
  --stage-h: 640;
  --session-x: 215px;
  --session-y: 64px;
  --session-tilt: -5.51deg;
  --alert-x: 25px;
  --alert-y: 275px;
  --alert-tilt: 5.55deg;
}

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

html { background: var(--bg); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* The glow and tilted panels run past the edge; clip rather than hide so
   focusing a key can't scroll the page sideways. */
.page { overflow-x: clip; }

button { font: inherit; color: inherit; }

/* ---------- Layout ---------- */

.hero {
  position: relative;
  display: grid;
  grid-template-columns: 568px minmax(0, 1fr);
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    "nav    stage"
    "pitch  stage"
    "specs  stage";
  max-width: 1440px;
  min-height: clamp(780px, 100vh, 1000px);
  margin: 0 auto;
  padding: 56px 0 56px 112px;
}

.nav { grid-area: nav; display: flex; align-items: center; gap: 16px; }
.nav-mark { width: 56px; height: 56px; fill: var(--amber); flex-shrink: 0; }
.nav-name { font-size: 32px; line-height: 40px; font-weight: 500; letter-spacing: 0.02em; }

.pitch {
  grid-area: pitch;
  align-self: center;
  display: flex;
  flex-direction: column;
  padding: 48px 0;
}

h1 {
  margin: 0 0 36px;
  max-width: 560px;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 92px;
  line-height: 88px;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.lede {
  margin: 0;
  max-width: 440px;
  font-size: 16px;
  line-height: 25px;
  color: var(--text-secondary);
}
.lede + .lede { margin-top: 25px; }

.actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px 28px;
  margin-top: 40px;
}

.download {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 11px 20px 11px 17px;
  border-radius: 10px;
  background: linear-gradient(180deg, #FFC452 0%, #F0A21A 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), 0 0 0 1px #B87A0E, 0 10px 30px rgba(255, 176, 32, 0.25);
  color: var(--amber-ink);
  font-size: 16px;
  line-height: 20px;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-decoration: none;
  transition: transform var(--key-up), box-shadow 200ms ease-out, filter 200ms ease-out;
}
.download:hover {
  filter: brightness(1.04);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), 0 0 0 1px #B87A0E, 0 12px 36px rgba(255, 176, 32, 0.38);
}
.download:active { transform: scale(0.98) translateY(1px); transition: transform var(--key-down); }

.requires { font-size: 14px; line-height: 18px; color: var(--text-muted); }

.specs {
  grid-area: specs;
  display: flex;
  gap: 44px;
  width: 560px;
  padding-top: 22px;
  border-top: 1px solid var(--rule);
}
.spec h2 {
  margin: 0 0 8px;
  font-size: 11px;
  line-height: 14px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--amber);
}
.spec p { margin: 0; font-size: 14px; line-height: 21px; color: var(--spec-text); }

:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; }

/* ---------- Stage ---------- */

.stage-wrap {
  grid-area: stage;
  align-self: center;
  position: relative;
  padding: 0 0 40px 40px;
  /* Set from demo.js to fit the stage to the column. */
  --scale: 1;
}

.stage {
  position: relative;
  width: calc(var(--stage-w) * 1px);
  height: calc(var(--stage-h) * 1px);
  transform: scale(var(--scale));
  transform-origin: 0 0;
}
/* The scaled stage still takes its full size in layout; this trims it. */
.stage-wrap { height: calc(var(--stage-h) * var(--scale) * 1px + 40px); }

.glow {
  position: absolute;
  left: 70px;
  top: -110px;
  width: 820px;
  height: 820px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 176, 32, 0.22) 0%, rgba(255, 176, 32, 0.06) 38%, rgba(255, 176, 32, 0) 68%);
  pointer-events: none;
}

.panel {
  position: absolute;
  background: var(--panel);
  overflow: clip;
  transform-origin: 0 0;
}

/* ---------- Session panel ---------- */

.session {
  left: var(--session-x);
  top: var(--session-y);
  width: 400px;
  height: 560px;
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  box-shadow: 0 0 0 1px #2A2A2C, 0 40px 100px rgba(0, 0, 0, 0.6);
  rotate: var(--session-tilt);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  background: linear-gradient(180deg, #1A1A1C 0%, #121213 100%);
  border-bottom: 1px solid #050505;
  flex-shrink: 0;
}
.panel-mark { width: 40px; height: 40px; fill: var(--amber); }

.badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border: 1px solid var(--amber-rim);
  border-radius: 4px;
  background: var(--amber-plate);
}
.badge-text { display: block; height: 12px; overflow: hidden; }
.badge-label {
  display: block;
  font-size: 10px;
  line-height: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--amber);
}

.lamp {
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 4px rgba(255, 176, 32, 0.7);
  flex-shrink: 0;
}
.lamp.small { width: 4px; height: 4px; }
.session:not(.is-paused) .badge .lamp { animation: breathe-lamp 1.2s ease-in-out infinite alternate; }

@keyframes breathe-lamp { to { opacity: 0.4; } }

.goal {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  padding: 34px 30px 0;
  text-align: center;
}
.goal-prompt { font-size: 11px; line-height: 13px; letter-spacing: 0.04em; color: var(--label-tertiary); }
.goal-title { font-size: 19px; line-height: 25px; font-weight: 500; letter-spacing: 0.02em; color: var(--label); }

.dial {
  position: relative;
  width: 200px;
  height: 200px;
  margin: 30px auto 0;
  flex-shrink: 0;
}
.dial svg { position: absolute; inset: 0; }

.arc {
  stroke-dasharray: 0 584.34;
  transition: opacity 300ms ease-out;
  filter: drop-shadow(0 1px 1.5px rgba(0, 0, 0, 0.6));
}
.session.is-paused .arc { animation: breathe-arc 1.5s ease-in-out infinite alternate; }

@keyframes breathe-arc {
  from { opacity: 0.25; }
  to { opacity: 0.5; }
}

.readout {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.clock {
  display: flex;
  font-size: 42px;
  line-height: 48px;
  font-weight: 500;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--label);
  transition: color 400ms ease-out;
}
.clock .digit { display: inline-block; }
.session.is-paused .clock { color: var(--label-dim); }

.caption {
  font-size: 11px;
  line-height: 13px;
  letter-spacing: 0.04em;
  color: var(--label-tertiary);
  font-variant-numeric: tabular-nums;
  transition: color 300ms ease-out;
}
.session.is-paused .caption { color: var(--amber); }

/* ---------- Keys ---------- */

.controls {
  display: flex;
  gap: 9px;
  margin-top: auto;
  padding: 0 20px 24px;
}

.key {
  flex: 1;
  display: block;
  padding: 0;
  border: 0;
  background: none;
  border-radius: 8px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
  transition: transform var(--key-up);
}
.key.is-static { cursor: default; }

/* A raised key: a lit top edge and a dark lip, drawn inside the face so the
   key keeps its size as the lip compresses. */
.key-face {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 43px;
  border-radius: 8px;
  background: linear-gradient(180deg, #232427 0%, #18191B 100%);
  box-shadow: inset 0 1px 0 #35363B, inset 0 -2px 0 #050506;
  transition: box-shadow var(--key-up), filter 150ms ease-out;
}
.key-face > :not(.pause-lamps) { transition: transform var(--key-up); }

.key:not(.is-static):not(:disabled):hover .key-face { filter: brightness(1.08); }

.key.is-pressed { transform: scale(0.975); transition: transform var(--key-down); }
.key.is-pressed .key-face {
  box-shadow: inset 0 0 0 #35363B, inset 0 -0.5px 0 #050506;
  transition: box-shadow var(--key-down), filter 150ms ease-out;
}
.key.is-pressed .key-face > :not(.pause-lamps) { transform: translateY(1.5px); transition: transform var(--key-down); }

.key:disabled { cursor: default; }

.icon { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-pause, .icon-play { stroke: var(--amber); transition: stroke 200ms ease-out; }
.icon-stop { stroke: var(--stop); }
#pause:disabled .icon { stroke: var(--label-faint); }

.swap { position: relative; display: block; width: 17px; height: 17px; }
.swap .icon { position: absolute; inset: 0; }
.swap[data-state="pause"] .icon-play,
.swap[data-state="play"] .icon-pause { opacity: 0; }

.pause-lamps {
  position: absolute;
  right: 12px;
  top: 50%;
  translate: 0 -50%;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.extend { gap: 2px; color: var(--extend); font-size: 16px; line-height: 13px; }

/* ---------- Block alert ---------- */

.alert {
  left: var(--alert-x);
  top: var(--alert-y);
  width: 360px;
  z-index: 2;
  display: flex;
  flex-direction: column;
  padding: 20px;
  border-radius: 14px;
  box-shadow: 0 0 0 1px #2E2E30, 0 30px 80px rgba(0, 0, 0, 0.7);
  rotate: var(--alert-tilt);
}
.alert-mark { width: 32px; height: 32px; fill: var(--amber); }
.alert-title {
  margin-top: 10px;
  font-size: 15px;
  line-height: 20px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--label);
}
.alert-body { margin: 10px 0 18px; font-size: 12px; line-height: 17px; color: var(--label-secondary); }
.alert-key {
  height: 41px;
  font-size: 12px;
  line-height: 15px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: #BAB8B3;
}

/* ---------- Narrower screens ---------- */

@media (max-width: 1279px) {
  .hero { grid-template-columns: minmax(0, 480px) minmax(0, 1fr); padding-left: 64px; }
  h1 { font-size: 76px; line-height: 74px; }
  .specs { width: auto; gap: 32px; }
}

@media (max-width: 1099px) {
  .hero {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    grid-template-areas: "nav" "pitch" "stage" "specs";
    min-height: 0;
    padding: 32px 24px 48px;
  }
  .nav-mark { width: 44px; height: 44px; }
  .nav-name { font-size: 26px; line-height: 32px; }
  .pitch { padding: 56px 0 24px; }
  h1 { font-size: clamp(56px, 12vw, 88px); line-height: 0.96; margin-bottom: 28px; }
  .stage-wrap { padding: 24px 0 16px; }
  .stage { margin-left: calc((100% - var(--stage-w) * var(--scale) * 1px) / 2); }
  .stage-wrap { height: calc(var(--stage-h) * var(--scale) * 1px + 40px); }
}

/* On phones, stack the alert above the timer so neither covers the keys. */
@media (max-width: 739px) {
  :root {
    --stage-w: 440;
    --stage-h: 800;
    --alert-x: 34px;
    --alert-y: 4px;
    --alert-tilt: 3deg;
    --session-x: 14px;
    --session-y: 226px;
    --session-tilt: -3deg;
  }
  .glow { left: -190px; top: 90px; }
}

@media (max-width: 560px) {
  .specs { flex-direction: column; gap: 24px; }
  .spec p br { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
