/* ══════════════════════════════════════════════════════════════
   Bonsai Studio — 一份安静的读写界面
   ══════════════════════════════════════════════════════════════ */

:root {
  --bg:        #FAF8F5;
  --bg-elev:   #FFFFFF;
  --ink:       #1B1A17;
  --ink-2:     #56534C;
  --ink-3:     #928D83;
  --line:      #E7E2D9;
  --line-2:    #D6CEC1;
  --accent:    #2F4A3E;
  --accent-2:  #3E6455;
  --wash:      #EDF1EE;
  --user-bg:   #F1EDE5;
  --code-bg:   #F4F1EA;
  --warn:      #9A4A2E;
  --shadow:    0 1px 2px rgba(40, 34, 24, .05), 0 8px 24px -16px rgba(40, 34, 24, .18);

  --sans: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --serif: Georgia, "Times New Roman", "Songti SC", "Source Han Serif SC", "Noto Serif CJK SC", "SimSun", serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Cascadia Mono", "Courier New", monospace;

  --ui: var(--sans);
  --prose: var(--sans);
  --scale: 1;
  --measure: 46rem;
}

[data-theme="night"] {
  --bg:        #161513;
  --bg-elev:   #1C1B18;
  --ink:       #EAE5DB;
  --ink-2:     #ABA69A;
  --ink-3:     #77726A;
  --line:      #2C2A25;
  --line-2:    #3B3831;
  --accent:    #83AA98;
  --accent-2:  #A3C4B4;
  --wash:      #212A26;
  --user-bg:   #232119;
  --code-bg:   #1F1D1A;
  --warn:      #C4754F;
  --shadow:    0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -16px rgba(0, 0, 0, .6);
}

[data-font="serif"] { --prose: var(--serif); }

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--ui);
  font-size: calc(15px * var(--scale));
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

/* 极淡的纸纹，只在肉眼几乎不可察的强度 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: .035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}
[data-theme="night"] body::before { opacity: .05; }

::selection { background: var(--wash); color: var(--ink); }

/* 细滚动条 */
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 9px; border: 3px solid var(--bg); }
*::-webkit-scrollbar-thumb:hover { background: var(--ink-3); }

.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: calc(276px * var(--scale)) 1fr;
  height: 100%;
}

/* ───────────────────────────── 侧栏 ───────────────────────────── */

.sidebar {
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  border-right: 1px solid var(--line);
  min-height: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: calc(10px * var(--scale));
  padding: calc(24px * var(--scale)) calc(20px * var(--scale)) calc(18px * var(--scale));
}
.mark { width: 27px; height: 27px; color: var(--accent); flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-size: calc(13.5px * var(--scale)); font-weight: 650; letter-spacing: .2em; color: var(--ink); }
.brand-sub  { font-size: calc(9px * var(--scale)); letter-spacing: .32em; color: var(--ink-3); margin-top: 3px; }

.new-chat {
  display: flex;
  align-items: center;
  gap: calc(9px * var(--scale));
  margin: 0 calc(14px * var(--scale)) calc(16px * var(--scale));
  padding: calc(10px * var(--scale)) calc(13px * var(--scale));
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg);
  color: var(--ink-2);
  font: inherit;
  font-size: calc(13.5px * var(--scale));
  cursor: pointer;
  transition: background .16s, color .16s, border-color .16s;
}
.new-chat svg { width: 14px; height: 14px; color: var(--ink-3); }
.new-chat:hover { background: var(--wash); border-color: var(--accent); color: var(--accent); }
.new-chat:hover svg { color: var(--accent); }

.threads {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 calc(10px * var(--scale)) calc(12px * var(--scale));
}
.thread {
  position: relative;
  padding: calc(9px * var(--scale)) calc(12px * var(--scale));
  border-radius: 8px;
  cursor: pointer;
  color: var(--ink-2);
  font-size: calc(13.5px * var(--scale));
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background .14s, color .14s;
}
.thread:hover { background: var(--bg); }
.thread.active { background: var(--wash); color: var(--ink); font-weight: 550; }
.thread.active::before {
  content: "";
  position: absolute; left: 0; top: 50%;
  transform: translateY(-50%);
  width: calc(2px * var(--scale)); height: calc(17px * var(--scale));
  background: var(--accent);
  border-radius: 2px;
}
.thread .t-meta {
  display: block;
  font-size: calc(11px * var(--scale));
  color: var(--ink-3);
  font-weight: 400;
  margin-top: calc(2px * var(--scale));
}

