@font-face {
    font-family: 'creep';
    src: url('fonts/creep.woff2') format('woff2'),
         url('fonts/creep.ttf') format('truetype');
}

:root {
    --bg: #0d0d0d;
    --surface: #111;
    --border: #222;
    --border-strong: #333;
    --text: #ccc;
    --text-muted: #888;
    --text-dim: #555;
    --text-dimmer: #444;
    --accent: #00ffcc;
    --chord: #fff;
    --key-white: #545454;
    --key-white-active: #999;
    --key-black: #000;
    --key-black-active: #888;
    --pane-bg: rgba(16, 16, 20, 0.96);
    --pane-border: #2a2a30;
    --pane-shadow: rgba(0, 0, 0, 0.5);
    --canvas-bg: #111;
    --canvas-border: #000;
    --canvas-outline: #222;
    --canvas-shadow: black;
    --canvas-dot-text: #aaa;
    --canvas-dot-text-active: #111;
    --canvas-center: #555;
    --key-label: #111;
}

body.light {
    --bg: #e8e8e8;
    --surface: #f5f5f5;
    --border: #ccc;
    --border-strong: #bbb;
    --text: #333;
    --text-muted: #666;
    --text-dim: #999;
    --text-dimmer: #777;
    --accent: #00aa77;
    --chord: #444;
    --key-white: #f7f7f7;
    --key-white-active: #aaa;
    --key-black: #444;
    --key-black-active: #999;
    --key-label: #888;
    --pane-bg: rgba(240, 240, 245, 0.96);
    --pane-border: #ccc;
    --pane-shadow: rgba(0, 0, 0, 0.1);
    --canvas-bg: #f0f0f0;
    --canvas-border: #bbb;
    --canvas-outline: #999;
    --canvas-shadow: rgba(0, 0, 0, 0.15);
    --canvas-dot-text: #333;
    --canvas-dot-text-active: #111;
    --canvas-center: #999;
}

body {
    font-family: monospace;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ── Top bar ─────────────────────────────────────────────────────────────── */

#bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 20px;
    box-sizing: border-box;
    z-index: 10;
}

#bar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

#logo {
    color: var(--accent);
    font-size: 0.9rem;
    letter-spacing: 0.3px;
}

#gear-btn {
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 2px 6px;
    line-height: 1;
    transition: color 0.15s, transform 0.3s ease;
}
#gear-btn:hover {
    color: var(--text-muted);
    transform: rotate(90deg);
}

#bar select {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-strong);
    padding: 6px 14px;
    font-size: 0.8rem;
    font-family: monospace;
    border-radius: 4px;
    cursor: pointer;
    outline: none;
}
#bar select:hover {
    border-color: var(--text-dim);
    color: var(--text);
}

/* ── Settings pane ───────────────────────────────────────────────────────── */

#settings-pane {
    position: fixed;
    top: 37px;
    left: 0;
    visibility: hidden;
    opacity: 0;
    background: var(--pane-bg);
    border: 1px solid var(--pane-border);
    border-top: none;
    padding: 12px 18px;
    z-index: 9;
    box-shadow: 0 4px 20px var(--pane-shadow);
    border-radius: 0 0 6px 6px;
    transition: opacity 0.15s ease, visibility 0s 0.15s;
}
#settings-pane.open {
    visibility: visible;
    opacity: 1;
    transition: opacity 0.15s ease, visibility 0s 0s;
}

.setting-group {
    margin-bottom: 4px;
}
.setting-group:last-child {
    margin-bottom: 0;
}

.group-sep {
    border: none;
    border-top: 1px solid var(--border);
    margin: 4px 0;
}

.group-title {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-dimmer);
    margin-bottom: 4px;
    padding-left: 1px;
}

.setting-row {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 0.75rem;
    margin: 3px 0;
    white-space: nowrap;
    cursor: pointer;
}
.setting-row input[type="checkbox"] {
    margin: 0;
}

