/* ========================================
   TEST MICRO
   Design: Clean page + dark audio console
   ======================================== */

/* CSS Variables */
:root {
    --color-bg: #ffffff;
    --color-bg-alt: #f8fafc;
    --color-bg-subtle: #f1f5f9;
    --color-text: #1e293b;
    --color-text-muted: #64748b;
    --color-text-light: #94a3b8;
    --color-primary: #4f46e5;
    --color-primary-hover: #4338ca;
    --color-primary-light: #e0e7ff;
    --color-border: #e2e8f0;
    --color-border-strong: #cbd5e1;
    --color-success: #10b981;
    --color-warning: #f59e0b;
    --color-danger: #ef4444;
    --color-danger-light: #fee2e2;

    /* Console */
    --console-bg: #0b1020;
    --console-surface: rgba(255, 255, 255, 0.04);
    --console-surface-hover: rgba(255, 255, 255, 0.08);
    --console-border: rgba(255, 255, 255, 0.08);
    --console-text: #e2e8f0;
    --console-muted: #94a3b8;
    --signal-green: #22c55e;
    --signal-yellow: #eab308;
    --signal-red: #ef4444;
    --accent-cyan: #22d3ee;
    --accent-violet: #a78bfa;

    --font-main: 'DM Sans', system-ui, -apple-system, sans-serif;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 20px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --shadow-console: 0 30px 60px -20px rgba(15, 23, 42, 0.45), 0 12px 24px -12px rgba(79, 70, 229, 0.25);
    --transition: 150ms ease;
}

/* Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Base */
html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-main);
    color: var(--color-text);
    background: var(--color-bg-alt);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

[hidden] {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Container */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ========================================
   HEADER
   ======================================== */
.header {
    background: linear-gradient(135deg, var(--color-bg) 0%, var(--color-bg-alt) 100%);
    border-bottom: 1px solid var(--color-border);
    padding: 32px 0 24px;
    text-align: center;
}

.header.header-standalone {
    padding: 44px 0 28px;
    background: linear-gradient(135deg, var(--color-bg) 0%, var(--color-primary-light) 100%);
}

.header h1 {
    font-size: clamp(1.75rem, 4vw, 2.4rem);
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 12px;
    letter-spacing: -0.02em;
}

.header h1 .highlight {
    color: var(--color-primary);
    font-weight: 600;
}

.header .subtitle {
    font-size: 1.1rem;
    color: var(--color-text-muted);
    max-width: 680px;
    margin: 0 auto;
}

.header-badges {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px 16px;
    margin-top: 18px;
    list-style: none;
}

.header-badges li {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--color-text);
}

.header-badges svg {
    color: var(--color-success);
    flex-shrink: 0;
}

/* ========================================
   MAIN APP
   ======================================== */
.main {
    padding: 28px 0 40px;
}

/* ========================================
   BUTTONS
   ======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    font-family: var(--font-main);
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition);
    border: none;
    white-space: nowrap;
    text-decoration: none;
}

.btn svg {
    flex-shrink: 0;
}

.btn-primary {
    background: var(--color-primary);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    background: var(--color-primary-hover);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--color-bg);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.btn-secondary:hover {
    background: var(--color-bg-alt);
    border-color: var(--color-border-strong);
}

/* ========================================
   MIC CONSOLE
   ======================================== */
.mic-app {
    --level: 0;
    position: relative;
    max-width: 960px;
    margin: 0 auto;
    padding: 22px;
    background:
        radial-gradient(120% 80% at 50% -10%, rgba(99, 102, 241, 0.22) 0%, rgba(11, 16, 32, 0) 60%),
        var(--console-bg);
    color: var(--console-text);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-console);
    border: 1px solid rgba(99, 102, 241, 0.25);
}

/* Top bar */
.mic-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    border-radius: 999px;
    background: var(--console-surface);
    border: 1px solid var(--console-border);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--console-text);
}

.status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--console-muted);
    flex-shrink: 0;
}

.status-pill[data-tone="info"] .status-dot {
    background: var(--accent-cyan);
    animation: pulseDot 1.4s ease-in-out infinite;
}

.status-pill[data-tone="ok"] .status-dot {
    background: var(--signal-green);
    box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.2);
}

.status-pill[data-tone="warn"] .status-dot {
    background: var(--signal-yellow);
    box-shadow: 0 0 0 4px rgba(234, 179, 8, 0.2);
}

.status-pill[data-tone="error"] .status-dot {
    background: var(--signal-red);
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.2);
}

@keyframes pulseDot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

