/* 全局 */
:root {
    --bg-main: #050816;
    --bg-sidebar: rgba(5, 8, 22, 0.7);
    --bg-input: rgba(15, 23, 42, 0.65);
    --bg-hover: rgba(30, 64, 175, 0.3);
    --bg-message-user: rgba(15, 23, 42, 0.8);
    --bg-message-ai: rgba(15, 23, 42, 0.7);

    --text-primary: #f9fafb;
    --text-secondary: #a1a1aa;

    --accent: #38bdf8;
    --accent-hover: #0ea5e9;

    --border-color: rgba(148, 163, 184, 0.45);

    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;

    --glass-bg: rgba(15, 23, 42, 0.65);
    --glass-border: rgba(148, 163, 184, 0.5);
    --glass-shadow: 0 20px 45px rgba(15, 23, 42, 0.85);
    --app-vw: 100vw;
    --app-vh: 100dvh;
    --modal-overlay-gap: clamp(12px, 3vw, 24px);
    --modal-safe-height: calc(var(--app-vh) - 48px);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    scrollbar-width: thin;
    scrollbar-color: #555 transparent;
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #777;
}

body {
    font-family: var(--font-family);
    background:
        radial-gradient(circle at 0% 0%, rgba(56, 189, 248, 0.22), transparent 55%),
        radial-gradient(circle at 100% 0%, rgba(129, 140, 248, 0.24), transparent 55%),
        radial-gradient(circle at 0% 100%, rgba(45, 212, 191, 0.2), transparent 55%),
        linear-gradient(135deg, #020617 0%, #020617 40%, #020617 100%);
    color: var(--text-primary);
    display: flex;
    min-height: var(--app-vh);
    height: var(--app-vh);
    overflow: hidden;
}

/* 应用容器 */
.app-container {
    display: flex;
    width: 100%;
    height: 100%;
    z-index: 10;
    position: relative;
    padding: 12px;
    gap: 12px;
}

/* 动态背景 */
.liquid-bg {
    position: fixed;
    inset: -20%;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
    filter: blur(4px);
}

.liquid-orb {
    position: absolute;
    width: 420px;
    height: 420px;
    border-radius: 999px;
    background: radial-gradient(circle at 30% 20%, rgba(248, 250, 252, 0.9), rgba(59, 130, 246, 0.25));
    mix-blend-mode: screen;
    opacity: 0.55;
    filter: blur(2px);
    animation: float-orb 26s ease-in-out infinite;
}

.orb-1 {
    top: -8%;
    left: -4%;
    background: radial-gradient(circle at 30% 20%, rgba(248, 250, 252, 1), rgba(59, 130, 246, 0.3));
}

.orb-2 {
    top: 40%;
    right: -8%;
    width: 460px;
    height: 460px;
    background: radial-gradient(circle at 40% 10%, rgba(248, 250, 252, 0.9), rgba(56, 189, 248, 0.35));
    animation-delay: -6s;
}

.orb-3 {
    bottom: -10%;
    left: 15%;
    width: 380px;
    height: 380px;
    background: radial-gradient(circle at 20% 0%, rgba(248, 250, 252, 0.85), rgba(45, 212, 191, 0.35));
    animation-delay: -12s;
}

.orb-4 {
    top: 20%;
    left: 45%;
    width: 260px;
    height: 260px;
    background: radial-gradient(circle at 10% 0%, rgba(248, 250, 252, 0.85), rgba(129, 140, 248, 0.45));
    animation-delay: -18s;
}

.orb-5 {
    bottom: 18%;
    right: 35%;
    width: 260px;
    height: 260px;
    background: radial-gradient(circle at 40% 0%, rgba(248, 250, 252, 0.9), rgba(14, 165, 233, 0.4));
    animation-delay: -22s;
}

@keyframes float-orb {
    0% {
        transform: translate3d(0, 0, 0) scale(1);
    }

    33% {
        transform: translate3d(40px, -40px, 0) scale(1.05);
    }

    66% {
        transform: translate3d(-30px, 30px, 0) scale(0.98);
    }

    100% {
        transform: translate3d(0, 0, 0) scale(1);
    }
}

/* 侧边栏 */
.sidebar {
    width: 260px;
    background: var(--glass-bg);
    backdrop-filter: blur(26px) saturate(140%);
    -webkit-backdrop-filter: blur(26px) saturate(140%);
    display: flex;
    flex-direction: column;
    border: 1px solid var(--glass-border);
    border-radius: 1.25rem;
    transition: transform 0.3s ease;
    z-index: 100;
    overflow: hidden;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    font-weight: 600;
    color: white;
}

.brand i {
    color: var(--accent);
    font-size: 1.5rem;
}

.brand-logo {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.new-chat-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: radial-gradient(circle at 0 0, rgba(248, 250, 252, 0.05), transparent 55%);
    border: 1px solid rgba(148, 163, 184, 0.5);
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 0.875rem;
    transition: background 0.2s, border-color 0.2s, transform 0.15s;
    width: 100%;
    text-align: left;
}

.new-chat-btn:hover {
    background: radial-gradient(circle at 0 0, rgba(248, 250, 252, 0.12), transparent 60%);
    border-color: rgba(248, 250, 252, 0.38);
    transform: translateY(-1px);
}

.chat-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.chat-list::-webkit-scrollbar {
    width: 6px;
}

.chat-list::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 3px;
}

