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

:root {
    --root-color: #ef4444;
    --scale-color: #06b6d4;
    --blue-note-color: #6366f1;
    --arpeggio-color: #22c55e;
    --fretboard-color: #1e293b;
    --fret-color: #475569;
    --bg-color: #0f172a;
    --container-bg: rgba(15, 23, 42, 0.85);
    --container-border: rgba(255, 255, 255, 0.06);
    --text-color: #f1f5f9;
    --text-muted: #94a3b8;
    --control-bg: rgba(30, 41, 59, 0.7);
    --info-bg: rgba(30, 41, 59, 0.6);
    --accent: #8b5cf6;
    --accent-hover: #7c3aed;
    --border-color: #8b5cf6;
    --surface-hover: rgba(139, 92, 246, 0.08);
    --ring: rgba(139, 92, 246, 0.25);
    /* Interval colours (degree 1-8) */
    --iv-1: #ef4444;
    --iv-2: #f97316;
    --iv-3: #eab308;
    --iv-4: #22c55e;
    --iv-5: #14b8a6;
    --iv-6: #3b82f6;
    --iv-7: #a855f7;
    --iv-8: #ec4899;
    --fret-count: 12;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    /* ── Auto-scale factor (set by JS based on viewport) ── */
    --vw-scale: 1;
    /* ── Computed scaled sizes ── */
    --s-container-pad: calc(24px * var(--vw-scale));
    --s-fretboard-pad: calc(12px * var(--vw-scale));
    --s-fret-height: calc(48px * var(--vw-scale));
    --s-fret-font: calc(13px * var(--vw-scale));
    --s-label-width: calc(56px * var(--vw-scale));
    --s-label-font: calc(13px * var(--vw-scale));
    --s-strip-pad-v: calc(10px * var(--vw-scale));
    --s-strip-pad-h: calc(16px * var(--vw-scale));
    --s-strip-gap: calc(12px * var(--vw-scale));
    --s-ctrl-font: calc(13px * var(--vw-scale));
    --s-ctrl-label: calc(12px * var(--vw-scale));
    --s-btn-pad-v: calc(8px * var(--vw-scale));
    --s-btn-pad-h: calc(16px * var(--vw-scale));
    --s-btn-font: calc(13px * var(--vw-scale));
    --s-transport: calc(36px * var(--vw-scale));
    --s-transport-main: calc(44px * var(--vw-scale));
    --s-transport-font: calc(16px * var(--vw-scale));
    --s-transport-main-font: calc(20px * var(--vw-scale));
    --s-toggle-w: calc(40px * var(--vw-scale));
    --s-toggle-h: calc(22px * var(--vw-scale));
    --s-toggle-dot: calc(16px * var(--vw-scale));
    --s-toggle-shift: calc(18px * var(--vw-scale));
    --s-h1-font: calc(1.35em * var(--vw-scale));
    --s-gap: calc(12px * var(--vw-scale));
    --s-seq-slot: calc(44px * var(--vw-scale));
    --s-color-swatch: calc(56px * var(--vw-scale));
    --s-slider-w: calc(80px * var(--vw-scale));
    --s-hamburger: calc(36px * var(--vw-scale));
}

[data-theme="dark"] {
    --bg-color: #0f172a;
    --container-bg: rgba(15, 23, 42, 0.85);
    --container-border: rgba(255, 255, 255, 0.06);
    --text-color: #f1f5f9;
    --text-muted: #94a3b8;
    --control-bg: rgba(30, 41, 59, 0.7);
    --info-bg: rgba(30, 41, 59, 0.6);
    --fret-color: #475569;
    --fretboard-color: #1e293b;
}

/* Light mode override */
[data-theme="light"] {
    --bg-color: #f1f5f9;
    --container-bg: rgba(255, 255, 255, 0.92);
    --container-border: rgba(0, 0, 0, 0.06);
    --text-color: #1e293b;
    --text-muted: #64748b;
    --control-bg: rgba(241, 245, 249, 0.8);
    --info-bg: rgba(248, 250, 252, 0.9);
    --fret-color: #94a3b8;
    --fretboard-color: #334155;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-color);
    min-height: 100vh;
    padding: calc(16px * var(--vw-scale));
    color: var(--text-color);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 98vw;
    margin: 0 auto;
    background: var(--container-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--container-border);
    border-radius: var(--radius-xl);
    padding: var(--s-container-pad);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(255, 255, 255, 0.03);
    animation: fadeSlideIn 0.4s ease-out;
}