.side-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: calc(8px * var(--scale));
  padding: calc(13px * var(--scale)) calc(16px * var(--scale));
  border-top: 1px solid var(--line);
}
.status { display: flex; align-items: center; gap: 7px; font-size: calc(12.5px * var(--scale)); color: var(--ink-3); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-3); flex: none; transition: background .2s; }
.status.on  .dot { background: #4E8A6B; box-shadow: 0 0 0 3px rgba(78, 138, 107, .16); }
.status.off .dot { background: var(--warn); box-shadow: 0 0 0 3px rgba(154, 74, 46, .14); }
.status.load .dot { background: var(--ink-3); animation: breathe 1.1s ease-in-out infinite; }
@keyframes breathe { 0%,100% { opacity: .3; } 50% { opacity: 1; } }

.gear {
  display: grid; place-items: center;
  width: calc(32px * var(--scale)); height: calc(32px * var(--scale));
  border: 0; border-radius: 8px;
  background: transparent; color: var(--ink-3);
  cursor: pointer; transition: background .15s, color .15s;
}
.gear svg { width: calc(16px * var(--scale)); height: calc(16px * var(--scale)); }
.gear:hover { background: var(--bg); color: var(--ink); }

/* ───────────────────────────── 主区 ───────────────────────────── */

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: calc(14px * var(--scale));
  height: calc(58px * var(--scale));
  padding: 0 calc(30px * var(--scale));
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  flex: none;
}
.topbar-title {
  font-size: calc(14.5px * var(--scale));
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-right { display: flex; align-items: center; gap: calc(10px * var(--scale)); flex: none; }

.chip {
  padding: calc(4px * var(--scale)) calc(10px * var(--scale));
  border: 1px solid var(--line);
  border-radius: 20px;
  font-size: calc(12px * var(--scale));
  color: var(--ink-3);
  background: var(--bg-elev);
  white-space: nowrap;
  max-width: calc(260px * var(--scale));
  overflow: hidden;
  text-overflow: ellipsis;
}
#chipSpeed { font-family: var(--mono); letter-spacing: -.01em; }
#chipSpeed.live { border-color: var(--accent); color: var(--accent); }

/* 实时速度迷你曲线 */
.spark {
  display: block;
  width: calc(96px * var(--scale));
  height: calc(28px * var(--scale));
  opacity: 0;
  transition: opacity .3s;
}
.spark.show { opacity: 1; }

.icon-btn {
  display: grid; place-items: center;
  width: calc(30px * var(--scale)); height: calc(30px * var(--scale));
  border: 0; border-radius: 7px;
  background: transparent; color: var(--ink-3);
  cursor: pointer; transition: background .15s, color .15s;
}
.icon-btn svg { width: calc(15px * var(--scale)); height: calc(15px * var(--scale)); }
.icon-btn:hover { background: var(--bg-elev); color: var(--ink); }

/* ── 消息流 ── */

.stream {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: calc(36px * var(--scale)) calc(30px * var(--scale)) calc(20px * var(--scale));
  scroll-behavior: smooth;
}
.stream-inner { max-width: var(--measure); margin: 0 auto; }

.empty { max-width: var(--measure); margin: 0 auto; padding-top: 8vh; }
.empty-rule { width: 48px; height: 1px; background: var(--line-2); margin-bottom: 28px; }
.empty h1 {
  margin: 0 0 calc(12px * var(--scale));
  font-family: var(--prose);
  font-size: calc(31px * var(--scale));
  font-weight: 500;
  letter-spacing: -.012em;
  color: var(--ink);
}
.empty-hint { margin: 0; font-size: calc(14px * var(--scale)); color: var(--ink-3); line-height: 1.75; }

.turn { position: relative; margin-bottom: calc(36px * var(--scale)); animation: rise .26s cubic-bezier(.22,.61,.36,1); }
@keyframes rise { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

.who {
  display: flex;
  align-items: center;
  gap: calc(8px * var(--scale));
  font-size: calc(10.5px * var(--scale));
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: calc(10px * var(--scale));
}
.who::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.turn.user .who { flex-direction: row-reverse; }
.turn.user .who::after { display: none; }
.turn.user .who::before { content: ""; flex: 1; height: 1px; background: var(--line); }

/* 悬浮操作 */
.turn-actions {
  position: absolute;
  right: 0; top: calc(-1px * var(--scale));
  display: flex; gap: calc(2px * var(--scale));
  opacity: 0; transition: opacity .16s;
}
.turn:hover .turn-actions { opacity: 1; }
.turn-actions button {
  border: 0; background: transparent; cursor: pointer;
  color: var(--ink-3); font: inherit;
  font-size: calc(10.5px * var(--scale)); letter-spacing: .1em;
  padding: calc(2px * var(--scale)) calc(7px * var(--scale)); border-radius: 5px;
}
.turn-actions button:hover { background: var(--bg-elev); color: var(--ink); }

.turn.user .body {
  display: block;
  margin-left: auto;
  max-width: 82%;
  padding: calc(12px * var(--scale)) calc(16px * var(--scale));
  background: var(--user-bg);
  border-radius: 15px 15px 4px 15px;
  font-size: calc(16.5px * var(--scale));
  line-height: 1.68;
  white-space: pre-wrap;
  word-break: break-word;
}

.prose {
  font-family: var(--prose);
  font-size: calc(17.5px * var(--scale));
  line-height: 1.8;
  color: var(--ink);
  word-wrap: break-word;
}
.prose > *:first-child { margin-top: 0; }
.prose > *:last-child { margin-bottom: 0; }
.prose p { margin: 0 0 1.05em; }
.prose h1, .prose h2, .prose h3, .prose h4 {
  font-family: var(--ui);
  font-weight: 600;
  line-height: 1.35;
  margin: 1.55em 0 .65em;
  letter-spacing: -.005em;
}
.prose h1 { font-size: 1.32em; }
.prose h2 { font-size: 1.17em; }
.prose h3 { font-size: 1.05em; }
.prose h4 { font-size: 1em; color: var(--ink-2); }
.prose ul, .prose ol { margin: 0 0 1.05em; padding-left: 1.4em; }
.prose li { margin: .3em 0; }
.prose li::marker { color: var(--ink-3); }
.prose blockquote {
  margin: 1.1em 0;
  padding: .1em 0 .1em 1.1em;
  border-left: 2px solid var(--line-2);
  color: var(--ink-2);
  font-style: italic;
}
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 1.9em 0; }
.prose a { color: var(--accent); text-decoration: none; border-bottom: 1px solid var(--line-2); }
.prose a:hover { border-bottom-color: var(--accent); }
.prose code {
  font-family: var(--mono);
  font-size: .855em;
  background: var(--code-bg);
  border: 1px solid var(--line);
  padding: .1em .35em;
  border-radius: 4px;
}
.prose table { border-collapse: collapse; margin: 1.1em 0; font-size: .93em; width: 100%; }
.prose th, .prose td { border: 1px solid var(--line); padding: .5em .75em; }
.prose th { background: var(--code-bg); font-weight: 600; text-align: left; }

.codeblock {
  margin: 1.2em 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--code-bg);
  overflow: hidden;
}
.codeblock .cb-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(7px * var(--scale)) calc(10px * var(--scale)) calc(7px * var(--scale)) calc(14px * var(--scale));
  border-bottom: 1px solid var(--line);
  font-family: var(--ui);
  font-size: calc(11px * var(--scale));
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.codeblock .cb-copy {
  border: 0; background: transparent; cursor: pointer;
  color: var(--ink-3); font: inherit; font-size: calc(11px * var(--scale));
  padding: calc(3px * var(--scale)) calc(7px * var(--scale)); border-radius: 5px;
}
.codeblock .cb-copy:hover { background: var(--bg-elev); color: var(--ink); }
.codeblock pre {
  margin: 0; padding: calc(13px * var(--scale)) calc(15px * var(--scale));
  overflow-x: auto;
  font-family: var(--mono);
  font-size: calc(13.5px * var(--scale));
  line-height: 1.62;
}
.codeblock pre code { background: none; border: 0; padding: 0; font-size: inherit; }

.think {
  margin: 0 0 calc(15px * var(--scale));
  border-left: 2px solid var(--line-2);
  padding: calc(2px * var(--scale)) 0 calc(2px * var(--scale)) calc(14px * var(--scale));
}
.think summary {
  cursor: pointer;
  font-size: calc(11.5px * var(--scale));
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-3);
  list-style: none;
}
.think summary::-webkit-details-marker { display: none; }
.think summary::before { content: "▸ "; }
.think[open] summary::before { content: "▾ "; }
.think .think-body {
  margin-top: calc(9px * var(--scale));
  font-size: calc(14.5px * var(--scale));
  line-height: 1.72;
  color: var(--ink-3);
  white-space: pre-wrap;
}

.typing { display: inline-flex; gap: calc(4px * var(--scale)); padding: calc(4px * var(--scale)) 0; }
.typing i { width: 5px; height: 5px; border-radius: 50%; background: var(--ink-3); animation: blink 1.05s ease-in-out infinite; }
.typing i:nth-child(2) { animation-delay: .16s; }
.typing i:nth-child(3) { animation-delay: .32s; }
@keyframes blink { 0%, 100% { opacity: .22; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-2px); } }

.caret {
  display: inline-block;
  width: calc(2px * var(--scale)); height: 1.05em;
  vertical-align: -.18em;
  margin-left: calc(2px * var(--scale));
  background: var(--accent);
  animation: blink .9s steps(2) infinite;
}

.turn-err {
  padding: calc(11px * var(--scale)) calc(14px * var(--scale));
  border: 1px solid var(--warn);
  border-radius: 9px;
  color: var(--warn);
  font-size: calc(14px * var(--scale));
  background: transparent;
}

