:root {
    color-scheme: dark;
    --bg: #0b1220;
    --bg-alt: #0f172a;
    --panel: #11182b;
    --panel-strong: #16203a;
    --text: #e5e7eb;
    --muted: #94a3b8;
    --border: #1f2a3d;
    --accent: #38bdf8;
    --accent-strong: #22d3ee;
    --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
    --radius: 14px;
    --font-sans: "Segoe UI", "Hiragino Sans", "Noto Sans JP", "Yu Gothic", "Helvetica Neue", Arial, sans-serif;
    --font-mono: "Cascadia Code", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
    --space-1: 8px;
    --space-2: 12px;
    --space-3: 16px;
    --space-4: 24px;
    --space-5: 32px;
    --glass: rgba(255, 255, 255, 0.03);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: radial-gradient(120% 120% at 20% 20%, rgba(56, 189, 248, 0.08), transparent 45%), radial-gradient(110% 110% at 80% 10%, rgba(244, 114, 182, 0.06), transparent 50%), linear-gradient(135deg, #0a0f1c, #0b1220 45%, #0f172a);
    color: var(--text);
    font-family: var(--font-sans);
    line-height: 1.6;
    letter-spacing: 0.01em;
}

.page-shell {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--space-5) var(--space-3) var(--space-5);
}

.hero {
    display: flex;
    justify-content: space-between;
    gap: var(--space-4);
    align-items: center;
    margin-bottom: var(--space-4);
}

.title-stack h1 {
    margin: 6px 0 6px;
    font-size: 34px;
    letter-spacing: 0.02em;
}

.lede {
    margin: 0 0 var(--space-2);
    color: var(--muted);
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    background: var(--glass);
}

.eyebrow.small {
    padding: 4px 10px;
    font-size: 11px;
}

.hero-orb {
    position: relative;
    width: 220px;
    height: 220px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(56, 189, 248, 0.25), rgba(34, 211, 238, 0.05)), linear-gradient(135deg, rgba(56, 189, 248, 0.15), rgba(37, 99, 235, 0.1));
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    display: grid;
    place-items: center;
    overflow: hidden;
}

.orb-glow {
    position: absolute;
    inset: 10%;
    background: radial-gradient(circle, rgba(34, 211, 238, 0.35), transparent 60%);
    filter: blur(24px);
}

.orb-title {
    position: relative;
    font-weight: 700;
    font-size: 42px;
    letter-spacing: 0.12em;
}

.orb-sub {
    position: absolute;
    bottom: 22px;
    right: 28px;
    text-align: right;
    font-size: 12px;
    color: var(--muted);
    line-height: 1.3;
}

.pill-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.chip {
    display: inline-flex;
    align-items: center;
    padding: 7px 12px;
    border-radius: 999px;
    border: 1px solid rgba(56, 189, 248, 0.4);
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.2), rgba(34, 211, 238, 0.25));
    color: #e6faff;
    font-weight: 600;
    font-size: 13px;
}

.panel {
    background: linear-gradient(140deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-3);
    box-shadow: var(--shadow);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    gap: var(--space-3);
    align-items: center;
    margin-bottom: var(--space-2);
}

.param-line {
    display: flex;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 10px;
    background: var(--panel);
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 13px;
}

.control-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: var(--space-2);
    align-items: stretch;
}

.file-drop {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    align-items: flex-start;
    border: 1px dashed rgba(56, 189, 248, 0.4);
    border-radius: var(--radius);
    padding: var(--space-3);
    background: rgba(255, 255, 255, 0.02);
    cursor: pointer;
    transition: border-color 0.2s ease, transform 0.1s ease;
}

.file-drop:hover {
    border-color: rgba(56, 189, 248, 0.9);
    transform: translateY(-1px);
}

.file-drop.dragover {
    border-color: rgba(239, 68, 68, 0.8);
    background: rgba(239, 68, 68, 0.08);
    box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.2);
}

.file-drop input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.file-label {
    font-size: 18px;
    font-weight: 700;
}

.file-chip {
    padding: 8px 12px;
    border-radius: 10px;
    background: var(--panel);
    color: var(--muted);
    max-width: 100%;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
    border: 1px solid var(--border);
}

.tiny {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 11px;
}

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

.action-stack {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: var(--space-3);
    border-radius: var(--radius);
    background: var(--panel);
    border: 1px solid var(--border);
}

.player-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: var(--space-3);
    border-radius: var(--radius);
    background: var(--panel-strong);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.player-section {
    margin: var(--space-3) 0 var(--space-4);
}

