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

html {
    overflow-x: auto;
}

body {
    background: #ddd;
    color: #aaa;
    font-family: 'Stack Sans Notch', sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    /* min-height: 100vh; */
    gap: 20px;
    margin: 30px;
    min-width: 1250px;
    margin-inline: auto;
    zoom: 0.8;
}

@media (max-width: 1400px) {
    body { zoom: 0.8; }
}

@media (max-width: 1300px) {
    body { zoom: 0.65; }
}

@media (max-width: 900px) {
    body { zoom: 0.6; }
}


h1 {
    font-size: 1.4rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: #aaa;
}

.button {
    font-family: inherit;
    font-weight: normal;
    background: #ccc;
    color: #888;
    border: none;
    border-radius: 20px;
    padding: 12px 36px;
    letter-spacing: 0.1em;
    cursor: pointer;
    text-transform: uppercase;
    transition: background 0.15s, color 0.15s, transform 0.1s;
    min-width: 130px;
}

.button:hover, .tab:hover {
    filter: brightness(0.9);
}

.sequencer {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sequencer-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

#tab-global .sequencer {
    gap: 4px;
    margin-bottom: 40px;
}

.row-label {
    width: 72px;
    font-size: 0.65rem;
    color: #888;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    text-align: right;
    flex-shrink: 0;
}

.step-number.group-start {
    color: #888;
}

.grid {
    display: grid;
    grid-template-columns: repeat(16, 48px);
    gap: 0px;
}

@property --amplitude {
    syntax: '<number>';
    inherits: false;
    initial-value: 0;
}

.step {
    --step-fill: #009966;
    --step-empty: #c4cac4;
    --step-glow: rgba(255, 220, 80, 0.8);
    width: 40px;
    height: 40px;
    border-radius: 20px;
    background: conic-gradient(
        from -90deg,
        var(--step-fill) calc(var(--amplitude) * 360deg),
        var(--step-empty) calc(var(--amplitude) * 360deg)
    );
    border-style: none;
    cursor: pointer;
    touch-action: none;
    /* transition: --amplitude 0.08s, box-shadow 0.08s, transform 0.05s; */
    /* box-shadow: 0 0 calc(var(--amplitude) * 12px) var(--step-glow); */
    position: relative;
    overflow: hidden;
}

.step:hover {
    filter: brightness(0.9);
}

.step.playing {
    /* filter: brightness(1.2); */
    transform: scale(0.9);
    /* filter: hue-rotate(-45deg) brightness(0.9);  */
    /* filter: brightness(0.9) drop-shadow(0px 0px 1px red); */
    filter: brightness(0.9);
}

.step.neighbor-zone {
    --step-fill: #97abb9;
    --step-empty: #d0d0d0;
    --step-glow: rgba(58, 90, 154, 0.8);
}


.melody-row .step {
    --step-fill: #b048a0;
    --step-glow: rgba(220, 80, 240, 0.8);
}

.melody-row .step.neighbor-zone {
    --step-fill: #3a5a9a;
    --step-glow: rgba(58, 90, 154, 0.8);
}

/*
.step:nth-child(4n+1) {
    margin-left: 6px;
}

.step:nth-child(1) {
    margin-left: 0;
}

.step-number:nth-child(4n+1) {
    margin-left: 6px;
}

.step-number:nth-child(1) {
    margin-left: 0;
}
*/

.scale-buttons {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    flex-wrap: wrap;
    justify-content: center;
    color: #666;
    font-size: 80%;
    font-weight: normal;
    align-items: center;
}

.scale-btn {
    min-width: unset;
    padding: 8px 20px;
    font-size: 0.75rem;
}

.scale-btn.active {
    background: #b048a0;
    color: #fff;
    box-shadow: 0 0 8px rgba(220, 80, 240, 0.6);
}

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


.status-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.65rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #aaa;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #333;
    transition: background 0.3s;
    flex-shrink: 0;
}

.status-dot.connected {
    background: #4caf50;
    box-shadow: 0 0 6px rgba(76, 175, 80, 0.6);
}

.status-dot.error {
    background: #e05c2a;
}

