* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: #1a1a2e;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 10px;
}
#app {
    width: 100%;
    max-width: 600px;
    height: 95vh;
    height: 95dvh;
    background: #16213e;
    border-radius: 28px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.8);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 16px 16px 12px 16px;
    position: relative;
}
#header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #e94560;
    font-size: 20px;
    font-weight: 700;
    padding: 8px 0 12px 0;
    border-bottom: 2px solid #0f3460;
    flex-shrink: 0;
}
#headerActions {
    display: flex;
    gap: 12px;
}
.header-btn {
    background: none;
    border: none;
    color: #e94560;
    font-size: 22px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 30px;
    transition: 0.2s;
    touch-action: manipulation;
}
.header-btn:active {
    transform: scale(0.85);
    background: rgba(233, 69, 96, 0.2);
}
#styleBar {
    padding: 10px 0 6px 0;
    flex-shrink: 0;
    border-bottom: 1px solid #0f3460;
    margin-bottom: 4px;
}
#styleSelect {
    width: 100%;
    padding: 8px 14px;
    background: #0f3460;
    color: #eee;
    border: 1px solid #30475e;
    border-radius: 30px;
    font-size: 14px;
    font-weight: 500;
    outline: none;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23e94560' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 18px;
    padding-right: 40px;
}
#styleSelect option {
    background: #16213e;
    color: #eee;
}
#chatBox {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    -webkit-overflow-scrolling: touch;
}
.message {
    max-width: 85%;
    padding: 10px 16px;
    border-radius: 18px;
    line-height: 1.5;
    word-break: break-word;
    white-space: pre-wrap;
    font-size: 15px;
}
.message.user {
    align-self: flex-end;
    background: #e94560;
    color: white;
    border-bottom-right-radius: 4px;
}
.message.ai {
    align-self: flex-start;
    background: #1a1a40;
    color: #eee;
    border: 1px solid #30475e;
    border-bottom-left-radius: 4px;
}
#inputArea {
    display: flex;
    gap: 10px;
    padding-top: 12px;
    border-top: 2px solid #0f3460;
    flex-shrink: 0;
}
#input {
    flex: 1;
    padding: 12px 18px;
    border: none;
    border-radius: 40px;
    background: #0f3460;
    color: white;
    font-size: 16px;
    outline: none;
    -webkit-appearance: none;
}
#input::placeholder {
    color: #888;
}
#sendBtn {
    padding: 12px 24px;
    border: none;
    border-radius: 40px;
    background: #e94560;
    color: white;
    font-weight: 700;
    font-size: 16px;
    cursor: pointer;
    transition: 0.2s;
    flex-shrink: 0;
    touch-action: manipulation;
}
#sendBtn:active {
    transform: scale(0.94);
    background: #c73652;
}
#chatBox::-webkit-scrollbar {
    width: 4px;
}
#chatBox::-webkit-scrollbar-thumb {
    background: #e94560;
    border-radius: 10px;
}

/* ----- 模态框样式 ----- */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
    backdrop-filter: blur(4px);
    transition: opacity 0.2s;
}
.modal.hidden {
    display: none;
}
.modal-content {
    background: #1a1a2e;
    border-radius: 28px;
    width: 100%;
    max-width: 500px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    padding: 20px;
    box-shadow: 0 30px 80px rgba(0,0,0,0.9);
    border: 1px solid #30475e;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #e94560;
    font-size: 20px;
    font-weight: 700;
    padding-bottom: 12px;
    border-bottom: 2px solid #0f3460;
    flex-shrink: 0;
}
.close-btn {
    background: none;
    border: none;
    color: #e94560;
    font-size: 28px;
    cursor: pointer;
    padding: 0 8px;
    touch-action: manipulation;
}
#sessionList {
    flex: 1;
    overflow-y: auto;
    padding-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.session-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #0f3460;
    border-radius: 16px;
    cursor: pointer;
    transition: 0.2s;
    touch-action: manipulation;
}
.session-item:active {
    transform: scale(0.97);
    background: #1a4a7a;
}
.session-item.active {
    border: 2px solid #e94560;
}
.session-info {
    flex: 1;
    overflow: hidden;
}
.session-title {
    color: #eee;
    font-size: 16px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.session-meta {
    color: #888;
    font-size: 12px;
    margin-top: 4px;
}
.session-delete {
    background: none;
    border: none;
    color: #e94560;
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    touch-action: manipulation;
}
.empty-session {
    color: #888;
    text-align: center;
    padding: 30px 0;
    font-size: 16px;
}

/* 小屏适配 */
@media (max-width: 480px) {
    #app {
        height: 98vh;
        height: 98dvh;
        padding: 12px 12px 10px 12px;
        border-radius: 20px;
    }
    #header {
        font-size: 18px;
        padding: 6px 0 10px 0;
    }
    .header-btn {
        font-size: 20px;
    }
    .message {
        font-size: 14px;
        padding: 8px 14px;
        max-width: 90%;
    }
    #input {
        font-size: 15px;
        padding: 10px 16px;
    }
    #sendBtn {
        font-size: 15px;
        padding: 10px 18px;
    }
    .modal-content {
        padding: 16px;
        max-height: 85vh;
    }
    .session-item {
        padding: 10px 14px;
    }
}
