/* ============================================================
   오디오 레벨 모니터 — 마이크 입력 점검 도구
   - 검은 배경 + 노란 강조 (프롬프터와 동일 톤)
   - 레벨 미터 + 스펙트럼 + 파형
   ============================================================ */

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    min-height: 100%;
}

.audio-body {
    background: #000;
    color: #fff;
    font-family: 'NanumSquare', 'Pretendard', 'Helvetica Neue', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
}

/* === 코너 버튼 === */
.audio-corner-btn {
    position: fixed;
    z-index: 50;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.95rem;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    text-decoration: none;
    border-radius: 999px;
    backdrop-filter: blur(8px);
    transition: opacity 0.2s, color 0.2s, background 0.2s, border-color 0.2s;
}
.audio-corner-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.4);
}
.audio-corner-btn--top-left { top: 18px; left: 18px; }
.audio-corner-btn--top-right { top: 18px; right: 18px; }

.audio-brand {
    font-family: 'Space Grotesk', sans-serif;
}

/* === 메인 스테이지 === */
.audio-stage {
    max-width: 1080px;
    margin: 0 auto;
    padding: clamp(5rem, 10vw, 7rem) clamp(1rem, 4vw, 3rem) 4rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.audio-header {
    text-align: center;
}

.audio-eyebrow {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.22em;
    color: rgba(255, 255, 0, 0.65);
    margin-bottom: 1rem;
}

.audio-title {
    font-size: clamp(1.8rem, 4vw, 2.8rem);
    font-weight: 900;
    letter-spacing: -0.025em;
    color: #fff;
    margin: 0 0 0.5rem;
}

.audio-sub {
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.45);
    margin: 0;
    letter-spacing: -0.005em;
}

/* === 컨트롤 === */
.audio-controls {
    display: flex;
    gap: 0.7rem;
    justify-content: center;
    flex-wrap: wrap;
}

.audio-select {
    flex: 1;
    min-width: 240px;
    max-width: 480px;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: rgba(255, 255, 255, 0.85);
    font-family: inherit;
    font-size: 0.88rem;
    border-radius: 6px;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}
.audio-select:hover, .audio-select:focus {
    border-color: rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.06);
}
.audio-select option {
    background: #111;
    color: #fff;
}

.audio-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.6rem;
    border: 1px solid rgba(255, 255, 0, 0.4);
    background: rgba(255, 255, 0, 0.1);
    color: rgba(255, 255, 0, 0.95);
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}
.audio-toggle-btn:hover {
    background: rgba(255, 255, 0, 0.2);
    border-color: rgba(255, 255, 0, 0.7);
    color: #fff;
}
.audio-toggle-btn.is-running {
    background: rgba(248, 113, 113, 0.12);
    border-color: rgba(248, 113, 113, 0.45);
    color: #f87171;
}

.audio-status {
    text-align: center;
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.4);
    margin: -1rem 0 0;
    letter-spacing: -0.005em;
    min-height: 1.2em;
}
.audio-status.is-error {
    color: #f87171;
}
.audio-status.is-running {
    color: #4ade80;
}

/* === 레벨 미터 === */
.audio-meter-block {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
}

.audio-meter-scale {
    position: relative;
    height: 1.2em;
    font-family: 'Space Grotesk', monospace;
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.35);
    letter-spacing: 0.1em;
}
/* dBFS 눈금 (pct = (db + 60) / 60 * 100): -60 0%, -40 33.3%, -20 66.7%, -12 80%, -6 90%, 0 100% */
.audio-meter-scale span {
    position: absolute;
    transform: translateX(-50%);
    top: 0;
}
.audio-meter-scale span:nth-child(1) { left: 0%;    transform: none; }
.audio-meter-scale span:nth-child(2) { left: 33.3%; }
.audio-meter-scale span:nth-child(3) { left: 66.7%; }
.audio-meter-scale span:nth-child(4) { left: 80%;   }
.audio-meter-scale span:nth-child(5) { left: 90%;   }
.audio-meter-scale span:nth-child(6) { right: 0;    transform: none; }

