.scale-piano {
    display: flex;
    position: relative;
    width: 100%;
    max-width: 560px;
    height: clamp(150px, 30vw, 220px);
    margin: 1.5rem auto 1rem;
    scroll-margin-top: 6rem;
}
.scale-key {
    border: 1px solid #333;
    border-radius: 0 0 6px 6px;
    cursor: pointer;
    font: inherit;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0 0 12px;
}
.scale-white {
    flex: 1 1 0;
    min-width: 0;
    height: 100%;
    background: #e5f7eb;
    color: #174d2b;
}
.scale-white span {
    background: #b6eac8;
    border-radius: 50%;
    padding: 3px 8px;
}
.scale-black {
    position: absolute;
    transform: translateX(-50%);
    width: 8%;
    height: 62%;
    background: #222;
    color: #fff;
    font-size: 0.75rem;
    z-index: 1;
}
.scale-key.in-scale.scale-white { box-shadow: inset 0 0 0 2px #2ecc71; }
.scale-key.in-scale.scale-black { background: #3d3d3d; box-shadow: inset 0 0 0 2px #2ecc71; }
.scale-key.is-tonika { position: relative; }
.scale-key.is-tonika::after {
    content: "";
    position: absolute;
    top: 6px;
    left: 50%;
    transform: translateX(-50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-orange);
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.15);
}
.scale-key:hover, .scale-key.is-playing { background: #2ecc71; color: #102b19; }
.scale-key:focus-visible { outline: 3px solid #1764bc; outline-offset: -4px; }
.scale-controls { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.scale-play { box-sizing: border-box; font: inherit; margin-bottom: 1rem; white-space: nowrap; }
.scale-play[aria-pressed="true"] { background: #b6eac8; color: #174d2b; }
.scale-piano-hint { font-size: 0.9rem; }
.scale-intervals { list-style: none; padding-left: 0; margin-bottom: 1.5rem; }

/* Piano + intervallmönster */
.pattern-piano {
    max-width: 480px;
    margin: 1.5rem auto;
}
.pp-piano {
    display: flex;
    position: relative;
    width: 100%;
    height: clamp(90px, 22vw, 130px);
}
.pp-white {
    flex: 1 1 0;
    min-width: 0;
    height: 100%;
    background: #fff;
    border: 2px solid #888;
    border-top: 4px solid #888;
    border-radius: 0 0 6px 6px;
    margin-left: -2px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 0.5rem;
    text-align: center;
    font-weight: 700;
    font-size: 0.95rem;
    color: #333;
}
.pp-white:first-child {
    margin-left: 0;
}
.pp-white.in-scale {
    background: #b6eac8;
    color: #174d2b;
}
.pp-white.pp-lead {
    color: #aaa;
    font-weight: 400;
}
.pp-black {
    position: absolute;
    top: 0;
    transform: translateX(-50%);
    width: 8%;
    height: 60%;
    background: #222;
    border-radius: 0 0 4px 4px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 0.4rem;
    text-align: center;
    font-weight: 700;
    font-size: 0.75rem;
    color: #fff;
    z-index: 1;
}
.pp-black.in-scale {
    box-shadow: inset 0 0 0 2px #2ecc71;
}
.pp-steps {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    padding: 0 calc(100% / 16);
    margin-top: 0.5rem;
}
.pp-steps span {
    text-align: center;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--primary-dark);
}
.pp-steps .pp-half {
    color: var(--secondary-color);
}

/* Upptäck-ruta */
.discovery-box {
    background: var(--background-alt);
    border-left: 4px solid var(--primary-color);
    border-radius: 0 8px 8px 0;
    padding: 1.25rem 1.5rem;
    margin: 1.5rem 0;
}
.discovery-box p {
    margin-bottom: 0.5rem;
}
.discovery-box p:last-child {
    margin-bottom: 0;
}

/* Utforska tonarter */
.key-explorer-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.key-tab[aria-pressed="true"] {
    background: var(--primary-color);
    color: var(--text-on-primary);
}
.key-explorer-description {
    font-weight: 600;
    min-height: 1.4em;
}
.key-explorer-tonic-label {
    color: var(--accent-orange);
}
.key-explorer-staff {
    max-width: 560px;
    margin: 1.25rem auto;
}
.key-explorer-staff svg {
    width: 100%;
    height: auto;
    display: block;
}
.key-explorer-staff-bg {
    fill: #ffffff;
}
.key-explorer-notehead {
    fill: #2c3e50;
    transition: fill 0.15s ease;
}
.key-explorer-notehead.is-tonika {
    fill: var(--accent-orange);
}
.key-explorer-notehead.is-playing {
    fill: var(--primary-color);
}
.key-explorer-ledger {
    stroke: #999;
    stroke-width: 1.5;
}
.key-explorer-play {
    margin-top: 0.5rem;
}

/* Kvintcirkeln */
.quint-circle-wrap {
    max-width: 520px;
    margin: 2rem auto 1rem;
}
.quint-circle {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
}
.quint-circle-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    border: 2px dashed var(--border-color);
}
.quint-circle-ring.outer {
    width: 84%;
    height: 84%;
}
.quint-circle-ring.inner {
    width: 54%;
    height: 54%;
}
.quint-circle-node {
    position: absolute;
    transform: translate(-50%, -50%);
    border-radius: 50px;
    text-align: center;
    font-weight: 800;
    white-space: nowrap;
    line-height: 1.1;
    font-family: inherit;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.quint-circle-node.major {
    background: var(--primary-color);
    color: var(--text-on-primary);
    padding: 0.45rem 0.65rem;
    font-size: 0.95rem;
    border: none;
}
.quint-circle-node.minor {
    background: var(--background-alt);
    color: var(--primary-dark);
    border: 2px solid var(--primary-color);
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 700;
}
.quint-circle-node.is-wide {
    white-space: normal;
    width: 4.2rem;
    font-size: 0.75rem;
    padding: 0.35rem 0.3rem;
}
.quint-circle-node.minor.is-wide {
    width: 3.6rem;
    font-size: 0.62rem;
    padding: 0.2rem 0.25rem;
}
.quint-circle-node:hover {
    transform: translate(-50%, -50%) scale(1.1);
}
.quint-circle-node:focus-visible {
    outline: 3px solid #1764bc;
    outline-offset: 2px;
}
.quint-circle-node.is-selected {
    background: var(--accent-orange);
    color: var(--text-on-primary);
    border-color: var(--accent-orange);
    box-shadow: 0 0 0 3px rgba(243, 156, 18, 0.35);
}
.quint-circle-caption {
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-light);
    margin-top: 0.75rem;
}
.quint-circle-description {
    text-align: center;
    font-weight: 600;
    min-height: 1.4em;
    margin-top: 0.75rem;
    color: var(--accent-orange);
}
.quint-circle-staff {
    max-width: 300px;
    margin: 1rem auto 0;
}
.quint-circle-staff svg {
    width: 100%;
    height: auto;
    display: block;
}
.quint-circle-staff .key-explorer-staff-bg {
    fill: #ffffff;
}
.quint-circle-staff.is-centered {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 34%;
    max-width: 165px;
    margin: 0;
    z-index: 2;
    pointer-events: none;
}

@media (max-width: 480px) {
    .quint-circle-node.major {
        font-size: 0.8rem;
        padding: 0.35rem 0.5rem;
    }
    .quint-circle-node.minor {
        font-size: 0.62rem;
        padding: 0.2rem 0.4rem;
    }
    .quint-circle-node.is-wide {
        font-size: 0.62rem;
        width: 3.4rem;
    }
    .quint-circle-node.minor.is-wide {
        font-size: 0.52rem;
        width: 3rem;
    }
}

@media (prefers-color-scheme: dark) {
    .pp-white {
        background: #e8e8e8;
        border-color: #999;
        color: #222;
    }
    .pp-white.pp-lead {
        color: #999;
    }
    .key-explorer-staff-bg {
        fill: #e8e8e8;
    }
    .quint-circle-staff .key-explorer-staff-bg {
        fill: #e8e8e8;
    }
}
