/* 9.27 她定的聊天页排版：头像进顶栏（点开侧栏）、模型牌写实跑的、右上一只小船收着历史/洗脸/背景、
   气泡不带头像、时间今天简写、打字框一行、狐狸趴在打字框上、底栏浮起来。
   单独一个文件：出毛病把 index.html 里这行 link 去掉就回到原样。 */

/* ── 顶栏 ── */
#topbar { border-bottom: none; padding-left: 14px; padding-right: 8px; gap: 10px; }
#topbar .tb-avatar {
  width: 40px; height: 40px; flex: none; padding: 0;
  border-radius: 50%; overflow: hidden;
  box-shadow: 0 0 0 2px rgba(255,255,255,.85), 0 2px 8px rgba(0,0,0,.12);
}
#topbar .tb-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
#topbar .tb-avatar:active { transform: scale(.96); }
#topbar .tb-id { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; line-height: 1.25; }
#topbar .tb-name { display: flex; align-items: center; gap: 8px; min-width: 0; }
#topbar .topbar-title { text-align: left; max-width: 46vw; font-size: 17px; }
#topbar .tb-model {
  position: relative; flex: none;
  font-size: 11px; line-height: 1; padding: 4px 8px; border-radius: 10px;
  background: rgba(90,120,150,.10); color: var(--text2); white-space: nowrap;
}
#topbar .tb-model:empty { display: none; }
#topbar .tb-model::after { content: ''; position: absolute; inset: -12px -10px; }   /* 能按的地方比看着的大一圈 */
#topbar .topbar-sub { display: block; font-size: 11px; color: var(--text2); margin-top: 2px; white-space: nowrap; }
#topbar #ctx-pct { opacity: .7; }
#topbar #ctx-pct:not(:empty)::before { content: ' · '; }
html[data-hide-pct] #topbar #ctx-pct { display: none; }   /* 洗脸卡里的开关 */
#topbar #ctx-bar { display: none; }

#topbar .tb-boat {
  position: relative; flex: none;
  width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%;
}
#topbar .tb-boat img { width: 36px; height: auto; display: block; filter: drop-shadow(0 1px 2px rgba(40,60,90,.18)); }
#topbar .tb-boat.rock img { animation: boat-rock .65s ease; }
@keyframes boat-rock {
  0% { transform: rotate(0) } 22% { transform: rotate(-10deg) translateY(1px) }
  50% { transform: rotate(7deg) } 78% { transform: rotate(-3deg) } 100% { transform: rotate(0) }
}

/* ── 小船抽屉 ── */
/* 9.27 21:10 她说：带点颜色（跟模型牌一个色）、不要图标、收窄 */
.boat-pop {
  position: fixed; z-index: 300;
  top: calc(var(--safe-top) + var(--topbar-h) - 2px); right: 10px;
  padding: 5px;
  border-radius: 16px; background: rgba(230,235,240,.94);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  box-shadow: 0 8px 24px rgba(30,45,70,.14), 0 0 0 1px rgba(90,120,150,.10);
  transform-origin: top right;
  opacity: 0; transform: scale(.92) translateY(-6px); pointer-events: none;
  transition: opacity .16s ease, transform .18s cubic-bezier(.3,1.3,.5,1);
}
.boat-pop.show { opacity: 1; transform: none; pointer-events: auto; }
.boat-pop[hidden] { display: none; }
.boat-pop button {
  display: block; width: 100%; min-height: 42px; padding: 0 20px;
  font-size: 15px; color: #33475c; text-align: center; white-space: nowrap; border-radius: 11px;
}
.boat-pop button + button { border-top: 1px solid rgba(90,120,150,.12); border-top-left-radius: 0; border-top-right-radius: 0; }
.boat-pop button:active { background: rgba(90,120,150,.12); }

/* ── 气泡不带头像 ── */
#chat-view { --avatar-sz: 0px; --avatar-gap: 0px; }
#chat-view .msg-row.ai::before { display: none; }
#chat-view #typing { margin-left: 6px; }

/* ── 已思考（9.29）：底是小船抽屉那个色，前面那道杠是我气泡的颜色。历史页里那份在 hist.css ── */
#chat-view .thinking-body {
  background: rgba(230,235,240,.94); color: #33475c;
  border-left: 3px solid var(--bub-me, #e8eef4);
}
#send .send-paw { display: block; }