.chat-item {
    padding: 0.75rem;
    border-radius: 0.75rem;
    cursor: pointer;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-primary);
    transition: background 0.2s, box-shadow 0.2s, transform 0.15s;
}

.chat-item i {
    font-size: 1.125rem;
    color: var(--text-secondary);
}

.chat-item:hover {
    background: radial-gradient(circle at 0 0, rgba(248, 250, 252, 0.05), transparent 70%);
    transform: translateY(-1px);
}

.chat-item.active {
    background: radial-gradient(circle at 0 0, rgba(248, 250, 252, 0.08), transparent 75%);
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.75);
}

.chat-item .title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.chat-item .del-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
}

.chat-item:hover .del-btn {
    display: block;
}

.chat-item .del-btn:hover {
    color: #ef4444;
}


.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
}

.settings-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-primary);
    cursor: pointer;
    width: 100%;
    padding: 0.75rem;
    border-radius: 0.5rem;
    transition: background 0.2s, border-color 0.2s, transform 0.15s;
    font-size: 0.875rem;
}

.settings-btn:hover {
    background: radial-gradient(circle at 0 0, rgba(248, 250, 252, 0.08), transparent 70%);
    border-color: rgba(148, 163, 184, 0.6);
    transform: translateY(-1px);
}

/* 主内容区 */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    max-width: 100%;
    min-width: 0;
    z-index: 1;
    background: rgba(15, 23, 42, 0.35);
    border: 1px solid var(--glass-border);
    border-radius: 1.25rem;
    overflow: hidden;
}

.topbar {
    height: 60px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 1.25rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.3);
    background: linear-gradient(90deg, rgba(15, 23, 42, 0.6), rgba(15, 23, 42, 0.3));
    backdrop-filter: blur(22px) saturate(140%);
    -webkit-backdrop-filter: blur(22px) saturate(140%);
    z-index: 50;
}

.menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    margin-right: 1rem;
}

.topbar-chat-meta {
    flex: 1;
    min-width: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.75rem;
}

