/**
 * Sketch Library Panel — slide-out from the right edge.
 *
 * Two pieces:
 *   .sketch-library-handle  — persistent tab on the right edge
 *   .sketch-library-panel   — full-height drawer
 */

/* Inside the topbar's file-ops-group — pick up the existing .ui-button look */
.sketch-library-handle--in-topbar {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.sketch-library-handle--in-topbar .sketch-library-handle__icon {
    font-size: 14px;
    line-height: 1;
}

.sketch-library-handle--in-topbar .sketch-library-handle__label {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.sketch-library-handle--active {
    color: var(--accent, #3891ff) !important;
    border-color: var(--accent, #3891ff);
}

/* Mode-active = the user is currently inside a sketch. Independent of
 * drawer-open state. Renders as a filled accent pill so it reads as a
 * persistent mode indicator rather than a transient hover. */
.sketch-library-handle--mode-active {
    color: var(--bg-1, #0c0c0e) !important;
    background: var(--accent, #3891ff) !important;
    border-color: var(--accent, #3891ff);
}

.sketch-library-handle--mode-active:hover {
    filter: brightness(1.08);
}

/* Floating fallback — only used if the topbar didn't mount in time */
.sketch-library-handle--floating {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 950;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--surface-1, rgba(20, 20, 20, 0.85));
    border: 1px solid var(--border-default, rgba(255, 255, 255, 0.1));
    border-radius: 8px;
    color: var(--text-1, rgba(255, 255, 255, 0.92));
    cursor: pointer;
    backdrop-filter: blur(var(--glass-blur, 12px));
    -webkit-backdrop-filter: blur(var(--glass-blur, 12px));
}

.sketch-library-handle--floating .sketch-library-handle__icon {
    font-size: 14px;
    line-height: 1;
}

.sketch-library-handle--floating .sketch-library-handle__label {
    font-size: 12px;
    font-weight: 600;
}

.sketch-library-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 360px;
    max-width: 92vw;
    z-index: 940;
    display: flex;
    flex-direction: column;
    background: var(--surface-1, rgba(20, 20, 20, 0.92));
    border-left: 1px solid var(--border-default, rgba(255, 255, 255, 0.1));
    color: var(--text-1, rgba(255, 255, 255, 0.92));
    backdrop-filter: blur(var(--glass-blur, 12px));
    -webkit-backdrop-filter: blur(var(--glass-blur, 12px));
    transform: translateX(100%);
    transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.4);
}

.sketch-library-panel.sketch-library-panel--open {
    transition: none;
    transform: translateX(0);
}

.sketch-library-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.05));
}

.sketch-library-panel__title {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-2, rgba(255, 255, 255, 0.7));
    margin: 0;
}

.sketch-library-panel__close {
    background: transparent;
    border: none;
    color: var(--text-2, rgba(255, 255, 255, 0.7));
    font-size: 22px;
    line-height: 1;
    width: 28px;
    height: 28px;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.12s ease, color 0.12s ease;
}

.sketch-library-panel__close:hover {
    background: var(--surface-2, rgba(0, 0, 0, 0.3));
    color: var(--text-1, rgba(255, 255, 255, 0.92));
}

.sketch-library-panel__actions {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.05));
}