.player-section .player-card {
    max-width: 980px;
    margin: 0 auto;
}

.player-head {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.player-title {
    font-weight: 700;
    letter-spacing: 0.01em;
}

.player-controls {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 10px;
    align-items: center;
}

.player-controls input[type="range"],
.playback-inline input[type="range"] {
    width: 100%;
    appearance: none;
    height: 6px;
    border-radius: 999px;
    background: linear-gradient(90deg, rgba(56,189,248,0.5), rgba(56,189,248,0.15));
    outline: none;
}

.player-controls input[type="range"]::-webkit-slider-thumb,
.playback-inline input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #22d3ee;
    box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.25);
    cursor: pointer;
}

.player-controls input[type="range"]::-moz-range-thumb,
.playback-inline input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #22d3ee;
    box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.25);
    border: none;
    cursor: pointer;
}

.time-label {
    font-family: var(--font-mono);
    color: var(--muted);
    font-size: 13px;
    white-space: nowrap;
}

.pill-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 18px;
    border-radius: 999px;
    border: 1px solid rgba(56, 189, 248, 0.6);
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.25), rgba(34, 211, 238, 0.3));
    color: #e6faff;
    font-weight: 700;
    letter-spacing: 0.01em;
    transition: transform 0.15s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    cursor: pointer;
}

.pill-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pill-button:hover:not(:disabled) {
    transform: translateY(-1px);
    border-color: rgba(34, 211, 238, 0.8);
    box-shadow: 0 8px 24px rgba(34, 211, 238, 0.24);
}

.pill-button.small {
    padding: 10px 14px;
    font-size: 14px;
}

.pill-button.ghost {
    background: transparent;
    border-color: var(--border);
    color: var(--text);
}

.pill-button.active {
    border-color: rgba(56, 189, 248, 0.8);
    box-shadow: 0 6px 16px rgba(56, 189, 248, 0.2);
}

.ghost-button {
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.02);
    color: var(--text);
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.ghost-button:hover {
    border-color: rgba(56, 189, 248, 0.6);
    background: rgba(255, 255, 255, 0.03);
}

.status-line {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    min-height: 26px;
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(56, 189, 248, 0.35);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.spinner.active {
    opacity: 1;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.hint-card {
    border: 1px solid var(--border);
    background: var(--panel);
    border-radius: var(--radius);
    padding: var(--space-3);
}

.hint-card ul {
    padding-left: 18px;
    margin: var(--space-2) 0 0;
    color: var(--muted);
}

.stage {
    margin-top: var(--space-4);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--panel-strong);
    padding: var(--space-3);
    box-shadow: var(--shadow);
}

.stage-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-2);
    flex-wrap: wrap;
    margin-bottom: var(--space-2);
}

.stage-right {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    min-width: 640px;
}

.playback-inline {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 10px;
    align-items: center;
    padding: 8px 12px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
}

.legend {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
}

.legend-swatch {
    width: 14px;
    height: 14px;
    border-radius: 4px;
    display: inline-block;
}

.legend-swatch.low {
    background: #0b3a6f;
}

.legend-swatch.mid {
    background: #6c5ce7;
}

.legend-swatch.high {
    background: #fca311;
}

.three-container {
    position: relative;
    width: 100%;
    height: min(70vh, 640px);
    border-radius: 12px;
    overflow: hidden;
    background: radial-gradient(circle at 20% 20%, rgba(56, 189, 248, 0.06), transparent 45%), var(--bg-alt);
    border: 1px solid var(--border);
}

.stage-grid {
    display: grid;
    grid-template-columns: 7fr 3fr;
    gap: var(--space-3);
    align-items: start;
}

.three-wrapper {
    width: 100%;
}

.spectro-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-3);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    min-height: 360px;
}

.spectro-head h4 {
    margin: 6px 0 0;
    letter-spacing: 0.01em;
}

.spectro-controls {
    display: inline-flex;
    gap: 8px;
    margin-bottom: 6px;
}

#spectrogramCanvas {
    flex: 1;
    width: 100%;
    height: 100%;
    min-height: 280px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: linear-gradient(135deg, rgba(255,255,255,0.02), rgba(255,255,255,0.05));
}

canvas {
    display: block;
}

@media (max-width: 780px) {
    .hero {
        flex-direction: column;
        align-items: flex-start;
    }

    .panel-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .three-container {
        height: 360px;
    }

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

    .stage-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .stage-right {
        width: 100%;
        min-width: 0;
        align-items: flex-start;
    }

    .playback-inline {
        width: 100%;
        grid-template-columns: auto 1fr auto;
    }
}
