* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: #f5f5f5;
}

.app-container {
    max-width: 430px;
    margin: 0 auto;
    background: #fff;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 加载屏幕 */
.loading-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: #fff;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #000;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 导航按钮 */
.nav-circle-btn {
    width: 40px;
    height: 40px;
    border: 1px solid #e5e7eb;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    cursor: pointer;
    color: #6b7280;
}

.nav-circle-btn:hover {
    background: #f9fafb;
}

/* 头部 */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid #f3f4f6;
}

.header-title {
    font-size: 17px;
    font-weight: 600;
    color: #111827;
}

/* 聊天区域 */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* 用户消息 */
.user-message {
    display: flex;
    justify-content: flex-end;
    align-items: flex-start;
    gap: 8px;
}

.user-message-content {
    background: #f3f4f6;
    border-radius: 20px;
    padding: 12px 16px;
    max-width: 85%;
    font-size: 15px;
    line-height: 1.5;
    color: #111827;
}

.user-message img {
    max-width: 80px;
    border-radius: 8px;
}

/* AI消息 */
.ai-message {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.ai-message-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.ai-text {
    font-size: 15px;
    color: #374151;
    line-height: 1.6;
    white-space: pre-wrap;
}

/* 图片 */
.ai-image {
    max-width: 100%;
    border-radius: 12px;
    background: #f3f4f6;
}

/* 视频 */
.ai-video {
    width: 100%;
    border-radius: 12px;
    background: #000;
}

/* 底部输入区域 */
.input-area {
    padding: 12px 16px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    border-top: 1px solid #f3f4f6;
    background: #fff;
}

.input-box {
    border: 1px solid #e5e7eb;
    border-radius: 24px;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: #fff;
}

.input-box input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 15px;
    background: transparent;
    min-width: 0;
}

.input-box input::placeholder {
    color: #9ca3af;
}

.input-icons {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.input-icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #6b7280;
}

.input-icon-btn:hover {
    background: #f3f4f6;
}

.send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #fff;
}

.send-btn:disabled {
    background: #e5e7eb;
    color: #9ca3af;
}

/* 登录页面 */
.login-container {
    max-width: 430px;
    margin: 0 auto;
    min-height: 100vh;
    background: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 24px;
}

.login-title {
    font-size: 28px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 8px;
    color: #111827;
}

.login-subtitle {
    font-size: 14px;
    color: #6b7280;
    text-align: center;
    margin-bottom: 32px;
}

.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s;
}

.form-input:focus {
    border-color: #000;
}

.captcha-row {
    display: flex;
    gap: 12px;
    align-items: center;
}

.captcha-row .form-input {
    flex: 1;
}

.captcha-display {
    padding: 12px 20px;
    background: #f3f4f6;
    border-radius: 12px;
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 4px;
    color: #111827;
    cursor: pointer;
    user-select: none;
}

.captcha-display:hover {
    background: #e5e7eb;
}

.submit-btn {
    width: 100%;
    padding: 14px;
    background: #000;
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    margin-top: 8px;
}

.submit-btn:hover {
    background: #1f2937;
}

.submit-btn:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

.toggle-mode {
    text-align: center;
    margin-top: 16px;
    font-size: 14px;
    color: #6b7280;
}

.toggle-mode button {
    background: none;
    border: none;
    color: #000;
    font-weight: 500;
    cursor: pointer;
    text-decoration: underline;
}

.error-message {
    background: #fef2f2;
    color: #dc2626;
    padding: 12px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 16px;
}

.success-message {
    background: #f0fdf4;
    color: #16a34a;
    padding: 12px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 16px;
}

/* 用户面板 */
.user-panel {
    max-width: 430px;
    margin: 0 auto;
    min-height: 100vh;
    background: #fff;
}

.panel-header {
    display: flex;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid #f3f4f6;
    gap: 12px;
}

.back-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #374151;
}

.back-btn:hover {
    background: #f3f4f6;
}