.sketch-library-panel__new {
    width: 100%;
    padding: 10px 12px;
    background: var(--accent-bg-soft, rgba(56, 145, 255, 0.2));
    border: 1px solid var(--accent, #3891ff);
    color: var(--accent, #3891ff);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
}

.sketch-library-panel__new:hover {
    background: var(--accent, #3891ff);
    color: white;
}

.sketch-library-panel__list {
    flex: 1;
    overflow-y: auto;
    padding: 6px 0;
}

.sketch-library-panel__empty {
    padding: 24px 16px;
    color: var(--text-3, rgba(255, 255, 255, 0.4));
    font-size: 13px;
    line-height: 1.5;
    text-align: center;
}

.sketch-library-panel__empty strong {
    color: var(--text-2, rgba(255, 255, 255, 0.7));
}

.sketch-row {
    display: flex;
    align-items: stretch;
    border-bottom: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.05));
    transition: background 0.12s ease;
}

.sketch-row:hover {
    background: var(--surface-2, rgba(0, 0, 0, 0.3));
}

.sketch-row--active {
    background: rgba(56, 145, 255, 0.08);
}

.sketch-row--active::before {
    content: '';
    width: 3px;
    background: var(--accent, #3891ff);
}

.sketch-row__main {
    flex: 1;
    text-align: left;
    background: transparent;
    border: none;
    padding: 12px 16px;
    color: inherit;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sketch-row__name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-1, rgba(255, 255, 255, 0.92));
}

.sketch-row__meta {
    font-size: 11px;
    color: var(--text-3, rgba(255, 255, 255, 0.4));
    display: flex;
    gap: 6px;
}

.sketch-row__sep {
    opacity: 0.6;
}

.sketch-row__actions {
    display: flex;
    align-items: center;
    gap: 2px;
    padding-right: 8px;
    opacity: 0;
    transition: opacity 0.12s ease;
}

.sketch-row:hover .sketch-row__actions,
.sketch-row:focus-within .sketch-row__actions {
    opacity: 1;
}

.sketch-row__action {
    background: transparent;
    border: none;
    color: var(--text-2, rgba(255, 255, 255, 0.7));
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    line-height: 1;
    transition: background 0.12s ease, color 0.12s ease;
}

.sketch-row__action:hover {
    background: var(--surface-3, rgba(0, 0, 0, 0.4));
    color: var(--text-1, rgba(255, 255, 255, 0.92));
}

.sketch-row__action--delete:hover {
    color: #ff6b6b;
}

.sketch-row__rename-input {
    background: var(--surface-3, rgba(0, 0, 0, 0.4));
    border: 1px solid var(--accent, #3891ff);
    color: var(--text-1, rgba(255, 255, 255, 0.92));
    font-size: 13px;
    font-weight: 600;
    padding: 4px 6px;
    border-radius: 4px;
    width: 100%;
    outline: none;
    font-family: inherit;
}

/* ─────────────────────────────────────────────────────────────
   Sketch Control Bar — floating strip when a sketch is loaded
   ───────────────────────────────────────────────────────────── */

.sketch-control-bar {
    position: fixed;
    top: 64px;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    z-index: 1105;
    display: none;
    align-items: center;
    gap: 16px;
    padding: 8px 14px;
    background: var(--surface-1, rgba(20, 20, 20, 0.85));
    border: 1px solid var(--border-default, rgba(255, 255, 255, 0.1));
    border-radius: 10px;
    color: var(--text-1, rgba(255, 255, 255, 0.92));
    backdrop-filter: blur(var(--glass-blur, 12px));
    -webkit-backdrop-filter: blur(var(--glass-blur, 12px));
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
    opacity: 0;
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.sketch-control-bar--visible {
    display: flex;
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.sketch-control-bar__label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-right: 8px;
    border-right: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.06));
}

.sketch-control-bar__chip {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.12em;
    padding: 2px 6px;
    background: var(--accent-bg-soft, rgba(56, 145, 255, 0.2));
    color: var(--accent, #3891ff);
    border-radius: 4px;
}

.sketch-control-bar__name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-1, rgba(255, 255, 255, 0.92));
}

.sketch-control-bar__controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sketch-control-bar__record {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 7px;
    border: 1px solid var(--border-strong, rgba(255, 255, 255, 0.2));
    background: var(--surface-2, rgba(0, 0, 0, 0.3));
    color: var(--text-1, rgba(255, 255, 255, 0.92));
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.sketch-control-bar__record:hover {
    background: var(--surface-3, rgba(0, 0, 0, 0.4));
    border-color: #ff5b5b;
    color: #ff5b5b;
}

.sketch-control-bar__record--armed {
    background: rgba(255, 60, 60, 0.18);
    border-color: #ff3c3c;
    color: #ff6b6b;
    animation: sketch-record-pulse 1.4s ease-in-out infinite;
}

.sketch-control-bar__record--armed:hover {
    background: rgba(255, 60, 60, 0.28);
    color: #ffd1d1;
}

.sketch-control-bar__record-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #ff3c3c;
    box-shadow: 0 0 6px rgba(255, 60, 60, 0.7);
}

.sketch-control-bar__record--armed .sketch-control-bar__record-dot {
    background: #ff3c3c;
    box-shadow: 0 0 10px rgba(255, 60, 60, 0.95);
}

@keyframes sketch-record-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 60, 60, 0.35); }
    50%      { box-shadow: 0 0 0 8px rgba(255, 60, 60, 0); }
}

.sketch-control-bar__capture {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 7px;
    border: 1px solid var(--border-default, rgba(255, 255, 255, 0.1));
    background: var(--surface-2, rgba(0, 0, 0, 0.3));
    color: var(--text-2, rgba(255, 255, 255, 0.7));
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
}