.current-chat-title {
    font-weight: 500;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 聊天区 */
.chat-container {
    flex: 1;
    overflow-y: hidden;
    position: relative;
    padding: 1.5rem 1.5rem 3.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* 欢迎态滚动切换 */
.chat-container:has(.welcome-screen[style*="display: none"]) {
    overflow-y: auto;
}

.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 2rem;
    text-align: center;
}

.welcome-screen h1 {
    font-size: 2rem;
    margin-bottom: 2rem;
    font-weight: 600;
}

.main-content.desktop-welcome-active .welcome-screen {
    justify-content: center;
    gap: 1.15rem;
    padding: 1rem 1rem 1.5rem;
}

.main-content.desktop-welcome-active .chat-container {
    padding: 1.5rem;
    overflow: hidden;
}

.main-content.desktop-welcome-active .welcome-screen h1 {
    margin: 0;
    line-height: 1.2;
    font-size: clamp(2rem, 3.3vw, 2.75rem);
    max-width: none;
    white-space: nowrap;
}

.input-area.welcome-inline {
    width: 100%;
    padding: 0;
    background: transparent;
}

.input-area.welcome-inline .upload-preview-list,
.input-area.welcome-inline .input-row {
    max-width: 760px;
}

.input-area.welcome-inline .upload-preview-list {
    margin-bottom: 0.5rem;
}

.input-area.welcome-inline .input-footer {
    display: none;
}



.messages {
    display: flex;
    flex-direction: column;
    padding: 0.25rem 0 1rem;
    gap: 0.25rem;
}

.messages:empty {
    display: none;
}

.message {
    padding: 0.35rem 0;
    display: flex;
    justify-content: center;
}

.message.user {
    background-color: transparent;
}

.message-wrapper {
    max-width: 840px;
    width: 100%;
    display: flex;
    gap: 1.25rem;
}

.message.user .message-wrapper {
    flex-direction: row-reverse;
}

.message-inner {
    min-width: 0;
    width: fit-content;
    max-width: 100%;
    line-height: 1.6;
    padding: 1rem 1.25rem;
    border-radius: 1.25rem;
    background: radial-gradient(circle at 0 0, rgba(248, 250, 252, 0.05), transparent 160%),
        linear-gradient(135deg, rgba(15, 23, 42, 0.85), rgba(15, 23, 42, 0.6));
    backdrop-filter: blur(22px) saturate(150%);
    -webkit-backdrop-filter: blur(22px) saturate(150%);
    border: 1px solid rgba(148, 163, 184, 0.55);
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.85);
}

.message.user .message-inner {
    background:
        radial-gradient(circle at 100% 0, rgba(56, 189, 248, 0.12), transparent 65%),
        linear-gradient(135deg, rgba(15, 23, 42, 0.9), rgba(15, 23, 42, 0.75));
    border-color: rgba(56, 189, 248, 0.55);
}

.message.user .message-actions {
    justify-content: flex-start;
}

.avatar {
    width: 30px;
    height: 30px;
    border-radius: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.2rem;
}

.avatar.user {
    background-color: transparent;
    overflow: hidden;
}

.avatar.ai {
    background: radial-gradient(circle at 30% 0, rgba(248, 250, 252, 1), rgba(56, 189, 248, 0.85));
    box-shadow: 0 10px 25px rgba(8, 47, 73, 0.85);
}

.content {
    flex: 1;
    min-width: 0;
    word-break: break-word;
}

/* Markdown */
.content h1,
.content h2,
.content h3,
.content h4 {
    margin-bottom: 0.5rem;
    margin-top: 1rem;
}

.content p {
    margin-bottom: 1rem;
}

.content p:last-child {
    margin-bottom: 0;
}

.user-text-content {
    white-space: pre-wrap;
}

.message-image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.6rem;
    margin-top: 0.7rem;
}

.message-image-item {
    border-radius: 0.85rem;
    overflow: hidden;
    border: 1px solid rgba(148, 163, 184, 0.45);
    background: rgba(15, 23, 42, 0.35);
}

.message-image-item img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 260px;
    object-fit: cover;
    cursor: zoom-in;
}

.message-file-list {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    margin-top: 0.7rem;
}

.message-file-item {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    border: 1px solid rgba(148, 163, 184, 0.45);
    background: rgba(15, 23, 42, 0.35);
    border-radius: 0.65rem;
    padding: 0.45rem 0.55rem;
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.message-file-item i {
    font-size: 1rem;
    color: var(--text-primary);
}

/* 表格 */
.content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    font-size: 0.9em;
    border: 1px solid var(--border-color);
}

