.jg-metronome {
    --jg-metro-blue: #2f84b7;
    --jg-metro-blue-dark: #1e648e;
    --jg-metro-blue-soft: #eaf6fc;
    --jg-metro-ink: #173044;
    --jg-metro-muted: #607384;
    width: min(100%, 620px);
    box-sizing: border-box;
    margin: 34px auto 52px;
    padding: clamp(24px, 5vw, 40px);
    color: var(--jg-metro-ink);
    text-align: center;
    background: linear-gradient(145deg, #ffffff 0%, #f6fbfe 100%);
    border: 1px solid #d8eaf4;
    border-radius: 24px;
    box-shadow: 0 18px 50px rgba(31, 91, 128, 0.12);
}

.jg-metronome *,
.jg-metronome *::before,
.jg-metronome *::after { box-sizing: border-box; }

.jg-metronome__eyebrow {
    margin: 0 0 4px;
    color: var(--jg-metro-blue-dark);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.jg-metronome__tempo-readout {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 9px;
}

.jg-metronome .jg-metronome__tempo-input {
    width: 3.25ch;
    min-width: 0;
    padding: 0;
    color: var(--jg-metro-ink);
    font: inherit;
    font-size: clamp(3.6rem, 12vw, 5.5rem);
    font-weight: 750;
    line-height: 1;
    text-align: right;
    background: transparent;
    border: 0;
    border-radius: 0;
    appearance: textfield;
}

.jg-metronome .jg-metronome__tempo-input::-webkit-inner-spin-button,
.jg-metronome .jg-metronome__tempo-input::-webkit-outer-spin-button {
    margin: 0;
    appearance: none;
}

.jg-metronome .jg-metronome__tempo-input:focus-visible {
    outline: 3px solid rgba(47, 132, 183, 0.35);
    outline-offset: 4px;
}

.jg-metronome__bpm {
    color: var(--jg-metro-muted);
    font-size: 1rem;
    font-weight: 700;
}

.jg-metronome__tempo-name {
    min-height: 1.5em;
    margin: 6px 0 24px;
    color: var(--jg-metro-muted);
}

.jg-metronome__beats {
    display: flex;
    justify-content: center;
    gap: 12px;
    min-height: 19px;
    margin-bottom: 24px;
}

.jg-metronome__beat {
    width: 12px;
    height: 12px;
    background: #c5d5df;
    border-radius: 50%;
    transition: transform 70ms ease, background-color 70ms ease, box-shadow 70ms ease;
}

.jg-metronome__beat--accent {
    width: 16px;
    height: 16px;
    margin-top: -2px;
}

.jg-metronome__beat.is-active {
    background: var(--jg-metro-blue);
    box-shadow: 0 0 0 7px rgba(47, 132, 183, 0.13);
    transform: scale(1.18);
}

.jg-metronome__tempo-controls {
    display: grid;
    grid-template-columns: 48px 1fr 48px;
    align-items: center;
    gap: 14px;
    margin-bottom: 24px;
}

.jg-metronome button,
.jg-metronome input,
.jg-metronome select { font: inherit; }

.jg-metronome button { cursor: pointer; }

.jg-metronome button:focus-visible,
.jg-metronome input:focus-visible,
.jg-metronome select:focus-visible {
    outline: 3px solid rgba(47, 132, 183, 0.4);
    outline-offset: 3px;
}

.jg-metronome__step {
    display: grid;
    width: 48px;
    height: 48px;
    padding: 0;
    place-items: center;
    color: var(--jg-metro-blue-dark);
    font-size: 1.8rem;
    line-height: 1;
    background: var(--jg-metro-blue-soft);
    border: 1px solid #cae5f4;
    border-radius: 50%;
}

.jg-metronome__step:hover { background: #d9effa; }

.jg-metronome .jg-metronome__range {
    width: 100%;
    height: 7px;
    padding: 0;
    accent-color: var(--jg-metro-blue);
    background: #dbe8ef;
    border: 0;
    border-radius: 999px;
    cursor: pointer;
}

.jg-metronome__actions {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
    gap: 12px;
    margin-bottom: 26px;
}

.jg-metronome .jg-metronome__start,
.jg-metronome .jg-metronome__tap {
    min-height: 54px;
    padding: 12px 20px;
    font-weight: 700;
    border-radius: 999px;
}

.jg-metronome .jg-metronome__start {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: #fff;
    background: var(--jg-metro-blue);
    border: 2px solid var(--jg-metro-blue);
    box-shadow: 0 8px 20px rgba(47, 132, 183, 0.24);
}

.jg-metronome .jg-metronome__start:hover {
    background: var(--jg-metro-blue-dark);
    border-color: var(--jg-metro-blue-dark);
}

.jg-metronome.is-playing .jg-metronome__start {
    background: #c84b55;
    border-color: #c84b55;
    box-shadow: 0 8px 20px rgba(200, 75, 85, 0.2);
}

.jg-metronome .jg-metronome__tap {
    color: var(--jg-metro-blue-dark);
    background: #fff;
    border: 2px solid #bddceb;
}

.jg-metronome .jg-metronome__tap:hover { background: var(--jg-metro-blue-soft); }
.jg-metronome__start-icon { font-size: 0.8em; }

.jg-metronome__options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding-top: 20px;
    text-align: left;
    border-top: 1px solid #dce9f0;
}

.jg-metronome__option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 44px;
    color: var(--jg-metro-muted);
    font-size: 0.9rem;
    font-weight: 600;
}

.jg-metronome .jg-metronome__option select {
    width: 76px;
    padding: 7px 24px 7px 12px;
    color: var(--jg-metro-ink);
    line-height: 1.25;
    background-color: #fff;
    border: 1px solid #bfd2dd;
    border-radius: 8px;
}

.jg-metronome .jg-metronome__toggle input {
    width: 20px;
    height: 20px;
    margin: 0;
    accent-color: var(--jg-metro-blue);
}

.jg-metronome__status {
    min-height: 1.5em;
    margin: 18px 0 0;
    color: var(--jg-metro-blue-dark);
    font-size: 0.88rem;
    font-weight: 700;
}

.jg-metronome__hint {
    margin: 5px 0 0;
    color: var(--jg-metro-muted);
    font-size: 0.78rem;
}

.jg-metronome__hint-touch { display: none; }
.jg-metronome__audio {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

@media (hover: none), (pointer: coarse) {
    .jg-metronome__hint-desktop { display: none; }
    .jg-metronome__hint-touch { display: inline; }
}

@media (max-width: 560px) {
    .jg-metronome {
        margin-top: 24px;
        padding: 24px 18px;
        border-radius: 18px;
    }

    .jg-metronome__actions,
    .jg-metronome__options { grid-template-columns: 1fr; }
    .jg-metronome__option { padding: 0 4px; }
}

@media (prefers-reduced-motion: reduce) {
    .jg-metronome__beat { transition: none; }
}