@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--container-border);
}

.header-left {
    flex: 1;
}

h1 {
    color: var(--text-color);
    font-size: var(--s-h1-font);
    font-weight: 700;
    letter-spacing: -0.025em;
    margin-bottom: 0;
}

.subtitle {
    display: none;
}

.theme-toggle {
    background: var(--control-bg);
    color: var(--text-color);
    border: 1px solid var(--container-border);
    padding: calc(6px * var(--vw-scale)) calc(14px * var(--vw-scale));
    border-radius: 999px;
    cursor: pointer;
    font-weight: 500;
    font-size: var(--s-ctrl-font);
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 6px;
    backdrop-filter: blur(8px);
}

.theme-toggle:hover {
    background: var(--surface-hover);
    border-color: var(--accent);
}

.controls {
    display: flex;
    justify-content: center;
    gap: var(--s-gap);
    margin-bottom: calc(16px * var(--vw-scale));
    flex-wrap: wrap;
    padding: calc(16px * var(--vw-scale));
    background: var(--control-bg);
    border-radius: var(--radius-md);
    border: 1px solid var(--container-border);
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

label {
    font-weight: 500;
    color: var(--text-muted);
    font-size: var(--s-ctrl-label);
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

select {
    padding: calc(7px * var(--vw-scale)) calc(12px * var(--vw-scale));
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    font-size: var(--s-ctrl-font);
    font-family: inherit;
    cursor: pointer;
    background: var(--control-bg);
    color: var(--text-color);
    transition: all var(--transition-fast);
    outline: none;
}

select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--ring);
}

select:hover {
    border-color: rgba(255, 255, 255, 0.2);
}

/* ── Unified Control Strip ──────────────────────────── */
.control-strip {
    display: flex;
    align-items: center;
    gap: var(--s-strip-gap);
    padding: var(--s-strip-pad-v) var(--s-strip-pad-h);
    background: var(--control-bg);
    border: 1px solid var(--container-border);
    border-radius: var(--radius-md);
    margin-bottom: calc(8px * var(--vw-scale));
    flex-wrap: wrap;
    justify-content: center;
}

.control-strip select {
    padding: calc(5px * var(--vw-scale)) calc(10px * var(--vw-scale));
    font-size: var(--s-ctrl-font);
}

.control-strip label {
    font-size: calc(11px * var(--vw-scale));
    white-space: nowrap;
}

.strip-divider {
    width: 1px;
    height: calc(24px * var(--vw-scale));
    background: var(--text-muted);
    opacity: 0.15;
    flex-shrink: 0;
}

/* ── Hamburger Button ─────────────────────────────── */
.hamburger-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--s-hamburger);
    height: var(--s-hamburger);
    border-radius: var(--radius-sm);
    border: 1px solid var(--container-border);
    background: var(--control-bg);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.hamburger-btn:hover,
.hamburger-btn.active {
    color: var(--text-color);
    background: var(--surface-hover);
    border-color: var(--accent);
}

.hamburger-btn.active {
    color: var(--accent);
}

/* ── Options Drawer ───────────────────────────────── */
.options-drawer {
    overflow: hidden;
    height: 0;
    transition: height 0.3s ease;
}

.drawer-inner {
    padding-top: 6px;
}

.drawer-section {
    padding: 10px 16px;
    background: var(--control-bg);
    border: 1px solid var(--container-border);
    border-radius: var(--radius-md);
    margin-top: 6px;
}

.drawer-section .toggle-row {
    gap: 14px;
}

/* ── Compact Player Bar ────────────────────────────── */
.player-bar {
    display: flex;
    align-items: center;
    gap: var(--s-strip-gap);
    padding: calc(8px * var(--vw-scale)) var(--s-strip-pad-h);
    background: var(--control-bg);
    border: 1px solid var(--container-border);
    border-radius: var(--radius-md);
    margin: calc(8px * var(--vw-scale)) 0;
    justify-content: center;
    flex-wrap: wrap;
}

.transport-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

