:root {
    --primary-color: #6366f1;
    --secondary-color: #a855f7;
    --accent-color: #ec4899;
    --bg-dark: #0f172a;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --record-red: #ef4444;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    position: relative;
}

/* Background Animation */
.background-blobs {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.4;
    animation: float 10s infinite ease-in-out;
}

.blob-1 {
    width: 400px;
    height: 400px;
    background: var(--primary-color);
    top: -100px;
    left: -100px;
}

.blob-2 {
    width: 300px;
    height: 300px;
    background: var(--secondary-color);
    bottom: -50px;
    right: -50px;
    animation-delay: -2s;
}

.blob-3 {
    width: 250px;
    height: 250px;
    background: var(--accent-color);
    bottom: 20%;
    left: 20%;
    animation-delay: -4s;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(30px, -30px); }
}

/* App Container */
.app-container {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 2rem;
    width: 100%;
    max-width: 450px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    margin: 20px;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

header {
    text-align: center;
}

header h1 {
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    background: linear-gradient(to right, var(--primary-color), var(--accent-color));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

header p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Device Selection */
.device-selection {
    width: 100%;
    margin-bottom: 1rem;
}

#micSelect {
    width: 100%;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: var(--text-main);
    font-family: 'Outfit', sans-serif;
    font-size: 0.9rem;
    cursor: pointer;
    outline: none;
    transition: all 0.2s;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%2394a3b8%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 0.65em auto;
}

#micSelect:hover {
    background-color: rgba(255, 255, 255, 0.08);
    border-color: var(--primary-color);
}

#micSelect option {
    background: var(--bg-dark);
    color: var(--text-main);
}

/* Visualizer */
.visualizer-container {
    width: 100%;
    height: 120px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 16px;
    overflow: hidden;
    position: relative;
    border: 1px solid var(--glass-border);
}

canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* Timer */
.timer {
    text-align: center;
    font-size: 2.5rem;
    font-weight: 300;
    font-variant-numeric: tabular-nums;
    letter-spacing: 2px;
    color: var(--text-main);
    text-shadow: 0 0 20px rgba(99, 102, 241, 0.3);
}

/* Controls */
.controls {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-top: 0.5rem;
}

.control-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: white;
    outline: none;
}

/* Loading State */
.loading {
    text-align: center;
    color: var(--text-main);
    font-size: 0.9rem;
    margin-top: 10px;
}

.loading.hidden {
    display: none;
}

/* Toggle Record Button */
.record-btn {
    background: var(--record-red);
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.2);
}

.record-btn:not(:disabled):hover {
    transform: scale(1.1);
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.4);
}

.record-btn.recording {
    /* Pulse animation handled by class addition */
    animation: pulse 1.5s infinite;
}

/* Stop State style for the single button */
.stop-state {
    background: var(--bg-dark);
    border: 2px solid var(--record-red);
    color: var(--record-red);
    box-shadow: none;
    animation: pulse-border 1.5s infinite;
}

.stop-state:hover {
    background: var(--record-red);
    color: white;
    transform: scale(1.05);
}

@keyframes pulse-border {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* Adjust Stop Btn legacy styles if any remaining, or just clean up */
/* Status Message */
.status-message {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    min-height: 1.2em;
    margin-top: 10px;
}

/* Recordings List */
.recordings-list {
    margin-top: 1rem;
    border-top: 1px solid var(--glass-border);
    padding-top: 1.5rem;
}

.recordings-list h2 {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--text-muted);
    font-weight: 400;
}

.recordings-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 200px;
    overflow-y: auto;
    padding-right: 5px;
}

/* Scrollbar styling */
.recordings-container::-webkit-scrollbar {
    width: 4px;
}
.recordings-container::-webkit-scrollbar-track {
    background: transparent;
}
.recordings-container::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 2px;
}

.recording-item {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.recording-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--glass-border);
}

.recording-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.recording-name {
    font-size: 0.9rem;
    color: var(--text-main);
}

.recording-date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.recording-actions {
    display: flex;
    gap: 0.5rem;
}

.action-btn {
    background: transparent;
    border: none;
    color: var(--text-main);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.action-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--primary-color);
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-style: italic;
    padding: 1rem;
}
