:root {
  --bg: #000; --panel: rgba(20,20,20,.55); --solid: #111; --line: rgba(255,255,255,.12); --text: #f5f5f5; --dim: #9a9a9a; --accent: #fff;
  --glass-blur: blur(22px) saturate(140%); --r: 18px; --side: 412px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  display: flex; background: var(--bg); color: var(--text); overflow: hidden;
  font: 14px/1.6 "Microsoft YaHei UI", "PingFang SC", "Noto Sans CJK SC", system-ui, sans-serif;
}
button, .button, input, select, textarea { font: inherit; color: inherit; }
.glass { background: var(--panel); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur); border: 1px solid var(--line); }
button, .button {
  background: var(--text); color: #000; border: 1px solid var(--text); border-radius: 999px;
  padding: 5px 14px; cursor: pointer; text-decoration: none; display: inline-block;
}
.ghost { background: rgba(255,255,255,.06); color: var(--text); border-color: var(--line); }
.ghost[aria-pressed="true"] { background: #ededed; color: #111; border-color: #ededed; }
.ghost[aria-pressed="true"]:hover { background: #fff; border-color: #fff; }
.ghost:hover { background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.28); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:disabled { opacity: .45; cursor: default; }
input, select, textarea {
  width: 100%; background: rgba(0,0,0,.35); border: 1px solid var(--line); border-radius: 12px; padding: 7px 11px;
}
.row { display: flex; align-items: center; gap: 8px; }
.grow { flex: 1; min-width: 0; }

#side { position: absolute; z-index: 5; left: 12px; top: 12px; bottom: 12px; width: calc(var(--side) - 24px); display: flex; flex-direction: column; background: var(--panel); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur); border: 1px solid var(--line); border-radius: 24px; overflow: hidden; }
#side header { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px 12px 18px; border-bottom: 1px solid var(--line); }
h1 { font-size: 16px; font-weight: 600; margin: 0; }
#log { flex: 1; overflow-y: auto; padding: 16px 12px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 84%; padding: 8px 13px; border-radius: 16px; line-height: 1.6; overflow-wrap: anywhere; }
.msg-text { white-space: pre-wrap; }
.msg-text code { background: rgba(255,255,255,.1); border-radius: 4px; padding: 0 4px; font-size: 13px; }
.msg-text strong { font-weight: 600; }
.msg.assistant { align-self: flex-start; background: rgba(255,255,255,.08); border-bottom-left-radius: 6px; }
.msg.user { align-self: flex-end; background: #fff; color: #000; border-bottom-right-radius: 6px; }
.msg.user, .msg-images.user { position: relative; }
.recall {
  position: absolute; right: calc(100% + 6px); bottom: 2px; padding: 1px 9px; font-size: 11px; white-space: nowrap;
  background: rgba(255,255,255,.06); color: var(--dim); border: 1px solid var(--line); opacity: 0; transition: opacity .15s;
}
.recall:hover { color: var(--text); background: rgba(255,255,255,.14); }
/* 引用：气泡旁边的“引用”，气泡里引着的那句，输入框上方正在引用的那句 */
.msg.assistant { position: relative; }
.quote-btn {
  position: absolute; top: 2px; padding: 1px 9px; font-size: 11px; white-space: nowrap;
  background: rgba(255,255,255,.06); color: var(--dim); border: 1px solid var(--line); opacity: 0; transition: opacity .15s;
}
.msg.user > .quote-btn { right: calc(100% + 6px); }
.msg.assistant > .quote-btn { left: calc(100% + 6px); }
.quote-btn:hover { color: var(--text); background: rgba(255,255,255,.14); }
.msg:hover > .quote-btn, .quote-btn:focus-visible { opacity: 1; }
@media (pointer: coarse) { .quote-btn { opacity: .85; } }
.msg-quote {
  margin: 2px 0 6px; padding: 3px 8px; border-left: 2px solid rgba(255,255,255,.3); border-radius: 4px;
  font-size: 12px; line-height: 1.5; color: var(--dim); background: rgba(255,255,255,.05);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap;
}
.msg.user .msg-quote { color: rgba(0,0,0,.55); background: rgba(0,0,0,.06); border-left-color: rgba(0,0,0,.25); }
#quoting { display: flex; align-items: flex-start; gap: 6px; margin: 2px 2px 6px; padding: 4px 8px; border-left: 2px solid rgba(255,255,255,.35); border-radius: 4px; background: rgba(255,255,255,.05); font-size: 12px; color: var(--dim); }
#quoting[hidden] { display: none; }
#quoting span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#unquote { padding: 0 6px; font-size: 13px; line-height: 1.2; background: none; border: none; color: var(--dim); }
#unquote:hover { color: var(--text); }
.msg.user:hover > .recall, .msg-images.user:hover > .recall, .recall:focus-visible { opacity: 1; }
@media (pointer: coarse) { .recall { opacity: .85; } }
.msg.notice { align-self: center; padding: 0 8px; font-size: 12px; color: var(--dim); background: none; }
.msg-read { display: block; margin-top: 2px; font-size: 11px; text-align: right; color: rgba(0,0,0,.45); }
.msg.user code { background: rgba(0,0,0,.14); }
.msg.error { align-self: center; max-width: 92%; background: rgba(255,255,255,.04); color: var(--text); border: 1px dashed rgba(255,255,255,.4); border-radius: 14px; font-size: 13px; }
.msg-tag { display: block; margin-bottom: 2px; font-size: 11px; color: var(--dim); }
.typing { align-self: flex-start; display: flex; gap: 5px; padding: 12px 14px; background: rgba(255,255,255,.08); border-radius: 16px; border-bottom-left-radius: 6px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--dim); }
@media (prefers-reduced-motion: no-preference) {
  .typing i { animation: typing 1.2s ease-in-out infinite; }
  .typing i:nth-child(2) { animation-delay: .2s; }
  .typing i:nth-child(3) { animation-delay: .4s; }
}
@keyframes typing { 0%, 60%, 100% { opacity: .35; } 30% { opacity: 1; } }
.trace-group { align-self: stretch; font-size: 12px; color: var(--dim); }
.trace-group summary { cursor: pointer; padding: 1px 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trace-group summary:hover { color: var(--text); }
.trace-body { display: flex; flex-direction: column; gap: 4px; margin: 4px 0 2px 6px; padding-left: 10px; border-left: 1px solid var(--line); }
.trace { display: block; width: 100%; font-size: 12px; color: var(--dim); background: none; border: 0; padding: 0; text-align: left; border-radius: 0; overflow-wrap: anywhere; }
.trace b { color: var(--text); font-weight: 500; margin-right: 6px; }
button.trace:hover { color: var(--text); }
#composer { padding: 10px 12px 12px; }
#doing { display: flex; align-items: center; gap: 7px; padding: 6px 14px 0; font-size: 12px; color: var(--dim); }
#doing[hidden] { display: none; }
#doing i { width: 6px; height: 6px; border-radius: 50%; background: var(--dim); flex: none; }
@media (prefers-reduced-motion: no-preference) { #doing i { animation: typing 1.6s ease-in-out infinite; } }
#inputBox { display: grid; gap: 6px; padding: 10px 10px 8px 12px; background: rgba(255,255,255,.06); border: 1px solid var(--line); border-radius: 22px; }
#inputBox:focus-within { border-color: rgba(255,255,255,.35); }
#input { resize: none; background: none; border: 0; border-radius: 0; padding: 0 3px; max-height: 140px; overflow-y: auto; line-height: 1.5; }
#input:focus-visible { outline: none; }
.tool { background: none; color: var(--dim); border: 0; border-radius: 999px; padding: 2px 10px; font-size: 12px; }
.tool:hover { color: var(--text); background: rgba(255,255,255,.1); }
#send { width: 30px; height: 30px; padding: 0; border-radius: 50%; line-height: 1; font-size: 16px; background: #fff; border-color: #fff; color: #000; }
#clock { margin-left: 12px; }
#clock:empty { display: none; }
#state { display: inline-flex; align-items: center; gap: 5px; padding: 1px 9px; border: 1px solid var(--line); border-radius: 999px; color: var(--dim); font-size: 12px; white-space: nowrap; }
#state::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #fff; }
#state[data-state="free"] { color: var(--text); border-color: rgba(255,255,255,.4); }
#state[data-state="free"]::before { background: #fff; box-shadow: 0 0 6px #fff; }
#state[data-state="asleep"] { color: var(--dim); background: rgba(255,255,255,.04); border-color: var(--line); }
#state[data-state="asleep"]::before { background: #555; }
#notebook { width: min(1080px, calc(100vw - 32px)); height: min(760px, calc(100vh - 32px)); max-width: none; max-height: none; padding: 12px; }
#notebook[open] { display: flex; flex-direction: column; gap: 10px; }
#bookStage { position: relative; flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: minmax(0, 1fr); perspective: 2200px; overflow: hidden; border-radius: 16px; }
#bookStage.single { grid-template-columns: 1fr; }
#bookStage .slot { min-width: 0; min-height: 0; display: flex; }
#bookStage .slot[hidden] { display: none; }
#bookBar { flex: none; }
#gallery { width: min(1080px, calc(100vw - 32px)); height: min(760px, calc(100vh - 32px)); max-width: none; max-height: none; padding: 12px; }
#gallery[open] { display: flex; flex-direction: column; gap: 10px; }
#galleryBar { flex: none; align-items: center; }
#galleryBar h2 { margin: 0; }
#galleryGrid { flex: 1; min-height: 0; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; align-content: start; }
#galleryGrid[hidden] { display: none; }
#galleryGrid .card { display: flex; flex-direction: column; gap: 6px; padding: 6px; background: rgba(255,255,255,.04); border: 1px solid var(--line); border-radius: 16px; color: var(--text); text-align: left; cursor: pointer; font: inherit; }
#galleryGrid .card:hover, #galleryGrid .card:focus-visible { border-color: var(--accent); }
#galleryGrid .card img { width: 100%; aspect-ratio: 4 / 3; object-fit: contain; background: #fff; border-radius: 11px; }
#galleryGrid .about { font-size: 12px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
#galleryGrid .when { font-size: 11px; color: var(--dim); }
#galleryGrid .empty { grid-column: 1 / -1; color: var(--dim); text-align: center; padding: 40px 0; }
#galleryView { flex: 1; min-height: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
#galleryView[hidden] { display: none; }
#galleryFrame { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; background: #fff; border-radius: 16px; overflow: hidden; }
#galleryFrame img { max-width: 100%; max-height: 100%; width: 100%; height: 100%; object-fit: contain; }
#galleryView figcaption { flex: none; display: flex; align-items: center; gap: 10px; font-size: 13px; line-height: 1.5; }
#galleryCaption { text-align: center; overflow-wrap: anywhere; }
.msg-images img { cursor: zoom-in; }
#viewer { width: min(1200px, calc(100vw - 32px)); height: min(900px, calc(100vh - 32px)); max-width: none; max-height: none; padding: 12px; }
#viewer[open] { display: flex; flex-direction: column; align-items: center; gap: 10px; }
#viewerImg { flex: 1; min-height: 0; width: 100%; object-fit: contain; background: #fff; border-radius: 12px; }
#closeViewer { flex: none; }
#bookPage { min-width: 76px; text-align: center; color: var(--dim); font-size: 12px; font-variant-numeric: tabular-nums; }
.page { position: relative; flex: 1; width: 100%; height: 100%; min-width: 0; display: flex; flex-direction: column; padding: 40px 44px 34px; background: #141414; color: #ece8e0; font-family: "Noto Serif SC", "Source Han Serif SC", "Songti SC", SimSun, serif; font-size: 15px; line-height: 1.9; overflow: hidden; }
.slot:first-child .page { box-shadow: inset -22px 0 26px -22px rgba(0,0,0,.9); }
.slot:nth-child(2) .page { box-shadow: inset 22px 0 26px -22px rgba(0,0,0,.9); }
#bookStage.single .page { box-shadow: none; }
.page.blank { background: #0e0e0e; }
.page.measure { position: absolute; left: 0; top: 0; visibility: hidden; pointer-events: none; }
.page-body { flex: 1; min-height: 0; overflow: hidden; overflow-wrap: anywhere; }
.page-body > :first-child { margin-top: 0; }
.page-body p { margin: 0 0 .9em; white-space: pre-wrap; }
.page-body h3 { margin: 1.1em 0 .5em; font-size: 19px; font-weight: 600; line-height: 1.5; }
.page-body h4 { margin: 1em 0 .4em; font-size: 16px; font-weight: 600; line-height: 1.5; color: #d8d3c9; }
.page-body blockquote { margin: 0 0 .9em; padding-left: 14px; border-left: 2px solid var(--accent); color: #bdb8ae; white-space: pre-wrap; }
.page-body hr { width: 72px; margin: 1.4em auto; border: 0; border-top: 1px solid #555; }
.page-body strong { font-weight: 700; color: #fff; }
.page-body code { background: rgba(255,255,255,.08); border-radius: 3px; padding: 0 4px; font-size: .9em; }
.note-figure { margin: 0 0 1em; text-align: center; }
.note-figure img { display: block; width: 100%; height: 240px; object-fit: contain; }
.note-figure figcaption { margin-top: 4px; color: var(--dim); font-size: 12px; line-height: 1.5; }
.page-num { position: absolute; bottom: 12px; left: 0; right: 0; text-align: center; color: var(--dim); font: 11px system-ui, sans-serif; font-variant-numeric: tabular-nums; }
.note-head { margin-bottom: 26px; padding-bottom: 14px; border-bottom: 1px solid #333; }
.note-head h2 { margin: 0; font-size: 26px; font-weight: 700; line-height: 1.35; }
.page-body .note-sub { margin: 6px 0 0; color: #b9b4aa; font-size: 15px; line-height: 1.6; }
.note-head small { display: block; margin-top: 8px; color: var(--dim); font: 12px system-ui, sans-serif; }
.page-body.cover { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.cover h2 { margin: 0 0 10px; font-size: 34px; font-weight: 700; letter-spacing: .12em; }
.cover p { margin: 0; color: var(--dim); }
.page-body h3.toc-title { margin: 0 0 14px; font-size: 22px; }
.toc-row { display: flex; align-items: baseline; gap: 12px; width: 100%; padding: 8px 2px; background: none; color: inherit; border: 0; border-bottom: 1px solid #2a2a2a; border-radius: 0; text-align: left; font: inherit; line-height: 1.5; }
.toc-row:hover { color: #fff; text-decoration: underline; }
.toc-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.toc-name small { display: block; color: var(--dim); font-size: 12px; }
.toc-num { color: var(--dim); font: 12px system-ui, sans-serif; font-variant-numeric: tabular-nums; }
.leaf { position: absolute; top: 0; bottom: 0; left: 50%; width: 50%; transform-origin: left center; transform-style: preserve-3d; z-index: 2; }
.leaf[hidden] { display: none; }
#bookStage.single .leaf { left: 0; width: 100%; }
.leaf-face { position: absolute; inset: 0; display: flex; backface-visibility: hidden; background: #141414; }
.leaf-face.back { transform: rotateY(180deg); }
@media (max-width: 759px) { .page { padding: 28px 22px 30px; } }
#pending { display: flex; flex-wrap: wrap; gap: 6px; }
#pending[hidden] { display: none; }
.pending-item { position: relative; width: 64px; height: 64px; padding: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #000; cursor: pointer; }
.pending-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pending-item::after { content: '×'; position: absolute; top: 0; right: 0; width: 18px; height: 18px; line-height: 18px; text-align: center; background: rgba(0,0,0,.75); color: #fff; font-size: 13px; }
#composer.dropping #inputBox { border-color: var(--accent); border-style: dashed; }
.msg-images { display: flex; flex-wrap: wrap; gap: 6px; }
.msg-images.user { align-self: flex-end; justify-content: flex-end; }
.msg-images.assistant { align-self: flex-start; }
.msg-images img { max-width: 240px; max-height: 200px; border: 1px solid var(--line); border-radius: 12px; display: block; }
#visionBox { font-size: 13px; }
#visionBox summary { cursor: pointer; margin-bottom: 8px; }
#visionBox label { display: block; margin-bottom: 8px; }

#stage { position: fixed; inset: 0; overflow: hidden; }
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.label { position: absolute; left: 0; top: 0; white-space: nowrap; font-size: 13px; color: #fff; text-shadow: 0 0 4px #000, 0 0 2px #000; will-change: transform; }
.label.skill { color: #f6cf8e; }
.region-label { position: absolute; pointer-events: none; z-index: 1; left: 0; top: 0; white-space: nowrap; font-size: 13px; letter-spacing: .2em; color: #fff; padding: 3px 12px; border: 1px solid rgba(255,255,255,.28); border-radius: 999px; background: rgba(0,0,0,.55); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); transition: opacity .6s; will-change: transform; }
.label[data-kind="lesson"] { color: #9fe8c4; }
.label[data-kind="belief"] { color: #cbb8ff; }
.label[data-kind="gap"] { color: #fff; font-style: italic; }
.label[data-kind="self"] { color: #ffe7a8; }
.label[data-kind="faded"] { color: #8a8a8a; text-decoration: line-through; }
#hud { position: absolute; left: calc(var(--side) + 4px); top: 18px; display: flex; gap: 10px; color: var(--dim); font-size: 12px; font-variant-numeric: tabular-nums; pointer-events: none; }
#tools { position: absolute; left: calc(var(--side) + 4px); bottom: 14px; display: flex; flex-wrap: wrap; gap: 4px; padding: 5px; border-radius: 999px; background: var(--panel); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur); border: 1px solid var(--line); }
#tools > * { background: transparent; border-color: transparent; font-size: 12px; padding: 4px 12px; }
#tools > *:hover { background: rgba(255,255,255,.12); border-color: transparent; }
#tools > [aria-pressed="true"], #tools > [aria-pressed="true"]:hover { background: #ededed; color: #111; }
#tip { position: absolute; pointer-events: none; background: var(--panel); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur); border: 1px solid var(--line); padding: 3px 10px; border-radius: 999px; font-size: 12px; white-space: nowrap; }
#empty { position: absolute; inset: 0 0 0 var(--side); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; color: var(--dim); padding: 16px; }
#empty[hidden], #tip[hidden], #inspector[hidden] { display: none; }
#empty p { margin: 0 0 8px; }
#empty .big { font-size: 22px; color: var(--text); }
#empty button { margin-top: 10px; }
#inspector { position: absolute; right: 12px; top: 12px; bottom: 12px; width: 320px; max-width: calc(100% - 24px); background: var(--panel); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur); border: 1px solid var(--line); border-radius: 24px; padding: 18px; overflow-y: auto; }
#closeInspector { position: absolute; right: 10px; top: 10px; width: 28px; height: 28px; padding: 0; border-radius: 50%; font-size: 16px; line-height: 1; }
#inspector h2 { font-size: 16px; margin: 0 28px 8px 0; overflow-wrap: anywhere; }
#inspector h3 { font-size: 12px; color: var(--dim); font-weight: 400; margin: 16px 0 4px; }
#inspector dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 0; font-variant-numeric: tabular-nums; }
#inspector dt { color: var(--dim); }
#inspector dd { margin: 0; }
#inspector pre { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; margin: 0; }
.link { display: block; width: 100%; text-align: left; background: none; color: var(--text); border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 4px 0; }
.link small { color: var(--dim); float: right; }

#scene { transition: filter 1.5s; }
#stage.sleeping #scene { filter: brightness(.5); }
#psyche { position: absolute; left: calc(var(--side) + 4px); bottom: 62px; width: 250px; max-height: calc(100% - 110px); overflow-y: auto; background: var(--panel); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur); border: 1px solid var(--line); border-radius: 20px; padding: 10px 14px 12px; font-size: 12px; }
#psyche h3, #desk h3 { margin: 4px 0; color: var(--dim); font-size: 12px; font-weight: 400; }
#desk { position: absolute; left: calc(var(--side) + 264px); bottom: 62px; width: 270px; max-height: calc(100% - 110px); overflow-y: auto; background: var(--panel); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur); border: 1px solid var(--line); border-radius: 20px; padding: 10px 14px 12px; font-size: 12px; }
#desk[hidden] { display: none; }
.desk-item { padding: 6px 0; border-top: 1px solid var(--line); line-height: 1.5; overflow-wrap: anywhere; }
.desk-item small { display: block; color: var(--dim); font-size: 11px; }
.desk-empty { color: var(--dim); }
.mood { display: grid; grid-template-columns: 34px 1fr 30px; align-items: center; gap: 6px; height: 20px; }
.mood b { font-weight: 500; }
.mood small { color: var(--dim); text-align: right; font-size: 11px; }
.psyche-note { color: var(--dim); font-size: 11px; line-height: 1.5; margin: 2px 0 4px; overflow-wrap: anywhere; }
.meter { display: grid; grid-template-columns: 34px 1fr 30px; align-items: center; gap: 6px; height: 18px; font-variant-numeric: tabular-nums; }
.meter small { color: var(--dim); text-align: right; font-size: 11px; }
.track { position: relative; height: 4px; background: rgba(255,255,255,.1); border-radius: 999px; overflow: hidden; }
.fill { position: absolute; top: 0; bottom: 0; left: 0; border-radius: 999px; transition: width .4s, left .4s; }
.axis { display: grid; grid-template-columns: 30px 1fr 30px; align-items: center; gap: 6px; height: 18px; }
.axis span:last-child { text-align: right; }
.axis .track::after { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: #666; }
.axis .fill { background: #ededed; }

dialog { background: rgba(20,20,20,.7); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur); color: var(--text); border: 1px solid var(--line); border-radius: 24px; width: min(460px, calc(100vw - 32px)); padding: 22px; }
dialog::backdrop { background: rgba(0,0,0,.4); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
dialog h2 { margin: 0 0 12px; font-size: 16px; }
dialog label { display: block; margin-bottom: 10px; color: var(--dim); font-size: 12px; }
dialog label input, dialog label select, dialog label .row { margin-top: 3px; font-size: 14px; color: var(--text); }
.hint { color: var(--dim); font-size: 12px; margin: 0 0 8px; }
#side header .row { gap: 6px; }
/* 会话列表：盖在聊天上面 */
.sessions-btn { margin-left: -6px; }
.sessions-btn[aria-expanded="true"] { color: var(--text); background: rgba(255,255,255,.1); }
#sessions { position: absolute; z-index: 3; left: 0; right: 0; top: 57px; bottom: 0; display: flex; flex-direction: column; gap: 10px; padding: 14px; background: #0e0e0e; }
#sessions[hidden] { display: none; }
.sessions-head { display: grid; gap: 2px; padding: 0 4px; }
.sessions-head .hint { margin: 0; }
#sessionList { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; overflow-y: auto; align-content: start; flex: 1; min-height: 0; }
.session { display: flex; align-items: center; gap: 6px; padding: 9px 10px 9px 12px; border-radius: 14px; border: 1px solid transparent; cursor: pointer; }
.session:hover { background: rgba(255,255,255,.06); }
.session[aria-current="true"] { background: rgba(255,255,255,.1); border-color: var(--line); }
.session .who { flex: 1; min-width: 0; display: grid; gap: 1px; }
.session .who b { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session .who small { color: var(--dim); font-size: 11px; }
.session .tag { flex: none; padding: 0 7px; border: 1px solid var(--line); border-radius: 999px; font-size: 11px; color: var(--dim); }
.session .del { flex: none; width: 26px; height: 26px; padding: 0; font-size: 15px; background: none; border: 1px solid transparent; color: var(--dim); opacity: 0; }
.session:hover .del, .session .del:focus-visible { opacity: 1; }
.session .del:hover { color: #ff8a8a; border-color: rgba(255,138,138,.35); }
@media (pointer: coarse) { .session .del { opacity: .8; } }
.session .pause:hover { color: var(--text); border-color: var(--line); }
.session .pause.on { opacity: 1; color: var(--text); }
.session.paused .who { opacity: .5; }
.new-session { display: flex; gap: 6px; }
.new-session input { flex: 1; min-width: 0; }
.sessions-foot { margin: 0 4px !important; }
.own-api { margin: 4px 0 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.035); }
.own-api-row { display: flex !important; align-items: center; gap: 8px; margin: 0 !important; color: var(--text) !important; font-size: 13px !important; }
.own-api-row input { width: auto; margin: 0; }
.own-api .hint { margin: 4px 0 0; }
.pref { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.care { display: grid; grid-template-columns: 1fr 60px; align-items: center; gap: 8px; font-size: 12px; margin: 3px 0; }
.care span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.self-line { font-size: 12px; margin: 3px 0; line-height: 1.5; }
#stage.hide-regions .region-label { display: none; }
.region-label[role="button"] { pointer-events: auto; cursor: pointer; }
.region-label:hover { border-color: rgba(255,255,255,.6); }
.region-label.focused { background: #fff; color: #000; border-color: #fff; }
.pref b { font-size: 14px; font-weight: 600; }
.pref .hint { margin: 3px 0 0; }
.pref .button, .pref button { flex: none; }
button.danger { color: #ff8a8a; border-color: rgba(255,138,138,.35); }
#settingsStatus { min-height: 1.6em; margin: 0 0 8px; font-size: 13px; overflow-wrap: anywhere; }
#settingsStatus.bad { color: #fff; font-weight: 600; }

@media (max-width: 760px) {
  :root { --side: 12px; }
  #side { left: 8px; right: 8px; top: auto; bottom: 8px; width: auto; height: 48%; border-radius: 20px; }
  #stage { bottom: calc(48% + 8px); }
  #psyche { left: 12px; bottom: 62px; width: min(250px, calc(50% - 18px)); }
  #desk { left: auto; right: 12px; bottom: 62px; width: min(270px, calc(50% - 18px)); }
}

.fragment { padding: 6px 0; border-bottom: 1px solid var(--line); }
.fragment small { color: var(--dim); font-size: 11px; }
.fragment.stage-模糊 pre { color: #b5b5b5; }
.fragment.stage-印象 pre { color: var(--dim); }
.fragment details { margin-top: 4px; font-size: 12px; color: var(--dim); }
.fragment summary { cursor: pointer; }

.msg.proposal { align-self: stretch; max-width: none; background: rgba(255,255,255,.05); border: 1px solid var(--line); font-size: 13px; }
.proposal-why { margin: 2px 0 8px; white-space: pre-wrap; }
.proposal-edit { margin: 6px 0; }
.proposal-edit summary { cursor: pointer; color: var(--dim); font-family: ui-monospace, Consolas, monospace; }
.proposal-edit pre { margin: 4px 0 0; padding: 6px 8px; border-radius: 8px; font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 260px; overflow: auto; }
.diff-old { background: rgba(255,90,90,.12); color: #ffb3b3; }
.diff-new { background: rgba(90,220,140,.12); color: #b6f2c8; }
.proposal-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.proposal-status { color: var(--dim); font-size: 12px; }

#voicePick { flex: 1; min-width: 0; padding: 6px 10px; border-radius: 10px; background: rgba(255,255,255,.06); border: 1px solid var(--line); color: var(--text); }
#voicePick optgroup, #voicePick option { background: #1b1b1b; color: #eee; }
/* 设置：分组卡片 */
#prefs { width: min(660px, calc(100vw - 32px)); height: min(560px, calc(100vh - 48px)); padding: 0; overflow: hidden; }
.prefs-main { flex: 1; min-height: 0; display: flex; }
.prefs-nav { flex: none; width: 128px; display: flex; flex-direction: column; gap: 2px; padding: 4px 10px 16px 14px; }
.prefs-nav button { justify-content: flex-start; text-align: left; padding: 7px 12px; border-radius: 10px; background: none; border: 1px solid transparent; color: var(--dim); font-size: 13px; }
.prefs-nav button:hover { color: var(--text); background: rgba(255,255,255,.06); }
.prefs-nav button[aria-selected="true"] { color: var(--text); background: rgba(255,255,255,.1); border-color: var(--line); }
.prefs-page { display: grid; gap: 16px; align-content: start; }
.prefs-page[hidden] { display: none; }
#prefs[open] { display: flex; flex-direction: column; }
.prefs-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 10px 22px; }
.prefs-head h2 { margin: 0; }
.icon-btn { width: 30px; height: 30px; padding: 0; display: grid; place-items: center; font-size: 18px; line-height: 1; background: none; color: var(--dim); border: 1px solid transparent; }
.icon-btn:hover { color: var(--text); background: rgba(255,255,255,.1); }
.prefs-body { flex: 1; min-width: 0; overflow-y: auto; overflow-x: hidden; padding: 4px 22px 22px 8px; }
.pref-group h3 { margin: 0 0 6px 4px; font-size: 11px; font-weight: 500; letter-spacing: .08em; color: var(--dim); }
.pref-card { background: rgba(255,255,255,.035); border: 1px solid var(--line); border-radius: 16px; padding: 0 14px; }
.pref-card .pref:last-child { border-bottom: 0; }
.pref-text { flex: 1; min-width: 0; }
.pref-actions { flex: none; display: flex; gap: 6px; }
.pref-card .pref.compact { padding: 9px 0; }
.skill-empty { padding: 12px 0; margin: 0; }
.group-foot { margin: 6px 4px 0 !important; }
.danger-card { border-color: rgba(255,138,138,.22); background: rgba(255,90,90,.04); }
.voice-row { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
.voice-foot { margin-top: 6px !important; }
#voiceNote:not(:empty)::before { content: ' · '; }
#voiceNote, #nameNote { color: var(--text); }
#nameNote:not(:empty)::before { content: ' · '; }
#nameInput { flex: 1; min-width: 0; padding: 6px 10px; border-radius: 10px; }
#herName { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 12em; }
/* 开关 */
.switch { position: relative; flex: none; width: 44px; height: 26px; padding: 0; border-radius: 999px; font-size: 0; background: rgba(255,255,255,.12); border: 1px solid var(--line); transition: background .15s, border-color .15s; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #bbb; transition: transform .15s, background .15s; }
.switch[aria-pressed="true"], .switch[aria-checked="true"] { background: #ededed; border-color: #ededed; }
.switch[aria-pressed="true"]::after, .switch[aria-checked="true"]::after { transform: translateX(18px); background: #111; }
@media (max-width: 480px) {
  #prefs { height: min(640px, calc(100vh - 32px)); }
  .prefs-main { flex-direction: column; }
  .prefs-nav { width: auto; flex-direction: row; overflow-x: auto; padding: 0 14px 10px; }
  .prefs-nav button { flex: none; text-align: center; }
  .prefs-body { padding: 0 14px 16px; }
  .pref { flex-wrap: wrap; gap: 10px; }
  .pref:has(.pref-actions) .pref-text { flex-basis: 100%; }
  .pref-actions { margin-left: auto; }
  .voice-row { flex-wrap: wrap; }
  #voicePick { flex-basis: 100%; }
  .voice-row button { flex: 1; }
}

/* 拍片模式：只留画面 */
body.film #side, body.film #stage > :not(#scene) { display: none !important; }
#chem .meter { grid-template-columns: 84px 1fr 34px; }
/* 直播设置 */
.live-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.live-fields label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--dim); }
.voice-row a.button { text-decoration: none; }
@media (max-width: 640px) { .live-fields { grid-template-columns: 1fr; } }
.prompt-input { display: block; margin-top: 10px; min-height: 120px; resize: vertical; font: inherit; font-size: 13px; line-height: 1.5; color: var(--text); }
.live-seen { white-space: pre-line; max-height: 7.5em; overflow: hidden; }

/* 框弹幕区域 */
.live-read { white-space: pre-wrap; max-height: 9em; overflow: auto; margin: 6px 0 0; font-size: 12px; }
.pick-overlay { position: fixed; inset: 0; z-index: 1000; background: rgba(0,0,0,.85); display: flex; flex-direction: column; }
.pick-overlay[hidden] { display: none; }
.pick-bar { display: flex; gap: 8px; align-items: center; padding: 10px 16px; color: #fff; font-size: 14px; }
.pick-bar span { flex: 1; }
.pick-stage { position: relative; flex: 1; margin: 0 16px 16px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.pick-stage img { max-width: 100%; max-height: 100%; user-select: none; -webkit-user-drag: none; cursor: crosshair; display: block; }
.pick-box { position: absolute; border: 2px solid #ff4d6d; background: rgba(255,77,109,.15); pointer-events: none; }
