:root {
  color-scheme: dark;
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  color: #f5eedf;
  background: #081827;
  --muted: #b7c4ce;
  --line: #354659;
  --mint: #86f2c3;
  --coral: #ff927f;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 0; }
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:focus-visible, #piano:focus-visible { outline: 3px solid var(--mint); outline-offset: 3px; z-index: 3; }
button:disabled { cursor: default; }
[hidden] { display: none !important; }
#demo {
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(16px, 3vw, 36px) clamp(14px, 4vw, 52px) clamp(22px, 4vw, 50px);
  padding-left: max(clamp(14px, 4vw, 52px), env(safe-area-inset-left));
  padding-right: max(clamp(14px, 4vw, 52px), env(safe-area-inset-right));
  background: radial-gradient(ellipse at 74% 40%, #142b38 0, transparent 59%);
}
.masthead, .brand, .quiet, .piano-bar, .piano-footer {
  display: flex;
  align-items: center;
}
.masthead { justify-content: space-between; gap: 12px; }
.brand { gap: 14px; font-weight: 650; font-size: .95rem; letter-spacing: .02em; }
.brand img { display: block; object-fit: contain; }
.brand span { color: var(--muted); border-left: 1px solid var(--line); padding-left: 14px; }
.quiet {
  background: transparent; border: 1px solid var(--line); border-radius: 100px;
  padding: 7px 13px; gap: 8px; min-height: 36px; font-size: .82rem; font-weight: 650;
}
.quiet:hover { background: #23394a; }
.speaker { color: var(--mint); font-size: 1.1rem; line-height: 1; }
.quiet[aria-pressed="true"] .speaker { color: var(--muted); text-decoration: line-through; }
.modes {
  display: flex; flex-wrap: wrap; width: fit-content; max-width: 100%; gap: 3px;
  padding: 4px; border-radius: 13px; border: 1px solid var(--line); background: #0d2030;
  margin: clamp(20px, 3vw, 32px) 0 0;
}
.modes button {
  background: transparent; color: #c2cfd6; font-size: .84rem; font-weight: 650;
  border: 0; border-radius: 9px; padding: 9px clamp(8px, 2.2vw, 22px); line-height: 1.15;
}
.modes button:hover { color: #fff; background: #1a3242; }
.modes button[aria-pressed="true"] { background: #f2ecdf; color: #0e2330; }
.intro { margin: clamp(18px, 2.8vw, 31px) 0 clamp(15px, 2.2vw, 24px); }
h1 { margin: 0; font-size: clamp(1.8rem, 4.2vw, 3.35rem); font-weight: 750; letter-spacing: -.058em; line-height: 1.06; text-wrap: balance; }
.intro p { margin: 8px 0 0; color: var(--muted); font-size: clamp(.91rem, 1.65vw, 1.02rem); line-height: 1.43; }
.instruments {
  --lesson-device-width: 381.25px;
  display: grid; grid-template-columns: minmax(0, 440px) minmax(175px, var(--lesson-device-width)); gap: clamp(16px, 3.8vw, 54px);
  justify-content: center; align-items: center; min-width: 0;
}
.tablet {
  width: 100%; max-width: 440px; justify-self: center; align-self: center;
  padding: clamp(6px, 1.25vw, 12px); border: 1px solid #454c53; border-radius: clamp(13px, 2vw, 21px);
  background: #0b1015; box-shadow: inset 0 1px #70778142, 0 8px 20px #02091354;
}
.tablet-screen {
  /* The 12.9-inch KEEZI App references use a 2732 × 2048 landscape display. */
  aspect-ratio: 4 / 3; display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto;
  border: 1px solid #222e3d; border-radius: 8px; background: #0a1727;
  overflow: hidden;
}
.tablet-bar {
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center; gap: 3px 6px; padding: 6px 8px 4px;
}
.tablet-brand { font-size: .74rem; font-weight: 800; line-height: 1.1; }
#song-name {
  grid-column: 1 / -1; text-align: center; font-size: .74rem;
  font-weight: 600; color: #dce3e6;
}
#play {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 6px clamp(10px, 2vw, 16px);
  border: 1px solid transparent; border-radius: 7px; background: var(--mint);
  color: #0a2820; font-size: .84rem; font-weight: 750; line-height: 1.1;
  outline-offset: -4px;
}
#play:hover:enabled { background: #b3ffdd; }
#play:focus-visible { outline-color: #0a2820; }
#play:disabled { opacity: .65; }
.play-mark { font-size: .76rem; }
#roll { width: 100%; height: 100%; min-height: 0; display: block; background: #0d2138; }
#lesson-status {
  align-self: center; padding: 4px 8px; min-height: 25px; text-align: center;
  font-size: .75rem; color: #d7e1e4;
}
.track { position: relative; height: 7px; background: #1a3047; }
.track::after {
  --tick: calc(100% / var(--note-count, 1));
  content: ""; position: absolute; inset: auto 0 0; height: 3px;
  background: repeating-linear-gradient(to right, transparent 0 calc(var(--tick) - 1px), #dde9ef7a calc(var(--tick) - 1px) var(--tick));
}
#track-fill { display: block; background: #60be81; width: 0; height: 100%; }
#lesson-count { justify-self: end; font-size: .7rem; white-space: nowrap; color: #dce3e6; }
#lesson-count { font-variant-numeric: tabular-nums; }
#device-wrap { display: flex; align-items: center; flex-direction: column; }
.device {
  /* Front projection of the 87.9 × 56 mm housing, with a 2 mm bevel. */
  position: relative; isolation: isolate;
  width: 100%; max-width: var(--lesson-device-width); aspect-ratio: 87.9 / 56;
  border-radius: 2.84% / 4.46%;
  background: linear-gradient(155deg, #41474c, #1a1f24 42%, #0c1015);
  box-shadow: 0 5px 0 #080b0e, 0 11px 20px #02091275;
}
.device::before,
.device::after { content: ""; position: absolute; z-index: -1; pointer-events: none; }
.device::before {
  inset: 3.57% 2.28%;
  border-radius: .6% / .96%;
  background: linear-gradient(155deg, #252a2e, #171b20 65%, #111519);
}
.device::after {
  /* The 62.2 × 48.8 mm cutout surrounds the centered active LCD. */
  left: 11.32%; top: 6.43%; width: 70.76%; height: 87.14%;
  background: #0a0c0e;
  box-shadow: inset 0 1px 2px #020305;
}
#touchscreen {
  position: absolute; left: 13.94%; top: 11.43%;
  display: block; width: 65.53%; height: auto; aspect-ratio: 4 / 3;
  background: #090f16; touch-action: none;
}
.device-wordmark {
  position: absolute; left: 89.15%; top: 49%;
  width: 43.06%; aspect-ratio: 1420 / 344;
  transform: translate(-50%, -50%) rotate(90deg);
  background: #e2d8bd;
  -webkit-mask: url("./keezi-case-wordmark.png") center 49.4% / 105.63% auto no-repeat;
  mask: url("./keezi-case-wordmark.png") center 49.4% / 105.63% auto no-repeat;
  pointer-events: none;
}
.device-caption { color: var(--muted); font-size: .75rem; font-weight: 600; margin-top: 12px; }
#demo:not([data-mode="0"]) .instruments { display: block; }
#demo:not([data-mode="0"]) .tablet { display: none; }
#demo:not([data-mode="0"]) #device-wrap { align-items: flex-start; }
#demo:not([data-mode="0"]) .device { max-width: 365px; }
#demo:not([data-mode="0"]) .device-caption { display: none; }
.instrument { margin-top: clamp(16px, 2.4vw, 28px); }
.piano-bar { gap: 8px; margin-bottom: 8px; }
.piano-bar strong { font-size: 1rem; letter-spacing: -.02em; }
#current-range { font-size: .75rem; color: var(--muted); }
#piano { border-radius: 9px; background: #121b20; border: 1px solid #465462; padding: 4px 4px 5px; box-shadow: 0 5px 0 #070f16, 0 8px 16px #03091455; outline-offset: 5px; }
#strip { width: 100%; height: clamp(14px, 2.2vw, 22px); display: block; pointer-events: none; }
#keys { height: clamp(104px, 14vw, 162px); isolation: isolate; position: relative; touch-action: none; user-select: none; -webkit-user-select: none; }
.piano-key {
  display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 2px;
  position: absolute; top: 0; padding: 0 0 6px; border: 0; font: inherit; touch-action: none;
  overflow: hidden; outline-offset: -4px !important; -webkit-user-select: none; user-select: none;
}
.white-key {
  height: 100%; color: #34434a; background: linear-gradient(to bottom, #d0d4cc, #f4f0e6 22%, #fffcf2 88%, #ddd9cd);
  border-right: 1px solid #687173; border-bottom: 3px solid #a9aa9f; border-radius: 1px 1px 4px 4px;
}
.black-key {
  height: 63%; z-index: 1; color: #e6eded; padding-bottom: 4px;
  background: linear-gradient(100deg, #28343d, #131d26 32%, #0e171f 87%, #2c3438);
  border: 1px solid #0b0f12; border-bottom: 5px solid #05090c; box-shadow: 1px 3px 2px #07111c59;
  border-radius: 1px 1px 3px 3px;
}
.piano-key[data-held="true"] { background: linear-gradient(to bottom, #81cbb3, #b9f6d8); border-bottom-color: #518c7c; color: #0e322c; }
.black-key[data-held="true"] { background: linear-gradient(to bottom, #356e61, #67c6a3); color: white; }
.piano-key[data-target="true"]::before { content: ""; display: block; width: 9px; height: 9px; border-radius: 50%; background: #14694f; border: 2px solid white; box-shadow: 0 0 0 1px #14694f; }
.piano-key:focus-visible { outline: 2px solid #176756; }
.piano-key.black-key:focus-visible { outline-color: #9dffdb; }
.note-name, .letter { pointer-events: none; font-size: clamp(.62rem, 1.5vw, .74rem); font-weight: 700; line-height: 1.05; }
.letter { font-size: .62rem; opacity: .8; }
@media (pointer: coarse) { .letter { display: none; } }
.piano-footer { justify-content: space-between; flex-wrap: wrap; gap: 5px 10px; margin: 10px 1px 0; font-size: .78rem; color: var(--muted); line-height: 1.4; }
.launcher-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.launcher-head h2 { font-size: 1.35rem; margin: 0; letter-spacing: -.035em; }
#launcher { width: min(350px, calc(100% - 30px)); border: 1px solid var(--line); border-radius: 15px; padding: 20px; background: #102333; color: #f5eedf; box-shadow: 0 16px 50px #03081299; }
#launcher::backdrop { background: #04111dc9; }
#launcher-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
#launcher button { background: #1c3242; color: inherit; border: 1px solid #45596a; padding: 9px; border-radius: 8px; }
#launcher button[aria-pressed="true"] { background: #eae6d9; color: #0e2330; }
.launcher-head button { min-width: 36px; line-height: 1; }
.text-button { border: 0; padding: 3px 0; color: var(--mint); background: transparent; text-decoration: underline; text-underline-offset: 3px; }
#device-toggle { display: none; }
#runtime-status { color: var(--coral); font-size: .92rem; }
#runtime-status:empty { display: none; }
@media (min-width: 740px) and (min-height: 551px) {
  #demo:not([data-mode="0"]) {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 36%);
    column-gap: 6%; align-items: center;
  }
  #demo:not([data-mode="0"]) > :is(.masthead, .modes, .instrument, #runtime-status, noscript) { grid-column: 1 / -1; }
  #demo:not([data-mode="0"]) > .instruments { margin-top: 20px; }
  #demo:not([data-mode="0"]) .device { margin-left: auto; }
  #demo:not([data-mode="0"]) .intro p { max-width: 43ch; }
}
@media (max-width: 649px) {
  .brand img { width: 76px; height: auto; }
  .brand, .quiet { gap: 8px; }
  .brand span { padding-left: 8px; font-size: .85rem; }
  .modes { width: 100%; }
  .modes button { flex: 1 1 auto; padding: 8px 5px; font-size: .78rem; }
  .instruments { display: flex; flex-direction: column; align-items: stretch; gap: 14px; }
  #demo[data-mode="0"]:not(.show-device) #device-wrap { display: none; }
  #demo[data-mode="0"] #device-toggle { display: inline-block; }
  #demo:not([data-mode="0"]) #device-wrap { align-items: center; }
  .tablet { align-self: center; }
  #keys { height: clamp(98px, 25vw, 130px); }
}
@media (max-width: 549px) {
  .modes { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .modes button { grid-column: span 2; }
  .modes button:nth-last-child(-n+2) { grid-column: span 3; }
}
@media (max-width: 649px) and (orientation: portrait), (max-width: 599px) {
  #demo[data-mode="0"] { display: flex; flex-direction: column; }
  #demo[data-mode="0"] .instruments { display: contents; }
  #demo[data-mode="0"] .instrument { order: 1; }
  #demo[data-mode="0"] #device-wrap { order: 2; margin-top: 12px; }
  #demo[data-mode="0"] #runtime-status { order: 3; }
}
@media (max-height: 550px) and (min-width: 600px) and (orientation: landscape) {
  #demo { padding-block: 10px 15px; }
  .masthead { float: left; min-height: 36px; }
  .brand img { width: 68px; height: auto; }
  .brand span { display: none; }
  .quiet { margin-left: 10px; }
  .modes { margin: 0 0 0 auto; }
  .intro { clear: both; margin: 11px 0; }
  h1 { font-size: 1.6rem; }
  .intro p { margin-top: 3px; font-size: .8rem; }
  .instruments {
    --lesson-device-width: 195px;
    display: grid; grid-template-columns: minmax(0, 235px) minmax(0, var(--lesson-device-width)); align-items: center; gap: 18px;
  }
  #demo[data-mode="0"]:not(.show-device) #device-wrap { display: flex; }
  #demo[data-mode="0"] #device-toggle { display: none; }
  .tablet-bar { padding: 4px 6px 3px; gap: 2px 4px; }
  .tablet-brand, #lesson-count { font-size: .64rem; }
  #lesson-status { min-height: 22px; padding-block: 2px; }
  .device-caption { display: none; }
  #demo:not([data-mode="0"]) .device { max-width: 205px; }
  .instrument { margin-top: 9px; }
  #keys { height: 75px; }
  #strip { height: 13px; }
  .piano-footer { margin-top: 6px; }
}
