:root { --panel-solid: #fafafa; --control-accent: #007f78; }
:root[data-theme="dark"] { --panel-solid: #101019; --control-accent: #70d8cb; }
[hidden] { display: none !important; }

.panel.panel--right, .panel.panel--left {
	box-sizing: border-box;
	width: 248px;
	padding: 14px;
	gap: 14px;
	max-height: calc(100dvh - 40px);
	background: var(--panel-solid);
	color: var(--ink);
	backdrop-filter: none;
	border-radius: 8px;
}
.panel.panel--right { overflow-x: hidden; overflow-y: auto; overscroll-behavior-y: contain; height: min(650px, calc(100dvh - 40px)); scrollbar-width: thin; scrollbar-color: var(--dim2) transparent; }
.control-navigation { position: sticky; top: 0; z-index: 2; display: flex; flex-direction: column; flex-shrink: 0; gap: 14px; background: var(--panel-solid); }
.panel-heading-title, .control-tab, .volume-label, .sampler-title { text-transform: uppercase; }
#planetTip { z-index: 9; }
.panel-heading { display: flex; align-items: center; gap: 8px; flex-shrink: 0; min-height: 36px; }
.panel-heading-title { font-size: 14px; font-weight: 500; margin: 0; flex: 1; letter-spacing: 0; }
.panel-heading .pad--release { width: auto; height: 36px; padding: 0 10px; font-size: 10px; letter-spacing: 0; }
.panel-close { display: none; width: 44px; height: 44px; border: 0; background: transparent; color: var(--ink); font-family: inherit; font-size: 24px; line-height: 1; cursor: pointer; }
.control-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); flex-shrink: 0; border-bottom: 1px solid var(--border-strong); }
.control-tab { min-width: 0; min-height: 44px; padding: 0 2px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--dim2); font: 11px/1.3 "IBM Plex Mono", monospace; cursor: pointer; }
.control-tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--control-accent); }
.control-tab:focus-visible, .panel button:focus-visible, .mobile-dock-button:focus-visible, .pad-sampler summary:focus-visible { outline: 2px solid var(--control-accent); outline-offset: 2px; }
.panel--right #extras { display: block; flex: 1 0 auto; overflow: visible; min-height: auto; padding: 0 2px; margin: 0 -2px; border: 0; }
.control-pane { display: flex; flex-direction: column; gap: 18px; padding: 2px 0 8px; }
.panel--right .control-group { gap: 8px; }
.panel--right #extras .pad--release { min-height: 44px; height: auto; font-size: 12px; letter-spacing: 0; }
.panel--right #extras .mode-toggle {
	position: relative;
	text-align: left;
	padding: 10px 48px 10px 10px;
	border: 1px solid var(--border);
	border-radius: 6px;
	background: transparent;
	color: var(--ink);
	font-weight: 400;
}
.mode-toggle::after { content: ''; position: absolute; right: 9px; top: calc(50% - 9px); width: 30px; height: 18px; border-radius: 10px; background: var(--track); }
.mode-toggle::before { content: ''; position: absolute; z-index: 1; right: 23px; top: calc(50% - 6px); width: 12px; height: 12px; border-radius: 50%; background: var(--dim2); transition: transform 140ms ease; }
.mode-toggle.is-active::after { background: var(--control-accent); }
.mode-toggle.is-active::before { transform: translateX(12px); background: var(--panel-solid); }
.mode-toggle[aria-busy="true"]::after { opacity: 0.45; }
.panel--right .journey-row { gap: 6px; }
.panel--right .journey-option, .panel--right .time-mode-row .journey-option { height: 40px; font-size: 11px; letter-spacing: 0; border-radius: 6px; }
.panel--right .time-mode-row { margin-top: 2px; }
.panel--right .waves { gap: 6px; padding: 0; }
.panel--right .waves-title { margin: 0 0 5px; font-size: 10px; letter-spacing: 0; }
.panel--right .wave { width: 100%; min-width: 0; height: 76px; padding: 6px 2px; flex-direction: column; gap: 5px; border-radius: 6px; }
.panel--right .wave-text { display: flex; align-items: center; gap: 2px; }
.panel--right .wave-symbol { font-size: 18px; }
.panel--right .wave-label { font-size: 10px; letter-spacing: 0; }
.panel--right .wave-hz { font-size: 8px; letter-spacing: 0; }
.panel--right .extras-row { gap: 8px; min-height: 44px; }
.panel--right .extras-label { font-size: 10px; letter-spacing: 0; }
.panel--right .pad-size, .pad-sampler .pad-size {
	height: 44px;
	min-width: 0;
	background: linear-gradient(to right, var(--control-accent) 0 var(--range-fill, 0%), var(--track) var(--range-fill, 0%) 100%) center / 100% 4px no-repeat;
}
.panel--right .pad-size::-webkit-slider-thumb, .pad-sampler .pad-size::-webkit-slider-thumb { width: 20px; height: 20px; }
.panel--right .pad-size::-moz-range-thumb, .pad-sampler .pad-size::-moz-range-thumb { width: 20px; height: 20px; }
.master-volume { display: grid; grid-template-columns: 1fr auto; align-items: center; font-size: 11px; gap: 0 8px; padding-top: 14px; border-top: 1px solid var(--border); }
.master-volume input { grid-column: 1 / -1; width: 100%; margin: 0; }
.volume-value { font-size: 10px; color: var(--dim2); font-variant-numeric: tabular-nums; }
.control-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; flex-shrink: 0; padding-top: 12px; border-top: 1px solid var(--border); }
.control-actions .pad--release { height: 40px; padding: 0 6px; font-size: 11px; letter-spacing: 0; min-width: 0; border-radius: 6px; }
.control-record { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; }
.control-record > button { flex: 1; width: auto; }
.control-record .extras-row { flex: 0 0 auto; width: auto; min-height: 40px; }
.control-record .extras-label { display: none; }
.control-record button:not(.pad--release) { min-width: 44px; min-height: 40px; }
.pad-sampler { border-top: 1px solid var(--border); padding-top: 8px; flex-shrink: 0; }
.pad-sampler summary { min-height: 40px; display: flex; align-items: center; justify-content: space-between; cursor: pointer; font-size: 11px; list-style: none; }
.pad-sampler summary::-webkit-details-marker { display: none; }
.pad-sampler summary::after { content: '+'; font-size: 18px; }
.pad-sampler[open] summary::after { content: '−'; }
.pad-sampler .extras-row { display: flex; align-items: center; gap: 8px; }
.pad-sampler .extras-label { font-size: 10px; letter-spacing: 0; }
.pad-sampler .pad-size { flex: 1; }
.panel--left .midi-status { font-size: 9px; letter-spacing: 0; }
.panel--left .pad-col { grid-template-columns: 36px minmax(32px, 1fr) 28px 28px; gap: 6px; }
.panel--left .pad-col .pad { width: 36px; height: 36px; }
.panel--left .pad-load, .panel--left .pad-grain { width: 28px; height: 32px; }

