:root {
    --bg-color: #0d1117;
    --card-bg: rgba(22, 27, 34, 0.7);
    --border-color: rgba(48, 54, 61, 0.8);
    --primary-color: #10b981;
    --primary-hover: #059669;
    --primary-glow: rgba(16, 185, 129, 0.3);
    --accent-color: #58a6ff;
    --text-primary: #c9d1d9;
    --text-secondary: #8b949e;
    --danger-color: #f85149;
    --success-color: #3fb950;
    --warning-color: #f59e0b;
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-family);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 2rem;
    background-image:
        radial-gradient(circle at top center, rgba(16, 185, 129, 0.08), transparent 40%),
        radial-gradient(circle at bottom right, rgba(88, 166, 255, 0.05), transparent 40%);
}

.dashboard {
    width: 100%;
    max-width: 1200px;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* --- Header --- */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.5rem;
    font-weight: 700;
}

.logo span {
    color: var(--primary-color);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--accent-color);
    text-decoration: none;
    font-size: 0.875rem;
    padding: 0.4rem 0.8rem;
    border: 1px solid rgba(88, 166, 255, 0.2);
    border-radius: 6px;
    transition: all 0.2s;
}

.nav-link:hover {
    background: rgba(88, 166, 255, 0.1);
    border-color: rgba(88, 166, 255, 0.4);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    transition: all 0.3s;
}

.dot.connected {
    background-color: var(--success-color);
    box-shadow: 0 0 10px var(--success-color);
    animation: pulse 2s infinite;
}

.dot.connecting,
.dot.loading {
    background-color: var(--warning-color);
    box-shadow: 0 0 10px var(--warning-color);
    animation: pulse 1s infinite;
}

.dot.disconnected {
    background-color: var(--text-secondary);
    box-shadow: none;
}

.dot.error {
    background-color: var(--danger-color);
    box-shadow: 0 0 10px var(--danger-color);
}

@keyframes pulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(63, 185, 80, 0.7);
    }

    70% {
        transform: scale(1);
        box-shadow: 0 0 0 10px rgba(63, 185, 80, 0);
    }

    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(63, 185, 80, 0);
    }
}

/* --- Main Layout --- */
.main-content {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 2rem;
}

@media (max-width: 768px) {
    .main-content {
        grid-template-columns: 1fr;
    }
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 2rem;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 0.75rem;
}

/* --- Controls Panel --- */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.radio-group {
    display: flex;
    gap: 1rem;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
}

.custom-select {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-family: var(--font-family);
    appearance: none;
    outline: none;
    transition: all 0.2s;
}

.custom-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px var(--primary-glow);
}

.custom-select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* --- Mic Button --- */
.mic-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem 0;
}

.mic-button {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    background: rgba(16, 185, 129, 0.1);
    color: var(--primary-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 1;
}

.mic-button:hover {
    background: rgba(16, 185, 129, 0.2);
    border-color: var(--primary-color);
    transform: scale(1.05);
}

.mic-button.listening {
    background: rgba(248, 81, 73, 0.15);
    border-color: var(--danger-color);
    color: var(--danger-color);
    animation: mic-pulse 2s infinite;
}

.mic-button.listening:hover {
    background: rgba(248, 81, 73, 0.25);
}

@keyframes mic-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(248, 81, 73, 0.4);
    }

    70% {
        box-shadow: 0 0 0 15px rgba(248, 81, 73, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(248, 81, 73, 0);
    }
}

.mic-ripple {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid var(--danger-color);
    opacity: 0;
    pointer-events: none;
}

.mic-ripple.active {
    animation: ripple 1.5s infinite;
}

@keyframes ripple {
    0% {
        transform: scale(1);
        opacity: 0.6;
    }

    100% {
        transform: scale(2);
        opacity: 0;
    }
}

.mic-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* --- Level Meter --- */
.level-meter-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.level-meter {
    height: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
    overflow: hidden;
}

.level-bar {
    height: 100%;
    width: 0%;
    background: var(--primary-color);
    border-radius: 3px;
    transition: width 0.05s ease;
}

.recording-time {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-align: center;
    font-variant-numeric: tabular-nums;
}

/* --- Transcript Panel --- */
.transcript-panel {
    min-height: 400px;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 0.75rem;
    margin-bottom: 0.5rem;
}

.panel-header h2 {
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 0;
}

.transcript-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.badge {
    background: rgba(16, 185, 129, 0.1);
    color: var(--primary-color);
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
}

.icon-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 4px;
    padding: 0.4rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--primary-color);
}

/* --- Transcript Area --- */
.transcript-area {
    flex: 1;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 1.5rem;
    min-height: 300px;
    max-height: 600px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    line-height: 1.8;
    font-size: 1.05rem;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 250px;
    color: var(--text-secondary);
    text-align: center;
}

.empty-icon {
    width: 48px;
    height: 48px;
    opacity: 0.5;
    margin-bottom: 1rem;
}

.text-sm {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

/* Live Text */
.live-text {
    white-space: pre-wrap;
    word-break: break-word;
}

.final-text {
    color: var(--text-primary);
}

.partial-text {
    color: var(--primary-color);
    opacity: 0.9;
}

.waiting-text {
    color: var(--text-secondary);
    font-style: italic;
}

/* Blinking cursor */
.cursor {
    display: inline-block;
    width: 2px;
    height: 1.1em;
    background: var(--primary-color);
    margin-left: 2px;
    animation: blink 1s step-end infinite;
    vertical-align: text-bottom;
}

@keyframes blink {

    0%,
    50% {
        opacity: 1;
    }

    51%,
    100% {
        opacity: 0;
    }
}

/* --- Utilities --- */
.hide {
    display: none !important;
}

/* --- Scrollbar --- */
.transcript-area::-webkit-scrollbar {
    width: 6px;
}

.transcript-area::-webkit-scrollbar-track {
    background: transparent;
}

.transcript-area::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.transcript-area::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}