.transport-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: var(--s-transport-font);
    cursor: pointer;
    width: var(--s-transport);
    height: var(--s-transport);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all var(--transition-fast);
}

.transport-btn:hover:not(:disabled) {
    background: var(--surface-hover);
    color: var(--text-color);
}

.transport-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.transport-btn.play-main {
    font-size: var(--s-transport-main-font);
    width: var(--s-transport-main);
    height: var(--s-transport-main);
    background: var(--accent);
    color: white;
    border-radius: 50%;
}

.transport-btn.play-main:hover {
    background: var(--accent-hover);
    transform: scale(1.05);
}

.transport-btn.active {
    color: var(--accent);
}

.transport-btn.loop-active {
    color: #22c55e;
    text-shadow: 0 0 8px rgba(34, 197, 94, 0.4);
}

.transport-btn.metronome-active {
    color: #f59e0b;
    text-shadow: 0 0 8px rgba(245, 158, 11, 0.4);
}

.player-slider-group {
    display: flex;
    align-items: center;
    gap: calc(6px * var(--vw-scale));
    font-size: calc(11px * var(--vw-scale));
    color: var(--text-muted);
}

.player-slider-group .slider {
    width: var(--s-slider-w);
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    outline: none;
}

.player-slider-group .slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    box-shadow: 0 0 6px var(--ring);
}

.player-slider-group .slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: none;
    box-shadow: 0 0 6px var(--ring);
}

.player-label {
    font-size: var(--s-ctrl-font);
    min-width: calc(18px * var(--vw-scale));
}

.fretboard {
    display: grid;
    grid-template-columns: var(--s-label-width) repeat(var(--fret-count, 12), 1fr);
    gap: 2px;
    background: var(--fretboard-color);
    padding: clamp(4px, var(--s-fretboard-pad), 14px);
    border-radius: var(--radius-lg);
    margin: calc(8px * var(--vw-scale)) 0;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.2);
    transition: opacity 0.15s ease-out;
}

.fretboard.scale-transition {
    opacity: 0.4;
}

.string-label {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: var(--s-label-font);
    border-radius: var(--radius-sm);
    padding: calc(12px * var(--vw-scale)) calc(5px * var(--vw-scale));
    cursor: pointer;
    transition: all var(--transition-fast);
}

.string-label.open-active {
    background: color-mix(in srgb, var(--scale-color) 80%, black);
    color: white;
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: -2px;
    box-shadow: 0 0 12px rgba(6, 182, 212, 0.3);
}

.string-label.open-root {
    background: color-mix(in srgb, var(--root-color) 80%, black);
    color: white;
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: -2px;
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.3);
}

.string-label.open-muted {
    opacity: 0.25;
    outline: none;
    box-shadow: none;
}

.fret {
    background: var(--fret-color);
    border: 1px solid rgba(0, 0, 0, 0.15);
    min-height: var(--s-fret-height);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: var(--s-fret-font);
    cursor: pointer;
    user-select: none;
    transition: all var(--transition-fast);
    border-radius: 4px;
    position: relative;
    color: rgba(255, 255, 255, 0.4);
}

.fret:hover {
    filter: brightness(1.25);
    transform: scale(1.06);
    z-index: 1;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.08);
}

.fret:active {
    transform: scale(0.96);
    filter: brightness(1.4);
    transition-duration: 50ms;
}

/* Shared highlighted fret styling */
.fret.root,
.fret.scale,
.fret.blue-note,
.fret.arpeggio {
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 0 12px rgba(0, 0, 0, 0.3);
    z-index: 1;
}

.fret.root {
    background: var(--root-color);
    animation: pulse 2s infinite;
    box-shadow: 0 0 16px rgba(239, 68, 68, 0.4);
}

.fret.scale {
    background: var(--scale-color);
}

.fret.blue-note {
    background: var(--blue-note-color);
}

.fret.arpeggio {
    background: var(--arpeggio-color);
    animation: pulse 2s infinite;
    box-shadow: 0 0 16px rgba(34, 197, 94, 0.4);
}

.fret.dimmed {
    opacity: 0.3;
}

.fret.out-of-scale {
    opacity: 0.12;
}

.fret.caged-muted {
    opacity: 0.1;
}

.fret.shape-selected {
    outline: 2px solid #f59e0b;
    outline-offset: -2px;
    z-index: 2;
}