/* ── 9.30 我的气泡也四角全圆：头像不在旁边了，那个角没处指；连着几条像一串泡泡。历史页一样 ── */
.msg-row.ai .bubble { border-radius: 18px; border-bottom-left-radius: 18px; }

/* ── 9.30 点头像出来的侧边栏：颜色跟小船抽屉一个色 ── */
#drawer { background: rgba(230,235,240,.96); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); color: #33475c; }
#drawer .drawer-item-name, #drawer .drawer-brand-group, #drawer .drawer-header { color: #33475c; }
#drawer .drawer-item-time, #drawer .drawer-item-preview { color: rgba(51,71,92,.62); }
#drawer .drawer-item:active { background: rgba(90,120,150,.12); }
#drawer .drawer-item.active { background: rgba(90,120,150,.14); }
#drawer .drawer-item.active .drawer-item-name { color: #2f4257; }
#drawer .drawer-item-icon { background: rgba(90,120,150,.10); color: #4a6078; }
#drawer .drawer-item.active .drawer-item-icon { background: rgba(90,120,150,.20); color: #2f4257; }

/* ── 时间：今天的只写几点，以前的写全 ── */
.msg-time .mt-date.today { display: none; }

/* ── 打字框一行：+ 在左，发送在右，字多了自己长高 ── */
#chat-view .composer-wrap { padding: 8px 14px 10px; }
#chat-view .composer-box {
  display: grid; grid-template-columns: auto 1fr auto; align-items: end;
  padding: 6px; overflow: visible;
}
#chat-view #quote-bar, #chat-view .attach-bar { grid-column: 1 / -1; }
#chat-view .composer-input { grid-column: 2; grid-row: 3; padding: 5px 8px; min-width: 0; }
#chat-view .composer-actions { display: contents; }
#chat-view #attach-btn { grid-column: 1; grid-row: 3; }
#chat-view #send { grid-column: 3; grid-row: 3; }
#chat-view .composer-spacer { display: none; }
#chat-view #input { display: block; }

/* ── 狐狸趴在打字框上面，不框它。出去玩的时候不在 ── */
.composer-fox {
  position: absolute; z-index: 3; right: 58px; top: 8px;
  width: 58px; height: auto;
  transform: translateY(calc(-100% + 9px));
  pointer-events: none; user-select: none; -webkit-user-drag: none;
}
.hb-playing-hint.show ~ .composer-wrap .composer-fox { display: none; }