.content th,
.content td {
    border: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    text-align: left;
}

.content th {
    background-color: var(--bg-hover);
    font-weight: 600;
}

.content tr:nth-child(even) {
    background-color: rgba(255, 255, 255, 0.02);
}

.code-block-wrapper {
    position: relative;
    display: block;
    margin: 1rem 0;
    max-width: 100%;
    min-width: 0;
}

.content pre {
    background: radial-gradient(circle at 0 0, rgba(248, 250, 252, 0.04), transparent 85%);
    backdrop-filter: blur(20px) saturate(150%);
    -webkit-backdrop-filter: blur(20px) saturate(150%);
    border: 1px solid rgba(148, 163, 184, 0.5);
    border-radius: 1.1rem;
    padding: 1rem;
    overflow-x: auto;
    margin: 0;
}

.content code {
    font-family: monospace;
    background: #444;
    padding: 0.2rem 0.4rem;
    border-radius: 0.25rem;
    font-size: 0.875rem;
}

.content pre code {
    background: none;
    padding: 0;
}

.code-copy-btn-container {
    position: absolute;
    top: 0;
    right: 0;
    pointer-events: none;
}

/* 代码块复制按钮 */
.code-copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    pointer-events: auto;
    transform: translateZ(0);
    will-change: transform;
    background: radial-gradient(circle at 0 0, rgba(248, 250, 252, 0.24), rgba(248, 250, 252, 0.04));
    border: 1px solid rgba(148, 163, 184, 0.7);
    color: var(--text-secondary);
    width: 30px;
    height: 30px;
    border-radius: 0.375rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.875rem;
    opacity: 0;
    transition: opacity 0.2s, background 0.2s, color 0.2s;
    z-index: 2;
}

.code-block-wrapper:hover .code-copy-btn {
    opacity: 1;
}

.code-copy-btn:hover {
    background: radial-gradient(circle at 0 0, rgba(248, 250, 252, 0.9), rgba(248, 250, 252, 0.3));
    color: white;
}

.code-copy-btn.copied {
    color: #22c55e;
    opacity: 1;
}

.content ul,
.content ol {
    padding-left: 2rem;
    margin-bottom: 1rem;
}

/* 输入区 */
.input-area {
    padding: 0 1.25rem 1.25rem 1.25rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: linear-gradient(180deg, transparent, rgba(2, 6, 23, 0.85) 70%);
}

.upload-preview-list {
    max-width: 840px;
    width: 100%;
    display: none;
    gap: 0.5rem;
    margin-bottom: 0.55rem;
    overflow-x: auto;
    padding-bottom: 0.15rem;
}

.input-row {
    max-width: 840px;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.upload-preview-list.has-items {
    display: flex;
}

.upload-preview-item {
    width: 72px;
    height: 72px;
    border-radius: 0.8rem;
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
    border: 1px solid rgba(148, 163, 184, 0.5);
    background: rgba(15, 23, 42, 0.55);
}

.upload-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    cursor: zoom-in;
}

.upload-preview-item-file {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    padding: 0.4rem;
}

.upload-preview-file-icon {
    font-size: 1.3rem;
    color: var(--text-primary);
    opacity: 0.9;
}

.upload-preview-file-name {
    width: 100%;
    font-size: 0.7rem;
    line-height: 1.2;
    color: var(--text-secondary);
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.upload-preview-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    border-radius: 999px;
    border: 1px solid rgba(248, 250, 252, 0.6);
    background: rgba(15, 23, 42, 0.85);
    color: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.75rem;
    line-height: 1;
}

.attach-btn {
    width: 44px;
    height: 44px;
    border-radius: 0.9rem;
    border: 1px solid rgba(148, 163, 184, 0.65);
    background: transparent;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    margin-right: 0;
    box-shadow: 0 10px 20px rgba(2, 6, 23, 0.4);
    transition: border-color 0.2s, color 0.2s, background 0.2s, transform 0.2s, box-shadow 0.2s;
}

.attach-btn i {
    font-size: 1.22rem;
}

