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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f5f7fa;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    margin: 0;
}

.container {
    background: white;
    border-radius: 12px;
    padding: 40px;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid #e8eaed;
    width: 95%;
    max-width: 1400px;
    height: 90vh;
    max-height: 900px;
    display: flex;
    flex-direction: column;
}

.main-layout {
    display: flex;
    gap: 30px;
    flex: 1;
    min-height: 0;
}

h1 {
    text-align: center;
    color: #2c3e50;
    margin-bottom: 10px;
    font-size: 2em;
    font-weight: 600;
    flex-shrink: 0;
    letter-spacing: -0.5px;
}

.tagline {
    text-align: center;
    font-size: 1em;
    font-weight: 400;
    color: #e67e22;
    margin-bottom: 30px;
    letter-spacing: 0.5px;
    font-style: italic;
}

h1.header-with-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 30px;
    font-size: 2.2em;
    font-weight: 600;
    color: #2c3e50;
    letter-spacing: -0.5px;
}

h1.header-with-icon .header-icon {
    flex-shrink: 0;
    color: #3498db;
}

h1.header-with-icon .header-text {
    line-height: 1.2;
}

.recording-section {
    text-align: center;
    margin-bottom: 20px;
}

.audio-source-selector {
    margin-bottom: 15px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
    display: flex;
    gap: 8px;
    justify-content: center;
}

.audio-source-btn {
    flex: 1;
    padding: 12px 8px;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.audio-source-btn:hover {
    background: #f8f9fa;
    border-color: #bdc3c7;
    transform: translateY(-1px);
}

.audio-source-btn.active {
    background: #2d3436;
    border-color: #2d3436;
    color: white;
}

.audio-source-btn.active svg {
    stroke: white;
}

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

.audio-source-btn:disabled:hover {
    transform: none;
    border-color: #e0e0e0;
}

.audio-source-selector select:disabled {
    background: #f0f0f0;
    cursor: not-allowed;
    opacity: 0.6;
    border-color: #ccc;
    color: #999;
}

.transcription-in-progress-warning {
    margin-top: 10px;
    padding: 8px 10px;
    font-size: 0.8em;
    color: #667eea;
    background: #f0f7ff;
    border: 1px solid #c5dbf7;
    border-radius: 6px;
    line-height: 1.4;
    text-align: center;
    /* 使用 visibility 和 opacity，元素始终占据空间 */
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.transcription-in-progress-warning.show {
    visibility: visible;
    opacity: 1;
}

.recording-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.auto-record-switch {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
    font-size: 0.85em;
    margin-bottom: 18px; /* 保持与Record按钮的距离 */
}

.auto-record-switch input[type="checkbox"] {
    display: none;
}

.auto-record-switch .slider {
    position: relative;
    width: 40px;
    height: 22px;
    background-color: #ccc;
    border-radius: 22px;
    transition: background-color 0.3s ease;
    margin-right: 6px;
}

.auto-record-switch .slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    left: 3px;
    top: 3px;
    background-color: white;
    border-radius: 50%;
    transition: transform 0.3s ease;
}

.auto-record-switch input[type="checkbox"]:checked + .slider {
    background-color: #2d3436;
}

.auto-record-switch input[type="checkbox"]:checked + .slider::before {
    transform: translateX(18px);
}

.auto-record-switch .label-text {
    font-size: 1em;
    color: #666;
}

.record-btn {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 2px solid #3498db;
    background: #3498db;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    display: block;
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.25);
    margin: 0;
    padding: 0;
    position: relative;
}

.record-btn .btn-icon {
    flex-shrink: 0;
    display: block;
    margin: 0 auto;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) !important;
}

.record-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.4);
    background: #2980b9;
}

.record-btn.recording {
    background: #e67e22;
    border-color: #e67e22;
    border-radius: 12px;
    animation: pulse-transcribe 1.5s ease-in-out infinite;
}

.record-btn.recording .btn-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) !important;
    display: block;
    margin: 0;
}

.record-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: #ccc;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.record-btn:disabled:hover {
    transform: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 2px 8px rgba(52, 152, 219, 0.25);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 4px 16px rgba(52, 152, 219, 0.5);
    }
}

