:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: #e0e7ff;
    --primary-glass: rgba(99, 102, 241, 0.1);
    --bg: #f8fafc;
    --sidebar-bg: #0f172a;
    --card-bg: rgba(255, 255, 255, 0.8);
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --success: #10b981;
    --success-bg: #d1fae5;
    --warning: #f59e0b;
    --warning-bg: #fef3c7;
    --danger: #ef4444;
    --danger-bg: #fee2e2;
    --radius: 20px;
    --radius-sm: 12px;
    --shadow-sm: 0 2px 4px rgb(0 0 0 / 0.05);
    --shadow: 0 10px 25px -5px rgb(0 0 0 / 0.05), 0 8px 10px -6px rgb(0 0 0 / 0.01);
    --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    --header-height: 80px;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Inter', sans-serif; }

body {
    background: var(--bg);
    background-image: 
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(16, 185, 129, 0.05) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

.text-muted { color: var(--text-muted); }
.text-xs { font-size: 12px; }
.text-sm { font-size: 14px; }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.font-bold { font-weight: 700; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-6 { margin-bottom: 24px; }
.w-full { width: 100%; }
.max-w-3xl { max-width: 48rem; }
.mx-auto { margin-left: auto; margin-right: auto; }
.flex { display: flex; }
.justify-end { justify-content: flex-end; }
.flex-1 { flex: 1; }
.hidden { display: none !important; }

/* Layout */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--sidebar-bg);
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    padding: 24px 20px;
    flex-shrink: 0;
    border-right: 1px solid #1e293b;
    z-index: 50;
    position: relative;
    box-shadow: 4px 0 24px rgba(0,0,0,0.1);
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 40px;
    color: white;
    padding: 0 8px;
}

.logo {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, var(--primary), #a5b4fc);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.5);
}

.nav-menu {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-item {
    background: transparent;
    border: none;
    color: #94a3b8;
    padding: 16px 20px;
    border-radius: var(--radius-sm);
    text-align: left;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 14px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-item i { font-size: 22px; transition: transform 0.3s; }
.nav-item:hover { background: rgba(255,255,255,0.05); color: white; }
.nav-item:hover i { transform: scale(1.1); color: #a5b4fc; }
.nav-item.active { 
    background: var(--primary); 
    color: white; 
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4); 
}
.nav-item.active i { color: white; }

.sidebar-footer { margin-top: auto; padding-top: 24px; border-top: 1px solid rgba(255,255,255,0.1); }

.api-key-form label { font-size: 13px; color: #94a3b8; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; font-weight: 500; }
.api-key-input-group { display: flex; gap: 8px; }
.api-key-input-group input {
    flex-grow: 1; background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1);
    padding: 12px; border-radius: var(--radius-sm); color: white; font-size: 13px; transition: all 0.3s;
}
.api-key-input-group input:focus { outline: none; border-color: var(--primary); background: rgba(0,0,0,0.2); }
.api-key-input-group button {
    background: rgba(255,255,255,0.1); border: none; color: white; width: 42px; border-radius: var(--radius-sm);
    cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.3s;
}
.api-key-input-group button:hover { background: var(--primary); transform: translateY(-2px); }

/* Main Content */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    position: relative;
    scroll-behavior: smooth;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 48px;
    height: var(--header-height);
    background: rgba(248, 250, 252, 0.7);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    position: sticky;
    top: 0;
    z-index: 40;
    border-bottom: 1px solid rgba(226, 232, 240, 0.6);
}

.header-titles h1 { font-size: 26px; font-weight: 800; color: var(--text); letter-spacing: -0.5px; margin-bottom: 4px; }
.header-titles p { font-size: 14px; }

.system-status {
    display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600;
    color: var(--text-muted); background: white; padding: 8px 16px; border-radius: 30px;
    border: 1px solid var(--border); box-shadow: var(--shadow-sm);
}
.status-dot { width: 8px; height: 8px; background: var(--success); border-radius: 50%; box-shadow: 0 0 10px var(--success); animation: pulse-dot 2s infinite; }
@keyframes pulse-dot { 0% { opacity: 0.6; } 50% { opacity: 1; box-shadow: 0 0 15px var(--success); } 100% { opacity: 0.6; } }

.content-wrapper { padding: 40px 48px 100px; max-width: 1400px; margin: 0 auto; width: 100%; }

/* Tabs & Animations */
.tab-content { display: none; }
.tab-content.active { display: block; }
.fade-in { animation: fadeInUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards; opacity: 0; transform: translateY(20px); }

@keyframes fadeInUp { to { opacity: 1; transform: translateY(0); } }

/* Grid & Cards */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(450px, 1fr)); gap: 32px; }

.card {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--radius);
    padding: 32px;
    border: 1px solid rgba(255,255,255,0.6);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s, box-shadow 0.3s;
}
.card:hover { box-shadow: var(--shadow-lg); }

