:root {
    /* 浅色主题 - 高级深绿色调 */
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --text-primary: #1a1a1a;
    --text-secondary: #6d6d6d;
    --accent-color: #2c6e49; /* 高级深绿色 */
    --hover-color: #245c3c;
    --border-color: #eaecef;
    --shadow-color: rgba(0, 0, 0, 0.05);
    --card-bg: #ffffff;
    --error-color: #d63031;
    --icon-color: #555555;
    --history-bg: #f5f7f5; /* 略带绿色的浅灰背景 */
}

[data-theme="dark"] {
    /* 深色主题 - 配合深绿色的暗色调 */
    --bg-primary: #121212;
    --bg-secondary: #1e1e1e;
    --text-primary: #e6e6e6;
    --text-secondary: #a0a0a0;
    --accent-color: #4da375; /* 绿色亮色变体 */
    --hover-color: #3d8c61;
    --border-color: #2c2c2c;
    --shadow-color: rgba(0, 0, 0, 0.2);
    --card-bg: #1e1e1e;
    --error-color: #e84545;
    --icon-color: #bbbbbb;
    --history-bg: #242924;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    transition: all 0.2s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.container {
    background-color: var(--card-bg);
    border-radius: 14px;
    box-shadow: 0 4px 24px var(--shadow-color);
    width: 100%;
    max-width: 480px;
    padding: 32px;
    position: relative;
}

.theme-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    background: var(--bg-secondary);
    border: none;
    color: var(--icon-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    transition: background-color 0.2s, transform 0.2s;
}

.theme-toggle:hover {
    transform: translateY(-2px);
}

.theme-toggle:active {
    transform: translateY(0);
}

.theme-toggle svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

p.subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 28px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 20px;
}

input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.95rem;
}

input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(44, 110, 73, 0.1);
}

/* 发音选择器样式 */
.pronunciation-selector {
    display: flex;
    gap: 10px;
    width: 100%;
}

.pronunciation-option {
    flex: 1;
    position: relative;
}

.pronunciation-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.pronunciation-option label {
    display: flex;
    align-items: center;
    padding: 12px;
    background-color: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pronunciation-option input[type="radio"]:checked + label {
    border-color: var(--accent-color);
    background-color: rgba(44, 110, 73, 0.05);
}

.pronunciation-option label:hover {
    border-color: var(--accent-color);
}

.option-icon {
    font-size: 1.5rem;
    margin-right: 12px;
}

.option-info {
    display: flex;
    flex-direction: column;
    text-align: left;
}

.option-name {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.option-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.pronunciation-option input[type="radio"]:focus + label {
    box-shadow: 0 0 0 3px rgba(44, 110, 73, 0.1);
}

/* 添加选中标记 */
.pronunciation-option input[type="radio"]:checked + label::after {
    content: "";
    position: absolute;
    top: 14px;
    right: 14px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--accent-color);
}

button#download-btn {
    width: 100%;
    padding: 14px 16px;
    background-color: var(--accent-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

button#download-btn:hover {
    background-color: var(--hover-color);
}

button#download-btn:active {
    transform: translateY(1px);
}

#error-message {
    color: var(--error-color);
    font-size: 0.85rem;
    margin-top: 12px;
    text-align: center;
    min-height: 20px;
}

#audio-container {
    margin-top: 20px;
    width: 100%;
}

audio {
    width: 100%;
    height: 36px;
    margin-top: 4px;
    border-radius: 8px;
}

.recent-searches {
    margin-top: 32px;
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
}

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

.history-header h2 {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.history-header h2 svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
}

.history-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toggle-history, .clear-history {
    background: none;
    border: none;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.2s, transform 0.2s;
}

.toggle-history {
    color: var(--accent-color);
    font-size: 0.85rem;
    padding: 4px 8px;
}

.toggle-history:hover {
    background-color: rgba(44, 110, 73, 0.1);
}

.clear-history {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    color: var(--text-secondary);
}

.clear-history:hover {
    color: var(--error-color);
    background-color: rgba(214, 48, 49, 0.1);
}

.clear-history svg {
    width: 16px;
    height: 16px;
}

#history-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 176px; /* 显示约3个项目的高度 */
    overflow-y: auto;
    overflow-x: hidden; /* 禁用水平滚动条 */
    transition: max-height 0.3s ease;
    width: 100%; /* 确保宽度正确 */
}

#history-list.expanded {
    max-height: 440px; /* 足够显示10个项目 */
}

/* 自定义滚动条 - 只保留垂直滚动条 */
#history-list::-webkit-scrollbar {
    width: 6px;
    height: 0; /* 移除水平滚动条 */
}

#history-list::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 10px;
}

#history-list::-webkit-scrollbar-thumb {
    background: var(--text-secondary);
    border-radius: 10px;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background-color: var(--history-bg);
    border-radius: 8px;
    transition: transform 0.1s;
    width: 100%;
    box-sizing: border-box;
}

.history-item:hover {
    transform: translateY(-2px);
}

.history-text-container {
    display: flex;
    align-items: baseline;
    max-width: calc(100% - 40px); /* 为播放按钮留出空间 */
    overflow: hidden; /* 防止文本溢出 */
    text-overflow: ellipsis; /* 文本过长时显示省略号 */
    white-space: nowrap; /* 防止文本换行 */
}

.history-item-text {
    font-size: 0.9rem;
    color: var(--text-primary);
}

.history-item-type {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-left: 4px;
    flex-shrink: 0; /* 防止类型标签被压缩 */
}

.history-item-play {
    background: transparent;
    border: none;
    color: var(--accent-color);
    cursor: pointer;
    width: 32px;
    height: 32px;
    min-width: 32px; /* 确保按钮不会被压缩 */
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
    flex-shrink: 0; /* 防止按钮被压缩 */
}

.history-item-play:hover {
    background-color: rgba(44, 110, 73, 0.1);
}

.history-item-play svg {
    width: 18px;
    height: 18px;
    fill: var(--accent-color);
    stroke: none;
}

footer {
    margin-top: 32px;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* 加载动画 */
@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-icon {
    animation: spin 1.5s linear infinite;
    display: inline-block;
}

/* 确认对话框样式 */
.confirm-dialog {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.confirm-dialog-content {
    background-color: var(--card-bg);
    border-radius: 12px;
    padding: 24px;
    max-width: 320px;
    width: 90%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    animation: dialogFadeIn 0.25s ease-out;
}

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

.confirm-dialog h3 {
    margin-bottom: 16px;
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 600;
}

.confirm-dialog p {
    margin-bottom: 24px;
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.5;
}

.confirm-dialog-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.confirm-dialog-btn {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    border: none;
    transition: all 0.15s ease;
}

.confirm-cancel {
    background-color: var(--bg-secondary);
    color: var(--text-secondary);
}

.confirm-cancel:hover {
    background-color: var(--border-color);
}

.confirm-delete {
    background-color: var(--error-color);
    color: white;
}

.confirm-delete:hover {
    background-color: #c42c2c;
}

/* 响应式调整 */
@media (max-width: 480px) {
    .container {
        padding: 24px 20px;
        border-radius: 12px;
    }
    
    .confirm-dialog-content {
        padding: 20px;
    }
}

@media (max-width: 400px) {
    .pronunciation-selector {
        flex-direction: column;
    }
    
    .option-icon {
        font-size: 1.25rem;
    }
}

