:root {
    --page-top: #dfe4e8;
    --page-bottom: #aeb8bf;
    --panel-top: #eef2f5;
    --panel-bottom: #cbd3d9;
    --border: #53616a;
    --text: #18252d;
    --muted: #5d6c76;
    --dark: #080d11;
    --dark-2: #303c44;
    --button-top: #71818b;
    --button-bottom: #46545e;
    --accent: #f0a817;
    --accent-dark: #a86c00;
    --line: #99a6ae;
    --shadow: rgba(15, 26, 33, 0.14);
    font-family: Roboto, Arial, Helvetica, sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: linear-gradient(180deg, var(--page-top), var(--page-bottom));
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background: linear-gradient(180deg, var(--page-top), var(--page-bottom));
}

a:link, a:visited {color: #b84444;}

button,
input {
    font: inherit;
}

button:focus-visible,
.drop-zone:focus-visible {
    outline: 3px solid rgba(240, 168, 23, 0.48);
    outline-offset: 2px;
}

.app-shell {
    width: min(1080px, calc(100% - 28px));
    margin: 18px auto 36px;
}

.panel {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: linear-gradient(180deg, var(--panel-top), var(--panel-bottom));
    box-shadow: 0 2px 8px var(--shadow), inset 0 1px rgba(255, 255, 255, 0.8);
}

.hero {
    padding: 18px 20px;
    margin-bottom: 12px;
}

.eyebrow {
    margin: 0 0 3px;
    color: #8c5a00;
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0.15em;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 4px;
    font-size: clamp(2rem, 4.3vw, 3rem);
    line-height: 0.98;
    letter-spacing: -0.035em;
}

h2 {
    margin-bottom: 8px;
    font-size: 1.05rem;
}

.intro,
.info p {
    max-width: 850px;
    margin-bottom: 0;
    color: #34444e;
    line-height: 1.35;
}

.analyzer {
    padding: 14px;
    margin-bottom: 12px;
}

.panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 12px;
}

.panel-head h2 {
    margin-bottom: 0;
}

.button {
    min-height: 38px;
    padding: 8px 14px;
    border: 1px solid #53616a;
    border-radius: 4px;
    color: #fff;
    background: linear-gradient(180deg, var(--button-top), var(--button-bottom));
    box-shadow: inset 0 1px rgba(255, 255, 255, 0.26), 0 1px 2px rgba(0, 0, 0, 0.16);
    font-weight: 700;
    cursor: pointer;
}

.button:hover:not(:disabled) {
    filter: brightness(1.07);
}

.button:active:not(:disabled) {
    transform: translateY(1px);
}

.button:disabled {
    opacity: 0.48;
    cursor: default;
}

.button-accent {
    border-color: #956200;
    color: #261b04;
    background: linear-gradient(180deg, #ffc13b, var(--accent));
}

.drop-zone {
    position: relative;
    overflow: hidden;
    height: 260px;
    border: 1px solid #53616a;
    border-radius: 5px 5px 2px 2px;
    background: var(--dark);
    cursor: pointer;
}

.drop-zone.drag-over {
    box-shadow: inset 0 0 0 3px var(--accent);
}

#waveform {
    display: block;
    width: 100%;
    height: 100%;
}

.drop-hint {
    position: absolute;
    inset: 0;
    display: grid;
    place-content: center;
    gap: 5px;
    text-align: center;
    color: #81919c;
    pointer-events: none;
}

.drop-hint strong {
    color: #aebbc4;
    font-size: 1rem;
}

.playhead {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    left: 0;
    background: var(--accent);
    box-shadow: 0 0 8px rgba(240, 168, 23, 0.75);
    pointer-events: none;
}

.file-row {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    padding: 10px 2px 2px;
    font-size: 0.9rem;
}

.file-row > div:first-child {
    min-width: 0;
}

.file-row strong {
    display: block;
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-meta {
    flex: 0 0 auto;
    color: var(--muted);
    text-align: right;
}

.muted {
    color: var(--muted);
}

.controls {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.status {
    min-height: 34px;
    margin-top: 10px;
    padding: 8px 10px;
    border-top: 1px solid #9ca8af;
    color: #46555f;
    font-size: 0.88rem;
}

.status.error {
    color: #8a1f16;
    font-weight: 700;
}

.results-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
    gap: 12px;
    margin-bottom: 12px;
}

.result-main,
.details,
.info {
    padding: 14px;
}

.bpm-readout {
    display: flex;
    align-items: baseline;
    min-height: 118px;
    padding: 12px 16px;
    border: 1px solid #53616a;
    border-radius: 5px;
    color: #fff;
    background:
        linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px),
        linear-gradient(180deg, #10171c, #222d34);
    background-size: 44px 44px, 44px 44px, auto;
}

#bpmValue {
    font-size: clamp(4.1rem, 9vw, 6.6rem);
    font-weight: 900;
    line-height: 0.9;
    letter-spacing: -0.055em;
}

.bpm-unit {
    margin-left: 10px;
    color: var(--accent);
    font-size: 1.15rem;
    font-weight: 900;
}

.confidence-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 9px;
    margin-top: 12px;
    font-size: 0.88rem;
}

.meter {
    height: 7px;
    overflow: hidden;
    border-radius: 999px;
    background: #52585c;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.38);
}

.meter span {
    display: block;
    width: 0;
    height: 100%;
    background: var(--accent);
    transition: width 220ms ease;
}

.result-note {
    margin: 12px 0 0;
    color: var(--muted);
    line-height: 1.35;
}

.details dl {
    margin: 0;
}

.details dl > div {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    padding: 12px 0;
    border-top: 1px solid #a4afb6;
}

.details dt {
    color: var(--muted);
}

.details dd {
    margin: 0;
    font-weight: 800;
}

.info p {
    max-width: none;
}

@media (max-width: 760px) {
    .app-shell {
        width: min(100% - 16px, 1080px);
        margin-top: 8px;
    }

    .hero,
    .analyzer,
    .result-main,
    .details,
    .info {
        padding: 12px;
    }

    h1 {
        font-size: 2.15rem;
    }

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

    .panel-head .button {
        width: 100%;
    }

    .drop-zone {
        height: 220px;
    }

    .file-row {
        flex-direction: column;
        gap: 5px;
    }

    .file-meta {
        text-align: left;
    }

    .results-grid {
        grid-template-columns: 1fr;
    }

    .controls {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 420px) {
    .drop-zone {
        height: 190px;
    }

    .controls {
        grid-template-columns: 1fr;
    }

    .confidence-row {
        grid-template-columns: auto auto;
    }

    .meter {
        grid-column: 1 / -1;
        grid-row: 2;
    }
}
