/* styles.css —— 从 index.html 拆出的样式表 */

/* 字体方案对齐官方 demo：优先 system-ui，iOS 上自动落到 SF Pro + 苹方 */
:root {
    --whale-font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
    --whale-font-family-code: Menlo, Monaco, Consolas, "Cascadia Mono", "Roboto Mono", "Courier New", Courier, monospace;
    /* 底部安全区兜底：JS 检测到取不到时会把 --safe-bottom 覆盖成 34px */
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    /* 导航图标下方到屏幕底边的距离：只保留必要的呼吸空间 */
    --nav-bottom-gap: max(8px, calc(var(--safe-bottom) - 26px));
    font-variant-ligatures: no-contextual;
}

html {
    height: 100%;
    font-family: var(--whale-font-family);
    /* iOS 独立窗口的系统保留区（WebKit bug）取页面背景色绘制；用底栏收尾色，
       让那条 62px 的系统带与导航栏底部融成一片，视觉上不再像“空隙”。 */
    background-color: #0f1722;
    overflow: hidden;
    overscroll-behavior: none;
}

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

body {
    /* 整页底色从深蓝开始向下过渡，露出的边缘都不会出现黑边 */
    background-color: #0f1722;
    background-image: linear-gradient(180deg, #1a2a40 0%, #0f1722 100%);
    background-repeat: no-repeat;
    background-size: 100% 100%;
    font-family: var(--whale-font-family);
    -webkit-text-size-adjust: none;
    font-feature-settings: "kern";
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    /* 不用 position:fixed，避免 iOS 上 fixed 子元素的视口基准出现异常 */
    position: relative;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
    touch-action: pan-y;
    display: flex;
    justify-content: center;
    color: #e0e0e0;
    -webkit-tap-highlight-color: transparent;
}

.app-container {
    /* 默认贴住 layout viewport 的四边（top/bottom 都为 0），不用 vh 或 visualViewport.height 定高。
       iOS 独立窗口下 visualViewport.height 可能不含底部安全区，用它定高会把底栏冻在屏幕上方。 */
    position: fixed;
    top: var(--app-top, 0px);
    bottom: 0;
    left: 0;
    right: 0;
    margin: 0 auto;
    width: 100%;
    max-width: 402px;
    /* 仅在键盘弹起时由 JS 写入像素高度；其余时候为 auto，由 top/bottom 撑满 */
    height: var(--app-vh, auto);
    background-color: #1a2a40;
    background-image: linear-gradient(180deg, #1a2a40 0%, #0f1722 100%);
    display: flex;
    flex-direction: column;
    /* 顶部微调：比原始安全区收紧 6px，靠近灵动岛但留出呼吸空间 */
    padding-top: max(6px, calc(env(safe-area-inset-top) - 6px));
    /* 底部导航改为在框架内绝对贴底，这里只预留它的高度，避免输入区被遮挡 */
    padding-bottom: calc(49px + var(--nav-bottom-gap));
    overflow: hidden;
}

/* 顶部栏：修复对齐问题 */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* 顶部整体上移：比原来少 3px 上下留白 */
    padding: 12px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    background-color: #1a2a40;
}

.header-icon { 
    font-size: 20px; 
    cursor: pointer; 
    background: none; 
    border: none; 
    color: white; 
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-center { 
    text-align: center; 
    flex: 1; /* 让中间占据剩余空间 */
}

.header-title { 
    font-family: inherit;
    font-size: 19px; 
    font-weight: 600;
    letter-spacing: 1.2px;
}

.header-status { 
    font-size: 11px; 
    color: #ff69b4; 
    margin-top: 4px; 
    height: 14px;
}

.header-right-icons {
    display: flex;
    gap: 15px;
}

/* 聊天区 */
.chat-area {
    position: relative;
    flex: 1;
    display: flex;
    min-height: 0;
}

.chat-box {
    position: relative;
    z-index: 1;
    flex: 1;
    padding: 18px 16px;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    gap: 16px;
    /* 细滚动条：默认隐藏，滚动时由 .is-scrolling 显示 */
}

/* Firefox 等不支持 ::-webkit-scrollbar 的浏览器走标准属性 */
@supports not selector(::-webkit-scrollbar) {
    .chat-box {
        scrollbar-width: thin;
        scrollbar-color: transparent transparent;
    }

    .chat-box.is-scrolling {
        scrollbar-color: rgba(255, 255, 255, 0.28) transparent;
    }
}

.chat-box::-webkit-scrollbar {
    width: 3px;
    height: 3px;
}

.chat-box::-webkit-scrollbar-track {
    background: transparent;
}

.chat-box::-webkit-scrollbar-thumb {
    background-color: transparent;
    border-radius: 999px;
}

.chat-box.is-scrolling::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.28);
}

.chat-box.is-scrolling::-webkit-scrollbar-thumb:hover {
    background-color: rgba(255, 255, 255, 0.45);
}

/* 像素鲸鱼装饰 */
.pixel-whale {
    --whale-size: 64px;
    --whale-color: #7fb8ff;
    position: absolute;
    right: 12px;
    bottom: 8px;
    width: var(--whale-size);
    height: var(--whale-size);
    color: var(--whale-color);
    z-index: 0; /* 低于消息层，不遮挡气泡 */
    pointer-events: none;
    opacity: 0.85;
}

.pixel-whale svg {
    width: 100%;
    height: 100%;
    display: block;
    overflow: visible;
}

.whale-inner {
    transform-box: fill-box;
    transform-origin: center bottom;
}

.pixel-whale.idle .whale-inner { animation: whaleFloat 3s ease-in-out infinite; }

@keyframes whaleFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.whale-eye {
    transform-box: fill-box;
    transform-origin: center;
}

.pixel-whale.thinking .whale-eye { animation: whaleBlink 1.2s infinite; }

@keyframes whaleBlink {
    0%, 100% { transform: scaleY(1); }
    50% { transform: scaleY(0.15); }
}

.whale-bubble { opacity: 0; }

.pixel-whale.thinking .whale-bubble {
    animation: whaleBubble 1.6s ease-out infinite;
}

.pixel-whale.thinking .whale-bubble:nth-of-type(2) { animation-delay: 0.5s; }
.pixel-whale.thinking .whale-bubble:nth-of-type(3) { animation-delay: 1s; }

@keyframes whaleBubble {
    0% { opacity: 0; transform: translateY(3px) scale(0.6); }
    30% { opacity: 1; }
    100% { opacity: 0; transform: translateY(-6px) scale(1); }
}

.whale-tail {
    transform-box: fill-box;
    transform-origin: right center;
}

.pixel-whale.happy .whale-tail { animation: whaleTail 0.5s ease-in-out 2; }

@keyframes whaleTail {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(-20deg); }
}

.pixel-whale.happy .whale-inner { animation: whaleHop 0.5s ease-in-out 2; }

@keyframes whaleHop {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.message {
    max-width: 82%;
    padding: 11px 14px;
    border-radius: 18px;
    font-size: 16px;
    line-height: 1.6;
    word-break: break-word;
    white-space: pre-wrap; /* 保留换行 */
    animation: fadeIn 0.3s ease;
    position: relative;
}

.message.user {
    align-self: flex-end;
    /* 参考官方 demo：更大的圆角与内边距 */
    padding: 10px 16px;
    border-radius: 22px;
    background-color: #ff69b4;
    color: white;
    border-bottom-right-radius: 6px;
    /* 长按不触发浏览器默认选中 / 系统菜单（"选择文本"操作会动态放开） */
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    cursor: pointer;
}

.message.user.selectable,
.message.user.selectable * {
    user-select: text;
    -webkit-user-select: text;
    -webkit-touch-callout: default;
    cursor: text;
}

.message.user.editing {
    white-space: normal;
    cursor: default;
    min-width: 200px;
}

/* 气泡就地编辑：输入框 + 取消/发送 */
.msg-edit-box { margin-top: 2px; }

.msg-edit-input {
    display: block;
    width: 100%;
    min-width: 168px;
    max-height: 160px;
    padding: 8px 11px;
    border: none;
    border-radius: 14px;
    background-color: rgba(255, 255, 255, 0.95);
    color: #333333;
    font-family: inherit;
    font-size: 15px;
    line-height: 1.5;
    resize: none;
    outline: none;
    overflow-y: auto;
}

.msg-edit-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 8px;
}