.attach-btn:hover {
    color: var(--text-primary);
    border-color: rgba(248, 250, 252, 0.8);
    background:
        radial-gradient(circle at 15% 10%, rgba(248, 250, 252, 0.28), transparent 60%),
        linear-gradient(165deg, rgba(15, 23, 42, 0.45), rgba(15, 23, 42, 0.18));
    transform: translateY(-1px);
    box-shadow: 0 12px 24px rgba(2, 6, 23, 0.5);
}

.attach-btn:active {
    transform: translateY(0);
}

.input-container {
    flex: 1;
    width: auto;
    max-width: none;
    position: relative;
    background: radial-gradient(circle at 0 0, rgba(248, 250, 252, 0.05), transparent 90%);
    backdrop-filter: blur(26px) saturate(150%);
    -webkit-backdrop-filter: blur(26px) saturate(150%);
    border-radius: 1.5rem;
    box-shadow: 0 20px 45px rgba(15, 23, 42, 0.9);
    display: flex;
    align-items: center;
    min-height: 56px;
    padding: 0.5rem 0.85rem 0.5rem 1rem;
    border: 1px solid rgba(148, 163, 184, 0.55);
    transition: border-color 0.3s, box-shadow 0.3s;
}

.input-container:focus-within {
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

textarea {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    resize: none;
    max-height: 200px;
    outline: none;
    padding: 0;
    line-height: 1.5;
}

#messageInput {
    line-height: 1.45;
    padding: 0.35rem 0;
    min-height: 1.45em;
    box-sizing: border-box;
}

#messageInput::placeholder {
    color: rgba(226, 232, 240, 0.6);
}

