/* The Audio Editor (/audio-editor) and Music Studio (/music-studio), one app
   in two modes (#as-app[data-mode]). It wears Video Studio's
   frame and panels (video-studio.css): menus and Export along the top, then
   the transport, then the library, the tracks and the settings in a row,
   with the piano roll under the tracks when it is open. On a phone the
   library and the settings become sheets opened from tabs along the bottom. */

/* ---- Start screen ---- */
.as-new .st-new-row + .st-new-row { margin-top: 12px; }
.as-new .st-new-row > .st-field { flex: 0 0 auto; }
.as-new #as-new-tempo { width: 96px; }
.as-other { margin: 14px 0 0; color: var(--muted); font-size: 0.86rem; text-align: center; }

/* ---- The frame ---- */
.as-work { grid-template-rows: auto auto minmax(0, 1fr); }
.as-body { grid-template-columns: 286px minmax(0, 1fr) 286px; }
.as-main { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); min-width: 0; min-height: 0; }
.as-work.has-roll .as-main { grid-template-rows: auto minmax(120px, 1fr) minmax(200px, 46%); }

.as-menu { max-height: 70vh; overflow-y: auto; scrollbar-width: thin; }
.as-menu-head { margin: 6px 10px 2px; color: var(--accent-strong); font-family: var(--mono); font-size: 0.62rem; letter-spacing: 0.08em; text-transform: uppercase; }

