/* petri-note.css - Base styling for the petri-note component */

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #1a1a2e;
    color: #eee;
    overflow-x: auto;
    overflow-y: auto;
}

/* Main component */
petri-note {
    display: flex;
    flex-direction: column;
    width: fit-content;
    min-width: 100%;
    user-select: none;
    -webkit-user-select: none;
    height: 100vh;
}

/* Header bar */
.pn-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 8px 16px;
    background: #16213e;
    border-bottom: 1px solid #0f3460;
    flex-shrink: 0;
}

.pn-header h1 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #e94560;
}

.pn-project-name {
    font-size: 14px;
    color: #aaa;
}

.pn-track-nav {
    display: flex;
    align-items: center;
    gap: 4px;
}

.pn-track-nav button {
    background: none;
    border: 1px solid #334;
    color: #8af;
    font-size: 10px;
    padding: 2px 6px;
    cursor: pointer;
    border-radius: 3px;
}

.pn-track-nav button:hover {
    background: #223;
    border-color: #4a90d9;
}
.pn-track-nav button:disabled {
    opacity: 0.25;
    cursor: default;
    color: #556;
}
.pn-track-nav button:disabled:hover {
    background: none;
    border-color: #334;
}

.pn-track-label {
    font-size: 13px;
    color: #ccc;
    min-width: 80px;
    text-align: center;
}

/* Transport controls */
.pn-transport {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pn-transport button {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 4px;
    background: #0f3460;
    color: #eee;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.2s;
}

.pn-transport button:hover {
    background: #1a4a7a;
}

.pn-transport button.playing {
    background: #e94560;
}

.pn-playback-mode {
    font-size: 13px !important;
    font-weight: bold;
    letter-spacing: -0.5px;
}

.pn-playback-mode.active {
    background: #1a6a3a !important;
}

.pn-tempo {
    display: flex;
    align-items: center;
    gap: 4px;
}

.pn-tempo input {
    width: 60px;
    padding: 4px 8px;
    border: 1px solid #0f3460;
    border-radius: 4px;
    background: #1a1a2e;
    color: #eee;
    font-size: 14px;
    text-align: center;
}

.pn-tempo span {
    font-size: 12px;
    color: #888;
}

/* Higher specificity than .pn-transport button so the auto-square
 * dimensions don't apply to the text pill. */
.pn-transport .pn-tap-tempo {
    width: auto;
    height: auto;
    padding: 4px 10px;
    border: 1px solid #0f3460;
    border-radius: 4px;
    background: transparent;
    color: #888;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.pn-transport .pn-tap-tempo:hover {
    background: #0f3460;
    border-color: #1a4a7a;
    color: #fff;
}
.pn-transport .pn-tap-tempo:active,
.pn-transport .pn-tap-tempo.tapping {
    background: #533483;
    border-color: #6a47a3;
    color: #fff;
}

/* Genre traits display */
.pn-genre-traits {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 4px 12px;
    background: #0d1b2a;
    border-bottom: 1px solid #0f3460;
    align-items: center;
    min-height: 24px;
}

.pn-trait {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 3px;
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    white-space: nowrap;
}

.pn-trait[data-param] {
    cursor: pointer;
    user-select: none;
}

.pn-trait[data-param]:hover {
    opacity: 0.85;
    outline: 1px solid rgba(255,255,255,0.25);
}

/* Zebra striping — odd/even chips get a different base background shade
 * so the row reads as a rhythm of distinct items rather than a blur.
 * `on` / `off` modifiers override with their own color scheme. */
.pn-trait:nth-child(odd) {
    background: rgba(255, 255, 255, 0.05);
}
.pn-trait:nth-child(even) {
    background: rgba(255, 255, 255, 0.10);
}

.pn-trait.on {
    background: rgba(46, 204, 113, 0.22);
    color: #7ee2a6;
    border: 1px solid rgba(46, 204, 113, 0.45);
    font-weight: 700;
}

/* Keep zebra shading for off chips but bump the text legibility from #555
 * to a readable neutral; borders sharpen the chip boundary vs neighbors. */
.pn-trait.off {
    color: #8a99ad;
    border: 1px solid rgba(255, 255, 255, 0.1);
}
.pn-trait.off:nth-child(odd) {
    background: rgba(15, 52, 96, 0.3);
}
.pn-trait.off:nth-child(even) {
    background: rgba(15, 52, 96, 0.55);
}

.pn-trait-info {
    font-size: 10px;
    color: #667;
    margin-left: auto;
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
}

/* Mixer panel */
.pn-mixer {
    display: flex;
    flex-direction: column;
    background: #16213e;
    border-bottom: 1px solid #0f3460;
    flex-shrink: 0;
}

.pn-mixer-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 16px;
    border-bottom: 1px solid rgba(15, 52, 96, 0.5);
    cursor: pointer;
    transition: background 0.15s;
}

/* Divider strip between standard Petri-net tracks and augmented tracks
 * (stingers and any other non-standard names). Shows a label + list so users
 * see at a glance what's been injected beyond the core kick/snare/hihat/etc. */
.pn-mixer-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 3px 16px;
    background: rgba(15, 52, 96, 0.35);
    border-top: 1px solid #0f3460;
    border-bottom: 1px solid #0f3460;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #9aa;
}

.pn-mixer-divider-label {
    font-weight: 700;
    color: #e94560;
}

.pn-mixer-divider-list {
    color: #6aa;
    font-weight: 500;
    letter-spacing: 0.5px;
    text-transform: none;
}

.pn-mixer-row:hover {
    background: rgba(255, 255, 255, 0.03);
}

.pn-mixer-row.active {
    background: rgba(233, 69, 96, 0.08);
    border-left: 3px solid #e94560;
    padding-left: 13px;
}

.pn-mixer-solo {
    width: 14px;
    height: 14px;
    margin: 0 2px 0 0;
    cursor: pointer;
    accent-color: #e94560;
    flex-shrink: 0;
}

.pn-mixer-mute {
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    border-radius: 4px;
    background: transparent;
    font-size: 12px;
    cursor: pointer;
    opacity: 0.6;
    transition: all 0.2s;
    flex-shrink: 0;
}

.pn-mixer-mute:hover {
    opacity: 1;
    background: rgba(255,255,255,0.1);
}

.pn-mixer-mute.muted {
    opacity: 1;
    color: #e94560;
}

