/* =============================================================
   HeadScore Pro — headscore-pro.css
   Same family as MicScore Pro · micaudiotest.com
   Palette: White · Dark green #1a5c3a · Accent #2d9e65
   Font: DM Sans + DM Mono
   ============================================================= */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600;700&family=DM+Mono:wght@400;500&display=swap');

/* ── Root ─────────────────────────────────────────────────────── */
.hsp-root {
    --g-dark:   #1a5c3a;
    --g-mid:    #2d9e65;
    --g-light:  #e8f5ee;
    --g-border: #d1e8db;
    --g-bg:     #f7faf8;
    --g-white:  #ffffff;
    --g-text:   #1a1f1d;
    --g-muted:  #6b7c74;
    --g-amber:  #e07b2a;
    --g-red:    #c0392b;
    --radius:   14px;
    --shadow:   0 4px 28px rgba(26,92,58,.11);

    font-family: 'DM Sans', sans-serif;
    background:  var(--g-white);
    border:      1px solid var(--g-border);
    border-radius: calc(var(--radius) + 4px);
    box-shadow:  var(--shadow);
    max-width:   680px;
    margin:      2rem auto;
    color:       var(--g-text);
    overflow:    hidden;
}

/* Prevent theme SVG stretching */
.hsp-root svg {
    display: inline-block;
    vertical-align: middle;
    max-width: none;
    width: auto;
    height: auto;
}

/* ── Header ───────────────────────────────────────────────────── */
.hsp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .75rem;
    padding: 1.1rem 2rem;
    background: var(--g-bg);
    border-bottom: 1px solid var(--g-border);
}

.hsp-logo {
    display: flex;
    align-items: center;
    gap: .65rem;
}
.hsp-logo svg { width: 32px !important; height: 32px !important; flex-shrink: 0; }
.hsp-logo-name {
    display: block;
    font-size: 1.05rem;
    font-weight: 300;
    letter-spacing: -.02em;
    color: var(--g-dark);
    line-height: 1.2;
}
.hsp-logo-name strong { font-weight: 700; }
.hsp-logo-sub {
    display: block;
    font-size: .72rem;
    color: var(--g-muted);
}
.hsp-logo-sub a { color: var(--g-mid); text-decoration: none; }
.hsp-logo-sub a:hover { text-decoration: underline; }

.hsp-device-pill {
    display: flex;
    align-items: center;
    gap: .4rem;
    font-size: .78rem;
    font-weight: 500;
    color: var(--g-muted);
    background: var(--g-white);
    border: 1px solid var(--g-border);
    padding: .3rem .75rem;
    border-radius: 20px;
    max-width: 220px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.hsp-device-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--g-muted); flex-shrink: 0;
    transition: background .3s;
}
.hsp-device-dot.is-active {
    background: var(--g-mid);
    box-shadow: 0 0 5px var(--g-mid);
}

/* ── Screens ──────────────────────────────────────────────────── */
.hsp-screen { display: none; padding: 1.75rem 2rem; }
.hsp-screen.is-active { display: block; }

.hsp-screen-header {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-bottom: 1rem;
}
.hsp-screen-header h2 {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -.02em;
    margin: 0;
}
.hsp-back-btn {
    font-family: 'DM Sans', sans-serif;
    font-size: .78rem;
    color: var(--g-muted);
    background: none;
    border: 1px solid var(--g-border);
    border-radius: 8px;
    padding: .3rem .65rem;
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
}
.hsp-back-btn:hover { color: var(--g-dark); border-color: var(--g-mid); }

.hsp-section-title { font-size: 1.2rem; font-weight: 700; margin: 0 0 .35rem; letter-spacing: -.02em; }
.hsp-section-sub   { font-size: .875rem; color: var(--g-muted); margin: 0 0 1.5rem; }
.hsp-hint          { font-size: .85rem; color: var(--g-muted); margin: 0 0 1.25rem; line-height: 1.6; }

/* ── Test grid (menu) ─────────────────────────────────────────── */
.hsp-test-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: .75rem;
}

.hsp-test-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .35rem;
    padding: 1.1rem .75rem;
    background: var(--g-bg);
    border: 2px solid var(--g-border);
    border-radius: var(--radius);
    cursor: pointer;
    font-family: 'DM Sans', sans-serif;
    text-align: center;
    transition: all .18s ease;
}
.hsp-test-card:hover {
    border-color: var(--g-mid);
    background: var(--g-light);
    transform: translateY(-2px);
    box-shadow: 0 5px 16px rgba(26,92,58,.12);
}
.hsp-test-card strong { font-size: .88rem; font-weight: 600; color: var(--g-text); }
.hsp-test-card small  { font-size: .73rem; color: var(--g-muted); }
.hsp-card-icon        { font-size: 1.6rem; }

