/* ============================================================
   JustYou 主题系统
   CSS 变量控制配色/深浅色/字体，方便以后整体换色
   ============================================================ */

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
    /* 低饱和度玫瑰色主色调（#C4828D），色相/饱和度可由设置页调节 */
    --accent-h: 350;
    --accent-s: 36%;
    --accent-l: 64%;
    --accent: hsl(var(--accent-h) var(--accent-s) var(--accent-l));
    --accent-strong: hsl(var(--accent-h) var(--accent-s) calc(var(--accent-l) - 12%));
    --accent-soft: hsl(var(--accent-h) var(--accent-s) var(--accent-l) / 0.35);

    --font-sans: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    --font: var(--font-sans);
    --font-script: "Snell Roundhand", "Bradley Hand", "Segoe Script", "Brush Script MT", cursive;
    --font-serif-italic: Georgia, "Songti SC", "Times New Roman", serif;
    --font-size-base: 16px;
    --font-weight-base: 400;

    --radius-lg: 20px;
    --radius-md: 14px;
    --radius-sm: 10px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-top: env(safe-area-inset-top, 0px);

    /* 三条统一的缓动曲线，社交 app 那种"手感"主要就是靠这个：
       大动作（页面/卡片进场）用又滑又不拖沓的 expo-out；按下瞬间要干脆，
       几乎没有缓动；松手回弹带一点点 overshoot，才不会显得生硬。 */
    --ease-smooth: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-snap: cubic-bezier(0.4, 0, 1, 1);
    --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* --- 深色（默认跟随系统） --- */
:root,
:root[data-theme="dark"] {
    --bg: #16121a;
    --bg-gradient:
        radial-gradient(circle at 15% 0%, hsl(var(--accent-h) var(--accent-s) 35% / 0.28), transparent 55%),
        radial-gradient(circle at 100% 15%, hsl(calc(var(--accent-h) - 40) 60% 30% / 0.22), transparent 50%),
        linear-gradient(165deg, #1c1521 0%, #16121a 45%, #1a1420 100%);
    --surface: #201a26;
    --surface-2: #2a2230;
    --text: #f3eef6;
    --text-dim: #b8adc4;
    --border: rgba(255, 255, 255, 0.08);
    --glass-bg: rgba(42, 34, 48, 0.5);
    --glass-border: rgba(255, 255, 255, 0.12);
    --bubble-user-bg: color-mix(in srgb, var(--accent) 55%, transparent);
    --bubble-ai-bg: rgba(42, 34, 48, 0.65);
    --nav-bg: rgba(22, 18, 26, 0.7);
    --shadow: 0 8px 28px rgba(0, 0, 0, 0.4);
    --shadow-soft: 0 10px 32px rgba(0, 0, 0, 0.3), 0 1px 0 rgba(255, 255, 255, 0.04) inset;
    --sticky-note-drop-shadow: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.4));
}

/* --- 浅色：淡粉色渐变，参考 iOS 设置页的柔和质感 --- */
/* 浅色：极淡粉灰底 + 白卡片 + 低饱和玫瑰强调色，参考 Claude 官网的高级灰质感，
   不用高饱和度的径向渐变色块 */
