*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
:root {
    --bg: #0a0a0a; --surface: #111111; --surface-2: #1a1a1a12; --surface-3: #222222;
    --border: #2a2a2a; --border-light: #333333; --accent: #63ff92; --accent-dim: rgba(255, 107, 43, 0.15);
    --red: #ff3b3b; --green: #2bff6b; --blue: #3b8bff; --blue-dim: rgba(59, 139, 255, 0.12);
    --text: #f0ece4; --text-dim: #8a8580; --text-muted: #5a5550;
    --mono: 'DM Mono', monospace; --display: 'Syne', sans-serif;
    --radius: 4px; --radius-lg: 8px;
}

/* THEME SCROLLBARS */
html { 
    font-size: 18px; -webkit-font-smoothing: antialiased; 
    scrollbar-width: thin; 
    scrollbar-color: var(--border-light) transparent; 
}
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
::-webkit-scrollbar-corner { background: transparent; }

body { background: var(--bg); color: var(--text); font-family: var(--mono); min-height: 100vh; position: relative; overflow-x: hidden; }

/* GALACTIC & GLITCH EFFECTS */
body::before { content: ''; position: fixed; inset: 0; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); opacity: 0.03; pointer-events: none; z-index: 9999; }
body::after { content: ''; position: fixed; inset: 0; background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(255, 255, 255, 0.008) 2px, rgba(255, 255, 255, 0.008) 4px); pointer-events: none; z-index: 9998; }
.galactic-bg { position: fixed; inset: 0; z-index: -2; pointer-events: none; background: radial-gradient(circle at 15% 50%, rgba(99, 255, 146, 0.04), transparent 25%), radial-gradient(circle at 85% 30%, rgba(59, 139, 255, 0.04), transparent 25%); }
.stars-bg { position: fixed; inset: 0; z-index: -1; pointer-events: none; width: 200vw; height: 200vh; background-image: radial-gradient(1px 1px at 20px 30px, #fff, rgba(0,0,0,0)), radial-gradient(1px 1px at 40px 70px, #fff, rgba(0,0,0,0)), radial-gradient(1.5px 1.5px at 90px 40px, #fff, rgba(0,0,0,0)); background-size: 150px 150px; opacity: 0.15; animation: star-drift 80s linear infinite; }
@keyframes star-drift { 0% { transform: translate(0, 0); } 100% { transform: translate(-150px, -150px); } }

.app { max-width: 960px; margin: 0 auto; padding: 0 24px 80px; position: relative; z-index: 1; }

.topbar { display: flex; align-items: center; justify-content: space-between; padding: 24px 0; border-bottom: 1px solid var(--border); gap: 16px; flex-wrap: wrap; }
.logo { font-family: var(--display); font-weight: 800; font-size: 1.2rem; color: var(--text); display: flex; align-items: center; gap: 8px; cursor: default; }
.logo .dot { width: 8px; height: 8px; background: var(--accent); border-radius: 50%; animation: pulse-dot 2s ease infinite; }
.logo .glitch-text { display: inline-block; position: relative; }
.logo:hover .glitch-text { animation: glitch-anim 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) both infinite; color: var(--accent); text-shadow: 2px 0px var(--blue), -2px 0px var(--red); }
@keyframes pulse-dot { 0%, 100% { opacity: 1; transform: scale(1) } 50% { opacity: 0.5; transform: scale(0.8) } }
@keyframes glitch-anim { 0% { transform: skew(0deg); } 20% { transform: skew(-5deg); } 40% { transform: skew(5deg); } 60% { transform: skew(-2deg); } 80% { transform: skew(2deg); } 100% { transform: skew(0deg); } }

.keys-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.key-btn { background: var(--surface); border: 1px solid var(--border); color: var(--text-dim); font-family: var(--mono); font-size: 0.7rem; padding: 7px 14px; cursor: pointer; transition: all 0.2s ease; text-transform: uppercase; border-radius: var(--radius); display: flex; align-items: center; gap: 6px; }
.key-btn:hover { border-color: var(--text-muted); color: var(--text) }
.key-btn.active { border-color: var(--green); color: var(--green); background: var(--green-dim); }
.key-indicator { width: 5px; height: 5px; border-radius: 50%; background: var(--text-muted); transition: background 0.2s; }
.key-btn.active .key-indicator { background: var(--green) }

.modal-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(8px); display: none; align-items: center; justify-content: center; z-index: 1000; padding: 24px; }
.modal-overlay.open { display: flex }
.modal { background: var(--surface); border: 1px solid var(--border); padding: 32px; max-width: 460px; width: 100%; border-radius: var(--radius-lg); }
.modal h3 { font-family: var(--display); font-size: 1rem; margin-bottom: 4px; }
.modal p { font-size: 0.7rem; color: var(--text-dim); margin-bottom: 16px; line-height: 1.5; }

