/* ラウドネス測定ツールのメインUIとリアルタイムモニター。
   画面構成およびダークグレーのベース（#2b2b2b系）は他言語版（/en/app/loudness-analyzer/）に合わせ、
   アクセント・メーター・グラフの色合いと下部の LIVE SPECTRUM・LEVEL パネルはオンラインマスタリング（/app/audio-mastering/）にそろえている。 */
:root {
    --la-bg: #2b2b2b;
    /* 明るいグレー（--la-bg）と暗いグレー（panel / deep）の差を広げ、補助文字も明るくして読みやすくした */
    --la-bg-head: #1a1a1a;
    --la-bg-panel: #1c1c1c;
    --la-bg-deep: #141414;
    --la-border: #4a4a4a;
    --la-border-soft: #3e3e3e;
    --la-ink: #eef2f6;
    --la-sub: #b4bec8;
    --la-muted: #929daa;
    --cs-blue: #12aee8;
    --cs-blue-d: #0b9bd3;
    --cs-yellow: #f5c518;
    --cs-orange: #ff8a1f;
    --cs-red: #e5484d;
    --cs-green: #2f9e6e;
    --cs-green-text: #4ad295;
    --cs-warn-text: #ffb347;
    --cs-red-text: #ff6b70;
}

[hidden] {
    display: none !important;
}

/* --- Main Analyzer Wrapper (Dark gray base + audio-mastering accents) --- */
.analyzer-wrapper {
    background-color: var(--la-bg);
    color: var(--la-ink);
    border: 1px solid var(--la-border);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.22);
    /* PC 表示ではメインツールだけ外枠 1300px 相当（中身 1260px）まで左右に広げる。
       親 .container（max-width 1200px）は広告・関連ツールと共通なのでそのままにし、ここで左右へはみ出させる。
       画面幅 1240px 以下では 0、1340px 以上で最大 50px ずつ広がる。 */
    margin-inline: calc(-1 * clamp(0px, (100vw - 1240px) / 2, 50px));
}

.analyzer-header {
    background: var(--la-bg-head);
    padding: 15px 25px;
    border-bottom: 1px solid var(--la-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.analyzer-title {
    font-weight: 800;
    font-size: 1.1rem;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 10px;
}

.analyzer-title i {
    color: var(--cs-blue);
}

.analyzer-brand {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--la-sub);
}

.pro-badge {
    background: rgba(18, 174, 232, 0.18);
    color: #5fd2fa;
    border: 1px solid rgba(18, 174, 232, 0.45);
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.5px;
}

/* Drop Zone */
.drop-zone {
    padding: 44px 30px;
    background: #252525;
    border: 2px dashed #484848;
    text-align: center;
    transition: border-color 0.25s, background-color 0.25s, box-shadow 0.25s;
    cursor: pointer;
    position: relative;
}

.drop-zone:hover,
.drop-zone.dragover {
    background: #2a2f34;
    border-color: var(--cs-blue);
    box-shadow: inset 0 0 24px rgba(18, 174, 232, 0.14);
}

.drop-icon {
    font-size: 3rem;
    color: var(--la-muted);
    margin-bottom: 14px;
    transition: color 0.25s, transform 0.25s;
}

.drop-zone:hover .drop-icon,
.drop-zone.dragover .drop-icon {
    color: var(--cs-blue);
    transform: scale(1.08);
}

.drop-heading {
    color: #fff;
    font-weight: 800;
    margin-bottom: 10px;
}

.drop-sub {
    color: var(--la-sub);
    font-size: 0.9rem;
}

.drop-formats {
    color: var(--la-muted);
    font-size: 0.8rem;
    margin-top: 10px;
}

#fileInput {
    display: none;
}

/* Dashboard Structure */
.dashboard {
    min-height: 400px;
    background: var(--la-bg);
}

.dashboard-top-grid {
    display: grid;
    grid-template-columns: 2fr 1.2fr;
    border-bottom: 1px solid var(--la-border);
}

/* Left Panel: Meters */
.meter-panel {
    padding: 18px;
    border-right: 1px solid var(--la-border);
    background: var(--la-bg);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.big-meter-box {
    background: var(--la-bg-deep);
    border-radius: 12px;
    padding: 16px 20px 14px;
    text-align: center;
    position: relative;
    border: 1px solid var(--la-border-soft);
    box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.45);
    flex: 1.2;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.meter-label {
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--la-sub);
    text-transform: uppercase;
    letter-spacing: 1.2px;
    margin-bottom: 8px;
}

.meter-value-wrap {
    display: flex;
    justify-content: center;
    align-items: baseline;
    gap: 8px;
}