/* ── 输入区 ── */

.composer-wrap {
  flex: none;
  padding: 0 calc(30px * var(--scale)) calc(15px * var(--scale));
  background: linear-gradient(to bottom, transparent, var(--bg) 32%);
}
.composer {
  max-width: var(--measure);
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--bg-elev);
  box-shadow: var(--shadow);
  transition: border-color .18s, box-shadow .18s;
}
.composer:focus-within { border-color: var(--accent); }

#input {
  display: block;
  width: 100%;
  border: 0;
  outline: 0;
  resize: none;
  padding: calc(15px * var(--scale)) calc(17px * var(--scale)) calc(6px * var(--scale));
  background: transparent;
  color: var(--ink);
  font-family: var(--prose);
  font-size: calc(17px * var(--scale));
  line-height: 1.7;
  max-height: calc(240px * var(--scale));
  overflow-y: auto;
}
#input::placeholder { color: var(--ink-3); }

.composer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: calc(12px * var(--scale));
  padding: calc(4px * var(--scale)) calc(10px * var(--scale)) calc(9px * var(--scale)) calc(15px * var(--scale));
}
.composer-left, .composer-right { display: flex; align-items: center; gap: calc(12px * var(--scale)); }

.mini-toggle {
  display: inline-flex; align-items: center; gap: calc(6px * var(--scale));
  font-size: calc(12.5px * var(--scale)); color: var(--ink-3); cursor: pointer;
  user-select: none;
}
.mini-toggle input { accent-color: var(--accent); margin: 0; width: 14px; height: 14px; }
.mini-toggle:hover { color: var(--ink-2); }
.mini-hint { font-size: calc(11.5px * var(--scale)); color: var(--ink-3); font-family: var(--mono); }

.ghost-btn {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-2);
  font: inherit; font-size: calc(13px * var(--scale));
  padding: calc(6px * var(--scale)) calc(13px * var(--scale)); border-radius: 8px; cursor: pointer;
}
.ghost-btn:hover { border-color: var(--warn); color: var(--warn); }

.send {
  display: grid; place-items: center;
  width: calc(36px * var(--scale)); height: calc(36px * var(--scale));
  border: 0; border-radius: 11px;
  background: var(--accent);
  color: var(--bg-elev);
  cursor: pointer;
  transition: opacity .15s, transform .12s, background .15s;
}
.send svg { width: calc(16px * var(--scale)); height: calc(16px * var(--scale)); }
.send:hover { background: var(--accent-2); }
.send:active { transform: scale(.94); }
.send:disabled { opacity: .28; cursor: default; }

.foot-note {
  max-width: var(--measure);
  margin: calc(9px * var(--scale)) auto 0;
  font-size: calc(11.5px * var(--scale));
  color: var(--ink-3);
  letter-spacing: .04em;
}

/* ───────────────────────────── 设置抽屉 ───────────────────────────── */

.scrim {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(24, 21, 16, .26);
  opacity: 0; pointer-events: none;
  transition: opacity .24s;
}
.scrim.show { opacity: 1; pointer-events: auto; }

.panel {
  position: fixed; top: 0; right: 0; bottom: 0;
  z-index: 50;
  width: calc(404px * var(--scale));
  max-width: 92vw;
  display: flex; flex-direction: column;
  background: var(--bg-elev);
  border-left: 1px solid var(--line);
  transform: translateX(101%);
  transition: transform .28s cubic-bezier(.22,.61,.36,1);
}
.panel.show { transform: none; }

.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(20px * var(--scale)) calc(22px * var(--scale)) calc(15px * var(--scale));
  border-bottom: 1px solid var(--line);
  flex: none;
}
.panel-head h2 { margin: 0; font-size: calc(15px * var(--scale)); font-weight: 600; letter-spacing: .02em; }

.panel-body { flex: 1; overflow-y: auto; padding: calc(6px * var(--scale)) calc(22px * var(--scale)) calc(44px * var(--scale)); }

.grp { padding: 19px 0; border-bottom: 1px solid var(--line); }
.grp:last-child { border-bottom: 0; }
.grp-title {
  font-size: calc(10.5px * var(--scale)); letter-spacing: .22em; text-transform: uppercase;
  color: var(--ink-3); margin-bottom: 15px;
}

.row { margin-bottom: calc(16px * var(--scale)); }
.row.split { display: grid; grid-template-columns: 1fr 1fr; gap: calc(12px * var(--scale)); }
.row-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: calc(7px * var(--scale));
  font-size: calc(13.5px * var(--scale)); color: var(--ink-2);
}
.val { font-family: var(--mono); font-size: calc(12.5px * var(--scale)); color: var(--ink-3); }

input[type="text"], input[type="number"], select, textarea {
  width: 100%;
  padding: calc(9px * var(--scale)) calc(11px * var(--scale));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
  font: inherit; font-size: calc(14px * var(--scale));
  outline: 0;
  transition: border-color .15s;
}
textarea { resize: vertical; line-height: 1.65; font-family: var(--prose); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
select { cursor: pointer; }

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: calc(20px * var(--scale)); background: transparent; cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 3px; background: var(--line); border-radius: 3px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: calc(15px * var(--scale)); height: calc(15px * var(--scale)); margin-top: calc(-6px * var(--scale));
  border-radius: 50%; background: var(--accent);
  border: 2px solid var(--bg-elev);
  box-shadow: 0 1px 3px rgba(0,0,0,.18);
}
input[type="range"]::-moz-range-track { height: 3px; background: var(--line); border-radius: 3px; }
input[type="range"]::-moz-range-thumb {
  width: calc(13px * var(--scale)); height: calc(13px * var(--scale)); border-radius: 50%;
  background: var(--accent); border: 2px solid var(--bg-elev);
}

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button {
  padding: calc(7px * var(--scale)) calc(15px * var(--scale));
  border: 0; background: transparent;
  color: var(--ink-3);
  font: inherit; font-size: calc(13.5px * var(--scale));
  cursor: pointer;
  transition: background .14s, color .14s;
}
.seg button + button { border-left: 1px solid var(--line); }
.seg button:hover { color: var(--ink-2); }
.seg button.on { background: var(--wash); color: var(--accent); font-weight: 550; }

.btn-line { display: flex; flex-wrap: wrap; gap: calc(8px * var(--scale)); margin-top: calc(4px * var(--scale)); }
.btn-line button {
  padding: calc(8px * var(--scale)) calc(15px * var(--scale));
  border-radius: 8px;
  font: inherit; font-size: calc(13.5px * var(--scale));
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.btn-line .solid { border: 1px solid var(--accent); background: var(--accent); color: var(--bg-elev); }
.btn-line .solid:hover { background: var(--accent-2); }
.btn-line .line { border: 1px solid var(--line); background: transparent; color: var(--ink-2); }
.btn-line .line:hover { border-color: var(--ink-3); color: var(--ink); }
.btn-line .danger:hover { border-color: var(--warn); color: var(--warn); }

/* ── 速度图表 ── */

.chart-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  padding: calc(11px * var(--scale)) calc(12px * var(--scale)) calc(10px * var(--scale));
  margin-top: calc(4px * var(--scale));
}
.chart-card canvas { display: block; width: 100%; height: calc(128px * var(--scale)); }

