:root {
    --bg: #141618;
    --surface: #1c1f24;
    --surface-2: #262a31;
    --border: rgba(255,255,255,0.1);
    --text: #eceff4;
    --text-dim: #9aa3b2;
    --accent: #c9a227;
    --accent-hover: #dbb42e;
    --accent-soft: rgba(201,162,39,0.18);
    --danger: #c53030;
    --danger-glow: rgba(197,48,48,0.25);
    --success: #3d8f5f;
    --font: 'DM Sans', system-ui, sans-serif;
    --mono: 'JetBrains Mono', monospace;
    --radius: 10px;
    --vu-width: clamp(108px, 11vmin, 140px);
    --grid-cols: 4;
    --grid-rows: 4;
    --page-btn-h: clamp(2.75rem, 6vmin, 3.5rem);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    overflow: hidden;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    background: var(--bg);
}

.app:fullscreen {
    width: 100%;
    height: 100%;
}

/* Peak meter → assets/peak-meter.css (LevelScope) */

/* ── Main area ── */
.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    background: var(--bg);
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: clamp(0.45rem, 1.2vmin, 0.65rem) clamp(0.75rem, 2vw, 1.25rem);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.topbar-left { display: flex; align-items: center; gap: 0.75rem; min-width: 0; }

.brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text);
    text-decoration: none;
    font-weight: 700;
    font-size: clamp(0.95rem, 1.8vw, 1.05rem);
    white-space: nowrap;
}
.brand:hover { color: var(--accent); }

.badge-live {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    padding: 0.2rem 0.45rem;
    border-radius: 3px;
    background: var(--danger);
    color: #fff;
    flex-shrink: 0;
}

.sd-bridge {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4b5563;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px rgba(75,85,99,0.35);
    transition: background 0.2s, box-shadow 0.2s;
}
.sd-bridge.waiting {
    background: #8b6914;
    box-shadow: 0 0 6px rgba(139,105,20,0.4);
    animation: sd-pulse 2s ease infinite;
}
.sd-bridge.connected {
    background: var(--accent);
    box-shadow: 0 0 8px rgba(201,162,39,0.55);
    animation: none;
}
.sd-bridge.disabled {
    background: #6b7280;
    box-shadow: none;
    animation: none;
}
@keyframes sd-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.45; }
}

