/* ===== 基礎設定與變數 ===== */
:root {
    --sunset-orange: #ff6b35;
    --sunset-magenta: #d63384;
    --sunset-purple: #4a1c6b;
    --sunset-deep-purple: #2d1142;
    --text-cream: #fff8f0;
    --text-cream-dim: rgba(255, 248, 240, 0.7);
    --flame-yellow: #ffc107;
    --flame-orange: #ff9800;
    --flame-red: #ff5722;
    --state-idle: #a0a0a0;
    --state-listening: #ff5722;
    --state-translating: #ffc107;
    --state-playing: #4caf50;
    --state-complete: #8bc34a;
    --card-bg: rgba(255, 255, 255, 0.1);
    --card-border: rgba(255, 255, 255, 0.2);
    --shadow: rgba(0, 0, 0, 0.3);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow-x: hidden; }

body {
    font-family: 'Noto Sans TC', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(135deg, var(--sunset-orange) 0%, var(--sunset-magenta) 40%, var(--sunset-purple) 70%, var(--sunset-deep-purple) 100%);
    background-attachment: fixed;
    min-height: 100vh;
    color: var(--text-cream);
    line-height: 1.6;
}

.app-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.header { text-align: center; padding: 20px 0; }
.header h1 { font-size: 2rem; font-weight: 700; text-shadow: 2px 2px 4px var(--shadow); margin-bottom: 8px; }
.subtitle { font-size: 1rem; color: var(--text-cream-dim); }

.language-selector {
    display: flex; flex-direction: column; align-items: center; gap: 10px;
    padding: 15px; background: var(--card-bg); border-radius: 16px;
    backdrop-filter: blur(10px); border: 1px solid var(--card-border);
}
.language-selector label { font-size: 1rem; font-weight: 500; }
.language-selector select {
    width: 100%; max-width: 300px; padding: 12px 16px; font-size: 1.1rem;
    font-family: inherit; border: 2px solid var(--flame-yellow); border-radius: 12px;
    background: rgba(255, 255, 255, 0.15); color: var(--text-cream); cursor: pointer;
    transition: all 0.3s ease; appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='%23fff8f0'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center;
}
.language-selector select:focus { outline: none; border-color: var(--flame-orange); box-shadow: 0 0 20px rgba(255, 193, 7, 0.4); }
.language-selector select option { background: var(--sunset-purple); color: var(--text-cream); }

.status-display { display: flex; justify-content: center; }
.status-indicator {
    display: flex; align-items: center; gap: 10px; padding: 10px 24px;
    background: var(--card-bg); border-radius: 50px;
    backdrop-filter: blur(10px); border: 1px solid var(--card-border); transition: all 0.3s ease;
}
.status-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--state-idle); transition: all 0.3s ease; }
.status-text { font-size: 1rem; font-weight: 500; }

.status-indicator.listening .status-dot { background: var(--state-listening); animation: pulse 1s infinite; box-shadow: 0 0 15px var(--state-listening); }
.status-indicator.translating .status-dot { background: var(--state-translating); animation: pulse 0.5s infinite; box-shadow: 0 0 15px var(--state-translating); }
.status-indicator.playing .status-dot { background: var(--state-playing); animation: pulse 0.8s infinite; box-shadow: 0 0 15px var(--state-playing); }
.status-indicator.complete .status-dot { background: var(--state-complete); box-shadow: 0 0 15px var(--state-complete); }

@keyframes pulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.3); opacity: 0.7; } }