.chart-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: calc(10px * var(--scale));
  margin-top: calc(11px * var(--scale));
}
.chart-stats div { min-width: 0; }
.chart-stats dt {
  font-size: calc(10px * var(--scale)); letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-3); margin: 0 0 3px;
}
.chart-stats dd {
  margin: 0;
  font-family: var(--mono);
  font-size: calc(13.5px * var(--scale));
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chart-stats dd small { color: var(--ink-3); font-size: calc(10.5px * var(--scale)); }

.hist {
  display: flex;
  align-items: flex-end;
  gap: calc(3px * var(--scale));
  height: calc(46px * var(--scale));
  margin-top: calc(12px * var(--scale));
  padding-top: calc(4px * var(--scale));
  border-top: 1px solid var(--line);
}
.hist i {
  flex: 1 1 0;
  min-width: calc(3px * var(--scale));
  max-width: calc(18px * var(--scale));
  background: var(--line-2);
  border-radius: 2px 2px 0 0;
  transition: height .3s ease, background .3s;
}
.hist i.cur { background: var(--accent); }

.logbox {
  margin: calc(12px * var(--scale)) 0 0;
  max-height: calc(148px * var(--scale));
  overflow: auto;
  padding: calc(10px * var(--scale)) calc(12px * var(--scale));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink-3);
  font-family: var(--mono);
  font-size: calc(11.5px * var(--scale));
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

.note { margin: 11px 0 0; font-size: calc(12.5px * var(--scale)); color: var(--ink-3); line-height: 1.65; }

/* ── 回到最新 ─────────────────────────────────────────────── */
.to-bottom {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--composer-h, 150px) + 18px);
  display: inline-flex;
  align-items: center;
  gap: calc(6px * var(--scale));
  padding: calc(7px * var(--scale)) calc(14px * var(--scale)) calc(7px * var(--scale)) calc(12px * var(--scale));
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-elev);
  color: var(--ink-2);
  font-family: var(--ui);
  font-size: calc(12.5px * var(--scale));
  letter-spacing: .02em;
  cursor: pointer;
  box-shadow: 0 4px 16px -8px rgba(0, 0, 0, .28);
  opacity: 0;
  transition: opacity .18s, transform .18s, background .16s, border-color .16s;
  z-index: 6;
}
.to-bottom[hidden] { display: none; }
.to-bottom.show { opacity: 1; }
.to-bottom:hover { background: var(--bg); border-color: var(--ink-3); color: var(--ink); transform: translateX(-50%) translateY(-1px); }
.to-bottom svg { width: calc(13px * var(--scale)); height: calc(13px * var(--scale)); }

/* ── 设置项锁 ─────────────────────────────────────────────── */
[data-lock] { position: relative; }

.veil {
  position: absolute;
  inset: calc(-2px * var(--scale));
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: calc(5px * var(--scale));
  padding: 0 calc(9px * var(--scale));
  border-radius: 9px;
  background: color-mix(in srgb, var(--bg-elev) 62%, transparent);
  cursor: pointer;
  font-size: calc(11.5px * var(--scale));
  letter-spacing: .01em;
  color: var(--ink-3);
  user-select: none;
  transition: background .16s, color .16s;
}
.veil.center { justify-content: center; padding: 0; }
.veil:hover {
  background: color-mix(in srgb, var(--bg-elev) 82%, transparent);
  color: var(--ink-2);
}
.veil svg { width: calc(12.5px * var(--scale)); height: calc(12.5px * var(--scale)); opacity: .85; flex: none; }
.veil span { white-space: nowrap; }

/* 思考开关：遮罩贴合小控件 */
.mini-toggle .veil { inset: calc(-3px * var(--scale)) calc(-6px * var(--scale)); border-radius: 12px; }
/* 按钮上的遮罩 */
button[data-lock] .veil { border-radius: inherit; }

/* ── 模型锁 ───────────────────────────────────────────────── */
.lock-scrim {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(24px * var(--scale));
  background: rgba(24, 22, 19, .34);
  backdrop-filter: blur(3px);
  animation: lockIn .16s ease-out;
}
.lock-scrim[hidden] { display: none; }
@keyframes lockIn { from { opacity: 0; } to { opacity: 1; } }

.lock-card {
  width: 100%;
  max-width: calc(340px * var(--scale));
  padding: calc(26px * var(--scale)) calc(26px * var(--scale)) calc(22px * var(--scale));
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--bg-elev);
  box-shadow: 0 24px 60px -24px rgba(0, 0, 0, .45);
  text-align: center;
  animation: lockUp .18s cubic-bezier(.2, .9, .3, 1);
}
@keyframes lockUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.lock-icon {
  width: calc(40px * var(--scale)); height: calc(40px * var(--scale));
  margin: 0 auto calc(14px * var(--scale));
  display: grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink-2);
  background: var(--bg);
}
.lock-icon svg { width: calc(21px * var(--scale)); height: calc(21px * var(--scale)); }

.lock-card h3 {
  margin: 0 0 calc(5px * var(--scale));
  font-family: var(--prose);
  font-size: calc(17px * var(--scale));
  font-weight: 600;
  letter-spacing: .01em;
  color: var(--ink);
}
.lock-sub {
  margin: 0 0 calc(18px * var(--scale));
  font-size: calc(12.5px * var(--scale));
  color: var(--ink-3);
  line-height: 1.6;
  word-break: break-all;
}
.lock-card input {
  width: 100%;
  padding: calc(10px * var(--scale)) calc(13px * var(--scale));
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--ui);
  font-size: calc(14px * var(--scale));
  letter-spacing: .12em;
  text-align: center;
  outline: none;
  transition: border-color .16s, box-shadow .16s;
}
.lock-card input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent);
}
.lock-card input.bad { border-color: #B4544E; animation: lockShake .3s; }
@keyframes lockShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.lock-err {
  margin: calc(9px * var(--scale)) 0 0;
  font-size: calc(12px * var(--scale));
  color: #B4544E;
  min-height: 1em;
}
.lock-err[hidden] { display: none; }

.lock-btns {
  display: flex;
  gap: calc(9px * var(--scale));
  margin-top: calc(18px * var(--scale));
}
.lock-btns button { flex: 1; padding: calc(9px * var(--scale)) 0; }

/* 下拉里锁定的项 */
select option.locked { color: var(--ink-3); }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: calc(276px * var(--scale)); z-index: 30; transform: translateX(-100%); transition: transform .26s; }
  .sidebar.show { transform: none; }
}

/* ══════════════════════════════════════════════════════════════
   账号 / 登录门
   ══════════════════════════════════════════════════════════════ */

.auth {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(24px * var(--scale));
  background: var(--bg);
  overflow-y: auto;
}
.auth[hidden] { display: none; }