@media (max-width: 720px), (pointer: coarse) {
	.mobile-dock { left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom, 0px)); width: auto; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
	.mobile-dock-button { width: 100%; height: 44px; font-size: 11px; letter-spacing: 0; background: var(--panel-solid); backdrop-filter: none; }
	.panel.panel--right, .panel.panel--left { width: auto; left: 12px; right: 12px; top: auto; bottom: calc(66px + env(safe-area-inset-bottom, 0px)); max-height: min(76dvh, 670px); padding: 12px 14px; gap: 12px; border-radius: 8px; }
	.panel.panel--right { height: min(76dvh, 670px); }
	.control-navigation { gap: 12px; }
	:root[data-mobile-panel="left"] #planetTip,
	:root[data-mobile-panel="right"] #planetTip { opacity: 0; visibility: hidden; }
	.panel-close { display: inline-grid; place-items: center; }
	.panel--right .panel-heading .pad--release { display: none; }
	.panel-heading-title { font-size: 16px; }
	.control-tab { font-size: 12px; }
	.panel--right #extras .pad--release { font-size: 13px; }
	.panel--right .journey-option, .panel--right .time-mode-row .journey-option { height: 44px; font-size: 12px; }
	.panel--right .wave-label { font-size: 12px; }
	.panel--right .wave-hz { font-size: 9px; }
	.control-actions .pad--release, .control-record button:not(.pad--release) { min-height: 44px; }
	.panel--left .pad-col { grid-template-columns: 40px minmax(20px, 1fr) 28px; gap: 6px; }
	.panel--left .pad-col .pad { grid-row: 1 / 3; width: 40px; height: 70px; border-radius: 6px; }
	.panel--left .pad-col .pad-size { grid-column: 2 / 4; grid-row: 1; width: 100%; height: 30px; background-size: 100% 4px; background-repeat: no-repeat; background-position: center; }
	.panel--left .pad-load, .panel--left .pad-grain { grid-row: 2; width: 100%; height: 34px; }
	.panel--left .pad-presets .pad-preset { height: 40px; }
}
@media (pointer: coarse) and (orientation: landscape) {
	.panel.panel--right { left: auto; width: min(370px, calc(60vw - 24px)); top: 12px; height: auto; max-height: none; }
	.panel.panel--left { right: auto; width: min(400px, calc(65vw - 24px)); top: 12px; max-height: none; }
	.panel.panel--right, .panel.panel--left { gap: 6px; padding: 8px 12px; }
	.control-navigation { gap: 6px; }
	.control-actions { padding-top: 6px; gap: 6px; }
	.panel-heading { min-height: 32px; }
	.panel-close { height: 32px; }
}
