:root {
    --bg-page: #ffffff;
    --bg-sidebar: #f0f4f9;
    --text-primary: #1f1f1f;
    --text-secondary: #444746;
    --text-tertiary: #5f6368;
    --accent-blue: #0b57d0;
    --bg-input: #f0f4f9;
    --bg-user-bubble: #e3e3e3;
    --sidebar-hover: #e0e4e9;
    --sidebar-active: #d3e3fd;
    --font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-page);
    color: var(--text-primary);
    font-family: var(--font-family);
    height: 100vh;
    overflow: hidden;
}

#app {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    padding: 12px;
    border-right: 1px solid rgba(0,0,0,0.05);
    height: 100%;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), padding 0.3s ease, opacity 0.2s ease;
    overflow: hidden;
    white-space: nowrap;
}

body.sidebar-collapsed .sidebar {
    width: 0;
    padding-left: 0;
    padding-right: 0;
    opacity: 0;
    border: none;
}

body.sidebar-collapsed #main-menu-btn {
    display: flex !important;
}

.sidebar-top {
    padding: 8px;
    margin-bottom: 12px;
}

.menu-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.menu-btn:hover {
    background-color: var(--sidebar-hover);
}

.new-chat-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    background-color: transparent;
    border: none;
    font-family: var(--font-family);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    padding: 12px 16px;
    border-radius: 24px;
    cursor: pointer;
    width: 100%;
    margin-bottom: 8px;
    transition: background-color 0.2s;
}
.new-chat-btn:hover {
    background-color: var(--sidebar-hover);
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-radius: 20px;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-item:hover {
    background-color: var(--sidebar-hover);
}
.sidebar-item.active {
    background-color: var(--sidebar-active);
    color: var(--text-primary);
}

.sidebar-section {
    margin-top: 16px;
}
.section-title {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-tertiary);
    padding: 0 16px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-bottom {
    margin-top: auto;
    padding-top: 12px;
}

.system-log {
    display: none; /* Hide retro log to fit Gemini UI, can enable for debugging */
}

#settings-btn {
    display: none !important;
}
#settings-btn.unlocked {
    display: flex !important;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background-color: var(--bg-page);
}

.topbar {
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
}

.logo {
    font-size: 20px;
    color: var(--text-secondary);
    font-weight: 400;
}

.chat-title {
    font-size: 16px;
    color: var(--text-primary);
    font-weight: 500;
}

.top-rights {
    display: flex;
    align-items: center;
    gap: 16px;
}

.upgrade-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: #e8f0fe;
    color: var(--accent-blue);
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 500;
    font-size: 14px;
    font-family: var(--font-family);
    cursor: pointer;
}

.user-avatar {
    width: 32px;
    height: 32px;
    background-color: #0b57d0;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
}

/* Scroll Wrapper for content */
.scroll-wrapper {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-bottom: 120px; /* Space for fixed input */
}

/* Welcome Screen */
.welcome-container {
    padding-top: 10vh;
    max-width: 800px;
    width: 100%;
    padding-left: 20px;
    padding-right: 20px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}
.welcome-container.hidden {
    display: none;
}

.welcome-title {
    font-size: 40px;
    line-height: 1.2;
    font-weight: 500;
    color: #c4c7c5;
    margin-bottom: 60px;
}
.gradient-text {
    background: linear-gradient(74deg, #4285f4 0, #9b72cb 9%, #d96570 20%, #d96570 24%, #9b72cb 35%, #4285f4 44%, #9b72cb 50%, #d96570 56%, #fbbc04 75%, #d96570 84%, #9b72cb 92%, #4285f4 100%);
    background-size: 400% 100%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    max-width: 700px;
}

.suggestion-chip {
    padding: 14px 20px;
    background-color: var(--bg-sidebar);
    border-radius: 20px;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}
.suggestion-chip:hover {
    background-color: var(--sidebar-hover);
}

/* Chat container */
.chat-container {
    max-width: 800px;
    width: 100%;
    padding: 20px;
    display: flex;
    flex-direction: column;
}
.chat-container.hidden {
    display: none;
}

.message {
    margin-bottom: 30px;
    display: flex;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-primary);
}

.message.user {
    justify-content: flex-end;
}

.message.user .msg-content {
    background-color: var(--bg-user-bubble);
    padding: 12px 18px;
    border-radius: 24px;
    max-width: 80%;
}