.msg-edit-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 12px;
    background-color: rgba(255, 255, 255, 0.25);
    color: #ffffff;
    font-family: inherit;
    font-size: 12.5px;
    line-height: 1.2;
    cursor: pointer;
}

.msg-edit-btn.primary {
    background-color: #ffffff;
    color: #e0559a;
    font-weight: 600;
}

/* 长按气泡弹出的图标菜单（横排三枚纯图标） */
.bubble-menu {
    position: fixed;
    z-index: 460;
    display: none;
    gap: 2px;
    padding: 6px;
    border-radius: 14px;
    background-color: rgba(35, 51, 74, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
    transform-origin: top right;
}

.bubble-menu.show {
    display: flex;
    animation: bubbleMenuIn 0.16s ease-out;
}

.bubble-menu.above { transform-origin: bottom right; }

.bubble-menu-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 10px;
    background-color: transparent;
    color: #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.12s ease, transform 0.12s ease;
}

.bubble-menu-btn:active {
    background-color: rgba(255, 255, 255, 0.12);
    transform: scale(0.94);
}

.bubble-menu-btn svg {
    width: 22px;
    height: 22px;
    display: block;
}

@keyframes bubbleMenuIn {
    from { opacity: 0; transform: scale(0.92); }
    to { opacity: 1; transform: scale(1); }
}

.message.ai {
    align-self: flex-start;
    white-space: normal; /* Markdown 渲染后由 marked 控制换行 */
    padding: 0;
    max-width: 100%;
    font-size: 14px;
    line-height: 1.75;
}

/* AI 回复不再使用气泡：只保留文本区域，操作栏与 token 单独一行 */
.message-bubble {
    background: none;
    color: #e0e0e0;
    border-radius: 0;
    padding: 0;
    font-size: 14px;
    line-height: 1.75;
    word-break: break-word;
}

/* AI 消息里的 Markdown 排版 */
.message.ai p { margin: 0 0 8px; }
.message.ai p:last-child { margin-bottom: 0; }
.message.ai ul, .message.ai ol { margin: 0 0 8px; padding-left: 20px; }
.message.ai li { margin-bottom: 2px; }
.message.ai h1, .message.ai h2, .message.ai h3 { margin: 8px 0; font-size: 17px; font-weight: 600; }
.message.ai blockquote {
    border-left: 3px solid rgba(255, 105, 180, 0.6);
    padding-left: 10px;
    margin: 8px 0;
    color: rgba(255, 255, 255, 0.7);
}
.message.ai pre {
    background-color: rgba(0, 0, 0, 0.35);
    padding: 10px;
    border-radius: 10px;
    /* 代码块不再出现白色横向滚动条：自动换行显示完整 */
    overflow-x: hidden;
    white-space: pre-wrap;
    word-break: break-word;
    margin: 8px 0;
}
.message.ai code {
    font-family: var(--whale-font-family-code);
    font-size: 13px;
    background-color: rgba(0, 0, 0, 0.3);
    padding: 1px 4px;
    border-radius: 4px;
}
.message.ai pre code { background: none; padding: 0; }

/* 深度思考折叠面板 */
.think-panel { margin-bottom: 10px; }

.think-header {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.45);
    font-size: 12px;
    user-select: none;
}

.think-arrow {
    display: inline-block;
    font-size: 13px;
    line-height: 1;
    transition: transform 0.2s ease;
}

.think-panel.expanded .think-arrow { transform: rotate(90deg); }

.think-content {
    display: none;
    margin-top: 8px;
    padding-left: 10px;
    border-left: 2px solid rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.5);
    font-size: 12px;
    line-height: 1.6;
    word-break: break-word;
    /* 不设内部滚动：主聊天区只保留一个滚动条 */
}

.think-panel.expanded .think-content { display: block; }

/* 思考内容走 Markdown 渲染：加粗/列表等正常显示 */
.think-content p { margin: 0 0 6px; }
.think-content p:last-child { margin-bottom: 0; }
.think-content strong { font-weight: 700; color: rgba(255, 255, 255, 0.65); }
.think-content em { font-style: italic; }
.think-content ul, .think-content ol { margin: 0 0 6px; padding-left: 18px; }
.think-content code {
    font-family: var(--whale-font-family-code);
    background-color: rgba(0, 0, 0, 0.3);
    padding: 1px 4px;
    border-radius: 4px;
}

/* 消息高亮（收藏跳转时） */
.message.highlight {
    animation: msgHighlight 1.6s ease;
}

@keyframes msgHighlight {
    0% { box-shadow: 0 0 0 0 rgba(255, 105, 180, 0); }
    30% { box-shadow: 0 0 0 3px rgba(255, 105, 180, 0.75); }
    100% { box-shadow: 0 0 0 0 rgba(255, 105, 180, 0); }
}

/* AI 消息操作栏：收藏 / 复制 / 重新生成 + token，同一行，上方细分割线 */
.ai-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    opacity: 0.85;
}

.token-bar {
    margin-top: 0;
    margin-left: auto;
    padding-left: 8px;
    font-size: 10.5px;
    color: rgba(255, 255, 255, 0.3);
    letter-spacing: 0.2px;
    white-space: nowrap;
    user-select: none;
}