.hsp-card--full {
    grid-column: span 3;
    flex-direction: row;
    justify-content: center;
    gap: .65rem;
    background: var(--g-dark);
    border-color: var(--g-dark);
    color: #fff;
    padding: .9rem;
}
.hsp-card--full:hover { background: var(--g-mid); border-color: var(--g-mid); transform: translateY(-1px); }
.hsp-card--full strong,
.hsp-card--full small { color: #fff; }
.hsp-card--full small { opacity: .75; }

/* ── Buttons ──────────────────────────────────────────────────── */
.hsp-controls { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1.25rem; }

.hsp-btn {
    padding: .68rem 1.25rem;
    border-radius: 9px; border: none;
    font-family: 'DM Sans', sans-serif;
    font-size: .875rem; font-weight: 600;
    cursor: pointer; transition: all .18s;
    letter-spacing: .01em;
}
.hsp-btn:disabled { opacity: .36; cursor: not-allowed; }
.hsp-btn--primary { background: var(--g-dark); color: #fff; }
.hsp-btn--primary:hover:not(:disabled) { background: var(--g-mid); transform: translateY(-1px); box-shadow: 0 4px 14px rgba(26,92,58,.22); }
.hsp-btn--danger  { background: var(--g-red); color: #fff; }
.hsp-btn--danger:hover:not(:disabled)  { background: #a93226; }
.hsp-btn--ghost   { background: var(--g-bg); color: var(--g-text); border: 1px solid var(--g-border); }
.hsp-btn--ghost:hover:not(:disabled)   { background: var(--g-light); border-color: var(--g-mid); }

.hsp-result-badge {
    margin-top: 1rem;
    padding: 0;
    border-radius: 10px;
    font-size: .85rem;
    max-height: 0;
    overflow: hidden;
    transition: max-height .35s ease, padding .25s;
}
.hsp-result-badge.visible {
    max-height: 80px;
    padding: .75rem 1rem;
}
.hsp-result-badge.ok   { background: rgba(45,158,101,.1); border: 1px solid rgba(45,158,101,.3); color: var(--g-dark); }
.hsp-result-badge.warn { background: rgba(224,123,42,.1); border: 1px solid rgba(224,123,42,.3); color: #7c3d00; }
.hsp-result-badge.fail { background: rgba(192,57,43,.1);  border: 1px solid rgba(192,57,43,.3);  color: var(--g-red); }

/* ── Balance test ─────────────────────────────────────────────── */
.hsp-balance-visual {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
    padding: 1.25rem;
    background: var(--g-bg);
    border: 1px solid var(--g-border);
    border-radius: var(--radius);
}

.hsp-channel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .5rem;
    flex: 1;
}
.hsp-channel-label {
    font-family: 'DM Mono', monospace;
    font-size: .72rem;
    font-weight: 500;
    letter-spacing: .08em;
    color: var(--g-muted);
}
.hsp-channel-ring {
    width: 64px; height: 64px;
    border-radius: 50%;
    border: 3px solid var(--g-border);
    display: flex; align-items: center; justify-content: center;
    transition: border-color .2s, box-shadow .2s;
    background: var(--g-white);
}
.hsp-channel-ring.is-active {
    border-color: var(--g-mid);
    box-shadow: 0 0 0 5px rgba(45,158,101,.2);
    animation: chPulse 1s ease-in-out infinite;
}
@keyframes chPulse { 0%,100%{transform:scale(1)} 50%{transform:scale(1.06)} }

.hsp-channel-meter {
    width: 100%;
    height: 6px;
    background: var(--g-border);
    border-radius: 999px;
    overflow: hidden;
}
.hsp-ch-bar {
    height: 100%;
    width: 0%;
    background: var(--g-mid);
    border-radius: 999px;
    transition: width .1s;
}
.hsp-channel-db {
    font-family: 'DM Mono', monospace;
    font-size: .72rem;
    color: var(--g-dark);
}

.hsp-balance-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .4rem;
    flex-shrink: 0;
}
.hsp-balance-gauge {
    width: 80px;
    height: 8px;
    background: var(--g-border);
    border-radius: 999px;
    position: relative;
}
.hsp-gauge-needle {
    position: absolute;
    top: -3px;
    left: 50%;
    transform: translateX(-50%);
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--g-dark);
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,.2);
    transition: left .3s ease;
}
.hsp-balance-label {
    font-size: .75rem;
    font-weight: 600;
    color: var(--g-muted);
    white-space: nowrap;
}

.hsp-test-sequence {
    display: flex;
    flex-direction: column;
    gap: .4rem;
    margin-bottom: 1rem;
}
.hsp-seq-step {
    padding: .5rem .85rem;
    border-radius: 8px;
    font-size: .82rem;
    color: var(--g-muted);
    background: var(--g-bg);
    border: 1px solid transparent;
    transition: all .2s;
}
.hsp-seq-step.is-active {
    color: var(--g-dark);
    background: var(--g-light);
    border-color: var(--g-border);
    font-weight: 500;
}

/* ── Frequency sweep ──────────────────────────────────────────── */
.hsp-sweep-display {
    background: var(--g-bg);
    border: 1px solid var(--g-border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
    text-align: center;
}
.hsp-sweep-freq {
    font-family: 'DM Mono', monospace;
    font-size: 2rem;
    font-weight: 500;
    color: var(--g-dark);
    letter-spacing: -.02em;
    line-height: 1;
    margin-bottom: .15rem;
}
.hsp-sweep-label {
    font-size: .72rem;
    color: var(--g-muted);
    margin-bottom: .85rem;
    text-transform: uppercase;
    letter-spacing: .06em;
}
#hsp-sweep-canvas {
    display: block;
    width: 100%;
    height: 80px;
    border-radius: 8px;
    background: #f0f7f3;
    margin-bottom: .65rem;
}
.hsp-sweep-bar-wrap {
    height: 6px;
    background: var(--g-border);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: .3rem;
}
.hsp-sweep-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--g-dark), var(--g-mid));
    border-radius: 999px;
    transition: width .1s;
}
.hsp-sweep-range {
    display: flex;
    justify-content: space-between;
    font-family: 'DM Mono', monospace;
    font-size: .65rem;
    color: var(--g-muted);
}