.device-picker {
    position: relative;
    display: flex;
    align-items: center;
    flex: 0 1 380px;
    min-width: 0;
}

.device-picker > svg {
    position: absolute;
    left: 12px;
    color: var(--console-muted);
    pointer-events: none;
}

.device-picker select {
    width: 100%;
    appearance: none;
    -webkit-appearance: none;
    padding: 9px 36px 9px 36px;
    font-family: var(--font-main);
    font-size: 0.9rem;
    color: var(--console-text);
    background: var(--console-surface)
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E")
        no-repeat right 12px center;
    border: 1px solid var(--console-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    text-overflow: ellipsis;
    transition: border-color var(--transition), background-color var(--transition);
}

.device-picker select:hover:not(:disabled) {
    border-color: rgba(255, 255, 255, 0.2);
}

.device-picker select:focus-visible {
    outline: 2px solid var(--accent-violet);
    outline-offset: 2px;
}

.device-picker select:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.device-picker select option {
    color: var(--color-text);
    background: var(--color-bg);
}

/* Stage (visualisation) */
.mic-stage {
    position: relative;
    height: 230px;
    border-radius: 14px;
    overflow: hidden;
    background:
        linear-gradient(rgba(148, 163, 184, 0.06) 1px, transparent 1px) 0 0 / 100% 25%,
        rgba(2, 6, 23, 0.55);
    border: 1px solid var(--console-border);
    box-shadow: 0 0 calc(var(--level) * 40px) calc(var(--level) * 2px) rgba(129, 140, 248, calc(var(--level) * 0.5)) inset;
}

.mic-stage canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.viz-switch {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    padding: 3px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.75);
    border: 1px solid var(--console-border);
    z-index: 1;
}

.viz-btn {
    padding: 4px 12px;
    font-family: var(--font-main);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--console-muted);
    background: transparent;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    transition: all var(--transition);
}

.viz-btn:hover {
    color: var(--console-text);
}

.viz-btn.active {
    color: #0b1020;
    background: var(--console-text);
}

.stage-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 20px;
    text-align: center;
    background: radial-gradient(60% 70% at 50% 50%, rgba(11, 16, 32, 0.35) 0%, rgba(11, 16, 32, 0.85) 100%);
    z-index: 2;
}

.btn-start {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 14px;
    padding: 16px 30px 16px 16px;
    font-family: var(--font-main);
    font-size: 1.15rem;
    font-weight: 700;
    color: white;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    border: none;
    border-radius: 999px;
    cursor: pointer;
    box-shadow: 0 12px 30px -8px rgba(99, 102, 241, 0.7);
    transition: transform var(--transition), box-shadow var(--transition);
}

.btn-start::before {
    content: '';
    position: absolute;
    inset: -6px;
    border-radius: inherit;
    border: 2px solid rgba(139, 92, 246, 0.55);
    animation: ring 2.2s ease-out infinite;
    pointer-events: none;
}

.btn-start:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 36px -8px rgba(99, 102, 241, 0.85);
}

.btn-start:focus-visible {
    outline: 3px solid white;
    outline-offset: 4px;
}

.btn-start:disabled {
    cursor: progress;
    transform: none;
    opacity: 0.85;
}

.btn-start:disabled::before {
    animation: none;
    opacity: 0;
}

.btn-start-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
}

@keyframes ring {
    0% { transform: scale(0.96); opacity: 0.9; }
    100% { transform: scale(1.18); opacity: 0; }
}

.stage-hint {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--console-muted);
}

/* Error state */
.mic-app[data-state="error"] .mic-stage {
    height: auto;
    min-height: 230px;
}

.mic-app[data-state="error"] .mic-stage canvas,
.mic-app[data-state="error"] .viz-switch {
    display: none;
}

.stage-error {
    position: relative;
    inset: auto;
    min-height: 230px;
    background: rgba(239, 68, 68, 0.06);
}

.error-card {
    max-width: 560px;
    text-align: left;
}

.error-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.15rem;
    font-weight: 700;
    color: #fecaca;
    margin-bottom: 6px;
}

.error-text {
    color: var(--console-text);
    margin-bottom: 12px;
}

.error-steps {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0 0 18px 20px;
    color: var(--console-muted);
    font-size: 0.93rem;
}

.error-steps li::marker {
    color: var(--accent-violet);
    font-weight: 700;
}

/* Meter */
.meter {
    display: flex;
    align-items: center;
    gap: 18px;
    margin-top: 18px;
}

.meter-body {
    flex: 1;
    min-width: 0;
}

