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

body {
    font-family: 'Microsoft YaHei', 'PingFang SC', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 40px;
}

header {
    text-align: center;
    margin-bottom: 40px;
}

header h1 {
    color: #333;
    font-size: 2.5em;
    margin-bottom: 10px;
}

.subtitle {
    color: #666;
    font-size: 1.1em;
}

.input-section {
    margin-bottom: 30px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #333;
    font-weight: 600;
    font-size: 1.1em;
}

.form-group textarea,
.form-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1em;
    font-family: inherit;
    transition: border-color 0.3s;
}

.form-group textarea:focus,
.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

.btn {
    padding: 14px 30px;
    border: none;
    border-radius: 8px;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    width: 100%;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

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

.loading {
    text-align: center;
    padding: 40px;
}

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

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

.hidden {
    display: none;
}

.story-section {
    margin-top: 40px;
    padding-top: 30px;
    border-top: 2px solid #e0e0e0;
}

.story-section h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.8em;
}

.story-content {
    background: #f8f9fa;
    padding: 30px;
    border-radius: 12px;
    line-height: 2.5;
    font-size: 1.2em;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.story-content .line {
    margin-bottom: 8px;
    display: block;
}

.story-content .pinyin-line {
    color: #667eea;
    font-weight: 500;
    font-size: 1.1em;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.story-content .pinyin-line:hover {
    background-color: rgba(102, 126, 234, 0.1);
}

.story-content .hanzi-line {
    color: #333;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.story-content .hanzi-line:hover {
    background-color: rgba(102, 126, 234, 0.1);
}

.character-line {
    line-height: 1.8;
}

.char-unit {
    position: relative;
    min-width: 1.5em;
    text-align: center;
}

.pinyin-char {
    display: block;
    line-height: 1.2;
    margin-bottom: 2px;
    font-weight: 500;
}

.hanzi-char {
    display: block;
    line-height: 1.2;
    font-weight: normal;
}

.char-unit .pinyin-char.clicked,
.char-unit .hanzi-char.clicked {
    background-color: #fff3cd !important;
    border: 2px solid #ffc107 !important;
    font-weight: bold !important;
    text-decoration: none !important;
    opacity: 1 !important;
    border-radius: 3px;
    padding: 2px 4px;
}

/* 继续生成区域样式 */
.continue-section {
    margin-top: 40px;
    padding-top: 30px;
}

.continue-divider {
    height: 2px;
    background: linear-gradient(to right, transparent, #e0e0e0, transparent);
    margin-bottom: 30px;
}

/* 导入故事区域样式 */
.import-section {
    margin-top: 40px;
    padding-top: 30px;
}

.import-divider {
    height: 2px;
    background: linear-gradient(to right, transparent, #e0e0e0, transparent);
    margin-bottom: 30px;
}

.import-section h3 {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.5em;
    text-align: center;
}

.import-section .form-group {
    margin-bottom: 20px;
}

.import-section textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1em;
    font-family: inherit;
    resize: vertical;
    min-height: 120px;
    box-sizing: border-box;
}

.import-section textarea:focus {
    outline: none;
    border-color: #667eea;
}

.import-section input[type="text"] {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1em;
    font-family: inherit;
    box-sizing: border-box;
}

.import-section input[type="text"]:focus {
    outline: none;
    border-color: #667eea;
}

.continue-section h3 {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.5em;
    text-align: center;
}

.continue-input {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 12px;
    margin-top: 20px;
}

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

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(108, 117, 125, 0.4);
}

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

@media (max-width: 600px) {
    .button-group {
        flex-direction: column;
    }
    
    .button-group .btn {
        width: 100%;
    }
}

/* 电脑端选择工具栏 */
.desktop-selection {
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.selection-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.selection-hint {
    color: #666;
    font-size: 0.95em;
    margin-right: 10px;
}

.btn-small {
    padding: 8px 16px;
    font-size: 0.9em;
}

.btn-small.active {
    background: #667eea;
    color: white;
    box-shadow: 0 2px 5px rgba(102, 126, 234, 0.3);
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover {
    background: #218838;
}

.btn-success:disabled {
    background: #6c757d;
    cursor: not-allowed;
    opacity: 0.6;
}

/* 选中状态 */
.char-unit .pinyin-char.selected,
.char-unit .hanzi-char.selected {
    background-color: #fff3cd !important;
    border: 2px solid #ffc107 !important;
    box-shadow: 0 2px 4px rgba(255, 193, 7, 0.3);
}

.char-unit .pinyin-char.saved,
.char-unit .hanzi-char.saved {
    background-color: #d4edda !important;
    border: 2px solid #28a745 !important;
    opacity: 0.8;
}

/* 二维码区域样式 */
.qrcode-section {
    margin: 30px 0;
    padding: 30px;
    background: #f8f9fa;
    border-radius: 12px;
    text-align: center;
}

.qrcode-container h3 {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.5em;
}

.qrcode {
    display: inline-block;
    padding: 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    margin: 20px 0;
}

.qrcode-url {
    margin-top: 15px;
    font-size: 1.1em;
    color: #667eea;
    font-weight: 600;
    word-break: break-all;
}

.qrcode-hint {
    margin-top: 15px;
    color: #666;
    font-size: 0.9em;
}

.alternative-urls {
    margin-top: 10px;
}

.alt-url {
    font-size: 0.95em;
    padding: 5px 10px;
    background: #e9ecef;
    border-radius: 5px;
    display: inline-block;
    margin: 5px 5px 5px 0;
    transition: background-color 0.2s;
}

.alt-url:hover {
    background: #dee2e6;
}

.qrcode-url {
    cursor: pointer;
    transition: color 0.2s;
}

.qrcode-url:hover {
    color: #764ba2;
    text-decoration: underline;
}

.troubleshooting {
    margin-top: 20px;
    text-align: left;
}

.troubleshooting details {
    cursor: pointer;
}

.troubleshooting summary {
    color: #667eea;
    font-weight: 500;
    padding: 10px;
    background: #f0f0f0;
    border-radius: 5px;
}

.troubleshooting summary:hover {
    background: #e0e0e0;
}

.story-content .clicked {
    background-color: #fff3cd !important;
    border: 2px solid #ffc107 !important;
    font-weight: bold !important;
    text-decoration: none !important;
    opacity: 1 !important;
    border-radius: 3px;
    padding: 2px 4px;
}

.review-section {
    margin-top: 30px;
    padding-top: 30px;
    border-top: 2px solid #e0e0e0;
}

.review-section h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.5em;
}

.review-words {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.review-word {
    background: #fff3cd;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 1em;
    border: 2px solid #ffc107;
}

.message {
    padding: 12px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-weight: 500;
}

.message.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.message.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.streaming-content {
    color: #333;
    line-height: 2;
    font-size: 1.2em;
    white-space: pre-wrap;
    word-wrap: break-word;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 12px;
    min-height: 100px;
}

.streaming-content::after {
    content: '▋';
    animation: blink 1s infinite;
    color: #667eea;
    margin-left: 2px;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

