/* ============================================================
   纸页酒馆 · Paper Tavern Dark
   深色手工纸 + 浅色墨迹 + 夜蓝单强调色
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&display=swap');

:root {
  --paper: 26, 24, 22;
  --paper-2: 37, 34, 31;
  --surface: 32, 29, 27;
  --ink: 215, 208, 195;
  --muted: 125, 118, 105;
  --rule: 52, 48, 42;
  --accent: 105, 145, 190;
  --warm: 190, 155, 120;
  --serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", Georgia, serif;
  --sans: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-spring: cubic-bezier(0.32, 0.72, 0, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  background: rgb(var(--paper));
  color: rgb(var(--ink));
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

/* 纸张噪点：固定层，不参与滚动 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
}

::selection { background: rgba(var(--accent), 0.35); }

a { color: rgb(var(--accent)); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* 入场动画 */
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); filter: blur(3px); }
  to { opacity: 1; transform: translateY(0); filter: blur(0); }
}
.rise { animation: rise 0.7s var(--ease-out) both; }
.rise-1 { animation-delay: 0.06s; }
.rise-2 { animation-delay: 0.14s; }
.rise-3 { animation-delay: 0.22s; }
.rise-4 { animation-delay: 0.3s; }

/* ============ 表单控件 ============ */
.input, input[type="text"], input[type="password"], textarea, select {
  width: 100%;
  background: rgb(var(--surface));
  border: 1px solid rgba(var(--rule), 1);
  border-radius: 10px;
  color: rgb(var(--ink));
  font-family: var(--sans);
  font-size: 14px;
  padding: 11px 14px;
  outline: none;
  transition: border-color 0.16s var(--ease-out), box-shadow 0.16s var(--ease-out);
}
.input:focus, input:focus, textarea:focus, select:focus {
  border-color: rgba(var(--accent), 0.65);
  box-shadow: 0 0 0 3px rgba(var(--accent), 0.18);
}
.input::placeholder, textarea::placeholder { color: rgba(var(--muted), 0.7); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgb(var(--accent));
  color: #0d1319;
  border: none;
  border-radius: 999px;
  padding: 12px 26px;
  font-family: var(--sans);
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: transform 0.12s var(--ease-spring), background-color 0.16s ease, box-shadow 0.2s ease;
}
.btn:hover { background: rgba(129, 165, 207, 1); }
.btn:active { transform: scale(0.98); }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: transparent;
  color: rgb(var(--muted));
  border: 1px solid rgba(var(--rule), 1);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px;
  cursor: pointer;
  transition: color 0.16s ease, border-color 0.16s ease, background-color 0.16s ease;
}
.btn-ghost:hover { color: rgb(var(--ink)); border-color: rgba(var(--accent), 0.5); background: rgba(var(--surface), 0.8); }

/* ============ 滚动条 ============ */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(var(--rule), 1); border-radius: 5px; border: 2px solid rgb(var(--paper)); }
::-webkit-scrollbar-thumb:hover { background: rgba(var(--muted), 0.7); }
* { scrollbar-width: thin; scrollbar-color: rgba(var(--rule), 1) transparent; }