.sub-setting {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 0 2px 17px;
    font-size: 0.7rem;
    color: var(--text-dim);
    max-height: 22px;
    overflow: hidden;
    transition: max-height 0.15s ease, opacity 0.15s ease, margin 0.15s ease;
}
.sub-setting.hidden {
    max-height: 0;
    opacity: 0;
    margin: 0;
}
.setting-row.dependent {
    padding-left: 14px;
    transition: opacity 0.15s ease;
}
.setting-row.dependent.disabled {
    opacity: 0.3;
    pointer-events: none;
}
.sub-label {
    min-width: 48px;
}
#fade-duration {
    flex: 1;
    height: 4px;
    cursor: pointer;
}
#fade-duration-label {
    min-width: 32px;
    text-align: right;
}

/* ── Main column ─────────────────────────────────────────────────────────── */

#mid-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding-top: 50px;
    padding-bottom: 80px;
}

#chord {
    font-size: 2.4rem;
    min-height: 2em;
    color: var(--chord);
    font-weight: bold;
    letter-spacing: 1px;
    margin: 10px 0 4px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#intervals {
    font-family: "SF Mono", "Consolas", "Menlo", monospace;
    font-size: 0.65rem;
    font-weight: normal;
    color: var(--text-muted);
    letter-spacing: 1px;
    margin-top: 2px;
    min-height: 1em;
}

canvas {
    display: block;
    border-radius: 50%;
    background: var(--canvas-bg);
    border: 7px solid var(--canvas-border);
    outline: 7px solid var(--canvas-outline);
    box-shadow: 0 9px 32px var(--canvas-shadow);
    position: relative;
    z-index: 1;
}

/* ── Footer controls ─────────────────────────────────────────────────────── */

#foot-row {
    width: 100%;
    max-width: 600px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.control-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.control-row label {
    color: var(--text-dimmer);
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.control-row select {
    padding: 2px 8px;
    font-size: 0.7rem;
    background: transparent;
    border: 1px solid var(--border-strong);
    color: var(--text-dim);
    border-radius: 3px;
    cursor: pointer;
    outline: none;
    font-family: monospace;
    transition: border-color 0.15s, color 0.15s;
}
.control-row select:hover {
    border-color: var(--text-dim);
    color: var(--text-muted);
}

/* ── Keyboard ────────────────────────────────────────────────────────────── */

#keyboard {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: var(--bg);
    z-index: 1;
    padding: 4px 0;
    transition: transform 0.25s ease, opacity 0.25s ease;
    overflow: visible;
}
#keyboard.hidden {
    transform: translateY(100%);
    opacity: 0;
    pointer-events: none;
}

#piano {
    position: relative;
    display: flex;
    max-width: 1400px;
    margin: 0 auto;
    height: 44px;
    user-select: none;
    overflow: visible;
}

.white-key {
    flex: 1;
    background: var(--key-white);
    border-radius: 0 0 2px 2px;
    margin: 0 0.5px;
    position: relative;
    z-index: 0;
    transition: background 0.06s ease;
    box-shadow: 1px 2px 2px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(0, 0, 0, 0.3);
}
.white-key .key-label {
    position: absolute;
    bottom: 3px;
    left: 0;
    width: 100%;
    text-align: center;
    font-family: 'creep', monospace;
    font-size: 8px;
    letter-spacing: -1px;
    transform: translateX(1px);
    color: var(--key-label);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
}
#piano.labels-enabled.show-labels .white-key .key-label {
    opacity: 0.85;
}
.white-key.active {
    background: var(--key-white-active);
}

.black-key {
    position: absolute;
    width: 1.1%;
    height: 22px;
    background: var(--key-black);
    border: 1px solid var(--key-black);
    border-style: none solid solid solid;
    border-radius: 0 0 2px 2px;
    z-index: 1;
    transition: background 0.06s ease;
}
.black-key.active {
    background: var(--key-black-active);
}