.send-btn {
    background: radial-gradient(circle at 30% 0, #e0f2fe, #38bdf8);
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s;
    flex-shrink: 0;
    margin-left: 0.6rem;
}

.send-btn i {
    font-size: 1.2rem;
}

.send-btn .bx-stop {
    font-size: 1.5rem;
}

.send-btn:hover:not(:disabled) {
    background-color: var(--accent-hover);
}

.send-btn:disabled {
    background: rgba(30, 64, 175, 0.7);
    cursor: not-allowed;
    opacity: 0.5;
}

.input-footer {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.75rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.copyright {
    opacity: 0.8;
}

/* 模态框 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--modal-overlay-gap);
    padding-top: calc(var(--modal-overlay-gap) + env(safe-area-inset-top, 0px));
    padding-right: calc(var(--modal-overlay-gap) + env(safe-area-inset-right, 0px));
    padding-bottom: calc(var(--modal-overlay-gap) + env(safe-area-inset-bottom, 0px));
    padding-left: calc(var(--modal-overlay-gap) + env(safe-area-inset-left, 0px));
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

body.compact-viewport .modal-overlay {
    align-items: flex-start;
}

#noticeModal {
    z-index: 260;
}

.notice-message {
    margin: 0;
    font-size: 1rem;
    line-height: 1.7;
    color: rgba(226, 232, 240, 0.96);
    white-space: pre-wrap;
    word-break: break-word;
}

.notice-modal .modal-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.28);
}

.notice-modal .modal-header h2 {
    margin: 0;
    font-size: 1.1rem;
    line-height: 1.2;
    letter-spacing: 0.01em;
}

.notice-modal .modal-body {
    padding: 1.1rem 1.25rem 1rem;
    gap: 0;
}

.notice-modal .modal-footer {
    padding: 0.95rem 1.25rem 1.15rem;
    border-top: 1px solid rgba(148, 163, 184, 0.2);
}

.notice-modal .btn {
    min-width: 116px;
    border-radius: 0.75rem;
}

.lightbox-overlay {
    position: fixed;
    inset: 0;
    z-index: 320;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.9rem;
    background: rgba(2, 6, 23, 0.88);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    padding: var(--modal-overlay-gap);
    padding-top: calc(var(--modal-overlay-gap) + env(safe-area-inset-top, 0px));
    padding-right: calc(var(--modal-overlay-gap) + env(safe-area-inset-right, 0px));
    padding-bottom: calc(var(--modal-overlay-gap) + env(safe-area-inset-bottom, 0px));
    padding-left: calc(var(--modal-overlay-gap) + env(safe-area-inset-left, 0px));
}

.lightbox-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.lightbox-overlay img {
    max-width: min(92vw, 1280px);
    max-height: max(160px, min(84vh, calc(var(--app-vh) - 140px)));
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 0.9rem;
    border: 1px solid rgba(148, 163, 184, 0.55);
    box-shadow: 0 30px 60px rgba(2, 6, 23, 0.65);
    background: rgba(15, 23, 42, 0.7);
}

.lightbox-caption {
    max-width: min(92vw, 980px);
    text-align: center;
    color: rgba(226, 232, 240, 0.9);
    font-size: 0.9rem;
    line-height: 1.4;
    min-height: 1.2em;
}

.lightbox-close {
    position: absolute;
    top: 1.2rem;
    right: 1.2rem;
    width: 42px;
    height: 42px;
    border-radius: 0.75rem;
    border: 1px solid rgba(148, 163, 184, 0.55);
    background: radial-gradient(circle at 15% 15%, rgba(248, 250, 252, 0.18), transparent 58%), rgba(15, 23, 42, 0.78);
    color: var(--text-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.lightbox-close i {
    font-size: 1.35rem;
}

.modal {
    background: radial-gradient(circle at 0 0, rgba(248, 250, 252, 0.06), transparent 120%),
        linear-gradient(135deg, rgba(15, 23, 42, 0.9), rgba(15, 23, 42, 0.85));
    backdrop-filter: blur(26px) saturate(150%);
    -webkit-backdrop-filter: blur(26px) saturate(150%);
    width: 100%;
    max-width: 450px;
    max-height: var(--modal-safe-height);
    border-radius: 1.5rem;
    border: 1px solid rgba(148, 163, 184, 0.55);
    box-shadow: 0 26px 60px rgba(15, 23, 42, 0.95);
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    transform: translateY(20px);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.active .modal {
    transform: translateY(0);
}

.account-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.account-avatar i {
    font-size: 40px;
    color: #fff;
    opacity: 0.8;
}

.account-modal {
    max-width: 460px;
}

.account-modal-body {
    padding: 2.2rem 1.5rem 1.7rem;
    align-items: center;
}

.account-info {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 0.35rem;
}

.account-quota-tag {
    align-self: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.36rem 0.82rem;
    border-radius: 999px;
    border: 1px solid rgba(56, 189, 248, 0.45);
    background: rgba(56, 189, 248, 0.12);
    color: #bae6fd;
    font-size: 0.8rem;
    line-height: 1.35;
    text-align: center;
}

.account-quota-tag.is-unlimited {
    border-color: rgba(74, 222, 128, 0.5);
    background: rgba(34, 197, 94, 0.12);
    color: #bbf7d0;
}

.account-quota-tag.is-muted {
    border-color: rgba(148, 163, 184, 0.42);
    background: rgba(148, 163, 184, 0.12);
    color: rgba(226, 232, 240, 0.86);
}

.account-user-panel {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.hidden {
    display: none !important;
}

.account-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    padding: 0.35rem;
    border-radius: 1rem;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(15, 23, 42, 0.42);
}

.account-tab {
    border: none;
    border-radius: 0.8rem;
    padding: 0.7rem 0.9rem;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

.account-tab:hover {
    color: var(--text-primary);
    background: rgba(56, 189, 248, 0.08);
}

.account-tab.active {
    color: white;
    background: linear-gradient(135deg, var(--accent), #0ea5e9);
    box-shadow: 0 10px 24px rgba(14, 165, 233, 0.28);
}

.account-tip {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.7;
    text-align: center;
}

.account-form {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.account-form-links {
    display: flex;
    justify-content: flex-end;
}

.account-link-btn {
    border: none;
    background: transparent;
    color: #7dd3fc;
    font-size: 0.86rem;
    padding: 0;
    cursor: pointer;
    font-family: inherit;
}

.account-link-btn:hover {
    color: #bae6fd;
}

.account-link-btn--center {
    margin: 0 auto;
}

.account-field {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.account-field label {
    font-size: 0.86rem;
    color: var(--text-primary);
}

.account-field input {
    background: radial-gradient(circle at 0 0, rgba(248, 250, 252, 0.05), transparent 85%);
    border: 1px solid rgba(148, 163, 184, 0.55);
    color: var(--text-primary);
    padding: 0.78rem 0.95rem;
    border-radius: 0.95rem;
    outline: none;
    font-family: inherit;
    backdrop-filter: blur(18px) saturate(150%);
    -webkit-backdrop-filter: blur(18px) saturate(150%);
}

.account-field input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.45);
}

.account-code-row {
    display: flex;
    gap: 0.6rem;
}

.account-code-row input {
    flex: 1;
}

.account-code-btn {
    flex-shrink: 0;
    min-width: 118px;
    padding: 0.78rem 0.9rem;
}

.account-submit-btn {
    width: 100%;
    justify-content: center;
}

.account-user-meta {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.45rem;
}

.account-user-meta h3 {
    margin: 0;
    font-size: 1.35rem;
    color: var(--text-primary);
}

.account-user-meta p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.92rem;
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
}

.close-btn:hover {
    color: white;
}

.modal-body {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.modal-body::-webkit-scrollbar {
    width: 6px;
}

.modal-body::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 3px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: #666;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 500;
}

.form-group input {
    background: radial-gradient(circle at 0 0, rgba(248, 250, 252, 0.05), transparent 85%);
    border: 1px solid rgba(148, 163, 184, 0.55);
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    border-radius: 0.9rem;
    outline: none;
    font-family: inherit;
    backdrop-filter: blur(18px) saturate(150%);
    -webkit-backdrop-filter: blur(18px) saturate(150%);
}

.form-group input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.45);
}

/* 系统提示词输入框 */
#settingsModal #systemPrompt {
    background: radial-gradient(circle at 0 0, rgba(248, 250, 252, 0.05), transparent 85%) !important;
    border: 1px solid rgba(148, 163, 184, 0.55) !important;
    color: var(--text-primary) !important;
    border-radius: 0.9rem !important;
    backdrop-filter: blur(18px) saturate(150%) !important;
    -webkit-backdrop-filter: blur(18px) saturate(150%) !important;
}

#settingsModal .modal {
    overflow: visible;
}