.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.card-header h3 { font-size: 18px; font-weight: 700; display: flex; align-items: center; gap: 10px; color: var(--text); }
.card-header h3 i { color: var(--primary); font-size: 24px; padding: 8px; background: var(--primary-glass); border-radius: 10px; }

textarea.large-textarea, textarea {
    width: 100%; height: 140px; padding: 18px; border: 2px solid transparent;
    border-radius: var(--radius-sm); margin-bottom: 24px; resize: none;
    font-size: 15px; transition: all 0.3s; background: rgba(241, 245, 249, 0.8);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02); line-height: 1.6;
}
textarea:focus { outline: none; border-color: var(--primary); background: white; box-shadow: 0 0 0 4px var(--primary-glass); }

/* Upload Zone */
.upload-zone {
    border: 2px dashed #cbd5e1; border-radius: var(--radius-sm); padding: 40px 20px;
    text-align: center; cursor: pointer; transition: all 0.3s ease; background: rgba(248, 250, 252, 0.5);
    display: flex; flex-direction: column; align-items: center; gap: 12px; position: relative; overflow: hidden;
}
.upload-icon-wrapper { width: 64px; height: 64px; background: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow-sm); margin-bottom: 8px; transition: all 0.3s; }
.upload-zone i { font-size: 32px; color: #94a3b8; transition: color 0.3s; }
.upload-title { font-weight: 600; color: var(--text); font-size: 15px; }
.upload-zone:hover { border-color: var(--primary); background: var(--primary-glass); }
.upload-zone:hover .upload-icon-wrapper { transform: translateY(-5px); box-shadow: 0 8px 20px rgba(99,102,241,0.2); }
.upload-zone:hover i { color: var(--primary); }
.upload-zone .browse { color: var(--primary); text-decoration: underline; text-underline-offset: 4px; }

/* Visualizer & Audio Preview */
.visualizer-container {
    background: #0f172a; height: 180px; border-radius: var(--radius-sm); margin-bottom: 24px;
    position: relative; overflow: hidden; box-shadow: inset 0 4px 10px rgba(0,0,0,0.3);
    border: 1px solid #1e293b;
}
canvas { width: 100%; height: 100%; }
.visualizer-overlay {
    position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
    color: #94a3b8; gap: 12px; background: rgba(15, 23, 42, 0.8); transition: opacity 0.4s; backdrop-filter: blur(4px);
}
.visualizer-overlay i { font-size: 42px; color: #475569; }

.audio-preview-container { background: white; padding: 20px; border-radius: var(--radius-sm); border: 1px solid var(--border); margin-bottom: 24px; box-shadow: var(--shadow-sm); }
.audio-preview-container h4 { margin-bottom: 12px; font-size: 13px; font-weight: 700; color: var(--text-muted); display: flex; align-items: center; gap: 8px; text-transform: uppercase; letter-spacing: 0.5px; }
audio.modern-audio-player, audio { width: 100%; height: 44px; outline: none; border-radius: 30px; }
audio::-webkit-media-controls-panel { background-color: #f1f5f9; }

/* Controls & Buttons */
.controls { display: flex; gap: 16px; }

.btn {
    padding: 14px 28px; border-radius: var(--radius-sm); font-weight: 600; cursor: pointer; border: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); font-size: 15px; display: inline-flex; align-items: center; justify-content: center; gap: 10px; position: relative; overflow: hidden;
}
.btn i { font-size: 20px; }

.btn-primary { background: linear-gradient(135deg, var(--primary), #818cf8); color: white; box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3); }
.btn-primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 8px 25px rgba(99, 102, 241, 0.4); }
.btn-primary:active:not(:disabled) { transform: translateY(0); }
.btn-primary:disabled { background: #cbd5e1; color: #94a3b8; cursor: not-allowed; box-shadow: none; transform: none; }

.btn-outline { background: white; border: 2px solid var(--border); color: var(--text); font-weight: 600; }
.btn-outline:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); background: var(--primary-glass); }

.btn-record { border-color: var(--danger); color: var(--danger); background: white; }
.btn-record:hover { background: var(--danger-bg); }
.btn-record.active { background: var(--danger); color: white; border-color: var(--danger); animation: pulse-danger 2s infinite; }
.record-icon { width: 12px; height: 12px; background: var(--danger); border-radius: 50%; transition: all 0.3s; }
.btn-record.active .record-icon { background: white; border-radius: 2px; transform: scale(1.2); }

@keyframes pulse-danger { 0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5); } 70% { box-shadow: 0 0 0 15px rgba(239, 68, 68, 0); } 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); } }