.pn-mixer-name {
    width: 70px;
    font-size: 12px;
    font-weight: 600;
    color: #ccc;
    flex-shrink: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pn-mixer-row.active .pn-mixer-name {
    color: #e94560;
}

.pn-riff-variants {
    display: flex;
    gap: 2px;
    margin-right: 4px;
    flex-shrink: 0;
    width: 42px;
}

.pn-riff-label {
    font-size: 9px;
    font-weight: 700;
    padding: 1px 4px;
    border-radius: 3px;
    background: rgba(255,255,255,0.1);
    color: #888;
}

.pn-riff-label.active {
    background: rgba(46, 204, 113, 0.3);
    color: #2ecc71;
}

.pn-riff-label.muted {
    background: rgba(233, 69, 96, 0.2);
    color: #666;
}

.pn-mixer-instrument {
    width: 140px;
    padding: 3px 6px;
    border: 1px solid #0f3460;
    border-radius: 4px;
    background: #1a1a2e;
    color: #eee;
    font-size: 11px;
    cursor: pointer;
    flex-shrink: 0;
}

.pn-mixer-instrument:hover {
    border-color: #1a4a7a;
}

.pn-mixer-output {
    width: 100px;
    padding: 3px 6px;
    border: 1px solid #0f3460;
    border-radius: 4px;
    background: #1a1a2e;
    color: #eee;
    font-size: 11px;
    cursor: pointer;
    flex-shrink: 0;
}

.pn-mixer-output:hover {
    border-color: #1a4a7a;
}

.pn-mixer-output {
    display: none;
}

petri-note.pn-midi-enabled .pn-mixer-output {
    display: inline-block;
}

.pn-mixer-size,
.pn-mixer-hits {
    width: 50px;
    padding: 3px 4px;
    border: 1px solid #0f3460;
    border-radius: 4px;
    background: #1a1a2e;
    color: #eee;
    font-size: 11px;
    cursor: pointer;
    flex-shrink: 0;
}

.pn-mixer-size:hover,
.pn-mixer-hits:hover {
    border-color: #1a4a7a;
}

.pn-mixer-save {
    padding: 2px 6px;
    border: 1px solid transparent;
    border-radius: 4px;
    background: transparent;
    color: #888;
    font-size: 12px;
    cursor: pointer;
    flex-shrink: 0;
}

.pn-mixer-save:hover {
    color: #f5a623;
    border-color: #0f3460;
}

.pn-preset-list {
    list-style: none;
    margin: 0 0 16px 0;
    padding: 0;
    max-height: 260px;
    overflow-y: auto;
    border: 1px solid #0f3460;
    border-radius: 4px;
}

.pn-preset-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-bottom: 1px solid #0f3460;
}

.pn-preset-item:last-child {
    border-bottom: none;
}

.pn-preset-name {
    flex: 1;
    font-size: 13px;
    color: #ccc;
}

.pn-preset-apply {
    padding: 3px 10px;
    border: 1px solid #0f3460;
    border-radius: 3px;
    background: #1a1a2e;
    color: #eee;
    font-size: 11px;
    cursor: pointer;
}

.pn-preset-apply:hover {
    border-color: #1a4a7a;
    background: #0f3460;
}

.pn-preset-delete {
    padding: 3px 8px;
    border: 1px solid transparent;
    border-radius: 3px;
    background: transparent;
    color: #888;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
}

.pn-preset-delete:hover {
    color: #e94560;
    border-color: #e94560;
}

.pn-audio-lock-banner {
    position: fixed;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    background: #3a1a1a;
    border: 1px solid #e94560;
    color: #ffe;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 9999;
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}

.pn-audio-lock-banner button {
    background: #e94560;
    border: none;
    color: #fff;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.pn-mixer-slider-group {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.pn-mixer-slider-group span {
    font-size: 10px;
    color: #666;
    width: 24px;
    flex-shrink: 0;
}

/* Cursor-anchored slider value tip — a single element appended to
 * <body> and positioned via JS (mousemove handler in mixer.js). Lives
 * outside the mixer row flow so hover never shifts the tail icons. */
.pn-slider-tip {
    position: fixed;
    z-index: 1500;
    padding: 3px 7px;
    background: rgba(15, 20, 40, 0.92);
    border: 1px solid rgba(74, 144, 217, 0.35);
    border-radius: 4px;
    color: #9ad;
    font-family: ui-monospace, SFMono-Regular, monospace;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.08s;
    white-space: nowrap;
}

.pn-mixer-slider {
    width: 80px;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: #0f3460;
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.pn-mixer-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #4a90d9;
    cursor: pointer;
}

.pn-mixer-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #4a90d9;
    cursor: pointer;
    border: none;
}

/* Chase-pulse indicator: every element touched by a live macro gets
 * `.pn-pulsing` (dim glow), and one at a time rotates through `.pn-pulsing-hot`
 * for a "running light" effect. Visual only — values don't change. Applied
 * to mixer sliders (pan/decay), FX sliders (fx-sweep/hold), and mute buttons
 * (mute macros). */
.pn-pulsing {
    box-shadow: 0 0 4px 1px rgba(233, 69, 96, 0.35);
    transition: box-shadow 0.12s ease-out;
}

.pn-pulsing-hot {
    box-shadow: 0 0 10px 3px rgba(233, 69, 96, 0.95);
}

.pn-mixer-slider.pn-pulsing::-webkit-slider-thumb,
.pn-fx-slider.pn-pulsing::-webkit-slider-thumb {
    background: #e94560;
}
.pn-mixer-slider.pn-pulsing::-moz-range-thumb,
.pn-fx-slider.pn-pulsing::-moz-range-thumb {
    background: #e94560;
}

select.pn-mixer-slider {
    width: 54px;
    height: auto;
    padding: 2px 4px;
    background: #1a1a2e;
    color: #eee;
    border: 1px solid #0f3460;
    border-radius: 4px;
    font-size: 11px;
    -webkit-appearance: menulist;
    appearance: menulist;
}

select.pn-mixer-slider:hover {
    border-color: #1a4a7a;
}

/* Default value notch mark on sliders */
/* Default-value tick: a 2px vertical sliver painted into the slider's
 * own track at --default-pct. Percentage scales with slider width so the
 * tick stays aligned on resize / re-render. Set --default-pct in JS once
 * per slider — see _addDefaultNotches. */
input[type="range"][data-default] {
    background-image: linear-gradient(
        to right,
        transparent calc(var(--default-pct, 50%) - 1px),
        rgba(255, 255, 255, 0.55) calc(var(--default-pct, 50%) - 1px),
        rgba(255, 255, 255, 0.55) calc(var(--default-pct, 50%) + 1px),
        transparent calc(var(--default-pct, 50%) + 1px)
    );
    background-repeat: no-repeat;
    background-size: 100% 100%;
}

.pn-mixer-test {
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: #666;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.pn-mixer-test:hover {
    background: rgba(233, 69, 96, 0.2);
    color: #e94560;
}

.pn-mixer-tone-reset {
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: #666;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    padding: 0;
}

.pn-mixer-tone-reset:hover {
    background: rgba(100, 200, 255, 0.2);
    color: #64ffda;
}

.pn-mixer-tone-prev,
.pn-mixer-tone-next {
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: #666;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    padding: 0;
    line-height: 24px;
    text-align: center;
}

.pn-mixer-tone-prev:hover {
    background: rgba(100, 200, 255, 0.2);
    color: #64ffda;
}

.pn-mixer-tone-next:hover {
    background: rgba(233, 69, 96, 0.2);
    color: #e94560;
}

.pn-mixer-rotate {
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: #666;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    margin-left: -4px;
}

.pn-mixer-rotate:hover {
    background: rgba(100, 200, 100, 0.2);
    color: #64ffda;
}

/* Effects panel */
/* Feel — icon button at the start of the traits row opens a modal with the
 * 4 abstract sliders. The button is intentionally distinct from trait chips
 * (diamond glyph on a circular purple well) so users can't confuse it with
 * a trait toggle. */