#settingsModal .modal-body {
    overflow: visible;
}

#settingsModal #customModelSelect {
    position: relative;
    z-index: 40;
}

#settingsModal #modelOptions {
    z-index: 80;
}

.form-group small {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.modal-footer {
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    flex-shrink: 0;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.btn {
    padding: 0.75rem 1.25rem;
    border-radius: 0.5rem;
    border: none;
    cursor: pointer;
    font-weight: 500;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    transition: 0.2s;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: rgba(148, 163, 184, 0.16);
    color: var(--text-primary);
    border: 1px solid rgba(148, 163, 184, 0.3);
}

.btn-secondary:hover {
    background: rgba(148, 163, 184, 0.26);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.9);
    color: white;
}

.btn-danger:hover {
    background: rgba(220, 38, 38, 0.95);
}

/* 下拉框 */
.custom-select-wrapper {
    position: relative;
    user-select: none;
    flex: 1;
}

.custom-select-trigger {
    background: radial-gradient(circle at 0 0, rgba(248, 250, 252, 0.05), transparent 85%);
    border: 1px solid rgba(148, 163, 184, 0.55);
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    border-radius: 0.9rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    font-size: 0.875rem;
    backdrop-filter: blur(18px) saturate(150%);
    -webkit-backdrop-filter: blur(18px) saturate(150%);
}

.custom-select-trigger:hover {
    border-color: rgba(248, 250, 252, 0.7);
}

.custom-options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: radial-gradient(circle at 0 0, rgba(15, 23, 42, 0.9), rgba(15, 23, 42, 0.7));
    backdrop-filter: blur(22px) saturate(150%);
    -webkit-backdrop-filter: blur(22px) saturate(150%);
    border: 1px solid rgba(148, 163, 184, 0.55);
    border-radius: 0.75rem;
    margin-top: 0.25rem;
    z-index: 10;
    max-height: var(--dropdown-max-h, 200px);
    overflow-y: auto;
    display: none;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    box-sizing: border-box;
    padding-bottom: env(safe-area-inset-bottom, 16px);
    transition: max-height 0.15s ease;
}

