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

:root {
    --primary: #667eea;
    --primary-dark: #5568d3;
    --secondary: #764ba2;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border: #334155;
    --shadow: rgba(0, 0, 0, 0.3);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, var(--bg-primary) 0%, #1a1f35 100%);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 3rem;
    padding: 2rem 0;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.logo h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Card */
.card {
    background: var(--bg-card);
    border-radius: 1.5rem;
    padding: 2rem;
    margin-bottom: 2rem;
    border: 1px solid var(--border);
    box-shadow: 0 10px 40px var(--shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 50px var(--shadow);
}

.card h2 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

/* Input Section */
#textInput {
    width: 100%;
    padding: 1rem;
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: 0.75rem;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.3s ease;
}

#textInput:focus {
    outline: none;
    border-color: var(--primary);
}

#textInput::placeholder {
    color: var(--text-secondary);
}

/* Audio Controls */
.audio-controls {
    margin-top: 2rem;
}

/* Microphone Selector */
.mic-selector {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 0.75rem;
    border: 1px solid var(--border);
}

.mic-selector label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-weight: 500;
    white-space: nowrap;
}

.mic-selector label svg {
    flex-shrink: 0;
}

.mic-select {
    flex: 1;
    padding: 0.75rem 1rem;
    background: var(--bg-primary);
    border: 2px solid var(--border);
    border-radius: 0.5rem;
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.3s ease;
}

.mic-select:hover {
    border-color: var(--primary);
}

.mic-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.mic-select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 0.5rem;
}

.button-group {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin: 1rem 0;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: 0.75rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}

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

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: var(--error);
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #dc2626;
    transform: translateY(-2px);
}

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

.btn-outline:hover:not(:disabled) {
    background: var(--primary);
    color: white;
}

.btn-analyze {
    width: 100%;
    margin-top: 1.5rem;
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
    color: white;
    font-size: 1.1rem;
    padding: 1rem;
}

.btn-analyze:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(16, 185, 129, 0.4);
}

/* Audio Status */
.audio-status {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 0.75rem;
    border-left: 4px solid var(--primary);
    display: none;
}

.audio-status.show {
    display: block;
}

#audioPlayback {
    width: 100%;
    margin-top: 1rem;
    border-radius: 0.75rem;
}

/* Loading Indicator */
.loading-indicator {
    text-align: center;
    padding: 3rem;
}

.spinner {
    width: 60px;
    height: 60px;
    margin: 0 auto 1rem;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Score Display */
.score-display {
    display: flex;
    gap: 3rem;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

.score-circle {
    position: relative;
    width: 200px;
    height: 200px;
}

.progress-ring {
    transform: rotate(-90deg);
}

.progress-ring-bg {
    fill: none;
    stroke: var(--border);
    stroke-width: 12;
}

.progress-ring-fill {
    fill: none;
    stroke: url(#scoreGradient);
    stroke-width: 12;
    stroke-linecap: round;
    stroke-dasharray: 534;
    stroke-dashoffset: 534;
    transition: stroke-dashoffset 1s ease;
}

.score-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.score-number {
    font-size: 3rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.score-label {
    font-size: 1.5rem;
    color: var(--text-secondary);
}

.score-details {
    flex: 1;
    min-width: 300px;
}

.score-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
}

.score-item:last-child {
    border-bottom: none;
}

.score-item-label {
    color: var(--text-secondary);
    font-weight: 500;
}

.score-item-value {
    font-weight: 600;
    color: var(--primary);
    font-size: 1.1rem;
}

.progress-bar {
    flex: 1;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    margin: 0 1rem;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--secondary) 100%);
    border-radius: 4px;
    transition: width 1s ease;
}

/* Word Analysis */
.word-analysis {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.word-item {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: 1rem;
    border-left: 4px solid var(--primary);
    transition: transform 0.2s ease;
}

.word-item:hover {
    transform: translateX(5px);
}

.word-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.word-text {
    font-size: 1.5rem;
    font-weight: 600;
}

.word-accuracy {
    font-size: 1.2rem;
    font-weight: 700;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
}

.accuracy-high {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.accuracy-medium {
    background: rgba(245, 158, 11, 0.2);
    color: var(--warning);
}

.accuracy-low {
    background: rgba(239, 68, 68, 0.2);
    color: var(--error);
}

.ipa-comparison {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin: 1rem 0;
}

.ipa-item {
    background: var(--bg-primary);
    padding: 0.75rem;
    border-radius: 0.5rem;
}

.ipa-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.ipa-value {
    font-size: 1.1rem;
    font-weight: 500;
    font-family: 'Courier New', monospace;
}

.phoneme-errors {
    margin-top: 1rem;
}

.error-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem;
    background: rgba(239, 68, 68, 0.1);
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
}

.error-type {
    padding: 0.25rem 0.75rem;
    background: var(--error);
    color: white;
    border-radius: 0.25rem;
    font-size: 0.875rem;
    font-weight: 600;
}

.error-detail {
    flex: 1;
    font-family: 'Courier New', monospace;
}

.error-accuracy {
    font-weight: 600;
    color: var(--error);
}

/* Text Visualization */
.text-visualization {
    font-size: 2rem;
    line-height: 2.5;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 1rem;
}

.char-correct {
    color: var(--success);
    background: rgba(16, 185, 129, 0.1);
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    margin: 0 0.1rem;
}

.char-error {
    color: var(--error);
    background: rgba(239, 68, 68, 0.2);
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    margin: 0 0.1rem;
    position: relative;
    cursor: help;
    border-bottom: 2px wavy var(--error);
}

.char-warning {
    color: var(--warning);
    background: rgba(245, 158, 11, 0.2);
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    margin: 0 0.1rem;
    position: relative;
    cursor: help;
}

/* Footer */
.footer {
    text-align: center;
    padding: 2rem 0;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    .logo h1 {
        font-size: 2rem;
    }

    .button-group {
        flex-direction: column;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }

    .score-display {
        flex-direction: column;
    }

    .text-visualization {
        font-size: 1.5rem;
    }

    /* Mic selector responsive */
    .mic-selector {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .mic-selector label {
        justify-content: flex-start;
    }
}

/* Add gradient definition for SVG */
svg defs {
    position: absolute;
}