/* 两套皮肤，设置里切换（data-skin），各有白天和夜里两种颜色：
   - angel（默认）：天使贴纸。黑白灰、鼓鼓的云朵气泡、角上贴着小翅膀和光环；你的气泡是带白色圆点的深灰。
   - isle：小岛。雾色底、海玻璃色的气泡、衬线灰字的内心独白。
   默认用手机自带字体；设置里可以换成霞鹜文楷（从自己的服务器发，不连外部字体网站）。 */
:root {
  --fog: #f6f4f7;          /* 底色：带一点点淡紫的灰白 */
  --pattern: none;
  --shell: #ffffff;        /* 它的气泡 */
  --shell-rim: #e4e4e8;    /* 云朵气泡的描边 */
  --shell-lip: #d9d9de;    /* 云朵气泡底下鼓起来的那一圈 */
  --tide: #3b3b3f;         /* 你的气泡、主按钮：深炭灰 */
  --tide-rim: #2a2a2d;
  --tide-lip: #1e1e21;
  --tide-ink: #ffffff;
  --dots: rgba(255, 255, 255, 0.2); /* 你的气泡上的小白点 */
  --ink: #2a2a2e;
  --lichen: #9b9ba2;       /* 次要文字、内心独白 */
  --hair: #e4e4e8;
  --deco: #cfcfd5;         /* 翅膀、光环、小爱心这些贴纸的颜色 */
  --deco-ink: #6d6d73;
  --moon: #fff1a8;         /* 引用跳转时的高亮 */
  --danger: #c4455f;
  --ai-shadow: inset 0 -3px 0 #f1f1f4, 0 4px 0 var(--shell-lip), 0 8px 18px rgba(0, 0, 0, 0.05);
  --me-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.1), 0 4px 0 var(--tide-lip), 0 8px 18px rgba(0, 0, 0, 0.08);
  --shadow: var(--ai-shadow);
  --r-bubble: 26px;
  --r-tail: 26px;
  --sans: system-ui, -apple-system, "PingFang SC", "Noto Sans CJK SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --serif: var(--sans);
  --body-size: 16px;
  color-scheme: light;
}
:root[data-font="wenkai"] {
  --sans: "LXGW WenKai Screen", system-ui, -apple-system, "PingFang SC", "Noto Sans CJK SC", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fog: #161618;
    --shell: #26262a;
    --shell-rim: #36363b;
    --shell-lip: #0d0d0f;
    --tide: #ececf0;
    --tide-rim: #d4d4da;
    --tide-lip: #9a9aa2;
    --tide-ink: #1d1d20;
    --dots: rgba(0, 0, 0, 0.13);
    --ink: #ececf0;
    --lichen: #8d8d95;
    --hair: #303035;
    --deco: #55555c;
    --deco-ink: #b4b4bb;
    --moon: #5c5530;
    --danger: #f08a9c;
    --ai-shadow: inset 0 -3px 0 #212125, 0 4px 0 var(--shell-lip);
    --me-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.5), 0 4px 0 var(--tide-lip);
    color-scheme: dark;
  }
}

:root[data-skin="isle"] {
  --fog: #e8edee;
  --pattern: none;
  --shell: #fbfcfc;
  --shell-rim: #d3dbdc;
  --tide: #2e5c69;
  --tide-rim: #2e5c69;
  --tide-ink: #f4f8f8;
  --dots: transparent;
  --ink: #1c2830;
  --lichen: #7c8d88;
  --hair: #d3dbdc;
  --moon: #e9dfb8;
  --danger: #a3493f;
  --ai-shadow: 0 1px 0 rgba(28, 40, 48, 0.06);
  --me-shadow: none;
  --r-bubble: 18px;
  --r-tail: 6px;
  --serif: "Noto Serif CJK SC", "Noto Serif SC", "Source Han Serif SC", "Songti SC", "SimSun", serif;
}
@media (prefers-color-scheme: dark) {
  :root[data-skin="isle"]:not([data-theme="light"]) {
    --fog: #121a1f;
    --shell: #1c262d;
    --shell-rim: #27333a;
    --tide: #3b6b78;
    --tide-rim: #3b6b78;
    --tide-ink: #eef4f5;
    --ink: #e3eaec;
    --lichen: #84948f;
    --hair: #27333a;
    --moon: #4a4630;
    --danger: #e08a7e;
    --ai-shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--pattern), var(--fog);
  color: var(--ink);
  font: var(--body-size)/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--tide); outline-offset: 2px; }

