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

:root {
    --primary-color: #e74c3c;
    --primary-dark: #c0392b;
    --secondary-color: #3498db;
    --background-color: #f5f5f5;
    --card-background: #ffffff;
    --text-color: #333333;
    --text-light: #666666;
    --border-color: #e0e0e0;
    --success-color: #27ae60;
    --warning-color: #f39c12;
}

body {
    font-family: 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', 'Noto Sans JP', 'Yu Gothic', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--text-color);
    line-height: 1.6;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    padding: 30px 0;
    color: white;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

header .subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
}

main {
    background: var(--card-background);
    border-radius: 16px;
    padding: 30px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

/* 设置区域 */
.settings-section {
    margin-bottom: 25px;
}

.settings-section details {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
}

.settings-section summary {
    cursor: pointer;
    font-weight: bold;
    color: var(--text-color);
    outline: none;
}

.settings-content {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
}

.setting-item {
    margin-bottom: 15px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.setting-item label {
    flex: 0 0 180px;
    font-size: 0.9rem;
    color: var(--text-light);
}

.setting-item input,
.setting-item select {
    flex: 1;
    min-width: 200px;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.9rem;
}

.setting-item input:focus,
.setting-item select:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.help-link {
    font-size: 0.8rem;
    color: var(--secondary-color);
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.8rem;
    background: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.3s;
}

.btn-small:hover {
    background: #2980b9;
}

/* 输入区域 */
.input-section {
    margin-bottom: 25px;
}

.input-section label {
    display: block;
    margin-bottom: 10px;
    font-weight: bold;
    color: var(--text-color);
}

.input-section textarea {
    width: 100%;
    padding: 15px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 1.1rem;
    resize: vertical;
    transition: border-color 0.3s, box-shadow 0.3s;
    font-family: inherit;
}

.input-section textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(231, 76, 60, 0.1);
}

.button-group {
    display: flex;
    gap: 15px;
    margin-top: 15px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: bold;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(231, 76, 60, 0.4);
}

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

.btn-secondary {
    background: #ecf0f1;
    color: var(--text-color);
}

.btn-secondary:hover {
    background: #dfe6e9;
}

/* 结果区域 */
.result-section {
    background: #fafafa;
    border-radius: 12px;
    padding: 25px;
    border: 1px solid var(--border-color);
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.result-header h2 {
    color: var(--text-color);
    font-size: 1.3rem;
}

.audio-controls {
    display: flex;
    gap: 10px;
}

.btn-play {
    background: linear-gradient(135deg, var(--success-color), #219a52);
    color: white;
    padding: 10px 20px;
}

.btn-play:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(39, 174, 96, 0.3);
}

.btn-stop {
    background: #95a5a6;
    color: white;
    padding: 10px 20px;
}

.btn-stop:hover:not(:disabled) {
    background: #7f8c8d;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* 假名显示 */
.furigana-display {
    font-size: 1.4rem;
    line-height: 2.5;
    padding: 20px;
    background: white;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin-bottom: 15px;
}

.furigana-display ruby {
    ruby-align: center;
}

.furigana-display rt {
    font-size: 0.6em;
    color: var(--primary-color);
    font-weight: normal;
}

.plain-text {
    font-size: 0.9rem;
    color: var(--text-light);
    padding: 10px;
    background: #f0f0f0;
    border-radius: 6px;
}

.plain-text::before {
    content: "原文: ";
    font-weight: bold;
}

/* 加载动画 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-overlay p {
    color: white;
    margin-top: 15px;
    font-size: 1.1rem;
}

/* Footer */
footer {
    text-align: center;
    padding: 20px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
}

/* 响应式设计 */
@media (max-width: 600px) {
    .container {
        padding: 10px;
    }

    header h1 {
        font-size: 1.8rem;
    }

    main {
        padding: 20px;
    }

    .button-group {
        flex-direction: column;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }

    .setting-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .setting-item label {
        flex: none;
    }

    .setting-item input,
    .setting-item select {
        width: 100%;
    }

    .result-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .audio-controls {
        width: 100%;
    }

    .audio-controls .btn {
        flex: 1;
    }
}

/* 动画效果 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-section {
    animation: fadeIn 0.3s ease;
}

/* 消息提示 */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    z-index: 1001;
    animation: slideUp 0.3s ease;
}

.toast.success {
    background: var(--success-color);
}

.toast.error {
    background: var(--primary-color);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translate(-50%, 20px);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}
