/* ==================== 基础重置与变量 ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #8E2DE2;
    --secondary-color: #4A00E0;
    --accent-color: #00c6ff;
    --bg-dark: #0f0c29;
    --bg-medium: #302b63;
    --bg-light: #24243e;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0c0;
    --gold: #ffd700;
    --border-radius: 15px;
    --sidebar-width: 280px;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Noto Serif SC', serif;
    background: linear-gradient(135deg, var(--bg-dark) 0%, var(--bg-medium) 50%, var(--bg-light) 100%);
    color: var(--text-primary);
}

/* ==================== 星空背景动画 ==================== */
.stars, .twinkling {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    display: block;
    pointer-events: none;
}

.stars {
    background: transparent url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 200"><circle fill="%23fff" cx="25" cy="25" r="1"/><circle fill="%23fff" cx="75" cy="75" r="0.5"/><circle fill="%23fff" cx="125" cy="45" r="1.2"/><circle fill="%23fff" cx="175" cy="125" r="0.8"/><circle fill="%23fff" cx="50" cy="150" r="1"/><circle fill="%23fff" cx="150" cy="175" r="0.6"/><circle fill="%23fff" cx="100" cy="100" r="1.5"/><circle fill="%23fff" cx="25" cy="175" r="0.7"/><circle fill="%23fff" cx="175" cy="25" r="1.1"/></svg>') repeat;
    background-size: 200px 200px;
    z-index: 0;
    animation: move-stars 100s linear infinite;
}

.twinkling {
    background: transparent url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 300"><circle fill="%23ffffff88" cx="50" cy="50" r="1"/><circle fill="%23ffffff66" cx="150" cy="100" r="0.8"/><circle fill="%23ffffffaa" cx="250" cy="200" r="1.2"/><circle fill="%23ffffff55" cx="100" cy="250" r="0.6"/></svg>') repeat;
    background-size: 300px 300px;
    z-index: 1;
    animation: move-twinkling 50s linear infinite;
    opacity: 0.5;
}

@keyframes move-stars {
    from { transform: translateY(0); }
    to { transform: translateY(-200px); }
}

@keyframes move-twinkling {
    from { transform: translateX(0); }
    to { transform: translateX(-300px); }
}

/* ==================== 侧边栏样式 ==================== */
.sidebar {
    position: fixed;
    left: calc(-1 * var(--sidebar-width) - 20px);
    top: 0;
    width: var(--sidebar-width);
    height: 100%;
    background: rgba(15, 12, 41, 0.98);
    backdrop-filter: blur(20px);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: left 0.3s ease;
    border-right: 1px solid rgba(142, 45, 226, 0.3);
}

.sidebar.active {
    left: 0;
}

.sidebar-header {
    display: flex;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    gap: 10px;
}

.sidebar-logo {
    font-size: 1.8rem;
}

.sidebar-header h2 {
    flex: 1;
    font-family: 'Ma Shan Zheng', cursive;
    font-size: 1.5rem;
    color: var(--gold);
}

.sidebar-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 5px;
    transition: color 0.3s;
}

.sidebar-close:hover {
    color: var(--primary-color);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

.sidebar-category {
    margin-bottom: 20px;
}

.sidebar-category h3 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.1);
}

.sidebar-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 15px;
    background: rgba(142, 45, 226, 0.1);
    border: 1px solid rgba(142, 45, 226, 0.2);
    border-radius: 10px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
}

.sidebar-btn:hover {
    background: rgba(142, 45, 226, 0.3);
    transform: translateX(5px);
    border-color: var(--primary-color);
}

.sidebar-btn:active {
    transform: translateX(5px) scale(0.98);
}

.btn-icon {
    font-size: 1.2rem;
}

.btn-text {
    font-size: 0.95rem;
}