.pn-feel-open {
    width: 22px;
    height: 22px;
    padding: 0;
    margin: 0 8px 0 0;
    border: 1px solid #6e4adf;
    border-radius: 50%;
    background: linear-gradient(135deg, #2a1a4a 0%, #4a2a7a 100%);
    color: #c3a6ff;
    cursor: pointer;
    font-size: 12px;
    line-height: 20px;
    text-align: center;
    vertical-align: middle;
    flex-shrink: 0;
}

.pn-feel-open:hover {
    color: #fff;
    border-color: #a58aff;
    box-shadow: 0 0 6px 1px rgba(195, 166, 255, 0.55);
}

/* Engaged state (Feel is shaping the track): the ◈ stays lit with a soft
 * permanent glow, not just on hover. Disengaged state (`.disengaged`)
 * overrides this below. */
.pn-feel-open:not(.disengaged) {
    color: #fff;
    background: linear-gradient(135deg, #3a2a6a 0%, #6e4adf 100%);
    border-color: #a58aff;
    box-shadow: 0 0 6px 1px rgba(195, 166, 255, 0.45);
}

/* Disengaged: Feel values are stale relative to current genre defaults.
 * The icon goes low-contrast / unfilled until the user reopens and nudges. */
.pn-feel-open.disengaged {
    background: transparent;
    color: #5a3a8a;
    border-color: #3a2a5a;
    border-style: dashed;
    box-shadow: none;
}

.pn-feel-open.disengaged:hover {
    color: #c3a6ff;
    border-color: #6e4adf;
    border-style: solid;
}

/* Feel modal — 2D vibe grid with a draggable triangle. */
.pn-feel-modal {
    min-width: 360px;
    max-width: 420px;
}

.pn-feel-gridwrap {
    padding: 8px 0 4px;
    display: flex;
    justify-content: center;
}

.pn-feel-grid-svg {
    width: 100%;
    max-width: 320px;
    touch-action: none;
    user-select: none;
    display: block;
}

.pn-feel-grid-bg {
    stroke: #0f3460;
    stroke-width: 1;
}

.pn-feel-grid-lines line {
    stroke: rgba(110, 74, 223, 0.18);
    stroke-width: 1;
    stroke-dasharray: 3 4;
}

.pn-feel-corner-label {
    fill: #c3a6ff;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    pointer-events: none;
}

.pn-feel-corner {
    stroke-width: 2;
    pointer-events: none;
    filter: drop-shadow(0 0 4px currentColor);
}

.pn-feel-grid-svg {
    cursor: crosshair;
}

.pn-feel-puck {
    fill: #e94560;
    stroke: #fff;
    stroke-width: 2;
    pointer-events: none;
    transition: r 120ms;
    filter: drop-shadow(0 0 6px rgba(233, 69, 96, 0.8));
}

.pn-feel-puck.dragging {
    r: 13;
    filter: drop-shadow(0 0 10px rgba(233, 69, 96, 1));
}

.pn-feel-ghost-puck {
    fill: none;
    stroke: rgba(233, 69, 96, 0.6);
    stroke-width: 2;
    stroke-dasharray: 3 3;
    pointer-events: none;
    filter: drop-shadow(0 0 4px rgba(233, 69, 96, 0.4));
}

.pn-feel-modal.disengaged .pn-feel-corner,
.pn-feel-modal.disengaged .pn-feel-puck {
    opacity: 0.55;
}

.pn-feel-constellation .pn-feel-star { cursor: pointer; }
.pn-feel-constellation .pn-feel-star circle {
    fill: rgba(255, 255, 255, 0.45);
    stroke: rgba(255, 255, 255, 0.15);
    stroke-width: 1;
    transition: fill 120ms, r 120ms;
}
.pn-feel-constellation .pn-feel-star text {
    fill: rgba(220, 210, 255, 0.55);
    font-size: 8.5px;
    font-weight: 500;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    user-select: none;
}
.pn-feel-constellation .pn-feel-star:hover circle {
    fill: #fff;
}
.pn-feel-constellation .pn-feel-star:hover text {
    fill: #fff;
}
.pn-feel-constellation .pn-feel-star.active circle {
    fill: #ffd36a;
    stroke: #fff;
    stroke-width: 1.5;
    filter: drop-shadow(0 0 5px rgba(255, 211, 106, 0.9));
}
.pn-feel-constellation .pn-feel-star.active text {
    fill: #ffe59a;
    font-weight: 700;
}

.pn-feel-close {
    position: absolute;
    top: 10px;
    right: 12px;
    background: transparent;
    border: none;
    color: #888;
    font-size: 22px;
    cursor: pointer;
}

.pn-feel-close:hover { color: #e94560; }

.pn-feel-modal .pn-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 14px;
}

.pn-feel-cancel,
.pn-feel-reset,
.pn-feel-apply {
    padding: 6px 14px;
    border-radius: 4px;
    border: 1px solid #0f3460;
    background: transparent;
    color: #ccc;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.pn-feel-cancel:hover,
.pn-feel-reset:hover { border-color: #888; color: #fff; }

.pn-feel-apply {
    background: #6e4adf;
    border-color: #6e4adf;
    color: #fff;
}

.pn-feel-apply:hover { background: #7e5aef; border-color: #a58aff; }

.pn-effects {
    border-bottom: 1px solid #0f3460;
    margin-bottom: 4px;
    display: flex;
    flex-direction: column;
}

/* Stacking order when panels are open: toggle bar (0), FX (1), Macros (2),
 * Beats (3), Auto-DJ (4). Matches the toggle button order. */
.pn-effects-toggle  { order: 0; }
.pn-effects-panel   { order: 1; }
.pn-macros-panel    { order: 2; }
.pn-oneshots-panel  { order: 3; }
.pn-autodj-panel    { order: 4; }

.pn-effects-toggle {
    display: flex;
    gap: 6px;
    padding: 4px 12px;
    background: #0a1628;
}

.pn-effects-btn {
    background: transparent;
    border: 1px solid #0f3460;
    color: #4a90d9;
    padding: 2px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    font-weight: bold;
}

.pn-effects-btn.active {
    background: #0f3460;
    color: #e94560;
}

.pn-macros-btn {
    background: transparent;
    border: 1px solid #0f3460;
    color: #4a90d9;
    padding: 2px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    font-weight: bold;
}

.pn-macros-btn:hover {
    color: #e94560;
    border-color: #e94560;
}

.pn-macros-btn.active {
    background: #0f3460;
    color: #e94560;
}

.pn-oneshots-btn {
    background: transparent;
    border: 1px solid #0f3460;
    color: #4a90d9;
    padding: 2px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    font-weight: bold;
}

.pn-oneshots-btn:hover {
    border-color: #e94560;
    color: #e94560;
}

.pn-oneshots-btn.active {
    background: #0f3460;
    color: #e94560;
}

.pn-oneshots-panel {
    display: flex;
    flex-direction: column;
    background: #0d1b2a;
    border-bottom: 1px solid #0f3460;
}

.pn-autodj-btn {
    background: transparent;
    border: 1px solid #0f3460;
    color: #4a90d9;
    padding: 2px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    font-weight: bold;
}

.pn-autodj-btn:hover {
    border-color: #e94560;
    color: #e94560;
}

.pn-autodj-btn.active {
    background: #0f3460;
    color: #e94560;
}

.pn-arrange-btn {
    background: transparent;
    border: 1px solid #0f3460;
    color: #4a90d9;
    padding: 2px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    font-weight: bold;
}

.pn-arrange-btn:hover {
    border-color: #e94560;
    color: #e94560;
}

.pn-arrange-btn.active {
    background: #0f3460;
    color: #e94560;
}

.pn-arrange-panel {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 8px 14px;
    background: #0d1b2a;
    border-bottom: 1px solid #0f3460;
    font-size: 11px;
    color: #ccc;
    flex-wrap: wrap;
}

.pn-arrange-apply {
    background: transparent;
    border: 1px solid #0f3460;
    color: #4a90d9;
    padding: 2px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    font-weight: bold;
}

.pn-arrange-apply:hover {
    border-color: #e94560;
    color: #e94560;
}

.pn-arrange-status {
    color: #888;
    font-style: italic;
}

.pn-autodj-panel {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 8px 14px;
    background: #0d1b2a;
    border-bottom: 1px solid #0f3460;
    font-size: 11px;
    color: #ccc;
}

.pn-autodj-toggle,
.pn-autodj-field {
    display: flex;
    align-items: center;
    gap: 6px;
}

.pn-autodj-field select {
    padding: 3px 6px;
    background: #1a1a2e;
    color: #eee;
    border: 1px solid #0f3460;
    border-radius: 3px;
    font-size: 11px;
    cursor: pointer;
}

.pn-autodj-field select:hover {
    border-color: #1a4a7a;
}

.pn-autodj-pools {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    padding: 2px 8px;
    border: 1px solid #0f3460;
    border-radius: 4px;
    background: rgba(15, 52, 96, 0.2);
}

.pn-autodj-pools legend {
    padding: 0 4px;
    font-size: 10px;
    color: #6aa;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.pn-autodj-pools label {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 11px;
    color: #ccc;
    cursor: pointer;
}

.pn-autodj-pools input[type="checkbox"] {
    accent-color: #e94560;
    cursor: pointer;
}

.pn-autodj-test-transition {
    border: 1px solid #64ffda;
    background: transparent;
    color: #64ffda;
    border-radius: 3px;
    padding: 2px 8px;
    font-size: 10px;
    cursor: pointer;
}

.pn-autodj-test-transition:hover {
    background: rgba(100, 255, 218, 0.1);
}

.pn-autodj-status {
    margin-left: auto;
    color: #6aa;
    font-style: italic;
    font-size: 10px;
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pn-macros-panel {
    display: flex;
    gap: 28px;
    padding: 10px 14px;
    background: #0d1b2a;
    align-items: flex-start;
}

.pn-macro-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 180px;
}

.pn-macro-group-label {
    font-size: 10px;
    color: #9aa;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 0 2px 2px;
    border-bottom: 1px solid #0f3460;
    margin-bottom: 2px;
}

.pn-macro-item {
    display: flex;
    gap: 6px;
    align-items: center;
}

.pn-macro-item .pn-macro-btn {
    flex: 1;
    text-align: left;
}

.pn-macro-btn {
    padding: 6px 14px;
    border: 1px solid #0f3460;
    border-radius: 4px;
    background: #1a1a2e;
    color: #eee;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    min-width: 80px;
}

.pn-macro-btn:hover {
    border-color: #e94560;
    color: #e94560;
}

.pn-macro-btn.firing {
    background: #e94560;
    color: #fff;
    border-color: #e94560;
}

.pn-macro-btn.running {
    background: #e94560;
    color: #fff;
    border-color: #f8b3c0;
    animation: pn-macro-pulse 1s ease-in-out infinite;
}

@keyframes pn-macro-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(233, 69, 96, 0.7); }
    50%      { box-shadow: 0 0 10px 3px rgba(233, 69, 96, 0.95); }
}

.pn-macro-btn.pn-macro-disabled {
    opacity: 0.4;
    text-decoration: line-through;
    color: #888;
    border-color: #444;
}

.pn-macro-btn.pn-macro-disabled:hover {
    border-color: #e94560;
    color: #aaa;
}

.pn-macro-edit-group { min-width: 120px; }

.pn-macros-edit {
    padding: 6px 10px;
    border: 1px solid #0f3460;
    border-radius: 4px;
    background: #1a1a2e;
    color: #eee;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}
.pn-macros-edit:hover { border-color: #f5a623; color: #f5a623; }
.pn-macros-edit.active {
    background: #f5a623;
    color: #1a1a2e;
    border-color: #f5a623;
}

.pn-macro-edit-hint {
    font-size: 10px;
    color: #9aa;
    display: none;
}
.pn-macros-panel.pn-edit-mode .pn-macro-edit-hint { display: block; }

/* In edit mode, tiles look "tappable to toggle" rather than "firing" */
.pn-macros-panel.pn-edit-mode .pn-macro-btn {
    border-style: dashed;
    border-color: #f5a623;
}
.pn-macros-panel.pn-edit-mode .pn-macro-btn:hover {
    background: #2a2030;
    color: #f5a623;
}

.pn-macro-btn.queued {
    border-color: #f5a623;
    color: #f5a623;
    animation: pn-macro-queued-pulse 1.2s ease-in-out infinite;
    position: relative;
}

/* Transition-eligible macros: teal left accent stripe. Picked up by the
 * Auto-DJ Transition pool on regen / shuffle-next / repeat-restart. */
.pn-macro-btn.pn-macro-transition {
    border-left: 3px solid #64ffda;
    padding-left: 11px;
}

@keyframes pn-macro-queued-pulse {
    0%, 100% { box-shadow: inset 0 0 0 0 rgba(245, 166, 35, 0.0); }
    50%      { box-shadow: inset 0 0 0 2px rgba(245, 166, 35, 0.5); }
}

.pn-macro-queue-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 9px;
    background: #f5a623;
    color: #1a1a2e;
    font-size: 10px;
    font-weight: bold;
    line-height: 18px;
    text-align: center;
}

.pn-macro-bars {
    padding: 4px 6px;
    background: #1a1a2e;
    color: #eee;
    border: 1px solid #0f3460;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
}

.pn-macro-bars:hover {
    border-color: #1a4a7a;
}

.pn-macro-pitch {
    padding: 4px 4px;
    background: #1a1a2e;
    color: #c3a6ff;
    border: 1px solid #0f3460;
    border-radius: 4px;
    font-size: 10px;
    cursor: pointer;
    min-width: 48px;
}

.pn-macro-pitch:hover {
    border-color: #6e4adf;
}

/* One-shot rows occupy their own top strip in the macros panel and match the
 * per-track mixer row styling: full-width horizontal layout with a Fire button,
 * instrument dropdown, Hits/Pit selects, and Vol/HP/HPR/LP/LPR/Atk/Dec sliders.
 * Everything below flows as the existing macro columns. */
.pn-os-rows {
    /* 2×2 grid clustered to the left — auto-sized columns so each Fire
     * pad takes only as much space as its controls need, instead of
     * stretching to fill the entire panel width. */
    display: grid;
    grid-template-columns: repeat(2, max-content);
    gap: 8px;
    justify-content: start;
    padding: 8px 14px;
    border-bottom: 1px solid #0f3460;
}

.pn-os-pad {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    border: 1px solid #0f3460;
    border-radius: 4px;
    background: #0d1b2a;
}

.pn-os-pair {
    padding: 3px 4px;
    background: #1a1a2e;
    color: #c3a6ff;
    border: 1px solid #0f3460;
    border-radius: 3px;
    font-size: 10px;
    cursor: pointer;
    max-width: 110px;
}

.pn-os-pair:hover {
    border-color: #6e4adf;
}

/* Bar selector next to Fire — matches the shape of pn-macro-bars in
 * the main Macros panel so both readouts read as the same control. */
.pn-os-bars {
    padding: 3px 4px;
    background: #1a1a2e;
    color: #c3a6ff;
    border: 1px solid #0f3460;
    border-radius: 3px;
    font-size: 10px;
    cursor: pointer;
}
.pn-os-bars:hover {
    border-color: #6e4adf;
}

.pn-os-fire {
    flex: 0 0 auto;
    min-width: 130px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 700;
    text-align: center;
    letter-spacing: 0.3px;
}

.pn-os-repeat {
    width: 14px;
    height: 14px;
    margin: 0 2px 0 0;
    cursor: pointer;
    accent-color: #e94560;
    flex-shrink: 0;
}

.pn-os-inst {
    /* Already inherits .pn-mixer-instrument styling */
}

.pn-macro-columns {
    display: flex;
    gap: 28px;
    padding: 4px 14px 10px;
    align-items: flex-start;
}

.pn-macro-panic {
    background: transparent;
    border: 1px solid #6a1020;
    color: #e94560;
    padding: 2px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.pn-macro-panic:hover {
    background: #4a0818;
    border-color: #e94560;
    color: #fff;
}

.pn-fx-bypass, .pn-fx-reset, .pn-cc-reset {
    background: transparent;
    border: 1px solid #0f3460;
    color: #666;
    padding: 2px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 10px;
}

.pn-fx-bypass:hover, .pn-fx-reset:hover, .pn-cc-reset:hover {
    color: #4a90d9;
    border-color: #4a90d9;
}

.pn-fx-bypass.active {
    background: #e94560;
    border-color: #e94560;
    color: #fff;
}

.pn-effects-panel {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px 16px;
    padding: 8px 12px;
    background: #0d1b2a;
}

.pn-fx-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.pn-fx-label {
    font-size: 11px;
    font-weight: bold;
    color: #e94560;
    border-bottom: 1px solid #0f3460;
    padding-bottom: 2px;
    margin-bottom: 2px;
}

.pn-fx-control {
    display: flex;
    align-items: center;
    gap: 4px;
}

.pn-fx-control span {
    font-size: 10px;
    color: #666;
    min-width: 20px;
}

.pn-fx-slider {
    width: 70px;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: #0f3460;
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.pn-fx-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #e94560;
    cursor: pointer;
}

.pn-fx-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #e94560;
    cursor: pointer;
    border: none;
}

/* .pn-fx-value removed — values surface via .pn-slider-tip cursor
 * tooltip now, so the FX panel keeps a tighter footprint. */

/* Timeline */
.pn-timeline {
    display: flex;
    align-items: stretch;
    height: 28px;
    position: relative;
    background: #0a0a1a;
    border-bottom: 1px solid #0f3460;
    flex-shrink: 0;
    overflow: visible;
    cursor: pointer;
    margin: 0 8px;
}

.pn-timeline-section {
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    border-right: 1px solid rgba(0,0,0,0.4);
    transition: opacity 0.2s;
    min-width: 0;
    overflow: hidden;
}

.pn-timeline-section {
    position: relative;
}

.pn-timeline-section span {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    white-space: nowrap;
}

.pn-timeline-phrases {
    font-size: 8px !important;
    font-weight: 400 !important;
    text-transform: none !important;
    letter-spacing: 1px !important;
    opacity: 0.7;
    margin-left: 4px;
}

.pn-timeline-phrase-divider {
    position: absolute;
    top: 0;
    width: 1px;
    height: 100%;
    background: rgba(255,255,255,0.25);
    pointer-events: none;
}

/* Loop markers */
.pn-loop-marker {
    position: absolute;
    top: 0;
    width: 8px;
    height: 100%;
    z-index: 3;
    cursor: ew-resize;
}

.pn-loop-start {
    border-left: 3px solid #f5a623;
    background: linear-gradient(to right, rgba(245,166,35,0.25), transparent);
}

.pn-loop-end {
    border-right: 3px solid #f5a623;
    background: linear-gradient(to left, rgba(245,166,35,0.25), transparent);
    transform: translateX(-8px);
}

.pn-loop-marker:hover {
    border-color: #ffc857;
}

.pn-loop-region {
    position: absolute;
    top: 0;
    height: 100%;
    background: rgba(245, 166, 35, 0.08);
    border-top: 2px solid rgba(245, 166, 35, 0.4);
    z-index: 1;
    pointer-events: none;
    display: none;
}

.pn-crop-bar-btn {
    background: #f5a623;
    border: none;
    border-radius: 3px;
    color: #000;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    padding: 2px 8px;
    margin-left: 8px;
}

.pn-crop-bar-btn:hover {
    background: #ffc857;
}

.pn-timeline-playhead {
    position: absolute;
    top: 0;
    left: 0;
    width: 2px;
    height: 100%;
    background: #fff;
    box-shadow: 0 0 6px rgba(255,255,255,0.8);
    z-index: 2;
    transition: left 0.1s linear;
    pointer-events: none;
}

/* (Track settings replaced by mixer panel above) */

/* Main workspace */
.pn-workspace {
    flex: 1;
    display: flex;
    position: relative;
    overflow: hidden;
    min-height: 400px;
}

/* Canvas container */
.pn-canvas-container {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.pn-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Stage for DOM nodes */
.pn-stage {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Petri net nodes */
.pn-node {
    position: absolute;
    pointer-events: auto;
    cursor: grab;
    user-select: none;
}

.pn-node:active {
    cursor: grabbing;
}

.pn-node.selected {
    filter: drop-shadow(0 0 8px #e94560);
}

/* Places */
.pn-place {
    width: 60px;
    height: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.pn-place-circle {
    width: 50px;
    height: 50px;
    border: 3px solid #4a90d9;
    border-radius: 50%;
    background: #1a1a2e;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: bold;
    color: #4a90d9;
}

/* Transitions */
.pn-transition {
    width: 50px;
    height: 50px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.pn-transition-rect {
    width: 40px;
    height: 40px;
    border: 3px solid #e94560;
    background: #1a1a2e;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pn-transition.firing .pn-transition-rect {
    background: #e94560;
    box-shadow: 0 0 20px #e94560;
}

/* Persistent playhead — the last-fired transition stays lit until the
 * next one fires, so the beat's position on the ring reads at a glance.
 * Softer than .firing so repeated fires still "flash" on top. */
.pn-transition.playhead .pn-transition-rect {
    border-color: #ffd36a;
    box-shadow: 0 0 14px rgba(255, 211, 106, 0.7), inset 0 0 6px rgba(255, 211, 106, 0.35);
}

.pn-transition.has-midi .pn-transition-rect {
    background: linear-gradient(135deg, #1a1a2e 50%, #2d1f3d 50%);
}

/* Node labels */
.pn-label {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 4px;
    font-size: 11px;
    color: #888;
    white-space: nowrap;
    pointer-events: auto;
}

/* MIDI indicator on transition */
.pn-midi-badge {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 34px;
    height: 34px;
    background: rgba(155, 89, 182, 0.4);
    border-radius: 4px;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.12s ease, box-shadow 0.12s ease;
}
.pn-midi-badge:hover {
    background: rgba(155, 89, 182, 0.7);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.2) inset;
}
.pn-midi-badge--empty {
    background: transparent;
    border: 1px dashed rgba(255, 255, 255, 0.25);
    color: rgba(255, 255, 255, 0.45);
    font-size: 14px;
    font-weight: 600;
    opacity: 0;
}
.pn-transition:hover .pn-midi-badge--empty {
    opacity: 1;
}
.pn-midi-badge--empty:hover {
    background: rgba(155, 89, 182, 0.25);
    border-color: rgba(155, 89, 182, 0.8);
    color: rgba(255, 255, 255, 0.9);
    opacity: 1;
}

/* (Toolbar removed - diagram is read-only) */

/* Status bar */
.pn-status {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 4px 16px;
    padding-bottom: calc(4px + env(safe-area-inset-bottom, 0px));
    background: #16213e;
    border-top: 1px solid #0f3460;
    font-size: 12px;
    color: #666;
    flex-shrink: 0;
}

.pn-status .connected {
    color: #2ecc71;
}

.pn-status .disconnected {
    color: #e74c3c;
}

/* MIDI binding editor modal */
.pn-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.pn-modal {
    background: #16213e;
    border-radius: 12px;
    padding: 24px;
    min-width: 400px;
    max-width: 90vw;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.pn-modal h2 {
    margin: 0 0 16px 0;
    font-size: 18px;
    color: #e94560;
}

.pn-modal-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.pn-modal-row label {
    width: 80px;
    font-size: 13px;
    color: #888;
}

.pn-modal-row input,
.pn-modal-row select {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #0f3460;
    border-radius: 4px;
    background: #1a1a2e;
    color: #eee;
    font-size: 14px;
}

.pn-modal-row input[name="noteName"] {
    flex: 0 0 80px;
    text-transform: none;
}

.pn-modal-row input.pn-invalid {
    border-color: #e94560;
}

.pn-modal-desc {
    font-size: 12px;
    color: #888;
    margin: 0 0 16px 0;
    line-height: 1.4;
}

.pn-modal-hint {
    font-size: 11px;
    color: #778;
    margin: 8px 0 16px 0;
    line-height: 1.5;
}

.pn-share-inline-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 10px 0 6px 0;
    font-size: 12px;
    color: #bbb;
    user-select: none;
}

.pn-share-storage {
    background: #0f1a2e;
    color: #ddd;
    border: 1px solid #2a3a5a;
    border-radius: 4px;
    padding: 4px 6px;
    font-size: 12px;
    cursor: pointer;
    font-variant-numeric: tabular-nums;
}

.pn-share-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 6px 0 10px 0;
    font-size: 12px;
    color: #bbb;
}

.pn-share-title-row > span {
    flex: 0 0 auto;
}

.pn-share-title {
    flex: 1;
    background: #0f1a2e;
    color: #eee;
    border: 1px solid #2a3a5a;
    border-radius: 4px;
    padding: 6px 8px;
    font-size: 13px;
    font-family: inherit;
}

.pn-share-title:focus {
    outline: none;
    border-color: #4a90d9;
}

.pn-share-preview {
    margin: 12px 0 6px 0;
    border-radius: 6px;
    overflow: hidden;
    background: #0d0d0d;
    line-height: 0;
}

.pn-share-preview-img {
    width: 100%;
    height: auto;
    display: block;
    aspect-ratio: 1200 / 630;
}

.pn-modal-row input[type="checkbox"] {
    flex: 0 0 auto;
    width: auto;
    margin: 0;
}

.pn-modal-row .pn-trait-val {
    flex: 0 0 50px;
    text-align: right;
    font-size: 13px;
    color: #ccc;
}

.pn-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
}

.pn-modal-actions button {
    padding: 8px 20px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
}

.pn-modal-actions .cancel {
    background: transparent;
    color: #888;
}

.pn-modal-actions .save {
    background: #e94560;
    color: #fff;
}

/* Piano keyboard for note selection */
.pn-piano {
    display: flex;
    height: 80px;
    margin: 12px 0;
    position: relative;
}

.pn-piano-key {
    flex: 1;
    border: 1px solid #333;
    background: #eee;
    cursor: pointer;
    position: relative;
}

.pn-piano-key.black {
    background: #222;
    width: 60%;
    height: 60%;
    position: absolute;
    z-index: 1;
}

.pn-piano-key.selected {
    background: #e94560;
}

.pn-piano-key.white.selected {
    background: #f7a8b8;
}

/* Generate controls */
.pn-generate {
    display: flex;
    gap: 6px;
    align-items: center;
}

.pn-genre-select {
    padding: 6px 8px;
    border: 1px solid #0f3460;
    border-radius: 4px;
    background: #1a1a2e;
    color: #eee;
    font-size: 12px;
}

.pn-structure-select,
.pn-loop-mode-select {
    padding: 6px 8px;
    border: 1px solid #0f3460;
    border-radius: 4px;
    background: #1a1a2e;
    color: #eee;
    font-size: 12px;
}

.pn-generate-btn {
    padding: 6px 14px;
    border: 1px solid #e94560;
    border-radius: 4px;
    background: #e94560;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.pn-generate-btn:hover {
    background: #d63851;
}

.pn-shuffle-btn {
    padding: 6px 14px;
    border: 1px solid #0f3460;
    border-radius: 4px;
    background: #0f3460;
    color: #ccc;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.pn-shuffle-btn:hover {
    background: #16213e;
    color: #fff;
}

.pn-stage-btn {
    padding: 6px 12px;
    border: 1px solid #533483;
    border-radius: 4px;
    background: transparent;
    color: #c3a6ff;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
.pn-stage-btn:hover {
    background: #533483;
    color: #fff;
}

.pn-download-btn,
.pn-upload-btn,
.pn-share-btn {
    padding: 4px 8px;
    border: 1px solid #0f3460;
    border-radius: 4px;
    background: #0f3460;
    color: #ccc;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.2s;
}

.pn-download-btn:hover,
.pn-upload-btn:hover,
.pn-share-btn:hover {
    background: #16213e;
    color: #64ffda;
}

.pn-share-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.pn-share-btn svg {
    display: block;
}

.pn-upload-btn {
    padding: 4px 8px;
    border: 1px solid #0f3460;
    border-radius: 4px;
    background: #0f3460;
    color: #ccc;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.2s;
}

/* Generator options toggle button */
.pn-gen-opts-toggle {
    width: 30px;
    height: 30px;
    border: 1px solid #0f3460;
    border-radius: 4px;
    background: transparent;
    color: #888;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
}

.pn-gen-opts-toggle:hover {
    background: rgba(255,255,255,0.05);
    color: #eee;
    border-color: #1a4a7a;
}

/* Generator options panel (collapsible) */
.pn-gen-options {
    display: flex;
    gap: 16px;
    align-items: center;
    padding: 6px 16px;
    background: #0f1a2e;
    border-bottom: 1px solid #0f3460;
    flex-shrink: 0;
}

.pn-gen-options label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: #aaa;
    cursor: pointer;
    user-select: none;
}

.pn-gen-options label:hover {
    color: #eee;
}

.pn-gen-options input[type="checkbox"] {
    accent-color: #e94560;
    cursor: pointer;
}

/* (Control ghosts removed - control nets shown in mixer) */

/* Help button */
.pn-help-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid #0f3460;
    background: transparent;
    color: #666;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.pn-help-btn:hover {
    color: #4a90d9;
    border-color: #4a90d9;
}

.pn-gh-link {
    color: #888;
    display: inline-flex;
    align-items: center;
    margin-left: 6px;
    transition: color 0.15s;
}
.pn-gh-link:hover {
    color: #fff;
}

/* "Using with AI" modal — copyable prompt; invoked from both the main
   help modal and the Stage help modal. Top-level overlay on body so it
   layers above either caller. */
.pn-ai-prompt-overlay {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 1500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.pn-ai-prompt-box {
    position: relative;
    max-width: 640px;
    width: 100%;
    max-height: 86vh;
    overflow-y: auto;
    background: linear-gradient(180deg, #0d1026 0%, #060814 100%);
    border: 1px solid rgba(74,144,217,0.3);
    border-radius: 12px;
    padding: 28px 32px 24px;
    color: #dce3f0;
    font-size: 13px;
    line-height: 1.55;
}
.pn-ai-prompt-box h2 { margin: 0 0 10px; font-size: 19px; color: #fff; font-weight: 600; }
.pn-ai-prompt-lede { color: #cfd6e5; margin: 0 0 14px; }
.pn-ai-prompt-lede code {
    background: rgba(255,255,255,0.07);
    padding: 1px 5px; border-radius: 3px; font-size: 12px;
}
.pn-ai-prompt-actions { display: flex; align-items: center; gap: 12px; margin: 0 0 10px; }
.pn-ai-prompt-copy {
    background: rgba(74,144,217,0.22);
    border: 1px solid rgba(74,144,217,0.55);
    color: #dce3f0;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
}
.pn-ai-prompt-copy:hover { background: rgba(74,144,217,0.35); color: #fff; }
.pn-ai-prompt-feedback { color: #64ffda; font-size: 12px; }
.pn-ai-prompt-text {
    width: 100%;
    min-height: 260px;
    box-sizing: border-box;
    background: rgba(0,0,0,0.45);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 8px;
    padding: 12px 14px;
    color: #cfe0f6;
    font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
    font-size: 12px;
    line-height: 1.5;
    resize: vertical;
}
.pn-ai-prompt-foot { color: #8a93a6; margin: 12px 0 0; font-size: 12px; }
.pn-ai-prompt-foot a { color: #4a90d9; text-decoration: none; }
.pn-ai-prompt-foot a:hover { color: #a8d0ff; text-decoration: underline; }
.pn-ai-prompt-close {
    position: absolute;
    top: 10px; right: 12px;
    width: 32px; height: 32px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.15);
    color: #eee;
    font-size: 20px; line-height: 1;
    border-radius: 50%;
    cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0;
}
.pn-ai-prompt-close:hover { background: rgba(255,255,255,0.12); }

/* Inline link-style button used in help bodies to trigger the AI prompt modal. */
.pn-link-btn {
    background: transparent;
    border: none;
    padding: 0;
    color: #4a90d9;
    font: inherit;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.pn-link-btn:hover { color: #a8d0ff; }

/* Help modal */
.pn-help-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pn-help-modal {
    background: #0a0a1a;
    border: 1px solid #0f3460;
    border-radius: 8px;
    padding: 24px 32px;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    color: #ccc;
    font-size: 13px;
    line-height: 1.6;
    position: relative;
}

.pn-help-modal h2 {
    color: #e94560;
    font-size: 18px;
    margin: 0 0 16px 0;
}

.pn-help-modal h3 {
    color: #4a90d9;
    font-size: 14px;
    margin: 16px 0 6px 0;
    border-bottom: 1px solid #0f3460;
    padding-bottom: 4px;
}

.pn-help-modal ul {
    margin: 0;
    padding-left: 18px;
}

.pn-help-modal li {
    margin-bottom: 4px;
}

.pn-help-modal b {
    color: #fff;
}

.pn-help-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    color: #666;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.pn-help-close:hover {
    color: #e94560;
}

/* Audio output selector */
.pn-audio-mode {
    display: flex;
    gap: 8px;
}

.pn-audio-mode button {
    padding: 6px 12px;
    border: 1px solid #0f3460;
    border-radius: 4px;
    background: transparent;
    color: #888;
    font-size: 12px;
    cursor: pointer;
}

.pn-audio-mode button.active {
    border-color: #e94560;
    color: #e94560;
}

.pn-wakelock-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    padding: 4px 8px !important;
}

.pn-wakelock-btn svg {
    display: block;
}

.pn-midi-output {
    padding: 6px 8px;
    border: 1px solid #0f3460;
    border-radius: 4px;
    background: #1a1a2e;
    color: #eee;
    font-size: 12px;
    cursor: pointer;
    min-width: 150px;
}

.pn-midi-output:hover {
    border-color: #1a4a7a;
}

/* Animations */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.pn-transition.firing {
    animation: pulse 0.1s ease-out;
}

/* ===== Tablet (iPad Mini landscape & portrait) ===== */
@media (max-width: 1100px) {
    .pn-riff-variants {
        display: none;
    }

    .pn-upload-input {
        display: none;
    }
}

/* ===== Small screens: just hide riff variants ===== */
@media (max-width: 600px) {
    .pn-riff-variants {
        display: none;
    }

    .pn-modal {
        min-width: unset;
        width: 95vw;
        padding: 16px;
    }
}

/* ===== Landscape phone: extra bottom clearance for Chrome bar ===== */
@media (max-height: 500px) and (orientation: landscape) {
    .pn-status {
        padding-bottom: calc(40px + env(safe-area-inset-bottom, 0px));
    }
}

/* --- Full-page Stage (lib/ui/stage.js) --- */
.pn-stage-overlay {
    position: fixed; inset: 0;
    background: #0a0a1a;
    z-index: 1100;
    display: flex;
}
/* Feel modal floats above Stage so it can be opened from the stage
   toolbar (or via the F hotkey) without being occluded by the overlay. */
.pn-feel-overlay { z-index: 1200; }
.pn-stage-menu {
    position: absolute;
    top: 12px;
    left: 14px;
    display: flex;
    gap: 4px;
    z-index: 3;
    background: rgba(0,0,0,0.35);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 999px;
    padding: 4px;
}
/* Force monochrome rendering on emoji-presentation glyphs (⚡, etc.)
   so they pick up the toolbar's color rather than the OS yellow. */
.pn-stage-menu button { font-variant-emoji: text; }
/* Burger: single dot mirroring the close × on the opposite side.
   Tapping it expands the full toolbar. Starts collapsed so the
   stage is mostly bare visual space by default. */
.pn-stage-burger {
    position: absolute; top: 10px; left: 14px;
    width: 32px; height: 32px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.15);
    color: #eee; font-size: 22px; line-height: 1;
    border-radius: 50%; cursor: pointer;
    z-index: 4;
    padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
    transition: background 120ms;
}
.pn-stage-burger:hover { background: rgba(255,255,255,0.12); }
.pn-stage-overlay.menu-collapsed .pn-stage-menu { display: none; }
.pn-stage-overlay:not(.menu-collapsed) .pn-stage-burger { display: none; }
.pn-stage-menu button {
    width: 32px; height: 32px;
    background: transparent;
    border: 1px solid transparent;
    color: rgba(255,255,255,0.55);
    font-size: 18px; line-height: 1;
    border-radius: 999px;
    cursor: pointer;
    transition: color 120ms, background 120ms, border-color 120ms;
}
.pn-stage-menu button:hover { color: #fff; }
.pn-stage-menu button.active {
    color: #fff;
    background: rgba(74,144,217,0.22);
    border-color: rgba(74,144,217,0.55);
}
.pn-stage-menu .pn-stage-scale {
    margin-left: 4px;
    height: 32px;
    padding: 0 8px;
    background: rgba(255,255,255,0.04);
    color: #eee;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 999px;
    font-size: 12px;
    cursor: pointer;
}
.pn-stage-menu .pn-stage-scale:focus { outline: none; border-color: rgba(74,144,217,0.55); }

/* Background canvas behind the meta-diagram (Void/Stars/Aurora). */
.pn-stage-bg {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
}

/* Scope canvas — used by every non-Constellation visualizer (Corona,
 * Sonar, Petal, Clock, Trails). Sits above the background; in any of
 * those "solo" visualizer modes it floats above the panels and the
 * rings + flame canvas hide so the new geometry reads cleanly. */
.pn-stage-scope {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
}
.pn-stage-overlay.viz-solo .pn-stage-scope { z-index: 5; }
.pn-stage-overlay.viz-solo .pn-stage-grid { opacity: 0; pointer-events: none; }
.pn-stage-overlay.viz-solo .pn-stage-flame { display: none; }
/* Constellation-specific toolbar controls — hide them while a non-
 * Constellation visualizer (Corona / Sonar / Petal) is active so the
 * toolbar shows only what applies. */
.pn-stage-overlay.viz-solo [data-viz],
.pn-stage-overlay.viz-solo .pn-stage-expand,
.pn-stage-overlay.viz-solo .pn-stage-backs,
.pn-stage-overlay.viz-solo .pn-stage-labels,
.pn-stage-overlay.viz-solo .pn-stage-bolts,
.pn-stage-overlay.viz-solo .pn-stage-scale { display: none; }

/* Share card flash — briefly appears on track change when the
 * cardflash toggle is on, so a recording captures genre/seed/tempo
 * plus a scannable QR. */
.pn-stage-cardbox {
    position: absolute;
    top: 56px;
    right: 14px;
    z-index: 4;
    width: 560px;
    max-width: 70vw;
    background: rgba(10,12,26,0.85);
    border: 1px solid rgba(74,144,217,0.35);
    border-radius: 10px;
    padding: 10px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.45);
    opacity: 1;
    transition: opacity 500ms ease;
    pointer-events: none;
}
.pn-stage-cardbox.fading { opacity: 0; }
.pn-stage-cardbox svg { display: block; width: 100%; height: auto; }

/* Help modal — read-only explainer for the passive-listener viewer. */
.pn-stage-help-modal {
    position: absolute;
    inset: 0;
    z-index: 5;
    background: rgba(0,0,0,0.72);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    backdrop-filter: blur(4px);
}
.pn-stage-help-box {
    position: relative;
    max-width: 640px;
    max-height: 86vh;
    overflow-y: auto;
    background: linear-gradient(180deg, #0d1026 0%, #060814 100%);
    border: 1px solid rgba(74,144,217,0.3);
    border-radius: 12px;
    padding: 28px 32px 24px;
    color: #dce3f0;
    font-size: 13px;
    line-height: 1.55;
    box-shadow: 0 18px 60px rgba(0,0,0,0.55);
}
.pn-stage-help-box h2 {
    margin: 0 0 12px;
    font-size: 17px;
    letter-spacing: 0.04em;
    color: #fff;
}
.pn-stage-help-box h3 {
    margin: 18px 0 8px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: rgba(74,144,217,0.95);
}
.pn-stage-help-box p { margin: 0 0 10px; }
.pn-stage-help-box ul { margin: 0; padding-left: 18px; }
.pn-stage-help-box li { margin: 0 0 6px; }
.pn-stage-help-box b { color: #fff; }
.pn-stage-help-box a {
    color: #78b4ff;
    text-decoration: underline;
    text-decoration-color: rgba(120, 180, 255, 0.35);
}
.pn-stage-help-box a:hover { color: #a8d0ff; text-decoration-color: rgba(168, 208, 255, 0.8); }
.pn-stage-help-box kbd {
    display: inline-block;
    padding: 1px 6px;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 4px;
    background: rgba(255,255,255,0.05);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 11px;
}
.pn-stage-help-lede { color: #cfd6e5; }
.pn-stage-help-foot {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.55);
    font-size: 12px;
}
.pn-help-sym {
    display: inline-block;
    width: 10px;
    height: 10px;
    border: 1.5px solid rgba(233,69,96,0.85);
    vertical-align: -1px;
    margin: 0 2px;
}
.pn-help-sym.circle { border-radius: 50%; border-color: rgba(74,144,217,0.85); }
.pn-stage-help-close {
    position: absolute;
    top: 8px; right: 10px;
    width: 28px; height: 28px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 50%;
    color: #eee;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}
.pn-stage-help-close:hover { background: rgba(255,255,255,0.12); }
.pn-stage-stats {
    position: absolute;
    bottom: 18px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3;
    color: rgba(255,255,255,0.6);
    font-size: 11px;
    letter-spacing: 0.04em;
    white-space: nowrap;
    pointer-events: none;
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 999px;
    padding: 6px 14px;
}
.pn-stage-grid {
    /* No transition on transform — the rAF loop writes transform
     * every frame for tilt + meta-rotation. A CSS transition here
     * fought with those writes and made layoutRing's stash-and-
     * measure trick read a stale rect, so the ring drifted below the
     * viewport after successive track changes. */
    transform-style: preserve-3d;
}
.pn-stage-close,
.pn-stage-overlay > .pn-stage-fullscreen {
    position: absolute; top: 10px;
    width: 32px; height: 32px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.15);
    color: #eee; font-size: 20px; line-height: 1;
    border-radius: 50%; cursor: pointer;
    z-index: 2;
}
.pn-stage-close { right: 14px; }
.pn-stage-overlay > .pn-stage-fullscreen { right: 54px; }
.pn-stage-close:hover,
.pn-stage-overlay > .pn-stage-fullscreen:hover { background: rgba(255,255,255,0.12); }
/* External fullscreen button used to sit inside .pn-stage-menu, which
   styled its .active state. Moving it out orphaned that feedback, so
   clicks looked no-op on an already-filling overlay. Restore an
   obvious active treatment. */
.pn-stage-overlay > .pn-stage-fullscreen.active {
    color: #fff;
    background: rgba(74,144,217,0.30);
    border-color: rgba(74,144,217,0.7);
}
/* Pseudo-fullscreen fallback — Stage already position:fixed fills the
   viewport, so when the real Fullscreen API is refused (iOS Safari on
   iPhone, sandboxed iframes, kiosk windows) we hide body scroll and
   force the overlay's z-index above anything else. Visually near-
   identical to real fullscreen for this specific overlay. */
.pn-stage-overlay.pn-stage-pseudo-fs {
    z-index: 2147483647;
}
/* Desktops have Esc; hide the floating × there. Touch devices
   (phones/tablets — `pointer: coarse`) keep the button because
   there's no practical keyboard fallback. */
@media (hover: hover) and (pointer: fine) {
    .pn-stage-close { display: none; }
}
/* Ring-of-rings composition: each sub-net panel is a square placed
   around a big circle. Positions are set inline from JS (stage.js
   layoutRing) because they depend on panel count + viewport. */
.pn-stage-grid {
    position: relative;
    flex: 1;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    /* overflow:visible — tilt's perspective projection enlarges the
     * grid's bounding box past viewport dims; hidden would clip the
     * bottom/sides of the ring at peak rotation angles. */
    overflow: visible;
    /* Sit above the bg canvas (Void/Stars/Aurora). */
    z-index: 1;
}
.pn-stage-panel {
    position: absolute;
    background: radial-gradient(circle at center, #131a33 0%, #070712 100%);
    border: 1px solid rgba(74,144,217,0.18);
    border-radius: 10px;
    /* overflow:visible so sub-rings drawn slightly past the panel box
     * (canvas nodes at scale, or mandala panels that intentionally
     * overlap at high N) don't get cropped into ugly half-arcs. */
    overflow: visible;
    aspect-ratio: 1 / 1;
    transition: opacity 280ms ease;
    /* Sit above the flame + pulse layers in the meta SVG so beat
     * particles emerging from a panel's center appear to pass BEHIND
     * the ring outlines and reappear in the composition's negative
     * space, instead of floating on top of the rings. */
    z-index: 2;
}
.pn-stage-panel.muted {
    opacity: 0.25;
}
.pn-stage-overlay.hide-backs .pn-stage-panel {
    background: transparent;
    border-color: transparent;
}
.pn-stage-overlay.hide-labels .pn-stage-panel .pn-stage-label {
    display: none;
}
.pn-stage-meta {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}
.pn-stage-flame {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}
.pn-stage-panel .pn-stage-canvas {
    position: absolute; inset: 0; width: 100%; height: 100%;
    pointer-events: none;
}
.pn-stage-panel .pn-stage-stage {
    position: absolute; inset: 0;
    pointer-events: none;
}
.pn-stage-panel .pn-stage-label {
    position: absolute; top: 8px; left: 10px;
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.55);
    pointer-events: none;
}