@keyframes pulse-transcribe {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 2px 8px rgba(230, 126, 34, 0.3);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 4px 20px rgba(230, 126, 34, 0.6);
    }
}

/* Waveform Canvas */
.waveform-canvas {
    width: 100%;
    max-width: 400px;
    height: 50px;
    margin: 12px auto 8px;
    background: transparent;
}

.recording-time {
    font-size: 1.2em;
    font-weight: 600;
    color: #2d3436;
    margin: 0;
}

.recording-status-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.cancel-record-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid #e0e0e0;
    background: #f8f9fa;
    color: #666;
    border-radius: 50%;
    cursor: pointer;
    margin: 0;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.cancel-record-btn:hover {
    background: #e8e8e8;
    border-color: #ccc;
    color: #333;
}

.cancel-record-btn:active {
    transform: scale(0.95);
}

.cancel-record-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    display: block;
    margin: auto;
}

.transcribe-options,
.playback-section {
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
    flex-shrink: 0;
}

.transcribe-options h3,
.playback-section h3 {
    margin-bottom: 15px;
    color: #333;
    font-size: 1.1em;
}

.playback-section h4 {
    margin-bottom: 12px;
    color: #333;
    font-size: 0.95em;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-buttons {
    margin-top: 20px;
    padding: 20px;
    background: #f0f7ff;
    border-radius: 10px;
    border: 2px solid #667eea;
}

.action-buttons h3 {
    margin-bottom: 15px;
    color: #333;
    font-size: 1.1em;
}

.action-btn:disabled,
.copy-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #e0e0e0;
    color: #999;
    border-color: #ccc;
}

.action-btn:disabled:hover,
.copy-btn:disabled:hover {
    transform: none;
    box-shadow: none;
    background: #e0e0e0;
    color: #999;
}

.action-btn {
    padding: 10px 15px;
    border: 2px solid #667eea;
    background: white;
    color: #667eea;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.3s ease;
    width: 100%;
}

.action-btn:hover {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(102, 126, 234, 0.3);
}

.play-btn {
    border-color: #28a745;
    color: #28a745;
}

.play-btn:hover {
    background: #28a745;
    color: white;
    box-shadow: 0 4px 10px rgba(40, 167, 69, 0.3);
}

.transcribe-action-btn {
    border-color: #667eea;
    color: #667eea;
}

.transcribe-action-btn:hover {
    background: #667eea;
    color: white;
    box-shadow: 0 4px 10px rgba(102, 126, 234, 0.3);
}

.duration-selector {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.duration-btn {
    flex: 1;
    padding: 12px 8px;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1em;
    font-weight: 500;
    color: #333;
}

.duration-btn:hover {
    background: #f8f9fa;
    border-color: #bdc3c7;
    transform: translateY(-1px);
}

.duration-btn.active {
    background: #2d3436;
    border-color: #2d3436;
    color: white;
}

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

.duration-btn:disabled:hover {
    transform: none;
    border-color: #e0e0e0;
}

.transcribe-btn {
    padding: 12px 20px;
    border: 2px solid #667eea;
    background: white;
    color: #667eea;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1em;
    transition: all 0.3s ease;
}

.transcribe-btn:hover {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(102, 126, 234, 0.3);
}

.result-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
}

.control-panel {
    width: 240px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.result-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-bottom: 15px;
    flex-shrink: 0;
    gap: 15px;
}

.result-section h3 {
    margin: 0;
    color: #333;
    flex-shrink: 0;
}

.auto-copy-switch {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.auto-copy-switch input[type="checkbox"] {
    display: none;
}

.auto-copy-switch .slider {
    position: relative;
    width: 44px;
    height: 24px;
    background-color: #ccc;
    border-radius: 24px;
    transition: background-color 0.3s ease;
    margin-right: 8px;
}

.auto-copy-switch .slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    top: 3px;
    background-color: white;
    border-radius: 50%;
    transition: transform 0.3s ease;
}

.auto-copy-switch input[type="checkbox"]:checked + .slider {
    background-color: #2d3436;
}