.api-guide { margin-bottom: 20px; padding: 14px; background: rgba(99, 255, 146, 0.05); border: 1px solid var(--border-light); border-radius: var(--radius); font-size: 0.7rem; color: var(--text-dim); line-height: 1.6; }
.api-guide a { color: var(--accent); text-decoration: none; font-weight: 500; }
.api-guide a:hover { text-decoration: underline; }
.api-guide ol { margin-left: 20px; margin-top: 8px; }
.api-guide li { margin-bottom: 4px; }

.modal input { width: 100%; background: var(--bg); border: 1px solid var(--border); color: var(--text); font-family: var(--mono); font-size: 0.75rem; padding: 10px 14px; outline: none; margin-bottom: 16px; border-radius: var(--radius); }
.modal input:focus { border-color: var(--accent) }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }
.btn-modal { font-family: var(--mono); font-size: 0.7rem; padding: 8px 18px; border: 1px solid var(--border); background: transparent; color: var(--text-dim); cursor: pointer; text-transform: uppercase; border-radius: var(--radius); }
.btn-modal.primary { background: var(--accent); border-color: var(--accent); color: var(--bg); }

.controls { padding: 32px 0; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; }
.settings-wrapper { width: 100%; max-width: 700px; margin-bottom: 24px; }
.settings-toggle { width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; background: transparent; border: 1px dashed var(--border); color: var(--text-muted); padding: 10px; border-radius: var(--radius); cursor: pointer; font-family: var(--mono); font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.1em; transition: all 0.2s; }
.settings-toggle:hover { color: var(--text); border-color: var(--text-muted); }
.settings-toggle.open { border-style: solid; border-color: var(--border); border-bottom: none; border-bottom-left-radius: 0; border-bottom-right-radius: 0; background: var(--surface); }
.settings-panel { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 0.3s ease; background: var(--surface); border: 1px solid var(--border); border-top: none; border-bottom-left-radius: var(--radius); border-bottom-right-radius: var(--radius); opacity: 0; }
.settings-panel.open { grid-template-rows: 1fr; opacity: 1; }
.settings-inner { overflow: hidden; }
.settings-panel.open .settings-inner { padding: 20px 24px 24px; }
.config-row { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.config-row:last-child { margin-bottom: 0; }
.config-group { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 160px; }
.config-group label { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); }
.config-group select { background: var(--bg); border: 1px solid var(--border); color: var(--text); font-family: var(--mono); font-size: 0.75rem; padding: 9px 12px; outline: none; cursor: pointer; border-radius: var(--radius); appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a8580' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; transition: border-color 0.2s; }
.config-group select:focus { border-color: var(--accent) }

.record-area { display: flex; flex-direction: column; align-items: center; gap: 20px; padding-top: 16px; position: relative; }

.record-btn { width: 188px; height: 188px; border-radius: 50%; border: none; background: transparent; cursor: pointer; display: flex; align-items: center; justify-content: center; position: relative; transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1); animation: record-idle-pulse 4s ease-in-out infinite; z-index: 1; }
.record-btn::before { content: ''; position: absolute; inset: -3px; border-radius: 50%; background: conic-gradient(from 0deg, transparent, var(--accent), transparent 30%); animation: spin 3s linear infinite; z-index: -2; opacity: 0.6; transition: opacity 0.3s; }
.record-btn::after { content: ''; position: absolute; inset: 0; border-radius: 50%; background: var(--surface); border: 2px solid var(--border-light); z-index: -1; transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1); }
.record-btn:hover::after { border-color: var(--accent); }
.record-btn:hover { transform: scale(1.04); animation: none; }