.meter-track {
    position: relative;
    height: 16px;
    border-radius: 999px;
    background:
        repeating-linear-gradient(90deg, transparent 0 calc(10% - 1px), rgba(11, 16, 32, 0.9) calc(10% - 1px) 10%),
        rgba(255, 255, 255, 0.07);
    overflow: hidden;
}

.meter-fill {
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, var(--signal-green) 0%, var(--signal-green) 65%, var(--signal-yellow) 82%, var(--signal-red) 96%);
    clip-path: inset(0 100% 0 0);
    will-change: clip-path;
}

.meter-peak {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 3px;
    margin-left: -3px;
    background: white;
    border-radius: 2px;
    opacity: 0.9;
    will-change: left;
}

.meter-scale {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    font-size: 0.72rem;
    font-variant-numeric: tabular-nums;
    color: var(--console-muted);
}

.meter-readout {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    min-width: 84px;
    line-height: 1.1;
}

.meter-readout span {
    font-size: 1.9rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}

.meter-readout small {
    font-size: 0.72rem;
    color: var(--console-muted);
    font-weight: 500;
}

/* Verdict */
.verdict {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-top: 18px;
    padding: 16px 18px;
    border-radius: 14px;
    background: var(--console-surface);
    border: 1px solid var(--console-border);
    border-left: 4px solid var(--console-muted);
    transition: border-color 250ms ease, background-color 250ms ease;
}

.verdict-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    flex-shrink: 0;
    background: rgba(148, 163, 184, 0.15);
    color: var(--console-muted);
}

.verdict-title {
    font-weight: 700;
    font-size: 1.05rem;
    margin-bottom: 2px;
}

.verdict-text {
    font-size: 0.93rem;
    color: var(--console-muted);
}

.verdict[data-tone="info"] { border-left-color: var(--accent-cyan); }
.verdict[data-tone="info"] .verdict-icon { background: rgba(34, 211, 238, 0.15); color: var(--accent-cyan); }

.verdict[data-tone="ok"] { border-left-color: var(--signal-green); background: rgba(34, 197, 94, 0.07); }
.verdict[data-tone="ok"] .verdict-icon { background: rgba(34, 197, 94, 0.18); color: var(--signal-green); }

.verdict[data-tone="warn"] { border-left-color: var(--signal-yellow); background: rgba(234, 179, 8, 0.07); }
.verdict[data-tone="warn"] .verdict-icon { background: rgba(234, 179, 8, 0.18); color: var(--signal-yellow); }

.verdict[data-tone="error"] { border-left-color: var(--signal-red); background: rgba(239, 68, 68, 0.08); }
.verdict[data-tone="error"] .verdict-icon { background: rgba(239, 68, 68, 0.18); color: var(--signal-red); }

/* Controls */
.mic-controls {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 16px;
}

.ctrl-btn {
    --progress: 0;
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    font-family: var(--font-main);
    text-align: left;
    color: var(--console-text);
    background: var(--console-surface);
    border: 1px solid var(--console-border);
    border-radius: 14px;
    cursor: pointer;
    overflow: hidden;
    transition: background-color var(--transition), border-color var(--transition), opacity var(--transition);
}

.ctrl-btn:hover:not(:disabled) {
    background: var(--console-surface-hover);
    border-color: rgba(255, 255, 255, 0.16);
}

.ctrl-btn:focus-visible {
    outline: 2px solid var(--accent-violet);
    outline-offset: 2px;
}

.ctrl-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.ctrl-btn::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    height: 3px;
    width: calc(var(--progress) * 100%);
    background: var(--signal-red);
}

.ctrl-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
    color: var(--console-text);
}

.rec-dot::before {
    content: '';
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--signal-red);
    transition: border-radius var(--transition), transform var(--transition);
}

.ctrl-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.25;
}

.ctrl-text strong {
    font-size: 0.95rem;
    font-weight: 600;
}

.ctrl-text small {
    font-size: 0.78rem;
    color: var(--console-muted);
}

.ctrl-btn.is-recording {
    border-color: rgba(239, 68, 68, 0.5);
    background: rgba(239, 68, 68, 0.1);
}

.ctrl-btn.is-recording .rec-dot::before {
    border-radius: 3px;
    transform: scale(0.85);
    animation: pulseDot 1s ease-in-out infinite;
}

.ctrl-btn.is-active {
    border-color: rgba(139, 92, 246, 0.6);
    background: rgba(139, 92, 246, 0.14);
}

.ctrl-btn.is-active .ctrl-icon {
    background: var(--accent-violet);
    color: #0b1020;
}

/* Recording playback */
.recording {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    margin-top: 14px;
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.3);
    animation: fadeUp 250ms ease;
}

