/* CSS Variables */
:root {
    --bg-color: #f5f5f7;
    --surface: #ffffff;
    --text-primary: #1d1d1f;
    --text-secondary: #86868b;
    --accent: #0071e3;
    --border: #d2d2d7;
    --radius-lg: 24px;
    --radius-md: 16px;
    --shadow: 0 10px 30px rgba(0,0,0,0.08);
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Reset & Base */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Screens */
.screen {
    display: none;
    min-height: 100vh;
    padding: 40px 24px;
    animation: fadeIn 0.4s ease forwards;
}

.screen.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Start Screen */
#screen-start {
    display: none;
}
#screen-start.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

.hero {
    text-align: center;
}

.hero h1 {
    font-size: 48px;
    letter-spacing: -0.02em;
    margin-bottom: 12px;
}

.hero p {
    font-size: 20px;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

/* Buttons */
.btn {
    background-color: var(--text-primary);
    color: #fff;
    border: none;
    padding: 16px 32px;
    border-radius: 980px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.btn:hover {
    transform: scale(1.02);
    opacity: 0.9;
}

.btn-outline {
    background-color: transparent;
    color: var(--text-primary);
    border: 2px solid var(--text-primary);
}

/* Bottom Sheet */
.overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.sheet {
    position: absolute;
    bottom: 0; left: 0; width: 100%;
    height: 90vh;
    background: var(--surface);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    transform: translateY(100%);
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 40px;
    text-align: center;
    box-shadow: 0 -10px 40px rgba(0,0,0,0.15);
}

.overlay.open .sheet {
    transform: translateY(0);
}

.btn-close {
    position: absolute;
    top: 24px; right: 24px;
    background: #e5e5ea;
    color: var(--text-primary);
    border: none;
    width: 36px; height: 36px;
    border-radius: 50%;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
}

.recording-indicator {
    width: 16px; height: 16px;
    background: #ff3b30;
    border-radius: 50%;
    margin: 0 auto 24px auto;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(255, 59, 48, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 14px rgba(255, 59, 48, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(255, 59, 48, 0); }
}

.sheet h2 {
    font-size: 32px;
    margin-bottom: 16px;
}

.instructions {
    font-size: 18px;
    line-height: 1.5;
    margin-bottom: 32px;
}

.disclaimer {
    font-size: 14px;
    color: var(--text-secondary);
    max-width: 400px;
}

/* Results Layout */
.results-layout {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
    height: calc(100vh - 80px); /* Account for padding */
}

@media (max-width: 800px) {
    .results-layout {
        grid-template-columns: 1fr;
        height: auto;
    }
}

.panel {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    /* FIX: Changed from hidden to auto so the panel can scroll if content is tall */
    overflow-y: auto; 
    overflow-x: hidden;
}

.panel-header {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

/* JSON Output Formatting */
.json-container {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 14px;
    line-height: 1.6;
    color: #333;
}
.json-key { color: #d05c44; font-weight: 600; }
.json-num { color: #0071e3; }
.json-str { color: #34a853; }
.json-indent { margin-left: 20px; }

/* Chart & Stats */
.chart-wrapper {
    width: 100%;
    aspect-ratio: 16/10;
    margin-bottom: 32px;
    flex-shrink: 0;
}

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

.stats-card {
    background: var(--bg-color);
    border-radius: var(--radius-md);
    padding: 24px;
    margin-bottom: 32px;
    border: 1px solid var(--border);
    flex-shrink: 0;
}

.stat-row {