.ntp-clock {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--text, #eceff4);
    flex-shrink: 0;
}
.ntp-time { min-width: 5.5ch; }
.ntp-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #6b7280;
    flex-shrink: 0;
}
.ntp-dot.synced { background: #22c55e; }
.ntp-dot.syncing { background: #eab308; animation: sd-pulse 1s ease infinite; }
.ntp-dot.error { background: #ef4444; }

@media (max-width: 900px) {
    .ntp-clock { display: none; }
}

.topbar-controls {
    display: flex;
    align-items: center;
    gap: clamp(0.5rem, 1.5vw, 1rem);
    flex-shrink: 0;
}

.ctrl {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: clamp(0.72rem, 1.4vw, 0.8rem);
    color: var(--text-dim);
}
.ctrl input[type="range"] {
    width: clamp(70px, 12vw, 110px);
    accent-color: var(--accent);
}
.ctrl-level input[type="range"] { width: clamp(56px, 10vw, 90px); }
.ctrl-level.disabled { opacity: 0.4; pointer-events: none; }

.btn-toggle {
    min-width: 3.6rem;
    padding-inline: 0.65rem;
    font-size: clamp(0.68rem, 1.2vw, 0.75rem);
    font-weight: 700;
    letter-spacing: 0.06em;
    border: 1px solid var(--border);
}
.btn-toggle.active {
    background: rgba(201, 162, 39, 0.2);
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: inset 0 0 0 1px rgba(201, 162, 39, 0.25);
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 8px;
    font-family: var(--font);
    font-size: clamp(0.78rem, 1.4vw, 0.85rem);
    font-weight: 600;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s, transform 0.08s;
    touch-action: manipulation;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: #1a1a1a; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #323842; }
.btn-danger {
    background: var(--danger);
    color: #fff;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 0.5rem 1.1rem;
}
.btn-danger:hover { background: #a82828; }
.btn-danger-outline { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn-danger-outline:hover { background: rgba(197,48,48,0.1); }
.btn-ghost {
    background: var(--surface-2);
    color: var(--text-dim);
    border: 1px solid var(--border);
    padding: 0.45rem 0.55rem;
    min-width: 2.5rem;
    min-height: 2.5rem;
}
.btn-ghost:hover { color: var(--text); border-color: rgba(255,255,255,0.22); background: #323842; }
.btn-ghost[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }
.btn-ghost .icon-fs-exit[hidden] { display: none; }
.btn-ghost[aria-pressed="true"] .icon-fs-enter { display: none; }
.btn-ghost[aria-pressed="true"] .icon-fs-exit { display: block; }
.btn-icon { background: none; border: none; color: var(--text-dim); font-size: 1.5rem; cursor: pointer; line-height: 1; padding: 0.25rem; }
.btn-icon:hover { color: var(--text); }

/* ── Grid ── */
.app-body {
    flex: 1;
    display: flex;
    flex-direction: row;
    min-height: 0;
    min-width: 0;
}

.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: clamp(0.5rem, 1.5vmin, 0.85rem) clamp(0.6rem, 2vw, 1.25rem);
    min-height: 0;
    min-width: 0;
}
.grid-wrap {
    flex: 1;
    min-height: 0;
    width: 100%;
    display: flex;
}

.cart-grid {
    display: grid;
    grid-template-columns: repeat(var(--grid-cols), minmax(0, 1fr));
    grid-template-rows: repeat(var(--grid-rows), minmax(0, 1fr));
    gap: clamp(0.35rem, 1vmin, 0.65rem);
    width: 100%;
    flex: 1;
    min-height: 12rem;
    align-content: stretch;
    max-width: none;
}

.cart {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-end;
    gap: 0;
    border: 2px solid rgba(255,255,255,0.14);
    border-radius: var(--radius);
    cursor: pointer;
    overflow: hidden;
    transition: border-color 0.12s, box-shadow 0.12s;
    user-select: none;
    min-height: 3.5rem;
    min-width: 0;
    padding: 0;
    text-align: center;
    touch-action: manipulation;
    background: transparent;
    font: inherit;
    color: inherit;
    -webkit-appearance: none;
    appearance: none;
}
.cart:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
.cart:not(.empty) { justify-content: flex-start; }
.cart:hover { border-color: rgba(255,255,255,0.32); box-shadow: 0 4px 14px rgba(0,0,0,0.35); }
.cart:active { transform: scale(0.98); }
.cart.empty {
    background: var(--surface) !important;
    border-style: dashed;
    border-color: rgba(255,255,255,0.12);
    align-items: center;
    justify-content: flex-start;
    gap: 0.2rem;
    padding: 0.5rem 0.35rem 0.35rem;
}
.cart.empty .cart-name { color: var(--text-dim); font-weight: 500; margin-bottom: 0.15rem; }
.cart.empty .cart-icon { margin-top: 0.15rem; }
.cart.playing { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 0 12px rgba(201,162,39,0.25); }
.cart.drag-over {
    border-color: var(--accent);
    border-style: solid;
    box-shadow: 0 0 0 3px var(--accent-soft), inset 0 0 24px rgba(201,162,39,0.12);
    transform: scale(1.02);
    z-index: 2;
}
.cart-drag-source {
    opacity: 0.42;
    transform: scale(0.96);
    z-index: 1;
}
.cart-drop-target {
    border-color: var(--accent) !important;
    border-style: solid !important;
    box-shadow: 0 0 0 3px var(--accent-soft), inset 0 0 20px rgba(201,162,39,0.2) !important;
    transform: scale(1.03);
    z-index: 3;
}
body.cart-dragging { cursor: grabbing; }
body.cart-dragging .cart { cursor: grabbing; }
body.cart-dragging .cart-drag-source { cursor: grabbing; }

.cart-key {
    position: absolute; top: 5px; left: 7px; z-index: 3;
    font-family: var(--mono); font-size: clamp(0.55rem, 1.1vmin, 0.65rem); font-weight: 600;
    opacity: 0.7; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}

/* Barre d'actions rapides — toujours visible (ergonomie régie) */
.cart-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.25rem;
    padding: 0.22rem 0.35rem 0.32rem;
    background: linear-gradient(to top, rgba(0,0,0,0.62), rgba(0,0,0,0.18));
    position: relative;
    z-index: 4;
    flex-shrink: 0;
}
.cart-actions-empty {
    justify-content: center;
    margin-top: auto;
}
.cart-action-group {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: clamp(2px, 0.4vmin, 4px);
    margin-left: auto;
}
.cart-action-btn {
    width: clamp(26px, 4.8vmin, 32px);
    height: clamp(26px, 4.8vmin, 32px);
    border: none;
    border-radius: 6px;
    background: rgba(0,0,0,0.42);
    color: rgba(255,255,255,0.92);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
    transition: background 0.12s, color 0.12s, transform 0.1s, box-shadow 0.12s;
    touch-action: manipulation;
}
.cart-action-btn svg {
    width: clamp(13px, 2.4vmin, 15px);
    height: clamp(13px, 2.4vmin, 15px);
    display: block;
}
.cart-action-btn:hover {
    background: rgba(0,0,0,0.78);
    transform: translateY(-1px);
}
.cart-action-btn:active { transform: scale(0.94); }
.cart-action-btn.active {
    background: var(--accent);
    color: #1a1a1a;
    box-shadow: 0 0 0 1px rgba(255,255,255,0.22);
}
.cart-action-btn.active:hover { background: #d4b030; }
.cart-action-stop {
    background: rgba(139, 32, 32, 0.9);
    color: #fff;
    box-shadow: 0 0 0 1px rgba(255,255,255,0.15);
}
.cart-action-stop:hover { background: #dc2626; }
.cart-action-clear:hover { background: rgba(127, 29, 29, 0.85); color: #fecaca; }
.cart-action-import {
    background: rgba(201, 162, 39, 0.35);
    color: #fff;
}
.cart-action-import:hover { background: rgba(201, 162, 39, 0.65); }
.cart.playing .cart-action-stop {
    animation: cart-stop-pulse 1.4s ease-in-out infinite;
}
@keyframes cart-stop-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.45); }
    50% { box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.15); }
}

.cart-badges {
    display: flex;
    align-items: center;
    gap: 3px;
    min-width: 0;
    flex: 1;
    overflow: hidden;
}
.cart-badge {
    font-family: var(--mono);
    font-size: clamp(0.48rem, 0.95vmin, 0.55rem);
    font-weight: 700;
    letter-spacing: 0.06em;
    padding: 0.12rem 0.28rem;
    border-radius: 3px;
    background: rgba(0,0,0,0.5);
    color: var(--accent);
    white-space: nowrap;
    line-height: 1;
}
.cart-badge-replay { color: #93c5fd; }

.cart-wave-wrap {
    position: relative;
    flex: 1;
    min-height: 0;
    width: 100%;
    display: flex;
    align-items: stretch;
    padding: 1.4rem 0.35rem 0.15rem;
}

.cart-wave {
    width: 100%;
    height: 100%;
    min-height: 20px;
    display: block;
}

.cart-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.35rem;
    padding: 0.3rem 0.5rem 0.4rem;
    background: linear-gradient(to top, rgba(0,0,0,0.5), transparent);
    position: relative;
    z-index: 2;
}

.cart-name {
    font-size: clamp(0.62rem, 1.4vmin, 0.85rem);
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
    line-height: 1.15;
    flex: 1;
    width: 100%;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.cart-dur {
    position: absolute;
    right: 5px;
    bottom: 4px;
    font-family: var(--mono);
    font-size: clamp(0.55rem, 1.1vmin, 0.65rem);
    font-weight: 600;
    color: rgba(255,255,255,0.9);
    background: rgba(0,0,0,0.45);
    padding: 0.1rem 0.32rem;
    border-radius: 4px;
    letter-spacing: 0.02em;
    z-index: 3;
    pointer-events: none;
}

.cart-icon { font-size: clamp(1rem, 2.5vmin, 1.3rem); opacity: 0.85; }

.cart-bigname-wrap {
    flex: 1;
    min-height: 0;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.4rem 0.6rem 0.7rem;
    overflow: hidden;
}

.cart-bigname {
    font-size: clamp(0.8rem, 3.2vmin, 1.6rem);
    font-weight: 800;
    line-height: 1.1;
    color: #fff;
    text-align: center;
    text-shadow: 0 1px 4px rgba(0,0,0,0.55);
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: anywhere;
    word-break: break-word;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.prefs-panel { width: min(440px, 92vw); }
.prefs-body { padding: 1rem 1.25rem 0.25rem; }
.mode-field {
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 10px;
    padding: 0.75rem 1rem 1rem;
    margin: 0;
}
.mode-field legend {
    padding: 0 0.4rem;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--accent);
    font-weight: 700;
}
.mode-opt {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.55rem 0.5rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.12s;
}
.mode-opt:hover { background: rgba(255,255,255,0.05); }
.mode-opt input { margin-top: 0.2rem; accent-color: var(--accent); }
.mode-opt strong { color: #fff; }
.mode-opt span { color: rgba(255,255,255,0.75); }
.mode-field + .mode-field { margin-top: 0.9rem; }
.mode-field .field-inline { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.35rem 0.5rem; }
.mode-field .field-inline span { color: rgba(255,255,255,0.8); font-size: 0.9rem; }
.mode-field select { min-width: 12rem; }
.mode-hint { margin: 0.4rem 0.5rem 0; font-size: 0.76rem; color: rgba(255,255,255,0.5); }
#outputField .field-inline + .field-inline { margin-top: 0.3rem; }
#outputUnlockBtn { margin: 0.5rem 0.5rem 0; }

.vu-color-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.4rem 0.5rem 0;
}
.vu-color-label { color: rgba(255,255,255,0.8); font-size: 0.9rem; }
.vu-swatches { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.vu-swatch {
    width: 20px;
    height: 20px;
    border-radius: 5px;
    cursor: pointer;
    border: 2px solid rgba(255,255,255,0.2);
    padding: 0;
    transition: transform 0.1s, border-color 0.1s;
}
.vu-swatch:hover { transform: scale(1.1); }
.vu-swatch.selected { border-color: #fff; box-shadow: 0 0 0 1px var(--accent); }

/* Progression : la partie jouée garde la couleur de la cart, la partie
   restante est assombrie. L'overlay couvre toute la hauteur et se retire
   de gauche à droite au fil de la lecture. */
.cart-progress {
    position: absolute; top: 0; right: 0; bottom: 0;
    left: 100%;
    background: rgba(0, 0, 0, 0.5);
    border-left: 2px solid var(--accent);
    box-shadow: -1px 0 6px rgba(0, 0, 0, 0.35);
    z-index: 2;
    pointer-events: none;
    transition: left 0.06s linear;
}
.cart:not(.playing) .cart-progress {
    left: 100%;
    border-left-color: transparent;
    box-shadow: none;
}

/* ── Bottom bar ── */
.bottombar {
    flex-shrink: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: clamp(0.45rem, 1.2vmin, 0.6rem) clamp(0.6rem, 2vw, 1.25rem) clamp(0.55rem, 1.4vmin, 0.75rem);
    display: flex;
    flex-direction: column;
    gap: clamp(0.4rem, 1vmin, 0.55rem);
}

.now-playing {
    display: flex;
    align-items: center;
    gap: clamp(0.5rem, 1.5vw, 1rem);
    min-height: 0;
}
.np-info {
    display: flex;
    flex-direction: column;
    min-width: clamp(90px, 14vw, 140px);
    flex-shrink: 0;
}
.np-label { font-size: 0.58rem; font-weight: 700; letter-spacing: 0.1em; color: var(--success); }
.np-title {
    font-size: clamp(0.78rem, 1.5vw, 0.88rem);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: clamp(120px, 22vw, 280px);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.np-progress-wrap {
    flex: 1;
    height: 5px;
    background: var(--surface-2);
    border-radius: 3px;
    overflow: hidden;
    min-width: 40px;
}
.np-progress { height: 100%; background: var(--accent); border-radius: 3px; }
.np-time {
    font-family: var(--mono);
    font-size: clamp(0.68rem, 1.3vw, 0.75rem);
    color: var(--text-dim);
    white-space: nowrap;
    flex-shrink: 0;
}

/* Pages — gros boutons tactiles, répartis sur toute la largeur */
.page-tabs {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: clamp(0.3rem, 0.8vmin, 0.5rem);
    width: 100%;
}
.page-tab {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: var(--page-btn-h);
    padding: 0.35rem 0.25rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--text-dim);
    font-family: var(--font);
    font-size: clamp(1rem, 2.2vmin, 1.25rem);
    font-weight: 700;
    cursor: pointer;
    touch-action: manipulation;
    transition: background 0.1s, border-color 0.1s, color 0.1s;
}
.page-tab:hover { color: var(--text); border-color: rgba(255,255,255,0.22); background: #323842; }
.page-tab:active { transform: scale(0.97); }
.page-tab.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #1a1a1a;
    box-shadow: inset 0 -2px 0 rgba(0,0,0,0.15);
}
.page-tab-label {
    display: block;
    font-size: 0.5em;
    font-weight: 600;
    letter-spacing: 0.06em;
    opacity: 0.75;
    line-height: 1;
    margin-bottom: 0.1em;
}

/* ── Edit modal (Cool Edit Pro) ── */
.edit-modal {
    border: none;
    border-radius: 12px;
    padding: 0;
    margin: auto;
    position: fixed;
    inset: 0;
    width: calc(100% - 1.5rem);
    max-width: 920px;
    height: fit-content;
    max-height: calc(100vh - 2rem);
    background: #181b20;
    color: var(--text);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.7);
    overflow: hidden;
}
.edit-modal::backdrop { background: rgba(0, 0, 0, 0.75); }
.edit-form { display: flex; flex-direction: column; max-height: min(calc(100vh - 2rem), 900px); overflow: hidden; }
.edit-form > .edit-body { overflow-y: auto; flex: 1; min-height: 0; }

.edit-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.75rem 1rem; border-bottom: 1px solid var(--border);
    background: var(--surface);
}
.edit-header-left { display: flex; align-items: baseline; gap: 0.75rem; }
.edit-header h2 { font-size: 1rem; font-weight: 700; }
.edit-duration { font-family: var(--mono); font-size: 0.75rem; color: var(--text-dim); }

.edit-toolbar {
    display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap;
    padding: 0.5rem 1rem; background: #22262d; border-bottom: 1px solid var(--border);
}
.toolbar-group { display: flex; gap: 2px; }
.tb-btn {
    width: 32px; height: 28px; border: 1px solid var(--border);
    border-radius: 4px; background: #2e333c; color: var(--text);
    font-size: 0.85rem; font-weight: 700; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.tb-btn:hover { background: #3a404b; border-color: rgba(255,255,255,0.2); }
.tb-play { background: #2d5a3d; border-color: #3d8f5f; color: #fff; width: 40px; }
.tb-play:hover { background: #356b49; }
.tb-loop { font-size: 1rem; width: 36px; }
.tb-loop.active {
    background: rgba(201, 162, 39, 0.25);
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: 0 0 0 1px rgba(201, 162, 39, 0.35);
}

.toolbar-readouts {
    display: flex; gap: 1rem; margin-left: auto;
    font-size: 0.72rem; color: var(--text-dim);
}
.toolbar-readouts b { font-family: var(--mono); color: var(--text); font-weight: 600; }
.wf-fade-hint {
    margin-left: auto;
    color: var(--accent);
    font-size: 0.65rem;
    letter-spacing: 0.02em;
    white-space: nowrap;
}
.curve-tag {
    font-size: 0.62rem;
    color: var(--accent);
    font-style: normal;
    margin-left: 0.25rem;
}

.waveform-wrap {
    height: 180px;
    background: #101215;
    border-bottom: 1px solid var(--border);
    cursor: crosshair;
    overflow: hidden;
}
#waveformCanvas { display: block; width: 100%; height: 100%; }

.waveform-scrollbar {
    height: 14px; background: var(--surface); padding: 3px 1rem;
    border-bottom: 1px solid var(--border);
}
.scroll-track {
    position: relative; height: 8px; background: #2e333c;
    border-radius: 4px; cursor: pointer;
}
.scroll-thumb {
    position: absolute; top: 0; height: 100%;
    background: var(--accent); border-radius: 4px; min-width: 20px;
    cursor: grab;
}
.scroll-thumb:active { cursor: grabbing; }

.edit-body { padding: 0.85rem 1rem; display: flex; flex-direction: column; gap: 0.75rem; }
.edit-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0.65rem; }
.field { display: flex; flex-direction: column; gap: 0.3rem; }
.field span { font-size: 0.72rem; color: var(--text-dim); font-weight: 500; }
.field input[type="text"] {
    padding: 0.45rem 0.65rem; border: 1px solid var(--border); border-radius: 6px;
    background: var(--surface-2); color: var(--text); font-family: var(--font); font-size: 0.88rem;
}

.color-picks { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.color-pick {
    width: 26px; height: 26px; border-radius: 5px;
    border: 2px solid transparent; cursor: pointer;
}
.color-pick.selected { border-color: #fff; box-shadow: 0 0 0 2px var(--accent); }

.edit-sliders { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6rem; }
.slider-field { display: flex; flex-direction: column; gap: 0.2rem; }
.slider-field span { font-size: 0.72rem; color: var(--text-dim); }
.slider-field em { font-family: var(--mono); font-style: normal; color: var(--text); }
.slider-field input[type="range"] { accent-color: var(--accent); width: 100%; }

.edit-playback {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    padding: 0.65rem 0.75rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
}
.check-field {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}
.check-field input { width: 16px; height: 16px; accent-color: var(--accent); }
.mode-field {
    border: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.mode-field legend {
    font-size: 0.72rem;
    color: var(--text-dim);
    font-weight: 500;
    margin-bottom: 0.15rem;
}
.mode-opt {
    display: flex;
    align-items: flex-start;
    gap: 0.45rem;
    font-size: 0.8rem;
    color: var(--text-dim);
    cursor: pointer;
}
.mode-opt input { margin-top: 0.15rem; accent-color: var(--accent); flex-shrink: 0; }
.mode-opt strong { color: var(--text); font-weight: 600; }

.edit-file { display: flex; align-items: center; gap: 0.65rem; }
.file-btn { cursor: pointer; }
.file-name { font-size: 0.78rem; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.edit-footer {
    display: flex; justify-content: flex-end; gap: 0.5rem;
    padding: 0.75rem 1rem; border-top: 1px solid var(--border); background: var(--surface);
}

/* ── Responsive ── */
@media (max-width: 900px) {
    .np-title { max-width: 140px; }
}

/* ── Audio processing modal ── */
.proc-modal { max-width: 560px; }
.proc-panel { display: flex; flex-direction: column; max-height: min(calc(100vh - 2rem), 720px); }
.proc-body {
    padding: 0.85rem 1rem 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    flex: 1;
    min-height: 0;
}
.proc-bus-meter {
    font-family: var(--mono);
    font-size: 0.68rem;
    color: var(--accent);
    font-weight: 600;
}
.proc-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.proc-toggle {
    display: flex;
    align-items: center;
    cursor: pointer;
}
.proc-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.proc-toggle-ui {
    display: inline-flex;
    align-items: center;
    padding: 0.4rem 0.85rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    color: var(--text-dim);
    transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.proc-toggle input:checked + .proc-toggle-ui {
    background: rgba(201, 162, 39, 0.2);
    border-color: var(--accent);
    color: var(--accent);
}
.field-inline {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
}
.field-inline span { white-space: nowrap; }
.field-inline select {
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-2);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.82rem;
    min-width: 8rem;
}
.proc-lead {
    margin: 0;
    font-size: 0.78rem;
    color: var(--text-dim);
    line-height: 1.45;
}
.proc-section {
    padding: 0.65rem 0.75rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}
.proc-section h3 {
    margin: 0;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--accent);
}
.proc-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.55rem 0.75rem;
}
.proc-hint {
    margin: 0;
    font-size: 0.75rem;
    color: var(--text-dim);
}
.proc-hint strong {
    font-family: var(--mono);
    color: var(--text);
}
.proc-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border);
    background: var(--surface);
}
@media (max-width: 520px) {
    .proc-grid { grid-template-columns: 1fr; }
}

/* ── Stream Deck help ── */
.sd-modal { max-width: 640px; }
.sd-panel { display: flex; flex-direction: column; max-height: min(calc(100vh - 2rem), 560px); }
.sd-body {
    padding: 1rem 1.1rem 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    font-size: 0.85rem;
    line-height: 1.5;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}
.sd-lead { color: var(--text-dim); }
.sd-steps {
    margin: 0 0 0 1.1rem;
    color: var(--text-dim);
    font-size: 0.82rem;
}
.sd-steps a { color: var(--accent); }
.sd-steps code {
    font-family: var(--mono);
    font-size: 0.75rem;
    background: var(--surface-2);
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
}
.sd-body h3 {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--accent);
    margin-top: 0.25rem;
}
.sd-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.sd-table th {
    text-align: left;
    padding: 0.35rem 0.75rem 0.35rem 0;
    color: var(--text-dim);
    font-weight: 600;
    white-space: nowrap;
    vertical-align: top;
    width: 28%;
}
.sd-table td { padding: 0.35rem 0; }
.sd-table kbd, .sd-examples kbd {
    display: inline-block;
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    font-family: var(--mono);
    font-size: 0.75rem;
    margin: 0.1rem 0.15rem 0.1rem 0;
}
.sd-note { color: var(--text-dim); font-size: 0.8rem; }
.sd-url {
    display: block;
    padding: 0.5rem 0.65rem;
    background: #101215;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: var(--mono);
    font-size: 0.72rem;
    word-break: break-all;
    color: var(--accent);
}
.sd-examples {
    list-style: none;
    font-size: 0.78rem;
    color: var(--text-dim);
}
.sd-examples li { padding: 0.2rem 0; }
.sd-examples code {
    font-family: var(--mono);
    color: var(--text);
    background: var(--surface-2);
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
}

@media (max-width: 768px) {
    .page-tabs { grid-template-columns: repeat(4, 1fr); }
    .edit-fields, .edit-sliders { grid-template-columns: 1fr; }
    .toolbar-readouts { display: none; }
    .brand span { display: none; }
}

@media (max-width: 520px) {
    .page-tabs { grid-template-columns: repeat(4, 1fr); }
    .np-info { min-width: 70px; }
    .ctrl span { display: none; }
}

@media (max-height: 500px) and (orientation: landscape) {
    :root { --page-btn-h: 2.25rem; }
    .topbar { padding-top: 0.35rem; padding-bottom: 0.35rem; }
    .main { padding-top: 0.35rem; padding-bottom: 0.35rem; }
}