.record-btn.recording { animation: none; }
.record-btn.recording::before { opacity: 0; animation: none; }
.record-btn.recording::after { border-color: var(--red); background: rgba(255, 59, 59, 0.06); animation: recording-pulse-bg 1.5s ease infinite; }
.record-btn.recording .rec-ring { position: absolute; inset: -8px; border: 1px solid var(--red); border-radius: 50%; opacity: 0; animation: ring-expand 1.5s ease infinite; z-index: -3; }
.record-btn.recording .rec-ring:nth-child(2) { animation-delay: 0.5s }
.record-btn.recording .rec-ring:nth-child(3) { animation-delay: 1s }

/* 3D Rotating Globe Effect */
.rec-icon { 
    width: 34px; 
    height: 34px; 
    border-radius: 50%; 
    background: linear-gradient(90deg, var(--accent) 0%, #17c453 25%, var(--accent) 50%, #17c453 75%, var(--accent) 100%);
    background-size: 200% 100%;
    box-shadow: inset -4px -4px 6px rgba(0, 0, 0, 0.4), inset 3px 3px 6px rgba(255, 255, 255, 0.5), 0 2px 8px rgba(99, 255, 146, 0.4);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1); 
    animation: globe-scroll 3s linear infinite;
}

/* Stop Button State (When Recording) */
.record-btn.recording .rec-icon { 
    width: 28px; 
    height: 28px; 
    border-radius: 6px; 
    background: var(--red);
    box-shadow: inset -2px -2px 4px rgba(0, 0, 0, 0.3), inset 2px 2px 4px rgba(255, 255, 255, 0.4);
    animation: none;
}

@keyframes globe-scroll { 0% { background-position: 200% 50%; } 100% { background-position: 0% 50%; } }
@keyframes spin { 100% { transform: rotate(360deg); } }
@keyframes record-idle-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.03); } }
@keyframes recording-pulse-bg { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 59, 59, 0.3) inset; } 50% { box-shadow: 0 0 0 12px rgba(255, 59, 59, 0) inset; } }
@keyframes ring-expand { 0% { opacity: 0.6; transform: scale(1) } 100% { opacity: 0; transform: scale(1.6) } }

.or-divider { display: flex; align-items: center; gap: 14px; width: 100%; max-width: 360px; }
.or-divider::before, .or-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.or-divider span { font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.15em; color: var(--text-muted); }
.upload-zone { border: 1px dashed var(--border); padding: 16px 28px; cursor: pointer; text-align: center; transition: all 0.2s; border-radius: var(--radius); width: 100%; max-width: 360px; }
.upload-zone:hover { border-color: var(--accent); background: var(--accent-dim); }
.upload-zone p { font-size: 0.7rem; color: var(--text-dim); }
.upload-zone .upload-hint { font-size: 0.6rem; color: var(--text-muted); margin-top: 4px; }

.status { text-align: center; padding: 20px 0; border-bottom: 1px solid var(--border); min-height: 72px; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 6px; }
.status-text { font-size: 0.72rem; color: var(--text-muted); letter-spacing: 0.02em; }
.status-text.error { color: var(--red) }
.status-text.success { color: var(--green) }

.thinking-badge { display: inline-flex; align-items: center; gap: 5px; font-size: 0.58rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--blue); background: var(--blue-dim); border: 1px solid rgba(59, 139, 255, 0.2); border-radius: var(--radius); padding: 2px 7px; margin-left: 8px; vertical-align: middle; }
.thinking-badge .t-dot { width: 4px; height: 4px; border-radius: 50%; background: var(--blue); animation: pulse-dot 1.5s ease infinite; }

.results { padding: 32px 0 }
.results-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.results-header h2 { font-family: var(--display); font-size: 0.9rem; }
.results-count { font-size: 0.65rem; color: var(--text-muted); text-transform: uppercase; }

.results-grid { display: flex; flex-direction: column; gap: 24px; }