.auth-card {
  width: 100%;
  max-width: calc(372px * var(--scale));
  padding: calc(30px * var(--scale)) calc(30px * var(--scale)) calc(24px * var(--scale));
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--bg-elev);
  box-shadow: var(--shadow);
  animation: lockUp .22s cubic-bezier(.2, .9, .3, 1);
}

.auth-brand { display: flex; align-items: center; gap: calc(11px * var(--scale)); margin-bottom: calc(22px * var(--scale)); }
.auth-brand .mark { width: 30px; height: 30px; color: var(--accent); flex: none; }
.auth-brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.auth-brand-text b { font-size: calc(13px * var(--scale)); font-weight: 650; letter-spacing: .2em; color: var(--ink); }
.auth-brand-text i { font-style: normal; font-size: calc(11px * var(--scale)); color: var(--ink-3); margin-top: 3px; letter-spacing: .06em; }

.auth-tabs {
  display: flex;
  gap: calc(4px * var(--scale));
  padding: calc(3px * var(--scale));
  margin-bottom: calc(20px * var(--scale));
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--bg);
}
.auth-tabs button {
  flex: 1;
  padding: calc(8px * var(--scale)) 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-3);
  font-family: var(--ui);
  font-size: calc(13px * var(--scale));
  cursor: pointer;
  transition: color .15s, background .15s;
}
.auth-tabs button.on { background: var(--bg-elev); color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(40,34,24,.08); }
.auth-tabs button:disabled { opacity: .45; cursor: not-allowed; }

.auth-field { display: block; margin: 0 0 calc(14px * var(--scale)); }
.auth-field span {
  display: block;
  margin-bottom: calc(6px * var(--scale));
  font-size: calc(11.5px * var(--scale));
  letter-spacing: .05em;
  color: var(--ink-3);
}
.auth-field input, .auth-field textarea, .persona-sel, .adm-role {
  width: 100%;
  padding: calc(9px * var(--scale)) calc(12px * var(--scale));
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--ui);
  font-size: calc(14px * var(--scale));
  outline: none;
  transition: border-color .16s, box-shadow .16s;
}
.auth-field textarea { resize: vertical; line-height: 1.6; font-size: calc(13.5px * var(--scale)); }
.auth-field input:focus, .auth-field textarea:focus, .persona-sel:focus, .adm-role:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent);
}

.auth-go {
  width: 100%;
  margin-top: calc(4px * var(--scale));
  padding: calc(10px * var(--scale)) 0;
  border: 1px solid var(--accent);
  border-radius: 11px;
  background: var(--accent);
  color: var(--bg-elev);
  font-family: var(--ui);
  font-size: calc(14px * var(--scale));
  font-weight: 600;
  letter-spacing: .04em;
  cursor: pointer;
  transition: background .15s;
}
.auth-go:hover { background: var(--accent-2); }
.auth-go:disabled { opacity: .6; cursor: wait; }

.auth-err {
  margin: 0 0 calc(12px * var(--scale));
  padding: calc(8px * var(--scale)) calc(11px * var(--scale));
  border: 1px solid color-mix(in srgb, #B4544E 38%, transparent);
  border-radius: 9px;
  background: color-mix(in srgb, #B4544E 8%, transparent);
  font-size: calc(12.5px * var(--scale));
  line-height: 1.55;
  color: #B4544E;
  white-space: pre-line;
}
.auth-err[hidden] { display: none; }
.auth-err.bad { color: #B4544E; }
.auth-err:not(.bad):not([hidden]) { border-color: var(--line); background: var(--wash); color: var(--ink-2); }

.auth-note { margin: 0 0 12px; font-size: calc(12px * var(--scale)); color: var(--ink-3); line-height: 1.6; }

.auth-ban {
  margin-top: calc(16px * var(--scale));
  padding: calc(13px * var(--scale)) calc(15px * var(--scale));
  border: 1px solid color-mix(in srgb, var(--warn) 42%, transparent);
  border-radius: 12px;
  background: color-mix(in srgb, var(--warn) 7%, transparent);
}
.auth-ban[hidden] { display: none; }
.auth-ban b { display: block; margin-bottom: 6px; font-size: calc(13.5px * var(--scale)); color: var(--warn); }
.auth-ban p { margin: 0 0 10px; font-size: calc(12.5px * var(--scale)); line-height: 1.65; color: var(--ink-2); white-space: pre-line; }
.auth-ban button { padding: calc(6px * var(--scale)) calc(14px * var(--scale)); }

.auth-links { display: flex; justify-content: center; margin-top: calc(16px * var(--scale)); }
.auth-links button {
  border: 0;
  background: transparent;
  color: var(--ink-3);
  font-size: calc(12px * var(--scale));
  letter-spacing: .03em;
  cursor: pointer;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}
.auth-links button:hover { color: var(--ink-2); }

/* ══════════════════════════════════════════════════════════════
   通用弹窗
   ══════════════════════════════════════════════════════════════ */

.modal-scrim {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(24px * var(--scale));
  background: rgba(24, 22, 19, .38);
  backdrop-filter: blur(3px);
  animation: lockIn .16s ease-out;
}
.modal-scrim[hidden] { display: none; }

.modal-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: calc(400px * var(--scale));
  max-height: calc(100vh - calc(48px * var(--scale)));
  padding: calc(22px * var(--scale)) calc(24px * var(--scale)) calc(20px * var(--scale));
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--bg-elev);
  box-shadow: 0 24px 60px -24px rgba(0, 0, 0, .45);
  animation: lockUp .18s cubic-bezier(.2, .9, .3, 1);
}
.modal-card.wide { max-width: calc(720px * var(--scale)); }
.modal-card.tall { max-height: calc(100vh - calc(64px * var(--scale))); }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: calc(16px * var(--scale));
}
.modal-head h3 { margin: 0; font-size: calc(16px * var(--scale)); font-weight: 650; letter-spacing: .02em; color: var(--ink); }
.modal-text { margin: 4px 0 6px; font-size: calc(13.5px * var(--scale)); line-height: 1.75; color: var(--ink-2); white-space: pre-line; }
.modal-btns { display: flex; gap: calc(9px * var(--scale)); margin-top: calc(16px * var(--scale)); }
.modal-btns button { flex: 1; padding: calc(9px * var(--scale)) 0; }

/* ══════════════════════════════════════════════════════════════
   顶栏按钮 / 侧栏身份卡
   ══════════════════════════════════════════════════════════════ */