/* ============ 登录页 ============ */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  min-height: 100dvh;
}
.login-card {
  width: 100%;
  max-width: 392px;
  background: rgb(var(--surface));
  border: 1px solid rgba(var(--rule), 1);
  border-radius: 22px;
  padding: 6px;
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.5);
}
.login-inner {
  background: rgb(var(--surface));
  background-image: repeating-linear-gradient(180deg, transparent 0px, transparent 35px, rgba(var(--ink), 0.022) 35px, rgba(var(--ink), 0.022) 36px);
  border: 1px solid rgba(var(--rule), 0.7);
  border-radius: 17px;
  padding: 40px 34px 26px;
}
.login-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-bottom: 30px;
  text-align: center;
}
.login-logo img { width: 54px; height: 54px; border-radius: 14px; opacity: 0.95; }
.login-title { font-family: var(--serif); font-size: 23px; font-weight: 600; letter-spacing: 0.12em; }
.login-sub { font-size: 12.5px; color: rgb(var(--muted)); line-height: 1.8; }
.login-eyebrow {
  display: inline-block;
  border: 1px solid rgba(var(--accent), 0.4);
  color: rgb(var(--accent));
  border-radius: 999px;
  padding: 2px 12px;
  font-size: 10px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
}
.field { margin-bottom: 15px; }
.field label {
  display: block;
  font-size: 12px;
  color: rgb(var(--muted));
  letter-spacing: 0.08em;
  margin-bottom: 7px;
}
.login-error {
  display: none;
  margin-top: 14px;
  padding: 10px 13px;
  background: rgba(212, 115, 106, 0.08);
  border: 1px solid rgba(212, 115, 106, 0.35);
  border-radius: 9px;
  color: #d4736a;
  font-size: 13px;
  line-height: 1.6;
}
.login-error.show { display: block; }
.login-alt {
  margin-top: 18px;
  text-align: center;
  font-size: 12.5px;
  color: rgb(var(--muted));
}
.login-foot {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid rgba(var(--rule), 0.8);
  font-size: 11.5px;
  color: rgba(var(--muted), 0.75);
  line-height: 1.8;
  text-align: center;
}

/* ============ 主界面布局 ============ */
.app {
  display: flex;
  height: 100dvh;
  position: relative;
  z-index: 1;
}

/* —— 左侧：书架栏 —— */
.library {
  width: 296px;
  min-width: 296px;
  height: 100dvh;
  border-right: 1px solid rgba(var(--rule), 0.9);
  display: flex;
  flex-direction: column;
  background: rgba(var(--paper-2), 0.55);
}
.library-head {
  padding: 22px 20px 14px;
  border-bottom: 1px solid rgba(var(--rule), 0.8);
}
.library-title {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.14em;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.library-title small { font-size: 10px; color: rgb(var(--muted)); letter-spacing: 0.22em; }
.library-body { flex: 1; overflow-y: auto; padding: 14px; }
.card-item {
  display: flex;
  gap: 12px;
  padding: 12px;
  border-radius: 13px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.card-item:hover { background: rgba(var(--surface), 0.85); border-color: rgba(var(--rule), 0.9); }
.card-item.active { background: rgba(var(--accent), 0.13); border-color: rgba(var(--accent), 0.45); }
.card-avatar {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 11px;
  background: rgb(var(--surface));
  border: 1px solid rgba(var(--rule), 1);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--serif);
  font-size: 19px;
  color: rgba(var(--ink), 0.85);
}
.card-avatar img { width: 100%; height: 100%; object-fit: cover; }
.card-meta { min-width: 0; flex: 1; }
.card-name {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-sub {
  font-size: 11.5px;
  color: rgb(var(--muted));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.library-foot { padding: 12px 14px; border-top: 1px solid rgba(var(--rule), 0.8); display: flex; flex-direction: column; gap: 8px; }

/* —— 右侧：聊天 —— */
.chat-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background-image: repeating-linear-gradient(180deg, transparent 0px, transparent 35px, rgba(var(--ink), 0.02) 35px, rgba(var(--ink), 0.02) 36px);
}
.chat-top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 26px;
  border-bottom: 1px solid rgba(var(--rule), 0.8);
  background: rgba(var(--paper), 0.7);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 5;
}
.chat-top-title { font-family: var(--serif); font-size: 16px; font-weight: 600; letter-spacing: 0.06em; min-width: 0; }
.chat-top-sub { font-size: 11.5px; color: rgb(var(--muted)); white-space: nowrap; }
.chat-top .spacer { flex: 1; }
.model-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgb(var(--surface));
  border: 1px solid rgba(var(--rule), 1);
  border-radius: 999px;
  padding: 6px 8px 6px 14px;
  font-size: 12px;
  color: rgb(var(--muted));
  cursor: pointer;
  transition: border-color 0.16s ease, color 0.16s ease;
  max-width: 260px;
}
.model-pill:hover { border-color: rgba(var(--accent), 0.5); color: rgb(var(--ink)); }
.model-pill b { color: rgb(var(--accent)); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 170px; }
.model-pill .fa, .model-pill svg { opacity: 0.7; }