.auto-copy-switch input[type="checkbox"]:checked + .slider::before {
    transform: translateX(20px);
}

.auto-copy-switch .label-text,
.auto-notify-switch .label-text,
.auto-record-switch .label-text {
    font-size: 1em;
    color: #666;
}

.auto-copy-switch .icon-label,
.auto-notify-switch .icon-label,
.auto-record-switch .icon-label {
    font-size: 1.2em;
    margin-left: 4px;
}

.auto-notify-switch {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.auto-notify-switch input[type="checkbox"] {
    display: none;
}

.auto-notify-switch .slider {
    position: relative;
    width: 44px;
    height: 24px;
    background-color: #ccc;
    border-radius: 24px;
    transition: background-color 0.3s ease;
    margin-right: 8px;
}

.auto-notify-switch .slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    top: 3px;
    background-color: white;
    border-radius: 50%;
    transition: transform 0.3s ease;
}

.auto-notify-switch input[type="checkbox"]:checked + .slider {
    background-color: #2d3436;
}

.auto-notify-switch input[type="checkbox"]:checked + .slider::before {
    transform: translateX(20px);
}

.auto-notify-switch .label-text {
    font-size: 0.9em;
    color: #666;
}

.result-box {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

#transcriptionResult {
    width: 100%;
    height: 100%;
    padding: 20px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1.05em;
    line-height: 1.7;
    font-family: inherit;
    resize: none;
    background: #fafbfc;
    color: #2c3e50;
    overflow-y: auto;
}

#transcriptionResult:focus {
    outline: none;
    border-color: #2d3436;
    background: white;
}

.result-copy-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    padding: 0;
    background: #f8f9fa;
    color: #2d3436;
    border: 1px solid #e0e0e0;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
}

.result-copy-btn:hover:not(:disabled) {
    background: #2d3436;
    color: white;
    border-color: #2d3436;
}

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

.result-copy-btn svg {
    width: 14px;
    height: 14px;
}

.result-copy-btn.success {
    background: #2ecc71;
    color: white;
    border-color: #2ecc71;
}

.result-copy-btn.error {
    background: #f5576c;
    color: white;
    border-color: #f5576c;
}

.result-copy-btn.pending {
    background: #4a9eff;
    color: white;
    border-color: #4a9eff;
}

/* History Expand Button */
.history-expand-btn {
    width: 100%;
    padding: 10px;
    margin-top: 10px;
    background: #f8f9fa;
    color: #999;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    cursor: not-allowed;
    font-size: 0.85em;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.history-expand-btn:not(:disabled) {
    background: #fff;
    color: #2d3436;
    cursor: pointer;
}

.history-expand-btn:not(:disabled):hover {
    background: #f0f0f0;
    border-color: #2d3436;
}

.history-expand-btn .history-icon {
    width: 18px;
    height: 18px;
}

.history-expand-btn .history-count {
    font-weight: 500;
}

.history-expand-btn:disabled {
    opacity: 0.5;
}

/* Old copy button styles - REMOVED
.copy-btn {
    position: absolute !important;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    padding: 0;
    background: #2d3436;
    color: white;
    border: 1px solid #2d3436;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.copy-btn:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(102, 126, 234, 0.3);
}

.copy-btn:active {
    transform: translateY(0);
}
*/

.loading {
    text-align: center;
    padding: 20px;
    color: #667eea;
    min-height: 80px;
}

.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading span {
    display: block;
    margin-top: 10px;
    font-size: 1em;
}

/* 响应式设计 */
@media (max-width: 900px) {
    .main-layout {
        flex-direction: column-reverse;
    }
    
    .control-panel {
        width: 100%;
        flex-direction: row;
        gap: 20px;
    }
    
    .recording-section {
        flex: 0 0 auto;
        margin-bottom: 0;
    }
    
    .playback-section {
        flex: 1;
    }
    
    .button-group {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .result-section {
        min-height: 400px;
    }
}

@media (max-width: 600px) {
    .container {
        padding: 15px;
        height: 95vh;
    }
    
    h1 {
        font-size: 1.4em;
        margin-bottom: 15px;
    }
    
    .control-panel {
        flex-direction: column;
    }
    
    .button-group {
        grid-template-columns: 1fr;
    }
    
    .record-btn {
        width: 80px;
        height: 80px;
    }
    
    .record-btn .btn-icon {
        width: 32px;
        height: 32px;
    }
    
    .recording-time {
        font-size: 1.2em;
    }
}

/* ================================
   History Modal Styles
   ================================ */

.history-btn {
    background: #2d3436;
    color: white;
    border: 1px solid #2d3436;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.2em;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 5px;
    box-shadow: 0 1px 3px rgba(45, 52, 54, 0.15);
}

.history-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(45, 52, 54, 0.25);
    background: #1a1f21;
}
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.history-btn:active {
    transform: translateY(0);
}

.history-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease;
}