.ai-action-btn {
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: none;
    color: rgba(255, 255, 255, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.1s ease, color 0.2s ease;
}

.ai-action-btn svg { width: 17px; height: 17px; display: block; }
.ai-action-btn:active { transform: scale(0.9); }
.ai-action-btn:hover { color: rgba(255, 255, 255, 0.85); }
.ai-action-btn.active { color: #ff69b4; }
.ai-action-btn.copied { color: #4ade80; }

/* 版本切换：< n/N > */
.version-nav {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
    color: rgba(255, 255, 255, 0.5);
    font-size: 12px;
}

.version-nav button {
    width: 22px;
    height: 22px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    line-height: 1;
}

.version-nav button:disabled { opacity: 0.3; cursor: not-allowed; }

/* 收藏页（全屏覆盖，备忘录风） */
.favorites-page {
    position: absolute;
    inset: 0;
    z-index: 50;
    background: linear-gradient(180deg, #1a2a40 0%, #0f1722 100%);
    display: none;
    flex-direction: column;
}

.favorites-page.show { display: flex; }

.favorites-header {
    display: flex;
    align-items: center;
    padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    background-color: #1a2a40;
}

.favorites-back {
    width: 30px;
    height: 30px;
    margin-right: 8px;
    border: none;
    border-radius: 8px;
    background: none;
    color: #e0e0e0;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.favorites-title {
    font-size: 17px;
    font-weight: 600;
}

.favorites-count {
    margin-left: 8px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.45);
}

.favorites-list {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.fav-card {
    position: relative;
    padding: 14px 12px 10px 12px;
    background-color: rgba(255, 255, 255, 0.07);
    border-radius: 12px;
    transition: background-color 0.2s ease;
}

.fav-card:active { background-color: rgba(255, 255, 255, 0.12); }
.fav-card-body { cursor: pointer; }

/* 卡片底部：跳转图标（右上）+ 取消收藏图标（右下） */
.fav-card-top {
    position: relative;
    padding-right: 34px; /* 给跳转图标留位置 */
}
.fav-jump {
    position: absolute;
    top: 4px;
    right: 2px;
}
.fav-actions {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    margin-top: 8px;
}
.fav-unfav {
    width: 26px;
    height: 26px;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.fav-unfav svg { width: 14px; height: 14px; }
.fav-unfav:active { background: rgba(255, 105, 180, 0.22); color: #ff69b4; }

.fav-summary {
    font-size: 15px;
    line-height: 1.55;
    color: #e0e0e0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

.fav-time {
    margin-top: 8px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.4);
}

.fav-empty {
    text-align: center;
    color: rgba(255, 255, 255, 0.4);
    font-size: 13px;
    padding: 60px 20px;
}

/* 收藏详情页（全屏覆盖，直接看全文） */
.fav-detail-page {
    position: absolute;
    inset: 0;
    z-index: 60;
    background: linear-gradient(180deg, #1a2a40 0%, #0f1722 100%);
    display: none;
    flex-direction: column;
}
.fav-detail-page.show { display: flex; }
.fav-detail-header {
    display: flex;
    align-items: center;
    padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    background-color: #1a2a40;
    gap: 8px;
}
.fav-detail-back {
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 8px;
    background: none;
    color: #e0e0e0;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.fav-detail-title { font-size: 17px; font-weight: 600; flex: 1; }
.fav-detail-jump {
    display: flex; align-items: center; gap: 4px;
    font-size: 12px; color: #ff69b4;
    border: none; background: none; cursor: pointer;
}
.fav-detail-jump svg { width: 14px; height: 14px; }
.fav-detail-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    -webkit-overflow-scrolling: touch;
}
.fav-detail-body > * { margin: 0 0 8px; }
.fav-detail-body p:last-child, .fav-detail-body ul:last-child { margin-bottom: 0; }
.fav-detail-meta {
    margin-top: 20px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.4);
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* 轻提示 */
.toast {
    position: fixed;
    left: 50%;
    bottom: 80px;
    transform: translateX(-50%);
    padding: 8px 16px;
    background-color: rgba(0, 0, 0, 0.75);
    color: #fff;
    font-size: 13px;
    border-radius: 20px;
    z-index: 500;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.toast.show { opacity: 1; }

/* 输入框上方功能图标栏 */
.tool-bar {
    display: flex;
    gap: 4px;
    padding: 8px 12px 2px;
    background-color: #1a2a40;
}

.tool-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: none;
    color: #8a96a8;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.1s ease, color 0.2s ease, background-color 0.2s ease;
}

.tool-btn svg {
    width: 20px;
    height: 20px;
    display: block;
    transform-origin: 50% 50%;
    transition: transform 0.28s cubic-bezier(0.34, 1.4, 0.64, 1);
}

.tool-btn:active { transform: scale(0.92); }

.tool-btn.active {
    color: #ff69b4;
    background-color: rgba(255, 105, 180, 0.12);
}

/* 深度思考：只保留图标，去掉按钮底色 / 边框 / 阴影 */
#btnThink {
    position: relative;
    color: #999;
    background: none;
    border: none;
    box-shadow: none;
    transition: color 0.3s ease, transform 0.1s ease;
}

#btnThink svg {
    position: relative;
    z-index: 1;
    width: 32px;
    height: 32px;
}

#btnThink.active {
    color: #ff69b4;
    background: none;
}

/* 呼吸光晕：伪元素复制一份图标，模糊后垫在图标下方 */
#btnThink::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 32px;
    height: 32px;
    transform: translate(-50%, -50%);
    background: url("data:image/svg+xml,%3Csvg%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20viewBox%3D'0%200%2032%2032'%20fill%3D'none'%20stroke%3D'%23FF69B4'%20stroke-width%3D'1.7'%3E%3Cg%20transform%3D'rotate(45%2016%2016)'%3E%3Cellipse%20cx%3D'16'%20cy%3D'16'%20rx%3D'11.9'%20ry%3D'5.9'%2F%3E%3Cellipse%20cx%3D'16'%20cy%3D'16'%20rx%3D'5.9'%20ry%3D'11.9'%2F%3E%3C%2Fg%3E%3Ccircle%20cx%3D'16'%20cy%3D'16'%20r%3D'1.9'%20fill%3D'%23FF69B4'%20stroke%3D'none'%2F%3E%3C%2Fsvg%3E") center / 32px 32px no-repeat;
    filter: blur(8px);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 0;
}

#btnThink.active::after {
    opacity: 0.4;
    animation: glow-breathe 2s ease-in-out infinite;
}

@keyframes glow-breathe {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.6; }
}

/* 点击反馈：弹性缩放 */
@keyframes thinkTap {
    0% { transform: scale(1); }
    30% { transform: scale(0.85); }
    65% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

#btnThink.tap svg {
    animation: thinkTap 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@media (prefers-reduced-motion: reduce) {
    #btnThink.tap svg { animation: none; }
    #btnThink.active::after { animation: none; }
}

/* 待发送文件卡片 */
.file-card {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 8px 15px 0;
    padding: 10px 12px;
    background-color: rgba(255, 255, 255, 0.08);
    border-radius: 12px;
}

.file-card[hidden] { display: none; }

.file-card-icon { font-size: 20px; }

.file-card-info {
    flex: 1;
    min-width: 0;
}

.file-card-name {
    font-size: 13px;
    color: #e0e0e0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-card-size {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.45);
    margin-top: 2px;
}

.file-card-remove {
    flex: none;
    width: 20px;
    height: 20px;
    border: none;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.12);
    color: #e0e0e0;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 待发送图片预览（输入框上方） */
.image-preview { display: none; }

.image-preview.has-images {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 15px 0;
    background-color: #1a2a40;
}

.preview-item {
    position: relative;
    width: 62px;
    height: 62px;
    border-radius: 10px;
    overflow: hidden;
    background-color: rgba(255, 255, 255, 0.08);
}

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

.preview-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    border: none;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 输入区容器（用于定位弹出层） */
.composer {
    position: relative;
    /* 透出页面渐变，避免与上下区域出现色带断层 */
    background-color: transparent;
}

.plus-btn {
    flex: none;
    width: 32px;
    height: 32px;
    margin-left: 8px;
    border: none;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.12);
    color: #b8c0cc;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease;
}

.plus-btn:active { transform: scale(0.92); }
.plus-btn.open { transform: rotate(45deg); }

/* + 号弹出菜单：输入框下方展开的 2×4 网格 */
.plus-menu {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px 8px;
    margin: 0 8px;
    padding: 0 12px;
    max-height: 0;
    overflow: hidden;
    background-color: #f7f7f7;
    border-radius: 12px;
    opacity: 0;
    pointer-events: none;
    transition: max-height 0.25s ease-out, padding 0.25s ease-out, opacity 0.2s ease-out;
}

.plus-menu.open {
    max-height: 240px;
    padding: 16px 12px;
    opacity: 1;
    pointer-events: auto;
    transition: max-height 0.25s ease-out, padding 0.25s ease-out, opacity 0.2s ease-out;
}

.plus-menu-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 0;
    background: none;
    border: none;
    cursor: pointer;
}

.plus-menu-icon {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    background-color: #ffffff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    transition: transform 0.12s ease;
}

.plus-menu-item:active .plus-menu-icon { transform: scale(0.92); }

.plus-menu-label {
    font-size: 11px;
    color: #333333;
    line-height: 1;
}

.plus-menu-placeholder {
    justify-self: center;
    width: 46px;
    height: 46px;
    border: 1px dashed #c8c8c8;
    border-radius: 12px;
}

/* 消息气泡里的图片 */
.msg-images {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 6px;
}

.message.user .msg-images:last-child { margin-bottom: 0; }

.msg-image {
    width: 120px;
    height: 120px;
    object-fit: cover;
    border-radius: 10px;
    cursor: zoom-in;
    display: block;
}

/* 图片放大查看层 */
.image-viewer {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.9);
    z-index: 100;
    cursor: zoom-out;
}

.image-viewer.show { display: flex; }

.image-viewer img {
    max-width: 94%;
    max-height: 94%;
    border-radius: 8px;
}

/* 底部输入区 */
.input-area {
    display: flex;
    padding: 10px 15px;
    background-color: #1a2a40;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    align-items: center;
}

input {
    flex: 1;
    padding: 12px 15px;
    border: none;
    border-radius: 20px;
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
    outline: none;
    font-size: 15px;
}

input::placeholder { color: rgba(255, 255, 255, 0.4); }

button#sendBtn {
    padding: 10px 18px;
    margin-left: 10px;
    background-color: #ff69b4;
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-weight: bold;
    font-size: 14px;
}

button#sendBtn.stop {
    background-color: rgba(255, 255, 255, 0.18);
}

