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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Helvetica Neue', Arial, sans-serif;
    background: #F5F3ED;
    height: 100vh;
    overflow: hidden;
}

/* 页面容器 */
.chat-page {
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: #F5F3ED;
    overflow: hidden;
    max-width: 480px;
    margin: 0 auto;
}

/* 顶部导航 */
.chat-header {
    padding: 7px 12px;
    background: #071D3A;
    flex-shrink: 0;
}

.hdr-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.hdr-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    border: 1px solid rgba(255,255,255,0.2);
}

.hdr-info {
    flex: 1;
}

.hdr-name {
    font-size: 15px;
    font-weight: 700;
    color: #fff;
}

.hdr-sub-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 2px 6px;
    margin-top: 2px;
}

.hdr-sub {
    font-size: 11px;
    color: rgba(255,255,255,0.65);
}

.hdr-divider {
    color: rgba(255,255,255,0.25);
    font-size: 10px;
}

.hdr-stats {
    font-size: 10px;
    color: rgba(255,255,255,0.7);
    background: rgba(255,255,255,0.12);
    padding: 1px 5px;
    border-radius: 999px;
}

.hdr-stats.gold {
    background: rgba(255,215,0,0.18);
    color: rgba(255,215,0,0.85);
}

.hdr-stats-val {
    font-weight: 700;
}

/* 历史记录 */
.history-toggle {
    padding: 6px 12px;
    background: #FAF9F6;
    border-bottom: 1px solid #ECE7DD;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    flex-shrink: 0;
}

.ht-title {
    font-size: 11px;
    color: #7B8493;
}

.ht-arrow {
    font-size: 10px;
    color: #1F5F9F;
    transition: transform 0.3s;
}

.ht-arrow.open {
    transform: rotate(90deg);
}

.history-list {
    background: #fff;
    border-bottom: 1px solid #ECE7DD;
    max-height: 120px;
    overflow-y: auto;
    flex-shrink: 0;
}

.history-item {
    padding: 8px 12px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-item:hover {
    background: #f8f9fa;
}

.history-item:last-child {
    border-bottom: none;
}

.hi-title {
    font-size: 13px;
    color: #263445;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hi-time {
    font-size: 11px;
    color: #9ca3b0;
    margin-left: 8px;
    flex-shrink: 0;
}

/* 聊天列表 */
.chat-list {
    flex: 1;
    min-height: 0;
    padding: 10px 10px 12px;
    box-sizing: border-box;
    overflow-y: auto;
}

.msg-row {
    display: flex;
    margin-bottom: 12px;
    align-items: flex-start;
}

.user-row {
    flex-direction: row-reverse;
    justify-content: flex-start;
}

.msg-side {
    width: 28px;
    flex-shrink: 0;
}

.msg-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    font-size: 12px;
}