.message.assistant {
    justify-content: flex-start;
    align-items: flex-start;
    gap: 16px;
}

.assistant-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-image: linear-gradient(to right, #4285f4, #d96570); /* Gradient avatar */
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
    font-weight: bold;
    flex-shrink: 0;
}

.message.assistant .msg-content {
    max-width: 85%;
    padding-top: 4px; /* Align with avatar */
}

/* 之前终端风格设定的王家卫遮罩 */
#cinematic-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: #000000;
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 2s ease-in-out;
}

#cinematic-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

#cinematic-text {
    color: #f2f2f2;
    font-family: "Songti SC", "STSong", "MingLiU", serif; 
    font-size: 22px;
    line-height: 1.8;
    letter-spacing: 4px;
    white-space: pre-wrap;
    text-align: center;
    width: 80%;
    max-width: 900px;
    text-shadow: 0 0 10px rgba(255,255,255,0.2);
    transition: opacity 1.5s ease-in-out;
}

/* Input Area Fixed */
.input-container-wrapper {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-bottom: 20px;
    background: linear-gradient(180deg, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 30%);
    transition: all 0.3s ease-in-out;
}

.input-container-wrapper.centered-state {
    bottom: auto;
    top: 50vh; /* 将基于视口原本 35vh 的高度下调到 50vh，避免遮挡回忆字眼 */
    background: transparent;
}

/* Loading Dots */
.loading-dots {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 24px;
    padding: 0 4px;
}
.loading-dots span {
    width: 6px;
    height: 6px;
    background-color: var(--accent-blue);
    border-radius: 50%;
    animation: blink 1.4s infinite both;
}
.loading-dots span:nth-child(2) {
    animation-delay: 0.2s;
}
.loading-dots span:nth-child(3) {
    animation-delay: 0.4s;
}
@keyframes blink {
    0% { opacity: 0.3; transform: scale(0.8); }
    20% { opacity: 1; transform: scale(1.2); }
    100% { opacity: 0.3; transform: scale(0.8); }
}

.input-area {
    max-width: 820px;
    width: 90%;
    background-color: var(--bg-input);
    border-radius: 36px;
    display: flex;
    align-items: center;
    padding: 10px 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.input-tools {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-secondary);
}

.input-wrapper {
    flex: 1;
    margin: 0 16px;
}

#user-input {
    width: 100%;
    border: none;
    background: transparent;
    font-size: 16px;
    font-family: var(--font-family);
    color: var(--text-primary);
    outline: none;
}

#user-input:disabled {
    opacity: 0.5;
}

.model-selector {
    font-size: 12px;
    font-weight: 500;
    display: flex;
    align-items: center;
    cursor: pointer;
    margin-right: 8px;
}

.send-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
}
.send-btn:hover {
    background-color: rgba(0,0,0,0.05);
}

.legal-text {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 12px;
}

/* Modal 设置弹窗样式 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.4);
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
    transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background-color: var(--bg-page);
    width: 90%;
    max-width: 800px;
    height: 80vh;
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    overflow: hidden;
}

.modal-header {
    padding: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

.modal-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 500;
    color: var(--text-primary);
}

.close-btn {
    background: transparent;
    border: none;
    font-size: 28px;
    color: var(--text-tertiary);
    cursor: pointer;
    line-height: 1;
}
.close-btn:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.modal-desc {
    margin-top: 0;
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 16px;
    line-height: 1.5;
}

/* 菜单导航第一层 */
.settings-menu {
    display: flex;
    flex-direction: column;
    gap: 16px;
    height: 100%;
}
.settings-menu.hidden {
    display: none;
}
.menu-item {
    background: var(--bg-user-msg);
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.2s;
}
.menu-item:hover {
    background: var(--sidebar-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}
.menu-item h3 {
    margin: 0 0 8px 0;
    font-size: 16px;
    color: var(--text-primary);
}
.menu-item p {
    margin: 0;
    font-size: 13px;
    color: var(--text-secondary);
}

/* 编辑区第二层 */
.settings-detail {
    display: flex;
    flex-direction: column;
    flex: 1;
    height: 100%;
}
.settings-detail.hidden {
    display: none;
}
.detail-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}
.back-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: none;
    color: var(--accent-blue);
    font-size: 14px;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 20px;
    transition: all 0.2s;
}
.back-btn:hover {
    background: var(--sidebar-hover);
}
#detail-title {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 15px;
}
.detail-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.settings-textarea {
    flex: 1;
    width: 100%;
    resize: none;
    padding: 16px;
    border-radius: 8px;
    border: 1px solid rgba(0,0,0,0.1);
    font-family: monospace;
    font-size: 14px;
    line-height: 1.6;
    background-color: var(--bg-input);
    color: var(--text-primary);
    outline: none;
}