.history-modal.show {
    display: flex;
    justify-content: center;
    align-items: center;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.history-modal-content {
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.history-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 25px;
    border-bottom: 2px solid #f0f0f0;
    gap: 15px;
}

.history-modal-header h2 {
    margin: 0;
    font-size: 1.5em;
    color: #333;
    flex: 1;
}

.clear-history-btn {
    background: #ff4757;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 5px;
}

.clear-history-btn:hover {
    background: #ee3344;
    transform: translateY(-1px);
}

.close-history-btn {
    background: #e0e0e0;
    color: #666;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2em;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-history-btn:hover {
    background: #d0d0d0;
    transform: rotate(90deg);
}

.history-list {
    padding: 20px 25px;
    overflow-y: auto;
    flex: 1;
}

.history-empty {
    text-align: center;
    color: #999;
    padding: 40px 20px;
    font-size: 1em;
    line-height: 1.6;
}

.history-item {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 15px;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    animation: fadeInItem 0.3s ease;
}

@keyframes fadeInItem {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.history-item:hover {
    border-color: #2d3436;
    box-shadow: 0 2px 8px rgba(45, 52, 54, 0.12);
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.history-item-time {
    font-size: 0.85em;
    color: #999;
    font-weight: 500;
}

.history-item-copy {
    background: #2d3436;
    color: white;
    border: 1px solid #2d3436;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 5px;
}

.history-item-copy:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(45, 52, 54, 0.2);
    background: #1a1f21;
}

.history-item-copy:active {
    transform: translateY(0);
}

.history-item-text {
    color: #333;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.95em;
    max-height: 150px;
    overflow-y: auto;
    padding: 10px;
    background: white;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.history-item-text::-webkit-scrollbar {
    width: 6px;
}

.history-item-text::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.history-item-text::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.history-item-text::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* Mobile Responsive */
@media (max-width: 600px) {
    .history-modal-content {
        width: 95%;
        max-height: 90vh;
    }
    
    .history-modal-header {
        padding: 15px;
        flex-wrap: wrap;
    }
    
    .history-modal-header h2 {
        font-size: 1.2em;
        width: 100%;
        margin-bottom: 10px;
    }
    
    .clear-history-btn {
        font-size: 0.85em;
        padding: 6px 12px;
    }
    
    .history-list {
        padding: 15px;
    }
    
    .history-item {
        padding: 12px;
    }
    
    .history-item-text {
        font-size: 0.9em;
        max-height: 120px;
    }
}

/* ================================
   SVG Icon Styles
   ================================ */

/* Global SVG icon styling */
svg {
    stroke: currentColor;
    flex-shrink: 0;
}

/* Inline icons (in text/headings) */
.icon-inline {
    vertical-align: middle;
    margin-right: 6px;
}

/* Small icons */
.icon-small {
    width: 36px;
    height: 36px;
}

/* Icon labels in switches */
.icon-label svg {
    display: block;
}

/* Button icons */
button svg {
    stroke: currentColor;
}

/* History Modal header icons */
.history-modal-header h2 {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Ensure SVG icons inherit button colors */
.history-btn svg,
.copy-btn svg,
.cancel-record-btn svg,
.clear-history-btn svg,
.close-history-btn svg {
    stroke: currentColor;
}

/* Audio source label alignment */
.audio-source-selector label {
    display: flex;
    align-items: center;
    justify-content: center;
}