.meter-value-main {
    font-family: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 5rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.05;
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.08);
    font-variant-numeric: tabular-nums;
}

.meter-unit {
    font-size: 1.15rem;
    color: var(--la-muted);
    font-weight: 700;
}

.lufs-bar {
    width: 56%;
    height: 6px;
    background: #3a3a3a;
    margin: 10px auto 2px auto;
    border-radius: 999px;
    position: relative;
    overflow: hidden;
}

.lufs-bar-fill {
    width: 0%;
    height: 100%;
    background: var(--cs-blue);
    border-radius: 999px;
    transition: width 0.5s, background-color 0.3s;
}

.sub-meters {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    flex: 1;
}

.mini-meter-box {
    background: var(--la-bg-panel);
    border-radius: 10px;
    padding: 11px 15px 0 15px;
    text-align: center;
    border: 1px solid var(--la-border-soft);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
    min-width: 0;
}

/* L/R Split Value Styles */
.lr-val-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0;
    margin-top: 2px;
    margin-bottom: 8px;
}

.lr-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 14px;
    flex: 1;
    min-width: 0;
}

.lr-group:first-child {
    border-right: 1px solid var(--la-border);
}

.ch-label {
    font-size: 0.75rem;
    color: var(--la-muted);
    font-weight: 800;
    margin-bottom: 2px;
}

.mini-val-sm {
    font-family: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--la-ink);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