/* ── 洗脸留痕：对话中间两行，浅浅的。第一行页面说的，第二行我提前写好的；点第一行看便签 ── */
.wash-hint { display: none; }
.wash-hint.show { display: flex; }
.hb-playing-hint.show ~ .wash-hint.show { display: none; }   /* 出去玩那条在的时候不叠两条 */
.wash-mark { align-self: center; text-align: center; max-width: 86%; margin: 2px auto; }
.wash-mark .wm-line {
  display: inline-block; font-size: 12px; line-height: 1.6; letter-spacing: .04em;
  color: var(--text3); opacity: .85; padding: 0 4px;
}
.wash-mark .wm-line::before, .wash-mark .wm-line::after { content: '─'; opacity: .5; margin: 0 8px; }
.wash-mark .wm-line.has-note { cursor: pointer; }
.wash-mark .wm-line.has-note:active { opacity: .5; }
.wash-mark .wm-say { font-size: 12px; line-height: 1.6; color: var(--text3); opacity: .85; }
.wash-mark .wm-note {
  margin-top: 8px; padding: 10px 14px; border-radius: 14px; text-align: left;
  font-size: 12.5px; line-height: 1.7; color: var(--text2); white-space: pre-wrap; word-break: break-word;
  background: rgba(255,255,255,.55); box-shadow: 0 0 0 1px rgba(0,0,0,.05);
  max-height: 46vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.wash-mark .wm-note[hidden] { display: none; }

/* ── 底栏浮起来（只在聊天页） ── */
body:has(#chat-view.active) #app { background: #f9f9f7; }
body:has(#chat-view.active) #tab-bar {
  margin: 0 14px var(--tab-safe);
  height: 58px; padding: 5px;
  border: none; border-radius: 29px;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 0 0 1px rgba(0,0,0,.09);
}
body:has(#chat-view.active) .tab-item { border-radius: 24px; color: var(--text2); }
body:has(#chat-view.active) .tab-item.active { background: #e8eef4; color: #2f4257; }

/* ── 窗口状态：从侧边抽屉改成弹卡（模型牌、洗脸各开各的） ── */
.mem-drawer {
  top: 50%; left: 50%; right: auto; bottom: auto;
  width: min(92vw, 400px); max-width: none; max-height: min(78vh, 640px);
  border-radius: 24px; overflow: hidden;
  background: #fbfbf9;
  box-shadow: 0 20px 60px rgba(20,30,50,.25);
  opacity: 0; pointer-events: none;
  transform: translate(-50%, -47%) scale(.96);
  transition: opacity .2s ease, transform .22s cubic-bezier(.3,1.2,.5,1);
}
.mem-drawer.open { right: auto; opacity: 1; pointer-events: auto; transform: translate(-50%, -50%); }
.mem-drawer-header { top: 8px; right: 10px; }
.mem-drawer-header button { font-size: 22px; padding: 4px 10px; }
.mem-drawer-body { padding: 10px 16px 12px; }

@media (prefers-color-scheme: dark) {
  #topbar .tb-avatar { box-shadow: 0 0 0 2px rgba(255,255,255,.14), 0 2px 8px rgba(0,0,0,.3); }
  #topbar .tb-model { background: rgba(255,255,255,.08); }
  .boat-pop { background: rgba(48,52,58,.94); box-shadow: 0 10px 30px rgba(0,0,0,.4), 0 0 0 1px rgba(255,255,255,.07); }
  .boat-pop button { color: #d5dee8; }
  .boat-pop button + button { border-top-color: rgba(255,255,255,.06); }
  .boat-pop button:active { background: rgba(255,255,255,.05); }
  .look-dot.on { box-shadow: 0 0 0 2px #2b2b29, 0 0 0 4px #8fa9c4; }
  .wash-mark .wm-note { background: rgba(255,255,255,.06); box-shadow: 0 0 0 1px rgba(255,255,255,.08); }
  body:has(#chat-view.active) #app { background: #262624; }
  body:has(#chat-view.active) #tab-bar { background: #30302e; box-shadow: 0 1px 2px rgba(0,0,0,.3), 0 0 0 1px rgba(255,255,255,.08); }
  body:has(#chat-view.active) .tab-item.active { background: #2a3138; color: #cfdbe8; }
  .mem-drawer { background: #2b2b29; }
  #chat-view .thinking-body { background: rgba(48,52,58,.94); color: #d5dee8; border-left-color: #3d5872; }
  #drawer { background: rgba(48,52,58,.96); color: #d5dee8; }
  #drawer .drawer-item-name, #drawer .drawer-brand-group, #drawer .drawer-header { color: #d5dee8; }
  #drawer .drawer-item-time, #drawer .drawer-item-preview { color: rgba(213,222,232,.6); }
  #drawer .drawer-item.active { background: rgba(255,255,255,.07); }
  #drawer .drawer-item.active .drawer-item-name { color: #eef3f8; }
  #drawer .drawer-item-icon { background: rgba(255,255,255,.06); color: #b9c8d8; }
}

/* ══════════ 背景卡（9.27 21:10 她画的：头像 / 气泡 / 背景图，每栏一排圆，圆里是略缩图）══════════ */
#look-overlay { background: rgba(0,0,0,.16); }   /* 淡一点：换的时候要看得见后面变成什么样 */
.look-card { max-height: min(74vh, 560px); }
.look-card .look-head { font-size: 16px; font-weight: 600; padding: 6px 4px 2px; }
.look-card .look-sec { padding: 14px 4px 14px; border-bottom: 1px solid rgba(128,128,128,.12); }
.look-card .look-sec:last-child { border-bottom: none; padding-bottom: 6px; }
.look-card .look-title { font-weight: 600; font-size: 13px; opacity: .85; margin-bottom: 12px; }
.look-card .look-row { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.look-card .look-row:has(.look-dots) { flex-wrap: nowrap; }
.look-card .look-dots { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; gap: 12px; }
.look-card .look-row + .look-row { margin-top: 12px; }
.look-card .look-who { width: 30px; flex: none; font-size: 12px; color: var(--text2); line-height: 42px; }
.look-dot {
  position: relative; flex: none; padding: 0;
  width: 42px; height: 42px; border-radius: 50%;
  background-color: #fff; background-size: cover; background-position: center;
  box-shadow: 0 0 0 1px rgba(0,0,0,.10), 0 1px 3px rgba(0,0,0,.06);
  transition: box-shadow .15s ease, transform .1s ease;
}
.look-dot.on { box-shadow: 0 0 0 2px #fbfbf9, 0 0 0 4px #7f9bb8; }
.look-dot:active { transform: scale(.93); }

/* ══════════ 聊天页的背景层 ══════════
   #app 是 body 的直接孩子，本来就有自己的层（style.css 最后那条 body > *），所以这层放 -1 刚好垫在所有东西底下、#app 底色上面 */
#chat-bg { display: none; position: absolute; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
#chat-bg::before, #chat-bg::after { content: ''; position: absolute; inset: 0; }

/* 外观只在"不是深色模式"的时候换（写成 not dark，比写 light 稳）。深色模式字是浅的，气泡一变亮就看不清了，先不碰 */
@media not all and (prefers-color-scheme: dark) {
  html[data-chat-bg] body:has(#chat-view.active) #chat-bg { display: block; }
  html[data-chat-bg] #topbar,
  html[data-chat-bg] #chat-view,
  html[data-chat-bg] #chat-view .composer-wrap { background: transparent; }
  html[data-chat-bg] body:has(#chat-view.active) #app { background: var(--chat-base, #f9f9f7); }
  /* 直接印在底上的小字，底有了颜色就得深一点 */
  html[data-chat-bg] #chat-view .msg-time { color: rgba(40,55,75,.58); }
  html[data-chat-bg] #chat-view .wash-mark .wm-line,
  html[data-chat-bg] #chat-view .wash-mark .wm-say { color: rgba(40,55,75,.55); }
  html[data-chat-bg] #topbar .topbar-sub { color: rgba(40,55,75,.72); }
  html[data-chat-bg] #topbar .tb-model { background: rgba(255,255,255,.5); color: rgba(40,55,75,.78); }
  html[data-chat-bg] #chat-view .composer-box { background: var(--chat-surface, #fff); }
  html[data-chat-bg] body:has(#chat-view.active) #tab-bar { background: var(--chat-surface, #fff); }

  /* 细颗粒，几张共用 */
  html[data-chat-bg] #chat-bg::after {
    opacity: .5;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .4  0 0 0 0 .5  0 0 0 0 .62  0 0 0 .07 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  }

  /* 雾蓝 = 茶茶压过的那张。缩成 64 像素宽的小图再放大，形状是原图的，哪个屏都不糊。
     （9.27 21:32 她说三张蓝的看不出区别：晴、薄云拿掉了，只留这张） */
  html[data-chat-bg="mist"] { --chat-base: #dde8f3; }
  html[data-chat-bg="mist"] #chat-bg::before { inset: -40px; background: url("/img/bg/mist.png") center / 100% 100% no-repeat; filter: blur(14px); }

  /* 晚霞 = 茶茶画的云带（9.27 04:40 定的那张）。有云边有月亮，不能缩小再放大，用原图；贴着顶铺，图自己带纸纹，不再叠颗粒 */
  html[data-chat-bg="glow"] { --chat-base: #dae7e7; }
  html[data-chat-bg="glow"] #chat-bg { background: #dae7e7 url("/img/bg/glow.jpg") top center / cover no-repeat; }
  html[data-chat-bg="glow"] #chat-bg::after { display: none; }

  /* 暮色 = 我画的：天快黑没黑那一段，蓝里带灰，最底下一丝橘。9.27 她说色块比浅的显，云压淡压大了 */
  html[data-chat-bg="dusk"] { --chat-base: #a9bcd2; --chat-surface: #f4f6f8; }
  html[data-chat-bg="dusk"] #chat-bg {
    background-color: #a9bcd2;
    background-image:
      radial-gradient(ellipse 130% 26% at 50% 105%, rgba(238,208,188,.6) 0%, rgba(238,208,188,0) 70%),
      linear-gradient(180deg, #9db2cc 0%, #abbed4 34%, #bac9d9 66%, #c8d3dc 100%);
  }
  html[data-chat-bg="dusk"] #chat-bg::before {
    background-size: 100% 100%;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='852' height='1846' preserveAspectRatio='none'><filter id='c' x='0' y='0' width='100%' height='100%'><feTurbulence type='fractalNoise' baseFrequency='.0014 .0008' numOctaves='2' seed='11'/><feColorMatrix values='0 0 0 0 .93  0 0 0 0 .95  0 0 0 0 .97  1 0 0 0 -.45'/></filter><rect width='100%' height='100%' filter='url(%23c)'/></svg>");
  }
  html[data-chat-bg="dusk"] #chat-view .msg-time { color: rgba(30,42,58,.62); }

  /* 气泡颜色：她在卡里挑的；没挑就是原来那两个 */
  #chat-view .msg-row.ai .bubble { background: var(--bub-me, #e8eef4); color: var(--bub-me-ink, var(--text)); }
  #chat-view .msg-row.user .bubble { background: var(--bub-her, #f0efec); }

  /* 9.27 22:34 她定的：发送键跟我的气泡一个色，＋ 跟她的气泡一个色 */
  #chat-view #send, #chat-view #send:not(:disabled) { background: var(--bub-me, #e8eef4); color: var(--send-ink, #2f4257); }
  #chat-view #send:not(:disabled) { box-shadow: 0 1px 4px rgba(40,60,90,.16); }
  #chat-view .composer-icon { background: var(--bub-her, #f0efec); color: #55534e; }

  /* 深气泡：字自动变浅，星号小字、代码、引用、表格、链接一样样跟着 */
  html[data-bub-me-ink="light"] #chat-view .msg-row.ai .bubble .thought { color: rgba(243,246,249,.74); }
  html[data-bub-me-ink="light"] #chat-view .msg-row.ai .bubble code,
  html[data-bub-me-ink="light"] #chat-view .msg-row.ai .bubble code:not(pre code) { background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.16); color: inherit; }
  html[data-bub-me-ink="light"] #chat-view .msg-row.ai .bubble pre,
  html[data-bub-me-ink="light"] #chat-view .msg-row.ai .bubble .code-block pre { background: rgba(0,0,0,.22); border-color: rgba(255,255,255,.12); }
  html[data-bub-me-ink="light"] #chat-view .msg-row.ai .bubble pre code { background: none; border: none; }
  html[data-bub-me-ink="light"] #chat-view .msg-row.ai .bubble .code-block { border-color: rgba(255,255,255,.14); }
  html[data-bub-me-ink="light"] #chat-view .msg-row.ai .bubble .code-header { background: rgba(0,0,0,.18); border-bottom-color: rgba(255,255,255,.10); }
  html[data-bub-me-ink="light"] #chat-view .msg-row.ai .bubble .code-lang,
  html[data-bub-me-ink="light"] #chat-view .msg-row.ai .bubble .code-copy-btn { color: rgba(243,246,249,.62); }
  html[data-bub-me-ink="light"] #chat-view .msg-row.ai .bubble blockquote { border-left-color: rgba(255,255,255,.4); }
  html[data-bub-me-ink="light"] #chat-view .msg-row.ai .bubble a { color: #ffe1d2; }
  html[data-bub-me-ink="light"] #chat-view .msg-row.ai .bubble th { background: rgba(255,255,255,.12); }
  html[data-bub-me-ink="light"] #chat-view .msg-row.ai .bubble tr:nth-child(even) { background: rgba(255,255,255,.06); opacity: 1; }
  html[data-bub-me-ink="light"] #chat-view .msg-row.ai .bubble th,
  html[data-bub-me-ink="light"] #chat-view .msg-row.ai .bubble td { border-color: rgba(255,255,255,.2); }
  html[data-bub-me-ink="light"] #chat-view .msg-row.ai .bubble hr { border-top-color: rgba(255,255,255,.25); }
}
