:root {
  color-scheme: dark;
  --background: #080808;
  --ink: #f2f0e9;
  --muted: #a3a39e;
  --line: #b6b6b1;
  --edge-offset: 12px;
  --contact-gap: 12px;
  --filter-width: 76px;
  --key-width: 76px;
  --rhythm-height: 90px;
  --rec-height: 62px;
  --cutoff-position: 100%;
  --safe-top: max(var(--edge-offset), env(safe-area-inset-top));
  --safe-bottom: max(var(--edge-offset), env(safe-area-inset-bottom));
  --safe-left: max(var(--edge-offset), env(safe-area-inset-left));
  --safe-right: max(var(--edge-offset), env(safe-area-inset-right));
  --center-left: calc(var(--safe-left) + var(--key-width) + var(--contact-gap));
  --center-right: calc(var(--safe-right) + var(--filter-width) + var(--contact-gap));
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Noto Sans TC", sans-serif;
  font-synthesis: none;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; background: var(--background); color: var(--ink); overscroll-behavior: none; }
body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
button, a, [role="slider"] { touch-action: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; }
button:disabled { cursor: wait; opacity: .45; }
button:focus-visible, a:focus-visible, [role="slider"]:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; }
[hidden] { display: none !important; }
#machine { position: fixed; top: 0; left: 0; width: 100%; height: 100svh; height: var(--surface-height, 100svh); touch-action: none; }
/* The viewport stays portrait; the pair faces sideways for a physically rotated phone. */
.performance-eyes { position: absolute; top: calc(var(--safe-top) + var(--rhythm-height) + 64px); bottom: calc(var(--safe-bottom) + var(--rec-height) + 20px); left: var(--center-left); right: var(--center-right); display: grid; place-items: center; pointer-events: none; color: var(--ink); }
.performance-eyes svg { display: block; width: 100%; height: 100%; max-width: 140px; max-height: 304px; }
html[data-mode="test"] .performance-eyes { display: none; }
.eyes-option { display: flex; align-items: center; gap: 12px; min-height: 48px; margin-top: 12px; font-size: 13px; cursor: pointer; }
.eyes-option input { width: 20px; height: 20px; margin: 0; accent-color: var(--ink); cursor: pointer; }
.eye-blink { animation: eye-blink 5.6s ease-in-out infinite; }
.eye-expression { transform: scaleY(var(--eye-open, 1)); transition: transform 160ms ease-out; }
.eye-pupil { transform: translate(var(--gaze-x, 0px), var(--gaze-y, 0px)) scale(var(--pupil-scale, 1)); transition: transform 160ms ease-out; }
.pupil-round { fill: #080808; }
.pupil-heart { fill: #ef526b; display: none; }
.pupil-sparkle { fill: #ffd64a; display: none; }
[data-eye-style="heart"] .pupil-round, [data-eye-style="sparkle"] .pupil-round { display: none; }
[data-eye-style="heart"] .pupil-heart, [data-eye-style="sparkle"] .pupil-sparkle { display: inline; }
@keyframes eye-blink { 0%, 43%, 47%, 92%, 96%, 100% { transform: scaleY(1); } 45%, 94% { transform: scaleY(.045); } }
html[data-mode="test"] .eye-blink, #machine[inert] .eye-blink { animation-play-state: paused; }
@media (prefers-reduced-motion: reduce) { .eye-blink { animation: none; } }
.pad { position: relative; background: transparent; border: 1px solid var(--line); border-radius: 3px; overflow: hidden; color: var(--ink); touch-action: none; transition: color 60ms linear, background-color 60ms linear; }
.pad.is-active { background: var(--ink); color: var(--background); border-color: var(--ink); }
.rhythms { position: absolute; top: var(--safe-top); left: var(--center-left); right: var(--center-right); height: var(--rhythm-height); display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--contact-gap); }
.rhythm { padding: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 8px; }
.pad-label { font-size: 9px; letter-spacing: .16em; }
.rhythm-number { font-size: 26px; font-weight: 300; line-height: 1; font-variant-numeric: tabular-nums; }
.menu-open { position: absolute; top: calc(var(--safe-top) + var(--rhythm-height) + 10px); right: var(--center-right); width: 44px; height: 44px; background: transparent; color: var(--muted); display: grid; place-items: center; }
.menu-open svg { fill: currentColor; }
.filter { position: absolute; top: var(--safe-top); bottom: var(--safe-bottom); right: var(--safe-right); width: var(--filter-width); }
.filter-fill { position: absolute; bottom: 0; width: 100%; height: var(--cutoff-position); background: #e5e5dd25; pointer-events: none; }
.filter-line { position: absolute; bottom: clamp(0px, var(--cutoff-position), calc(100% - 3px)); height: 3px; width: 100%; background: var(--ink); pointer-events: none; }
.filter-label { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 10px; letter-spacing: .2em; pointer-events: none; }
.filter.is-active { background: #252525; color: var(--ink); }
.record { position: absolute; bottom: var(--safe-bottom); left: var(--center-left); right: var(--center-right); height: var(--rec-height); display: flex; align-items: center; justify-content: center; gap: 12px; font-size: 11px; letter-spacing: .12em; }
.record-dot { width: 8px; height: 8px; border: 1px solid currentColor; border-radius: 50%; }
.record.is-active .record-dot { background: currentColor; }
.reset { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); background: transparent; display: flex; align-items: center; justify-content: center; gap: 9px; min-width: 90px; min-height: 48px; color: var(--muted); font-size: 10px; letter-spacing: .12em; }
.reset:active { color: var(--ink); }
.keyboard { position: absolute; top: var(--safe-top); bottom: var(--safe-bottom); left: var(--safe-left); width: var(--key-width); display: grid; grid-template-rows: repeat(5, minmax(0, 1fr)); gap: var(--contact-gap); }
.key { display: flex; align-items: center; justify-content: center; font-size: 24px; font-weight: 300; }
[data-mode="test"] .menu-open { color: var(--ink); }
[data-mode="test"] .pad { border-style: dashed; }
[data-mode="test"] .pad.is-active { border-style: solid; }
dialog { color: var(--ink); background: #101010; border: 1px solid #444; border-radius: 5px; padding: 0; }
dialog::backdrop { background: #000c; }
.welcome { position: fixed; inset: 0; border: 0; border-radius: 0; width: 100%; max-width: none; height: 100%; max-height: none; background: var(--background); overflow-y: auto; touch-action: pan-y; }
.welcome-content { width: min(100%, 480px); min-height: 100%; padding: max(32px, env(safe-area-inset-top)) 32px max(24px, env(safe-area-inset-bottom)); margin: auto; display: flex; flex-direction: column; justify-content: center; }
.eyebrow { display: flex; align-items: center; gap: 10px; font-size: 10px; letter-spacing: .18em; color: var(--muted); margin-bottom: 32px; }
.tiny-mark { display: inline-block; width: 11px; height: 11px; border: 1px solid var(--ink); }
h1 { margin: 0; font-size: clamp(58px, 17vw, 83px); letter-spacing: -.065em; line-height: .95; font-weight: 500; }
.title-period { color: #777; }
.welcome-actions { margin-top: 64px; display: flex; flex-direction: column; gap: 10px; }
.action { display: flex; justify-content: space-between; align-items: center; padding: 0 19px; width: 100%; min-height: 52px; border: 1px solid #565653; border-radius: 3px; font-size: 13px; letter-spacing: .04em; }
.action.primary { background: var(--ink); color: #101010; border-color: var(--ink); }
.action.secondary { background: transparent; color: var(--ink); }
.action:active { filter: brightness(.78); }
.permission-note { margin: 15px 0 0; color: var(--muted); font-size: 11px; line-height: 1.8; min-height: 20px; }
.text-action { padding: 12px 0; background: transparent; font-size: 12px; text-decoration: underline; text-underline-offset: 4px; }
.menu-dialog { width: min(440px, calc(100vw - 32px)); max-height: calc(100svh - 32px); padding: 23px; overflow: auto; touch-action: pan-y; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
h2 { font-size: 18px; font-weight: 500; letter-spacing: -.035em; margin: 0; }
.close { flex-shrink: 0; width: 44px; height: 44px; background: transparent; font-size: 26px; font-weight: 300; }
.instructions { margin: 22px 0; }
.instructions > div { display: grid; grid-template-columns: 74px 1fr; padding: 12px 0; border-bottom: 1px solid #303030; }
dt { font-size: 10px; letter-spacing: .08em; padding-top: 3px; }
dd { margin: 0; font-size: 12px; line-height: 1.8; color: #c1c1ba; }
.setup-note { font-size: 11px; color: var(--muted); line-height: 1.8; }
.credits { display: inline-flex; min-height: 44px; align-items: center; color: var(--muted); font-size: 10px; text-underline-offset: 3px; }
.notice { position: fixed; z-index: 10; bottom: calc(var(--safe-bottom) + var(--rec-height) + 16px); left: 50%; transform: translateX(-50%); max-width: calc(100vw - var(--center-left) - var(--center-right)); width: max-content; background: #242424; border: 1px solid #444; padding: 12px 16px; border-radius: 3px; font-size: 12px; line-height: 1.6; opacity: 0; pointer-events: none; }
.notice.visible { opacity: 1; }
@media (hover: hover) { .action:hover { border-color: var(--ink); } .menu-open:hover, .reset:hover, .text-action:hover { color: white; } .pad:hover { border-color: white; } }
@media (max-width: 350px) { :root { --edge-offset: 10px; --contact-gap: 9px; --filter-width: 64px; --key-width: 64px; --rec-height: 54px; } .welcome-content { padding-left: 25px; padding-right: 25px; } .rhythm .pad-label { letter-spacing: .04em; } }
@media (max-height: 650px) { :root { --rhythm-height: 74px; } .eyebrow { margin-bottom: 22px; } h1 { font-size: 61px; } }
@media (orientation: landscape) and (max-height: 500px) { :root { --contact-gap: 8px; --rhythm-height: 74px; --rec-height: 48px; } .rhythm-number { font-size: 22px; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Hide contact paint without changing hit targets; keep the settings button visible. */
html[data-mode="play"] #machine .pad,
html[data-mode="play"] #reset { opacity: 0; }

#start-status:empty, #mic-status:empty { display: none; }