.sequencer-row.locked .step {
    opacity: 0.25;
    cursor: not-allowed;
    pointer-events: none;
}

.sequencer-row.locked .row-label {
    opacity: 0.35;
}

.sequencer-row.my-track .row-label {
    color: #e05c2a;
}

/* ── Console tab ── */
.console-buttons {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
    justify-content: center;
}

/* ── Notation tab ────────────────────────────────────────────────── */
#notationScore {
    padding: 24px 16px;
    overflow-x: auto;
}

#notationScore svg {
    display: block;
    margin: 0 auto;
    /* filter: invert(1) hue-rotate(180deg); */
}

.console-log {
    max-height: calc(100vh - 160px);
    width: 1200px;
    background: #ccc;
    overflow-y: auto;
    overflow-x: auto;
    font-family: monospace;
    font-size: 0.75rem;
    color: #444;
    padding: 12px 16px;
    margin: 20px;
    font-weight: 100;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.console-entry {
    white-space: nowrap;
    word-break: break-all;
    line-height: 1.3;
}

.console-time {
    color: #555;
}

.console-type {
    color: #7af;
    margin: 0;
}

.console-body {
    color: #666;
}

#resetGlobalStateBtn {
    background: #b15;
    box-shadow: 0 0 8px rgba(220, 20, 80, 1.0);
    color: #fff;
}

#resetGlobalStateBtn:hover {
    background: #d37;
}

/* ── Tabs ── */
.tab-bar {
    display: flex;
}

.hidden {
    display: none;
}

.tab {
    background: #ccc;
    border: none;
    border-radius: 20px;
    color: #888;
    /* font-size: 0.75rem; */
    letter-spacing: 0.02em;
    font-weight: bold;
    text-transform: uppercase;
    padding: 12px 36px;
    margin: 0 12px;
    cursor: pointer;
    transition: color 0.15s;
}


.global-buttons {
    display: flex;
    justify-content: center;
    margin-bottom: 16px;
}

#playPauseBtn, #playAllBtn, .tab.active {
    background-color: #ccbc00;
    color: rgba(255, 255, 255, 0.9);
    /* box-shadow: 0 0 8px rgba(255, 220, 80, 1.0); */
}

#playPauseBtn:hover {
    filter: brightness(0.9);
}

#playPauseBtn:active {
    transform: scale(0.96);
}


/* .tab.active {
    color: rgba(255, 255, 255, 0.9);
    background-color: #ccbc00;
} */

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}


/* Multi-step note pill shape */
.melody-row .step.note-head {
    width: 48px;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.melody-row .step.note-continuation {
    width: 48px;
    border-radius: 0;
    background: var(--step-fill);
    /* box-shadow: 0 0 12px var(--step-glow); */
}

.melody-row .step.note-tail {
    width: 40px;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    background: var(--step-fill);
    /* box-shadow: 0 0 12px var(--step-glow); */
}

.melody-row .step.neighbor-zone {
    --step-fill: #3a5a9a;
    --step-glow: rgba(58, 90, 154, 0.8);
}

/* Bigger gap at the zone boundaries */
/*
.step.zone-boundary {
    margin-left: 14px !important;
}*/

/* Region labels */
.region-labels-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
}

.region-labels-spacer {
    width: 72px;
    flex-shrink: 0;
}

.region-labels-container {
    display: flex;
    width: 100%;
}

.region-label {
    font-size: 0.8rem;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    text-align: center;
    padding: 6px 0 0px 0;
    font-weight: normal;
    position: relative;
    margin: 4px;
    border-top: 1px solid currentColor;
    border-left: 1px solid currentColor;
    border-right: 1px solid currentColor;
}

.region-label {
    color: #aaa;
}

#slotDisplay {
    font-size: 0.8rem;
    font-weight: normal;
    text-transform: uppercase;
}

.author-lozenge {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #eee;
    padding: 12px 36px;
    border-radius: 999px;
    font-family: inherit;
    font-size: 1.5rem;
    font-weight: 200;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    pointer-events: none;
    z-index: 200;
    opacity: 0;
    transition: opacity 0.4s;
}

.author-lozenge.visible {
    opacity: 1;
}