.recording-info {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}

.recording-info strong {
    font-size: 0.92rem;
}

.recording-info span {
    font-size: 0.78rem;
    color: var(--console-muted);
    font-variant-numeric: tabular-nums;
}

.recording audio {
    flex: 1;
    min-width: 220px;
    height: 40px;
}

.recording .btn-secondary {
    padding: 8px 14px;
    color: var(--console-text);
    background: transparent;
    border-color: rgba(255, 255, 255, 0.2);
}

.recording .btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Stats */
.mic-stats {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 1px;
    margin-top: 16px;
    border-radius: 14px;
    overflow: hidden;
    background: var(--console-border);
    border: 1px solid var(--console-border);
}

.stat {
    padding: 12px 14px;
    background: var(--console-bg);
    min-width: 0;
}

.stat dt {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--console-muted);
    margin-bottom: 2px;
}

.stat dd {
    font-size: 0.95rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Options */
.mic-options {
    margin-top: 14px;
    border-radius: 14px;
    border: 1px solid var(--console-border);
    background: var(--console-surface);
}

.mic-options summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    list-style: none;
}

.mic-options summary::-webkit-details-marker {
    display: none;
}

.mic-options summary::after {
    content: '+';
    font-size: 1.2rem;
    font-weight: 400;
    color: var(--console-muted);
    transition: transform var(--transition);
}

.mic-options[open] summary::after {
    transform: rotate(45deg);
}

.mic-options-body {
    padding: 0 16px 16px;
}

.mic-options-body > p {
    font-size: 0.85rem;
    color: var(--console-muted);
    margin-bottom: 12px;
}

.switch-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 24px;
}

.switch {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 0.9rem;
}

.switch input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
}

.switch-ui {
    position: relative;
    width: 38px;
    height: 22px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.15);
    transition: background-color var(--transition);
    flex-shrink: 0;
}

.switch-ui::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: white;
    transition: transform var(--transition);
}

.switch input:checked + .switch-ui {
    background: var(--color-primary);
}

.switch input:checked + .switch-ui::after {
    transform: translateX(16px);
}

.switch input:focus-visible + .switch-ui {
    outline: 2px solid var(--accent-violet);
    outline-offset: 2px;
}

/* ========================================
   SPEAKER / HEADPHONES TEST
   ======================================== */
.speaker-test {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
    max-width: 960px;
    margin: 20px auto 0;
    padding: 20px 22px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
}

.speaker-copy h2 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 2px;
}

.speaker-copy p {
    font-size: 0.92rem;
    color: var(--color-text-muted);
}

.speaker-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.speaker-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    font-family: var(--font-main);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-text);
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    border-radius: 999px;
    cursor: pointer;
    transition: all var(--transition);
}

.speaker-btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.speaker-btn:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.speaker-btn.is-playing {
    color: white;
    background: var(--color-primary);
    border-color: var(--color-primary);
}

/* ========================================
   MODALS
   ======================================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    overflow-y: auto;
    padding: 40px 20px;
    backdrop-filter: blur(4px);
}

.modal.active {
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.modal-content {
    background: var(--color-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 500px;
    width: 100%;
    padding: 32px;
    position: relative;
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    font-size: 1.75rem;
    color: var(--color-text-muted);
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.modal-close:hover {
    background: var(--color-bg-subtle);
    color: var(--color-text);
}

.modal-content h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 20px;
}

.modal-content h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text);
    margin: 20px 0 10px;
}

.modal-content p {
    color: var(--color-text-muted);
    line-height: 1.6;
    margin-bottom: 12px;
}

.modal-content a {
    color: var(--color-primary);
}

/* ========================================
   TOAST
   ======================================== */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 12px 24px;
    background: var(--color-text);
    color: white;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transition: all 300ms ease;
    z-index: 2000;
    max-width: calc(100vw - 32px);
    text-align: center;
}

.toast.visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.success {
    background: var(--color-success);
}

.toast.error {
    background: var(--color-danger);
}

.toast.info {
    background: var(--color-primary);
}

/* ========================================
   SEO CONTENT
   ======================================== */
.seo-content {
    background: var(--color-bg);
    border-top: 1px solid var(--color-border);
    padding: 64px 0;
}

.seo-section {
    margin-bottom: 56px;
}

.seo-section:last-child {
    margin-bottom: 0;
}

.seo-section h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 16px;
    letter-spacing: -0.01em;
}

.section-intro {
    font-size: 1.05rem;
    color: var(--color-text-muted);
    margin-bottom: 24px;
    max-width: 820px;
}

.section-intro strong {
    color: var(--color-text);
}