.top-btn {
  padding: calc(5px * var(--scale)) calc(12px * var(--scale));
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  font-family: var(--ui);
  font-size: calc(12px * var(--scale));
  letter-spacing: .03em;
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.top-btn:hover { border-color: var(--ink-3); color: var(--ink); }
.top-btn[hidden] { display: none; }

.user-chip {
  display: flex;
  align-items: center;
  gap: calc(9px * var(--scale));
  margin: 0 calc(14px * var(--scale)) calc(10px * var(--scale));
  padding: calc(8px * var(--scale)) calc(10px * var(--scale));
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
}
.u-dot {
  width: calc(8px * var(--scale)); height: calc(8px * var(--scale));
  border-radius: 50%;
  background: var(--ink-3);
  flex: none;
}
.u-dot.r-admin { background: #B4544E; }
.u-dot.r-friend { background: #3E6D8E; }
.u-dot.r-member { background: #7A5E9E; }
.u-dot.r-guest { background: var(--ink-3); }

.u-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.u-text b { font-size: calc(12.5px * var(--scale)); font-weight: 650; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.u-text i { font-style: normal; font-size: calc(10.5px * var(--scale)); color: var(--ink-3); margin-top: 2px; }

.u-out {
  display: grid;
  place-items: center;
  width: calc(28px * var(--scale)); height: calc(28px * var(--scale));
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-3);
  cursor: pointer;
  flex: none;
}
.u-out svg { width: calc(14px * var(--scale)); height: calc(14px * var(--scale)); }
.u-out:hover { background: var(--wash); color: var(--warn); }

/* ══════════════════════════════════════════════════════════════
   Composer 里的人设选择
   ══════════════════════════════════════════════════════════════ */

.persona-pick {
  display: flex;
  align-items: center;
  gap: calc(6px * var(--scale));
  color: var(--ink-3);
  cursor: pointer;
}
.persona-pick svg { width: calc(13px * var(--scale)); height: calc(13px * var(--scale)); flex: none; }
.persona-sel {
  width: auto;
  max-width: calc(128px * var(--scale));
  padding: calc(3px * var(--scale)) calc(6px * var(--scale));
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--ink-2);
  font-family: var(--ui);
  font-size: calc(12px * var(--scale));
  cursor: pointer;
  text-overflow: ellipsis;
  box-shadow: none;
}
.persona-sel:hover { border-color: var(--line); }
.persona-sel:focus { border-color: var(--accent); box-shadow: none; }

.p-manage {
  padding: calc(3px * var(--scale)) calc(9px * var(--scale));
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-3);
  font-family: var(--ui);
  font-size: calc(11.5px * var(--scale));
  letter-spacing: .03em;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.p-manage:hover { color: var(--ink); border-color: var(--ink-3); }

/* ══════════════════════════════════════════════════════════════
   人设卡管理
   ══════════════════════════════════════════════════════════════ */

.persona-layout {
  display: grid;
  grid-template-columns: calc(168px * var(--scale)) 1fr;
  gap: calc(16px * var(--scale));
  min-height: 0;
  flex: 1;
  overflow: auto;
}
.persona-list {
  display: flex;
  flex-direction: column;
  gap: calc(4px * var(--scale));
  align-self: start;
  padding: calc(6px * var(--scale));
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
}
.p-item {
  position: relative;
  padding: calc(8px * var(--scale)) calc(10px * var(--scale));
  border-radius: 8px;
  font-size: calc(12.5px * var(--scale));
  color: var(--ink-2);
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: background .13s, color .13s;
}
.p-item:hover { background: var(--wash); color: var(--ink); }
.p-item.cur { background: var(--wash); color: var(--ink); font-weight: 600; }
.p-item.on::after {
  content: "使用中";
  position: absolute;
  top: 50%;
  right: calc(8px * var(--scale));
  transform: translateY(-50%);
  font-size: calc(9px * var(--scale));
  letter-spacing: .08em;
  color: var(--accent);
}
.p-item.none { color: var(--ink-3); font-style: italic; }

.persona-editor { min-width: 0; }
.persona-editor .btn-line { margin-top: calc(10px * var(--scale)); }
.persona-editor .note { margin-top: calc(10px * var(--scale)); }

@media (max-width: 720px) {
  .persona-layout { grid-template-columns: 1fr; }
}

/* ══════════════════════════════════════════════════════════════
   管理面板
   ══════════════════════════════════════════════════════════════ */

.adm-tabs {
  display: flex;
  gap: calc(4px * var(--scale));
  padding: calc(3px * var(--scale));
  margin-bottom: calc(14px * var(--scale));
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--bg);
  flex: none;
}
.adm-tabs button {
  flex: 1;
  padding: calc(7px * var(--scale)) 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-3);
  font-family: var(--ui);
  font-size: calc(12.5px * var(--scale));
  cursor: pointer;
  transition: color .15s, background .15s;
}
.adm-tabs button.on { background: var(--bg-elev); color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(40,34,24,.08); }

.adm-body { flex: 1; min-height: 0; overflow-y: auto; padding-right: calc(2px * var(--scale)); }
.adm-pane[hidden] { display: none; }

.adm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: calc(12.5px * var(--scale));
}
.adm-table th {
  text-align: left;
  padding: calc(6px * var(--scale)) calc(8px * var(--scale));
  border-bottom: 1px solid var(--line);
  font-weight: 600;
  color: var(--ink-3);
  font-size: calc(11.5px * var(--scale));
  letter-spacing: .04em;
  white-space: nowrap;
}
.adm-table td {
  padding: calc(8px * var(--scale));
  border-bottom: 1px solid var(--line);
  color: var(--ink-2);
  vertical-align: middle;
}
.adm-table tr:last-child td { border-bottom: 0; }
.adm-name { color: var(--ink); font-weight: 600; white-space: nowrap; }
.adm-dev { margin-top: calc(2px * var(--scale)); font-size: calc(10.5px * var(--scale)); color: var(--ink-3); }
.adm-role { width: auto; padding: 4px 7px; font-size: calc(12px * var(--scale)); box-shadow: none; }
.adm-ops { display: flex; gap: calc(6px * var(--scale)); flex-wrap: wrap; }
.adm-ops button {
  padding: 4px 11px;
  font: inherit;
  font-size: calc(12px * var(--scale));
  border: 1px solid var(--line);
  border-radius: 7px;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
}
.adm-ops button:hover { border-color: var(--ink-3); color: var(--ink); }
.adm-ops button.solid {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--bg-elev);
}
.adm-ops button.solid:hover { background: var(--accent-2); border-color: var(--accent-2); color: var(--bg-elev); }
.adm-ops button.danger:hover { border-color: var(--warn); color: var(--warn); }
/* 已单独设过限额的账号：按钮高亮 */
.adm-ops button.accent {
  border-color: var(--accent);
  background: var(--wash);
  color: var(--accent);
  font-weight: 600;
}
.adm-ops button.accent:hover { border-color: var(--accent); color: var(--accent); background: var(--wash); }
/* 用量列里的「专属」小标 */
.adm-quota { white-space: nowrap; }
.qtag {
  display: inline-block;
  margin-left: calc(6px * var(--scale));
  padding: calc(1px * var(--scale)) calc(7px * var(--scale));
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--wash);
  color: var(--accent);
  font-size: calc(10.5px * var(--scale));
  font-weight: 600;
  vertical-align: 1px;
}

.st {
  display: inline-block;
  padding: calc(2px * var(--scale)) calc(9px * var(--scale));
  border-radius: 999px;
  font-size: calc(11px * var(--scale));
  letter-spacing: .03em;
  white-space: nowrap;
}
.st-on { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); }
.st-off { background: var(--wash); color: var(--ink-3); }
.st-ban { background: color-mix(in srgb, var(--warn) 13%, transparent); color: var(--warn); }