.chat-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 30px 26px 20px;
  scroll-behavior: smooth;
}
.chat-col { max-width: 860px; margin: 0 auto; display: flex; flex-direction: column; gap: 4px; }

/* —— 消息 —— */
.msg {
  max-width: 100%;
  padding: 10px 14px 16px;
  border-radius: 13px;
  position: relative;
  transition: background-color 0.15s ease;
}
.msg:hover { background: rgba(var(--ink), 0.035); }
.msg.user { background: rgba(var(--paper-2), 0.55); border: 1px solid rgba(var(--rule), 0.8); }
.msg-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 5px;
}
.msg-name { font-weight: 700; font-size: 13.5px; letter-spacing: 0.03em; }
.msg-time { font-size: 10.5px; color: rgba(var(--muted), 0.8); }
.msg-text {
  font-family: var(--serif);
  font-size: 15.5px;
  line-height: 1.95;
  letter-spacing: 0.012em;
  word-break: break-word;
  white-space: pre-wrap;
}
.msg-text q { color: rgb(var(--accent)); }
.msg-text em { color: rgb(var(--warm)); }
.msg-text code {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 12.5px;
  background: rgb(var(--surface));
  border: 1px solid rgba(var(--rule), 0.9);
  border-radius: 6px;
  padding: 1px 6px;
}
.msg-text pre {
  background: rgb(var(--surface));
  border: 1px solid rgba(var(--rule), 0.9);
  border-radius: 9px;
  padding: 12px 14px;
  overflow-x: auto;
  margin: 8px 0;
}
.msg-text pre code { background: transparent; border: none; padding: 0; }
.msg-text details {
  margin: 8px 0;
  border: 1px solid rgba(var(--rule), 0.9);
  border-left: 3px solid rgba(var(--accent), 0.55);
  border-radius: 9px;
  background: rgb(var(--surface));
}
.msg-text details summary {
  cursor: pointer;
  padding: 8px 13px;
  font-size: 12.5px;
  color: rgb(var(--muted));
  list-style: none;
  user-select: none;
}
.msg-text details summary::before { content: "▸ "; color: rgb(var(--accent)); }
.msg-text details[open] summary::before { content: "▾ "; }
.msg-text details pre { margin: 0 13px 12px; border: none; background: transparent; }

/* 打印中光标 */
.cursor-blink::after {
  content: "▍";
  color: rgb(var(--accent));
  animation: blink 1s steps(1) infinite;
  margin-left: 1px;
}
@keyframes blink { 50% { opacity: 0; } }

/* —— 输入区 —— */
.composer-wrap { padding: 14px 26px 20px; }
.composer {
  max-width: 860px;
  margin: 0 auto;
  background: rgb(var(--surface));
  border: 1px solid rgba(var(--rule), 1);
  border-radius: 16px;
  padding: 12px 16px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.35);
  transition: border-color 0.16s ease, box-shadow 0.2s ease;
}
.composer:focus-within {
  border-color: rgba(var(--accent), 0.6);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.35), 0 0 0 3px rgba(var(--accent), 0.16);
}
.composer textarea {
  background: transparent;
  border: none;
  resize: none;
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.8;
  min-height: 44px;
  max-height: 200px;
  padding: 0;
}
.composer textarea:focus { border: none; box-shadow: none; }
.composer-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}
.composer-bar .spacer { flex: 1; }
.send-btn {
  width: 42px;
  height: 42px;
  min-width: 42px;
  border-radius: 50%;
  border: none;
  background: rgb(var(--accent));
  color: #0d1319;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s var(--ease-spring), background-color 0.16s ease;
}
.send-btn:hover { background: rgba(129, 165, 207, 1); }
.send-btn:active { transform: scale(0.94); }
.send-btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* 空状态 */
.empty-state {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: rgb(var(--muted));
  text-align: center;
  padding: 40px;
}
.empty-state .big { font-family: var(--serif); font-size: 21px; color: rgba(var(--ink), 0.75); letter-spacing: 0.1em; }

/* ============ 消息操作 ============ */
.msg .msg-actions {
  display: none;
  gap: 2px;
  background: rgb(var(--surface));
  border: 1px solid rgba(var(--rule), 1);
  border-radius: 8px;
  padding: 1px 3px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}