.sketch-control-bar__capture[hidden] {
    display: none !important;
}

.sketch-control-bar__capture:hover:not(:disabled) {
    background: var(--surface-3, rgba(0, 0, 0, 0.4));
    color: var(--text-1, rgba(255, 255, 255, 0.92));
}

.sketch-control-bar__capture:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.sketch-control-bar__capture--flash {
    background: var(--accent-bg-soft, rgba(56, 145, 255, 0.2));
    color: var(--accent, #3891ff);
    border-color: var(--accent, #3891ff);
}

.sketch-control-bar__action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 58px;
    padding: 6px 10px;
    border-radius: 7px;
    border: 1px solid var(--border-default, rgba(255, 255, 255, 0.1));
    background: var(--surface-2, rgba(0, 0, 0, 0.3));
    color: var(--text-2, rgba(255, 255, 255, 0.7));
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.sketch-control-bar__action:hover:not(:disabled) {
    background: var(--surface-3, rgba(0, 0, 0, 0.4));
    border-color: var(--accent, #3891ff);
    color: var(--text-1, rgba(255, 255, 255, 0.92));
}

.sketch-control-bar__action:disabled,
.sketch-control-bar__record:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.sketch-control-bar__action--active {
    border-color: #ff5b5b;
    color: #ff8d8d;
    background: rgba(255, 60, 60, 0.14);
}

/* ─────────────────────────────────────────────────────────────
   Capture result toast — appears after Capture, offers Undo + Expand
   ───────────────────────────────────────────────────────────── */

.sketch-capture-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(12px);
    z-index: 930;
    display: none;
    align-items: center;
    gap: 14px;
    padding: 10px 14px;
    background: var(--surface-1, rgba(20, 20, 20, 0.92));
    border: 1px solid var(--border-default, rgba(255, 255, 255, 0.1));
    border-radius: 10px;
    color: var(--text-1, rgba(255, 255, 255, 0.92));
    box-shadow: 0 6px 22px rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(var(--glass-blur, 12px));
    -webkit-backdrop-filter: blur(var(--glass-blur, 12px));
    opacity: 0;
    transition: opacity 0.16s ease, transform 0.16s ease;
    max-width: 90vw;
}

.sketch-capture-toast--visible {
    display: flex;
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.sketch-capture-toast__msg {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-1, rgba(255, 255, 255, 0.92));
}

.sketch-capture-toast__actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.sketch-capture-toast__expand,
.sketch-capture-toast__undo {
    padding: 5px 10px;
    border-radius: 6px;
    border: 1px solid var(--border-strong, rgba(255, 255, 255, 0.2));
    background: var(--surface-2, rgba(0, 0, 0, 0.3));
    color: var(--text-1, rgba(255, 255, 255, 0.92));
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.sketch-capture-toast__expand:hover,
.sketch-capture-toast__undo:hover {
    background: var(--accent-bg-soft, rgba(56, 145, 255, 0.2));
    border-color: var(--accent, #3891ff);
    color: var(--accent, #3891ff);
}

.sketch-capture-toast__close {
    background: transparent;
    border: none;
    color: var(--text-2, rgba(255, 255, 255, 0.7));
    font-size: 18px;
    line-height: 1;
    width: 24px;
    height: 24px;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
}

.sketch-capture-toast__close:hover {
    background: var(--surface-3, rgba(0, 0, 0, 0.4));
    color: var(--text-1, rgba(255, 255, 255, 0.92));
}

.sketch-control-bar__quantize {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--text-2, rgba(255, 255, 255, 0.7));
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.sketch-control-bar__quantize select {
    background: var(--surface-3, rgba(0, 0, 0, 0.4));
    color: var(--text-1, rgba(255, 255, 255, 0.92));
    border: 1px solid var(--border-default, rgba(255, 255, 255, 0.1));
    border-radius: 6px;
    padding: 4px 6px;
    font-size: 12px;
    font-weight: 600;
    text-transform: none;
    cursor: pointer;
}

/* When the body enters sketch-mode, hide the song-playback waterfall but keep
   the composite tracklane visible. The composite shows the user the rolled-up
   MIDI across all sketch lanes — Phase F restored this so the multitrack
   sketchpad has a "summary" view at the top of the lane stack. */

body.sketch-mode .waterfall-container,
body.sketch-mode #waterfall {
    display: none !important;
}
