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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 5px;
    overflow-y: auto;
    overflow-x: hidden;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

/* 结果页面使用全宽容器 */
.container.wide {
    max-width: 95%;
}

.header {
    background: white;
    padding: 12px 15px;
    border-radius: 6px 6px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.header h1 {
    font-size: 20px;
    color: #333;
}

.logout-btn, .back-btn {
    background: #f44336;
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
}

.back-btn {
    background: #2196F3;
}

.logout-btn:hover, .back-btn:hover {
    opacity: 0.9;
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.login-box h1 {
    text-align: center;
    margin-bottom: 30px;
    color: #667eea;
    font-size: 28px;
}

.login-box input {
    width: 100%;
    padding: 15px;
    margin-bottom: 15px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 16px;
}

.login-box button {
    width: 100%;
    padding: 15px;
    margin-bottom: 10px;
    border: none;
    border-radius: 5px;
    background: #667eea;
    color: white;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.3s;
}

.login-box button:hover {
    background: #5568d3;
}

.login-box button.secondary {
    background: #f5f5f5;
    color: #666;
}

.login-box button.secondary:hover {
    background: #e0e0e0;
}

.service-list {
    background: white;
    padding: 20px;
    border-radius: 0 0 10px 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.service-item {
    background: #f9f9f9;
    padding: 20px;
    margin-bottom: 15px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    border: 2px solid transparent;
}

.service-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    border-color: #667eea;
}

.service-item h3 {
    color: #333;
    margin-bottom: 10px;
    font-size: 20px;
}

.service-item p {
    color: #666;
    margin-bottom: 10px;
    font-size: 14px;
}

.service-item .price {
    color: #f44336;
    font-size: 24px;
    font-weight: bold;
}

.fortune-box {
    background: white;
    padding: 10px;
    border-radius: 0 0 6px 6px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.input-section, .payment-section, .result-section {
    margin-bottom: 15px;
}

.fortune-box h3 {
    color: #333;
    margin-bottom: 10px;
    font-size: 16px;
}

.fortune-box textarea {
    width: 100%;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
    resize: vertical;
}

.fortune-box button {
    width: 100%;
    padding: 15px;
    margin-bottom: 10px;
    border: none;
    border-radius: 5px;
    background: #667eea;
    color: white;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.3s;
}

.fortune-box button:hover {
    background: #5568d3;
}

.fortune-box button.secondary {
    background: #4CAF50;
}

.fortune-box button.secondary:hover {
    background: #45a049;
}

.fortune-result {
    background: linear-gradient(to bottom, #ffffff 0%, #f8f9fa 100%);
    padding: 20px;
    border-radius: 8px;
    line-height: 1.9;
    color: #2c3e50;
    font-size: 15px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border: 1px solid #e8e8e8;
}

/* Markdown 样式优化 */
.fortune-result h1,
.fortune-result h2,
.fortune-result h3 {
    color: #667eea;
    font-weight: 600;
    line-height: 1.3;
}

.fortune-result h1 {
    font-size: 24px;
    margin: 20px 0 16px 0;
    padding-bottom: 10px;
    border-bottom: 3px solid #667eea;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.fortune-result h2 {
    font-size: 20px;
    margin: 18px 0 14px 0;
    padding-left: 12px;
    border-left: 4px solid #667eea;
    background: #f0f4ff;
    padding: 10px 12px;
    border-radius: 4px;
}

.fortune-result h3 {
    font-size: 18px;
    margin: 16px 0 12px 0;
    padding-left: 10px;
    border-left: 3px solid #a8b3ea;
}

.fortune-result p {
    margin-bottom: 12px;
    text-align: justify;
}

.fortune-result ul,
.fortune-result ol {
    margin-left: 20px;
    margin-bottom: 12px;
    padding-left: 8px;
}

.fortune-result li {
    margin-bottom: 8px;
    padding-left: 4px;
    position: relative;
}

.fortune-result ul li::before {
    content: '▸';
    color: #667eea;
    font-weight: bold;
    position: absolute;
    left: -16px;
}

.fortune-result strong {
    color: #764ba2;
    font-weight: 600;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.fortune-result em {
    color: #555;
    font-style: italic;
}

.fortune-result code {
    background: #f0f0f0;
    padding: 3px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    color: #e83e8c;
    border: 1px solid #e0e0e0;
}

.fortune-result blockquote {
    border-left: 4px solid #667eea;
    padding: 12px 16px;
    margin: 14px 0;
    background: #f8f9ff;
    color: #555;
    font-style: italic;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.1);
}

.fortune-result hr {
    border: none;
    height: 2px;
    background: linear-gradient(to right, transparent, #667eea, transparent);
    margin: 20px 0;
}

/* 给第一段添加特殊样式 */
.fortune-result > p:first-of-type {
    font-size: 16px;
    font-weight: 500;
    color: #667eea;
    padding: 12px;
    background: #f0f4ff;
    border-radius: 6px;
    border-left: 4px solid #667eea;
}

.loading {
    text-align: center;
    padding: 20px;
    color: #666;
}

.error {
    color: #f44336;
    padding: 10px;
    background: #ffebee;
    border-radius: 5px;
    margin-bottom: 15px;
}

/* 加载动画 */
.loading-dots {
    font-size: 18px;
    color: #667eea;
    text-align: center;
}

.loading-dots span {
    animation: loadingDot 1.4s infinite;
    animation-fill-mode: both;
}

.loading-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.loading-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes loadingDot {
    0%, 80%, 100% {
        opacity: 0;
    }
    40% {
        opacity: 1;
    }
}

/* 流式文本容器 */
#streamResult {
    max-height: none;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0;
    line-height: 1.9;
    font-size: 15px;
    color: #2c3e50;
    width: 100%;
    box-sizing: border-box;
}

/* 为 streamResult 应用相同的 markdown 样式 */
#streamResult h1,
#streamResult h2,
#streamResult h3,
#streamResult h4,
#streamResult h5,
#streamResult h6 {
    color: #667eea;
    font-weight: 600;
    margin: 1em 0 0.5em;
    line-height: 1.4;
}

#streamResult h1 { font-size: 1.8em; }
#streamResult h2 { font-size: 1.5em; }
#streamResult h3 { font-size: 1.3em; }
#streamResult h4 { font-size: 1.1em; }
#streamResult h5 { font-size: 1em; }
#streamResult h6 { font-size: 0.9em; }

#streamResult p {
    margin: 0.8em 0;
    line-height: 1.8;
    text-align: left;
}

#streamResult strong {
    color: #764ba2;
    font-weight: 600;
}

#streamResult em {
    color: #667eea;
    font-style: italic;
}