/* ===================== 底部导航栏 ===================== */
.bottom-bar {
    /* 相对 app-container 绝对贴底：框架高度 = 可见高度，所以这里就是屏幕可见底边 */
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-width: none;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 2px 6px calc(2px + var(--nav-bottom-gap));
    flex-shrink: 0;
    /* 底板与页面收尾色完全一致，顶部用渐变淡入，不再出现一条浮起来的色带或分割线 */
    background: linear-gradient(180deg, rgba(15, 23, 34, 0) 0, #0f1722 26px);
    border-top: none;
}

.nav-item {
    position: relative;
    width: 56px;
    height: 44px;
    padding: 0;
    border: none;
    border-radius: 14px;
    background: none;
    color: rgba(255, 255, 255, 0.36);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: color 0.16s ease-out, background-color 0.16s ease-out, transform 0.1s ease-out;
    -webkit-tap-highlight-color: transparent;
}

.nav-item svg {
    width: 23px;
    height: 23px;
    display: block;
    transition: transform 0.16s ease-out, filter 0.16s ease-out;
}

.nav-item:active { transform: scale(0.94); }

.nav-item.active {
    color: #ff69b4;
    background: radial-gradient(circle at 50% 62%, rgba(255, 105, 180, 0.14), transparent 72%);
}

.nav-item.active svg {
    transform: scale(1.05);
    filter: drop-shadow(0 0 6px rgba(255, 105, 180, 0.45));
}

.nav-dot {
    position: absolute;
    left: 50%;
    bottom: 4px;
    width: 4px;
    height: 4px;
    margin-left: -2px;
    border-radius: 50%;
    background: #ff69b4;
    opacity: 0;
    transform: scale(0.6);
    transition: opacity 0.16s ease-out, transform 0.16s ease-out;
}

.nav-item.active .nav-dot {
    opacity: 1;
    transform: scale(1);
}

/* ===================== 底部导航页面骨架 ===================== */
/* 页面底板：只要不在聊天页，就垫一层完全不透明的底色，
   页面之间只在这层实底上做极短交叉淡化，任何时刻都不会透出聊天层 */
.page-stage {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: calc(49px + var(--nav-bottom-gap));
    z-index: 39;
    background: linear-gradient(180deg, #1a2a40 0%, #0f1722 100%);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.app-container:not([data-page="chat"]) .page-stage {
    opacity: 1;
    visibility: visible;
}

.page {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: calc(49px + var(--nav-bottom-gap));
    z-index: 40;
    display: flex;
    flex-direction: column;
    padding-top: env(safe-area-inset-top);
    background: linear-gradient(180deg, #1a2a40 0%, #0f1722 100%);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    /* 原生 tab 手感：不位移，只保留极短的交叉淡化 */
    transition: opacity 0.1s ease-out, visibility 0s linear 0.1s;
    will-change: opacity;
}

.page.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    z-index: 41; /* 新页淡入时压住正在淡出的旧页，避免中途穿帮 */
    transition: opacity 0.1s ease-out, visibility 0s;
}

/* 切回聊天页时直接硬切：不做淡出，避免半透明页面叠在聊天内容上 */
.app-container[data-page="chat"] .page {
    transition: none;
}

.page-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px 13px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.page-heading { flex: 1; min-width: 0; }

.page-title {
    font-family: inherit;
    font-size: 20px;
    font-weight: 600;
    letter-spacing: 1px;
    color: #e8e8e8;
}

.page-subtitle {
    display: block;
    margin-top: 5px;
    font-size: 12px;
    letter-spacing: 0.3px;
    color: rgba(255, 255, 255, 0.33);
}

.page-body {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.page-placeholder {
    width: 100%;
    padding: 34px 18px;
    text-align: center;
    border: 1px dashed rgba(255, 255, 255, 0.12);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.02);
}

.page-placeholder svg {
    width: 30px;
    height: 30px;
    margin-bottom: 12px;
    color: rgba(255, 255, 255, 0.22);
}

.page-placeholder-title {
    font-size: 13px;
    letter-spacing: 0.5px;
    color: rgba(255, 255, 255, 0.55);
}

.page-placeholder-desc {
    margin-top: 6px;
    font-size: 11px;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.27);
}

/* ===================== 多功能侧边栏 ===================== */

/* 顶部菜单按钮图标 */
#btnMenu svg {
    width: 21px;
    height: 21px;
    display: block;
}

/* 遮罩层 */
.sidebar-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
    z-index: 300;
}

.sidebar-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

/* 侧边栏主体：75% 宽 + 深色毛玻璃 */
.sidebar {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 75%;
    max-width: 340px;
    z-index: 310;
    transform: translateX(-102%);
    transition: transform 0.38s cubic-bezier(0.22, 0.8, 0.24, 1);
    background: rgba(18, 28, 43, 0.74);
    backdrop-filter: blur(22px) saturate(140%);
    -webkit-backdrop-filter: blur(22px) saturate(140%);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.45);
    will-change: transform;
}

.sidebar.open {
    transform: translateX(0);
}

.sidebar-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: calc(12px + env(safe-area-inset-top)) 12px calc(10px + env(safe-area-inset-bottom));
}

/* 顶部搜索区 */
.sidebar-search {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.06);
    flex: none;
}

.sidebar-search svg {
    width: 15px;
    height: 15px;
    color: rgba(255, 255, 255, 0.5);
    flex: none;
}

.sidebar-search input {
    flex: 1;
    min-width: 0;
    background: none;
    border: none;
    outline: none;
    color: #e8e8e8;
    font-size: 14px;
    font-family: inherit;
}

.sidebar-search input::placeholder {
    color: rgba(255, 255, 255, 0.35);
}

/* 中部 Tabs */
.sidebar-tabs {
    display: flex;
    gap: 6px;
    margin-top: 12px;
    padding: 3px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 11px;
    flex: none;
}

.sidebar-tab {
    flex: 1;
    padding: 7px 0;
    border: none;
    border-radius: 9px;
    background: none;
    color: rgba(255, 255, 255, 0.55);
    font-size: 13.5px;
    font-family: inherit;
    cursor: pointer;
    transition: background-color 0.25s ease, color 0.25s ease, box-shadow 0.25s ease;
}

.sidebar-tab.active {
    background: rgba(255, 105, 180, 0.18);
    color: #ff9ccb;
    box-shadow: inset 0 0 0 1px rgba(255, 105, 180, 0.25);
}

/* 内容区 */
.sidebar-body {
    flex: 1;
    overflow-y: auto;
    margin-top: 12px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.sidebar-body::-webkit-scrollbar { width: 4px; }
.sidebar-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 2px;
}

.sidebar-panel { display: none; }
.sidebar-panel.active { display: block; }

.sidebar-empty {
    color: rgba(255, 255, 255, 0.3);
    font-size: 12.5px;
    text-align: center;
    padding: 30px 10px;
    line-height: 1.8;
}

/* 列表角落的日期筛选入口（历史对话 / 记忆胶囊共用） */
.history-toolbar {
    position: sticky;
    top: 0;
    z-index: 6;
    display: flex;
    justify-content: flex-end;
    padding: 0 2px 8px;
    background: linear-gradient(180deg, rgba(18, 28, 43, 0.96) 0%, rgba(18, 28, 43, 0.88) 62%, rgba(18, 28, 43, 0) 100%);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.history-filter-btn {
    display: inline-flex;
    align-items: baseline;
    gap: 3px;
    padding: 2px;
    border: none;
    background: none;
    color: rgba(255, 255, 255, 0.45);
    font-size: 11px;
    line-height: 1.2;
    font-family: inherit;
    letter-spacing: 0.2px;
    cursor: pointer;
    transition: color 0.2s ease, opacity 0.15s ease;
}

.history-filter-btn .filter-caret {
    font-size: 8.5px;
    opacity: 0.7;
    transform: translateY(-1px);
}

.history-filter-btn:active { opacity: 0.65; }

.history-filter-btn.active { color: #ff9ccb; }

/* 底部弹出的日期选择器（日历） */
.date-sheet {
    position: absolute;
    inset: 0;
    z-index: 420;
}

.date-sheet[hidden] { display: none; }

.date-sheet-mask {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    transition: opacity 0.25s ease;
}

.date-sheet.show .date-sheet-mask { opacity: 1; }

.date-sheet-panel {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding-bottom: env(safe-area-inset-bottom);
    border-radius: 20px 20px 0 0;
    background: linear-gradient(180deg, #1e2c40 0%, #16202f 100%);
    box-shadow: 0 -14px 34px rgba(0, 0, 0, 0.45);
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.22, 0.8, 0.24, 1);
}

.date-sheet.show .date-sheet-panel { transform: translateY(0); }

.date-sheet-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.date-sheet-btn {
    padding: 4px 2px;
    border: none;
    background: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
}

.date-sheet-btn:active { opacity: 0.7; }

.date-sheet-confirm {
    color: #ff69b4;
    font-weight: 600;
}

/* 日历面板 */
.cal-panel {
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
    min-height: 46vh;
}

.cal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px 6px;
}

.cal-arrow {
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 10px;
    background: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 20px;
    line-height: 1;
    font-family: inherit;
    cursor: pointer;
}

.cal-arrow:active { background: rgba(255, 255, 255, 0.08); }

.cal-title {
    padding: 5px 10px;
    border: none;
    border-radius: 9px;
    background: none;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: #e8e8e8;
    cursor: pointer;
}

.cal-title:active { background: rgba(255, 255, 255, 0.08); }

.cal-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    padding: 4px 12px 6px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.32);
    text-align: center;
}