.panel-title {
    font-size: 17px;
    font-weight: 600;
    color: #111827;
}

.panel-content {
    padding: 20px;
}

.user-avatar {
    width: 64px;
    height: 64px;
    background: #f3f4f6;
    border-radius: 50%;
    margin: 0 auto 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-avatar i {
    font-size: 24px;
    color: #9ca3af;
}

.user-name {
    font-size: 16px;
    font-weight: 600;
    color: #111827;
    text-align: center;
    margin-bottom: 24px;
}

.quota-section {
    margin-bottom: 24px;
}

.quota-title {
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    margin-bottom: 8px;
}

.quota-bar {
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
}

.quota-bar-fill {
    height: 100%;
    background: #000;
    border-radius: 4px;
    transition: width 0.3s;
}

.quota-bar-fill.warning {
    background: #f59e0b;
}

.quota-bar-fill.danger {
    background: #ef4444;
}

.quota-hint {
    font-size: 12px;
    color: #9ca3af;
    margin-top: 4px;
}

.recharge-section {
    margin-bottom: 24px;
}

.recharge-title {
    font-size: 16px;
    font-weight: 600;
    color: #111827;
    margin-bottom: 12px;
}

.recharge-input-row {
    display: flex;
    gap: 12px;
}

.recharge-input-row .form-input {
    flex: 1;
}

.recharge-btn {
    padding: 12px 20px;
    background: #000;
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
}

.recharge-btn:disabled {
    background: #9ca3af;
}

.quota-link-btn {
    display: block;
    width: 100%;
    padding: 14px;
    background: #f3f4f6;
    color: #111827;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    margin-top: 16px;
}

.quota-link-btn:hover {
    background: #e5e7eb;
}

.logout-btn {
    width: 100%;
    padding: 14px;
    background: #fff;
    color: #ef4444;
    border: 1px solid #ef4444;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    margin-top: 32px;
}

.logout-btn:hover {
    background: #fef2f2;
}

/* 模型选择器 */
.model-selector {
    padding: 8px 16px;
    border-bottom: 1px solid #f3f4f6;
}

.model-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.model-tab {
    padding: 6px 12px;
    border-radius: 16px;
    border: 1px solid #e5e7eb;
    background: #fff;
    font-size: 13px;
    color: #374151;
    cursor: pointer;
    white-space: nowrap;
}

.model-tab.active {
    background: #000;
    color: #fff;
    border-color: #000;
}

/* 上传预览 */
.upload-preview {
    padding: 8px 16px;
    position: relative;
    display: inline-block;
}

.upload-preview img {
    max-width: 80px;
    max-height: 80px;
    border-radius: 8px;
}

.upload-preview .remove-btn {
    position: absolute;
    top: 0;
    right: 8px;
    width: 24px;
    height: 24px;
    background: #ef4444;
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 加载动画 */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-4px); }
}

/* 侧边菜单 */
.side-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.side-menu-overlay.show {
    opacity: 1;
    visibility: visible;
}

.side-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    max-width: 80%;
    height: 100%;
    background: #fff;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.side-menu.show {
    transform: translateX(0);
}

.side-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #e5e7eb;
}

.side-menu-title {
    font-size: 18px;
    font-weight: 600;
    color: #111827;
}

.side-menu-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #6b7280;
}

.side-menu-content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.menu-section {
    margin-bottom: 24px;
}

.menu-section-title {
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 12px;
}

.menu-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #fff;
    font-size: 14px;
    color: #374151;
    cursor: pointer;
    justify-content: center;
}

.menu-btn:hover {
    background: #f9fafb;
}

.menu-btn i {
    color: #6b7280;
}

/* 隐藏文件输入 */
.hidden {
    display: none;
}


/* 功能按钮 */
.action-btn {
    display: block;
    width: 100%;
    padding: 14px;
    background: #f3f4f6;
    color: #111827;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    text-align: center;
    margin-bottom: 12px;
}

.action-btn:hover {
    background: #e5e7eb;
}