@media (prefers-color-scheme: light) {
    :root {
        --bg: #fdf2f4;
        --bg-gradient: linear-gradient(165deg, #fef8f9 0%, #fdf2f4 50%, #fbeef1 100%);
        --surface: #ffffff;
        --surface-2: #f7ecef;
        --text: #2d2d2d;
        --text-dim: #8a8385;
        --border: rgba(0, 0, 0, 0.06);
        --glass-bg: rgba(255, 255, 255, 0.72);
        --glass-border: rgba(255, 255, 255, 0.8);
        --bubble-user-bg: color-mix(in srgb, var(--accent) 45%, white 20%);
        --bubble-ai-bg: rgba(255, 255, 255, 0.72);
        --nav-bg: rgba(255, 255, 255, 0.75);
        --shadow: 0 8px 24px rgba(196, 130, 141, 0.14);
        --shadow-soft: 0 10px 30px rgba(196, 130, 141, 0.14), 0 1px 0 rgba(255, 255, 255, 0.6) inset;
        --sticky-note-drop-shadow: drop-shadow(0 8px 14px rgba(196, 130, 141, 0.28));
    }
}
:root[data-theme="light"] {
    --bg: #fdf2f4;
    --bg-gradient: linear-gradient(165deg, #fef8f9 0%, #fdf2f4 50%, #fbeef1 100%);
    --surface: #ffffff;
    --surface-2: #f7ecef;
    --text: #2d2d2d;
    --text-dim: #8a8385;
    --border: rgba(0, 0, 0, 0.06);
    --glass-bg: rgba(255, 255, 255, 0.72);
    --glass-border: rgba(255, 255, 255, 0.8);
    --bubble-user-bg: color-mix(in srgb, var(--accent) 55%, white 25%);
    --bubble-ai-bg: rgba(255, 255, 255, 0.72);
    --nav-bg: rgba(255, 255, 255, 0.75);
    --shadow: 0 8px 24px rgba(196, 130, 141, 0.14);
    --shadow-soft: 0 10px 30px rgba(196, 130, 141, 0.14), 0 1px 0 rgba(255, 255, 255, 0.6) inset;
    --sticky-note-drop-shadow: drop-shadow(0 8px 14px rgba(196, 130, 141, 0.28));
}
html, body {
    height: 100%;
    background: var(--bg-gradient);
    color: var(--text);
    font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-base);
    -webkit-font-smoothing: antialiased;
    overscroll-behavior-x: none;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    touch-action: pan-y;
    line-height: 1.5;
}

a, button, input, textarea, select {
    font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* ============================================================
   页面外壳 + 底部导航
   ============================================================ */

.app-shell {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* SPA 外壳（app.html）：聊天/主页/深处/设置/日历五个板块同时在 DOM 里，JS 只切 .hidden
   （配合 300ms 交叉淡入淡出），不重新加载文档。外层只是个 flex 中转层，每个板块自己决定
   是"整页滚动"（主页/深处/设置/日历）还是"内部固定高度、自己内容区滚"（聊天）。
   欢迎页不是单独的板块——它就是主页的一部分（欢迎卡片 + 收起的正文），
   见下面"欢迎页 / 主页合并"那一段。 */
.app-viewport { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
/* 注意：这里故意不用 animation（哪怕只是页面首次出现的淡入）——CSS animation 对同一属性
   的优先级高于 transition，只要这个板块被 display:none -> flex 切换过一次，
   animation 就会重新播放，把下面 switchTo() 精心编排的 transition 直接顶掉，
   表现出来就是"淡入淡出只有一半是丝滑的，剩下瞬间跳过去"。 */
.app-section { flex: 1; min-height: 0; }
.app-section[data-page="chat"], .app-section[data-page="workbench"] {
    display: flex; flex-direction: column; height: 100%;
}
.app-section:not([data-page="chat"]):not([data-page="workbench"]) {
    overflow-y: auto;
    overscroll-behavior-x: none;
    touch-action: pan-y;
    padding: calc(16px + var(--safe-top)) 16px calc(24px + var(--safe-bottom));
    -webkit-overflow-scrolling: touch;
}
/* 工作台跟聊天不完全一样：上面还有项目/会话选择器、tab 切换这些不该跟着消息区一起滚走的
   控件，所以自己加一层 padding（聊天页没有这层，是直接 flex:1 铺满），消息区/预览区
   各自用 flex:1 撑满剩下的高度，自己内部滚动。 */
.app-section[data-page="workbench"] {
    padding: calc(8px + var(--safe-top)) 16px 0;
    gap: 7px;
}

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

/* 聊天区顶部：加载更早历史消息时的占位/转圈 */
.chat-top-sentinel {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 0;
    overflow: hidden;
    transition: height 0.15s ease;
}
.chat-top-sentinel.loading { height: 36px; }
.chat-top-sentinel.hidden { display: none; }
.chat-top-spinner {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    animation: spin 0.7s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* AI 回复气泡：第一个 token 到达前的等待态进度条 */
.ai-progress-bar {
    width: 56px;
    height: 4px;
    border-radius: 2px;
    background: var(--border);
    overflow: hidden;
}
.ai-progress-bar span {
    display: block;
    height: 100%;
    width: 40%;
    border-radius: 2px;
    background: var(--accent);
    animation: ai-progress-sweep 1.1s ease-in-out infinite;
}
@keyframes ai-progress-sweep {
    0% { transform: translateX(-120%); }
    100% { transform: translateX(280%); }
}

/* 页面切换：点击站内链接时由 transitions.js 加上此类，做淡出过渡 */
body.page-leaving .app-shell {
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.18s ease, transform 0.18s ease;
}
.app-shell { transition: opacity 0.18s ease, transform 0.18s ease; }

/* ============================================================
   卡片 / 通用组件
   ============================================================ */

.card {
    background: var(--glass-bg);
    backdrop-filter: blur(20px) saturate(1.3);
    -webkit-backdrop-filter: blur(20px) saturate(1.3);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 18px;
    box-shadow: var(--shadow-soft);
    margin-bottom: 14px;
    transition: box-shadow 0.25s ease, transform 0.25s ease;
}
@media (hover: hover) {
    .card:hover { box-shadow: var(--shadow-soft), 0 0 0 1px var(--glass-border); transform: translateY(-1px); }
}

.card-title {
    font-size: 13px;
    color: var(--text-dim);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn {
    border: none;
    border-radius: var(--radius-sm);
    padding: 11px 18px;
    font-size: 14px;
    cursor: pointer;
    background: var(--surface-2);
    color: var(--text);
    transition: transform 0.22s var(--ease-bounce), opacity 0.15s, box-shadow 0.25s ease, filter 0.2s ease;
}
.btn:active { transform: scale(0.95); transition-duration: 0.08s; transition-timing-function: var(--ease-snap); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-danger { background: #e0607a; color: #fff; }
.btn-ghost { background: transparent; border: 1px solid var(--border); }

@media (hover: hover) {
    .btn:hover { transform: translateY(-1px); filter: brightness(1.06); box-shadow: 0 6px 16px rgba(0, 0, 0, 0.14); }
    .btn-primary:hover { box-shadow: 0 6px 18px var(--accent-soft); }
    .btn-ghost:hover { background: var(--surface-2); border-color: transparent; }
    .btn:active { transform: scale(0.95); box-shadow: none; transition-duration: 0.08s; transition-timing-function: var(--ease-snap); }
}

.input {
    width: 100%;
    padding: 13px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface-2);
    color: var(--text);
    font-size: 15px;
}
.input:focus { outline: none; border-color: var(--accent); }

/* 开关 */
.switch { position: relative; display: inline-block; width: 46px; height: 26px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
    position: absolute; inset: 0; background: var(--surface-2);
    border: 1px solid var(--border); border-radius: 999px; cursor: pointer;
    transition: background 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}
.switch .track::before {
    content: ""; position: absolute; width: 20px; height: 20px; left: 2px; top: 2px;
    background: #fff; border-radius: 50%; box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.25s ease;
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::before { transform: translateX(20px); }

@media (hover: hover) {
    .switch:hover .track { box-shadow: 0 0 0 5px var(--accent-soft); }
    .switch:hover .track::before { box-shadow: 0 2px 6px rgba(0,0,0,0.35); }
}

.row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 0;
}
.row + .row { border-top: 1px solid var(--border); }
.row-label { font-size: 14.5px; }
.row-hint { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

.slider {
    -webkit-appearance: none;
    width: 100%; height: 6px; border-radius: 999px;
    background: var(--surface-2);
    outline: none;
}
.slider::-webkit-slider-thumb {
    -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%;
    background: var(--accent); cursor: pointer; box-shadow: 0 2px 6px rgba(0,0,0,0.25);
    transition: transform 0.15s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.2s ease;
}
.slider::-moz-range-thumb {
    width: 20px; height: 20px; border-radius: 50%; border: none;
    background: var(--accent); cursor: pointer;
    transition: transform 0.15s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.2s ease;
}
@media (hover: hover) {
    .slider:hover::-webkit-slider-thumb { transform: scale(1.15); box-shadow: 0 4px 10px var(--accent-soft); }
    .slider:hover::-moz-range-thumb { transform: scale(1.15); }
}

.empty-state { text-align: center; color: var(--text-dim); font-size: 13.5px; padding: 24px 0; }

/* ============================================================
   登录页
   ============================================================ */

.login-page {
    min-height: 100vh; min-height: 100dvh;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 24px; gap: 20px;
    animation: page-fade-in 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.quote-card {
    width: 100%; max-width: 340px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px) saturate(1.3); -webkit-backdrop-filter: blur(20px) saturate(1.3);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    padding: 22px 20px;
    text-align: center;
}
.quote-text {
    font-family: var(--font);
    font-size: 16px; line-height: 1.8; color: var(--text);
    margin-bottom: 14px;
}
.heart-btn {
    background: none; border: none; cursor: pointer;
    font-size: 26px; line-height: 1; transition: transform 0.15s;
    filter: grayscale(1) opacity(0.5);
}
.heart-btn[data-level="1"] { filter: none; opacity: 0.55; }
.heart-btn[data-level="2"] { filter: none; opacity: 0.8; }
.heart-btn[data-level="3"] { filter: none; opacity: 1; transform: scale(1.1); }
.heart-btn:active { transform: scale(0.85); }
.heart-hint { font-size: 11px; color: var(--text-dim); margin-top: 6px; }

.login-card {
    width: 100%; max-width: 340px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px) saturate(1.3);
    -webkit-backdrop-filter: blur(20px) saturate(1.3);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 28px 22px;
    box-shadow: var(--shadow-soft);
    text-align: center;
}
.login-card h1 { font-size: 22px; margin-bottom: 18px; letter-spacing: 0.5px; }
.login-card .input { margin-bottom: 12px; text-align: center; }
.login-error { color: #e0607a; font-size: 13px; margin-top: 4px; }
.install-hint { color: var(--text-dim); font-size: 12px; margin-top: 16px; }

/* ============================================================
   主页
   ============================================================ */

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat-tile {
    background: var(--surface-2); border-radius: var(--radius-md);
    padding: 12px 14px;
}
.stat-tile .val { font-size: 19px; font-weight: 600; }
.stat-tile .lbl { font-size: 11.5px; color: var(--text-dim); margin-top: 2px; }

.collapsible-head {
    display: flex; align-items: center; justify-content: space-between;
    cursor: pointer;
}
.collapsible-head .chevron { transition: transform 0.2s; color: var(--text-dim); }
.collapsible-head.open .chevron { transform: rotate(180deg); }
.collapsible-body { max-height: 0; overflow: hidden; transition: max-height 0.25s ease; }
.collapsible-body.open { max-height: 600px; overflow-y: auto; }
.like-item {
    display: flex; justify-content: space-between; gap: 10px;
    padding: 8px 0; font-size: 13px; border-top: 1px solid var(--border);
}
.like-item .qt { color: var(--text-dim); flex: 1; }
.like-item .lv { flex-shrink: 0; }

/* ============================================================
   日历弹层
   ============================================================ */

.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.45);
    display: flex; align-items: flex-end; z-index: 100;
    animation: overlay-fade-in 0.22s ease both;
}
.modal-overlay.hidden { display: none; }
@keyframes overlay-fade-in {
    from { background: rgba(0,0,0,0); }
    to { background: rgba(0,0,0,0.45); }
}
.modal-sheet {
    width: 100%; max-height: 85vh; overflow-y: auto;
    background: var(--glass-bg);
    backdrop-filter: blur(20px) saturate(1.3);
    -webkit-backdrop-filter: blur(20px) saturate(1.3);
    border: 1px solid var(--glass-border);
    border-bottom: none;
    box-shadow: var(--shadow-soft);
    border-radius: 22px 22px 0 0;
    padding: 18px 18px calc(24px + var(--safe-bottom));
    animation: sheet-slide-up 0.28s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes sheet-slide-up {
    from { opacity: 0; transform: translateY(24px); }
    to { opacity: 1; transform: translateY(0); }
}
.modal-sheet-handle { width: 40px; height: 4px; background: var(--border); border-radius: 999px; margin: 0 auto 14px; }
.cal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.cal-header .title { font-size: 16px; font-weight: 600; }
.cal-header button { background: none; border: none; font-size: 18px; color: var(--text-dim); cursor: pointer; padding: 6px 10px; }

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; margin-bottom: 8px; }
.cal-dow { font-size: 11px; color: var(--text-dim); padding: 4px 0 8px; }
.cal-day {
    aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    border-radius: 50%; font-size: 13px; position: relative; cursor: pointer; color: var(--text);
    transition: background 0.2s ease, transform 0.15s var(--ease-snap), box-shadow 0.2s ease;
}
.cal-day.other-month { color: var(--text-dim); opacity: 0.35; }
.cal-day .dot { width: 5px; height: 5px; border-radius: 50%; margin-top: 2px; }
.cal-day.has-period { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.cal-day.has-important .dot { background: #c9973f; }
.cal-day.has-period .dot { background: var(--accent); }
/* 有AI心情批注的一天：格子打一层很淡的暖色底，跟经期的强调色区分开，
   一眼扫过月历就能看出"这几天他有留话" */
.cal-day.has-mood { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.cal-day.has-mood.has-period { background: color-mix(in srgb, var(--accent) 26%, transparent); }
/* 按下的轻微回弹，弥补目前月历里唯一的动效只有"选中"这一种，日常点按也该有点反馈 */
.cal-day:active { transform: scale(0.9); }

/* 今天：玫瑰色圆形高亮（放在 has-period/has-important 后面，优先级更高） */
.cal-day.today { background: var(--accent); color: #fff; box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 45%, transparent); }
.cal-day.today .dot { background: #fff; }

/* 有聊天记录的日期：底部一个中性小圆点，跟经期/纪念日的强调色圆点区分开 */
.cal-day.has-messages::after {
    content: ""; position: absolute; bottom: 4px; left: 50%; transform: translateX(-50%);
    width: 4px; height: 4px; border-radius: 50%; background: var(--text-dim);
}
.cal-day.today.has-messages::after { background: rgba(255, 255, 255, 0.85); }

/* 选中的日期：缩放弹跳一下 */
@keyframes cal-day-bounce {
    0% { transform: scale(0.9); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}
.cal-day.selected { animation: cal-day-bounce 320ms ease-out; box-shadow: 0 0 0 2px var(--accent-strong); }

.cal-editor { margin-top: 16px; }
.type-toggle { display: flex; gap: 8px; margin-bottom: 10px; }
.type-toggle button {
    flex: 1; padding: 10px; border-radius: var(--radius-sm); border: 1px solid var(--border);
    background: var(--surface-2); color: var(--text-dim); cursor: pointer; font-size: 13px;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}
.type-toggle button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.type-toggle button:active { transform: scale(0.96); }
@media (hover: hover) {
    .type-toggle button:hover:not(.active) { border-color: var(--accent); color: var(--text); }
}

/* ============================================================
   聊天页
   ============================================================ */

.chat-header {
    position: sticky; top: 0; z-index: 10;
    display: grid; grid-template-columns: 36px 1fr auto; align-items: center; gap: 10px;
    padding: calc(14px + var(--safe-top)) 12px 14px;
    background: transparent;
}
.chat-header-right { grid-column: 3; display: flex; align-items: center; gap: 2px; }
.chat-header-center { grid-column: 2; text-align: center; min-width: 0; }
.chat-title-script { font-family: var(--font-script); font-size: 21px; color: var(--text); line-height: 1.2; }
.chat-model-switch {
    display: inline-flex; align-items: center; gap: 3px; margin-top: 2px;
    background: none; border: none; cursor: pointer;
    font-size: 11.5px; color: var(--text-dim); max-width: 100%;
}
.chat-model-switch span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-model-chevron { font-size: 9px; flex-shrink: 0; }

/* 副本世界里显示当前世界名字的小标签，点了直接回主线 */
.world-badge {
    display: inline-flex; align-items: center; gap: 4px; margin-top: 2px; max-width: 100%;
    background: var(--accent-soft); border: none; border-radius: 999px; cursor: pointer;
    padding: 2px 10px; font-size: 11px; color: var(--accent);
}
.world-badge.hidden { display: none; }
.world-badge span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.icon-btn {
    width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    background: transparent; border: none; color: var(--text-dim); cursor: pointer;
    transition: background 0.18s ease, color 0.18s ease, transform 0.22s var(--ease-bounce);
}
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn:active { transform: scale(0.85); transition-duration: 0.08s; transition-timing-function: var(--ease-snap); }
@media (hover: hover) {
    .icon-btn:hover { background: var(--surface-2); color: var(--text); }
}

/* 主线聊天窗口右上角的上下文用量圆环：当前窗口累计喂给模型的 token 数 / 压缩门槛(150k)，
   点开看这一轮的摘要（见 chat.js refreshContextRing / openContextSummarySheet，
   接口 GET /api/conversations/<id>/context）。复用 .icon-btn 的点击态，圆环本身用 svg
   stroke-dasharray 画出进度，不额外起一套按钮样式。 */
.context-ring-btn svg.context-ring-svg { width: 30px; height: 30px; transform: rotate(-90deg); }
.context-ring-bg { stroke: var(--border); }
.context-ring-fg {
    stroke: var(--accent); stroke-dasharray: 97.4; stroke-dashoffset: 97.4;
    transition: stroke-dashoffset 0.4s ease, stroke 0.3s ease;
}
/* 用量快摸到门槛（触发压缩前夕）：圆环变个更醒目的颜色提示一下，压缩本身仍然是后台自动做的，
   这里纯粹是可视化，不影响触发逻辑 */
.context-ring-fg.near-threshold { stroke: #c9973f; }

.chat-messages {
    flex: 1; overflow-y: auto; overscroll-behavior-x: none; touch-action: pan-y;
    padding: 16px 16px calc(90px + var(--safe-bottom) + var(--keyboard-inset, 0px));
    display: flex; flex-direction: column; gap: 8px;
    -webkit-overflow-scrolling: touch;
}

/* 气泡最大宽度：左右统一用固定像素留白（不再用百分比），保证两边贴边距离对称，
   宽屏下也不会一边（user 92%）比另一边（assistant 100%-32px）更早封顶——之前这两条规则
   算出来的留白在窄屏上凑巧接近、宽屏上差得很明显，是"间距不对称"的真正原因 */
.msg-row { display: flex; flex-direction: column; max-width: calc(100% - 16px); min-width: 0; user-select: none; -webkit-user-select: none; }
.msg-row.user { align-self: flex-end; align-items: flex-end; }
.msg-row.assistant { align-self: flex-start; align-items: flex-start; }
.msg-row.pending { opacity: 0.7; }

/* 第一行：头像 + 名字，水平排列；第二行开始（thinking / 气泡）不跟头像并排，
   靠 .msg-row 的 align-items 统一控制左右对齐，跟头像左（右）边对齐 */
.msg-header { display: flex; align-items: center; gap: 8px; max-width: 100%; min-width: 0; margin-bottom: 6px; }
.msg-row.user .msg-header { flex-direction: row-reverse; }

.msg-avatar {
    width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
    object-fit: cover;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.16), 0 0 0 1px var(--glass-border) inset;
}
/* 占位头像：圆形底 + 姓氏首字。江妄用主题玫瑰色（跟气泡/强调色统一），
   阿荞用一支柔和的丁香紫作对照——两个人各有自己的颜色，但都在同一套低饱和、
   温柔基调里，不会显得跳或廉价 */
.msg-avatar-fallback {
    background: linear-gradient(150deg, var(--accent), var(--accent-strong));
    display: flex; align-items: center; justify-content: center; color: #fff;
    font-size: 13px; font-weight: 600; letter-spacing: 0.2px;
    font-family: var(--font-serif-italic), var(--font);
}
.msg-row.user .msg-avatar-fallback {
    background: linear-gradient(150deg, hsl(272 26% 74%), hsl(272 30% 54%));
}

.msg-name { font-size: 11.5px; color: var(--text-dim); font-weight: 500; letter-spacing: 0.2px; }

.msg-thinking-slot { width: 100%; }
.msg-thinking-slot:empty { display: none; }
.thinking-box { width: 100%; margin-bottom: 6px; }
.thinking-toggle {
    display: flex; align-items: center; gap: 3px;
    background: none; border: none; padding: 3px 4px; margin-left: -4px;
    font-size: 11px; color: var(--text-dim); cursor: pointer;
}
.thinking-chevron { width: 12px; height: 12px; flex-shrink: 0; transition: transform 0.2s ease; }
.thinking-box.open .thinking-chevron { transform: rotate(90deg); }
.thinking-content {
    display: none;
    margin-top: 2px; padding: 8px 10px; border-radius: 10px;
    background: var(--surface-2); color: var(--text-dim);
    font-size: 12px; line-height: 1.5; white-space: pre-wrap; word-break: break-word;
}
.thinking-box.open .thinking-content { display: block; }

.bubble-wrap { max-width: 100%; }

.bubble {
    padding: 12px 15px; border-radius: 18px; line-height: 1.6; font-size: calc(var(--font-size-base) - 2px);
    white-space: pre-wrap; word-break: break-word;
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    box-shadow: 0 4px 14px rgba(0,0,0,0.12);
}
.msg-row.user .bubble { background: var(--bubble-user-bg); color: #fff; border-bottom-right-radius: 5px; }
.msg-row.assistant .bubble { background: var(--bubble-ai-bg); border-bottom-left-radius: 5px; }

/* 微信式"对方正在输入"占位气泡：工作台专用（见 workbench.js showTypingIndicator）——
   发消息后立刻插一条这个，等真正内容开始流式返回时再整个换掉，不用干等着空屏幕 */
.bubble.typing-indicator { display: flex; align-items: center; gap: 4px; padding: 14px 16px; }
.typing-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--text-dim);
    animation: typing-bounce 1.2s infinite ease-in-out;
}
.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* 状态栏渲染卡片：只给个位置/最大宽度，内容/配色/边框全部由角色卡/世界书/预设里让模型
   自己生成的HTML决定（通常会带内联样式），这里不做任何视觉假设，容器本身空的时候不占地方。
   white-space: pre-wrap 是必须的——酒馆状态栏预设的典型写法是纯换行分隔字段（不是每行都套
   <br>/<p>），HTML默认会把这些换行当空白折叠掉，不加这条会导致所有字段挤成一堆看不清的
   紧密文字（2026-07-21 真实撞见过）。 */
.status-bar-slot:empty { display: none; }
.status-bar-card { max-width: 100%; margin-top: 6px; overflow-x: auto; white-space: pre-wrap; }

.msg-footer { display: flex; align-items: center; gap: 8px; margin-top: 4px; padding: 0 4px; }
.msg-row.user .msg-footer { flex-direction: row-reverse; }
.msg-time { font-size: 10.5px; color: var(--text-dim); }

.msg-version-nav { display: flex; align-items: center; gap: 4px; font-size: 10.5px; color: var(--text-dim); }
.msg-version-nav button {
    background: none; border: none; color: var(--text-dim); cursor: pointer;
    font-size: 13px; line-height: 1; padding: 2px 4px;
}
.msg-version-nav button:active { color: var(--accent); }

/* 发送后的可中断控件：3秒撤回倒计时 / 生成中随时停止，悬浮在输入框上方 */
.chat-abort-btn {
    position: fixed;
    left: 50%;
    bottom: calc(66px + var(--safe-bottom) + var(--keyboard-inset, 0px));
    transform: translateX(-50%);
    z-index: 5;
    padding: 7px 16px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 12.5px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.18);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    cursor: pointer;
    transition: bottom 0.15s ease;
}
.chat-abort-btn:active { transform: translateX(-50%) scale(0.94); }

.chat-input-bar {
    position: fixed; left: 0; right: 0; bottom: var(--safe-bottom);
    display: flex; gap: 8px; align-items: flex-end;
    padding: 10px 12px;
    background: var(--nav-bg);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
}
.chat-input-bar textarea {
    flex: 1; padding: 11px 16px; border-radius: 20px; border: 1px solid var(--border);
    background: var(--surface-2); color: var(--text); font-size: 15px;
    font-family: inherit; line-height: 1.4; resize: none;
    max-height: 132px; overflow-y: hidden;
}
.chat-input-bar textarea:focus { outline: none; border-color: var(--accent); }
.expand-btn {
    width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--border);
    background: var(--surface-2); color: var(--text-dim); flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.18s cubic-bezier(0.22, 1, 0.36, 1), color 0.15s ease;
}
.expand-btn svg { width: 17px; height: 17px; }
.expand-btn:active { transform: scale(0.92); }
@media (hover: hover) {
    .expand-btn:hover { color: var(--accent); border-color: var(--accent); }
}
.send-btn {
    width: 42px; height: 42px; border-radius: 50%; border: none;
    background: var(--accent); color: #fff; font-size: 17px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.18s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.2s ease, filter 0.2s ease;
}
.send-btn:disabled { opacity: 0.5; }
.send-btn:active:not(:disabled) { transform: scale(0.92); }
@media (hover: hover) {
    .send-btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 6px 16px var(--accent-soft); filter: brightness(1.06); }
}
.wb-code-btn {
    width: 34px; height: 34px; font-size: 14px; margin-left: 6px; align-self: center;
    background: var(--surface-2); color: var(--text-dim); border: 1px solid var(--border);
}
.wb-code-btn:active:not(:disabled) { transform: scale(0.92); background: var(--accent); color: #fff; }

/* 全屏编辑输入框 */
.fullscreen-editor {
    position: fixed; inset: 0; z-index: 200;
    display: flex; flex-direction: column;
    background: var(--bg-gradient);
    padding-top: var(--safe-top);
}
.fullscreen-editor.hidden { display: none; }
.fullscreen-editor-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 14px; border-bottom: 1px solid var(--border);
}
.fullscreen-editor-title { font-size: 15px; font-weight: 600; }
.fullscreen-editor-textarea {
    flex: 1; border: none; background: transparent; color: var(--text);
    font-family: inherit; font-size: 16px; line-height: 1.6;
    padding: 16px; resize: none; outline: none;
}

/* 跨窗口只读预览：照抄 .fullscreen-editor 的全屏 overlay 模式 */
.peek-overlay {
    position: fixed; inset: 0; z-index: 200;
    display: flex; flex-direction: column;
    background: var(--bg-gradient);
    padding-top: var(--safe-top);
}
.peek-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 14px; border-bottom: 1px solid var(--border);
}
.peek-title { font-size: 15px; font-weight: 600; }
.peek-messages {
    flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
    padding: 16px 16px calc(16px + var(--safe-bottom));
    display: flex; flex-direction: column; gap: 8px;
}

/* 切换聊天窗口的列表（抽屉「切换副本世界」打开的 sheet） */
.conv-list { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.conv-row { display: flex; align-items: center; gap: 4px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.conv-row:last-child { border-bottom: none; }
.conv-row-main { flex: 1; min-width: 0; text-align: left; background: none; border: none; padding: 4px 0; cursor: pointer; }
.conv-row-title { font-size: 14.5px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-row-preview { font-size: 12px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.conv-row-icon {
    flex-shrink: 0; background: none; border: none; color: var(--text-dim); cursor: pointer;
    font-size: 13px; padding: 6px 8px;
}
@media (hover: hover) {
    .conv-row-icon:hover { color: var(--accent); }
}

/* 聊天页有自己的输入栏，底部导航往下移；隐藏聊天页多余空间 */
body.no-scroll-body { overflow: hidden; }

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

.avatar-row { display: flex; gap: 24px; }
.avatar-upload-item { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.avatar-preview {
    width: 64px; height: 64px; border-radius: 50%; object-fit: cover;
    background: linear-gradient(135deg, var(--accent-soft), var(--surface-2));
    border: 1px solid var(--glass-border);
}
.avatar-upload-item .row-label { font-size: 12.5px; }
.avatar-upload-item .btn { padding: 6px 14px; font-size: 12.5px; }

.color-swatches { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.swatch {
    width: 34px; height: 34px; border-radius: 50%; border: 2px solid transparent;
    cursor: pointer; position: relative;
    transition: transform 0.18s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.2s ease, box-shadow 0.2s ease;
}
.swatch.active { border-color: var(--text); }
.swatch:active { transform: scale(0.9); }
@media (hover: hover) {
    .swatch:hover { transform: scale(1.12); box-shadow: 0 4px 12px rgba(0,0,0,0.2); }
}

.font-toggle, .theme-toggle { display: flex; gap: 8px; margin-top: 8px; }
.font-toggle button, .theme-toggle button {
    flex: 1; padding: 10px; border-radius: var(--radius-sm); border: 1px solid var(--border);
    background: var(--surface-2); color: var(--text-dim); cursor: pointer; font-size: 13px;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}
.font-toggle button.active, .theme-toggle button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.font-toggle button:active, .theme-toggle button:active { transform: scale(0.96); }
@media (hover: hover) {
    .font-toggle button:hover:not(.active), .theme-toggle button:hover:not(.active) { border-color: var(--accent); color: var(--text); }
}

/* ============================================================
   经期关心卡片
   ============================================================ */

.hidden { display: none !important; }

.period-phase { font-size: 14px; line-height: 1.6; }
.period-next { font-size: 13px; color: var(--text-dim); margin-top: 10px; }
.discomfort-list { list-style: none; margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.discomfort-list li {
    font-size: 12.5px; color: var(--text-dim); padding-left: 14px; position: relative;
}
.discomfort-list li::before {
    content: ""; position: absolute; left: 0; top: 6px;
    width: 5px; height: 5px; border-radius: 50%; background: var(--accent);
}
.period-care {
    font-family: var(--font); font-size: 14px; line-height: 1.7;
    margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border);
    color: var(--text);
}

/* ============================================================
   日历日备注（用户 + AI）
   ============================================================ */

.cal-day .note-mark {
    position: absolute; top: 2px; right: 4px; font-size: 8px; color: var(--accent);
}
.cal-day .mood-mark {
    position: absolute; top: 1px; right: 3px; font-size: 8px; color: var(--accent-strong);
}
.cal-day.today .mood-mark { color: rgba(255, 255, 255, 0.9); }
/* 便利贴标记放左上角，跟心情/备注（右上角）错开，不用抢同一个位置 */
.cal-day .sticky-mark { position: absolute; top: 2px; left: 4px; font-size: 7px; opacity: 0.75; }
.cal-day.today .sticky-mark { opacity: 0.95; }

.day-note-item {
    padding: 10px 0; border-top: 1px solid var(--border);
    font-size: 13.5px; line-height: 1.55;
}
.day-note-item:first-child { border-top: none; }
.day-note-item .dn-head {
    display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px;
}
.day-note-item .dn-author { font-size: 11.5px; color: var(--accent); font-weight: 600; }
.day-note-item.author-ai .dn-author { color: var(--text-dim); }
.day-note-item .dn-time { font-size: 10.5px; color: var(--text-dim); }
.day-note-item .dn-del {
    background: none; border: none; color: var(--text-dim); font-size: 12px; cursor: pointer; padding: 2px 6px;
}

/* ============================================================
   深处页
   ============================================================ */

.deep-title { font-size: 20px; font-weight: 700; letter-spacing: 1px; }
.deep-sub { font-size: 12.5px; color: var(--text-dim); margin-top: 2px; }

.section-back-header { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
/* 工作台顶部留白比其它板块更紧凑一点，把省下的高度让给聊天记录区（移动端竖屏优先） */
.app-section[data-page="workbench"] .section-back-header { margin-bottom: 6px; }
.back-btn {
    width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
    background: var(--surface-2); border: none; color: var(--text-dim);
    display: flex; align-items: center; justify-content: center; cursor: pointer;
    transition: transform 0.22s var(--ease-bounce);
}
.back-btn svg { width: 17px; height: 17px; }
.back-btn:active { transform: scale(0.88); transition-duration: 0.08s; transition-timing-function: var(--ease-snap); }

.deep-card { padding: 16px 18px; }
.deep-icon { margin-right: 2px; }

.deep-persona-textarea {
    margin-top: 12px; font-family: var(--font); resize: vertical; line-height: 1.6;
    min-height: 220px;
}
.deep-persona-actions {
    display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 10px;
}
.deep-save-hint { font-size: 12px; color: var(--text-dim); }

.deep-list { margin-top: 4px; }
.deep-item { padding: 10px 0; border-top: 1px solid var(--border); font-size: 13.5px; line-height: 1.6; }
.deep-item:first-child { border-top: none; }
.deep-item-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.deep-item-summary { flex: 1; min-width: 0; }
.deep-tag { flex-shrink: 0; font-size: 12px; color: var(--text-dim); }
.deep-item-actions { flex-shrink: 0; display: flex; gap: 2px; }
.deep-item-edit, .deep-item-delete {
    flex-shrink: 0; background: none; border: none; cursor: pointer;
    color: var(--text-dim); font-size: 13px; line-height: 1; padding: 4px;
}
.deep-item-edit:active { color: var(--accent); }
.deep-item-delete:active { color: #e0607a; }
.deep-item-edit:disabled, .deep-item-delete:disabled { opacity: 0.4; }
.deep-item-meta { font-size: 11.5px; color: var(--text-dim); margin-top: 4px; }
.deep-item-date { font-size: 12px; color: var(--accent); font-weight: 600; margin-bottom: 4px; }
.deep-item-body { color: var(--text); }

/* 情绪面板：8个同色阶(accent)量表，track是accent更淡的一阶，fill是accent本身——
   不用彩虹色区分8个维度，靠图标+文字识别身份，颜色只承担"这一维现在有多满"这一件事 */
.emotion-meter-group { display: flex; flex-direction: column; gap: 12px; }
.emotion-meter-row { display: flex; align-items: center; gap: 10px; }
.emotion-meter-icon { font-size: 15px; width: 20px; text-align: center; flex-shrink: 0; }
.emotion-meter-label { font-size: 13px; color: var(--text-dim); width: 44px; flex-shrink: 0; }
.emotion-meter-track {
    flex: 1; height: 8px; border-radius: 999px;
    background: var(--accent-soft); overflow: hidden;
}
.emotion-meter-fill {
    height: 100%; border-radius: 999px; background: var(--accent);
    transition: width 0.6s var(--ease-smooth);
}
.emotion-meter-value {
    font-size: 12px; color: var(--text-dim); width: 34px; text-align: right; flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}
.emotion-event-delta { font-variant-numeric: tabular-nums; }
.emotion-event-delta.up { color: var(--accent); }
.emotion-event-delta.down { color: var(--text-dim); }

#memory-list .deep-item { cursor: pointer; }

.memory-detail-title { font-size: 16px; font-weight: 600; line-height: 1.5; padding-right: 8px; }
.memory-detail-meta { font-size: 12px; color: var(--text-dim); margin-top: 6px; }
.memory-detail-body {
    margin-top: 14px; font-size: 13.5px; line-height: 1.7; color: var(--text);
    max-height: 55vh; overflow-y: auto;
}
.memory-detail-line { margin-bottom: 8px; white-space: pre-wrap; }

/* 上下文用量圆环点开的摘要面板，复用 .memory-detail-* 那套排版 */
.context-summary-meta { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.context-summary-progress {
    height: 5px; border-radius: 999px; background: var(--border); margin-top: 10px; overflow: hidden;
}
.context-summary-progress span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.context-summary-section-title {
    font-size: 12.5px; font-weight: 600; color: var(--accent); margin-top: 16px; margin-bottom: 6px;
}
.context-summary-text {
    font-size: 13.5px; line-height: 1.7; color: var(--text); white-space: pre-wrap; word-break: break-word;
}
.context-summary-empty { font-size: 13px; color: var(--text-dim); margin-top: 14px; line-height: 1.6; }
.memory-detail-label { font-weight: 600; color: var(--accent); margin-right: 2px; }
.memory-detail-actions { display: flex; gap: 10px; margin-top: 16px; }
.memory-detail-actions .btn { flex: 1; }
.deep-edit-textarea { width: 100%; min-height: 80px; resize: vertical; font-size: 13.5px; line-height: 1.6; }
.deep-edit-actions { display: flex; gap: 8px; margin-top: 8px; }

.blackbox-gate { text-align: center; padding: 18px 8px 8px; }
.blackbox-gate-text { font-size: 13px; color: var(--text-dim); margin-bottom: 14px; line-height: 1.6; }

.memory-import-panel { margin-top: 10px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); }
.memory-import-mode {
    display: flex; align-items: center; gap: 6px;
    font-size: 12.5px; color: var(--text-dim); padding: 4px 0; cursor: pointer;
}
.memory-import-status { font-size: 12px; color: var(--text-dim); margin-top: 8px; min-height: 16px; }

/* ============================================================
   欢迎页 / 主页合并成一个板块（data-page="home"）
   ============================================================
   欢迎卡片和主页的卡片都在同一份 DOM 里，全靠 data-stage="welcome"|"entered"
   这一个属性驱动 CSS，没有另外的"迷你欢迎卡片"，也没有第二个板块跟它交叉淡出。
   data-stage 从服务端渲染就定好初值（/ 是 welcome，/home 直接是 entered），
   点一下欢迎卡片只改这一个属性，下面所有规则在同一次样式重算里联动生效：
   欢迎卡片压缩上移、装饰淡出、背景洗白、正文展开推挤欢迎卡片。 */

.app-section[data-page="home"] {
    position: relative;
    display: flex; flex-direction: column; align-items: center;
    padding-top: 18vh;
    background: linear-gradient(160deg, #fdf2f4 0%, #f0d5da 55%, #c4828d 100%);
    transition: padding-top 600ms var(--ease-smooth);
}
.app-section[data-page="home"][data-stage="entered"] {
    padding-top: calc(16px + var(--safe-top));
}

/* 背景不要突变：渐变没法平滑插值，所以叠一层纯色遮罩，靠 opacity 过渡把
   欢迎态的粉色"洗"成主页正常的背景色 */
.app-section[data-page="home"]::before {
    content: ""; position: absolute; inset: 0; background: var(--bg);
    opacity: 0; transition: opacity 600ms var(--ease-smooth); pointer-events: none; z-index: 0;
}
.app-section[data-page="home"][data-stage="entered"]::before { opacity: 1; }

.welcome-hearts { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.deco-heart { position: absolute; color: rgba(255, 255, 255, 0.55); }
.welcome-hearts, .welcome-tap-hint { transition: opacity 400ms var(--ease-smooth); }
.app-section[data-page="home"][data-stage="entered"] .welcome-hearts,
.app-section[data-page="home"][data-stage="entered"] .welcome-tap-hint {
    opacity: 0; pointer-events: none;
}

/* 欢迎卡片：同一个元素，压缩变小 + 跟着父级 padding-top 收窄自然"滑"到顶部，
   不用 translateY 硬指定位移量，避免跟 padding 的位移重复计算、对不上 */
.welcome-card {
    width: 100%; max-width: 360px; z-index: 1;
    background: rgba(255, 255, 255, 0.78);
    backdrop-filter: blur(20px) saturate(1.3); -webkit-backdrop-filter: blur(20px) saturate(1.3);
    border-radius: 28px; box-shadow: 0 20px 45px rgba(196, 130, 141, 0.25);
    padding: 34px 24px; text-align: center;
    transition: transform 600ms var(--ease-smooth), padding 600ms var(--ease-smooth), box-shadow 600ms var(--ease-smooth);
    transform-origin: center top;
}
.app-section[data-page="home"][data-stage="entered"] .welcome-card {
    transform: scale(0.68);
    padding: 14px 16px;
    box-shadow: var(--shadow-soft);
    margin-bottom: -20px; /* scale 会在视觉上留出一圈空白，用负 margin 把下面内容拉近一点 */
}
.welcome-heart-icon { color: var(--accent-strong); margin-bottom: 14px; transition: opacity 400ms var(--ease-smooth), height 400ms var(--ease-smooth), margin 400ms var(--ease-smooth); overflow: hidden; }
.welcome-heart-icon svg { width: 32px; height: 32px; }
.app-section[data-page="home"][data-stage="entered"] .welcome-heart-icon {
    opacity: 0; height: 0; margin: 0;
}
.welcome-greeting { font-family: var(--font-script); font-size: 25px; color: var(--accent-strong); line-height: 1.4; margin-bottom: 18px; transition: font-size 600ms var(--ease-smooth), margin 600ms var(--ease-smooth); }
.app-section[data-page="home"][data-stage="entered"] .welcome-greeting { font-size: 15px; margin-bottom: 4px; }

.welcome-days { display: flex; align-items: baseline; justify-content: center; gap: 6px; }
.welcome-days-num {
    font-family: var(--font-serif-italic); font-size: 52px; font-weight: 700; color: var(--accent-strong);
    line-height: 1; transition: font-size 600ms var(--ease-smooth), color 600ms var(--ease-smooth);
}
.welcome-days-unit { font-size: 14px; color: var(--text-dim); letter-spacing: 1px; }
.welcome-since { font-size: 12.5px; color: rgba(45, 45, 45, 0.6); margin-top: 6px; letter-spacing: 0.5px; transition: color 600ms var(--ease-smooth); }
.app-section[data-page="home"][data-stage="entered"] .welcome-days-num { font-size: 30px; color: var(--accent); }
.app-section[data-page="home"][data-stage="entered"] .welcome-since { color: var(--text-dim); }

.welcome-quote-card {
    width: 100%; max-width: 360px; z-index: 1;
    background: rgba(255, 255, 255, 0.55);
    backdrop-filter: blur(20px) saturate(1.3); -webkit-backdrop-filter: blur(20px) saturate(1.3);
    border-radius: var(--radius-lg); box-shadow: none;
    padding: 18px 20px; text-align: center; margin: 14px 0;
    transition: background 600ms var(--ease-smooth), border 600ms var(--ease-smooth),
                box-shadow 600ms var(--ease-smooth), padding 600ms var(--ease-smooth), margin 600ms var(--ease-smooth);
}
.app-section[data-page="home"][data-stage="entered"] .welcome-quote-card {
    background: var(--glass-bg); border: 1px solid var(--glass-border); box-shadow: var(--shadow-soft);
    padding: 12px 16px; margin: 10px 0;
}
.welcome-quote-text { font-style: italic; font-size: 14.5px; line-height: 1.7; color: var(--text); }
.welcome-quote-sign { font-size: 12px; color: var(--text-dim); margin-top: 10px; }

.welcome-tap-hint { font-size: 12.5px; color: rgba(45, 45, 45, 0.55); letter-spacing: 1px; z-index: 1; }

/* 便利贴：闲时随手写的一句话，故意跟其它玻璃拟态卡片不同调——纸感、微斜、像真的贴上去的，
   一眼就能跟"今天的一句话"引用卡区分开、跟主页背景（浅粉渐变）拉开对比。用顶部胶带+横线纸纹+
   上下撕边伪造"从便签本上撕下来"的样子，::before 描一圈同形状的深色轮廓当"边框"。
   配色刻意用低饱和米色纸张，不跟着 --accent-h 走——真实的纸不会因为 app 主题换色变粉，
   跟 --text/--bg 脱钩是有意的。
   clip-path 会把普通 box-shadow/border 一起裁掉且不会跟着毛边走样，所以：
   1) 阴影改用 filter: drop-shadow()，天然贴合裁剪后的轮廓；
   2) "边框"改用 ::before 叠一层同形状、四周大 2px 的深色底，露出的 2px 就是描边。 */
:root { --sticky-torn-shape: polygon(
    0% 0.8%, 5% 0%, 10% 1.2%, 15% 0.2%, 20% 1%, 25% 0%, 30% 1.2%, 35% 0.3%, 40% 1%, 45% 0%,
    50% 1.2%, 55% 0.2%, 60% 1%, 65% 0%, 70% 1.2%, 75% 0.3%, 80% 1%, 85% 0%, 90% 1.2%, 95% 0.2%, 100% 0.8%,
    100% 99.2%, 95% 100%, 90% 98.8%, 85% 99.8%, 80% 99%, 75% 100%, 70% 98.8%, 65% 99.7%, 60% 99%, 55% 100%,
    50% 98.8%, 45% 99.8%, 40% 99%, 35% 100%, 30% 98.8%, 25% 99.7%, 20% 99%, 15% 100%, 10% 98.8%, 5% 99.8%, 0% 99.2%
); }
.sticky-note {
    position: relative; z-index: 0; width: 100%; max-width: 340px; margin: 14px auto 18px;
    padding: 26px 18px 18px;
    background:
        repeating-linear-gradient(180deg, transparent 0 27px, hsl(28 40% 35% / 0.07) 27px 28px),
        linear-gradient(180deg, hsl(46 70% 98%), hsl(40 55% 94%));
    clip-path: var(--sticky-torn-shape);
    filter: var(--sticky-note-drop-shadow);
    transform: rotate(-1.4deg);
    transition: transform 250ms var(--ease-smooth), opacity 300ms var(--ease-smooth), max-height 300ms var(--ease-smooth);
}
.sticky-note::before {
    content: ""; position: absolute; inset: -2px; z-index: -1;
    background: hsl(30 30% 55%); clip-path: var(--sticky-torn-shape);
}
.sticky-note:hover { transform: rotate(-0.3deg) scale(1.012); }
.sticky-note.hidden { display: none; }
/* 顶部胶带，贴在撕边上方，遮住一点毛边——用米卡其色的和纸胶带，不用玫瑰色，
   跟纸张的低饱和调性统一 */
.sticky-note-pin {
    position: absolute; top: -10px; left: 50%; transform: translateX(-50%) rotate(-2deg);
    width: 64px; height: 22px; border-radius: 2px;
    background: hsl(38 30% 85% / 0.8);
    border: 1px solid hsl(32 22% 65% / 0.5);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.18);
}

.sticky-note-thread { display: flex; flex-direction: column; gap: 10px; }
.sticky-note-entry {
    /* 中文手写体：--font-script 那串（Snell Roundhand/Bradley Hand/Segoe Script...）全是拉丁文
       花体字体，中文内容碰不到会直接退到系统默认字体。试过两版真手写体（志莽行书太连笔看不清、
       马善政体也还是偏毛笔калли字），这版换成"站酷快乐体"——圆润可爱的印刷体，不是连笔手写，
       但足够跳脱、比默认字体更有"随手写"的俏皮感，最容易读。 */
    font-family: 'ZCOOL KuaiLe', var(--font-script), var(--font-serif-italic), cursive;
    font-size: 16px; line-height: 1.8; color: #5a4a38; text-align: left;
    transition: max-height 250ms var(--ease-smooth), opacity 200ms ease;
}
.sticky-note-entry.author-user {
    color: hsl(var(--accent-h) 40% 34%); padding-left: 14px;
    border-left: 2px solid hsl(var(--accent-h) 35% 60% / 0.45);
}
.sticky-note-entry .sn-time {
    display: block; font-family: var(--font-sans); font-size: 10.5px; color: rgba(90, 74, 56, 0.55);
    margin-top: 2px;
}
.sticky-note-entry.collapsed { display: none; }

.sticky-note-expand {
    display: block; width: 100%; text-align: center; background: none; border: none;
    font-family: var(--font-sans); font-size: 11.5px; color: rgba(90, 74, 56, 0.65);
    padding: 0 0 8px; cursor: pointer;
}
.sticky-note-expand.hidden { display: none; }

.sticky-note-reply {
    display: flex; align-items: center; gap: 6px; margin-top: 12px;
    padding-top: 10px; border-top: 1px dashed hsl(35 25% 45% / 0.3);
}
.sticky-note-reply-input {
    flex: 1; min-width: 0; background: rgba(255, 255, 255, 0.5); border: none; border-radius: 8px;
    padding: 7px 10px; font-family: var(--font-sans); font-size: 13px; color: #5a4a38;
}
.sticky-note-reply-input::placeholder { color: rgba(90, 74, 56, 0.45); }
.sticky-note-reply-input:focus { outline: none; background: rgba(255, 255, 255, 0.75); }
.sticky-note-reply-send {
    flex-shrink: 0; width: 30px; height: 30px; border-radius: 50%; border: none;
    background: hsl(var(--accent-h) 40% 55%); color: #fff; font-size: 13px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.sticky-note-reply-send:disabled { opacity: 0.5; }
.sticky-note-reply-send.pending { animation: sticky-note-pulse 1s ease-in-out infinite; }
@keyframes sticky-note-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }


/* 主页正文：欢迎态收起（不可见也不可点），进入后展开——这个展开动作本身
   就是"把欢迎卡片顶上去"的视觉来源，不需要再单独给欢迎卡片加位移动画 */
.home-content {
    width: 100%; max-width: 360px; z-index: 1;
    max-height: 0; opacity: 0; overflow: hidden; pointer-events: none;
    transition: max-height 600ms var(--ease-smooth), opacity 500ms var(--ease-smooth);
}
.app-section[data-page="home"][data-stage="entered"] .home-content {
    max-height: 2000px; opacity: 1; pointer-events: auto;
}

.period-line {
    display: flex; align-items: center; gap: 8px; cursor: pointer;
    padding: 4px; margin-bottom: 8px; font-size: 12.5px; color: var(--text-dim);
}
.period-line-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
.period-line-text { flex: 1; }
.period-line .chevron { transition: transform 0.2s; }
.period-line.open .chevron { transform: rotate(180deg); }
.period-detail { margin-top: -2px; }

.nav-card {
    display: flex; flex-direction: column; align-items: flex-start; text-align: left;
    width: 100%;
    background: var(--glass-bg);
    backdrop-filter: blur(20px) saturate(1.3); -webkit-backdrop-filter: blur(20px) saturate(1.3);
    border: 1px solid var(--glass-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-soft);
    padding: 18px; cursor: pointer;
    transition: transform 0.22s var(--ease-bounce), box-shadow 0.25s ease;
}
.nav-card:active { transform: scale(0.95); transition-duration: 0.08s; transition-timing-function: var(--ease-snap); }
@media (hover: hover) {
    .nav-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-soft), 0 0 0 1px var(--glass-border); }
}
.nav-card-icon { font-size: 22px; margin-bottom: 10px; }
.nav-card-title { font-family: var(--font-serif-italic); font-style: italic; font-size: 17px; color: var(--text); margin-bottom: 4px; }
.nav-card-sub { font-size: 12px; color: var(--text-dim); }

.nav-card-big { margin-bottom: 10px; }
.nav-card-big .nav-card-icon { font-size: 26px; color: var(--accent); }

.nav-card-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 10px; }

.home-footer { text-align: center; font-size: 12px; color: var(--text-dim); padding: 14px 0 6px; }

/* ============================================================
   聊天页侧边抽屉
   ============================================================ */

.drawer-overlay {
    position: fixed; inset: 0; z-index: 200;
    display: flex; background: rgba(0, 0, 0, 0);
    transition: background 0.28s ease;
}
.drawer-overlay.hidden { display: none; }
.drawer-overlay.open { background: rgba(0, 0, 0, 0.4); }
.drawer-panel {
    width: 78%; max-width: 300px; height: 100%;
    background: var(--glass-bg);
    backdrop-filter: blur(20px) saturate(1.3); -webkit-backdrop-filter: blur(20px) saturate(1.3);
    border-right: 1px solid var(--glass-border);
    padding: calc(24px + var(--safe-top)) 18px calc(24px + var(--safe-bottom));
    display: flex; flex-direction: column;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}
.drawer-overlay.open .drawer-panel { transform: translateX(0); }
.drawer-title { font-family: var(--font-script); font-size: 22px; color: var(--text); margin-bottom: 10px; }
.drawer-item {
    display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
    background: none; border: none;
    padding: 13px 10px; border-radius: var(--radius-md); font-size: 14.5px; color: var(--text);
    cursor: pointer; font-family: inherit;
    position: relative; overflow: hidden;
    transition: background 0.15s ease, transform 0.22s var(--ease-bounce);
}
.drawer-item-icon { width: 19px; height: 19px; flex-shrink: 0; color: var(--text-dim); }
.drawer-item:active { background: var(--surface-2); transform: scale(0.97); transition-duration: 0.08s; transition-timing-function: var(--ease-snap); }
.drawer-divider { height: 1px; background: var(--border); margin: 3px 10px; }

/* 点击波纹 */
.drawer-item .ripple {
    position: absolute; border-radius: 50%; transform: scale(0);
    background: color-mix(in srgb, var(--accent) 35%, transparent);
    pointer-events: none; animation: drawer-ripple 500ms ease-out;
}
@keyframes drawer-ripple {
    to { transform: scale(2.6); opacity: 0; }
}

/* ============================================================
   板块切换：淡入淡出 + 轻微上移，300ms（app-shell.js 控制）
   ============================================================ */

.app-section { opacity: 1; transform: translateY(0); transition: opacity 0.3s var(--ease-smooth), transform 0.3s var(--ease-smooth); }
.app-section.fade-hidden { opacity: 0; transform: translateY(8px); }

@media (min-width: 640px) {
    .app-viewport { max-width: 480px; margin: 0 auto; }
    .login-page { max-width: 480px; margin: 0 auto; }
    .chat-input-bar, .chat-header {
        width: 100%; max-width: 480px; left: 50%; right: auto; transform: translateX(-50%);
    }
}

/* 强制行距生效：这个项目里气泡是 .bubble、消息行是 .msg-row（没有 .message-bubble/.message），
   按实际类名对应过来 */
* { line-height: 1.5 !important; }
.bubble { line-height: 1.6 !important; }
.msg-row { margin-bottom: 8px !important; }

/* ============================================================
   工作台：项目/会话选择器 + 活动日志 + iframe 预览。消息气泡/输入框直接复用聊天页的
   .chat-messages/.chat-input-bar/.bubble/.msg-row（见上面 .app-section[data-page="workbench"]
   那条选择器，让工作台也走跟聊天页一样的"内部固定高度自己滚"布局），这里只补工作台特有的部分。
   ============================================================ */
/* 状态栏：时间/天气/定位/电量，窄窄一条，放在项目选择器上方——只是环境信息，
   不该跟聊天内容抢视觉重量，字号比其它 UI 都小，纯文字没有卡片背景 */
.wb-statusbar {
    display: flex; align-items: center; gap: 6px; flex-shrink: 0;
    font-size: 11.5px; color: var(--text-dim);
    padding: 0 2px; overflow: hidden; white-space: nowrap;
}
.wb-statusbar-item { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wb-statusbar-sep { flex-shrink: 0; opacity: 0.5; }
.wb-statusbar-battery.hidden { display: none; }

/* 项目/会话切换 + 状态栏默认收起，手机上那几行下拉框常驻会占掉大半屏——展开状态记在
   localStorage 里，跟主线聊天窗口的持久化选择是同一套思路 */
.wb-header-current {
    flex: 1; min-width: 0; font-size: 12.5px; color: var(--text-dim);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.wb-header-toggle[aria-expanded="true"] .wb-activity-chevron { transform: rotate(180deg); }
.wb-header-collapsible.hidden { display: none; }
.wb-header-collapsible { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }

.wb-toolbar { display: flex; gap: 8px; flex-shrink: 0; }
.wb-select {
    flex: 1; height: 40px; padding: 0 12px; font-size: 14px;
    -webkit-appearance: none; appearance: none;
}
.wb-icon-only { width: 40px; height: 40px; padding: 0; flex-shrink: 0; font-size: 18px; line-height: 1; }

/* 「自己」项目的重启提醒：默认收起成一条窄提示，点开才展开详情——
   常驻的一整段文字太占移动端竖屏空间，挤压聊天记录区可用高度 */
.wb-self-banner {
    flex-shrink: 0; width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px;
    font-size: 12px; color: var(--text-dim); line-height: 1.4; text-align: left;
    background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 6px 10px;
}
.wb-self-banner-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wb-self-banner-chevron { flex-shrink: 0; font-size: 11px; transition: transform 0.18s ease; }
.wb-self-banner[aria-expanded="true"] .wb-self-banner-chevron { transform: rotate(180deg); }
.wb-self-banner.hidden { display: none; }
.wb-self-banner-detail {
    flex-shrink: 0; font-size: 12.5px; color: var(--text-dim); line-height: 1.5;
    background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 8px 10px; margin-top: -4px;
}
.wb-self-banner-detail code { font-size: 11.5px; background: var(--bg); padding: 1px 5px; border-radius: 5px; }
.wb-self-banner-detail.hidden { display: none; }

.wb-tabs { display: flex; gap: 6px; flex-shrink: 0; }
.wb-tabs.hidden { display: none; }
.wb-tab {
    padding: 7px 14px; border-radius: 999px; border: 1px solid var(--border);
    background: var(--surface-2); color: var(--text-dim); font-size: 13px;
}
.wb-tab.active { background: var(--accent); color: #fff; border-color: transparent; }
.wb-tab.hidden { display: none; }

.wb-empty {
    flex: 1; display: flex; align-items: center; justify-content: center; text-align: center;
    color: var(--text-dim); font-size: 14px; padding: 40px 20px;
}
.wb-empty.hidden { display: none; }

.wb-panel { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.wb-panel.hidden { display: none; }

/* 活动日志（工具调用记录）：默认折叠成一行摘要，点一下才展开细节——一长串 Read/Grep/Bash
   逐条堆叠会把聊天流挤得很晕，折叠态只给"在忙什么/忙完了"的一句话状态。
   展开动画用 grid-template-rows 0fr -> 1fr 的经典技巧（比 max-height 更准，不用猜内容高度）。 */
.wb-activity {
    align-self: flex-start; flex-shrink: 0; max-width: 88%; width: fit-content; min-width: 190px;
    display: flex; flex-direction: column;
    margin: 2px 0 4px;
    background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px;
    overflow: hidden;
}
/* 一轮跑完之后的耗时/token 小字——贴在这轮最后一条气泡下面，让阿荞心里有个准数，
   不用光靠感觉猜"是不是变慢了/是不是卡住了"。*/
.wb-turn-meta {
    align-self: flex-start; font-size: 11px; color: var(--text-dim);
    padding: 0 4px 6px; margin-top: -2px;
}
/* 头像旁实时跳秒——这一轮真的在跑的时候才有，跑完这个 span 所在的整行头像就被摘掉了，
   最终耗时/token 数走的是上面 .wb-turn-meta，两个不会同时显示重复信息 */
.wb-live-timer {
    font-size: 11px; color: var(--text-dim); font-variant-numeric: tabular-nums;
}
.wb-activity-summary {
    display: flex; align-items: center; gap: 8px; width: 100%;
    background: none; border: none; text-align: left; cursor: pointer;
    padding: 7px 12px; font-size: 12px; color: var(--text-dim); font-family: inherit;
}
.wb-activity-summary-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wb-activity-chevron { flex-shrink: 0; font-size: 10px; transition: transform 0.25s var(--ease-smooth); }
.wb-activity:not(.collapsed) .wb-activity-chevron { transform: rotate(180deg); }
.wb-activity-lines-wrap {
    display: grid; grid-template-rows: 0fr;
    transition: grid-template-rows 0.28s var(--ease-smooth);
}
.wb-activity:not(.collapsed) .wb-activity-lines-wrap { grid-template-rows: 1fr; }
.wb-activity-lines {
    overflow: hidden; min-height: 0;
    display: flex; flex-direction: column; gap: 4px;
    padding: 0 12px 8px;
}
.wb-activity-line {
    font-size: 12px; color: var(--text-dim); padding: 5px 10px; border-radius: 10px;
    background: var(--surface); border: 1px solid var(--border);
    white-space: pre-wrap; word-break: break-word;
}
.wb-activity-error { color: #e0607a; border-color: rgba(224, 96, 122, 0.4); }
.wb-activity-status { text-align: center; }

.wb-preview-bar { flex-shrink: 0; padding: 4px 0 10px; }
.wb-preview-frame {
    flex: 1; min-height: 0; width: 100%; border: 1px solid var(--border);
    border-radius: var(--radius-md); background: #fff;
}

.wb-worklog { flex: 1; min-height: 0; overflow-y: auto; padding: 2px 2px 20px; }
.wb-worklog-date {
    font-weight: 600; font-size: 14px; color: var(--text);
    margin: 16px 0 6px; padding-bottom: 4px; border-bottom: 1px solid var(--border);
}
.wb-worklog-date:first-child { margin-top: 2px; }
.wb-worklog-item {
    font-size: 13.5px; color: var(--text); line-height: 1.6;
    padding: 3px 0 3px 2px; white-space: pre-wrap; word-break: break-word;
}
.wb-worklog-done { color: var(--text-dim); text-decoration: line-through; }
.wb-worklog-text {
    font-size: 13px; color: var(--text-dim); line-height: 1.6;
    padding: 3px 0; white-space: pre-wrap; word-break: break-word;
}
.wb-worklog-empty { font-size: 13px; color: var(--text-dim); text-align: center; padding: 40px 20px; }

.wb-modal {
    position: fixed; inset: 0; z-index: 200;
    display: flex; align-items: center; justify-content: center;
    background: rgba(0, 0, 0, 0.4); padding: 20px;
}
.wb-modal.hidden { display: none; }
.wb-modal-card { width: 100%; max-width: 400px; }
.wb-modal-status { font-size: 12.5px; color: #e0607a; min-height: 16px; margin-bottom: 6px; }

.wb-image-preview {
    position: fixed; left: 12px; right: 12px;
    bottom: calc(64px + var(--safe-bottom) + var(--keyboard-inset, 0px));
    z-index: 4; display: flex; align-items: center; gap: 8px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 6px 8px; box-shadow: var(--shadow-soft);
}
.wb-image-preview.hidden { display: none; }
.wb-image-preview img { width: 40px; height: 40px; object-fit: cover; border-radius: 8px; }
.wb-image-preview-remove {
    margin-left: auto; width: 26px; height: 26px; border-radius: 50%; border: none;
    background: var(--surface-2); color: var(--text-dim); font-size: 13px;
}
.wb-bubble-image { max-width: 220px; border-radius: 14px; display: block; margin-bottom: 6px; }

#wb-image-btn.has-image {
    color: var(--accent); border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 14%, var(--surface-2));
    position: relative;
}
#wb-image-btn.has-image::after {
    content: ''; position: absolute; top: 2px; right: 2px;
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--accent); border: 1.5px solid var(--surface);
}

@media (min-width: 640px) {
    .wb-image-preview { width: 100%; max-width: 480px; left: 50%; right: auto; transform: translateX(-50%); }
}