.hsp-sweep-limits {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: .85rem 1rem;
    background: var(--g-light);
    border: 1px solid var(--g-border);
    border-radius: 10px;
}
.hsp-limit-item {
    display: flex;
    flex-direction: column;
    gap: .15rem;
    flex: 1;
    text-align: center;
}
.hsp-limit-item span { font-size: .72rem; color: var(--g-muted); }
.hsp-limit-item strong { font-family: 'DM Mono', monospace; font-size: .95rem; color: var(--g-dark); }

/* ── Bass driver test ─────────────────────────────────────────── */
.hsp-bass-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: .65rem;
    margin-bottom: 1rem;
}

.hsp-bass-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .3rem;
    padding: .9rem .5rem;
    background: var(--g-bg);
    border: 2px solid var(--g-border);
    border-radius: 12px;
    cursor: pointer;
    font-family: 'DM Sans', sans-serif;
    transition: all .15s;
    position: relative;
    overflow: hidden;
}
.hsp-bass-btn:hover {
    border-color: var(--g-mid);
    background: var(--g-light);
}
.hsp-bass-btn.is-playing {
    border-color: var(--g-dark);
    background: var(--g-light);
    box-shadow: 0 0 0 3px rgba(26,92,58,.15);
}
.hsp-bass-hz   { font-family: 'DM Mono', monospace; font-size: .95rem; font-weight: 500; color: var(--g-dark); }
.hsp-bass-desc { font-size: .7rem; color: var(--g-muted); }
.hsp-bass-wave {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 3px;
    background: var(--g-mid);
    transform: scaleX(0);
    transition: transform .15s;
}
.hsp-bass-btn.is-playing .hsp-bass-wave { transform: scaleX(1); animation: bassWave .5s ease-in-out infinite alternate; }
@keyframes bassWave { from{height:3px} to{height:6px} }