.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    padding: 0 12px 10px;
}

.cal-day {
    height: 40px;
    padding: 0;
    border: none;
    border-radius: 10px;
    background: none;
    color: rgba(255, 255, 255, 0.2);
    font-size: 13.5px;
    font-family: inherit;
    cursor: default;
    transition: background-color 0.18s ease, color 0.18s ease;
}

.cal-day.has-record {
    color: #e2e2e2;
    background: rgba(255, 255, 255, 0.06);
    cursor: pointer;
}

.cal-day.has-record:active { background: rgba(255, 255, 255, 0.14); }

.cal-day.today {
    color: #ff69b4;
    font-weight: 600;
    box-shadow: inset 0 0 0 1px rgba(255, 105, 180, 0.55);
}

.cal-day.today.has-record { background: rgba(255, 105, 180, 0.14); }

.cal-day.empty { visibility: hidden; }

/* 年份快选 */
.cal-year-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 4px 16px 14px;
    max-height: 232px;
    overflow-y: auto;
}

.cal-year-grid[hidden] { display: none; }
.cal-grid[hidden] { display: none; }
.cal-weekdays[hidden] { display: none; }

.cal-year {
    height: 42px;
    border: none;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    color: #dcdcdc;
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
}

.cal-year:active { background: rgba(255, 255, 255, 0.13); }

.cal-year.active {
    background: rgba(255, 105, 180, 0.18);
    color: #ff9ccb;
    box-shadow: inset 0 0 0 1px rgba(255, 105, 180, 0.4);
}

.cal-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 18px 6px;
}