.sidebar-footer {
    padding: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.author-card {
    background: rgba(255, 255, 255, 0.05);
    padding: 12px;
    border-radius: 10px;
    font-size: 0.8rem;
    text-align: center;
}

.author-card p {
    margin: 3px 0;
    color: var(--text-secondary);
}

.author-card strong {
    color: var(--gold);
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ==================== 主容器 ==================== */
.main-container {
    position: relative;
    z-index: 10;
    height: 100%;
    display: flex;
    flex-direction: column;
    max-width: 900px;
    margin: 0 auto;
}

/* ==================== 顶部导航 ==================== */
.top-nav {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    background: rgba(15, 12, 41, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(142, 45, 226, 0.3);
}

.menu-btn, .clear-btn {
    background: rgba(142, 45, 226, 0.2);
    border: none;
    color: var(--text-primary);
    font-size: 1.3rem;
    padding: 10px 15px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.menu-btn:hover, .clear-btn:hover {
    background: rgba(142, 45, 226, 0.4);
}

.nav-title {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.nav-logo {
    font-size: 1.5rem;
    animation: float 3s ease-in-out infinite;
}

.master-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    box-shadow: 0 0 20px rgba(142, 45, 226, 0.6), 0 0 40px rgba(142, 45, 226, 0.3);
    animation: float 3s ease-in-out infinite, glow 2s ease-in-out infinite alternate;
    border: 2px solid rgba(255, 215, 0, 0.5);
}

@keyframes glow {
    from { box-shadow: 0 0 20px rgba(142, 45, 226, 0.6), 0 0 40px rgba(142, 45, 226, 0.3); }
    to { box-shadow: 0 0 25px rgba(255, 215, 0, 0.5), 0 0 50px rgba(142, 45, 226, 0.5); }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.nav-title h1 {
    font-family: 'Ma Shan Zheng', cursive;
    font-size: 1.8rem;
    background: linear-gradient(to right, var(--gold), #fff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ==================== 聊天区域 ==================== */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.message {
    display: flex;
    gap: 12px;
    animation: fadeIn 0.4s ease;
}

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

.message.user {
    flex-direction: row-reverse;
}

.avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
    position: relative;
}

.message.assistant .avatar {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    box-shadow: 0 0 15px rgba(142, 45, 226, 0.5);
}

.message.user .avatar {
    background: linear-gradient(135deg, var(--accent-color), #0072ff);
}

.message-content {
    max-width: 80%;
    padding: 15px 18px;
    border-radius: var(--border-radius);
    backdrop-filter: blur(10px);
}

.message.assistant .message-content {
    background: rgba(142, 45, 226, 0.12);
    border: 1px solid rgba(142, 45, 226, 0.25);
    border-left: 4px solid var(--primary-color);
}

.message.user .message-content {
    background: rgba(0, 198, 255, 0.1);
    border: 1px solid rgba(0, 198, 255, 0.25);
    border-right: 4px solid var(--accent-color);
}

.message-header {
    font-weight: bold;
    margin-bottom: 10px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.message-text {
    line-height: 1.9;
    font-size: 0.95rem;
}

.message-text p {
    margin-bottom: 12px;
}

.message-text p:last-child {
    margin-bottom: 0;
}

.message-text ul, .message-text ol {
    margin: 10px 0;
    padding-left: 20px;
}

.message-text li {
    margin: 6px 0;
}

.message-text strong {
    color: var(--gold);
}

.message-text mark {
    background: linear-gradient(120deg, rgba(142, 45, 226, 0.4) 0%, rgba(74, 0, 224, 0.4) 100%);
    color: #fff;
    padding: 2px 8px;
    border-radius: 5px;
    font-weight: 500;
}

/* 吉凶样式 */
.luck-great {
    color: #ffd700;
    font-weight: bold;
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.5);
}

.luck-good {
    color: #90EE90;
    font-weight: bold;
}

.luck-small {
    color: #98FB98;
}

.luck-bad {
    color: #ff6b6b;
    font-weight: bold;
    text-shadow: 0 0 8px rgba(255, 107, 107, 0.5);
}

.luck-medium-bad {
    color: #ff9999;
}

.luck-small-bad {
    color: #ffb3b3;
}

/* 五行颜色 */
.wuxing-金 { color: #FFD700; font-weight: 500; }
.wuxing-木 { color: #90EE90; font-weight: 500; }
.wuxing-水 { color: #87CEEB; font-weight: 500; }
.wuxing-火 { color: #FF6B6B; font-weight: 500; }
.wuxing-土 { color: #DEB887; font-weight: 500; }

/* 列表项样式 */
.list-item {
    padding-left: 10px;
    margin: 6px 0;
    display: flex;
    align-items: flex-start;
    gap: 5px;
}

.list-num {
    color: var(--accent-color);
    font-weight: bold;
    min-width: 20px;
}

/* 标题图标 */
.title-icon {
    color: var(--gold);
    margin-right: 5px;
}

.message-text .highlight {
    background: linear-gradient(120deg, rgba(255, 215, 0, 0.2) 0%, rgba(255, 215, 0, 0.1) 100%);
    border-left: 3px solid var(--gold);
    padding: 10px 15px;
    margin: 10px 0;
    border-radius: 0 10px 10px 0;
}

.message-text .section-title {
    color: var(--accent-color);
    font-weight: bold;
    font-size: 1.05rem;
    margin: 15px 0 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.message-text .divination-result {
    background: rgba(255, 255, 255, 0.05);
    border: 1px dashed rgba(142, 45, 226, 0.4);
    padding: 12px 15px;
    border-radius: 10px;
    margin: 10px 0;
}

.fortune-saying {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.15) 0%, rgba(255, 215, 0, 0.05) 100%);
    border: 1px solid rgba(255, 215, 0, 0.3);
    padding: 12px 15px;
    border-radius: 10px;
    margin-top: 15px;
    color: var(--gold);
    font-style: italic;
}

/* ==================== 输入区域 ==================== */
.input-section {
    padding: 15px 20px;
    background: rgba(15, 12, 41, 0.8);
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(142, 45, 226, 0.2);
}

.input-wrapper {
    display: flex;
    gap: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 25px;
    padding: 8px 15px;
    border: 2px solid rgba(142, 45, 226, 0.3);
    transition: all 0.3s ease;
}

.input-wrapper:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 20px rgba(142, 45, 226, 0.3);
}

.input-wrapper textarea {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    resize: none;
    outline: none;
    max-height: 120px;
    line-height: 1.5;
}

.input-wrapper textarea::placeholder {
    color: var(--text-secondary);
}

.send-btn {
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    font-size: 1.4rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.send-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 0 25px rgba(142, 45, 226, 0.6);
}

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

/* ==================== 底部信息 ==================== */
.bottom-info {
    text-align: center;
    padding: 10px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    background: rgba(15, 12, 41, 0.5);
}

.bottom-info strong {
    color: var(--accent-color);
}

/* ==================== 加载动画 ==================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 12, 41, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.loading-overlay.active {
    display: flex;
}

.loading-content {
    text-align: center;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(142, 45, 226, 0.2);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-content p {
    color: var(--text-secondary);
    font-style: italic;
}

/* ==================== 响应式设计 ==================== */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 80vw;
    }
    
    .sidebar {
        left: -100%;
        width: 80vw;
        max-width: 300px;
        box-shadow: 5px 0 25px rgba(0, 0, 0, 0.8);
        z-index: 2001;
        border-right: 1px solid rgba(142, 45, 226, 0.2);
        padding-bottom: env(safe-area-inset-bottom, 0);
    }
    
    .sidebar.active {
        left: 0;
    }
    
    .sidebar-content {
        flex: 1;
        overflow-y: auto;
        padding: 10px;
        padding-bottom: 20px;
        -webkit-overflow-scrolling: touch;
    }
    
    .sidebar-footer {
        padding: 10px;
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 0));
        flex-shrink: 0;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .author-card {
        padding: 10px;
        font-size: 0.75rem;
    }
    
    .author-card p {
        margin: 2px 0;
    }
    
    /* 侧边栏遮罩层 */
    .sidebar-overlay {
        display: block;
        z-index: 2000;
        background: rgba(0, 0, 0, 0.7);
        backdrop-filter: blur(5px);
    }
    
    .sidebar-overlay.active {
        opacity: 1;
        visibility: visible;
    }
    
    .top-nav {
        padding: 12px 15px;
        z-index: 100;
        position: relative;
    }
    
    .nav-title h1 {
        font-size: 1.5rem;
    }
    
    .menu-btn, .clear-btn {
        padding: 8px 12px;
        font-size: 1.2rem;
    }
    
    .chat-container {
        padding: 15px 10px;
        gap: 15px;
        overflow-x: hidden;
    }
    
    .message {
        gap: 8px;
        padding-left: 0;
    }
    
    .avatar {
        display: none !important;
    }
    
    .message-content {
        max-width: 100%;
        padding: 12px 14px;
    }
    
    .message-text {
        font-size: 0.9rem;
        line-height: 1.8;
    }
    
    .input-section {
        padding: 12px 15px;
    }
    
    .input-wrapper {
        padding: 6px 12px;
    }
    
    .input-wrapper textarea {
        font-size: 0.95rem;
    }
    
    .send-btn {
        width: 44px;
        height: 44px;
        font-size: 1.2rem;
    }
    
    .sidebar-btn {
        padding: 10px 12px;
    }
    
    .btn-text {
        font-size: 0.9rem;
    }
    
    .sidebar-category {
        margin-bottom: 15px;
    }
    
    .sidebar-category h3 {
        font-size: 0.85rem;
        margin-bottom: 8px;
    }
    
    .sidebar-header {
        padding: 15px;
        flex-shrink: 0;
    }
    
    .sidebar-logo {
        font-size: 1.5rem;
    }
    
    .sidebar-header h2 {
        font-size: 1.3rem;
    }
}

@media (max-width: 375px) {
    .nav-title h1 {
        font-size: 1.3rem;
    }
    
    .avatar {
        width: 32px;
        height: 32px;
        font-size: 1.1rem;
    }
    
    .message-content {
        max-width: 88%;
        padding: 10px 12px;
    }
    
    .message-text {
        font-size: 0.85rem;
    }
}

/* ==================== 滚动条美化 ==================== */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
}

::-webkit-scrollbar-thumb {
    background: rgba(142, 45, 226, 0.4);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(142, 45, 226, 0.6);
}

/* ==================== 打字机效果 ==================== */
.typing-cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    background: var(--primary-color);
    margin-left: 2px;
    animation: blink 1s infinite;
}

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