.shape-editing .fret {
    cursor: crosshair;
}

.shape-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    margin-bottom: 6px;
    background: var(--control-bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--container-border);
    font-size: 13px;
    transition: border-color var(--transition-fast);
}

.shape-card:hover {
    border-color: rgba(255, 255, 255, 0.12);
}

.shape-card .shape-name {
    flex: 1;
    font-weight: 600;
}

.shape-card .shape-meta {
    color: var(--text-muted);
    font-size: 11px;
}

.shape-card .btn {
    padding: 3px 10px;
    font-size: 11px;
}


/* Interval colour mode — inline bg set by JS, just ensure text is white */
.fret.interval-colored {
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 0 12px rgba(0, 0, 0, 0.3);
    z-index: 1;
}

/* Fret range slider in control strip */
.fret-range-group {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
}

.fret-range-group input[type=range] {
    width: 70px;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.fret-range-group input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    box-shadow: 0 0 6px var(--ring);
}

.fret-range-group input[type=range]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: none;
    box-shadow: 0 0 6px var(--ring);
}

/* CAGED shape legend dots */
.caged-legend {
    display: flex;
    gap: 6px;
    align-items: center;
    font-size: 11px;
    flex-wrap: wrap;
    justify-content: center;
    padding: 4px 0;
    color: var(--text-muted);
}

.caged-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

/* Interval colour legend */
.interval-legend {
    display: flex;
    gap: 6px;
    align-items: center;
    font-size: 11px;
    flex-wrap: wrap;
    justify-content: center;
    padding: 4px 0;
    color: var(--text-muted);
}

.iv-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.fret.playing {
    background-color: #f59e0b !important;
    transform: scale(1.12);
    z-index: 2;
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.6);
    border-color: rgba(255, 255, 255, 0.8) !important;
}

.fret.fade-out {
    transition: background-color 0.5s ease-out, transform 0.3s ease-out,
                box-shadow 0.5s ease-out, border-color 0.4s ease-out !important;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.08); }
    100% { transform: scale(1); }
}

.fret-numbers {
    display: grid;
    grid-template-columns: var(--s-label-width) repeat(var(--fret-count, 12), 1fr);
    gap: 2px;
    margin-bottom: calc(8px * var(--vw-scale));
}

.fret-number {
    text-align: center;
    font-weight: 500;
    color: var(--text-muted);
    font-size: var(--s-ctrl-label);
    padding: calc(4px * var(--vw-scale));
}

.btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: var(--s-btn-pad-v) var(--s-btn-pad-h);
    margin: calc(4px * var(--vw-scale));
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    font-size: var(--s-btn-font);
    font-family: inherit;
    transition: all var(--transition-fast);
}

.btn:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--ring);
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled {
    background: var(--fret-color);
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-stop {
    background: #ef4444;
}

.btn-stop:hover {
    background: #dc2626;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.slider {
    width: 200px;
    margin: 0 10px;
}

.info-panel {
    margin: 12px 0;
}

.info-box {
    background: var(--info-bg);
    padding: 20px;
    border-radius: var(--radius-md);
    border: 1px solid var(--container-border);
}

.info-box h3 {
    margin-top: 0;
    margin-bottom: 16px;
    color: var(--text-color);
    font-weight: 600;
    font-size: 16px;
    border-bottom: 1px solid var(--container-border);
    padding-bottom: 8px;
}

.scale-table-wrap {
    overflow-x: auto;
    margin-top: 16px;
    border-radius: var(--radius-sm);
}

.scale-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--s-ctrl-font);
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.scale-table th,
.scale-table td {
    padding: 8px 10px;
    border: 1px solid rgba(255, 255, 255, 0.04);
    white-space: nowrap;
}

.scale-table thead tr:first-child th {
    background: var(--scale-color);
    color: #fff;
    font-weight: 600;
    font-size: 13px;
}

.scale-table thead tr:first-child th:first-child {
    text-align: left;
    padding-left: 14px;
    background: var(--fretboard-color);
    color: #fff;
}

.scale-table thead tr:first-child th.root-col {
    background: var(--root-color);
    color: #fff;
}

.scale-table thead tr:first-child th.note-col {
    background: var(--scale-color);
}