.adm-banform {
  margin-top: calc(14px * var(--scale));
  padding: calc(14px * var(--scale)) calc(15px * var(--scale));
  border: 1px solid color-mix(in srgb, var(--warn) 38%, transparent);
  border-radius: 12px;
  background: color-mix(in srgb, var(--warn) 6%, transparent);
}
.adm-banform[hidden] { display: none; }
.adm-banform b { display: block; margin-bottom: 10px; font-size: calc(13px * var(--scale)); color: var(--warn); }
.adm-banform label { display: block; margin-bottom: 10px; font-size: calc(12.5px * var(--scale)); color: var(--ink-2); }
.adm-banform select, .adm-banform input {
  display: block;
  width: 100%;
  margin-top: calc(5px * var(--scale));
  padding: calc(7px * var(--scale)) calc(10px * var(--scale));
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg-elev);
  color: var(--ink);
  font-family: var(--ui);
  font-size: calc(13px * var(--scale));
  outline: none;
}
.adm-banform .btn-line { margin-top: calc(4px * var(--scale)); }
.adm-banform .btn-line button { padding: calc(6px * var(--scale)) calc(16px * var(--scale)); }

/* 单账号生成参数表单：中性配色，区别于红色警示的封禁表单 */
#admLimitForm {
  border-color: color-mix(in srgb, var(--accent) 38%, transparent);
  background: color-mix(in srgb, var(--accent) 6%, transparent);
  animation: riseIn .22s ease-out both;
}
#admLimitForm b { color: var(--accent); }
.lim-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(calc(150px * var(--scale)), 1fr));
  gap: calc(10px * var(--scale));
}
.lim-grid label { margin-bottom: 0; }
#admLimitForm .note { margin: calc(8px * var(--scale)) 0 calc(4px * var(--scale)); }

.adm-set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(12px * var(--scale)) calc(2px * var(--scale));
  border-bottom: 1px solid var(--line);
  font-size: calc(13.5px * var(--scale));
  color: var(--ink);
}
.adm-set-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(calc(180px * var(--scale)), 1fr)); gap: calc(12px * var(--scale)); margin: calc(16px * var(--scale)) 0 calc(4px * var(--scale)); }
.adm-set-grid label {
  display: flex;
  flex-direction: column;
  gap: calc(6px * var(--scale));
  padding: calc(12px * var(--scale)) calc(14px * var(--scale));
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  font-size: calc(12.5px * var(--scale));
  color: var(--ink-2);
}
.adm-set-grid input {
  width: 100%;
  padding: calc(8px * var(--scale)) calc(11px * var(--scale));
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg-elev);
  color: var(--ink);
  font-family: var(--mono);
  font-size: calc(13.5px * var(--scale));
  outline: none;
}
.adm-set-grid input:focus { border-color: var(--accent); }
.adm-pane .note { margin-top: calc(10px * var(--scale)); }
#admSettings .btn-line { margin-top: calc(16px * var(--scale)); }

.adm-fb {
  position: relative;
  padding: calc(13px * var(--scale)) calc(15px * var(--scale));
  margin-bottom: calc(10px * var(--scale));
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
}
.adm-fb.done { opacity: .62; }
/* 未处理反馈：右上角小红点 */
.adm-fb > .fb-dot {
  position: absolute;
  top: calc(10px * var(--scale));
  right: calc(11px * var(--scale));
  width: calc(9px * var(--scale));
  height: calc(9px * var(--scale));
  border-radius: 50%;
  background: #C0392B;
  box-shadow: 0 0 0 calc(3px * var(--scale)) var(--bg);
  animation: popIn .32s cubic-bezier(.2, .9, .3, 1) both;
}
.adm-fb > .fb-dot::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: #C0392B;
  animation: dotPulse 2s ease-in-out infinite;
}
/* 思考替换规则编辑器 */
.adm-sub {
  margin-top: calc(20px * var(--scale));
  padding-top: calc(14px * var(--scale));
  border-top: 1px solid var(--line);
}
.adm-sub h4 {
  margin: 0 0 calc(8px * var(--scale));
  font-size: calc(13px * var(--scale));
  color: var(--ink);
  font-weight: 600;
}
.th-rule {
  display: grid;
  grid-template-columns: 1fr 1fr auto auto auto;
  align-items: center;
  gap: calc(7px * var(--scale));
  margin-bottom: calc(7px * var(--scale));
}
.th-rule input[type=text] {
  min-width: 0;
  padding: calc(6px * var(--scale)) calc(9px * var(--scale));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-elev);
  color: var(--ink);
  font-family: var(--ui);
  font-size: calc(12.5px * var(--scale));
  outline: none;
}
.th-rule input[type=text]:focus { border-color: var(--accent); }
.th-flag {
  display: inline-flex;
  align-items: center;
  gap: calc(4px * var(--scale));
  white-space: nowrap;
  font-size: calc(12px * var(--scale));
  color: var(--ink-2);
  cursor: pointer;
}
.th-rule button {
  padding: calc(4px * var(--scale)) calc(10px * var(--scale));
  border: 1px solid var(--line);
  border-radius: 7px;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: calc(13px * var(--scale));
  cursor: pointer;
}
.th-rule button:hover { border-color: var(--warn); color: var(--warn); }
@media (max-width: 640px) {
  .th-rule { grid-template-columns: 1fr 1fr; }
}

/* 反馈面板顶部：统计 + 清空 */
.adm-fb-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: calc(10px * var(--scale));
  margin-bottom: calc(6px * var(--scale));
}
.adm-fb-bar .note { margin: 0; }
.adm-fb-bar .note.warn { color: #C0392B; font-weight: 600; }
.adm-fb-bar button { padding: calc(5px * var(--scale)) calc(11px * var(--scale)); font-size: calc(12px * var(--scale)); }
.adm-fb-head { display: flex; align-items: baseline; gap: calc(10px * var(--scale)); margin-bottom: calc(7px * var(--scale)); }
.adm-fb-head b { font-size: calc(13px * var(--scale)); color: var(--ink); }
.adm-fb-head i { font-style: normal; font-size: calc(11px * var(--scale)); color: var(--ink-3); }
.adm-fb p { margin: 0 0 9px; font-size: calc(13px * var(--scale)); line-height: 1.65; color: var(--ink-2); white-space: pre-line; word-break: break-word; }
.adm-fb-ops { display: flex; gap: calc(7px * var(--scale)); flex-wrap: wrap; margin-top: calc(8px * var(--scale)); }
.adm-fb-ops button { padding: 5px 12px; font-size: calc(12px * var(--scale)); }

.adm-reply-input {
  display: block;
  width: 100%;
  margin-top: calc(8px * var(--scale));
  padding: calc(7px * var(--scale)) calc(11px * var(--scale));
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg-elev);
  color: var(--ink);
  font-family: var(--ui);
  font-size: calc(13px * var(--scale));
  outline: none;
}
.adm-reply-input:focus { border-color: var(--accent); }
/* ── IP 封禁 ─────────────────────────────────────────────────── */
.adm-ip-add { display: flex; gap: 8px; margin: 12px 0 4px; flex-wrap: wrap; }
.adm-ip-add input {
  flex: 1;
  min-width: 180px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--mono);
  font-size: calc(13px * var(--scale));
  outline: none;
}
.adm-ip-add input:focus { border-color: var(--accent); }
.adm-ip-add button { padding: 7px 16px; }