/* Forms & Selects */
.settings-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; background: rgba(248, 250, 252, 0.5); padding: 24px; border-radius: var(--radius-sm); border: 1px dashed var(--border); }
.input-group label { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--text-muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px; }
.input-group label i { font-size: 16px; color: var(--primary); }
.modern-select {
    width: 100%; padding: 14px 16px; border: 2px solid transparent; border-radius: var(--radius-sm);
    background: white; font-size: 15px; font-weight: 500; color: var(--text); outline: none;
    transition: all 0.3s; box-shadow: var(--shadow-sm); cursor: pointer; appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2364748b' viewBox='0 0 256 256'%3E%3Cpath d='M213.66,101.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,53.66,90.34L128,164.69l74.34-74.35a8,8,0,0,1,11.32,11.32Z'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 16px center; padding-right: 48px;
}
.modern-select:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-glass); }

.modern-range { width: 100%; accent-color: var(--primary); height: 6px; background: #e2e8f0; border-radius: 4px; outline: none; -webkit-appearance: none; margin-top: 10px; }
.modern-range::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; background: var(--primary); border-radius: 50%; cursor: pointer; box-shadow: 0 2px 6px rgba(99,102,241,0.4); transition: transform 0.1s; }
.modern-range::-webkit-slider-thumb:hover { transform: scale(1.2); }