.scale-table thead tr:first-child th.note-col-alt {
    background: var(--scale-color);
    filter: brightness(1.2);
}

.scale-table tbody tr:nth-child(1) td {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-color);
}

.scale-table tbody tr:nth-child(2) td {
    background: var(--fretboard-color);
    color: #fff;
}

.scale-table tbody td:first-child {
    font-weight: 600;
    text-align: left;
    padding-left: 14px;
    background: var(--fretboard-color) !important;
    color: #fff;
}

.scale-table .note-clickable {
    cursor: pointer;
    transition: opacity var(--transition-fast);
}

.scale-table .note-clickable:hover {
    opacity: 0.75;
}

.interval-display {
    margin-top: 16px;
    font-size: 13px;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    background: var(--control-bg);
    color: var(--text-color);
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--accent);
}

#customTuningPanel {
    display: none;
    background: var(--info-bg);
    padding: 20px;
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    border: 1px solid var(--container-border);
}

.custom-tuning-controls {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.custom-tuning-controls > div {
    display: flex;
    flex-direction: column;
    gap: 6px;
    text-align: center;
}

.apply-btn {
    margin-top: 12px;
    padding: 8px 20px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    font-family: inherit;
    font-size: 13px;
    transition: all var(--transition-fast);
}

.apply-btn:hover {
    background: var(--accent-hover);
    box-shadow: 0 4px 12px var(--ring);
}

.color-controls {
    background: var(--info-bg);
    padding: 24px;
    border-radius: var(--radius-md);
    margin-top: 0;
    text-align: center;
    border: 1px solid var(--container-border);
}

.color-controls h3 {
    color: var(--text-color);
    margin-bottom: 20px;
    font-size: 16px;
    font-weight: 600;
    border-bottom: 1px solid var(--container-border);
    padding-bottom: 10px;
    display: inline-block;
}

.color-group {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.color-control {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 12px;
    background: var(--control-bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--container-border);
    transition: all var(--transition-fast);
}

.color-control:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.1);
}

.color-control label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
}

.color-control input[type="color"] {
    width: var(--s-color-swatch);
    height: var(--s-color-swatch);
    border: 2px solid var(--container-border);
    border-radius: 50%;
    cursor: pointer;
    transition: all var(--transition-fast);
    background: transparent;
}

.color-control input[type="color"]:hover {
    transform: scale(1.08);
    border-color: var(--accent);
}

.toggle-row {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 0;
    background: none;
    align-items: center;
}

.toggle-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toggle-group label {
    font-size: var(--s-ctrl-label);
    font-weight: 500;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: var(--text-muted);
}

.toggle-switch {
    position: relative;
    width: var(--s-toggle-w);
    height: var(--s-toggle-h);
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    margin: 0;
    cursor: pointer;
    z-index: 2;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 22px;
    transition: var(--transition-base);
}

.toggle-slider:before {
    content: "";
    position: absolute;
    height: var(--s-toggle-dot);
    width: var(--s-toggle-dot);
    left: 3px;
    bottom: 3px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: var(--transition-base);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--accent);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(var(--s-toggle-shift));
    background: white;
}

.arp-controls-wrap {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    max-width: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-width 0.3s ease, opacity 0.2s ease;
}

.arp-controls-wrap.visible {
    max-width: 320px;
    opacity: 1;
}

.arpeggio-select {
    padding: 5px 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    background: var(--control-bg);
    color: var(--text-color);
    transition: all var(--transition-fast);
}

.arpeggio-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--ring);
}

/* ── Tab System ──────────────────────────────────────── */
.tab-bar {
    display: flex;
    gap: 2px;
    margin-top: 12px;
    padding: 4px;
    background: var(--control-bg);
    border-radius: var(--radius-md);
    border: 1px solid var(--container-border);
}

.tab-btn {
    flex: 1;
    padding: var(--s-btn-pad-v) calc(12px * var(--vw-scale));
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-weight: 500;
    font-size: var(--s-ctrl-font);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: inherit;
}

.tab-btn:hover {
    color: var(--text-color);
    background: rgba(255, 255, 255, 0.04);
}

.tab-btn.active {
    color: var(--text-color);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2), inset 0 -2px 0 0 var(--accent);
}

.tab-panel {
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.25s ease, padding 0.3s ease;
    max-height: 0;
    opacity: 0;
    padding: 0;
}