.cal-clear { color: #ff9ccb; }

.cal-clear[hidden] { display: none; }

/* 历史对话：按天分区的问答卡片 */
.history-day { margin-bottom: 12px; }

.history-day-label {
    text-align: center;
    font-size: 10.5px;
    color: rgba(255, 255, 255, 0.32);
    letter-spacing: 0.5px;
    margin: 2px 0 8px;
}

.chat-card {
    padding: 2px;
    margin-bottom: 8px;
    border-radius: 13px;
    background: rgba(255, 255, 255, 0.025);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
    transition: box-shadow 0.3s ease;
}

.chat-card .history-item { margin-bottom: 4px; }
.chat-card .history-item:last-child { margin-bottom: 0; }

/* 从日历定位到某一天时，整块轻微闪一下 */
.history-day.located .history-day-label { color: #ff9ccb; }
.history-day.located .chat-card { box-shadow: inset 0 0 0 1px rgba(255, 105, 180, 0.45); }
.history-day.located { animation: dayLocate 1.8s ease; }

@keyframes dayLocate {
    0% { background: rgba(255, 105, 180, 0); }
    25% { background: rgba(255, 105, 180, 0.08); }
    100% { background: rgba(255, 105, 180, 0); }
}

.history-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 9px 11px;
    border-radius: 11px;
    background: rgba(255, 255, 255, 0.05);
    margin-bottom: 6px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.history-item:active { background: rgba(255, 255, 255, 0.12); }

.history-item-top {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 10.5px;
    color: rgba(255, 255, 255, 0.35);
}

.history-item-role { color: #ff9ccb; }

.history-item-text {
    font-size: 13.5px;
    color: #d8d8d8;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

.history-item-text mark {
    background: rgba(255, 105, 180, 0.35);
    color: #fff;
    border-radius: 3px;
    padding: 0 1px;
}

.search-results .history-item {
    border: 1px solid rgba(255, 105, 180, 0.18);
}

/* 记忆胶囊：便利贴风格 */
/* 双 Tab：玫瑰星球（critical） / 金色麦浪（daily） */
.capsule-tabs {
    display: flex;
    gap: 6px;
    padding: 3px;
    margin-bottom: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
}

.capsule-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    padding: 6px 0 5px;
    border: none;
    border-radius: 10px;
    background: none;
    color: rgba(255, 255, 255, 0.5);
    font-family: inherit;
    cursor: pointer;
    transition: background-color 0.25s ease, color 0.25s ease, box-shadow 0.25s ease;
}

.capsule-tab-title {
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.capsule-tab-sub {
    font-size: 9.5px;
    letter-spacing: 0.6px;
    color: rgba(255, 255, 255, 0.3);
}

.capsule-tab.active {
    background: rgba(255, 105, 180, 0.16);
    color: #ffb3d6;
    box-shadow: inset 0 0 0 1px rgba(255, 105, 180, 0.24);
}

.capsule-tab[data-importance="critical"].active {
    background: rgba(214, 178, 70, 0.14);
    color: #f0d38a;
    box-shadow: inset 0 0 0 1px rgba(214, 178, 70, 0.32);
}

.capsule-tab.active .capsule-tab-sub { color: rgba(255, 255, 255, 0.55); }

/* critical 胶囊过多时的提醒 */
.capsule-warn {
    margin-bottom: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    background: rgba(214, 178, 70, 0.12);
    box-shadow: inset 0 0 0 1px rgba(214, 178, 70, 0.28);
    color: #e8c978;
    font-size: 11.5px;
    line-height: 1.5;
}

.capsule-warn[hidden] { display: none; }

.capsule-hint {
    font-size: 11.5px;
    line-height: 1.55;
    color: rgba(255, 255, 255, 0.34);
    padding: 0 2px 10px;
}

/* 手动写入区：用户自己记录，作者记为 Chloe */
.capsule-compose {
    display: flex;
    gap: 8px;
    align-items: stretch;
    margin-bottom: 12px;
}

.capsule-compose textarea {
    flex: 1;
    resize: none;
    border-radius: 11px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.06);
    color: #e8e8e8;
    font-size: 13px;
    padding: 8px 10px;
    outline: none;
    font-family: inherit;
    line-height: 1.45;
}

.capsule-compose textarea::placeholder { color: rgba(255, 255, 255, 0.3); }

.capsule-compose button {
    width: 42px;
    border: none;
    border-radius: 11px;
    background: linear-gradient(135deg, #ff69b4, #b06df0);
    color: #fff;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    transition: transform 0.15s ease, filter 0.2s ease;
}

.capsule-compose button:active {
    transform: scale(0.95);
    filter: brightness(1.1);
}

.capsule-card {
    position: relative;
    padding: 11px 12px;
    border-radius: 14px;
    margin-bottom: 9px;
    color: #2a2333;
    box-shadow: 0 4px 18px rgba(255, 105, 180, 0.12);
    animation: capsuleIn 0.3s ease both;
}

@keyframes capsuleIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.capsule-card::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 14px;
    pointer-events: none;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}

/* 不同作者不同底色 */
.capsule-author-chloe {
    background: linear-gradient(150deg, #ffe0ef 0%, #ffc7e0 100%);
    box-shadow: 0 4px 20px rgba(255, 105, 180, 0.22);
}

.capsule-author-whale {
    background: linear-gradient(150deg, #dceeff 0%, #c3ddff 100%);
    box-shadow: 0 4px 20px rgba(96, 165, 250, 0.22);
}

.capsule-author-other {
    background: linear-gradient(150deg, #fdf3cf 0%, #ffe9a8 100%);
    box-shadow: 0 4px 20px rgba(250, 204, 21, 0.18);
}

/* 重要记忆：金色细边 + 微光 */
.capsule-card.capsule-critical {
    box-shadow: inset 0 0 0 1.5px rgba(214, 178, 70, 0.7), 0 4px 22px rgba(214, 178, 70, 0.28);
}

.capsule-card.capsule-critical::after {
    box-shadow: inset 0 0 0 1px rgba(214, 178, 70, 0.5);
}

.capsule-meta {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 10px;
    font-weight: 600;
    opacity: 0.65;
    margin-bottom: 5px;
}

.capsule-meta-right {
    display: flex;
    align-items: center;
    gap: 5px;
}

.capsule-star {
    width: 20px;
    height: 20px;
    margin: -3px -3px -3px 0;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: none;
    color: rgba(42, 35, 51, 0.35);
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.12s ease, color 0.2s ease;
}

.capsule-star.active { color: #c99a1e; }

.capsule-star:active { transform: scale(0.9); }

.capsule-content {
    font-size: 13.5px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

/* 胶囊底部：版本切换 + 编辑/删除 */
.capsule-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 7px;
    min-height: 20px;
}

.capsule-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10.5px;
    font-weight: 600;
    color: rgba(42, 35, 51, 0.55);
}

.capsule-nav button {
    width: 20px;
    height: 20px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: rgba(42, 35, 51, 0.1);
    color: rgba(42, 35, 51, 0.7);
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.capsule-nav button:disabled { opacity: 0.3; cursor: not-allowed; }

.capsule-tools {
    display: flex;
    gap: 3px;
    margin-left: auto;
}

.capsule-tool {
    width: 22px;
    height: 22px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: none;
    color: rgba(42, 35, 51, 0.42);
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.12s ease, background-color 0.2s ease, color 0.2s ease;
}

.capsule-tool:hover {
    color: rgba(42, 35, 51, 0.8);
    background: rgba(42, 35, 51, 0.09);
}

.capsule-tool:active { transform: scale(0.9); }

/* 胶囊编辑态 */
.capsule-edit textarea {
    width: 100%;
    min-height: 64px;
    resize: none;
    border-radius: 9px;
    border: 1px solid rgba(42, 35, 51, 0.18);
    background: rgba(255, 255, 255, 0.6);
    color: #2a2333;
    font-size: 12.5px;
    line-height: 1.5;
    padding: 7px 9px;
    outline: none;
    font-family: inherit;
}

.capsule-edit textarea:focus { border-color: rgba(42, 35, 51, 0.4); }

.capsule-edit-meta {
    margin-top: 4px;
    font-size: 10px;
    text-align: right;
    color: rgba(42, 35, 51, 0.45);
}

.capsule-edit-actions {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    margin-top: 6px;
}

.capsule-edit-actions button {
    border: none;
    border-radius: 8px;
    padding: 5px 12px;
    font-size: 11.5px;
    font-family: inherit;
    cursor: pointer;
}

.capsule-edit-actions .c-btn-cancel {
    background: rgba(42, 35, 51, 0.1);
    color: rgba(42, 35, 51, 0.7);
}

.capsule-edit-actions .c-btn-save {
    background: rgba(42, 35, 51, 0.8);
    color: #fff;
    font-weight: 600;
}

/* 底部设置区 */
.sidebar-footer {
    flex: none;
    padding-top: 10px;
    margin-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.sidebar-setting {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 9px 10px;
    border: none;
    border-radius: 11px;
    background: none;
    color: rgba(255, 255, 255, 0.66);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.sidebar-setting svg { width: 17px; height: 17px; }

.sidebar-setting:active { background: rgba(255, 255, 255, 0.07); }

/* ===================== 设置页 ===================== */

.settings-page {
    position: absolute;
    inset: 0;
    /* 高于侧边栏(310)与遮罩(300)：作为覆盖层盖在展开的侧边栏之上 */
    z-index: 400;
    display: none;
    flex-direction: column;
    background: linear-gradient(180deg, #1a2a40 0%, #0f1722 100%);
}

.settings-page.show { display: flex; }

.settings-header {
    display: flex;
    align-items: center;
    padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    background-color: #1a2a40;
    flex: none;
}

.settings-title {
    font-size: 17px;
    font-weight: 600;
    color: #e8e8e8;
}

.settings-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 16px calc(24px + env(safe-area-inset-bottom));
}

.settings-section-label {
    font-size: 11px;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.38);
    margin: 0 4px 8px;
}

/* API Key 折叠卡片 */
.settings-card {
    background: rgba(255, 255, 255, 0.07);
    border-radius: 12px;
    overflow: hidden;
}

.settings-key-toggle {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    padding: 14px;
    background: none;
    border: none;
    color: #e8e8e8;
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
}

.settings-key-name { font-weight: 500; }

.settings-key-chevron svg {
    width: 18px;
    height: 18px;
    display: block;
    color: rgba(255, 255, 255, 0.45);
    transition: transform 0.25s ease;
}

.settings-card.expanded .settings-key-chevron svg { transform: rotate(180deg); }

.settings-key-panel {
    max-height: 0;
    overflow: hidden;
    padding: 0 14px;
    transition: max-height 0.3s ease, padding-bottom 0.3s ease;
}

.settings-card.expanded .settings-key-panel {
    max-height: 200px;
    padding-bottom: 14px;
}

.settings-key-row {
    display: flex;
    gap: 8px;
    padding-top: 2px;
}

.settings-key-input-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 6px;
    height: 40px;
    padding: 0 10px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.settings-key-input-wrap input {
    flex: 1;
    min-width: 0;
    background: none;
    border: none;
    outline: none;
    color: #e8e8e8;
    font-size: 13px;
    font-family: inherit;
}

.settings-key-input-wrap input[type="password"] { letter-spacing: 2px; }

.settings-eye {
    flex: none;
    display: flex;
    padding: 2px;
    border: none;
    background: none;
    color: rgba(255, 255, 255, 0.45);
    cursor: pointer;
}

.settings-eye svg { width: 17px; height: 17px; }

.settings-check {
    flex: none;
    height: 40px;
    padding: 0 16px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #ff69b4, #b06df0);
    color: #fff;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: transform 0.15s ease;
}

.settings-check:active { transform: scale(0.97); }

.settings-hint {
    margin-top: 8px;
    font-size: 11px;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.32);
}

/* 导入 / 导出 */
.settings-rows {
    margin-top: 18px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    overflow: hidden;
}

.settings-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.settings-row:last-child { border-bottom: none; }

.settings-row-text {
    flex: 1;
    min-width: 0;
}

.settings-row-title {
    font-size: 15px;
    font-weight: 500;
    color: #e8e8e8;
    margin-bottom: 4px;
}

.settings-row-desc {
    font-size: 12.5px;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.38);
}

.settings-pill {
    flex: none;
    padding: 7px 16px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    background: transparent;
    color: #e8e8e8;
    font-size: 12.5px;
    font-family: inherit;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.settings-pill:active { background: rgba(255, 255, 255, 0.1); }

/* 与 settings-pill 同款的链接按钮（调试面板入口） */
.settings-pill-link {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    color: #e8e8e8;
}

.settings-pill-primary {
    border-color: rgba(255, 105, 180, 0.5);
    background: rgba(255, 105, 180, 0.16);
    color: #ffb3d6;
    font-weight: 600;
}

/* 灵魂源文件编辑器 */
.settings-soul {
    padding: 12px 14px 14px;
}

.settings-soul-input {
    width: 100%;
    min-height: 180px;
    max-height: 46vh;
    resize: vertical;
    border-radius: 11px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(0, 0, 0, 0.22);
    color: #e8e8e8;
    font-size: 12.5px;
    line-height: 1.6;
    padding: 10px 11px;
    outline: none;
    font-family: inherit;
    transition: border-color 0.2s ease;
}

.settings-soul-input:focus { border-color: rgba(255, 105, 180, 0.55); }

.settings-soul-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 9px;
}

.settings-soul-count {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.36);
}

.settings-soul-actions {
    display: flex;
    gap: 8px;
}

/* 阈值输入 */
.settings-input {
    flex: none;
    width: 100px;
    padding: 7px 10px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.06);
    color: #e8e8e8;
    font-size: 12.5px;
    font-family: inherit;
    text-align: right;
    outline: none;
    transition: border-color 0.2s ease;
}

.settings-input:focus { border-color: rgba(255, 105, 180, 0.6); }

/* 开关滑块（碎碎念模式） */
.settings-switch {
    position: relative;
    flex: none;
    display: inline-flex;
    cursor: pointer;
}

.settings-switch input {
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
}

.settings-switch-track {
    position: relative;
    display: block;
    width: 46px;
    height: 26px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.12);
    transition: background-color 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

.settings-switch-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #cfd6e0;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.25s ease;
}

.settings-switch input:checked + .settings-switch-track {
    background: linear-gradient(135deg, rgba(255, 105, 180, 0.9), rgba(176, 109, 240, 0.9));
    border-color: rgba(255, 105, 180, 0.5);
    box-shadow: 0 0 10px rgba(255, 105, 180, 0.28);
}

.settings-switch input:checked + .settings-switch-track .settings-switch-thumb {
    transform: translateX(20px);
    background: #fff;
}

.settings-switch input:focus-visible + .settings-switch-track {
    outline: 2px solid rgba(255, 105, 180, 0.5);
    outline-offset: 2px;
}

.settings-input::-webkit-outer-spin-button,
.settings-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* 导入模式选择 */
.settings-mode-label { margin-top: 18px; }

.settings-mode {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 6px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
}

.settings-mode-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 11px;
    border-radius: 9px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.settings-mode-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.settings-mode-option:has(input:checked) {
    background: rgba(255, 105, 180, 0.10);
    border-color: rgba(255, 105, 180, 0.30);
}

.settings-mode-dot {
    flex: none;
    position: relative;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    border: 1.5px solid rgba(255, 255, 255, 0.28);
    transition: border-color 0.2s ease;
}

.settings-mode-dot::after {
    content: '';
    position: absolute;
    inset: 3px;
    border-radius: 50%;
    background: #ff69b4;
    transform: scale(0);
    transition: transform 0.18s ease;
}

.settings-mode-option input:checked + .settings-mode-dot { border-color: #ff69b4; }
.settings-mode-option input:checked + .settings-mode-dot::after { transform: scale(1); }

.settings-mode-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.settings-mode-title {
    font-size: 12.5px;
    color: #e8e8e8;
    transition: color 0.2s ease;
}

.settings-mode-option input:checked ~ .settings-mode-text .settings-mode-title { color: #ff9ccb; }

.settings-mode-desc {
    font-size: 10.5px;
    color: rgba(255, 255, 255, 0.35);
}

/* 危险操作 */
.settings-danger { margin-top: 24px; }

.settings-danger-btn {
    width: 100%;
    padding: 13px;
    border-radius: 12px;
    border: 1px solid rgba(255, 77, 77, 0.45);
    background: rgba(255, 77, 77, 0.10);
    color: #ff6b6b;
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.settings-danger-btn:active { background: rgba(255, 77, 77, 0.18); }

.settings-danger-hint {
    margin-top: 8px;
    text-align: center;
    font-size: 10.5px;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.28);
}

/* ===================== 导入对话选择器 ===================== */

.import-picker {
    position: absolute;
    inset: 0;
    /* 高于设置页(400)，低于 toast(500) */
    z-index: 450;
    display: none;
    flex-direction: column;
    background: rgba(10, 16, 26, 0.96);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.import-picker.show { display: flex; }

.import-picker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: calc(14px + env(safe-area-inset-top)) 16px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex: none;
}

.import-picker-title {
    font-size: 16px;
    font-weight: 600;
    color: #e8e8e8;
}

.import-picker-close {
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
    cursor: pointer;
}

.import-picker-hint {
    padding: 10px 16px 0;
    font-size: 11.5px;
    color: rgba(255, 255, 255, 0.35);
    flex: none;
}

.import-picker-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px calc(20px + env(safe-area-inset-bottom));
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.import-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 14px;
    margin-bottom: 8px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.import-item:active { background: rgba(255, 255, 255, 0.11); }

.import-item-main {
    flex: 1;
    min-width: 0;
}

.import-item-title {
    font-size: 13.5px;
    color: #e8e8e8;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.import-item-meta {
    font-size: 10.5px;
    color: rgba(255, 255, 255, 0.35);
}

.import-item-go {
    flex: none;
    font-size: 12px;
    color: #ff9ccb;
}

.import-loading {
    text-align: center;
    padding: 14px 0;
    font-size: 11.5px;
    color: rgba(255, 255, 255, 0.3);
}

.tab-item.active { border: 2px solid #ff69b4; color: #ff69b4; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===================== 小窝 ===================== */

.nest-body {
    display: block;
    align-items: stretch;
    justify-content: flex-start;
    padding: 12px 14px 28px;
    overflow-y: auto;
}

.nest-body::-webkit-scrollbar { width: 3px; }
.nest-body::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.18); border-radius: 999px; }

.nest-card {
    margin-bottom: 10px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.045);
    border: 1px solid rgba(255, 255, 255, 0.07);
    overflow: hidden;
}

.nest-card-head {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border: none;
    background: none;
    color: #e6e6e6;
    font-family: inherit;
    font-size: 14.5px;
    text-align: left;
    cursor: pointer;
}

.nest-card-title {
    display: flex;
    align-items: center;
    gap: 7px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.nest-ico { font-size: 14px; }

.nest-card-meta {
    margin-left: auto;
    font-size: 10.5px;
    color: rgba(255, 255, 255, 0.35);
}

.nest-chevron {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.3);
    transition: transform 0.22s ease;
}

.nest-card.open .nest-chevron { transform: rotate(180deg); }

.nest-card-body { display: none; padding: 0 14px 14px; }
.nest-card.open .nest-card-body { display: block; }

.nest-btn {
    border: none;
    border-radius: 10px;
    padding: 8px 14px;
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
    transition: opacity 0.15s ease, transform 0.12s ease;
}

.nest-btn:active { transform: scale(0.96); }

.nest-btn.primary {
    background: linear-gradient(135deg, #ff69b4, #b06df0);
    color: #fff;
    font-weight: 600;
}

.nest-btn.ghost {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.7);
}

.nest-btn.small { padding: 7px 12px; font-size: 11.5px; }

.nest-btn:disabled { opacity: 0.45; cursor: default; transform: none; }

.nest-input,
.nest-textarea {
    width: 100%;
    padding: 9px 11px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.05);
    color: #e0e0e0;
    font-family: inherit;
    font-size: 13.5px;
    outline: none;
}

.nest-input:focus,
.nest-textarea:focus { border-color: rgba(255, 105, 180, 0.45); }

.nest-textarea {
    resize: none;
    line-height: 1.6;
    margin-bottom: 8px;
}

.nest-input::placeholder,
.nest-textarea::placeholder { color: rgba(255, 255, 255, 0.22); }

.nest-date { flex: none; width: auto; color-scheme: dark; }

.nest-form-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.nest-form-row .nest-input:not(.nest-date) { flex: 1; min-width: 120px; }

.nest-form-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 2px;
}

.nest-hint {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.3);
    line-height: 1.5;
}