.ai-avatar {
    background: radial-gradient(circle at 35% 30%,#fff 5%,#e8f0fe 55%,#c8ddf8 100%);
    margin-right: 6px;
}

.student-avatar {
    background: linear-gradient(135deg,#e8f4d8,#f4f9ee);
    margin-left: 6px;
}

.msg-main {
    display: flex;
    flex-direction: column;
}

.user-main {
    max-width: 72%;
    align-items: flex-end;
    display: flex;
    flex-direction: column;
}

.ai-main {
    max-width: 80%;
    align-items: flex-start;
}

.msg-bubble {
    padding: 9px 11px;
    font-size: 14px;
    line-height: 1.65;
    word-break: break-word;
    box-sizing: border-box;
}

.msg-bubble p {
    margin-bottom: 6px;
}

.msg-bubble p:last-child {
    margin-bottom: 0;
}

.user-bubble {
    background: #1F5F9F;
    color: #fff;
    border-radius: 11px 4px 11px 11px;
}

.ai-bubble {
    background: #fff;
    color: #263445;
    border-radius: 4px 11px 11px 11px;
    box-shadow: 0 3px 9px rgba(21,39,66,0.06);
}

/* 加载动画 */
.loading-bubble {
    background: #fff;
    padding: 9px 11px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-radius: 11px;
    box-shadow: 0 2px 7px rgba(21,39,66,0.05);
}

.loading-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid #D8E4F2;
    border-top-color: #1F5F9F;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}

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

.loading-title {
    font-size: 13px;
    color: #263445;
    font-weight: 600;
}

.loading-sub {
    font-size: 11px;
    color: #7B8493;
    margin-top: 2px;
    display: block;
}

/* 快捷问题 */
.quick-bar {
    padding: 5px 10px 6px;
    background: #FAF9F6;
    border-top: 1px solid #ECE7DD;
    flex-shrink: 0;
}

.quick-bar-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.qh-title {
    font-size: 11px;
    color: #7B8493;
}

.qh-refresh {
    font-size: 10px;
    color: #1F5F9F;
    cursor: pointer;
}

.quick-bar-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.q-chip {
    font-size: 11px;
    padding: 5px 10px;
    border-radius: 999px;
    background: #fff;
    color: #415066;
    border: 1px solid #E8E4DB;
    cursor: pointer;
    white-space: normal;
    word-break: break-all;
    max-width: 70%;
}

.q-chip:hover {
    background: #f0f0f0;
}

/* 输入区域 */
.input-bar {
    padding: 4px 8px;
    padding-bottom: calc(4px + env(safe-area-inset-bottom));
    background: #fff;
    border-top: 1px solid #ECECEC;
    display: flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
}

.chat-input {
    flex: 1;
    height: 36px;
    background: #F5F6F8;
    border-radius: 18px;
    padding: 0 12px;
    font-size: 13px;
    border: none;
    outline: none;
}

.chat-input:focus {
    background: #f0f2f5;
}

.chat-input::placeholder {
    color: #9ca3b0;
}

.send-btn {
    height: 36px;
    padding: 0 14px;
    border-radius: 18px;
    background: #1F5F9F;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    flex-shrink: 0;
}

.send-btn:hover {
    background: #1a508a;
}

.send-btn:disabled {
    background: #D7DCE3;
    cursor: not-allowed;
}

/* 提示信息 */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.75);
    color: white;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    z-index: 1000;
    animation: fadeInOut 3s ease-in-out;
}

@keyframes fadeInOut {
    0%, 100% { opacity: 0; }
    10%, 90% { opacity: 1; }
}

/* 弹窗 */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal-content {
    width: 90%;
    max-width: 300px;
    background: #fff;
    border-radius: 14px;
    padding: 18px 16px;
    text-align: center;
}

.modal-content h3 {
    font-size: 16px;
    font-weight: 700;
    color: #1a2a3d;
    margin-bottom: 10px;
}

.modal-content p {
    font-size: 13px;
    color: #5a6b7a;
    margin-bottom: 6px;
}

.modal-content strong {
    color: #e74c3c;
    font-size: 15px;
}

.share-preview {
    background: #f0f7ff;
    border: 1px solid #d0e3ff;
    border-radius: 8px;
    padding: 12px;
    margin: 12px 0;
}

.share-text {
    font-size: 12px;
    color: #333;
    line-height: 1.6;
    margin-bottom: 10px;
}

.btn-copy {
    background: #1F5F9F;
    color: #fff;
    border: none;
    padding: 6px 14px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
}

.btn-copy:hover {
    background: #1a508a;
}

.modal-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.modal-actions button {
    flex: 1;
    height: 40px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    border: none;
    cursor: pointer;
}

.btn-cancel {
    background: #f0f2f5;
    color: #5a6b7a;
    border: 1px solid #e0e3e8 !important;
}

.btn-confirm {
    background: linear-gradient(135deg, #1F5F9F, #2B6FAE);
    color: #fff;
}

/* 响应式 */
@media (max-width: 480px) {
    .chat-page {
        max-width: 100%;
    }
}