#streamResult ul,
#streamResult ol {
    margin: 1em 0;
    padding-left: 2em;
}

#streamResult li {
    margin: 0.5em 0;
    line-height: 1.7;
}

#streamResult blockquote {
    margin: 1em 0;
    padding: 0.8em 1em;
    border-left: 4px solid #667eea;
    background: rgba(102, 126, 234, 0.05);
    border-radius: 4px;
    color: #555;
}

#streamResult hr {
    border: none;
    height: 1px;
    background: linear-gradient(90deg, transparent, #667eea, transparent);
    margin: 1.5em 0;
}

#streamResult code {
    background: #f0f4ff;
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 0.9em;
    color: #764ba2;
}

#streamResult pre {
    background: #1e1e2e;
    padding: 1em;
    border-radius: 6px;
    overflow-x: auto;
    margin: 1em 0;
}

#streamResult pre code {
    background: transparent;
    color: #e2e2f0;
    padding: 0;
}

#streamResult::-webkit-scrollbar {
    width: 8px;
}

#streamResult::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

#streamResult::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 4px;
}

#streamResult::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #5568d3 0%, #6a3f8f 100%);
}

/* 响应式设计 */
@media (max-width: 768px) {
    body {
        padding: 3px;
    }

    .container {
        max-width: 100%;
    }

    .container.wide {
        max-width: 100%;
    }

    .fortune-result,
    #streamResult {
        padding: 12px;
        font-size: 14px;
        line-height: 1.6;
    }

    .header {
        padding: 10px 12px;
    }

    .header h1 {
        font-size: 18px;
    }

    .fortune-box {
        padding: 8px;
    }

    .fortune-box h3 {
        font-size: 15px;
        margin-bottom: 8px;
    }

    .input-section, .payment-section, .result-section {
        margin-bottom: 12px;
    }

    .fortune-result h1 {
        font-size: 20px;
        margin-top: 12px;
        margin-bottom: 8px;
    }

    .fortune-result h2 {
        font-size: 18px;
        margin-top: 10px;
        margin-bottom: 8px;
    }

    .fortune-result h3 {
        font-size: 16px;
        margin-top: 10px;
        margin-bottom: 6px;
    }

    .fortune-result p {
        margin-bottom: 8px;
    }

    .fortune-result ul,
    .fortune-result ol {
        margin-left: 15px;
        margin-bottom: 8px;
    }

    .fortune-result li {
        margin-bottom: 4px;
    }
}