.nest-list { margin-top: 8px; }

.nest-empty {
    padding: 12px 0;
    text-align: center;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.25);
}

.nest-del {
    width: 24px;
    height: 24px;
    flex: none;
    padding: 0;
    border: none;
    border-radius: 7px;
    background: none;
    color: rgba(255, 255, 255, 0.3);
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
}

.nest-sub-label {
    margin-bottom: 6px;
    font-size: 10.5px;
    color: rgba(255, 255, 255, 0.32);
}

/* 补记信封 */
.nest-envelope {
    position: relative;
    margin-bottom: 12px;
    padding: 13px 14px;
    border-radius: 14px;
    border: 1px solid rgba(255, 105, 180, 0.28);
    background: linear-gradient(135deg, rgba(255, 105, 180, 0.16), rgba(176, 109, 240, 0.12));
    box-shadow: 0 6px 20px rgba(255, 105, 180, 0.08);
}

.nest-envelope-top {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    letter-spacing: 0.4px;
    color: #ffb3d9;
}

.nest-envelope-text {
    margin: 8px 0 11px;
    font-size: 12.5px;
    line-height: 1.7;
    color: rgba(255, 255, 255, 0.78);
}

.nest-envelope-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* 全局浮层版本：不依赖小窝页面，任何页面都能看到 */
.global-envelope {
    position: absolute;
    top: calc(70px + env(safe-area-inset-top));
    left: 14px;
    right: 14px;
    z-index: 290;
    margin-bottom: 0;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    animation: envelopeIn 0.28s ease-out;
}

