@font-face { font-family: "DM Serif Display"; src: url("./fonts/DMSerifDisplay-Regular.ttf") format("truetype"); font-style: normal; font-weight: 400; font-display: swap; }
@font-face { font-family: "DM Serif Display"; src: url("./fonts/DMSerifDisplay-Italic.ttf") format("truetype"); font-style: italic; font-weight: 400; font-display: swap; }
@font-face { font-family: "DM Sans"; src: url("./fonts/DMSans-Variable.ttf") format("truetype"); font-style: normal; font-weight: 100 1000; font-display: swap; }
:root {
  color-scheme: dark;
  --bg: #0c0c0c; --panel: #171717; --line: #343434; --border: var(--line);
  --text: #f5f3ed; --muted: #aaa8a2; --accent: #f1eee5;
  --font-display: "DM Serif Display",Georgia,"Times New Roman",serif;
  --font-ui: "DM Sans",-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
  --left: #55a9f6; --right: #6bdaa6; --danger: #bebebe;
  --player-height: 112px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--font-ui); }
button,input,select,textarea { font: inherit; }
button { border: 1px solid #414141; background: #202020; color: var(--text); padding: 9px 14px; border-radius: 4px; cursor: pointer; }
button:hover { background: #303030; border-color: #767676; }
button:disabled { opacity: .43; cursor: not-allowed; }
button:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible,summary:focus-visible,a:focus-visible { outline: 2px solid #d2d2d2; outline-offset: 3px; }
input:not([type=range]):not([type=checkbox]):not([type=color]),select,textarea { background: #181818; color: var(--text); border: 1px solid #4c4c4c; border-radius: 6px; padding: 9px 11px; min-width: 0; }
input[type=range],input[type=checkbox],progress { accent-color: var(--accent); }
input[type=checkbox] { width: 17px; height: 17px; margin: 0; flex-shrink: 0; }
input[type=range] { cursor: pointer; min-width: 0; min-height: 22px; }
input[type=color] { height: 38px; width: 48px; border: 1px solid #535353; background: #1c1c1c; border-radius: 5px; padding: 3px; }
svg { display: block; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.icon-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
h1,h2,h3,p { margin: 0; }
h1,h2,h3 { font-family: var(--font-display); font-weight: 400; }
h1 { font-size: 40px; font-style: italic; letter-spacing: -.6px; line-height: 1.2; }
h2 { font-size: 25px; letter-spacing: -.3px; line-height: 1.35; }
h3 { font-size: 20px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.eyebrow { font-size: 11px; letter-spacing: 1.3px; font-weight: 600; color: var(--muted); margin-bottom: 7px; }
.shell { display: grid; grid-template-columns: minmax(0,1fr); height: 100dvh; min-height: 300px; }
.brand { color: var(--text); text-decoration: none; display: flex; align-items: center; min-height: 42px; }
.brand img { display: block; width: 160px; height: auto; }
.connection-row { display: flex; gap: 16px; margin: -8px 0 24px; font-size: 12px; color: var(--muted); }
.connection { display: flex; align-items: center; gap: 7px; }
.connection:before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #8e8e8e; }
.connection.connected:before { background: #b7b7b7; }
.work-area { min-width: 0; display: flex; flex-direction: column; background: var(--bg); overflow: hidden; }
.topbar { display: grid; grid-template-columns: 160px minmax(160px,1fr) auto; align-items: center; padding: 18px 32px; gap: 24px; flex-shrink: 0; border-bottom: 1px solid #252525; margin-bottom: 0; position: relative; z-index: 30; }
.global-search { height: 44px; display: flex; align-items: center; gap: 11px; padding: 0 14px; border: 1px solid #353535; background: #161616; border-radius: 5px; width: 100%; min-width: 0; color: #b3b3b3; }
.global-search svg { height: 19px; width: 19px; }
.global-search input { border: 0 !important; background: none !important; outline: none !important; padding: 0 !important; font-size: 14px; width: 100%; }
.global-search input::placeholder { color: #aaaaaa; }
.global-search:focus-within { border-color: #b2b2b2; box-shadow: 0 0 0 2px #b5b5b51a; }
.topbar-end { grid-column: 3; margin-left: auto; display: flex; align-items: center; gap: 16px; }
.hardware-state { font-size: 12px; color: #b7b7b7; white-space: nowrap; }
.hardware-state.enabled { color: #cacaca; }
.emergency { min-height: 36px; padding: 7px 12px; border: 1px solid #5a5a5a; color: #c3c3c3; background: #262626; font-size: 12px; white-space: nowrap; }
.emergency:hover { background: #333333; border-color: #838383; }
.workspace { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.view-scroll { position: relative; height: 100%; min-height: 0; overflow: auto; scrollbar-color: #515151 transparent; padding: 12px 32px 32px; }
#music-view,#setup-view,#devices-view { max-width: 1440px; margin-inline: auto; }
.view-heading { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-bottom: 26px; }
.view-heading .muted { font-size: 14px; margin-top: 9px; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 20px; }
.primary-button,button.primary { background: var(--accent); border-color: var(--accent); color: #111; font-weight: 600; }
.primary-button:hover,button.primary:hover { background: #fff; border-color: #fff; }
.quiet-button { background: #2c2c2c; border-color: #4c4c4c; padding: 8px 12px; color: #dcdcdc; font-size: 13px; white-space: nowrap; }
.icon-button { display: flex; align-items: center; justify-content: center; border: 0; background: none; padding: 9px; width: 38px; height: 38px; border-radius: 7px; color: #bfbfbf; flex-shrink: 0; }
.icon-button:hover,.icon-button.active { background: #3d3d3d; color: #dfdfdf; }
.icon-button svg { height: 21px; width: 21px; }
.field { display: flex; flex-direction: column; gap: 8px; font-size: 13px; color: var(--muted); }
.settings-panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 24px; margin-bottom: 24px; }
.output-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; align-items: start; }
.hardware-control { font-size: 14px; }
.hardware-control p { margin: 6px 0 14px; line-height: 1.55; }
.hardware-control button { font-size: 13px; }
.hint { font-size: 13px; color: var(--muted); line-height: 1.6; margin-top: 18px; }
.status-label { font-size: 12px; color: #cacaca; background: #323232; border-radius: 5px; padding: 4px 9px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.buttons { display: flex; gap: 9px; flex-wrap: wrap; margin-top: 18px; }
#message { margin: 0 32px 12px; padding: 12px 15px; border: 1px solid #666666; border-radius: 7px; background: #363636; color: #e6e6e6; font-size: 14px; flex-shrink: 0; }
#message.error { border-color: #6d6d6d; background: #2e2e2e; color: #d4d4d4; }
.loading-state { color: var(--muted); padding: 40px 0; font-size: 14px; }
/* Transport stays above the scrollable library and visualizer. */
.player-bar { height: var(--player-height); flex-shrink: 0; position: relative; z-index: 20; background: #141414; border-bottom: 1px solid #3a3a3a; box-shadow: 0 6px 22px #0b0b0b26; display: grid; grid-template-columns: minmax(170px,1fr) minmax(150px,280px) auto; grid-template-rows: minmax(0,1fr) 34px; align-items: center; padding: 12px 22px 0; gap: 8px 24px; }
.now-playing { display: flex; align-items: center; gap: 13px; min-width: 0; }
.now-meta { display: flex; flex-direction: column; min-width: 0; gap: 5px; }
.now-meta button { padding: 0; border: 0; background: none; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; text-align: left; font: italic 26px/1.3 var(--font-display); display: block; }
.now-meta button:hover { text-decoration: underline; }
.now-meta span { color: #b4b4b4; font-size: 12px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.player-center { min-width: 0; }
.player-buttons { display: flex; align-items: center; justify-content: center; gap: 20px; height: 42px; }
.play-button { width: 40px; height: 40px; border-radius: 50%; background: var(--accent); color: #111; border: 0; padding: 0; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 8px #0003; }
.play-button:hover { background: white; transform: scale(1.04); }
.play-button svg { height: 23px; width: 23px; stroke-width: 2.1; }
.timeline { grid-column: 1 / -1; position: relative; height: 34px; margin-inline: -22px; font-size: 11px; font-variant-numeric: tabular-nums; color: #bbbbbb; }
.timeline input { position: absolute; inset: auto 0 0; height: 22px; margin: 0; width: 100%; accent-color: var(--accent); }
.timeline span { position: absolute; top: 0; left: 22px; }.timeline span:last-child { left: auto; right: 22px; text-align: right; }
.player-tools { display: flex; align-items: center; justify-content: end; gap: 6px; min-width: 0; }
.volume-control { display: flex; align-items: center; gap: 7px; color: #c0c0c0; margin-left: 5px; }
.volume-control svg { width: 18px; height: 18px; }.volume-control input { width: 74px; margin: 0; accent-color: var(--accent); }
#queue-panel { max-width: 1100px; margin-inline: auto; }
/* Falling notes and keyboard share the same horizontal pitch geometry. */
.visualizer-view { --keyboard-height: clamp(104px,16dvh,144px); display: flex; flex-direction: column; min-height: 490px; height: 100%; }
.visual-controls { display: flex; align-items: center; gap: 12px 20px; margin-bottom: 12px; flex-wrap: wrap; }
.visual-controls>label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.visual-controls input { width: 66px; padding: 7px 9px !important; font-size: 13px; }
.hand-legend { display: flex; gap: 20px; margin-right: auto; color: #cdcdcd; font-size: 13px; }
.hand-legend span { display: flex; align-items: center; gap: 8px; }.hand-legend i { width: 9px; height: 9px; border-radius: 3px; }
.left-color { background: var(--left); }.right-color { background: var(--right); }
.part-settings { margin-bottom: 12px; display: flex; gap: 12px; flex-wrap: wrap; }.part-settings:empty { display: none; }
.part-settings label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }.part-settings select { padding: 7px 9px; font-size: 13px; }
.part-settings>p { width: 100%; }.part-list,.channel-options { display: flex; align-items: center; flex-wrap: wrap; gap: 12px 20px; }
.channel-options { width: 100%; padding-top: 12px; border-top: 1px solid var(--line); }
.roll-scroll { overflow-x: auto; overflow-y: hidden; scrollbar-color: #6b6b6b #1d1d1d; border: 0; border-top: 1px solid #444; border-radius: 0; flex: 1; min-height: calc(var(--keyboard-height) + 201px); background: #161616; box-shadow: 0 8px 24px #0d0d0d40; }
#roll-surface { position: relative; display: flex; flex-direction: column; height: 100%; min-width: 780px; }
#piano-roll { display: block; width: 100%; height: 0; min-height: 150px; flex: 1 1 0; }
#roll-empty { position: absolute; top: 38%; width: 100%; text-align: center; color: #afafaf; font-size: 15px; pointer-events: none; }
#strike-line { height: 3px; flex: 0 0 3px; background: linear-gradient(90deg,#79797980,#dbdbdb,#7d7d7d90); box-shadow: 0 -2px 11px #99999938; position: relative; z-index: 2; }
#roll-lightbar { display: block; width: 100%; height: 26px; flex: 0 0 26px; background: #171717; pointer-events: none; }
#keyboard { height: var(--keyboard-height); min-height: 104px; flex: 0 0 var(--keyboard-height); position: relative; background: #161616; }
.key { position: absolute; top: 0; display: flex; align-items: end; justify-content: center; padding: 0 0 10px; border-radius: 0 0 5px 5px; user-select: none; touch-action: none; font-size: 10px; font-weight: 400; transition: transform 60ms,box-shadow 90ms; transform-origin: 50% 0; }
.key.white { z-index: 0; height: calc(100% - 4px); background: linear-gradient(90deg,#bcbcbc,#f1f1f1 10%,#dedede 86%,#b3b3b3); border: 1px solid #828282; border-top: 0; color: #626262; box-shadow: inset 0 -5px 0 #ababab,0 3px 4px #0009,inset 0 1px #ffffffd9; }
.key.black { height: 63%; background: linear-gradient(90deg,#161616,#414141 18%,#2f2f2f 72%,#191919); border: 1px solid #111111; border-top: 0; color: #a3a3a3; z-index: 1; box-shadow: inset 0 -5px 0 #0f0f0f,0 4px 7px #000b,inset 1px 0 #6f6f6f88; }
.key.white.sounding,.key.white.pressed { background: linear-gradient(90deg,var(--key-dark),var(--key-color) 18%,var(--key-color) 78%,var(--key-dark)); color: #333333; box-shadow: inset 0 5px 11px #21212166,inset 0 -2px 0 #33333388,0 0 13px var(--key-glow); transform: translateY(3px) scaleY(.96); }
.key.black.sounding,.key.black.pressed { background: linear-gradient(90deg,var(--key-dark),var(--key-color) 30%,var(--key-dark)); box-shadow: inset 0 5px 9px #14141488,inset 0 -3px #0f0f0f88,0 0 12px var(--key-glow); transform: translateY(3px) scaleY(.96); }
.key:focus-visible { outline-offset: -3px; }
.visualizer-fullscreen .shell { grid-template-columns: minmax(0,1fr); }
.visualizer-fullscreen .brand,.visualizer-fullscreen .search-area { display: none; }
.visualizer-fullscreen .topbar { display: flex; justify-content: flex-end; padding-block: 10px 0; border: 0; margin-bottom: 0; }
.visualizer-fullscreen .view-scroll { padding-top: 12px; }
.visualizer-fullscreen .visualizer-view { min-height: 440px; }
.sr-only { position: absolute; clip: rect(0,0,0,0); height: 1px; width: 1px; overflow: hidden; white-space: nowrap; }
@media(min-width:1700px) { .view-scroll { padding-inline: 48px; }.topbar { padding-inline: 48px; } }
@media(max-width:1180px) {
  .view-scroll { padding-inline: 24px; }.topbar { padding-inline: 24px; }
  .hardware-state { display: none; }.player-bar { column-gap: 16px; grid-template-columns: minmax(160px,1fr) minmax(140px,220px) auto; padding-inline: 16px; }.timeline { margin-inline: -16px; }.timeline span { left: 16px; }.timeline span:last-child { right: 16px; }
  .volume-control input { width: 60px; }
  #message { margin-inline: 24px; }
}
@media(max-width:800px) {
  :root { --player-height: 154px; }
  .shell { grid-template-columns: minmax(0,1fr); }
  .topbar { grid-template-columns: minmax(0,1fr) auto; gap: 8px 16px; padding: 12px 20px 8px; }
  .brand { grid-column: 1; grid-row: 1; }.brand img { width: 145px; }
  .topbar-end { grid-column: 2; grid-row: 1; }
  .search-area { grid-column: 1 / -1; grid-row: 2; }
  .global-search { height: 38px; padding: 0 10px; gap: 8px; margin-bottom: 4px; }
  .global-search input { font-size: 13px; }.topbar-end { margin: 0; }.emergency { padding: 7px 9px; font-size: 12px; }
  .view-scroll { padding: 14px 20px 24px; }h1 { font-size: 32px; }.view-heading { gap: 16px; align-items: flex-start; flex-wrap: wrap; }
  #message { margin-inline: 20px; font-size: 13px; }
  .player-bar { padding: 10px 16px 0; grid-template-columns: auto minmax(0,1fr); grid-template-rows: 48px 44px 34px; gap: 6px 10px; }
  .now-playing { grid-column: 1 / -1; grid-row: 1; }.now-meta { gap: 2px; }.now-meta button { font-size: 23px; }.now-meta span { font-size: 12px; }
  .player-tools { grid-column: 2; grid-row: 2; gap: 0; }.player-tools .icon-button { width: 32px; height: 40px; padding: 6px; }
  .player-tools .volume-control { display: none; }.player-center { grid-column: 1; grid-row: 2; }
  .player-buttons { gap: 4px; height: 40px; }.player-buttons .icon-button { width: 32px; height: 40px; padding: 6px; }
  .timeline { grid-row: 3; }
  .output-grid { grid-template-columns: 1fr; gap: 24px; }.settings-panel { padding: 20px; }
  .visualizer-view { min-height: 480px; }
  .visual-controls { gap: 12px; }.hand-legend { width: 100%; font-size: 12px; gap: 16px; }
  .visual-controls>label { font-size: 12px; gap: 5px; }.visual-controls input { width: 52px; padding: 6px !important; }
}
@media(prefers-reduced-motion:reduce) { * { scroll-behavior: auto !important; }.key { transition: none; }.play-button:hover { transform: none; } }

.connection-panel { max-width: 560px; width: calc(100% - 40px); margin: auto; padding: 48px 0; }
.connection-panel h1 { margin: 8px 0 16px; }
.connection-panel p { max-width: 44ch; }
.connection-panel > button { margin-top: 24px; }
.player-bar[inert] { opacity: .45; }
.preparing-song { color: var(--text); font-size: 11px; }
.performance-summary { margin: 0 0 12px; font-size: 12px; color: var(--muted); }
.performance-summary summary { cursor: pointer; padding: 6px 0; }
.performance-legend { display: flex; flex-wrap: wrap; gap: 12px; margin: 7px 0; }
.performance-legend span { display: inline-flex; align-items: center; gap: 6px; }
.performance-legend i { width: 18px; height: 10px; border-radius: 2px; }
.prepared-swatch { background: var(--left); }
.original-swatch { border: 1px solid #ffffff60; background: #ffffff0a; }
.omitted-swatch { border: 1px dashed #c69898; }
.performance-changes { max-height: 180px; overflow-y: auto; padding-left: 22px; margin: 8px 0; }
.performance-changes li { margin: 4px 0; }

/* The roll reaches the viewport edges; controls retain comfortable reading space. */
.view-scroll.showing-visualizer { padding: 0; }
.control-panel { position: absolute; inset: 0 0 auto; z-index: 12; display: flex; flex-direction: column; max-height: min(620px, calc(100% - clamp(104px,16dvh,144px) - 48px)); background: #141414; border-bottom: 1px solid #505050; box-shadow: 0 18px 50px #0009; animation: panel-arrive 220ms ease-out; }
.panel-scroll { padding: 16px 24px; overflow-y: auto; overscroll-behavior: contain; min-height: 0; scrollbar-color: #555 transparent; }
.panel-backdrop { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 11; border: 0; border-radius: 0; background: #0006; cursor: default; padding: 0; }
.panel-backdrop:hover { background: #0006; }
@keyframes panel-arrive { from { transform: translateY(-100%); } to { transform: translateY(0); } }
@media(max-width:800px) {
  .panel-scroll { padding: 12px 16px; }
}
@media(prefers-reduced-motion:reduce) { .control-panel { animation: none; } }

/* Setup uses the same keyboard, with space left for the keys and the roll. */
.workspace[data-panel="setup"] .panel-backdrop { pointer-events: none; height: auto; bottom: calc(clamp(104px,16dvh,144px) + 16px); }
.key.white.setup-selected { background: linear-gradient(90deg,#6c6c6c,#bcbab3 20%,#a5a39d 80%,#656565); color: #181818; }
.key.black.setup-selected { background: linear-gradient(90deg,#292929,#88867e 28%,#56554e); color: #fff; }
.key.setup-editing { outline: 2px solid #fffdf5; outline-offset: -3px; }
.key.setup-editing::after { content: ""; position: absolute; bottom: 24px; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.key.setup-calibrating { background: #e8e4d9 !important; color: #26241f; box-shadow: inset 0 0 0 3px #a6a39a; }

#visual-settings-view .performance-summary { margin: 8px 0 0; }
.panel-scroll .settings-panel { padding: 16px; margin-bottom: 16px; border-radius: 6px; }
.panel-scroll .section-head { margin-bottom: 12px; }
.panel-scroll .section-head h2 { font-size: 22px; }
.panel-scroll .connection-row { margin: 0 0 12px; }
.panel-scroll .output-grid { gap: 16px; }
.panel-scroll .hint { margin-top: 10px; font-size: 12px; }

.topbar .emergency { border: 1px solid #555; }
.emergency svg { fill: currentColor; stroke: none; width: 18px; height: 18px; }
.workspace[data-panel="lights"] .panel-backdrop,.workspace[data-panel="queue"] .panel-backdrop { background: transparent; }
@media(max-width:380px) {
  .player-bar { grid-template-columns: minmax(0,1fr) auto; }
  .now-playing { grid-column: 1; }
  .player-center { grid-column: 2; grid-row: 1; }
  .player-tools { grid-column: 1 / -1; justify-content: center; }
}

/* The public page is a live view; management lives behind admin access. */
.visitor-mode [data-admin],html:not(.visitor-mode) [data-visitor] { display: none !important; }
.visitor-mode .player-bar { --player-height: 106px; grid-template-columns: minmax(0,1fr) auto; grid-template-rows: minmax(0,1fr) 28px; }
.visitor-mode .now-playing { grid-column: 1; grid-row: 1; }
.visitor-mode .player-tools { grid-column: 2; grid-row: 1; gap: 8px; justify-content: end; }
.visitor-mode .timeline { grid-row: 2; height: 28px; }
.visitor-mode #keyboard { cursor: default; }
.public-status { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.public-status::before { content: ""; width: 5px; height: 5px; background: currentColor; border-radius: 50%; }
#public-position { position: absolute; inset: auto 0 0; width: 100%; height: 3px; appearance: none; border: 0; background: #303030; }
#public-position::-webkit-progress-bar { background: #303030; }
#public-position::-webkit-progress-value { background: var(--accent); }
#public-position::-moz-progress-bar { background: var(--accent); }
.admin-dialog { width: min(420px,calc(100% - 32px)); padding: 24px; border: 1px solid #555; border-radius: 8px; background: var(--panel); color: var(--text); box-shadow: 0 24px 100px #000a; }
.admin-dialog::backdrop { background: #000b; }
.admin-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.admin-dialog form { display: grid; gap: 14px; margin-top: 24px; }
.admin-dialog form button { justify-self: start; }
.admin-dialog .error:empty { display: none; }
#admin-preview { margin-top: 24px; }
@media(max-width:800px) {
  .visitor-mode .player-bar { --player-height: 102px; }
  .visitor-mode .player-tools .icon-button { width: 36px; }
}

/* Owner access stays in the existing compact dialog. */
#passkey-controls > button {width:100%;margin:8px 0 16px}
#passkey-setup {border-top:1px solid var(--line,#333);padding-top:14px}
#passkey-setup summary {cursor:pointer;color:var(--muted,#aaa);font-size:.85rem}
#passkey-register {margin-top:18px}
#passkey-error:empty {display:none}