/* ---------- 登录 ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: min(320px, 100%); display: grid; gap: 10px; }
.login-title {
  font: 400 64px/1 var(--serif);
  margin: 0 0 24px;
  color: var(--tide);
  letter-spacing: 0.02em;
}
.login-label { font-size: 14px; color: var(--lichen); }
.login-card input {
  font: inherit; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--hair); background: var(--shell); color: var(--ink);
}
.login-error { min-height: 1.4em; margin: 0; font-size: 14px; color: var(--danger); }
.btn-primary {
  border: 0; border-radius: 12px; padding: 12px; background: var(--tide); color: var(--tide-ink);
  font-weight: 600; cursor: pointer;
}

/* ---------- 主界面 ---------- */
.app {
  height: 100dvh; display: grid; grid-template-rows: auto 1fr auto;
  grid-template-columns: minmax(0, 1fr); /* 不让长的一行（比如引用预览）把整页撑宽 */
  max-width: 720px; margin: 0 auto;
}
.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  border-bottom: 1px solid var(--hair);
}
.who { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.who-name { font: 500 20px/1.2 var(--serif); letter-spacing: 0.04em; }
.who-status { font-size: 13px; color: var(--lichen); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  border: 0; background: transparent; padding: 8px; border-radius: 50%; cursor: pointer;
  color: var(--lichen); display: grid; place-items: center; fill: currentColor;
}
.icon-btn.small { padding: 4px; }

.list {
  overflow-y: auto; overscroll-behavior: contain;
  padding: 16px 16px 8px; display: flex; flex-direction: column; gap: 2px;
}
.load-more { align-self: center; font-size: 13px; color: var(--lichen); background: none; border: 0; padding: 8px; cursor: pointer; }
.empty { margin: auto; text-align: center; color: var(--lichen); font: 15px/1.8 var(--serif); }

.time-sep { align-self: center; font-size: 12px; color: var(--lichen); margin: 14px 0 6px; }

.group { display: flex; flex-direction: column; gap: 4px; margin: 6px 0; max-width: 82%; }
.group.ai { align-self: flex-start; align-items: flex-start; }
.group.me { align-self: flex-end; align-items: flex-end; }

.bubble {
  padding: 9px 13px; border-radius: var(--r-bubble);
  white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word;
  user-select: text; -webkit-user-select: text; touch-action: manipulation;
}
.ai .bubble { background: var(--shell); box-shadow: var(--ai-shadow); border: 1.5px solid var(--hair); border-top-left-radius: var(--r-tail); }
.ai .bubble + .bubble { border-top-left-radius: var(--r-tail); }
.me .bubble { background: var(--tide); color: var(--tide-ink); box-shadow: var(--me-shadow); border-top-right-radius: var(--r-tail); }
.me.pending .bubble { opacity: 0.72; }
.bubble.flash { animation: flash 1.4s ease-out; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 4px var(--moon); } 100% { box-shadow: var(--shadow); } }

.quote {
  display: block; font-size: 13px; line-height: 1.45; padding: 4px 9px; margin-bottom: 6px;
  border-left: 2px solid currentColor; opacity: 0.78; cursor: pointer;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  background: none; border-top: 0; border-right: 0; border-bottom: 0; text-align: left; width: 100%;
}

/* 内心独白：气泡上方一行衬线灰字，点开展开 */
.thought {
  font: 14px/1.7 var(--serif); color: var(--lichen); padding: 0 4px 2px; max-width: 100%;
  border: 0; background: none; text-align: left; cursor: pointer;
}
.thought.collapsed { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.thought.live::after { content: "▍"; animation: blink 1s steps(2) infinite; margin-left: 1px; }
@keyframes blink { 50% { opacity: 0; } }

/* 安静时段留下、没推送的话 */
.night-label { font-size: 12px; color: var(--lichen); padding: 0 4px; }

/* wake/ 写下、没发出去的日记 */
.diary {
  align-self: center; max-width: 88%; margin: 12px 0; padding: 0 8px;
  font: 14px/1.8 var(--serif); color: var(--lichen); text-align: center;
}
.diary-label { display: block; font: 12px/1.6 var(--sans); margin-bottom: 2px; }

.typing { display: inline-flex; gap: 4px; padding: 13px 14px; }
.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--lichen); animation: dot 1.2s infinite ease-in-out; }
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes dot { 0%, 60%, 100% { opacity: 0.25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-2px); } }