.hsp-bass-rating { margin-bottom: 1rem; }
.hsp-bass-rating p { font-size: .82rem; color: var(--g-muted); margin: 0 0 .5rem; }
.hsp-rating-row { display: flex; flex-wrap: wrap; gap: .4rem; }
.hsp-rating-chip {
    font-size: .75rem;
    padding: .3rem .7rem;
    border-radius: 20px;
    border: 1px solid var(--g-border);
    background: var(--g-white);
    cursor: pointer;
    transition: all .15s;
    font-family: 'DM Sans', sans-serif;
}
.hsp-rating-chip:hover { border-color: var(--g-mid); background: var(--g-light); }
.hsp-rating-chip.is-good   { background: rgba(45,158,101,.15); border-color: var(--g-mid); color: var(--g-dark); }
.hsp-rating-chip.is-weak   { background: rgba(224,123,42,.1);  border-color: var(--g-amber); color: #7c3d00; }
.hsp-rating-chip.is-silent { background: rgba(192,57,43,.1);   border-color: var(--g-red); color: var(--g-red); }

/* ── Latency test ─────────────────────────────────────────────── */
.hsp-latency-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .75rem;
    margin-bottom: 1.25rem;
}
.hsp-latency-ring {
    position: relative;
    width: 150px;
    height: 150px;
}
.hsp-latency-ring svg { position: absolute; top: 0; left: 0; }
.hsp-lat-bg   { fill: none; stroke: var(--g-border); stroke-width: 10; }
.hsp-lat-fill {
    fill: none; stroke: var(--g-dark); stroke-width: 10;
    stroke-linecap: round;
    stroke-dasharray: 327;
    stroke-dashoffset: 327;
    transform: rotate(-90deg);
    transform-origin: center;
    transition: stroke-dashoffset 1s ease, stroke .4s;
}
.hsp-latency-inner {
    position: absolute; inset: 0;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
}
.hsp-latency-val  { font-size: 2.2rem; font-weight: 700; color: var(--g-dark); line-height: 1; }
.hsp-latency-unit { font-size: .75rem; color: var(--g-muted); }
.hsp-latency-grade { font-size: .9rem; font-weight: 600; color: var(--g-dark); }