.custom-options.open {
    display: block;
}

.custom-option {
    padding: 0.62rem 0.72rem;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.875rem;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
}

.custom-option-label {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.custom-option:hover {
    background-color: var(--bg-hover);
}

.custom-option.selected {
    background-color: var(--accent);
    color: white;
}


/* 消息删除按钮 */
.msg-del-btn:hover {
    color: #ef4444 !important;
}

/* 移动端 */
@media (max-width: 768px) {
    .app-container {
        padding: 0;
        gap: 0;
    }

    .sidebar {
        position: absolute;
        height: 100%;
        transform: translateX(-100%);
        border-radius: 0;
        border-left: none;
        border-top: none;
        border-bottom: none;
        overflow: visible;
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 10px 0 20px rgba(0, 0, 0, 0.5);
    }

    .main-content {
        border-radius: 0;
        border: none;
        overflow: visible;
    }

    .menu-btn {
        display: block;
    }

    .topbar {
        min-height: 60px;
        height: auto;
        padding: 0.4rem 0.85rem;
        gap: 0.5rem;
    }

    .topbar-chat-meta {
        gap: 0.42rem;
    }

    .current-chat-title {
        font-size: 0.94rem;
    }

    .chat-container {
        padding: 1rem 0.75rem 3.5rem;
    }

    .welcome-screen {
        justify-content: flex-start;
        padding: 1rem 0.5rem 0.25rem;
    }

    .welcome-screen h1 {
        font-size: 1.65rem;
        line-height: 1.28;
        margin: 0.2rem 0 0;
        max-width: 10em;
    }

    .message-wrapper {
        gap: 0.5rem;
    }

    .message-inner {
        padding: 0.6rem 0.8rem;
    }

    .upload-preview-item {
        width: 64px;
        height: 64px;
    }

    .input-row {
        gap: 0;
        padding: 0.3rem;
        border-radius: 1rem;
        border: 1px solid rgba(148, 163, 184, 0.52);
        background: radial-gradient(circle at 0 0, rgba(248, 250, 252, 0.07), transparent 92%);
        box-shadow: 0 14px 30px rgba(2, 6, 23, 0.58);
    }

    .input-row:focus-within {
        border-color: rgba(226, 232, 240, 0.52);
        box-shadow: 0 14px 28px rgba(2, 6, 23, 0.62);
    }

    .attach-btn {
        width: 40px;
        height: 40px;
        border-radius: 0.75rem;
        margin-right: 0.25rem;
        box-shadow: none;
    }

    .input-container {
        min-height: 50px;
        padding: 0.35rem 0.6rem 0.35rem 0.75rem;
        border: none;
        box-shadow: none;
        border-radius: 0.8rem;
        background: transparent;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }

    .input-container:focus-within {
        border-color: transparent;
        box-shadow: none;
    }

    #messageInput {
        padding: 0.28rem 0;
    }

    .send-btn {
        width: 34px;
        height: 34px;
        margin-left: 0.4rem;
    }

    .message-image-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .modal {
        border-radius: 1.15rem;
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .modal-footer .btn {
        flex: 1 1 140px;
    }

    .account-modal-body {
        padding: 1.6rem 1rem 1.2rem;
    }

    .account-code-row {
        flex-direction: column;
    }

    .account-code-btn {
        width: 100%;
    }

    .account-form-links {
        justify-content: center;
    }
}