.tab-panel[hidden] {
    display: block !important;
    max-height: 0;
    opacity: 0;
    padding: 0;
    pointer-events: none;
    visibility: hidden;
}

.tab-panel.open {
    max-height: 800px;
    opacity: 1;
    padding: 16px 0;
    pointer-events: auto;
    visibility: visible;
}

/* Remove outer margins from panels inside tabs */
.tab-panel .controls {
    margin-bottom: 12px;
}

.tab-panel .sequencer-panel {
    margin: 0;
}

.tab-panel .info-panel {
    margin: 0;
}

.tab-panel .color-controls {
    margin-top: 0;
}

.sequencer-panel {
    background: var(--info-bg);
    border-radius: var(--radius-md);
    padding: 20px;
    margin: 0;
    text-align: center;
    border: 1px solid var(--container-border);
}

.seq-slots {
    display: flex;
    gap: 6px;
    justify-content: center;
    flex-wrap: wrap;
    margin: 16px 0;
}

.seq-slot {
    width: var(--s-seq-slot);
    height: var(--s-seq-slot);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    font-size: 12px;
    color: var(--text-muted);
    background: var(--control-bg);
    transition: all var(--transition-fast);
    user-select: none;
}

.seq-slot:hover {
    border-color: var(--accent);
    transform: scale(1.05);
}

.seq-slot.selected {
    border-color: var(--accent);
    box-shadow: 0 0 8px var(--ring);
}

.seq-slot.filled {
    color: var(--text-color);
    background: rgba(139, 92, 246, 0.1);
    border-color: var(--accent);
}

.seq-slot.seq-playing {
    background: #f59e0b;
    color: white;
    border-color: #f59e0b;
    transform: scale(1.08);
    box-shadow: 0 0 12px rgba(245, 158, 11, 0.4);
}

.seq-controls {
    display: flex;
    gap: 6px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 12px;
}

/* ── Smooth Dropdown ───────────────────────────────── */
.smooth-dropdown-anchor {
    position: relative;
    width: var(--s-hamburger);
    height: var(--s-hamburger);
    flex-shrink: 0;
}