.settings-textarea:focus {
    border-color: var(--accent-blue);
}

.modal-footer {
    padding: 16px 24px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    border-top: 1px solid rgba(0,0,0,0.05);
}

.secondary-btn {
    padding: 10px 20px;
    background: transparent;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 20px;
    color: var(--text-secondary);
    font-weight: 500;
    cursor: pointer;
    font-family: var(--font-family);
}
.secondary-btn:hover {
    background: var(--sidebar-hover);
}

.primary-btn {
    padding: 10px 20px;
    background: var(--accent-blue);
    border: none;
    border-radius: 20px;
    color: white;
    font-weight: 500;
    cursor: pointer;
    font-family: var(--font-family);
}
.primary-btn:hover {
    background-color: #0842a0;
}

/* AI 生成的神奇图片样式 */
.ai-generated-image {
    display: block;
    max-width: 100%;
    margin-top: 16px;
    border-radius: 4px;
    /* 宝丽来相纸质感边缘 */
    border: 8px solid #fff;
    border-bottom-width: 24px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transform: rotate(1deg); /* 随意摆放的真实感 */
    transition: transform 0.3s ease;
}

.ai-generated-image:hover {
    transform: rotate(0deg) scale(1.02);
}

.fade-in-image {
    animation: imageFade 2s ease-in-out forwards;
}

@keyframes imageFade {
    0% { opacity: 0; filter: blur(10px) contrast(150%) sepia(50%); }
    50% { opacity: 0.5; filter: blur(5px) sepia(20%); }
    100% { opacity: 1; filter: blur(0) sepia(0); }
}

/* 消息编辑按钮样式 */
.message {
    position: relative;
}

.edit-btn {
    position: absolute;
    right: -35px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 10;
}

.message:hover .edit-btn {
    opacity: 1;
    right: -40px;
}

.edit-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    transform: translateY(-50%) scale(1.1);
}

.edit-btn:active {
    transform: translateY(-50%) scale(0.9);
}

/* 适配窄屏 */
@media (max-width: 768px) {
    .edit-btn {
        right: 0;
        top: -15px;
        transform: none !important;
        opacity: 0.6;
        background: rgba(0, 0, 0, 0.3);
    }
    .message:hover .edit-btn {
        right: 5px;
        top: -15px;
    }
}

/* 图片操作栏样式 */
.image-action-container {
    position: relative;
    display: block;
    width: fit-content;
    max-width: 100%;
}

.image-action-bar {
    position: absolute;
    top: 25px; /* 考虑到宝丽来边框 */
    right: 25px;
    display: flex;
    gap: 10px;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 20;
    transform: translateY(-5px);
}

.image-action-container:hover .image-action-bar {
    opacity: 1;
    transform: translateY(0);
}

.img-action-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
}

.img-action-btn:hover {
    background: rgba(0, 0, 0, 0.7);
    transform: scale(1.1);
    border-color: #007aff; /* 保持与系统主色一致 */
    color: #007aff;
}

.img-action-btn:active {
    transform: scale(0.95);
}

.img-action-btn svg {
    pointer-events: none;
}

/* 适配窄屏：移动端时按钮始终半透明可见 */
@media (max-width: 768px) {
    .image-action-bar {
        opacity: 0.7;
        transform: none;
        top: 15px;
        right: 15px;
    }
}

/* 全屏灯箱样式 */
.lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85); /* 极暗背景 */
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: zoom-out; /* 提示点击可缩小 */
}

.lightbox-overlay.hidden {
    display: none;
}

#lightbox-img {
    max-width: 90%;
    max-height: 90%;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    border: 1px solid rgba(255,255,255,0.1);
    animation: lightboxZoom 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.lightbox-close {
    position: absolute;
    top: 30px;
    right: 40px;
    color: white;
    font-size: 40px;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.3s;
}

.lightbox-close:hover {
    opacity: 1;
}

@keyframes lightboxZoom {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* 小屏适配 */
@media (max-width: 768px) {
    #lightbox-img {
        max-width: 95%;
    }
    .lightbox-close {
        top: 20px;
        right: 20px;
    }
}