.msg:hover .msg-actions { display: inline-flex; }
.msg-act {
  background: transparent;
  border: none;
  color: rgb(var(--muted));
  font-size: 12px;
  line-height: 1;
  padding: 4px 7px;
  cursor: pointer;
  border-radius: 5px;
  transition: color 0.13s ease, background-color 0.13s ease;
}
.msg-act:hover { color: rgb(var(--accent)); background: rgba(var(--ink), 0.06); }

.swipe-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 6px;
}
.swipe-count { font-size: 11px; color: rgb(var(--muted)); letter-spacing: 0.1em; }

/* ============ 模型列表 ============ */
.model-row {
  display: flex;
  align-items: center;
  gap: 9px;
  background: rgb(var(--surface));
  border: 1px solid rgba(var(--rule), 0.9);
  border-radius: 9px;
  padding: 8px 12px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  color: rgb(var(--ink));
  font-family: var(--sans);
  font-size: 12.5px;
  transition: border-color 0.14s ease, background-color 0.14s ease;
}
.model-row:hover { border-color: rgba(var(--accent), 0.5); background: rgb(var(--paper-2)); }
.model-row.current { border-color: rgba(var(--accent), 0.6); background: rgba(var(--accent), 0.08); }
.model-check { width: 14px; text-align: center; color: rgb(var(--muted)); }
.model-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-tag { font-size: 10px; color: rgb(var(--accent)); letter-spacing: 0.12em; }

