/* Desktop tokens: prototype/ui_widgets.py; layout: frontend.py. */
:root{color-scheme:dark;--bg:#1c1e1b;--panel:#242722;--side:#181b18;--line:#41463d;--text:#eeeae1;--muted:#b0b5a9;--accent:#b8c6a3;--active:#343e2e;--gold:#d7c4a4;--sidebar:220px;font:15px/1.5 -apple-system,BlinkMacSystemFont,"Source Han Sans SC","Microsoft YaHei",sans-serif}*{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--text);height:100vh;height:100dvh;display:flex;flex-direction:column;overflow:hidden}button,input{font:inherit}button{min-height:44px;padding:9px 20px;border:1px solid var(--line);border-radius:0;background:var(--panel);color:var(--text);cursor:pointer;touch-action:manipulation}button:hover{background:var(--active)}button:disabled{opacity:.45;cursor:not-allowed}button.primary{background:var(--accent);color:var(--bg);border-color:var(--accent)}button[aria-pressed=true],button.active,button.held{background:var(--active);color:var(--accent);border-color:var(--accent)}button:focus-visible,input:focus-visible,a:focus-visible{outline:2px solid var(--gold);outline-offset:3px}.term{border:0;background:transparent;padding:4px 0;min-height:32px;text-decoration:underline;text-underline-offset:3px;color:var(--muted);font-size:13px}.term:hover{background:transparent;color:var(--text)}.top{height:78px;flex-shrink:0;display:flex;justify-content:space-between;align-items:center;gap:18px;padding:12px 24px;border-bottom:1px solid var(--line)}.brand{display:flex;align-items:center;gap:14px;text-decoration:none;color:var(--text);white-space:nowrap}.brand-icon{font-size:38px;line-height:1;color:var(--accent)}.brand strong{font-size:28px;font-weight:650}.brand-name{color:var(--muted);font-size:15px;margin-left:4px}.header-actions{display:flex;gap:8px}.layout{display:flex;min-height:0;flex:1}.sidebar{background:var(--side);width:var(--sidebar);flex-shrink:0;padding:22px 12px 12px;display:flex;flex-direction:column;overflow:auto}.section-label{font-size:13px;color:var(--muted);padding:0 10px;margin-bottom:18px}#modes{display:flex;flex-direction:column;gap:5px}.mode{display:flex;align-items:center;gap:10px;text-align:left;border:0;background:transparent;min-height:48px;padding:10px 12px;font-size:15px;white-space:nowrap}.mode .number{font-variant-numeric:tabular-nums}.mode.active{background:var(--active)}.mode.unavailable{color:#8b9184}.soon{font-size:9px;margin-left:auto}.sidebar-bottom{margin-top:auto;padding-top:22px;display:flex;flex-direction:column;align-items:stretch;gap:8px}.sidebar-bottom .term{text-align:left;padding-left:10px}.right-pane{flex:1;min-width:0;display:flex;flex-direction:column}.workspace{flex:1;min-height:0;overflow:auto;padding:24px 28px 30px;scrollbar-color:var(--line) var(--bg);scrollbar-gutter:stable}.empty-state{display:flex;justify-content:space-between;align-items:center;gap:16px;padding:18px 22px;background:var(--panel);margin-bottom:22px}.empty-state h2{font-size:19px;margin:0;font-weight:500}.empty-state p{font-size:12px;color:var(--muted);margin:6px 0 0}.empty-state[hidden]{display:none}.editor-heading{display:flex;align-items:center;justify-content:space-between;gap:16px}.title-line{display:flex;align-items:center;gap:16px;flex-wrap:wrap}h1{font-size:30px;line-height:1.35;margin:0;font-weight:600}.rate{margin:4px 0 6px}.rate[hidden]{display:none}.visual{margin:6px 0 22px}.visual-top{display:flex;align-items:center;justify-content:space-between;gap:12px}.visual-switch{display:flex;gap:5px}.visual-switch button{min-width:104px}.visual-meta{display:flex;align-items:center;justify-content:space-between;gap:14px;font-size:12px;color:var(--muted);margin:12px 12px 2px 38px}.legend{white-space:nowrap;color:var(--accent)}.legend i{display:inline-block;width:8px;height:2px;background:var(--accent);vertical-align:middle;margin:0 4px 0 14px}.legend i:last-child{background:var(--gold)}#scope{display:block;width:100%;height:clamp(190px,25vh,280px)}.visual-bottom{display:flex;justify-content:space-between;gap:12px;color:var(--muted);font-size:11px;margin-left:38px;margin-top:3px}.parameters{padding:0 0 14px}.parameter{margin:14px 0 18px}.parameter-top{display:flex;justify-content:space-between;align-items:center;gap:12px}.parameter-top label{color:var(--muted);font-size:14px;text-decoration:underline;text-underline-offset:3px}.parameter-top output{color:var(--gold);font-size:22px;font-variant-numeric:tabular-nums}.parameter input{width:100%;margin:0}.range-labels{display:flex;justify-content:space-between;color:var(--muted);font-size:12px}.presets{display:flex;gap:6px;flex-wrap:wrap;margin-top:10px}.presets button{font-size:12px;padding:6px 15px}.original-note{font-size:14px;color:var(--muted);padding:10px 0}.original-note strong{font-weight:400;display:block}.original-note strong+*{display:none}input[type=range]{--fill:0%;appearance:none;-webkit-appearance:none;background:transparent;min-height:36px;cursor:pointer;touch-action:pan-y}input[type=range]::-webkit-slider-runnable-track{height:4px;border-radius:4px;background:linear-gradient(to right,var(--accent) var(--fill),var(--line) var(--fill))}input[type=range]::-webkit-slider-thumb{appearance:none;-webkit-appearance:none;width:14px;height:14px;border:0;border-radius:50%;background:var(--accent);margin-top:-5px}input[type=range]::-moz-range-track{height:4px;background:var(--line)}input[type=range]::-moz-range-progress{height:4px;background:var(--accent)}input[type=range]::-moz-range-thumb{width:14px;height:14px;border:0;border-radius:50%;background:var(--accent)}.transport{flex-shrink:0;padding:12px 26px max(10px,env(safe-area-inset-bottom));background:var(--bg);position:relative}.transport:before{content:"";position:absolute;top:0;left:26px;right:26px;height:1px;background:var(--line)}.track-line{display:flex;justify-content:space-between;align-items:center;gap:15px;font-size:14px}.track-line #track-name{min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}#time{white-space:nowrap;font-size:12px;color:var(--muted);font-variant-numeric:tabular-nums}.wave-seek{height:44px;position:relative;margin:4px 0}.wave-seek canvas{width:100%;height:100%;display:block}.wave-seek input{position:absolute;inset:0;width:100%;height:100%;margin:0;opacity:0;touch-action:none}.wave-seek:focus-within{outline:1px solid var(--gold)}.transport-bottom{display:flex;gap:14px;align-items:center;flex-wrap:wrap}.play-actions,.compare{display:flex;gap:5px;align-items:center}.play-actions button,.compare button{padding:8px 15px}.play-actions #restart{padding:8px 12px}.play-actions #play{min-width:78px}#hold{user-select:none;-webkit-user-select:none;-webkit-touch-callout:none;touch-action:none}.volume{margin-left:auto;display:flex;align-items:center;gap:9px;white-space:nowrap;font-size:12px;color:var(--muted)}.volume input{width:90px}.volume output{width:30px;text-align:right}.transport-status{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-top:6px;font-size:11px;color:var(--muted)}#compare-label{color:var(--accent);margin-left:12px}.transport-status .term{font-size:11px;min-height:24px}.notice{font-size:11px;color:var(--muted);line-height:1.5;max-height:36px;overflow:auto}.notice.error{color:#edb3a3}.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap}dialog{background:var(--panel);color:var(--text);border:1px solid var(--line);width:min(540px,calc(100% - 32px));max-height:85dvh;padding:24px}dialog::backdrop{background:#0009}.dialog-header{display:flex;justify-content:space-between;align-items:center;gap:16px}.dialog-header h2{font-size:22px;margin:0}.dialog-header button{border:0;padding:4px 12px;font-size:22px}#dialog-content{white-space:pre-line;line-height:1.9;font-size:14px;color:var(--muted);margin:20px 0}#settings-dialog p,#settings-dialog small{font-size:13px;line-height:1.8;color:var(--muted)}.loop{display:flex;align-items:center;gap:8px;min-height:48px;margin:14px 0}.loop input{width:18px;height:18px;accent-color:var(--accent)}

/* Touch-sized controls and safe-area insets apply to every layout. */
:root{--dock-height:230px}
.top{padding-left:max(24px,env(safe-area-inset-left));padding-right:max(24px,env(safe-area-inset-right))}
button,.term,.transport-status .term{min-height:44px}
input[type=range]{min-height:44px}
input[type=range]::-webkit-slider-thumb{width:22px;height:22px;margin-top:-9px}
input[type=range]::-moz-range-thumb{width:22px;height:22px}
.workspace{scroll-padding-block:20px;overscroll-behavior-y:contain}
.transport{padding-right:max(22px,env(safe-area-inset-right));padding-bottom:calc(8px + env(safe-area-inset-bottom))}
.transport-status .term{min-height:32px;padding:4px 8px}
.notice:empty{display:none}
#compare-help{min-width:44px;text-align:center}
.visual-bottom,.visual-meta{flex-wrap:wrap}
.mode.unavailable .soon{display:inline;font-size:10px}
.sidebar-bottom{gap:6px}
.parameter{margin:12px 0 20px}
.parameter-top label{font-size:15px}
.presets button{min-width:56px}
@media(min-width:981px) and (max-width:1400px){
 :root{--sidebar:180px}
 .sidebar{padding:18px 8px 10px}.mode{font-size:13px;gap:6px;padding:10px 8px;min-height:48px}
 .mode.unavailable{flex-wrap:wrap;row-gap:0}.mode .soon{margin-left:24px}
 .workspace{padding:20px 24px}.transport{padding-left:24px}
 .transport-bottom{gap:8px}.play-actions button,.compare button{padding:9px 12px}
 .volume input{width:90px}
}
@media(min-width:981px) and (orientation:landscape) and (max-height:900px){
 .top{height:70px}.workspace{padding-top:16px;padding-bottom:20px}
 #scope{height:clamp(140px,20vh,180px)}
 .visual{margin-bottom:12px}.visual-meta{margin-top:6px}
 .parameter{margin:8px 0 12px}.parameter-top output{font-size:22px}
 .rate{margin:0}.transport{padding-top:8px}.wave-seek{height:44px;margin:0}
 .transport-status{margin-top:2px}
}
/* Portrait tablets and narrow split views: modes and editor share the full width.
   The sole scrolling pane reserves the measured player height, including safe area. */
@media(max-width:980px),(max-width:1100px) and (orientation:portrait){
 .top{height:76px;padding:12px max(22px,env(safe-area-inset-right)) 12px max(22px,env(safe-area-inset-left))}
 .brand strong{font-size:26px}.brand-name{font-size:14px}
 .layout{display:block;overflow-y:auto;overflow-x:hidden;overscroll-behavior-y:contain;scroll-padding-top:16px;scroll-padding-bottom:calc(var(--dock-height) + 16px);padding-bottom:calc(var(--dock-height) + 24px)}
 .sidebar{width:auto;overflow:visible;padding:18px 24px 12px;border-bottom:1px solid var(--line)}
 .section-label{padding:0;margin-bottom:12px}
 #modes{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}
 .mode{border:1px solid var(--line);font-size:14px;min-height:52px;padding:10px 12px;gap:8px;white-space:normal;flex-wrap:wrap;row-gap:2px}
 .mode .number{font-size:11px;color:var(--muted)}.mode .soon{margin-left:auto}
 .sidebar-bottom{margin-top:10px;padding:0;flex-direction:row;justify-content:space-between;align-items:center}
 .sidebar-bottom .term{padding-left:0}.sidebar-bottom>button{padding:8px 16px}
 .right-pane{display:contents}
 .workspace{overflow:visible;scrollbar-gutter:auto;padding:24px;min-height:auto}
 h1{font-size:30px}.title-line{gap:14px}
 #scope{height:clamp(190px,22vh,270px)}
 .visual{margin:8px 0 24px}.visual-switch{gap:8px}.visual-switch button{min-height:48px;min-width:116px}
 .visual-meta{margin-top:12px;font-size:12px}.visual-bottom{font-size:11px}
 .parameter{margin:20px 0 24px}.parameter input{min-height:52px}
 .transport{position:fixed;bottom:0;left:0;right:0;z-index:10;border-top:1px solid var(--line);padding:10px max(24px,env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(24px,env(safe-area-inset-left));box-shadow:0 -8px 20px #0002}
 .transport:before{display:none}
 .transport-bottom{display:grid;grid-template-columns:auto 1fr;gap:8px 16px}
 .play-actions{gap:6px}.play-actions button,.compare button{min-height:48px;padding:9px 16px}
 .compare{justify-content:flex-end;gap:6px}.volume{grid-column:1/-1;justify-content:flex-end;width:100%;gap:12px;font-size:13px}
 .volume input{width:160px;min-height:44px}.volume output{width:36px}
 .wave-seek{height:44px;margin:2px 0}.transport-status{margin-top:0}
 .empty-state{padding:18px;gap:14px}.empty-state h2{font-size:19px}
}
@media(max-width:600px){
 .top{height:68px;padding:10px max(14px,env(safe-area-inset-right)) 10px max(14px,env(safe-area-inset-left));gap:8px}
 .brand{gap:7px}.brand strong{font-size:23px}.brand-icon{font-size:30px}.brand-name{display:none}
 .header-actions{gap:6px}.header-actions button{padding:8px 12px;font-size:12px}
 .sidebar{padding:14px 14px 10px}#modes{gap:6px}.section-label{font-size:12px;margin-bottom:8px}
 .mode{font-size:12px;padding:8px 4px;min-height:48px;justify-content:center;gap:3px}.mode .number{display:none}.mode.unavailable{flex-direction:column}.mode .soon{margin:0;font-size:9px}
 .sidebar-bottom{margin-top:8px}.sidebar-bottom button{font-size:12px;padding:8px 10px}
 .workspace{padding:18px 14px 24px}.editor-heading{gap:8px;align-items:flex-start}.editor-heading>button{font-size:12px;padding:8px 12px}
 .title-line{gap:2px;flex-direction:column;align-items:flex-start}h1{font-size:25px}.title-line .term{font-size:12px}
 .visual-top{gap:4px;flex-wrap:wrap}.visual-switch{gap:5px;flex:1}.visual-switch button{min-width:0;flex:1;font-size:12px;padding:8px 10px}.visual-top>.term{font-size:12px;margin-left:auto}
 .visual-meta{margin-left:30px;font-size:11px;gap:6px}.legend i{margin-left:5px}#scope{height:200px}.visual-bottom{font-size:10px;margin-left:30px}
 .parameter-top label{font-size:14px}.parameter-top output{font-size:22px}
 .empty-state{flex-wrap:wrap}.empty-state>button{width:100%}
 .transport{padding:8px max(14px,env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(14px,env(safe-area-inset-left))}
 .track-line{font-size:12px}#time{font-size:10px}.wave-seek{height:44px}
 .transport-bottom{gap:4px 6px;grid-template-columns:1fr}.play-actions{grid-column:1;grid-row:1;justify-content:flex-start}
 .compare{grid-column:1;grid-row:2;justify-content:flex-start}.play-actions button,.compare button{padding:8px 14px;min-height:44px;font-size:13px}
 .volume{grid-column:1;grid-row:3;min-width:0;gap:8px}.volume input{width:clamp(100px,35vw,180px)}
 .transport-status{font-size:10px;gap:4px}.transport-status .term{font-size:10px}.notice{font-size:10px;max-height:30px}
}
@media(min-width:390px) and (max-width:600px){
 .transport-bottom{grid-template-columns:auto 1fr}.play-actions{grid-column:1;grid-row:1}
 .compare{grid-column:1/-1;grid-row:2;justify-content:space-between}.compare button:not(.term){flex:1}
 .volume{grid-column:2;grid-row:1;justify-content:flex-end;font-size:11px}.volume input{width:clamp(65px,15vw,90px)}.volume output{width:28px}
}
@media(max-height:520px) and (orientation:landscape){
 .top{height:60px}.transport .wave-seek{height:44px}.visual{margin-bottom:12px}#scope{height:150px}
 .transport-bottom{display:flex;flex-wrap:wrap;gap:4px 8px}.volume{width:auto;margin-left:auto}.volume input{width:80px}
 .play-actions button,.compare button{min-height:44px;padding:8px 10px}
}

/* The library uses the same modal and touch sizes as the editor. */
.empty-actions{display:flex;gap:8px;flex-shrink:0;flex-wrap:wrap}
#library-dialog{width:min(820px,calc(100% - 32px));overflow-y:auto;overscroll-behavior:contain}
.library-intro,#library-status{font-size:13px;line-height:1.7;color:var(--muted)}
#library-tracks{display:grid;gap:12px;margin:20px 0}
.library-track{display:flex;align-items:center;gap:16px;padding:14px;border:1px solid var(--line);background:var(--bg)}
.library-cover{width:80px;height:80px;object-fit:cover;flex-shrink:0;border-radius:5px;background:var(--panel)}
.library-category{display:block;color:var(--accent);font-size:11px;letter-spacing:.08em;margin-bottom:5px}
.library-credits{display:flex;flex-wrap:wrap;gap:8px 20px;font-size:11px;color:var(--muted)}
.library-credits a{color:var(--accent);text-underline-offset:3px}
.library-track.current{border-color:var(--accent)}
.library-track-info{flex:1;min-width:0}.library-track h3{font-size:18px;font-weight:500;margin:0 0 6px;overflow-wrap:anywhere}
.library-track p{margin:0;font-size:12px;color:var(--muted)}.library-track button{flex-shrink:0;min-width:100px}
.library-current{display:inline-block;color:var(--accent);font-size:11px;margin-top:6px}
#library-cancel[hidden]{display:none}
@media(max-width:1100px){.empty-state{flex-wrap:wrap}.empty-actions{flex-shrink:1}}
@media(max-width:600px){
 .top{height:auto;min-height:106px;flex-wrap:wrap;padding-top:8px;padding-bottom:8px;row-gap:6px}
 .brand{width:100%}.brand-name{display:inline;font-size:12px}.brand strong{font-size:22px}.brand-icon{font-size:26px}
 .header-actions{width:100%;display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px}.header-actions button{padding:8px 4px}
 .empty-actions{display:grid;width:100%;grid-template-columns:1fr;gap:8px}
 #library-dialog{width:calc(100% - 20px);max-height:calc(100dvh - 24px);padding:18px}
 .library-track{padding:12px;gap:12px;display:grid;grid-template-columns:64px minmax(0,1fr)}.library-cover{width:64px;height:64px}.library-track h3{font-size:17px}.library-track-info{min-width:0}.library-track button{width:100%;grid-column:1/-1}.library-track p{line-height:1.6}
}

.parameter-note{font-size:12px;line-height:1.7;color:var(--muted);margin:10px 0 0}