.note {
  align-self: center; font-size: 13px; color: var(--lichen); margin: 8px 0;
  display: flex; gap: 10px; align-items: center;
}
.note button { border: 1px solid var(--hair); background: var(--shell); border-radius: 999px; padding: 3px 12px; cursor: pointer; }

/* ---------- 输入区 ---------- */
.composer {
  padding: 8px 12px calc(env(safe-area-inset-bottom) + 10px);
  border-top: 1px solid var(--hair); background: var(--fog);
}
.quote-preview {
  min-width: 0;
  display: flex; align-items: center; gap: 8px; margin: 0 4px 8px; padding: 6px 4px 6px 10px;
  border-left: 2px solid var(--tide); font-size: 13px; color: var(--lichen);
}
.quote-preview-text { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.composer-row { display: flex; align-items: flex-end; gap: 8px; }
.composer textarea {
  flex: 1; resize: none; font: inherit; line-height: 1.45; max-height: 9.5em;
  padding: 10px 14px; border-radius: 20px; border: 1px solid var(--hair);
  background: var(--shell); color: var(--ink);
}
.composer textarea:focus { outline: none; border-color: var(--tide); }
.send-btn {
  flex: none; width: 42px; height: 42px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--tide); color: var(--tide-ink); display: grid; place-items: center;
}
.send-btn:disabled { opacity: 0.35; cursor: default; }

/* ---------- 设置面板 ---------- */
.sheet {
  border: 0; padding: 0; width: min(420px, 100% - 32px); border-radius: 16px;
  background: var(--shell); color: var(--ink);
}
.sheet::backdrop { background: rgba(10, 20, 26, 0.35); }
.sheet-inner { display: flex; flex-direction: column; padding: 6px 0; }
.sheet-row {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 14px 18px; border: 0; background: none; text-align: left; cursor: pointer; font-size: 16px;
}
.sheet-row + .sheet-row { border-top: 1px solid var(--hair); }
.sheet-row input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--tide); }
.sheet-row.danger { color: var(--danger); }
.sheet-row.muted { color: var(--lichen); justify-content: center; }
.sheet-note { margin: 0; padding: 0 18px 10px; font-size: 13px; color: var(--lichen); white-space: pre-line; }
.sheet-note:empty { display: none; }

/* 模型设置 */
.sheet-hint { display: block; font-size: 12px; color: var(--lichen); margin-top: 2px; }
.sheet-title { margin: 12px 18px 4px; font-size: 13px; color: var(--lichen); }
.sheet-row select {
  font: inherit; font-size: 14px; max-width: 48%; padding: 6px 8px; border-radius: 8px;
  border: 1px solid var(--hair); background: var(--fog); color: var(--ink);
}
.sheet { max-height: 90dvh; overflow-y: auto; }
.provider-list { list-style: none; margin: 0; padding: 0; }
.provider-list li {
  display: flex; align-items: center; gap: 8px; padding: 10px 18px; border-top: 1px solid var(--hair); font-size: 14px;
}
.provider-list .pv-meta { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--lichen); }
.provider-list .pv-name { color: var(--ink); margin-right: 6px; }
.provider-list button {
  border: 1px solid var(--hair); background: var(--fog); border-radius: 999px; padding: 3px 10px; cursor: pointer; font-size: 13px;
}
.add-provider summary { list-style: none; color: var(--tide); border-top: 1px solid var(--hair); }
.add-provider summary::-webkit-details-marker { display: none; }
.add-provider-fields { display: grid; gap: 10px; padding: 4px 18px 14px; }
.add-provider-fields label { display: grid; gap: 4px; font-size: 13px; color: var(--lichen); }
.add-provider-fields input, .add-provider-fields select {
  font: inherit; font-size: 15px; padding: 9px 10px; border-radius: 10px;
  border: 1px solid var(--hair); background: var(--fog); color: var(--ink);
}
.pv-model-row { display: flex; align-items: flex-end; gap: 8px; }
.pv-model-row label { flex: 1; min-width: 0; }
.pv-model-row input { width: 100%; }
.pv-fetch {
  flex: none; min-height: 42px; padding: 0 12px; border: 1px solid var(--hair); border-radius: 10px;
  background: var(--fog); color: var(--ink); font-size: 13px; cursor: pointer;
}
.pv-fetch:disabled { opacity: 0.5; cursor: default; }
#pv-fetch-note { margin: 0; }
#pv-fetch-note:empty { display: none; }