.button-container { display: flex; justify-content: center; padding: 20px 0; }
.translate-button {
    position: relative; width: 160px; height: 160px; border-radius: 50%; border: none;
    background: linear-gradient(145deg, var(--flame-yellow), var(--flame-orange));
    color: var(--sunset-deep-purple); cursor: pointer; transition: all 0.3s ease;
    box-shadow: 0 8px 30px rgba(255, 152, 0, 0.5), 0 4px 15px rgba(0, 0, 0, 0.3), inset 0 2px 10px rgba(255, 255, 255, 0.3);
    overflow: hidden; -webkit-tap-highlight-color: transparent; touch-action: none; user-select: none;
}
.translate-button:hover { transform: scale(1.05); }
.translate-button:active, .translate-button.active { transform: scale(0.95); background: linear-gradient(145deg, var(--flame-orange), var(--flame-red)); }
.translate-button.listening { background: linear-gradient(145deg, var(--flame-red), #e91e63); animation: buttonPulse 1s infinite; }
.translate-button.translating { background: linear-gradient(145deg, var(--flame-yellow), #ffeb3b); }
.translate-button.playing { background: linear-gradient(145deg, #4caf50, #8bc34a); }
.translate-button.complete { background: linear-gradient(145deg, #8bc34a, #cddc39); }
.translate-button:disabled { opacity: 0.7; cursor: not-allowed; transform: none; }

@keyframes buttonPulse { 0%, 100% { box-shadow: 0 8px 30px rgba(255, 87, 34, 0.5), 0 0 0 0 rgba(255, 87, 34, 0.7); } 50% { box-shadow: 0 8px 30px rgba(255, 87, 34, 0.5), 0 0 0 20px rgba(255, 87, 34, 0); } }

.button-inner { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; position: relative; z-index: 1; }
.mic-icon { width: 48px; height: 48px; transition: transform 0.3s ease; }
.translate-button.listening .mic-icon { animation: micBounce 0.5s infinite; }
@keyframes micBounce { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.2); } }
.button-text { font-size: 1rem; font-weight: 700; text-align: center; }

.progress-container { background: var(--card-bg); border-radius: 12px; padding: 15px; backdrop-filter: blur(10px); border: 1px solid var(--card-border); }
.progress-bar { height: 8px; background: rgba(255, 255, 255, 0.2); border-radius: 4px; overflow: hidden; position: relative; margin-bottom: 10px; }
.progress-bar::after {
    content: ''; position: absolute; top: 0; left: 0; height: 100%;
    width: var(--progress, 0%); background: linear-gradient(90deg, var(--flame-yellow), var(--flame-orange));
    border-radius: 4px; transition: width 0.3s ease;
}
.progress-bar.listening::after { background: linear-gradient(90deg, var(--state-listening), var(--flame-red)); animation: progressPulse 1s infinite; }
.progress-bar.translating::after { background: linear-gradient(90deg, var(--flame-yellow), var(--state-translating)); }
.progress-bar.playing::after { background: linear-gradient(90deg, var(--state-playing), #8bc34a); }
.progress-bar.complete::after { background: linear-gradient(90deg, var(--state-complete), #cddc39); }
@keyframes progressPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }
.progress-text { display: block; text-align: center; font-size: 0.9rem; color: var(--text-cream-dim); font-weight: 500; }
.progress-text.active { color: var(--flame-yellow); font-weight: 700; }

.text-section { display: flex; flex-direction: column; gap: 15px; flex: 1; }
.text-card { background: var(--card-bg); border-radius: 16px; padding: 20px; backdrop-filter: blur(10px); border: 1px solid var(--card-border); transition: all 0.3s ease; }
.text-card.original { border-left: 4px solid var(--flame-orange); }
.text-card.translated { border-left: 4px solid var(--state-playing); }
.text-label { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; font-weight: 500; color: var(--text-cream-dim); font-size: 0.9rem; }
.label-icon { font-size: 1.2rem; }
.text-content { font-size: 1.1rem; line-height: 1.8; min-height: 60px; }
.text-content .placeholder { color: var(--text-cream-dim); font-style: italic; }

.hint-section { text-align: center; padding: 15px; font-size: 0.9rem; color: var(--text-cream-dim); }

.browser-warning { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.9); z-index: 1000; justify-content: center; align-items: center; }
.browser-warning.show { display: flex; }
.warning-content { text-align: center; padding: 40px; background: var(--sunset-purple); border-radius: 20px; max-width: 400px; margin: 20px; }
.warning-content h2 { margin-bottom: 20px; color: var(--flame-yellow); }

@media (max-width: 480px) {
    .app-container { padding: 15px; gap: 15px; }
    .header h1 { font-size: 1.6rem; }
    .translate-button { width: 140px; height: 140px; }
    .mic-icon { width: 40px; height: 40px; }
    .button-text { font-size: 0.9rem; }
    .text-card { padding: 15px; }
    .text-content { font-size: 1rem; min-height: 50px; }
}

@media (min-width: 768px) {
    .app-container { padding: 40px; gap: 25px; }
    .header h1 { font-size: 2.5rem; }
    .translate-button { width: 180px; height: 180px; }
    .mic-icon { width: 56px; height: 56px; }
    .text-content { font-size: 1.2rem; min-height: 80px; }
}