/* ============ 弹窗 ============ */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 9, 8, 0.72);
  backdrop-filter: blur(6px);
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.overlay.show { display: flex; }
.modal {
  width: 100%;
  max-width: 520px;
  background: rgb(var(--surface));
  border: 1px solid rgba(var(--rule), 1);
  border-radius: 20px;
  padding: 6px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  animation: rise 0.35s var(--ease-out) both;
  max-height: 88dvh;
  display: flex;
}
.modal-inner {
  background: rgb(var(--surface));
  border: 1px solid rgba(var(--rule), 0.7);
  border-radius: 15px;
  padding: 26px 26px 20px;
  width: 100%;
  overflow-y: auto;
}
.modal-title { font-family: var(--serif); font-size: 18px; font-weight: 600; letter-spacing: 0.08em; margin-bottom: 18px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.drop-zone {
  border: 1.5px dashed rgba(var(--muted), 0.5);
  border-radius: 13px;
  padding: 34px 20px;
  text-align: center;
  color: rgb(var(--muted));
  font-size: 13.5px;
  cursor: pointer;
  transition: border-color 0.18s ease, background-color 0.18s ease, color 0.18s ease;
}
.drop-zone:hover, .drop-zone.dragover {
  border-color: rgba(var(--accent), 0.6);
  background: rgba(var(--accent), 0.06);
  color: rgb(var(--ink));
}
.hint { font-size: 12px; color: rgb(var(--muted)); line-height: 1.7; }

/* toast */
#toasts {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}
.toast {
  background: rgb(var(--surface));
  border: 1px solid rgba(var(--rule), 1);
  border-radius: 11px;
  padding: 10px 18px;
  font-size: 13px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  animation: rise 0.3s var(--ease-out) both;
  max-width: min(480px, 90vw);
}
.toast.error { border-color: rgba(212, 115, 106, 0.5); color: #d4736a; }
.toast.success { border-color: rgba(90, 174, 112, 0.5); }

/* ============ 移动端 ============ */
@media (max-width: 860px) {
  .app { flex-direction: column-reverse; }
  .library {
    width: 100%;
    min-width: 0;
    height: 42dvh;
    border-right: none;
    border-top: 1px solid rgba(var(--rule), 1);
  }
  .chat-pane { height: 58dvh; }
  .chat-top { padding: 10px 14px; }
  .chat-scroll { padding: 16px 12px 12px; }
  .composer-wrap { padding: 10px 12px 14px; }
  .msg-text { font-size: 14.5px; }
  .model-pill { max-width: 150px; }
}

/* ============ 原生酒馆骨架：图标栏 + 抽屉 ============ */
.icon-bar {
  width: 62px;
  min-width: 62px;
  height: 100dvh;
  border-right: 1px solid rgba(var(--rule), 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  background: rgba(var(--paper-2), 0.6);
}
.icon-group { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.nav-icon {
  width: 42px; height: 42px;
  border-radius: 11px;
  border: 1px solid rgba(var(--rule), 0.9);
  background: rgb(var(--surface));
  color: rgb(var(--ink));
  font-size: 17px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background-color 0.16s ease, border-color 0.16s ease, transform 0.1s ease;
  filter: grayscale(0.35);
}
.nav-icon:hover { background: rgb(var(--paper-2)); border-color: rgba(var(--accent), 0.5); transform: translateY(-1px); filter: none; }
.nav-icon.open { background: rgb(var(--accent)); border-color: rgb(var(--accent)); filter: none; }
.conn-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: #d4736a; margin: 6px 0 2px;
  box-shadow: 0 0 0 2px rgb(var(--surface));
  transition: background-color 0.3s ease;
}
.conn-dot.on { background: #5aae70; }

.drawer {
  width: 330px;
  min-width: 330px;
  height: 100dvh;
  overflow-y: auto;
  border-right: 1px solid rgba(var(--rule), 0.9);
  background: rgb(var(--paper));
  padding: 20px 18px;
  display: none;
}
.drawer.open { display: block; animation: drawerIn 0.3s var(--ease-out) both; }
@keyframes drawerIn {
  from { opacity: 0; transform: translateX(-14px); }
  to { opacity: 1; transform: translateX(0); }
}
.drawer-title {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.1em;
  margin-bottom: 18px;
}
.field-label {
  display: block;
  font-size: 12px;
  color: rgb(var(--muted));
  letter-spacing: 0.06em;
  margin: 14px 0 6px;
}
.drawer-page textarea, .drawer-page input[type="text"] { margin-bottom: 4px; }
.field-row { display: flex; gap: 8px; margin: 10px 0; }
.btn.small { padding: 9px 16px; font-size: 13px; flex: 1; }
.btn-ghost.small { padding: 7px 12px; font-size: 12px; }

.status-line { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: rgb(var(--muted)); margin-bottom: 8px; }
.status-line .dot { width: 8px; height: 8px; border-radius: 50%; background: #d4736a; }
.status-line.on .dot { background: #5aae70; }
.status-line.on { color: rgb(var(--ink)); }

.model-list { display: flex; flex-direction: column; gap: 4px; max-height: 44dvh; overflow-y: auto; margin-top: 4px; }
.hint-block {
  margin-top: 14px;
  padding: 10px 12px;
  background: rgba(var(--surface), 0.7);
  border: 1px solid rgba(var(--rule), 0.8);
  border-radius: 9px;
  font-size: 11.5px;
  color: rgb(var(--muted));
  line-height: 1.8;
}
.hint-block b { color: rgb(var(--accent)); font-weight: 500; }

.readonly-pill {
  background: rgb(var(--surface));
  border: 1px solid rgba(var(--rule), 0.9);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12.5px;
  color: rgb(var(--accent));
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.slider-row {
  display: grid;
  grid-template-columns: 108px 1fr 44px;
  align-items: center;
  gap: 10px;
  margin: 8px 0;
  font-size: 12.5px;
  color: rgb(var(--muted));
}
.slider-row b { color: rgb(var(--ink)); font-weight: 500; text-align: right; font-variant-numeric: tabular-nums; }
.slider-row input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 5px;
  background: rgba(var(--accent), 0.25);
  border-radius: 4px;
  outline: none;
}
.slider-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: rgb(var(--accent));
  border: 2px solid rgb(var(--surface));
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.4);
  cursor: pointer;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 2px;
  font-size: 13.5px;
  cursor: pointer;
}
.check-row input { width: 15px; height: 15px; accent-color: rgb(var(--accent)); }

.entry-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.entry-item {
  background: rgb(var(--surface));
  border: 1px solid rgba(var(--rule), 0.85);
  border-radius: 9px;
  padding: 8px 12px;
  font-size: 12.5px;
}
.entry-item .e-head { display: flex; gap: 8px; align-items: center; }
.entry-item .e-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry-item .e-badge {
  font-size: 10px;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid rgba(var(--rule), 1);
  color: rgb(var(--muted));
}
.entry-item .e-badge.constant { color: rgb(var(--accent)); border-color: rgba(var(--accent), 0.4); }
.entry-item .e-badge.off { color: #d4736a; border-color: rgba(212, 115, 106, 0.4); }
.entry-item .e-keys { margin-top: 4px; font-size: 11px; color: rgb(var(--muted)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.char-list-compact { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; }
.mini-card {
  display: flex; gap: 10px; align-items: center;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 13px;
  transition: background-color 0.14s ease, border-color 0.14s ease;
}
.mini-card:hover { background: rgba(var(--surface), 0.85); border-color: rgba(var(--rule), 0.9); }
.mini-card.active { background: rgba(var(--accent), 0.12); border-color: rgba(var(--accent), 0.45); }
.mini-avatar {
  width: 36px; height: 36px; min-width: 36px;
  border-radius: 9px;
  background: rgb(var(--surface));
  border: 1px solid rgba(var(--rule), 1);
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--serif);
}
.mini-avatar img { width: 100%; height: 100%; object-fit: cover; }
.mini-del { opacity: 0; }
.mini-card:hover .mini-del { opacity: 1; }

.chat-pane { position: relative; }
.chat-top { padding: 13px 24px; background: rgba(var(--paper), 0.75); }
.composer-wrap { padding: 12px 24px 18px; }
.composer {
  max-width: 920px;
  border-radius: 14px;
  padding: 10px 14px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.composer textarea { flex: 1; min-height: 42px; padding: 8px 2px; font-size: 14.5px; }
.bar-icon {
  width: 38px; height: 38px; min-width: 38px;
  border: none;
  background: transparent;
  color: rgb(var(--muted));
  font-size: 17px;
  cursor: pointer;
  border-radius: 9px;
  transition: color 0.14s ease, background-color 0.14s ease;
}
.bar-icon:hover { color: rgb(var(--accent)); background: rgba(var(--ink), 0.05); }
.send-btn { width: 40px; height: 40px; min-width: 40px; }

.options-menu {
  position: absolute;
  left: 24px;
  bottom: 88px;
  z-index: 30;
  display: none;
  flex-direction: column;
  background: rgb(var(--surface));
  border: 1px solid rgba(var(--rule), 1);
  border-radius: 13px;
  padding: 6px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
  min-width: 210px;
  animation: rise 0.22s var(--ease-out) both;
}
.options-menu.show { display: flex; }
.option-item {
  background: transparent;
  border: none;
  color: rgb(var(--ink));
  font-size: 13.5px;
  text-align: left;
  padding: 10px 14px;
  border-radius: 9px;
  cursor: pointer;
  transition: background-color 0.13s ease;
}
.option-item:hover { background: rgba(var(--accent), 0.12); }

.msg.editing textarea {
  width: 100%;
  background: rgb(var(--surface));
  border: 1px solid rgba(var(--accent), 0.5);
  border-radius: 9px;
  color: rgb(var(--ink));
  font-family: var(--serif);
  font-size: 14.5px;
  line-height: 1.8;
  padding: 10px 12px;
  min-height: 120px;
  outline: none;
}
body.no-lines .chat-pane { background-image: none; }
body.no-serif .msg-text { font-family: var(--sans); font-size: 14.5px; line-height: 1.8; }

@media (max-width: 900px) {
  .icon-bar { width: 52px; min-width: 52px; padding: 10px 0; }
  .nav-icon { width: 36px; height: 36px; font-size: 14px; }
  .drawer { width: calc(100vw - 52px); min-width: 0; position: fixed; left: 52px; top: 0; z-index: 40; box-shadow: 0 12px 40px rgba(0,0,0,.5); }
  .chat-top { padding: 10px 12px; }
  .chat-scroll { padding: 16px 10px 10px; }
  .composer-wrap { padding: 8px 10px 12px; }
  .options-menu { left: 10px; bottom: 76px; }
}