/* Peak Messages Area */
.peak-msg {
    margin: 0 -15px;
    padding: 7px 10px;
    background: rgba(0, 0, 0, 0.3);
    border-top: 1px solid var(--la-border-soft);
    font-size: 0.74rem;
    font-weight: 700;
    color: var(--la-sub);
    min-height: 36px;
    line-height: 1.45;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.peak-location {
    font-size: 0.72rem;
    color: var(--cs-blue);
    margin-top: 5px;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
    font-family: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

.peak-location:hover {
    color: #5fd2fa;
}

/* Right Panel: Analysis */
.analysis-panel {
    padding: 18px;
    background: var(--la-bg-panel);
    overflow-y: auto;
}

.panel-heading {
    font-size: 0.95rem;
    font-weight: 800;
    margin-bottom: 10px;
    color: #c5cfd8;
    display: flex;
    align-items: center;
    gap: 8px;
}

.panel-heading i {
    color: var(--cs-blue);
}

.platform-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.platform-item {
    background: var(--la-bg);
    padding: 10px 14px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border: 1px solid #474747;
    transition: border-color 0.2s;
}

.pf-led {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex: none;
    background: #666;
}

.platform-item.pass .pf-led {
    background: var(--cs-green-text);
    box-shadow: 0 0 6px rgba(74, 210, 149, 0.55);
}

.platform-item.warn .pf-led {
    background: var(--cs-orange);
    box-shadow: 0 0 6px rgba(255, 138, 31, 0.55);
}

.platform-item.fail .pf-led {
    background: var(--cs-red);
    box-shadow: 0 0 6px rgba(229, 72, 77, 0.65);
}

.pf-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.pf-name {
    font-weight: 800;
    font-size: 0.92rem;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.pf-name i {
    color: var(--la-sub);
}

.pf-status {
    font-size: 0.85rem;
    font-weight: 700;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.status-badge {
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 800;
    margin-bottom: 2px;
}

.status-pass {
    background: rgba(47, 158, 110, 0.22);
    color: var(--cs-green-text);
}

.status-fail {
    background: rgba(229, 72, 77, 0.22);
    color: var(--cs-red-text);
}

.status-warn {
    background: rgba(255, 138, 31, 0.22);
    color: var(--cs-warn-text);
}

.pf-meter-wrap {
    width: 100%;
    height: 8px;
    background: #474747;
    border-radius: 4px;
    display: flex;
    position: relative;
    overflow: visible;
}

.pf-seg {
    height: 100%;
}

.pf-seg-blue {
    background: var(--cs-blue);
    border-top-left-radius: 4px;
    border-bottom-left-radius: 4px;
}

.pf-seg-green {
    background: var(--cs-green);
}

.pf-seg-yellow {
    background: var(--cs-yellow);
}

.pf-seg-red {
    background: var(--cs-red);
    border-top-right-radius: 4px;
    border-bottom-right-radius: 4px;
}

.pf-needle {
    position: absolute;
    top: -4px;
    width: 2.5px;
    height: 16px;
    margin-left: -1.25px;
    border-radius: 2px;
    background: #fff;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.85);
    z-index: 2;
    transition: left 0.5s ease;
}

.gain-suggestion {
    font-size: 0.75rem;
    color: var(--la-sub);
    font-family: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

.gain-up {
    color: #5fd2fa;
}

.gain-down {
    color: var(--cs-red-text);
}

.platform-footnote {
    margin-top: 10px;
    font-size: 0.78rem;
    color: var(--la-muted);
    text-align: right;
    line-height: 1.5;
}

/* Waveform (Full Width, Dark gray base + audio-mastering signal colors) */
.waveform-container {
    width: 100%;
    height: 220px;
    background: #161616;
    margin-top: 0;
    position: relative;
    overflow: visible;
    cursor: pointer;
}

canvas#waveCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* Peak Marker */
.peak-marker {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1.5px;
    background: var(--cs-blue);
    box-shadow: 0 0 5px rgba(18, 174, 232, 0.75);
    pointer-events: none;
    display: none;
    z-index: 5;
}

.peak-marker .peak-label {
    position: absolute;
    /* ラベルの四角の中央に線が来るように置く（波形の端では app.js が内側へずらす） */
    left: 50%;
    transform: translateX(-50%);
    background: var(--cs-blue);
    color: #fff;
    font-size: 0.6rem;
    font-weight: 800;
    letter-spacing: .03em;
    padding: 1px 5px;
    border-radius: 3px;
    white-space: nowrap;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}

/* TRUE PEAK：青の実線、ラベルは段の上端 */
.peak-marker.is-tp .peak-label {
    top: 3px;
}

/* SAMPLE PEAK：黄の点線、ラベルは段の下端（同じ位置でも TRUE PEAK と重ならない） */
.peak-marker.is-sp {
    background: repeating-linear-gradient(to bottom, var(--cs-yellow) 0 4px, transparent 4px 7px);
    box-shadow: none;
    z-index: 4;
}

.peak-marker.is-sp .peak-label {
    bottom: 3px;
    background: var(--cs-yellow);
    color: #1a1a1a;
}

/* Seek Bar */
.seek-bar {
    position: absolute;
    top: 35px;
    bottom: 0;
    width: 2px;
    background: #ffffff;
    z-index: 6;
    display: none;
    pointer-events: none;
    box-shadow: 0 0 5px rgba(255, 255, 255, 0.8);
}

/* Controls Area */
.controls-area {
    background: var(--la-bg-head);
    padding: 16px 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-top: 1px solid var(--la-border-soft);
    gap: 18px;
    flex-wrap: wrap;
}

.btn-play {
    background: var(--cs-blue);
    color: #fff;
    border: none;
    padding: 10px 28px;
    border-radius: 30px;
    font-weight: 700;
    font-size: 0.98rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    transition: background-color 0.2s, transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 12px rgba(18, 174, 232, 0.32);
}

.btn-play:hover {
    background: var(--cs-blue-d);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(18, 174, 232, 0.42);
}

.btn-play:active {
    transform: translateY(0);
}

.btn-play.playing {
    background: var(--cs-red);
    box-shadow: 0 4px 12px rgba(229, 72, 77, 0.32);
}

.btn-play.playing:hover {
    background: #d1383d;
}

.btn-text-mobile {
    display: none;
}

.silent-mode-hint {
    display: none;
}

.time-display {
    font-family: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    color: #fff;
    font-size: 1.08rem;
    font-weight: 700;
    min-width: 90px;
    font-variant-numeric: tabular-nums;
}

.btn-reset {
    background: transparent;
    color: var(--la-sub);
    border: 1px solid #525252;
    padding: 7px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s, background-color 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-reset:hover {
    color: #fff;
    border-color: var(--cs-blue);
    background: rgba(18, 174, 232, 0.12);
}

/* Loading Overlay */
.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(20, 20, 20, 0.88);
    z-index: 10;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.loading-text {
    color: #fff;
    font-weight: 700;
    font-size: 0.95rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #444;
    border-top: 4px solid var(--cs-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 14px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===== LIVE SPECTRUM & LEVEL (メインツールと同じダークグレーベース + audio-mastering グラフ色) ===== */
.la-monitor-shell {
    margin-top: 18px;
    /* メインツール（.analyzer-wrapper）と同じく PC 表示で外枠 1300px 相当まで左右に広げる */
    margin-inline: calc(-1 * clamp(0px, (100vw - 1240px) / 2, 50px));
    padding: 16px;
    border: 1px solid var(--la-border);
    border-radius: 16px;
    background: var(--la-bg);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.18);
    color: var(--la-ink);
    min-width: 0;
}

.cs-monitor {
    display: grid;
    /* STEREO FIELD は 0.51fr。最小 176px は見出し「STEREO FIELD」が1行に収まる幅。合計 2.2fr のうち残りを LIVE SPECTRUM に回す */
    grid-template-columns: minmax(0, 1.69fr) minmax(176px, 0.51fr) 270px;
    gap: 14px;
}

.cs-panel {
    border: 1px solid var(--la-border-soft);
    border-radius: 12px;
    background: var(--la-bg-panel);
    padding: 12px 14px 10px;
    min-width: 0;
}

.cs-panel-head {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    color: #fff;
}

.cs-panel-head strong {
    white-space: nowrap;
    font-weight: 800;
    letter-spacing: .02em;
}

.cs-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--cs-blue);
    box-shadow: 0 0 8px rgba(18, 174, 232, 0.55);
    flex: none;
}

.cs-spec-wrap,
.cs-imager-wrap {
    position: relative;
    height: 200px;
    margin-top: 6px;
}

.cs-spec-wrap canvas,
.cs-imager-wrap canvas,
.lv-wrap canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.cs-level .cs-panel-head {
    gap: 8px;
}

.lv-reset {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    margin-left: auto;
    border: 1px solid #484848;
    border-radius: 7px;
    background: var(--la-bg);
    color: var(--la-sub);
    font-size: 12px;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s, background-color 0.2s;
}

.lv-reset:hover {
    border-color: var(--cs-blue);
    color: var(--cs-blue);
    background: rgba(18, 174, 232, 0.12);
}

.lv-body {
    display: flex;
    gap: 12px;
    height: 200px;
    margin-top: 6px;
}

.lv-wrap {
    position: relative;
    flex: 0 0 118px;
}

.lv-side {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
    padding-left: 12px;
    border-left: 1px solid var(--la-border-soft);
}

.lv-lufs {
    display: flex;
    flex: 1;
    flex-direction: column;
    justify-content: space-around;
    margin: 0;
}

.lv-lufs dt {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .04em;
    color: var(--la-sub);
}

.lv-lufs dd {
    display: flex;
    align-items: baseline;
    gap: 5px;
    margin: 0;
    line-height: 1.15;
}

.lv-lufs output {
    /* SHORT-TERM・INTEGRATED も PEAK MAX と同じ 17px にそろえる（以前は 27px） */
    font: 700 17px/1.1 ui-monospace, SFMono-Regular, Menlo, monospace;
    color: #fff;
    font-variant-numeric: tabular-nums;
    letter-spacing: -.03em;
}

.lv-lufs small {
    font-size: 11px;
    font-weight: 700;
    color: var(--la-sub);
}

.lv-lufs .is-over output {
    color: var(--cs-red-text);
}

.lv-time {
    margin: 0;
    font-size: 11px;
    color: var(--la-sub);
    font-variant-numeric: tabular-nums;
}

/* --- Responsive --- */
@media (max-width: 900px) {
    .dashboard-top-grid {
        grid-template-columns: 1fr;
    }

    .meter-panel {
        border-right: none;
        border-bottom: 1px solid var(--la-border);
    }
}

@media (max-width: 980px) {
    .cs-monitor {
        grid-template-columns: minmax(0, 1fr) 270px;
    }

    .cs-monitor > .cs-spectrum {
        grid-column: 1 / -1;
    }
}

@media (max-width: 680px) {
    .cs-monitor {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 640px) {
    .la-monitor-shell {
        padding: 12px;
        border-radius: 14px;
    }

    .cs-spec-wrap {
        height: 150px;
    }

    .cs-imager-wrap {
        height: 185px;
    }

    .lv-body {
        height: 190px;
    }
}

@media (max-width: 600px) {
    .drop-zone {
        padding: 32px 18px;
    }

    .meter-value-main {
        font-size: 3.5rem;
    }

    .mini-val-sm {
        font-size: 1.2rem;
    }

    .lr-group {
        padding: 0 5px;
    }

    .ch-label {
        font-size: 0.65rem;
    }

    .peak-location {
        font-size: 0.62rem;
    }

    .peak-msg {
        font-size: 0.68rem;
        padding: 8px 5px;
    }

    .meter-label {
        font-size: 0.75rem;
    }

    .sub-meters {
        gap: 10px;
    }

    .meter-panel {
        padding: 15px;
    }

    .analysis-panel {
        padding: 16px 15px;
    }

    .big-meter-box {
        padding: 20px 10px;
    }

    .analyzer-header .analyzer-brand {
        display: none;
    }

    .btn-play .btn-text-desktop {
        display: none;
    }

    .btn-play .btn-text-mobile {
        display: inline !important;
    }

    .btn-reset .btn-text {
        display: none;
    }

    .silent-mode-hint {
        display: block;
        font-size: 0.68rem;
        color: var(--la-sub);
        margin-top: 8px;
        width: 100%;
        text-align: center;
        line-height: 1.35;
    }
}