.audio-meter {
    position: relative;
    width: 100%;
    height: 36px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    overflow: hidden;
}

.audio-meter-fill {
    position: absolute;
    inset: 0;
    width: 0%;
    background: linear-gradient(
        90deg,
        #4ade80 0%,
        #4ade80 50%,
        #facc15 75%,
        #fb923c 88%,
        #f87171 95%,
        #ef4444 100%
    );
    transition: width 60ms linear;
    border-radius: 5px 0 0 5px;
}

/* 피크 홀드 라인 */
.audio-meter-peak {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0%;
    width: 2px;
    background: rgba(255, 255, 255, 0.85);
    box-shadow: 0 0 6px rgba(255, 255, 255, 0.5);
    transition: left 60ms linear;
    pointer-events: none;
    opacity: 0;
}
.audio-meter-peak.is-active { opacity: 1; }

/* 권장 범위 점선 표시 (-18 ~ -12 dBFS = 70% ~ 80%) */
.audio-meter-target {
    position: absolute;
    top: -4px;
    bottom: -4px;
    left: 70%;
    width: 10%;
    border-left: 1px dashed rgba(255, 255, 0, 0.35);
    border-right: 1px dashed rgba(255, 255, 0, 0.35);
    pointer-events: none;
}

/* === 수치 표시 === */
.audio-readouts {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.audio-readout {
    flex: 1;
    min-width: 120px;
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
    padding: 0.6rem 0.9rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 6px;
}

.audio-readout-label {
    font-family: 'Space Grotesk', monospace;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    color: rgba(255, 255, 255, 0.4);
}

.audio-readout-value {
    font-family: 'Space Grotesk', monospace;
    font-size: 1.4rem;
    font-weight: 700;
    color: #fff;
    margin-left: auto;
    font-variant-numeric: tabular-nums;
}

.audio-readout-unit {
    font-family: 'Space Grotesk', monospace;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.4);
}

.audio-readout--clip {
    flex: 0 0 auto;
    min-width: 110px;
    justify-content: space-between;
}

.audio-clip-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: background 0.1s, box-shadow 0.1s, border-color 0.1s;
    margin-left: auto;
}
.audio-clip-dot.is-active {
    background: #ef4444;
    border-color: #ef4444;
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.7);
}

.audio-hint {
    margin: 0;
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.35);
    letter-spacing: 0.05em;
}

/* === 스펙트럼 / 파형 === */
.audio-viz {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.audio-viz-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

.audio-viz-label {
    font-family: 'Space Grotesk', monospace;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.22em;
    color: rgba(255, 255, 255, 0.4);
}

.audio-viz-card canvas {
    width: 100%;
    height: 180px;
    display: block;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 6px;
}

/* === 단축키 안내 === */
.audio-shortcuts {
    text-align: center;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    color: rgba(255, 255, 255, 0.3);
    text-transform: uppercase;
    margin-top: 1rem;
}

.audio-shortcuts kbd {
    display: inline-block;
    padding: 0.18rem 0.5rem;
    margin: 0 2px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 4px;
    font-family: 'Space Grotesk', monospace;
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.55);
    letter-spacing: 0.05em;
}

/* === 반응형 === */
@media (max-width: 768px) {
    .audio-corner-btn {
        padding: 0.4rem 0.7rem;
        font-size: 0.65rem;
    }
    .audio-corner-btn span { display: none; }
    .audio-controls {
        flex-direction: column;
        align-items: stretch;
    }
    .audio-select {
        max-width: none;
    }
    .audio-viz {
        grid-template-columns: 1fr;
    }
    .audio-readouts {
        gap: 0.7rem;
    }
    .audio-readout {
        min-width: 100px;
        padding: 0.5rem 0.7rem;
    }
    .audio-readout-value {
        font-size: 1.15rem;
    }
}