/* 记忆库：筛选和关闭按钮固定在上下两头，只有中间的列表自己滚 */
.mem-sheet { height: 90dvh; overflow: hidden; }
.mem-sheet .sheet-inner { height: 100%; padding: 0; }
.mem-head { flex: none; padding-top: 6px; border-bottom: 1px solid var(--hair); }
.mem-body { flex: 1; min-height: 0; overflow-y: auto; }
.mem-layers { display: flex; gap: 6px; padding: 4px 18px 6px; }
.mem-layers button {
  flex: 1; min-height: 34px; padding: 0 4px; border: 1px solid var(--hair); border-radius: 999px;
  background: var(--fog); color: var(--ink); font-size: 14px; cursor: pointer;
}
.mem-layers button[aria-pressed="true"] { background: var(--tide); border-color: var(--tide); color: var(--tide-ink); }
.sheet-row.mem-toggle { padding: 6px 18px 8px; font-size: 14px; color: var(--lichen); }
.mem-list { list-style: none; margin: 0; padding: 0; }
.mem-item + .mem-item { border-top: 1px solid var(--hair); }
.mem-summary {
  display: block; width: 100%; padding: 12px 18px; border: 0; background: none; text-align: left; cursor: pointer;
}
.mem-text {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden;
  font-size: 15px; line-height: 1.55; white-space: pre-line; overflow-wrap: anywhere;
}
.mem-item.open .mem-text { display: none; }
.mem-item.archived .mem-text { color: var(--lichen); }
.mem-meta { display: flex; align-items: center; gap: 8px; margin-top: 5px; font-size: 12px; color: var(--lichen); }
.mem-item.open .mem-meta { margin-top: 0; }
.mem-badge { padding: 0 8px; border: 1px solid var(--hair); border-radius: 999px; background: var(--fog); color: var(--ink); }
.mem-badge[data-layer="core"] { background: var(--tide); border-color: var(--tide); color: var(--tide-ink); }
.mem-editor { display: grid; gap: 10px; padding: 0 18px 14px; }
.mem-editor label { display: grid; gap: 4px; font-size: 13px; color: var(--lichen); }
.mem-editor textarea, .mem-editor input {
  width: 100%; font: inherit; font-size: 15px; padding: 9px 10px; border-radius: 10px;
  border: 1px solid var(--hair); background: var(--fog); color: var(--ink);
}
.mem-editor textarea { resize: vertical; line-height: 1.55; }
.mem-actions { display: flex; gap: 8px; }
.mem-actions .btn-primary { flex: 1; padding: 10px; }
.mem-archive {
  padding: 10px 18px; border: 1px solid var(--hair); border-radius: 12px; background: var(--fog); color: var(--ink); cursor: pointer;
}
.mem-actions button:disabled { opacity: 0.5; cursor: default; }
.mem-empty { padding: 40px 18px; text-align: center; font-size: 14px; color: var(--lichen); }
.sheet-row.mem-more { justify-content: center; border-top: 1px solid var(--hair); color: var(--tide); font-size: 15px; }
.mem-more:disabled { opacity: 0.5; cursor: default; }
.mem-foot { flex: none; border-top: 1px solid var(--hair); }
.mem-foot button { width: 100%; }