.hsp-latency-scale {
    display: flex;
    gap: .4rem;
    margin-bottom: 1.25rem;
}
.hsp-lat-range {
    flex: 1;
    text-align: center;
    padding: .45rem .35rem;
    border-radius: 8px;
    font-size: .7rem;
    font-weight: 600;
    line-height: 1.4;
}
.hsp-lat-range small { font-weight: 400; }
.hsp-lat--great { background: rgba(45,158,101,.15); color: var(--g-dark); }
.hsp-lat--good  { background: rgba(45,158,101,.08); color: #2d6b4a; }
.hsp-lat--ok    { background: rgba(224,123,42,.1);  color: #7c3d00; }
.hsp-lat--bad   { background: rgba(192,57,43,.1);   color: var(--g-red); }

/* ── Mic test ─────────────────────────────────────────────────── */
#hsp-mic-canvas {
    display: block;
    width: 100%;
    height: 80px;
    border-radius: 10px;
    background: var(--g-bg);
    border: 1px solid var(--g-border);
    margin-bottom: 1rem;
}
.hsp-mic-meters {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}
.hsp-mic-meter-block { display: flex; flex-direction: column; gap: .3rem; }
.hsp-mic-meter-block label { font-size: .72rem; font-weight: 700; color: var(--g-muted); text-transform: uppercase; letter-spacing: .05em; }
.hsp-bar-wrap  { height: 6px; background: var(--g-border); border-radius: 999px; overflow: hidden; }
.hsp-bar-fill  { height: 100%; width: 0%; border-radius: 999px; background: var(--g-mid); transition: width .1s; }
.hsp-bar--green { background: var(--g-mid); }
.hsp-meter-val { font-family: 'DM Mono', monospace; font-size: .75rem; color: var(--g-dark); }

.hsp-mic-selector-wrap {
    display: flex;
    align-items: center;
    gap: .6rem;
    flex-wrap: wrap;
    padding: .65rem 1rem;
    background: var(--g-light);
    border: 1px solid var(--g-border);
    border-radius: 10px;
    margin-bottom: 1rem;
    font-size: .8rem;
    font-weight: 600;
    color: var(--g-dark);
}
.hsp-mic-select-wrap { position: relative; flex: 1; min-width: 160px; }
.hsp-mic-select {
    width: 100%; appearance: none; -webkit-appearance: none;
    padding: .4rem 2rem .4rem .7rem;
    border: 1px solid var(--g-border); border-radius: 8px;
    background: var(--g-white); font-family: 'DM Sans', sans-serif;
    font-size: .82rem; color: var(--g-text); cursor: pointer;
}
.hsp-mic-select:focus { outline: none; border-color: var(--g-mid); }
.hsp-mic-select-wrap svg { position: absolute; right: .6rem; top: 50%; transform: translateY(-50%); pointer-events: none; width: 10px !important; height: 10px !important; }
.hsp-btn-refresh {
    font-family: 'DM Sans', sans-serif; font-size: .78rem; font-weight: 600;
    color: var(--g-dark); background: var(--g-white);
    border: 1px solid var(--g-border); border-radius: 8px;
    padding: .35rem .75rem; cursor: pointer; transition: all .15s;
}
.hsp-btn-refresh:hover { background: var(--g-light); border-color: var(--g-mid); }

/* ── Results / HeadScore ──────────────────────────────────────── */
.hsp-score-wrap {
    display: flex; align-items: center; justify-content: center;
    position: relative; width: 150px; height: 150px;
    margin: 0 auto 1.5rem;
}
.hsp-score-ring { position: absolute; top: 0; left: 0; width: 150px !important; height: 150px !important; transform: rotate(-90deg); }
.hsp-ring-bg   { fill: none; stroke: var(--g-border); stroke-width: 10; }
.hsp-ring-fill {
    fill: none; stroke: var(--g-dark); stroke-width: 10;
    stroke-linecap: round; stroke-dasharray: 327; stroke-dashoffset: 327;
    transition: stroke-dashoffset 1.2s cubic-bezier(.22,.61,.36,1), stroke .4s;
}
.hsp-score-inner {
    position: absolute; inset: 0;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
}
.hsp-score-number { font-size: 2.4rem; font-weight: 700; color: var(--g-dark); line-height: 1; }
.hsp-score-label  { font-size: .72rem; color: var(--g-muted); }
.hsp-score-grade  { font-size: .85rem; font-weight: 600; margin-top: .15rem; }

.hsp-breakdown { margin-bottom: 1.25rem; }
.hsp-breakdown-row {
    display: grid; grid-template-columns: 140px 1fr 70px;
    align-items: center; gap: .75rem;
    padding: .5rem 0; border-bottom: 1px solid var(--g-border);
    font-size: .84rem;
}
.hsp-breakdown-row:last-child { border-bottom: none; }
.hsp-mini-bar  { height: 6px; background: var(--g-border); border-radius: 999px; overflow: hidden; }
.hsp-mini-fill { height: 100%; width: 0%; border-radius: 999px; background: var(--g-mid); transition: width 1s ease; }
.hsp-mini-fill--amber { background: var(--g-amber); }
.hsp-breakdown-row > span:last-child { font-family: 'DM Mono', monospace; font-size: .75rem; text-align: right; color: var(--g-dark); }

.hsp-toggle-btn {
    display: flex; align-items: center; justify-content: space-between;
    width: 100%; padding: .75rem 1rem; margin-bottom: 0;
    background: var(--g-light); border: 1px solid var(--g-border);
    border-radius: 10px; font-family: 'DM Sans', sans-serif;
    font-size: .875rem; font-weight: 600; color: var(--g-dark);
    cursor: pointer; transition: background .15s;
}
.hsp-toggle-btn:hover { background: #d6eddf; }
.hsp-toggle-btn svg { width: 12px !important; height: 8px !important; transition: transform .25s; flex-shrink: 0; }
.hsp-toggle-btn.is-open svg { transform: rotate(180deg); }

.hsp-analysis-panel { max-height: 0; overflow: hidden; transition: max-height .4s ease; }
.hsp-analysis-panel.is-open { max-height: 2000px; }

.hsp-recs {
    background: var(--g-light); border: 1px solid var(--g-border);
    border-radius: var(--radius); padding: 1.1rem 1.25rem; margin: 1rem 0;
}
.hsp-recs h3 { font-size: .9rem; font-weight: 700; margin: 0 0 .65rem; }
.hsp-recs ul  { margin: 0; padding-left: 1.1rem; display: flex; flex-direction: column; gap: .45rem; }
.hsp-recs li  { font-size: .84rem; line-height: 1.5; }

.hsp-tech-grid {
    display: grid; grid-template-columns: repeat(2,1fr);
    gap: .4rem .75rem; margin-bottom: 1rem;
    padding: 1rem 1.1rem;
    background: var(--g-bg); border: 1px solid var(--g-border);
    border-radius: var(--radius);
}
.hsp-tech-item { display: flex; justify-content: space-between; font-size: .8rem; }
.hsp-tech-item span:first-child { color: var(--g-muted); }
.hsp-tech-item span:last-child  { font-family: 'DM Mono', monospace; font-weight: 500; color: var(--g-dark); }

.hsp-result-actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1.25rem; }

/* ── Countdown overlay ────────────────────────────────────────── */
#hsp-countdown-overlay { pointer-events: all; }
#hsp-cd-message { white-space: pre-line; }

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 500px) {
    .hsp-screen { padding: 1.4rem 1.1rem; }
    .hsp-header { padding: .85rem 1.1rem; }
    .hsp-test-grid { grid-template-columns: repeat(2,1fr); }
    .hsp-card--full { grid-column: span 2; }
    .hsp-bass-grid  { grid-template-columns: repeat(2,1fr); }
    .hsp-latency-scale { flex-wrap: wrap; }
    .hsp-breakdown-row { grid-template-columns: 100px 1fr 55px; }
    .hsp-tech-grid { grid-template-columns: 1fr; }
    .hsp-balance-visual { flex-direction: column; }
}