/* ---- Transport ---- */
.as-transport { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 5px 10px; background: var(--surface); border-bottom: 1px solid var(--border); }
.as-tp-btns, .as-tp-opts { display: flex; align-items: center; gap: 3px; flex: none; }
.as-tp-opts { margin-left: auto; }
.as-transport .vs-play { margin: 0 2px; }
.as-rec { display: grid; place-items: center; }
.as-rec-dot { display: block; width: 13px; height: 13px; background: #ef4f4f; border-radius: 50%; }
.as-app.is-recording .as-rec { background: rgba(239, 79, 79, 0.18); }
.as-app.is-recording .as-rec-dot { animation: vs-blink 1s steps(2, start) infinite; }
.as-clock { display: flex; flex-direction: column; gap: 1px; margin: 0; padding: 3px 12px; background: #0b0914; border: 1px solid var(--border); border-radius: 0; font-family: var(--mono); font-variant-numeric: tabular-nums; line-height: 1.15; }
.as-now { color: var(--text); font-size: 0.95rem; }
.as-bbt { color: var(--muted); font-size: 0.68rem; }
.as-tempo { display: inline-flex; align-items: center; gap: 4px; margin: 0 2px 0 6px; }
.as-tempo .vs-num { width: 64px; }
.as-sig { width: auto; min-width: 64px; }
.as-timebase { min-width: 52px; }
.as-timebase[aria-pressed="true"] { color: var(--tint-text); background: var(--tint); border-color: var(--tint-border); }
.as-master { position: relative; width: 70px; height: 8px; margin-left: 8px; overflow: hidden; background: #0b0914; border: 1px solid var(--border); border-radius: 0; }
.as-master span, .as-in-meter span { display: block; width: 0; height: 100%; background: linear-gradient(90deg, #2ec4b6 0 70%, #e8b44f 70% 90%, #ef4f4f 90%); background-size: 70px 100%; transition: width 60ms linear; }
.as-master span.is-hot, .as-in-meter.is-hot span { box-shadow: inset -4px 0 0 #ef4f4f; }

/* ---- Tracks ---- */
.as-tl { min-width: 0; min-height: 0; background: var(--bg-deep); }
.as-tl-scroll { position: relative; height: 100%; overflow: auto; scrollbar-width: thin; scrollbar-color: var(--border) transparent; overscroll-behavior: contain; }
.as-tl-grid { position: relative; min-width: 100%; min-height: 100%; padding-bottom: 10px; }
.as-ruler-row { position: sticky; top: 0; z-index: 6; display: flex; height: 30px; background: var(--surface); border-bottom: 1px solid var(--border); }
.as-ruler-corner { position: sticky; left: 0; z-index: 1; flex: 0 0 var(--head, 214px); background: var(--surface); border-right: 1px solid var(--border); }
.as-ruler { display: block; height: 30px; cursor: ew-resize; touch-action: none; }
.as-loopmark { position: absolute; top: 0; height: 9px; z-index: 2; background: rgba(155, 148, 184, 0.35); border-radius: 0; pointer-events: none; }
.as-loopmark.is-on { background: rgba(232, 180, 79, 0.85); }
.as-loopmark[hidden] { display: none; }
.as-rows { display: flex; flex-direction: column; }
.as-row { display: flex; border-bottom: 1px solid var(--border-soft, rgba(255, 255, 255, 0.05)); }
.as-row.is-moving { position: relative; z-index: 6; opacity: 0.85; box-shadow: var(--hard); cursor: grabbing; }
.as-head { position: sticky; left: 0; z-index: 4; display: flex; flex-direction: column; justify-content: center; gap: 5px; flex: 0 0 var(--head, 214px); padding: 4px 8px 4px 12px; overflow: hidden; color: var(--muted); background: var(--surface); border-right: 1px solid var(--border); box-shadow: inset 4px 0 0 var(--tc); font-size: 0.74rem; cursor: pointer; }
.as-row.is-current .as-head { color: var(--text); background: var(--surface-2); }
.as-head-row { display: flex; align-items: center; gap: 4px; min-width: 0; }
.as-head-icon { display: grid; place-items: center; flex: none; color: var(--tc); }
.as-head-name { flex: 1 1 auto; min-width: 0; overflow: hidden; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.as-head-rename { flex: 1 1 auto; min-width: 0; padding: 1px 5px; color: var(--text); background: var(--surface-2); border: 1px solid var(--accent); border-radius: 0; font: inherit; }
.as-head-inst { flex: 0 1 auto; min-width: 0; overflow: hidden; color: var(--muted); font-size: 0.68rem; text-overflow: ellipsis; white-space: nowrap; }
.as-hb { display: grid; place-items: center; flex: none; width: 22px; height: 20px; padding: 0; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); border-radius: 0; font: inherit; font-size: 0.66rem; font-weight: 700; cursor: pointer; }
.as-hb.is-m.is-on { color: #14111f; background: #e8b44f; border-color: #e8b44f; }
.as-hb.is-s.is-on { color: #14111f; background: #2ec4b6; border-color: #2ec4b6; }
.as-hb.is-r.is-on { color: #fff; background: #ef4f4f; border-color: #ef4f4f; }
.as-hb.is-i.is-on { color: #07040d; background: #5ad1e6; border-color: #5ad1e6; }
.as-hb.is-view.is-on { color: var(--tint-text); background: var(--tint); border-color: var(--tint-border); }
.as-hb:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.as-vol { flex: 1 1 auto; min-width: 30px; }
.as-meter { display: grid; gap: 1px; height: 5px; overflow: hidden; background: #0b0914; border-radius: 0; }
/* Left over right, one green-amber-red run across the meter's width, cut off at the level. */
.as-meter-l { display: block; background: linear-gradient(90deg, #2ec4b6 0 70%, #e8b44f 70% 90%, #ef4f4f 90%); clip-path: inset(0 100% 0 0); }
.as-meter-l.is-hot { box-shadow: inset -4px 0 0 #ef4f4f; }
.as-head-size { position: absolute; left: 0; right: 0; bottom: -2px; height: 6px; cursor: ns-resize; touch-action: none; }
.as-head { position: sticky; }
.as-lane { position: relative; flex: none; height: 100%; }
.as-row.is-muted .as-lane { opacity: 0.45; }
.as-row.is-current .as-lane { background-color: rgba(139, 92, 246, 0.04); }
.as-lane-hint { position: absolute; left: 12px; top: 50%; margin: 0; color: var(--faint); font-size: 0.76rem; transform: translateY(-50%); white-space: nowrap; pointer-events: none; }
.as-range { position: absolute; top: 0; bottom: 0; z-index: 3; background: rgba(255, 255, 255, 0.16); box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.7), inset -1px 0 0 rgba(255, 255, 255, 0.7); pointer-events: none; }

.as-clip { position: absolute; top: 2px; bottom: 2px; overflow: hidden; color: #fff; background: color-mix(in srgb, var(--tc) 30%, #14111f); border: 1px solid color-mix(in srgb, var(--tc) 60%, transparent); border-radius: 0; outline: none; }
.as-clip.is-midi { background: color-mix(in srgb, var(--tc) 22%, #14111f); }
.as-clip.is-muted { opacity: 0.45; }
.as-clip.is-picked { z-index: 2; border: 2px solid #fff; box-shadow: 0 0 0 2px var(--accent); }
.as-clip.is-dragging { z-index: 4; opacity: 0.85; box-shadow: 3px 3px 0 var(--edge); }
.as-clip.is-recording { background: rgba(239, 79, 79, 0.3); border-color: #ef4f4f; }
.as-clip-top { position: relative; z-index: 2; display: flex; align-items: center; gap: 6px; height: 16px; padding: 0 6px; overflow: hidden; background: color-mix(in srgb, var(--tc) 55%, #14111f); font-size: 0.66rem; line-height: 16px; white-space: nowrap; cursor: grab; touch-action: none; }
.as-clip-name { overflow: hidden; text-overflow: ellipsis; }
.as-clip-badge { margin-left: auto; font-family: var(--mono); font-size: 0.6rem; opacity: 0.85; }
.as-clip-cv { position: absolute; top: 16px; display: block; pointer-events: none; }
.as-fade, .as-xfade { position: absolute; top: 16px; bottom: 0; z-index: 1; pointer-events: none; }
.as-fade.is-in { left: 0; background: linear-gradient(to bottom right, rgba(8, 6, 16, 0.55) 50%, transparent 50.5%); }
.as-fade.is-out { right: 0; background: linear-gradient(to bottom left, rgba(8, 6, 16, 0.55) 50%, transparent 50.5%); }
.as-xfade { background: repeating-linear-gradient(135deg, rgba(232, 180, 79, 0.18) 0 4px, transparent 4px 8px); border-top: 2px solid rgba(232, 180, 79, 0.8); }
.as-xfade.is-in { left: 0; }
.as-xfade.is-out { right: 0; }
.as-fh { position: absolute; top: 17px; z-index: 3; width: 10px; height: 10px; background: #fff; border: 2px solid var(--accent); border-radius: 0; cursor: ew-resize; touch-action: none; }
.as-trim { position: absolute; top: 16px; bottom: 0; z-index: 2; width: 8px; cursor: ew-resize; touch-action: none; }
.as-trim.is-l { left: 0; }
.as-trim.is-r { right: 0; }
.as-clip.is-picked .as-trim { background: rgba(255, 255, 255, 0.5); }

.as-tl-foot { position: sticky; left: 0; display: flex; gap: 6px; width: max-content; padding: 8px 12px; }
.as-tl-foot .btn { display: inline-flex; align-items: center; gap: 5px; }
.as-tl-foot { z-index: 8; flex-wrap: wrap; align-items: flex-start; max-width: min(100vw, 560px); }
.as-add-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px; width: 100%; }
.as-add-pick[hidden] { display: none; }
.as-add-opt { display: flex; align-items: center; gap: 10px; padding: 9px 11px; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 0; font: inherit; text-align: left; cursor: pointer; }
.as-add-opt svg { flex: none; color: var(--gold); }
.as-add-opt span { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.as-add-opt small { color: var(--muted); font-size: 0.72rem; }
.as-add-opt:hover, .as-add-opt:focus-visible { border-color: var(--gold); outline: none; }
.as-playhead { position: absolute; top: 0; bottom: 0; left: 0; z-index: 7; width: 0; pointer-events: none; will-change: transform; }
.as-playhead::before { content: ""; position: absolute; top: 0; bottom: 0; left: -1px; width: 2px; background: #fff; box-shadow: 0 0 6px rgba(0, 0, 0, 0.6); }
.as-app.is-recording .as-playhead::before { background: #ef4f4f; }
.as-playhead-knob { position: sticky; top: 0; display: block; width: 14px; height: 14px; margin-left: -7px; background: #fff; border-radius: 0; cursor: ew-resize; pointer-events: auto; touch-action: none; }
.as-app.is-dragover .as-tl { box-shadow: inset 0 0 0 2px var(--accent-strong); }

/* ---- Piano roll ---- */
.as-roll { display: grid; grid-template-rows: auto minmax(0, 1fr); min-height: 0; background: #0b0914; border-top: 2px solid var(--accent); }
.as-roll[hidden] { display: none; }
.as-roll-bar { display: flex; align-items: center; gap: 6px; min-width: 0; padding: 4px 8px; overflow-x: auto; background: var(--surface); border-bottom: 1px solid var(--border); scrollbar-width: none; }
.as-roll-name { flex: 0 1 auto; min-width: 0; margin-right: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.as-roll-bar .seg { flex: none; margin: 0; }
.as-roll-bar .vs-select { flex: none; width: auto; }
.as-roll-vel { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 0.74rem; }
.as-roll-vel input { width: 90px; }
#as-roll-close, #as-mix-close { margin-left: auto; }
.as-steps { min-height: 0; overflow: auto; overscroll-behavior: contain; }
.as-steps[hidden], .as-roll-cv[hidden], #as-roll-view[hidden] { display: none; }
.as-steps canvas { display: block; touch-action: pan-x pan-y; cursor: pointer; }
.as-roll:not(.is-steps) #as-steps-repeat { display: none; }
.as-roll.is-steps :is(#as-roll-tool, #as-roll-snap, #as-roll-q, #as-roll-up, #as-roll-down) { display: none; }
.as-roll-cv { display: block; width: 100%; height: 100%; min-height: 0; outline: none; touch-action: none; }
.as-roll-cv:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }

/* ---- Mixer: every track as a strip, side by side, with the master at the end ---- */
.as-work.has-mix .as-main { grid-template-rows: auto minmax(120px, 1fr) minmax(250px, 46%); }
.as-mix { display: grid; grid-template-rows: auto minmax(0, 1fr); min-height: 0; background: #0b0914; border-top: 2px solid var(--accent); }
.as-mix[hidden] { display: none; }
.as-mix-hint { flex: 1 1 auto; min-width: 0; overflow: hidden; color: var(--muted); font-size: 0.72rem; text-overflow: ellipsis; white-space: nowrap; }
.as-mix-strips { display: flex; gap: 4px; min-height: 0; padding: 6px; overflow: auto; overscroll-behavior: contain; }
.as-strip { display: grid; grid-template-rows: auto auto auto minmax(60px, 1fr) auto auto; gap: 4px; flex: none; width: 82px; min-height: 0; padding: 5px; background: var(--surface); border: 1px solid var(--border); border-top: 3px solid var(--tc, var(--accent)); }
.as-strip.is-current { background: #2a2046; border-color: var(--accent); border-top-color: var(--tc, var(--accent)); }
.as-strip.is-master { border-top-color: var(--gold); margin-left: auto; }
.as-strip-name { overflow: hidden; padding: 0; color: var(--text); background: none; border: 0; font: inherit; font-size: 0.74rem; font-weight: 600; text-align: left; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.as-strip-fx { display: flex; flex-direction: column; gap: 2px; min-height: 0; max-height: 58px; overflow-y: auto; scrollbar-width: none; }
.as-strip-slot { overflow: hidden; padding: 1px 4px; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 0; font: inherit; font-size: 0.64rem; text-align: left; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.as-strip-slot.is-off { color: var(--faint); text-decoration: line-through; }
.as-strip-slot.is-add { color: var(--muted); border-style: dashed; text-align: center; }
.as-strip-pan { width: 100%; }
.as-strip-pan-head { display: flex; justify-content: space-between; color: var(--muted); font-size: 0.64rem; }
.as-strip-pan-val { color: var(--text); font-variant-numeric: tabular-nums; }
.as-strip-mid { display: flex; justify-content: center; gap: 6px; min-height: 0; }
.as-fader { position: relative; flex: none; width: 22px; min-height: 0; background: #07040d; border: 1px solid var(--border); cursor: ns-resize; touch-action: none; outline: none; }
.as-fader::before { content: ""; position: absolute; left: 50%; top: 4px; bottom: 4px; width: 2px; margin-left: -1px; background: #3b2f63; }
.as-fader:focus-visible { box-shadow: var(--focus-ring); }
.as-fader-knob { position: absolute; left: -3px; right: -3px; height: 12px; margin-top: -6px; background: #f1edfb; border: 2px solid #07040d; box-shadow: 2px 2px 0 #07040d; pointer-events: none; }
.as-fader.is-auto .as-fader-knob { background: var(--accent-strong); }
.as-fader-zero { position: absolute; left: -4px; right: -4px; height: 1px; background: var(--gold); pointer-events: none; }
.as-vmeter { display: flex; gap: 2px; flex: none; width: 12px; min-height: 0; padding: 1px; background: #07040d; }
.as-vmeter span { flex: 1; background: linear-gradient(0deg, #2ec4b6 0 70%, #e8b44f 70% 90%, #ef4f4f 90%); clip-path: inset(100% 0 0 0); }
.as-strip-db { color: var(--muted); font-family: var(--mono); font-size: 0.66rem; text-align: center; }
.as-strip-btns { display: flex; justify-content: center; gap: 3px; }

/* ---- Sampler pads ---- */
.as-pads { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.as-pad { display: grid; gap: 5px; min-width: 0; padding: 6px; background: var(--surface); border: 1px solid var(--border); }
.as-pad.is-over { border-color: var(--gold); }
.as-pad-top { display: flex; align-items: center; gap: 6px; min-width: 0; }
.as-pad-hit { flex: none; width: 34px; height: 34px; color: #14111f; background: #2ec4b6; border: 2px solid #07040d; box-shadow: 2px 2px 0 #07040d; font: inherit; font-weight: 700; cursor: pointer; touch-action: manipulation; }
.as-pad-hit:active { transform: translate(2px, 2px); box-shadow: none; }
.as-pad.is-empty .as-pad-hit { background: var(--surface-2); color: var(--muted); }
.as-pad-name { flex: 1 1 auto; min-width: 0; overflow: hidden; font-size: 0.78rem; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.as-pad-len { flex: none; color: var(--muted); font-family: var(--mono); font-size: 0.66rem; }
.as-pad-wave { display: block; width: 100%; height: 56px; cursor: ew-resize; touch-action: none; }
.as-pad-btns { display: flex; gap: 4px; flex-wrap: wrap; }
.as-pad-btns .btn { flex: 1 1 auto; padding-inline: 4px; }
.as-pad-btns .btn.is-rec { color: #fff; background: #ef4f4f; }
@media (max-width: 760px) { .as-pads { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---- Library and settings ---- */
.as-files { display: flex; flex-direction: column; gap: 6px; }
.as-file { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 5px 8px; padding: 5px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 0; cursor: grab; }
.as-file-wave { grid-column: 1 / -1; position: relative; height: 36px; overflow: hidden; background: #0b0914; border-radius: 0; }
.as-file-wave canvas { display: block; width: 100%; height: 100%; }
.as-file-btns { display: flex; align-items: center; gap: 4px; }
.as-file-btns .vs-tile-add { position: static; }
.as-file-btn { display: grid; place-items: center; width: 26px; height: 26px; padding: 0; color: var(--muted); background: transparent; border: 1px solid var(--border); border-radius: 0; cursor: pointer; }
.as-file-btn:hover, .as-file-btn:focus-visible { color: var(--text); border-color: var(--gold); outline: none; }
.as-file.is-mine .as-file-wave { background: #14100a; }
.as-loops { display: flex; flex-direction: column; gap: 5px; margin-top: 6px; }
.as-loop { display: flex; align-items: center; gap: 6px; padding-right: 5px; background: var(--surface-2); border: 1px solid var(--border); cursor: grab; }
.as-loop .vs-tile-add { position: static; flex: none; }
.as-loop-play { display: flex; flex: 1 1 auto; min-width: 0; flex-direction: column; gap: 1px; padding: 7px 10px; color: var(--text); background: none; border: 0; font: inherit; text-align: left; cursor: pointer; }
.as-loop-play.is-on { color: var(--bg); background: var(--gold); }
.as-loop-play.is-on .vs-fx-line { color: var(--bg); }
.as-loop-play:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.as-mine-find { width: 100%; margin: 0 0 6px; }
.as-inst-group { display: flex; flex-direction: column; gap: 5px; margin: 0 0 8px; }
.as-rec-big { display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%; }
.as-rec-big .as-rec-dot { width: 11px; height: 11px; }
.as-in-meter { height: 8px; margin: 4px 0; overflow: hidden; background: #0b0914; border: 1px solid var(--border); border-radius: 0; }
.as-insp-sub { margin: 8px 0 -2px; }
.as-insp-tabs { display: flex; margin: 8px 12px 0; }
.as-insp-tabs .seg-btn { flex: 1 1 0; }
.as-insp-len, .as-time-in { font-family: var(--mono); font-size: 0.78rem; }
.as-time-in { flex: 1 1 auto; min-width: 0; }
.as-insp-empty { margin-top: 4px; }

/* ---- Tools ---- */
.as-tools-panel .vs-sec:first-child { margin-top: 0; border-top: 0; }
.as-tool { display: flex; flex-direction: column; gap: 9px; }
.as-tool-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.as-big-line { margin: 0; color: var(--tint-text); font-family: var(--mono); font-size: 0.78rem; }
.as-dots { display: flex; gap: 6px; }
.as-dots i { width: 14px; height: 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 50%; transition: background 60ms linear; }
.as-dots i.is-on { background: var(--accent-strong); border-color: var(--accent-strong); }
.as-dots i.is-one { background: var(--gold); border-color: var(--gold); }
.btn.is-on { color: var(--tint-text); }
.as-tap { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; width: 100%; min-height: 120px; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 0; font: inherit; cursor: pointer; touch-action: manipulation; }
.as-tap:active { background: var(--tint); }
.as-tap:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.as-tap-bpm { font-family: var(--display); font-size: 2.6rem; font-weight: 800; line-height: 1; }
.as-tap-unit { color: var(--muted); font-family: var(--mono); font-size: 0.72rem; }
.as-tune { display: flex; flex-direction: column; gap: 8px; padding: 12px; background: #0b0914; border: 1px solid var(--border); border-radius: 0; }
.as-tune-read { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 0; font-family: var(--mono); }
.as-tune-note { font-family: var(--display); font-size: 2rem; font-weight: 800; }
.as-tune-cents { color: var(--tint-text); font-size: 0.78rem; }
.as-tune-hz { color: var(--muted); font-size: 0.72rem; }
.as-tune-meter { position: relative; height: 14px; background: linear-gradient(90deg, rgba(239, 79, 79, 0.35), rgba(232, 180, 79, 0.25) 40%, rgba(46, 196, 182, 0.4) 50%, rgba(232, 180, 79, 0.25) 60%, rgba(239, 79, 79, 0.35)); border-radius: 0; }
.as-tune-ok { position: absolute; left: 47%; width: 6%; top: 0; bottom: 0; border-left: 1px solid rgba(255, 255, 255, 0.4); border-right: 1px solid rgba(255, 255, 255, 0.4); }
.as-tune-needle { position: absolute; top: -3px; bottom: -3px; left: 50%; width: 3px; margin-left: -1.5px; background: #fff; border-radius: 0; transition: left 80ms linear; }
.as-tune-meter[data-state="ok"] .as-tune-needle { background: #2ec4b6; box-shadow: 0 0 8px #2ec4b6; }
.as-tune-meter[data-state="idle"] .as-tune-needle { opacity: 0.3; }
.as-hz { width: 90px; }
.as-bk-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.as-bk-grid > div { display: flex; flex-direction: column; gap: 2px; padding: 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 0; }
.as-bk-big { font-family: var(--display); font-size: 1.25rem; font-weight: 800; line-height: 1.15; }
.as-bk-grid small { color: var(--muted); font-family: var(--mono); font-size: 0.7rem; }
.as-stats { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 0; font-size: 0.78rem; }
.as-stats dt { color: var(--muted); }
.as-stats dd { margin: 0; font-family: var(--mono); }
.as-spectrum { display: block; width: 100%; height: auto; border-radius: 0; }

/* ---- Dialogs ---- */
.as-noise-step { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 10px 12px; background: var(--surface-2); border-radius: 0; }
.as-ex-player { width: 100%; }

@media (hover: hover) {
  .as-hb:not(.is-on):hover, .as-tap:hover { color: var(--bg); background: var(--gold); border-color: var(--gold); }
  .as-clip:not(.is-picked):hover { border-color: var(--gold); }
  .as-file:hover { border-color: var(--gold); }
  .as-head:hover .as-head-name { color: var(--text); }
}

/* ---- Wave Synth macro lane (over a track's clips) ---- */
.as-auto { position: absolute; left: 0; right: 0; top: 3px; z-index: 4; background: rgba(11, 9, 20, 0.55); border-top: 1px dashed var(--gold); border-bottom: 1px dashed var(--gold); }
.as-auto-svg { display: block; cursor: crosshair; touch-action: none; }
.as-auto-line { fill: none; stroke: var(--gold); stroke-width: 2; }
.as-auto-pt { fill: #fff; stroke: var(--gold); stroke-width: 1.5; cursor: grab; }
.as-auto-pick { position: absolute; left: 4px; top: 2px; max-width: 170px; padding: 0 4px; height: 18px; color: var(--text); background: var(--surface); border: 1px solid var(--gold); border-radius: 0; font-size: 0.68rem; }
.as-auto-hint { position: absolute; left: 182px; right: 8px; top: 2px; margin: 0; color: var(--muted); font-size: 0.68rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
.as-auto-val { position: absolute; left: 6px; top: 23px; color: var(--gold); font: 600 0.68rem var(--mono); pointer-events: none; }
.as-hb.is-auto.is-on { color: #1a1626; background: var(--gold); border-color: var(--gold); }
.as-hb.is-auto.has-auto:not(.is-on) { color: var(--gold); border-color: var(--gold); }
.vs-slider.is-auto { opacity: 0.6; }
.vs-slider.is-auto .vs-field-label::after { content: " · automated"; color: var(--gold); }

/* ---- Wave Synth editor ---- */
#ws-dialog.st-dialog { width: min(1180px, calc(100vw - 24px)); max-height: calc(100vh - 24px); }
.ws-editor { --ws-wave: var(--accent-strong); display: flex; flex-direction: column; gap: 10px; }
.ws-top { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ws-preset { flex: 0 1 220px; }
.ws-name { flex: 1 1 160px; min-width: 0; }
.ws-row { display: grid; gap: 8px; }
.ws-row-2 { grid-template-columns: 2fr 1fr; }
.ws-row-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ws-row-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.ws-card { display: flex; flex-direction: column; gap: 6px; min-width: 0; padding: 8px; background: var(--surface-2); border: 1px solid var(--rule); border-radius: 0; }
.ws-card-head { display: flex; justify-content: space-between; align-items: center; gap: 6px; font-weight: 600; }
.ws-card-title { font-size: 0.85rem; }
.ws-table-pic, .ws-env-pic { width: 100%; height: auto; background: #0b0914; border: 1px solid var(--rule); }
.ws-knobs { display: flex; flex-wrap: wrap; gap: 4px 2px; }
.ws-knob { display: flex; flex-direction: column; align-items: center; width: 58px; }
.ws-knob-dial { width: 36px; height: 36px; cursor: ns-resize; touch-action: none; }
.ws-knob-dial:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.ws-knob-dial svg { width: 100%; height: 100%; }
.ws-knob-track { fill: none; stroke: var(--border); stroke-width: 4; }
.ws-knob-val { fill: none; stroke: var(--accent-strong); stroke-width: 4; }
.ws-knob-label { color: var(--muted); font-size: 0.66rem; text-align: center; line-height: 1.1; }
.ws-knob-num { padding: 0 2px; color: var(--text); background: none; border: 0; font: 0.7rem var(--mono); cursor: text; }
.ws-knob-input { width: 56px; font-size: 0.7rem; }
.ws-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.ws-mods { display: flex; flex-direction: column; gap: 6px; }
.ws-mod { display: grid; grid-template-columns: 1fr 1fr auto auto auto; gap: 6px; align-items: center; }
.ws-knob-ring { fill: none; stroke: var(--gold); stroke-width: 2.5; }
.ws-knob-dot { fill: #fff; }
.ws-knob.is-modded .ws-knob-label { color: var(--gold); }
.ws-strip { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; padding: 6px 8px; background: var(--surface-2); border: 1px solid var(--rule); }
.ws-strip-label { margin-right: 4px; color: var(--muted); font-size: 0.72rem; }
.ws-chip { padding: 3px 8px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 0; font-size: 0.72rem; cursor: grab; touch-action: none; user-select: none; }
.ws-chip:hover { border-color: var(--gold); }
.ws-chip.is-armed { color: #1a1626; background: var(--gold); border-color: var(--gold); }
.ws-ghost { position: fixed; z-index: 10000; pointer-events: none; border-color: var(--gold); box-shadow: var(--hard); }
.ws-editor.is-dragging-src .ws-can-mod .ws-knob-dial, .ws-editor.is-armed .ws-can-mod .ws-knob-dial { outline: 1px dashed var(--gold); outline-offset: 1px; }
.ws-can-mod.is-target .ws-knob-dial { outline: 2px solid var(--gold) !important; }
.ws-row-lfo { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr); }
.ws-lfo-pic { width: 100%; height: auto; background: #0b0914; border: 1px solid var(--rule); cursor: crosshair; touch-action: none; }
.ws-lfo .ws-card-head { flex-wrap: wrap; }
.ws-lfo .ws-card-head .vs-field { margin: 0; }
.ws-lfo .ws-card-head select { width: auto; }
.ws-sub { display: flex; flex-direction: column; gap: 4px; padding-top: 6px; border-top: 1px solid var(--rule); }
.ws-sub:first-of-type { border-top: 0; padding-top: 0; }
.ws-macros { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.ws-macro { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.ws-macro .ws-knob-label { display: none; }
.ws-macro-name { width: 100%; padding: 2px 4px; font-size: 0.72rem; text-align: center; }
.ws-keys { position: relative; display: flex; height: 72px; user-select: none; touch-action: none; }
.ws-key { flex: 1 1 0; min-width: 0; padding: 0; background: #f4f1fb; border: 1px solid #27223a; border-radius: 0; }
.ws-key.is-black { flex: 0 0 0; position: relative; z-index: 1; width: 0; height: 60%; margin: 0; border: 0; overflow: visible; }
.ws-key.is-black::before { content: ""; position: absolute; top: 0; left: -9px; width: 18px; height: 100%; background: #1a1626; border: 1px solid #000; }
.ws-key.is-down { background: var(--accent-soft); }
.ws-key.is-black.is-down::before { background: var(--accent); }
.ws-edit { justify-self: start; }
.ws-main:not([hidden]), .ws-table-page:not([hidden]) { display: flex; flex-direction: column; gap: 10px; }
.ws-table-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; align-items: center; }
.ws-frames { display: flex; flex-wrap: wrap; gap: 3px; max-height: 120px; overflow-y: auto; }
.ws-frame { padding: 1px; background: #0b0914; border: 1px solid var(--rule); border-radius: 0; cursor: pointer; }
.ws-frame canvas { display: block; width: 56px; height: 32px; }
.ws-frame.is-on { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.ws-pad { width: 100%; height: auto; background: #0b0914; border: 1px solid var(--rule); touch-action: none; }
.ws-pad[hidden] { display: none; }
.ws-sources { flex-wrap: wrap; }
.ws-sources select { width: auto; max-width: 240px; }
.ws-formula { width: 100%; font-family: var(--mono); }
.ws-formula-err { color: var(--danger); }
.ws-link-hint { padding: 4px 8px; border: 1px dashed var(--gold); }
.ws-frame-btns { margin: 0; }
.ws-editor { position: relative; }
.ws-top-2 { gap: 8px; }
.ws-locks { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.ws-locks .vs-check { margin: 0; }
.ws-quality { width: auto; margin-left: auto; }
.ws-browser:not([hidden]) { display: flex; flex-direction: column; gap: 6px; padding: 8px; background: var(--surface-2); border: 1px solid var(--accent); }
.ws-browser-top { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ws-find { flex: 0 1 220px; }
.ws-cats { flex-wrap: wrap; }
.ws-sounds { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 4px; max-height: 260px; overflow-y: auto; }
.ws-sound { display: flex; min-width: 0; }
.ws-sound-name { flex: 1; min-width: 0; display: flex; justify-content: space-between; gap: 6px; padding: 5px 8px; color: var(--text); text-align: left; background: var(--surface); border: 1px solid var(--rule); border-radius: 0; cursor: pointer; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.ws-sound-name:hover { border-color: var(--accent); }
.ws-sound-cat { color: var(--faint); font-size: 0.7rem; }
.ws-star { width: 28px; color: var(--faint); background: var(--surface); border: 1px solid var(--rule); border-left: 0; border-radius: 0; cursor: pointer; }
.ws-star.is-on { color: var(--gold); }
.ws-scopes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ws-scope { width: 100%; height: 56px; background: #0b0914; border: 1px solid var(--rule); }
.ws-knob.is-modded .ws-knob-label { cursor: pointer; text-decoration: underline dotted; }
.ws-pop { position: absolute; z-index: 20; width: 300px; padding: 8px; background: var(--surface); border: 1px solid var(--gold); box-shadow: var(--hard); }
.ws-pop-title { margin: 0 0 6px; font-weight: 600; font-size: 0.8rem; }
.ws-pop-row { display: grid; grid-template-columns: 1fr auto auto auto; gap: 6px; align-items: center; padding: 4px 0; border-top: 1px solid var(--rule); }
.ws-pop-src { font-size: 0.75rem; }
.ws-mod { grid-template-columns: 1fr 1fr auto auto auto auto auto; }
@media (max-width: 900px) {
  .ws-row-3, .ws-row-2, .ws-row-lfo { grid-template-columns: minmax(0, 1fr); }
  .ws-row-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .ws-row-4 { grid-template-columns: minmax(0, 1fr); }
  #ws-dialog.st-dialog { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; }
  .ws-knob { width: 62px; }
  .ws-knob-dial { width: 42px; height: 42px; }
  .ws-strip { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .ws-chip { flex: none; padding: 6px 10px; }
  .ws-keys { height: 96px; }
  .ws-scopes { grid-template-columns: 1fr; }
  .ws-quality { margin-left: 0; }
  .ws-pop { width: calc(100% - 8px); left: 4px !important; }
  .ws-pair { grid-template-columns: minmax(0, 1fr); }
  .ws-mod { grid-template-columns: 1fr 1fr; }
}

/* ---- Phones ---- */
@media (max-width: 760px) {
  .as-new .st-new-row > .st-field { flex: 1 1 100%; }
  .as-work { grid-template-rows: auto auto minmax(0, 1fr) auto; }
  .as-body { grid-template-columns: minmax(0, 1fr); }
  .as-work.has-roll .as-main { grid-template-rows: auto minmax(100px, 1fr) minmax(180px, 50%); }
  .as-work.has-mix .as-main { height: 100%; grid-template-rows: auto minmax(90px, 1fr) minmax(230px, 55%); }
  .as-mix-hint { display: none; }
  .as-strip { width: 70px; }
  .as-transport { gap: 6px; padding: 4px 6px; overflow-x: auto; scrollbar-width: none; }
  .as-transport::-webkit-scrollbar { display: none; }
  .as-tp-opts { margin-left: 0; }
  .as-bbt, .as-master, #as-to-end { display: none; }
  .as-clock { padding: 3px 8px; }
  .as-head { padding: 4px 4px 4px 8px; }
  .as-head .as-vol, .as-head-inst { display: none; }
  .as-hb { width: 20px; }
  .as-trim { width: 14px; }
  #as-zoom-sel { display: none; }
}
.as-pads.as-pads-list { grid-template-columns: minmax(0, 1fr); }
.as-pack { display: grid; gap: 6px; margin-top: 8px; padding: 6px; background: var(--surface); border: 1px solid var(--border); }
.as-pack-top { display: flex; align-items: center; gap: 6px; min-width: 0; }
.as-pack-name { flex: 1 1 auto; min-width: 0; overflow: hidden; font-size: 0.78rem; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }

/* ---- Patterns view ---- */
.as-pat { display: none; min-width: 0; min-height: 0; grid-template-rows: auto minmax(0, 1fr); background: var(--bg-deep); }
.as-work.is-pat .as-tl { display: none; }
.as-work.is-pat .as-pat { display: grid; }
.as-pat-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.as-pat-what { min-width: 0; font-size: 0.78rem; font-weight: 600; }
.as-pat-num { min-width: 2.2em; color: var(--gold); font-family: var(--mono); text-align: center; }
.as-pat-hint { flex: 1 1 220px; color: var(--muted); font-size: 0.7rem; }
.as-pat-grid { overflow: auto; overscroll-behavior: contain; padding-bottom: 8px; }
.as-pat-row { display: grid; grid-template-columns: 110px repeat(var(--bars), 34px); width: max-content; }
.as-pat-name { position: sticky; left: 0; z-index: 1; overflow: hidden; padding: 0 8px; background: var(--surface); border-left: 4px solid var(--c, transparent); border-bottom: 1px solid var(--border); font-size: 0.74rem; line-height: 34px; text-overflow: ellipsis; white-space: nowrap; }
.as-pat-ruler .as-pat-name { border-left-color: transparent; }
.as-pat-n { color: var(--muted); font-family: var(--mono); font-size: 0.66rem; line-height: 22px; text-align: center; }
.as-pat-cell { height: 34px; padding: 0; color: var(--text); background: #0b0914; border: 0; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); font: inherit; font-family: var(--mono); font-size: 0.8rem; font-weight: 700; cursor: pointer; touch-action: manipulation; }
.as-pat-cell.has-pat { color: #07040d; background: var(--c); }
.as-pat-cell.has-part { color: var(--muted); background: color-mix(in srgb, var(--c) 22%, #0b0914); }
.as-pat-cell.is-sel { outline: 2px solid var(--gold); outline-offset: -2px; }
.as-pat-cell:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }
.as-pat-empty { padding: 12px; }
@media (max-width: 760px) { .as-pat-row { grid-template-columns: 84px repeat(var(--bars), 32px); } .as-pat-hint { display: none; } }