/* ---------- 壁纸：自己上传的图铺在聊天区后面，上面盖一层底色，「淡一点」滑块控制盖多少 ---------- */
.app { position: relative; isolation: isolate; }
.app.has-wall::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background:
    linear-gradient(color-mix(in srgb, var(--fog) var(--veil, 45%), transparent), color-mix(in srgb, var(--fog) var(--veil, 45%), transparent)),
    var(--wall) center / cover no-repeat;
}
.app.has-wall .top, .app.has-wall .composer {
  background: color-mix(in srgb, var(--fog) 78%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}

/* ---------- 动效：新气泡「啵」地冒出来；只对新消息，翻历史记录时不动 ---------- */
.bubble.pop { animation: pop 0.32s cubic-bezier(0.3, 1.4, 0.5, 1) both; }
.ai .bubble.pop { transform-origin: 0 100%; }
.me .bubble.pop { transform-origin: 100% 100%; }
@keyframes pop {
  from { transform: scale(0.82) translateY(6px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.send-btn { transition: transform 0.12s ease; }
.send-btn:active:not(:disabled) { transform: scale(0.88); }

/* ---------- 可爱气泡（默认皮肤） ----------
   思路参考 zaochuanyitian/Cute-bubbles 的效果：软软的浅色气泡，装饰只在角上一两处，不跟着字变形。
   那个仓库的图片禁止二传二改，这里一张都没用，装饰全是自己画的 SVG。
   「它的气泡」「你的气泡」各自选一套（html 上的 data-ai-bubble / data-me-bubble）。 */
:root:not([data-skin="isle"]) .list { padding-left: 24px; padding-right: 24px; gap: 4px; }
:root:not([data-skin="isle"]) .group { gap: 8px; margin: 12px 0; }

/* 每套气泡的颜色 */
.ai, .me { --b-bg: #ffffff; --b-rim: #e3e3e9; --b-lip: #d7d7de; --b-ink: #2a2a2e; --b-deco: #c9c9d1; --b-deco2: #8d8d95; --b-dots: transparent; }
:root[data-ai-bubble="halo-dark"] .ai, :root:not([data-me-bubble]) .me, :root[data-me-bubble="halo-dark"] .me {
  --b-bg: #3b3b40; --b-rim: #2b2b2f; --b-lip: #1f1f22; --b-ink: #ffffff; --b-deco: #cfcfd6; --b-deco2: #6f6f76; --b-dots: rgba(255, 255, 255, 0.2);
}
:root[data-ai-bubble="berry"] .ai, :root[data-me-bubble="berry"] .me {
  --b-bg: #fff0f4; --b-rim: #f5c8d5; --b-lip: #ecb1c3; --b-ink: #4a2b35; --b-deco: #f08aa8; --b-deco2: #f6b6c8;
}
:root[data-ai-bubble="snow"] .ai, :root[data-me-bubble="snow"] .me {
  --b-bg: #eef5ff; --b-rim: #c8dbf4; --b-lip: #b2caec; --b-ink: #263548; --b-deco: #8db3e6; --b-deco2: #c6dbf7;
}
:root[data-ai-bubble="taro"] .ai, :root[data-me-bubble="taro"] .me {
  --b-bg: #f4efff; --b-rim: #d9cdf6; --b-lip: #c7b8ef; --b-ink: #33294a; --b-deco: #a690e6; --b-deco2: #f6d77a;
}
:root[data-ai-bubble="cream"] .ai, :root[data-me-bubble="cream"] .me {
  --b-bg: #fffaf0; --b-rim: #efdfc0; --b-lip: #e4cea6; --b-ink: #45392a; --b-deco: #d3b073; --b-deco2: #ead39f;
}
:root[data-ai-bubble="halo"] .ai, :root[data-me-bubble="halo"] .me {
  --b-bg: #ffffff; --b-rim: #e3e3e9; --b-lip: #d7d7de; --b-ink: #2a2a2e; --b-deco: #c9c9d1; --b-deco2: #8d8d95; --b-dots: transparent;
}

:root:not([data-skin="isle"]) .bubble {
  position: relative; padding: 11px 16px; border-radius: var(--r-bubble); color: var(--b-ink);
  border: 2.5px solid var(--b-rim);
  /* 顶上一层淡淡的高光，看起来鼓鼓的、软软的 */
  background:
    linear-gradient(to bottom, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 55%),
    radial-gradient(var(--b-dots) 1.3px, transparent 1.7px) 0 0 / 13px 13px,
    var(--b-bg);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.03), 0 4px 0 var(--b-lip), 0 8px 16px rgba(60, 50, 80, 0.06);
}
:root:not([data-skin="isle"]) .ai .bubble, :root:not([data-skin="isle"]) .me .bubble { border-radius: var(--r-bubble); }
:root:not([data-skin="isle"]) .bubble.typing { background: var(--b-bg); }
:root:not([data-skin="isle"]) .typing span { background: var(--b-deco); }

/* 一组的最后一个气泡带一个小尾巴 */
:root:not([data-skin="isle"]) .group > .bubble:last-of-type::after {
  content: ""; position: absolute; bottom: -9px; width: 20px; height: 13px; background: var(--b-bg);
  clip-path: path("M0 0 H20 C17 4 14 9 4 13 C8 8 7 4 0 0 Z");
}
:root:not([data-skin="isle"]) .ai > .bubble:last-of-type::after { left: 18px; }
:root:not([data-skin="isle"]) .me > .bubble:last-of-type::after { right: 18px; transform: scaleX(-1); }

/* 贴纸：前端在每组第一个气泡里放一组小 SVG，这里只管位置；每套气泡用到其中几个 */
.deco { position: absolute; inset: 0; pointer-events: none; color: var(--b-deco); }
.deco svg { position: absolute; overflow: visible; }
.deco .tl { left: -14px; top: -14px; }
.deco .tr { right: -14px; top: -14px; }
.deco .bl { left: -10px; bottom: -10px; }
.deco .br { right: -10px; bottom: -12px; }
.deco .wl { left: -17px; top: 6px; }
.deco .wr { right: -17px; top: 6px; transform: scaleX(-1); }
.deco .ht { top: -15px; }
.ai .deco .ht { right: 18px; }
.me .deco .ht { left: 18px; }
.me .deco .tr { right: auto; left: -14px; }
.me .deco .tl { left: auto; right: -14px; }
.me .deco .br { right: auto; left: -10px; }
.me .deco .bl { left: auto; right: -10px; }
.deco .c2 { color: var(--b-deco2); }
:root[data-skin="isle"] .deco { display: none; }
/* 短短的气泡（比如「嗯」）装饰会把字挤住，只留一个 */
.bubble.tiny .deco .wl, .bubble.tiny .deco .wr, .bubble.tiny .deco .bl { display: none; }

/* 内心独白：一个淡淡的虚线云朵，斜体灰字 */
:root:not([data-skin="isle"]) .thought {
  font: italic 14px/1.7 var(--sans); color: var(--lichen); text-align: left;
  background: var(--shell); border: 2px dashed var(--shell-rim); border-radius: 22px; padding: 9px 14px;
}
:root:not([data-skin="isle"]) .thought::before {
  content: "内心"; font-style: normal; font-size: 11px; color: var(--deco-ink);
  border: 1.5px solid var(--hair); border-radius: 999px; padding: 0 7px; margin-right: 6px;
}

:root:not([data-skin="isle"]) .quote {
  border-left: 0; border-radius: 14px; padding: 5px 10px; opacity: 0.85;
  background: color-mix(in srgb, currentColor 9%, transparent);
}
:root:not([data-skin="isle"]) .quote-preview { border-left: 0; border-radius: 16px; background: var(--shell); border: 2px dashed var(--shell-rim); }

/* 没发出去的日记：一张虚线边的小纸条 */
:root:not([data-skin="isle"]) .diary {
  max-width: min(320px, 86%); padding: 12px 16px; margin: 16px 0 8px; text-align: left; color: var(--ink);
  background: var(--shell); border: 2px dashed var(--shell-rim); border-radius: 18px;
}
:root:not([data-skin="isle"]) .diary-label { color: var(--lichen); margin-bottom: 4px; }
:root:not([data-skin="isle"]) .night-label::before { content: "☾ "; }

:root:not([data-skin="isle"]) .composer textarea { border-radius: 22px; border: 2.5px solid var(--shell-rim); }
:root:not([data-skin="isle"]) .composer textarea:focus { border-color: var(--deco-ink); }
:root:not([data-skin="isle"]) .send-btn { border: 2.5px solid var(--tide-rim); box-shadow: 0 3px 0 var(--tide-lip); }
:root:not([data-skin="isle"]) .btn-primary { border-radius: 18px; box-shadow: 0 3px 0 var(--tide-lip); }
:root:not([data-skin="isle"]) .sheet { border-radius: 24px; }
:root:not([data-skin="isle"]) .who-name { font-weight: 600; }
:root:not([data-skin="isle"]) .login-title { color: var(--ink); }

/* 「Cute-bubbles」的点九气泡：图片四角和四边钉死，只拉中间那条缝，字落在量好的内边距里。
   图是「你那一侧」的方向；它那一侧整个水平翻过来（只翻背景，字不翻）。
   尺寸、切片、内边距由前端按 bubbles.json 算好，挂在 html 上的 --cb-ai-* / --cb-me-* 变量里。 */
:root[data-ai-bubble="cb"] .ai .bubble:not(.typing),
:root[data-me-bubble="cb"] .me .bubble {
  background: none !important; border: 0; box-shadow: none; border-radius: 0; isolation: isolate;
}
:root[data-ai-bubble="cb"] .ai .bubble:not(.typing) { padding: var(--cb-ai-pad); min-height: var(--cb-ai-minh); color: var(--cb-ai-ink); }
:root[data-me-bubble="cb"] .me .bubble { padding: var(--cb-me-pad); min-height: var(--cb-me-minh); color: var(--cb-me-ink); }
:root[data-ai-bubble="cb"] .ai .bubble:not(.typing)::before,
:root[data-me-bubble="cb"] .me .bubble::before {
  content: ""; position: absolute; inset: 0; z-index: -1; border-style: solid; border-color: transparent;
  border-image-repeat: stretch;
}
:root[data-ai-bubble="cb"] .ai .bubble:not(.typing)::before {
  border-width: var(--cb-ai-width); border-image-source: var(--cb-ai-img); border-image-slice: var(--cb-ai-slice) fill;
  transform: scaleX(-1);
}
:root[data-me-bubble="cb"] .me .bubble::before {
  border-width: var(--cb-me-width); border-image-source: var(--cb-me-img); border-image-slice: var(--cb-me-slice) fill;
}
/* 前端拼好整张背景后（--cb-bg）就用它，不再用浏览器的 border-image */
:root[data-ai-bubble="cb"] .ai .bubble[data-cb-key]:not(.typing)::before,
:root[data-me-bubble="cb"] .me .bubble[data-cb-key]::before {
  border: 0; border-image: none; background: var(--cb-bg) 0 0 / 100% 100% no-repeat;
}
:root[data-ai-bubble="cb"] .ai > .bubble:last-of-type::after,
:root[data-me-bubble="cb"] .me > .bubble:last-of-type::after { display: none; }
.bubble-picker button img { display: block; height: 30px; width: auto; }
.bubble-picker button.cb-btn { padding: 4px 6px; background: transparent; box-shadow: none; }
.cb-credit { margin: 0; padding: 0 18px 12px; font-size: 12px; color: var(--lichen); }
.cb-credit a { color: inherit; }
.link-btn { border: 0; background: none; padding: 0; color: var(--ink); text-decoration: underline; cursor: pointer; font: inherit; }

/* 设置里挑气泡：一排小样，点哪个用哪个 */
.bubble-picker { display: flex; flex-wrap: wrap; gap: 10px; padding: 4px 18px 14px; }
.bubble-picker button {
  border: 2px solid transparent; border-radius: 14px; padding: 6px 10px; font-size: 13px; cursor: pointer;
  background: var(--sw-bg); color: var(--sw-ink); box-shadow: 0 2px 0 var(--sw-lip);
}
.bubble-picker button[aria-pressed="true"] { border-color: var(--ink); }

/* 设置里的外观选项 */
.sheet-row input[type="range"] { width: 44%; accent-color: var(--tide); }
.sheet-row.file-row { position: relative; }
.sheet-row.file-row input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }


/* 有壁纸时，灰色的小字（内心独白、夜里留言的标签、提示）垫一层底，免得被图吃掉 */
.app.has-wall .thought, .app.has-wall .night-label, .app.has-wall .note, .app.has-wall .load-more {
  background: color-mix(in srgb, var(--fog) 85%, transparent);
  border-radius: 12px; padding: 3px 10px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