/* Stunning Loading UI */
.stunning-loader { text-align: center; padding: 40px 20px; background: white; border-radius: var(--radius-sm); border: 1px solid var(--border); box-shadow: var(--shadow-lg); position: relative; overflow: hidden; }
.stunning-loader::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: linear-gradient(90deg, var(--primary), #a5b4fc, var(--primary)); background-size: 200% 100%; animation: gradientMove 2s linear infinite; }
@keyframes gradientMove { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

.loader-waves { display: flex; justify-content: center; align-items: center; gap: 6px; height: 60px; margin-bottom: 24px; }
.loader-waves span { width: 8px; height: 20px; background: var(--primary); border-radius: 4px; animation: wave 1s ease-in-out infinite; }
.loader-waves span:nth-child(1) { animation-delay: 0.0s; }
.loader-waves span:nth-child(2) { animation-delay: 0.1s; height: 40px; }
.loader-waves span:nth-child(3) { animation-delay: 0.2s; height: 60px; }
.loader-waves span:nth-child(4) { animation-delay: 0.3s; height: 40px; }
.loader-waves span:nth-child(5) { animation-delay: 0.4s; }
@keyframes wave { 0%, 100% { transform: scaleY(0.5); opacity: 0.5; } 50% { transform: scaleY(1); opacity: 1; box-shadow: 0 0 15px var(--primary); } }

.loader-title { font-size: 20px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.loader-subtitle { font-size: 14px; color: var(--text-muted); margin-bottom: 24px; }

.fancy-progress-bar { width: 100%; height: 8px; background: #f1f5f9; border-radius: 4px; overflow: hidden; position: relative; }
.fancy-progress-fill { position: absolute; top: 0; left: 0; height: 100%; background: linear-gradient(90deg, var(--primary), #a5b4fc); width: 30%; animation: progressIndeterminate 2s ease-in-out infinite alternate; border-radius: 4px; }
@keyframes progressIndeterminate { 0% { left: -30%; width: 30%; } 100% { left: 100%; width: 30%; } }

/* Results */
.result-container { margin-top: 32px; background: white; border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow-lg); overflow: hidden; }

/* Detailed Assessment Report */
.assessment-report { padding: 0; }
.report-header { background: linear-gradient(135deg, #0f172a, #1e293b); color: white; padding: 48px; display: flex; gap: 48px; align-items: center; position: relative; overflow: hidden; }
.report-header::after { content: '\ea3a'; font-family: "Phosphor"; position: absolute; right: -20px; bottom: -40px; font-size: 200px; opacity: 0.03; }

.score-dial {
    position: relative; width: 160px; height: 160px; border-radius: 50%;
    background: conic-gradient(var(--success) calc(var(--score) * 1%), rgba(255,255,255,0.05) 0);
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
    box-shadow: 0 0 30px rgba(0,0,0,0.5);
}
.score-dial::before { content: ''; position: absolute; inset: 12px; background: #1e293b; border-radius: 50%; box-shadow: inset 0 4px 10px rgba(0,0,0,0.5); }
.score-content { position: relative; text-align: center; }
.score-val { font-size: 48px; font-weight: 800; line-height: 1; text-shadow: 0 2px 10px rgba(0,0,0,0.5); }
.score-label { font-size: 13px; font-weight: 700; color: #94a3b8; letter-spacing: 2px; margin-top: 6px; }

.feedback-summary { flex-grow: 1; z-index: 2; }
.feedback-summary h2 { font-size: 28px; margin-bottom: 16px; display: flex; align-items: center; gap: 12px; font-weight: 800; }
.feedback-summary h2 i { color: #a5b4fc; background: rgba(255,255,255,0.1); padding: 8px; border-radius: 12px; }
.feedback-summary p { color: #e2e8f0; font-size: 16px; margin-bottom: 12px; line-height: 1.7; }
.smart-insights { margin-top: 20px; background: rgba(255,255,255,0.05); border-left: 4px solid var(--primary); padding: 16px 20px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.smart-insights p { font-size: 14px; color: #cbd5e1; margin: 0; }
.smart-insights strong { color: white; }

.report-body { padding: 48px; background: white; }
.report-body h3 { font-size: 20px; font-weight: 800; margin-bottom: 24px; display: flex; align-items: center; gap: 10px; color: var(--text); border-bottom: 2px solid #f1f5f9; padding-bottom: 16px; }
.report-body h3 i { color: var(--primary); }

.word-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }

.word-card {
    background: white; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 20px;
    transition: all 0.3s; cursor: pointer; position: relative; overflow: hidden; box-shadow: var(--shadow-sm);
}
.word-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: #cbd5e1; }
.word-card .word-text { font-size: 22px; font-weight: 800; margin-bottom: 6px; letter-spacing: -0.5px; }
.word-card .word-acc { font-size: 13px; color: var(--text-muted); font-weight: 600; display: inline-block; padding: 4px 10px; background: #f1f5f9; border-radius: 20px; margin-top: 8px; }

.word-card.correct { border-top: 4px solid var(--success); }
.word-card.mispronounced { border-top: 4px solid var(--warning); }
.word-card.missed { border-top: 4px solid var(--danger); background: #fef2f2; }

.word-details { margin-top: 16px; padding-top: 16px; border-top: 1px dashed #cbd5e1; font-size: 14px; display: none; color: #475569; animation: slideDown 0.3s ease; }
@keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
.word-card.expanded .word-details { display: block; }

.detail-row { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 13px; }
.detail-row span:first-child { font-weight: 600; color: var(--text-muted); }
.detail-row span:last-child { font-weight: 700; color: var(--text); }

.tip-box { background: var(--primary-glass); color: var(--primary-hover); padding: 12px 16px; border-radius: 8px; margin-top: 16px; font-size: 13px; display: flex; gap: 10px; align-items: flex-start; line-height: 1.5; font-weight: 500; }
.tip-box i { font-size: 18px; flex-shrink: 0; margin-top: 2px; }
.tip-box.warning { background: var(--warning-bg); color: #b45309; }

/* Transcription Results */
.lrc-header { display: flex; justify-content: space-between; align-items: center; padding: 24px 32px; border-bottom: 1px solid var(--border); background: #f8fafc; }
.lrc-header h3 { font-size: 18px; font-weight: 700; display: flex; align-items: center; gap: 10px; margin: 0; }
.lrc-header h3 i { font-size: 24px; }
.lrc-view { height: 400px; overflow-y: auto; background: white; padding: 32px; font-family: 'JetBrains Mono', 'Courier New', monospace; white-space: pre-wrap; font-size: 15px; line-height: 2; color: #1e293b; border-radius: 0 0 var(--radius) var(--radius); }

/* Mobile Responsiveness */
@media (max-width: 1024px) {
    .content-wrapper { padding: 32px; }
    .top-bar { padding: 0 32px; }
}

@media (max-width: 768px) {
    .app-container { flex-direction: column; }
    
    .sidebar {
        width: 100%; height: auto; flex-direction: row; padding: 16px; order: 2; border-right: none; border-top: 1px solid #1e293b;
        box-shadow: 0 -4px 20px rgba(0,0,0,0.2); justify-content: space-between; align-items: center; z-index: 100;
    }
    
    .brand { display: none; }
    .sidebar-footer { margin: 0; padding: 0; border: none; }
    .hide-mobile { display: none; }
    .api-key-form label { margin: 0; }
    
    .nav-menu { flex-direction: row; justify-content: center; gap: 8px; width: 100%; }
    .nav-item { flex-direction: column; gap: 4px; padding: 10px; font-size: 11px; flex: 1; text-align: center; justify-content: center; }
    .nav-item i { font-size: 24px; }
    
    .main-content { order: 1; height: calc(100vh - 80px); }
    .top-bar { padding: 0 20px; height: 70px; }
    .header-titles h1 { font-size: 20px; }
    .header-titles p { display: none; }
    
    .content-wrapper { padding: 20px; padding-bottom: 40px; }
    .grid { grid-template-columns: 1fr; }
    .card { padding: 20px; }
    .settings-panel { grid-template-columns: 1fr; }
    
    .report-header { flex-direction: column; text-align: center; padding: 32px 20px; gap: 24px; }
    .feedback-summary h2 { justify-content: center; }
    .report-body { padding: 24px 20px; }
    .w-full-mobile { width: 100%; }
}