.result-pair { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; position: relative; }
.pair-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-light); padding-bottom: 12px; margin-bottom: 16px; }
.pair-time { font-size: 0.6rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.1em; }
.btn-delete { background: transparent; border: 1px solid var(--border-light); color: var(--red); font-family: var(--mono); font-size: 0.6rem; padding: 4px 10px; border-radius: var(--radius); cursor: pointer; text-transform: uppercase; transition: all 0.2s; }
.btn-delete:hover { background: rgba(255, 59, 59, 0.1); border-color: var(--red); }
.pair-contents { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.result-card { background: var(--bg); border: 1px solid var(--border-light); padding: 20px; border-radius: var(--radius); opacity: 0; transform: translateY(12px); transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1); position: relative; overflow: hidden; }
.result-card.visible { opacity: 1; transform: translateY(0); }
.result-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px; }
.result-card.transcript::before { background: var(--accent) }
.result-card.translation::before { background: var(--blue) }

.result-label { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.result-label .indicator { width: 6px; height: 6px; border-radius: 50%; }
.result-card.transcript .indicator { background: var(--accent) }
.result-card.translation .indicator { background: var(--blue); }
.result-label span { font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--text-muted); font-weight: 500; }
.result-meta { display: flex; gap: 16px; margin-bottom: 12px; flex-wrap: wrap; }
.meta-item { font-size: 0.6rem; color: var(--text-muted); }
.meta-item strong { color: var(--text-dim); }
.result-text { font-size: 16px; line-height: 1.7; color: var(--text); word-break: break-word; }
.result-card audio { width: 100%; margin-top: 16px; height: 40px; border-radius: var(--radius); filter: invert(1) hue-rotate(180deg) contrast(0.8); outline: none; }

.skeleton-line { background: linear-gradient(90deg, var(--surface) 25%, var(--border) 50%, var(--surface) 75%); background-size: 200% 100%; animation: shimmer 1.6s ease-in-out infinite; border-radius: var(--radius); height: 14px; margin-bottom: 10px; width: 100%; }
.skeleton-line:last-of-type { margin-bottom: 0; width: 60%; } .skeleton-line.short { width: 45%; } .skeleton-line.medium { width: 75%; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.translating-indicator { display: flex; align-items: center; gap: 8px; margin-top: 16px; font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--blue); }
.translating-dots { display: flex; gap: 3px; }
.translating-dots span { width: 4px; height: 4px; border-radius: 50%; background: var(--blue); animation: bounce-dot 0.9s ease infinite; }
.translating-dots span:nth-child(2) { animation-delay: 0.15s; } .translating-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce-dot { 0%, 60%, 100% { transform: translateY(0); opacity: 0.4; } 30% { transform: translateY(-8px); opacity: 1; } }

/* REAL-TIME THINKING UI */
.thinking-container { background: var(--surface-2); border: 1px solid var(--border-light); border-radius: var(--radius); margin-bottom: 16px; transition: all 0.3s ease; }
.thinking-header { padding: 10px 14px; cursor: pointer; display: flex; align-items: center; justify-content: space-between; font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--blue); user-select: none; border-bottom: 1px solid var(--border-light); }
.thinking-container.collapsed .thinking-header { border-bottom: none; }
.thinking-header:hover { background: rgba(59, 139, 255, 0.05); }
.thinking-content { padding: 14px; font-size: 0.7rem; color: var(--text-muted); max-height: 250px; overflow-y: auto; white-space: pre-wrap; font-family: var(--mono); line-height: 1.6; background: var(--bg); border-bottom-left-radius: var(--radius); border-bottom-right-radius: var(--radius); }
.thinking-container.collapsed .thinking-content { display: none; }
.toggle-icon { font-size: 0.5rem; transition: transform 0.2s; }
.thinking-container.collapsed .toggle-icon { transform: rotate(-90deg); }

.card-actions { position: absolute; top: 16px; right: 16px; display: flex; gap: 6px; z-index: 2; }
.icon-btn { background: transparent; border: 1px solid var(--border); color: var(--text-muted); width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; cursor: pointer; border-radius: var(--radius); font-size: 0.8rem; transition: all 0.2s; }
.icon-btn:hover { border-color: var(--text-muted); color: var(--text); background: var(--surface); }
.icon-btn.primary-hover:hover { border-color: var(--accent); color: var(--accent); }
.icon-btn.blue-hover:hover { border-color: var(--blue); color: var(--blue); }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); border: 1px dashed var(--border); border-radius: var(--radius-lg); }

@media(max-width:640px) { .app { padding: 0 16px 60px } .pair-contents { grid-template-columns: 1fr } }