.adm-ip-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.adm-ip-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--bg);
}
.adm-ip-row code {
  font-family: var(--mono);
  font-size: calc(13px * var(--scale));
  color: var(--ink);
  font-weight: 600;
}
.adm-ip-meta {
  flex: 1;
  font-size: calc(11.5px * var(--scale));
  color: var(--ink-3);
}
.adm-ip-row button { padding: 4px 12px; }

.adm-fb .adm-fb-reply {
  margin: calc(8px * var(--scale)) 0 0;
  padding: calc(7px * var(--scale)) calc(10px * var(--scale));
  border-left: 2px solid var(--accent);
  background: var(--wash);
  color: var(--ink-2);
  white-space: pre-line;
}

/* 弹窗内的反馈表单复用 auth-field */
#fbScrim .modal-card { max-width: calc(440px * var(--scale)); }

/* 侧栏底部：身份卡在上，状态行在下 */
.side-foot { flex-direction: column; align-items: stretch; gap: 0; padding: 0; }
.foot-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: calc(8px * var(--scale));
  padding: 0 calc(16px * var(--scale)) calc(13px * var(--scale));
}
.user-chip { margin: calc(13px * var(--scale)) calc(16px * var(--scale)) calc(11px * var(--scale)); }

/* ── 图标随字号一起缩放 ─────────────────────────────────────── */
.mark { width: calc(27px * var(--scale)); height: calc(27px * var(--scale)); }
.new-chat svg { width: calc(14px * var(--scale)); height: calc(14px * var(--scale)); }
.icon-btn svg { width: calc(15px * var(--scale)); height: calc(15px * var(--scale)); }
.u-out svg { width: calc(14px * var(--scale)); height: calc(14px * var(--scale)); }
.persona-pick svg { width: calc(13px * var(--scale)); height: calc(13px * var(--scale)); }
.lock-icon svg { width: calc(21px * var(--scale)); height: calc(21px * var(--scale)); }
.auth-brand .mark { width: calc(30px * var(--scale)); height: calc(30px * var(--scale)); }

/* ══════════════════════════════════════════════════════════════
   动效：入场、按压、红点弹跳、面板切换
   ══════════════════════════════════════════════════════════════ */

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { 0% { transform: scale(.35); opacity: 0; } 62% { transform: scale(1.14); opacity: 1; } 100% { transform: scale(1); } }
@keyframes riseIn { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity: 1; transform: none; } }
@keyframes turnIn { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }
@keyframes paneIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
@keyframes slideX { from { opacity: 0; transform: translateX(-6px); } to { opacity: 1; transform: none; } }
/* 未处理红点的呼吸光晕 */
@keyframes dotPulse { 0%,100% { opacity: .55; transform: scale(1); } 50% { opacity: 0; transform: scale(2.1); } }

/* 新消息轻轻浮上来 */
.turn.enter { animation: turnIn .3s cubic-bezier(.2, .9, .3, 1) both; }

/* 弹窗：淡入背景 + 上浮卡片 */
.modal-scrim { animation: fadeIn .16s ease-out both; }
.modal-card { animation: riseIn .22s cubic-bezier(.2, .9, .3, 1) both; }
.modal-card.narrow { max-width: 340px; }

/* 管理面板切页淡入 */
.adm-pane:not([hidden]) { animation: paneIn .2s ease-out both; }
.adm-fb, .adm-ip-row { animation: paneIn .22s ease-out both; }

/* 红点出现时弹一下 */
.dot-badge:not([hidden]) { animation: popIn .32s cubic-bezier(.2, .9, .3, 1) both; }

/* 按钮按压反馈 */
.new-chat, .top-btn, .auth-go, .ghost-btn, .p-manage,
.btn-line button, .adm-ops button, .icon-btn, .u-out, .thread {
  transition: background .16s ease, color .16s ease, border-color .16s ease,
              box-shadow .16s ease, transform .12s ease, opacity .16s ease;
}
.new-chat:active, .top-btn:active, .auth-go:active, .ghost-btn:active,
.p-manage:active, .btn-line button:active, .adm-ops button:active, .icon-btn:active {
  transform: scale(.975);
}

/* 会话列表：悬停微微右移 */
.thread:hover { transform: translateX(2px); }
.thread.active { animation: slideX .18s ease-out both; }

/* 提示行出现时淡入 */
.foot-note.flash { animation: turnIn .28s ease-out both; }

/* 危险确认按钮 */
.modal-btns .solid.danger-ok {
  border-color: var(--warn);
  background: var(--warn);
  color: #fff;
}
.modal-btns .solid.danger-ok:hover { filter: brightness(1.08); }

/* 尊重系统的「减少动态效果」设置 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
.top-btn, .adm-tabs button { position: relative; }
.dot-badge {
  position: absolute;
  top: -5px;
  right: -6px;
  min-width: calc(16px * var(--scale));
  height: calc(16px * var(--scale));
  padding: 0 4px;
  border-radius: 999px;
  background: #C0392B;
  color: #fff;
  font-size: calc(10px * var(--scale));
  font-weight: 600;
  line-height: calc(16px * var(--scale));
  text-align: center;
  letter-spacing: 0;
  box-shadow: 0 0 0 2px var(--bg-elev);
  pointer-events: none;
}
.dot-badge[hidden] { display: none; }
.dot-badge.sm { top: -3px; right: -3px; box-shadow: 0 0 0 2px var(--bg); }
.adm-tabs button.on .dot-badge.sm { box-shadow: 0 0 0 2px var(--bg-elev); }

/* ── 通知 / 反馈 / 确认弹窗要浮在登录门之上 ─────── */
#fbScrim { z-index: 70; }
#confirmScrim { z-index: 78; }
#noticeScrim { z-index: 80; }

/* 确认弹窗里的留言框 */
#cfInput {
  width: 100%;
  margin-top: 10px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--ui);
  font-size: calc(13.5px * var(--scale));
  line-height: 1.6;
  resize: vertical;
  outline: none;
}
#cfInput:focus { border-color: var(--accent); }
.auth-field input[readonly] {
  background: var(--wash);
  color: var(--ink-2);
  cursor: default;
  font-family: var(--mono);
  letter-spacing: .04em;
}
.auth-field input[readonly]:focus { border-color: var(--line); box-shadow: none; }

/* ── 身份卡可点击刷新余量 ───────────────────────────────────── */
.user-chip { cursor: pointer; transition: border-color .15s; }
.user-chip:hover { border-color: var(--line-2); }
.user-chip.refreshing .u-dot { animation: chipSpin .5s linear infinite; }
@keyframes chipSpin { to { transform: rotate(360deg); } }

/* ── 余量：快用完时变色提示 ─────────────────────────────────── */
.u-text i.warn { color: var(--warn); }
.u-text i.full { color: var(--warn); }