@keyframes envelopeIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 纪念日 */
.ann-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
    padding: 9px 10px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
}

.ann-days {
    min-width: 54px;
    font-size: 17px;
    font-weight: 700;
    color: #ff9ccb;
}

.ann-days small {
    margin-left: 2px;
    font-size: 10px;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.4);
}

.ann-info { flex: 1; min-width: 0; }
.ann-name { font-size: 13px; color: #e6e6e6; }
.ann-sub { margin-top: 2px; font-size: 10px; color: rgba(255, 255, 255, 0.32); }

/* 情绪打卡 */
.mood-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.mood-emoji {
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 11px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.2s ease, background-color 0.2s ease;
}

.mood-emoji.active {
    border-color: rgba(255, 105, 180, 0.55);
    background: rgba(255, 105, 180, 0.16);
    transform: translateY(-2px);
}

.mood-calendar-head {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin: 12px 0 6px;
}

.mood-cal-nav {
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.6);
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
}

.mood-month-label {
    font-size: 11.5px;
    letter-spacing: 0.5px;
    color: rgba(255, 255, 255, 0.55);
}

.mood-calendar {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.mood-cal-cell {
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.025);
    font-size: 10px;
    color: rgba(255, 255, 255, 0.28);
}

.mood-cal-cell.empty { background: none; }

.mood-cal-cell.has {
    color: #fff;
    font-weight: 600;
    cursor: pointer;
}

.mood-cal-cell.today { box-shadow: inset 0 0 0 1px rgba(255, 105, 180, 0.5); }

.mood-detail {
    margin-top: 8px;
    padding: 9px 11px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
    font-size: 12px;
    line-height: 1.65;
    color: rgba(255, 255, 255, 0.7);
}

.mood-curve-wrap { margin-top: 12px; }

.mood-curve {
    display: block;
    width: 100%;
    height: 78px;
}

/* 情绪拆解 */
.feel-hint {
    margin-bottom: 10px;
    font-size: 11px;
    line-height: 1.65;
    color: rgba(255, 255, 255, 0.4);
}

.feel-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.feel-field span {
    display: block;
    margin-bottom: 5px;
    font-size: 10.5px;
    color: rgba(255, 255, 255, 0.45);
}

.feel-item {
    margin-top: 6px;
    padding: 8px 10px;
    border-left: 2px solid rgba(255, 105, 180, 0.5);
    border-radius: 0 10px 10px 0;
    background: rgba(255, 255, 255, 0.04);
    font-size: 11.5px;
    line-height: 1.65;
    color: rgba(255, 255, 255, 0.6);
}

.feel-item-head {
    margin-bottom: 3px;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.3);
}

/* 时空胶囊 */
.tc-item {
    margin-top: 7px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(255, 255, 255, 0.04);
}

.tc-item.locked { opacity: 0.8; }

.tc-head {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
}

.tc-status {
    margin-left: auto;
    padding: 2px 7px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    font-size: 10px;
}

.tc-item.unlocked .tc-status {
    color: #ffb3d9;
    background: rgba(255, 105, 180, 0.15);
}

.tc-body {
    margin-top: 8px;
    font-size: 13.5px;
    line-height: 1.75;
    color: rgba(255, 255, 255, 0.82);
    white-space: pre-wrap;
}

.tc-locked-text {
    margin-top: 8px;
    font-size: 11.5px;
    color: rgba(255, 255, 255, 0.3);
}

.tc-reply { margin-top: 10px; }
.tc-reply-label { margin-bottom: 5px; font-size: 10.5px; color: rgba(255, 255, 255, 0.4); }

.tc-reply-text {
    padding: 8px 10px;
    border-radius: 10px;
    background: rgba(255, 105, 180, 0.08);
    font-size: 12px;
    line-height: 1.7;
    color: #ffd6e9;
    white-space: pre-wrap;
}

/* 梦境 */
.dream-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.dream-toggle-title { font-size: 12px; color: #e0e0e0; }
.dream-toggle-desc { margin-top: 2px; font-size: 10px; color: rgba(255, 255, 255, 0.3); }

.dream-item {
    margin-top: 7px;
    padding: 9px 11px;
    border-radius: 11px;
    background: rgba(255, 255, 255, 0.04);
}

.dream-date { font-size: 10px; letter-spacing: 0.4px; color: rgba(255, 255, 255, 0.3); }

.dream-content {
    margin-top: 5px;
    font-size: 13.5px;
    line-height: 1.7;
    color: rgba(255, 255, 255, 0.8);
    white-space: pre-wrap;
}

.dream-review {
    margin-top: 8px;
    padding: 8px 10px;
    border-left: 2px solid rgba(255, 105, 180, 0.45);
    border-radius: 0 9px 9px 0;
    background: rgba(255, 105, 180, 0.06);
    font-size: 12px;
    line-height: 1.7;
    color: rgba(255, 255, 255, 0.62);
    white-space: pre-wrap;
}

.dream-review-label { margin-bottom: 3px; font-size: 10px; color: #ffb3d9; }

/* 每日小记：翻日记本 */
.note-book {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
}

.note-page {
    position: relative;
    padding: 14px 14px 12px 20px;
    border-radius: 4px 12px 12px 4px;
    border: 1px solid rgba(255, 255, 255, 0.07);
    background: linear-gradient(180deg, rgba(255, 248, 240, 0.07), rgba(255, 248, 240, 0.032));
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}

.note-page::before {
    content: '';
    position: absolute;
    left: 9px;
    top: 10px;
    bottom: 10px;
    width: 1px;
    background: rgba(255, 105, 180, 0.25);
}

.note-date {
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.35);
}

.note-content {
    margin-top: 6px;
    font-family: inherit;
    font-size: 14.5px;
    line-height: 2;
    color: rgba(255, 255, 255, 0.82);
    white-space: pre-wrap;
    word-break: break-word;
}

.note-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 6px;
}

.note-mini {
    padding: 0;
    border: none;
    background: none;
    color: rgba(255, 255, 255, 0.3);
    font-size: 10px;
    font-family: inherit;
    cursor: pointer;
}

.note-sheet-panel {
    display: flex;
    flex-direction: column;
    max-height: 82vh;
}

.note-sheet-title { font-size: 13px; color: rgba(255, 255, 255, 0.75); }

.note-editor {
    flex: 1;
    min-height: 230px;
    margin: 12px 16px 16px;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
    color: #e6e6e6;
    font-family: inherit;
    font-size: 15px;
    line-height: 1.9;
    outline: none;
    resize: none;
}

.note-editor:focus { border-color: rgba(255, 105, 180, 0.45); }

/* ===================== 视口测量面板（仅 ?debug=1 / #debug 时注入） ===================== */
.dev-panel {
    position: fixed;
    inset: 0;
    z-index: 900;
    display: flex;
    flex-direction: column;
    background-color: rgba(8, 13, 20, 0.96);
    color: #e0e6ef;
}

.dev-panel-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.dev-panel-title {
    flex: 1;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.dev-panel-btn {
    padding: 6px 12px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 999px;
    background: transparent;
    color: rgba(255, 255, 255, 0.72);
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
}

.dev-panel-btn:active { background-color: rgba(255, 255, 255, 0.1); }

.dev-panel-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 10px 14px calc(24px + env(safe-area-inset-bottom));
}

.dev-note {
    padding: 10px 12px;
    margin-bottom: 8px;
    border-radius: 12px;
    background-color: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.5);
    font-size: 11px;
    line-height: 1.7;
}

.dev-row {
    display: flex;
    gap: 10px;
    padding: 9px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 12px;
}

.dev-row:last-child { border-bottom: none; }

.dev-key {
    flex: none;
    width: 128px;
    color: rgba(255, 255, 255, 0.4);
}

.dev-val {
    flex: 1;
    min-width: 0;
    color: #dfe7f2;
    font-family: var(--whale-font-family-code);
    font-size: 10.5px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-all;
}

.dev-val.warn { color: #ffb3d9; font-weight: 600; }
.dev-val.ok { color: #7ee2a8; }