.section-intro code,
.seo-card code {
    font-size: 0.88em;
    padding: 1px 6px;
    border-radius: 4px;
    background: var(--color-bg-subtle);
    color: var(--color-text);
}

/* SEO Grid */
.seo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.seo-card {
    padding: 24px;
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    transition: box-shadow var(--transition);
}

.seo-card:hover {
    box-shadow: var(--shadow-md);
}

.seo-icon {
    font-size: 2rem;
    margin-bottom: 12px;
}

.seo-card h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 8px;
}

.seo-card p {
    font-size: 0.95rem;
    color: var(--color-text-muted);
    line-height: 1.6;
}

.seo-card p + p {
    margin-top: 8px;
}

.seo-card p strong {
    color: var(--color-text);
    font-weight: 500;
}

/* Level table */
.level-table-wrap {
    overflow-x: auto;
    margin-top: 24px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
}

.level-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.level-table th,
.level-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

.level-table th {
    background: var(--color-bg-alt);
    font-weight: 600;
}

.level-table tr:last-child td {
    border-bottom: none;
}

.level-table td {
    color: var(--color-text-muted);
}

.level-table td:first-child {
    font-weight: 600;
    color: var(--color-text);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.level-swatch {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 8px;
    vertical-align: middle;
}

/* FAQ */
.faq-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.faq-item {
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.faq-item summary {
    padding: 18px 24px;
    font-size: 1rem;
    font-weight: 500;
    color: var(--color-text);
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    transition: background var(--transition);
}

.faq-item summary::-webkit-details-marker {
    display: none;
}

.faq-item summary::after {
    content: '+';
    font-size: 1.25rem;
    font-weight: 400;
    color: var(--color-text-muted);
    transition: transform var(--transition);
}

.faq-item[open] summary::after {
    transform: rotate(45deg);
}

.faq-item summary:hover {
    background: var(--color-bg);
}

.faq-item p {
    padding: 0 24px 18px;
    font-size: 0.95rem;
    color: var(--color-text-muted);
    line-height: 1.7;
}

/* ========================================
   FOOTER
   ======================================== */
.footer {
    padding: 32px 0;
    text-align: center;
    border-top: 1px solid var(--color-border);
    background: var(--color-bg-alt);
}

.footer-tagline {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    margin-bottom: 12px;
}

.footer-credit {
    font-size: 0.9rem;
    color: var(--color-text);
    font-weight: 500;
}

.footer-credit a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color var(--transition);
}

.footer-credit a:hover {
    color: var(--color-primary-hover);
    text-decoration: underline;
}

.footer-links {
    margin-top: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    font-size: 0.85rem;
}

.footer-links a {
    color: var(--color-text-muted);
    text-decoration: none;
    transition: color var(--transition);
}

.footer-links a:hover {
    color: var(--color-primary);
}

.footer-separator {
    color: var(--color-border-strong);
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 860px) {
    .mic-stats {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 720px) {
    .container {
        padding: 0 16px;
    }

    .header.header-standalone {
        padding: 32px 0 22px;
    }

    .header .subtitle {
        font-size: 1rem;
    }

    .mic-app {
        padding: 16px;
        border-radius: 16px;
    }

    .device-picker {
        flex: 1 1 100%;
    }

    .mic-stage {
        height: 190px;
    }

    .stage-error,
    .mic-app[data-state="error"] .mic-stage {
        min-height: 190px;
    }

    .btn-start {
        font-size: 1.05rem;
        padding: 12px 24px 12px 12px;
    }

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

    #stopBtn {
        grid-column: 1 / -1;
    }

    .meter-readout span {
        font-size: 1.5rem;
    }

    .speaker-test {
        flex-direction: column;
        align-items: stretch;
    }

    .speaker-actions {
        justify-content: stretch;
    }

    .speaker-btn {
        flex: 1;
        justify-content: center;
    }

    .seo-content {
        padding: 48px 0;
    }

    .seo-section h2 {
        font-size: 1.3rem;
    }
}

@media (max-width: 480px) {
    .mic-controls {
        grid-template-columns: 1fr;
    }

    .mic-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .meter {
        gap: 12px;
    }

    .meter-readout {
        min-width: 64px;
    }

    .ctrl-btn {
        padding: 12px 14px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .btn-start::before,
    .status-pill[data-tone="info"] .status-dot {
        animation: none;
    }
}

/* ========================================
   PRINT
   ======================================== */
@media print {
    .main,
    .modal,
    .toast {
        display: none !important;
    }

    .seo-content {
        border: none;
        padding: 0;
    }
}