.smooth-dropdown {
    position: absolute;
    top: 0;
    right: 0;
    width: var(--s-hamburger);
    height: var(--s-hamburger);
    background: var(--control-bg);
    border: 1px solid var(--container-border);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    cursor: pointer;
    transform-origin: top right;
    transition: width 0.38s cubic-bezier(0.23, 1, 0.32, 1),
                height 0.38s cubic-bezier(0.23, 1, 0.32, 1),
                border-radius 0.3s ease;
    z-index: 100;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.smooth-dropdown.open {
    width: calc(220px * var(--vw-scale));
    border-radius: 14px;
    cursor: default;
}

.smooth-dropdown-trigger {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.smooth-dropdown.open .smooth-dropdown-trigger {
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
}

.smooth-dropdown-trigger svg {
    color: var(--text-muted);
}

.smooth-dropdown-content {
    padding: calc(8px * var(--vw-scale));
    opacity: 0;
    transition: opacity 0.2s ease 0s;
    pointer-events: none;
}

.smooth-dropdown.open .smooth-dropdown-content {
    opacity: 1;
    pointer-events: auto;
    transition-delay: 0.08s;
}

.smooth-dropdown-menu {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.smooth-dropdown-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: calc(12px * var(--vw-scale));
    padding: calc(8px * var(--vw-scale)) calc(12px * var(--vw-scale));
    padding-left: calc(14px * var(--vw-scale));
    border-radius: 8px;
    font-size: calc(13px * var(--vw-scale));
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
    transition: color 0.2s ease;
    opacity: 0;
    transform: translateX(8px);
}

.smooth-dropdown.open .smooth-dropdown-item {
    opacity: 1;
    transform: translateX(0);
    transition: color 0.2s ease,
                opacity 0.15s cubic-bezier(0.23, 1, 0.32, 1),
                transform 0.15s cubic-bezier(0.23, 1, 0.32, 1);
}

.smooth-dropdown.open .smooth-dropdown-item:nth-child(1) { transition-delay: 0.06s, 0.06s, 0.06s; }
.smooth-dropdown.open .smooth-dropdown-item:nth-child(2) { transition-delay: 0.06s, 0.08s, 0.08s; }
.smooth-dropdown.open .smooth-dropdown-item:nth-child(3) { transition-delay: 0.06s, 0.10s, 0.10s; }
.smooth-dropdown.open .smooth-dropdown-item:nth-child(4) { transition-delay: 0.06s, 0.12s, 0.12s; }
.smooth-dropdown.open .smooth-dropdown-item:nth-child(5) { transition-delay: 0.06s, 0.14s, 0.14s; }
.smooth-dropdown.open .smooth-dropdown-item:nth-child(6) { transition-delay: 0.06s, 0.16s, 0.16s; }
.smooth-dropdown.open .smooth-dropdown-item:nth-child(7) { transition-delay: 0.06s, 0.18s, 0.18s; }

.smooth-dropdown-item:hover {
    color: var(--text-color);
}

.smooth-dropdown-item .sdd-bg {
    position: absolute;
    inset: 0;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.smooth-dropdown-item:hover .sdd-bg,
.smooth-dropdown-item.active .sdd-bg {
    opacity: 1;
}

.smooth-dropdown-item .sdd-bar {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%) scaleY(0);
    width: 3px;
    height: calc(20px * var(--vw-scale));
    border-radius: 3px;
    background: var(--accent);
    transition: transform 0.25s cubic-bezier(0.23, 1, 0.32, 1);
    pointer-events: none;
}

.smooth-dropdown-item:hover .sdd-bar,
.smooth-dropdown-item.active .sdd-bar {
    transform: translateY(-50%) scaleY(1);
}

.smooth-dropdown-item.active {
    color: var(--text-color);
}

.smooth-dropdown-item .sdd-icon {
    width: calc(18px * var(--vw-scale));
    height: calc(18px * var(--vw-scale));
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}

.smooth-dropdown-item .sdd-label {
    position: relative;
    z-index: 1;
    white-space: nowrap;
}

.smooth-dropdown-divider {
    height: 1px;
    background: var(--container-border);
    margin: calc(6px * var(--vw-scale)) calc(8px * var(--vw-scale));
    opacity: 0;
    transition: opacity 0.2s ease 0.12s;
}

.smooth-dropdown.open .smooth-dropdown-divider {
    opacity: 1;
}

.smooth-dropdown-item.danger:hover {
    color: #ef4444;
}

.smooth-dropdown-item.danger:hover .sdd-bg {
    background: rgba(239, 68, 68, 0.08);
}

.smooth-dropdown-item.danger:hover .sdd-bar {
    background: #ef4444;
}

/* Layout-only media query for narrow screens */
@media (max-width: 768px) {
    body { padding: 0; }

    .container {
        border-radius: 0;
        box-shadow: none;
        border: none;
        backdrop-filter: none;
    }

    .header {
        flex-direction: row;
        border-bottom: none;
    }

    h1 {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    #themeText { display: none; }
    #modeText { display: none; }

    .fretboard {
        margin-left: -2px;
        margin-right: -2px;
    }

    .fret-numbers {
        margin-left: -2px;
        margin-right: -2px;
    }

    .controls {
        flex-direction: column;
        align-items: stretch;
    }

    .control-group { width: 100%; }
    .control-group select { width: 100%; }

    .fret {
        min-height: calc(44px * var(--vw-scale));
    }

    select {
        min-height: 44px;
        font-size: 16px; /* prevents iOS auto-zoom on focus */
    }

    .tab-btn {
        min-height: 44px;
    }

    .transport-btn {
        min-width: 44px;
        min-height: 44px;
    }
}

/* Landscape orientation on phones */
@media (max-height: 500px) and (orientation: landscape) {
    .header {
        margin-bottom: 4px;
        padding-bottom: 4px;
    }

    .control-strip {
        padding: 4px var(--s-strip-pad-h);
        margin-bottom: 4px;
    }

    .options-drawer .drawer-section {
        padding: 6px 12px;
        margin-top: 2px;
    }

    .fretboard {
        margin: 4px 0;
    }

    .fret {
        min-height: calc(32px * var(--vw-scale));
    }

    .fret-numbers {
        margin-bottom: 2px;
    }

    .tab-bar {
        margin-top: 4px;
    }
}
