/* Littly 控制台 · 样式表
 *
 * 视觉方向：「显影室 / Darkroom」
 * ===================================================================
 * 她的记忆像一卷底片 —— 拍下时只是潜影，被看见时才显影。
 * 于是整套界面用胶片说话：片基、药膜、片边、安全灯、齿孔、片格号。
 *
 * 三条纪律（改版时守住）：
 *   1. 颜色克制 —— 底色是片基（近黑微冷），**唯一**的高饱和色是安全灯的琥珀；
 *      显影后的银盐绿只用于「已生效」，定影红只用于「危险 / 失败」。
 *   2. 字体分职 —— 无衬线是**系统外壳**；**衬线只给「她」**（她的消息、她的日记、
 *      记忆正文）；等宽是元数据（时间、ID、计数、片格号）。字体本身承担语义。
 *   3. 结构即信息 —— 齿孔与片格号只出现在真正像胶片的地方（记忆列表 / 角色条），
 *      不做装饰性复制；一个记忆 = 一个片格，编号即它在时间序里的位置。
 *
 * 纯 CSS：无外部字体、无第三方资源、无构建工具。
 */

/* =====================================================================
 * 令牌
 * =================================================================== */

:root {
  /* —— 片基与药膜（底） —— */
  --base: #0f1114;         /* 片基：最底层 */
  --base-2: #14171b;       /* 桌面 */
  --emulsion: #191d22;     /* 药膜面：卡片 / 面板 */
  --emulsion-2: #1f242b;   /* 抬升面：输入框 / 悬浮 */
  --emulsion-3: #262c34;   /* 再抬升：选中态 */
  --edge: #2a3038;         /* 片边（描边） */
  --edge-soft: #20252c;    /* 淡片边 */

  /* —— 安全灯（唯一的强调色） —— */
  --safelight: #e0913c;
  --safelight-dim: #a25f1c;
  --safelight-wash: rgba(224, 145, 60, 0.12);
  --safelight-edge: rgba(224, 145, 60, 0.42);

  /* —— 显影后的银盐（已生效 / 成功） —— */
  --halide: #8fa79c;
  --halide-wash: rgba(143, 167, 156, 0.14);

  /* —— 定影红（危险 / 失败） —— */
  --fixer: #c6483a;
  --fixer-wash: rgba(198, 72, 58, 0.14);

  /* —— 相纸（文字） —— */
  --paper: #dcd8d0;
  --paper-dim: #9a9a93;
  --paper-faint: #65676a;

  --radius: 4px;
  --radius-sm: 3px;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
  --shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.4);

  /* 无衬线 = 系统外壳 */
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC",
    "Noto Sans CJK SC", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* 衬线 = 她的声音。
   *
   * 顺序不是随手排的：**中日韩衬线族必须排在前面**。
   * 浏览器是「逐字符回退」：Latin 走 Iowan/Georgia，中文走宋体。
   * 但如果把「本机没有的族」放前面，Linux 上 fontconfig 会拿默认字体顶替
   * （实测："Songti SC" 在 Linux 上被顶替成黑体 → 中文悄悄掉回无衬线，
   * 「她的声音」这个设计就整个失效了）。
   * 所以第一顺位是覆盖最广的 Noto Serif CJK SC（Linux 桌面 / 容器里普遍有），
   * macOS 会跳过它落到 Songti SC，Windows 落到 SimSun。
   */
  --font-her: "Noto Serif CJK SC", "Source Han Serif SC", "Songti SC",
    "Iowan Old Style", "Palatino Linotype", Palatino, Georgia,
    "Noto Serif SC", SimSun, serif;
  /* 等宽 = 元数据 */
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

/* =====================================================================
 * 基础
 * =================================================================== */

* { box-sizing: border-box; }

/* hidden 属性必须真正隐藏。
 *
 * 背景：.login / .app / .page / .search-overlay 都是 `display: flex`，
 * 它们的类选择器优先级高于浏览器默认样式表里的 `[hidden] { display: none }`，
 * 于是「加了 hidden 属性的元素依然可见、依然能被命中」。
 * 规则：任何带 hidden 属性的元素一律不参与布局、不响应指针命中。
 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--base);
  color: var(--paper);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* 三个视图是 body 的同级 flex 项：#login-view / #app-view / #page-console。
 * 顶栏 #topbar 是外壳（flex: none）。 */
body { display: flex; flex-direction: column; }

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
a { color: var(--safelight); }

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

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2b323b; border-radius: 0; }
::-webkit-scrollbar-thumb:hover { background: #3a4350; }

/* 可见的键盘焦点（暗底上不能用默认的 outline 颜色）。 */
:focus-visible {
  outline: 2px solid var(--safelight);
  outline-offset: 1px;
}

/* =====================================================================
 * 排版基元
 * =================================================================== */

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.005em; }
p { margin: 0; }

.boot { padding: 48px; text-align: center; color: var(--paper-faint); }

.muted { color: var(--paper-dim); }
.small { font-size: 12px; }
.hidden-input { display: none; }
.only-narrow { display: none; }

.stack > * + * { margin-top: 12px; }

.sub-title {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--paper-faint);
  font-family: var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.prose { line-height: 1.8; }
.pre-wrap { white-space: pre-wrap; }
pre {
  margin: 0; padding: 10px 12px; overflow: auto;
  background: var(--base); border: 1px solid var(--edge-soft); border-radius: var(--radius);
  font-family: var(--mono); font-size: 12px; line-height: 1.6; color: var(--paper-dim);
}

/* =====================================================================
 * 顶栏：机器头
 * =================================================================== */

.topbar {
  flex: none; height: 48px; display: flex; align-items: center; gap: 12px;
  padding: 0 14px; background: var(--base-2);
  border-bottom: 1px solid var(--edge-soft);
}

.brand {
  background: none; border: none; cursor: pointer; padding: 4px 2px;
  font-family: var(--mono); font-size: 13px; font-weight: 600;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--paper);
}
.brand:hover { color: var(--safelight); }

.topbar-mid { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

/* 状态标签：像贴在机器上的小标签片。 */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--edge); background: transparent; color: var(--paper-dim);
  border-radius: var(--radius-sm); padding: 3px 9px; font-size: 12px; cursor: pointer;
}
.chip:hover { border-color: var(--safelight-edge); color: var(--paper); }
.chip kbd {
  font-family: var(--mono); font-size: 10.5px; color: var(--paper-faint);
  border: 1px solid var(--edge-soft); border-radius: 2px; padding: 0 3px;
}

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 28px; height: 28px; padding: 0 6px;
  border: 1px solid transparent; background: transparent; color: var(--paper-dim);
  border-radius: var(--radius-sm); cursor: pointer; font-size: 14px;
}
.icon-btn:hover { background: var(--emulsion-2); color: var(--paper); }

.user-menu-wrap { position: relative; }
.user-btn {
  border: 1px solid var(--edge); background: transparent; color: var(--paper-dim);
  border-radius: var(--radius-sm); padding: 4px 10px; cursor: pointer; font-size: 12.5px;
}
.user-btn:hover { border-color: var(--safelight-edge); color: var(--paper); }
.user-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 70; min-width: 152px;
  background: var(--emulsion); border: 1px solid var(--edge); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 4px; display: flex; flex-direction: column;
}
.user-menu button {
  border: none; background: transparent; color: var(--paper-dim); text-align: left;
  padding: 6px 9px; border-radius: var(--radius-sm); cursor: pointer; font-size: 13px;
}
.user-menu button:hover { background: var(--emulsion-2); color: var(--paper); }
.user-menu hr { border: none; border-top: 1px solid var(--edge-soft); margin: 4px 0; }

/* =====================================================================
 * 登录
 * =================================================================== */

.login {
  flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center;
  padding: 24px; background:
    radial-gradient(120% 90% at 50% 0%, rgba(224, 145, 60, 0.05), transparent 62%),
    var(--base);
}

.login-card {
  position: relative; overflow: hidden;
  width: 100%; max-width: 348px; padding: 30px 26px 24px;
  background: var(--emulsion); border: 1px solid var(--edge); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
/* 卡片顶边的一排齿孔 —— 进门就是一条胶片（与记忆片格同一套齿孔语言）。 */
.login-perf {
  position: absolute; top: 0; left: 0; right: 0; height: 8px;
  background-color: var(--edge);
  background-image: repeating-linear-gradient(90deg,
    var(--base) 0 5px, transparent 5px 14px);
  pointer-events: none;
}
.login-title {
  font-size: 19px; letter-spacing: 0.2em; font-weight: 600;
  font-family: var(--mono); text-transform: uppercase;
}
.login-sub { margin: 5px 0 20px; font-size: 12px; color: var(--paper-faint); }

.login-error {
  min-height: 18px; margin: 10px 0 0; font-size: 12.5px; color: var(--fixer);
}
.login-actions { display: flex; gap: 8px; margin-top: 14px; }
.login-hint { margin: 14px 0 0; font-size: 11.5px; color: var(--paper-faint); line-height: 1.6; }

/* =====================================================================
 * 表单
 * =================================================================== */

.field { display: block; margin-bottom: 12px; }
.field-label {
  display: block; margin-bottom: 5px; font-size: 11.5px; color: var(--paper-dim);
  font-family: var(--mono); letter-spacing: 0.06em;
}
.field-hint { margin-top: 4px; font-size: 11.5px; color: var(--paper-faint); }

input, textarea, select {
  width: 100%; padding: 8px 10px;
  background: var(--base); border: 1px solid var(--edge); border-radius: var(--radius-sm);
  outline: none; transition: border-color .15s ease, background .15s ease;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--safelight-dim);
  background: var(--base-2);
}
textarea { resize: vertical; line-height: 1.65; }
input::placeholder, textarea::placeholder { color: var(--paper-faint); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.span-2 { grid-column: span 2; }

/* 只读值：表单里的「当前值」展示（如 B 站接入面板的登录态 / UID / 护栏开关）。
   用等宽字体 —— 这些都是元数据，不是正文。 */
.value {
  display: flex; align-items: center; min-height: 35px;
  padding: 8px 10px; background: var(--base);
  border: 1px solid var(--edge-soft); border-radius: var(--radius-sm);
  color: var(--paper-dim); font-family: var(--mono); font-size: 12.5px;
}

.checkbox-row, .switch-row {
  display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--paper-dim);
}
.switch-row { gap: 8px; }
.switch-track {
  width: 34px; height: 18px; border-radius: 9px; background: var(--base-2);
  border: 1px solid var(--edge); position: relative; flex: none; cursor: pointer;
}
.switch-thumb {
  position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--paper-faint); transition: transform .16s ease, background .16s ease;
}
.switch-input:checked ~ .switch-track { border-color: var(--safelight-dim); }
.switch-input:checked ~ .switch-track .switch-thumb {
  transform: translateX(16px); background: var(--safelight);
}
.switch-input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-label { font-size: 13px; color: var(--paper-dim); }

.checkbox { accent-color: var(--safelight); width: 14px; height: 14px; }

/* =====================================================================
 * 按钮
 * =================================================================== */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 14px; border: 1px solid var(--edge); background: var(--emulsion-2);
  color: var(--paper-dim); border-radius: var(--radius-sm); cursor: pointer;
  font-size: 13px; line-height: 1.4; transition: border-color .15s ease, color .15s ease, background .15s ease;
}
.btn:hover:not(:disabled) { border-color: var(--safelight-edge); color: var(--paper); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary {
  background: var(--safelight); border-color: var(--safelight); color: #16120b; font-weight: 500;
}
.btn-primary:hover:not(:disabled) { background: #ec9d45; border-color: #ec9d45; color: #16120b; }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; }
.btn-mini { padding: 2px 8px; font-size: 11.5px; }

.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* 会话列表里的最后一条摘要 */
.conv-preview {
  font-size: 11.5px; color: var(--paper-faint);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%;
}

/* 说明性的一行小字（面板里的操作提示） */
.hint {
  font-size: 11.5px; color: var(--paper-faint); line-height: 1.65;
  padding: 6px 9px; border-left: 2px solid var(--edge);
  background: var(--base-2); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* 状态点（渠道是否已绑定） */
.dot {
  width: 6px; height: 6px; border-radius: 50%; flex: none;
  display: inline-block; border: 1px solid var(--edge);
}
.dot-on { background: var(--halide); border-color: var(--halide); }
.dot-off { background: transparent; border-color: var(--edge); }

/* 通用换行容器 */
.wrap { overflow-wrap: anywhere; }

/* 分段控件：像一排拨档。 */
.seg { display: inline-flex; border: 1px solid var(--edge); border-radius: var(--radius-sm); overflow: hidden; }
.seg-btn {
  border: none; background: transparent; color: var(--paper-dim); cursor: pointer;
  padding: 4px 12px; font-size: 12.5px; border-right: 1px solid var(--edge);
}
.seg-btn:last-child { border-right: none; }
.seg-btn.is-active { background: var(--safelight-wash); color: var(--safelight); }
.seg-btn:hover:not(.is-active) { background: var(--emulsion-2); color: var(--paper); }

/* =====================================================================
 * 聊天页
 * =================================================================== */

.app { flex: 1; min-height: 0; display: flex; }
.page { flex: 1; min-height: 0; display: flex; }
.page-chat { flex-direction: row; }

/* 左侧：胶片条（角色 + 会话） */
.sidebar {
  width: 224px; flex: none; display: flex; flex-direction: column;
  border-right: 1px solid var(--edge-soft); background: var(--base-2);
  overflow: hidden;
}
.side-block { padding: 10px; border-bottom: 1px solid var(--edge-soft); }
.side-grow { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.side-foot { border-bottom: none; border-top: 1px solid var(--edge-soft); }
.side-title {
  font-size: 10.5px; color: var(--paper-faint); margin-bottom: 7px;
  font-family: var(--mono); letter-spacing: 0.12em; text-transform: uppercase;
}

.bot-list, .conv-list { overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }

/* 角色条 = 一段竖着的胶片：左右两侧各一列齿孔。
 *
 * 齿孔要能看见，胶片边条就得比背景亮（深色底上「洞」= 更暗的缺口，
 * 边条本身是稍亮的金属灰）。列表左右各留 7px 内边距，
 * 免得选中态的琥珀色左标和边条撞在一起。 */
.bot-list {
  position: relative; padding: 5px 7px;
  border-left: 3px solid transparent; border-right: 3px solid transparent;
}
.bot-list::before, .bot-list::after {
  content: ""; position: absolute; top: 0; bottom: 0; width: 4px;
  background-color: var(--edge);
  background-image: repeating-linear-gradient(180deg,
    var(--base) 0 5px, transparent 5px 14px);
  pointer-events: none;
}
.bot-list::before { left: 0; }
.bot-list::after { right: 0; }

.bot-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 5px 8px; border: none; border-left: 2px solid transparent;
  background: transparent; cursor: pointer; text-align: left; color: var(--paper-dim);
}
.bot-item:hover { background: var(--emulsion); color: var(--paper); }
.bot-item.is-active {
  background: var(--emulsion); color: var(--paper);
  border-left-color: var(--safelight);
}
.bot-avatar {
  width: 22px; height: 22px; border-radius: 2px; object-fit: cover; flex: none;
  border: 1px solid var(--edge);
}
.bot-avatar-fallback {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--emulsion-2); font-size: 11px; color: var(--paper-dim);
  font-family: var(--mono);
}
.bot-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.conv-item {
  display: flex; flex-direction: column; gap: 1px; width: 100%;
  padding: 6px 8px; border: 1px solid transparent; border-left: 2px solid transparent;
  background: transparent; cursor: pointer; text-align: left; color: var(--paper-dim);
}
.conv-item:hover { background: var(--emulsion); color: var(--paper); }
.conv-item.is-active { background: var(--emulsion); border-left-color: var(--safelight); color: var(--paper); }
.conv-title { font-size: 13px; color: var(--paper); }
.conv-time { font-size: 11px; color: var(--paper-faint); font-family: var(--mono); }

/* 右侧：一张大纸 */
.chat-main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }

.chat-head {
  flex: none; padding: 9px 18px; border-bottom: 1px solid var(--edge-soft);
  display: flex; align-items: baseline; gap: 10px;
}
.chat-title { font-size: 14px; font-weight: 600; }
.chat-sub { font-size: 12px; color: var(--paper-faint); font-family: var(--mono); }

.msg-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 20px 18px 10px; }
.msg-list { max-width: 860px; margin: 0 auto; display: flex; flex-direction: column; gap: 11px; }

.day-sep {
  display: flex; align-items: center; gap: 10px;
  color: var(--paper-faint); font-size: 10.5px; font-family: var(--mono); letter-spacing: 0.1em;
}
.day-sep::before, .day-sep::after { content: ""; flex: 1; height: 1px; background: var(--edge-soft); }
.day-sep span { white-space: nowrap; }

.msg { display: flex; flex-direction: column; gap: 3px; max-width: 78%; position: relative; }
.msg-user { align-self: flex-end; align-items: flex-end; }
.msg-assistant { align-self: flex-start; }
.msg-system { align-self: center; max-width: 90%; }

.bubble {
  padding: 10px 14px 20px; background: var(--emulsion);
  border: 1px solid var(--edge-soft); border-radius: var(--radius);
  word-break: break-word; position: relative;
}
/* 她的话：衬线 + 一道安全灯边 —— 字体与边线都在说「这是她」。 */
.msg-assistant .bubble {
  background: var(--emulsion);
  border-color: var(--edge-soft);
  border-left: 2px solid var(--safelight);
  font-family: var(--font-her);
  font-size: 15px;
  line-height: 1.85;
}
/* 你的话：无衬线、凹陷在片基里。 */
.msg-user .bubble {
  background: var(--base-2); border-color: var(--edge);
}
.msg-system .bubble {
  background: transparent; border-color: transparent; color: var(--paper-faint);
  font-family: var(--mono); font-size: 11.5px; padding: 2px 0;
}
.msg-deleted { color: var(--paper-faint); font-style: italic; }
.msg-text { white-space: pre-wrap; }
.msg-image { max-width: 260px; border-radius: 2px; display: block; border: 1px solid var(--edge); }
.msg-failed {
  margin-top: 5px; font-size: 11.5px; color: var(--fixer);
  font-family: var(--mono);
}

.msg-reasoning { margin-top: 7px; }
.msg-reasoning summary {
  cursor: pointer; font-size: 11.5px; color: var(--paper-faint); font-family: var(--mono);
}

/* 时间戳与操作按钮：绝对定位落在气泡底部的留白里。
 *
 * 之前它们是气泡的兄弟节点、按文档流占位 —— 即使悬停前完全透明，
 * 每个气泡底下也白白留着 25px，一屏对话能空掉三分之一。
 * 现在：气泡底部 padding 留出 20px 的「字幕条」，时间戳与操作按钮浮在上面，
 * 悬停才显形，不占布局。 */
.msg-meta {
  position: absolute; left: 14px; right: 14px; bottom: 3px; height: 14px;
  display: flex; align-items: center; gap: 8px; line-height: 1;
  pointer-events: none;
}
.msg-user .msg-meta { justify-content: flex-end; }
.msg-time {
  font-size: 10.5px; color: transparent; transition: color .15s ease;
  font-family: var(--mono); letter-spacing: 0.04em; pointer-events: auto;
}
.msg:hover .msg-time, .msg:focus-within .msg-time { color: var(--paper-faint); }
.msg-actions {
  display: flex; gap: 4px; opacity: 0; transition: opacity .15s ease;
  pointer-events: auto;
}
.msg:hover .msg-actions, .msg:focus-within .msg-actions { opacity: 1; }
.msg-act {
  border: none; background: transparent; color: var(--paper-faint); cursor: pointer;
  font-size: 10.5px; line-height: 1.4; padding: 0 4px; border-radius: 2px;
  font-family: var(--mono);
}
.msg-act:hover { color: var(--paper); background: var(--emulsion-2); }

.turn-indicator { display: flex; align-items: center; gap: 8px; color: var(--paper-faint); font-size: 12.5px; }
.turn-label { color: var(--paper-faint); }
.turn-silent { color: var(--paper-faint); font-size: 11.5px; }
.dots { display: inline-flex; gap: 4px; }
.dots i {
  width: 4px; height: 4px; border-radius: 50%; background: var(--safelight);
  animation: bounce 1.1s infinite ease-in-out;
}
.dots i:nth-child(2) { animation-delay: .15s; }
.dots i:nth-child(3) { animation-delay: .3s; }
/* 「正在输入」：三点，节奏比「思考中」更轻 */
.typing { display: inline-flex; gap: 3px; }
.typing i {
  width: 3px; height: 3px; border-radius: 50%; background: var(--paper-faint);
  animation: bounce 1.4s infinite ease-in-out;
}
.typing i:nth-child(2) { animation-delay: .18s; }
.typing i:nth-child(3) { animation-delay: .36s; }
@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .45; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.scroll-bottom {
  position: absolute; right: 22px; bottom: 118px; z-index: 20;
  width: 30px; height: 30px; border-radius: 50%;
  border: 1px solid var(--edge); background: var(--emulsion-2); color: var(--paper-dim);
  cursor: pointer; box-shadow: var(--shadow-sm);
}
.scroll-bottom:hover { border-color: var(--safelight-edge); color: var(--safelight); }

/* 写入口 = 接触印相的说明条（caption strip） */
.composer {
  flex: none; border-top: 1px solid var(--edge-soft); padding: 9px 18px 12px;
  background: var(--base-2);
}
.quick-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; }
.quick-toggle {
  border: 1px solid var(--edge); background: transparent; color: var(--paper-faint);
  border-radius: 999px; padding: 2px 9px; font-size: 11.5px; cursor: pointer; flex: none;
  font-family: var(--mono);
}
.quick-toggle:hover { border-color: var(--safelight-edge); color: var(--paper-dim); }
.quick-list { display: flex; gap: 6px; flex-wrap: wrap; }
.quick-list.is-collapsed { display: none; }
.quick-chip {
  border: 1px solid var(--edge-soft); background: var(--emulsion); color: var(--paper-dim);
  border-radius: 999px; padding: 2px 10px; font-size: 11.5px; cursor: pointer;
}
.quick-chip:hover { border-color: var(--safelight-edge); color: var(--paper); }

.composer-row { display: flex; align-items: flex-end; gap: 8px; max-width: 860px; margin: 0 auto; }
#composer-input {
  flex: 1; min-height: 38px; max-height: 180px; resize: none;
  padding: 9px 12px; border-radius: var(--radius);
  background: var(--base); border: 1px solid var(--edge); outline: none;
}
#composer-input:focus { border-color: var(--safelight-dim); }
.composer-hint {
  max-width: 860px; margin: 7px auto 0; font-size: 11px; color: var(--paper-faint);
  font-family: var(--mono);
}

/* =====================================================================
 * 控制台：档案柜
 * =================================================================== */

.page-console { flex-direction: row; }

.console-nav {
  width: 196px; flex: none; padding: 14px 0; overflow-y: auto;
  border-right: 1px solid var(--edge-soft); background: var(--base-2);
}
.nav-group + .nav-group { margin-top: 16px; }
.nav-group-title {
  padding: 0 16px 6px; font-size: 10.5px; color: var(--paper-faint);
  font-family: var(--mono); letter-spacing: 0.12em; text-transform: uppercase;
}
.nav-item {
  display: block; width: 100%; text-align: left; border: none;
  border-left: 2px solid transparent; background: transparent; color: var(--paper-dim);
  padding: 5px 16px; cursor: pointer; font-size: 13px;
}
.nav-item:hover { background: var(--emulsion); color: var(--paper); }
.nav-item.is-active {
  background: var(--emulsion); color: var(--paper); border-left-color: var(--safelight);
}

.console-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.panel-head {
  flex: none; padding: 13px 20px; border-bottom: 1px solid var(--edge-soft);
  display: flex; align-items: baseline; gap: 10px;
}
.panel-title { font-size: 16px; font-weight: 600; }
.panel-crumb {
  font-size: 10.5px; color: var(--paper-faint); font-family: var(--mono);
  letter-spacing: 0.1em; text-transform: uppercase;
}
.panel-body { flex: 1; min-height: 0; overflow-y: auto; padding: 18px 20px 40px; }

.panel-error {
  border: 1px solid var(--fixer); background: var(--fixer-wash);
  border-radius: var(--radius); padding: 12px 14px;
}
.panel-error-title { color: var(--fixer); font-size: 13px; font-weight: 600; }
.panel-error-msg { color: var(--paper-dim); font-size: 12.5px; margin-top: 3px; }

/* =====================================================================
 * 卡片与列表
 * =================================================================== */

.card {
  background: var(--emulsion); border: 1px solid var(--edge-soft);
  border-radius: var(--radius); margin-bottom: 14px;
}
.card-head {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-bottom: 1px solid var(--edge-soft);
}
.card-title { font-size: 13.5px; font-weight: 600; }
.card-body { padding: 14px; }

.list { display: flex; flex-direction: column; gap: 8px; }
.list-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  background: var(--emulsion); border: 1px solid var(--edge-soft); border-radius: var(--radius);
}
.list-item:hover { border-color: var(--edge); }
.list-item.is-active {
  border-color: var(--safelight-dim); background: var(--safelight-wash);
}
.list-item-title { font-size: 13px; color: var(--paper); }
.list-item-sub { font-size: 11.5px; color: var(--paper-faint); }

.badge {
  display: inline-flex; align-items: center; padding: 1px 7px; border-radius: 2px;
  font-size: 10.5px; font-family: var(--mono); letter-spacing: 0.04em;
  border: 1px solid var(--edge); color: var(--paper-dim); background: var(--base-2);
}
.badge-default { color: var(--paper-dim); }
.badge-ok { color: var(--halide); border-color: rgba(143, 167, 156, .4); background: var(--halide-wash); }
.badge-warn { color: var(--safelight); border-color: var(--safelight-edge); background: var(--safelight-wash); }
.badge-danger { color: var(--fixer); border-color: rgba(198, 72, 58, .45); background: var(--fixer-wash); }

.tag {
  display: inline-flex; align-items: center; padding: 1px 7px; border-radius: 2px;
  font-size: 11px; background: var(--emulsion-2); border: 1px solid var(--edge-soft);
  color: var(--paper-dim);
}
.tag-list { display: inline-flex; gap: 4px; flex-wrap: wrap; }

.empty {
  padding: 22px 14px; text-align: center; border: 1px dashed var(--edge);
  border-radius: var(--radius); background: var(--base-2);
}
.empty-text { color: var(--paper-faint); font-size: 12.5px; }

.loading { display: flex; align-items: center; gap: 8px; padding: 18px; color: var(--paper-faint); }
.loading-text { font-size: 12.5px; font-family: var(--mono); }
.spinner {
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid var(--edge); border-top-color: var(--safelight);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* =====================================================================
 * 签名元件：接触印相（contact sheet）
 * -------------------------------------------------------------------
 * 一条记忆 = 一个片格。片格号 = 它在时间序里的位置（CSS 计数器自动编号）。
 * 顶边是齿孔。被取代 / 被抑制的记忆 = 还没显影的潜影（低对比 + 轻微模糊）。
 * =================================================================== */

.list, .stack { counter-reset: frame; }

/* 紧凑行（联系人详情里的记忆摘要）—— 先定义，避免与下面的整格样式抢优先级。 */
.mem-row {
  display: flex; align-items: baseline; gap: 8px; padding: 4px 0;
  font-size: 12.5px; color: var(--paper-dim);
}
.mem-row .mem-cat { flex: none; }
.mem-row .mem-text {
  flex: 1; min-width: 0; margin-top: 0;
  font-family: var(--font-her); font-size: 13px; line-height: 1.7; color: var(--paper-dim);
}

.mem-row-full {
  position: relative; counter-increment: frame;
  display: flex; align-items: flex-start; gap: 12px;
  padding: 18px 12px 12px;
  background: var(--emulsion); border: 1px solid var(--edge-soft); border-radius: var(--radius);
  overflow: hidden;
  max-width: 1000px;
  animation: develop .34s ease both;
}
/* 顶边齿孔：一条稍亮的胶片边条，上面打出方孔。 */
.mem-row-full::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 8px;
  background-color: var(--edge);
  background-image: repeating-linear-gradient(90deg,
    var(--base) 0 5px, transparent 5px 14px);
  pointer-events: none;
}
/* 片格号：右下角（右上角让给操作按钮）。 */
.mem-row-full::after {
  content: counter(frame, decimal-leading-zero);
  position: absolute; bottom: 9px; right: 12px;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.1em;
  color: var(--paper-faint);
}

.mem-main { flex: 1; min-width: 0; }
.mem-head {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 11.5px; color: var(--paper-dim);
}
.mem-cat {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--safelight);
}
.mem-kind { font-family: var(--mono); font-size: 10.5px; color: var(--paper-faint); }
/* 记忆正文 —— 她的记忆，用衬线。 */
.mem-row-full .mem-text {
  margin-top: 5px; font-family: var(--font-her); font-size: 14.5px; line-height: 1.8;
  color: var(--paper); white-space: pre-wrap;
}
.mem-actions { display: flex; gap: 8px; flex: none; align-items: flex-start; }
/* 片格上的操作：不做成实心按钮框，改成等宽小字，安静一点。 */
.mem-actions .btn {
  border-color: transparent; background: transparent; color: var(--paper-faint);
  font-family: var(--mono); font-size: 11px; padding: 1px 3px;
}
.mem-actions .btn:hover {
  color: var(--safelight); border-color: var(--safelight-edge); background: var(--safelight-wash);
}

.mem-group { margin-bottom: 12px; }
.mem-group-title {
  font-size: 10.5px; color: var(--paper-faint); font-family: var(--mono);
  letter-spacing: 0.1em; text-transform: uppercase; margin-bottom: 7px;
  padding-bottom: 5px; border-bottom: 1px solid var(--edge-soft);
}

/* 潜影：被取代 / 已抑制的记忆还没显影出来。 */
.mem-row-full[data-state='superseded'],
.mem-row-full[data-state='suppressed'] {
  opacity: .42; filter: blur(1.2px);
}
.mem-row-full[data-state='superseded']:hover,
.mem-row-full[data-state='suppressed']:hover { opacity: .85; filter: none; }

@keyframes develop {
  from { opacity: .3; filter: blur(3px); }
  to { opacity: 1; filter: blur(0); }
}

/* 错峰显影：前若干片格依次浮现。 */
.mem-row-full:nth-child(1) { animation-delay: 0ms; }
.mem-row-full:nth-child(2) { animation-delay: 30ms; }
.mem-row-full:nth-child(3) { animation-delay: 60ms; }
.mem-row-full:nth-child(4) { animation-delay: 90ms; }
.mem-row-full:nth-child(5) { animation-delay: 120ms; }
.mem-row-full:nth-child(6) { animation-delay: 150ms; }
.mem-row-full:nth-child(7) { animation-delay: 180ms; }
.mem-row-full:nth-child(8) { animation-delay: 210ms; }
.mem-row-full:nth-child(n+9) { animation-delay: 240ms; }

/* =====================================================================
 * 统计 / 图表
 * =================================================================== */

.stat-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.stat {
  padding: 12px 13px; background: var(--emulsion);
  border: 1px solid var(--edge-soft); border-radius: var(--radius);
}
.stat-label {
  font-size: 10.5px; color: var(--paper-faint); font-family: var(--mono);
  letter-spacing: 0.1em; text-transform: uppercase;
}
.stat-value {
  margin-top: 4px; font-size: 22px; font-weight: 600; line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.stat-sub { font-size: 11.5px; color: var(--paper-dim); margin-top: 2px; }

.chart { width: 100%; }
.chart-svg { width: 100%; height: 132px; display: block; }
.chart-axis {
  display: flex; justify-content: space-between; gap: 6px; margin-top: 7px;
  color: var(--paper-faint); font-size: 10px; font-family: var(--mono);
}
.chart-tick {
  font-size: 9.5px; color: var(--paper-faint); font-family: var(--mono);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 22%;
}
.chart-bar rect.bar { fill: var(--safelight); }
.chart-hbar .hrow { display: flex; align-items: center; gap: 10px; padding: 3px 0; }
.chart-hbar .hrow-label { width: 110px; font-size: 12px; color: var(--paper-dim); }
.chart-hbar .hrow-track { flex: 1; height: 8px; background: var(--base-2); border-radius: 2px; overflow: hidden; }
.chart-hbar .hrow-fill { height: 100%; background: var(--safelight); }
.chart-hbar .hrow-fill.tone-ok { background: var(--halide); }
.chart-hbar .hrow-fill.tone-warn { background: var(--safelight); }
.chart-hbar .hrow-fill.tone-danger { background: var(--fixer); }
.chart-hbar .hrow-value {
  width: 62px; text-align: right; font-size: 11.5px; color: var(--paper-dim);
  font-family: var(--mono); font-variant-numeric: tabular-nums;
}

.progress { margin-top: 8px; }
.progress-track { height: 6px; background: var(--base-2); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--halide); }
.progress-fill.is-warn { background: var(--safelight); }
.progress-fill.is-over { background: var(--fixer); }
.progress-meta {
  margin-top: 5px; font-size: 11.5px; color: var(--paper-dim);
  display: flex; justify-content: space-between; font-family: var(--mono);
}
.degrade-note { margin-top: 8px; font-size: 11.5px; color: var(--safelight); }

/* 等级点阵（人格维度 1~5） */
.pips { display: inline-flex; gap: 3px; }
.pips .pip {
  width: 8px; height: 8px; border-radius: 1px; background: var(--emulsion-3);
  border: 1px solid var(--edge);
}
.pips .pip.on { background: var(--safelight); border-color: var(--safelight); }
.dims { display: flex; flex-direction: column; gap: 8px; }
.dim-row {
  display: flex; align-items: center; gap: 10px; padding: 7px 0;
  border-bottom: 1px solid var(--edge-soft);
}
.dim-head { display: flex; align-items: center; gap: 8px; width: 150px; flex: none; }
.dim-key { font-size: 12.5px; color: var(--paper-dim); }
.dim-level { font-family: var(--mono); font-size: 11px; color: var(--paper-faint); }
.dim-desc { font-size: 12px; color: var(--paper-faint); flex: 1; min-width: 0; }

/* =====================================================================
 * 成长 / 提案 / 变更
 * ===================================================================== */

.change {
  border: 1px solid var(--edge-soft); border-radius: var(--radius);
  padding: 10px 12px; background: var(--base-2);
}
.change + .change { margin-top: 8px; }
.change-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.change-dim { font-size: 12.5px; color: var(--paper); }
.change-delta {
  font-family: var(--mono); font-size: 11.5px; color: var(--safelight);
  font-variant-numeric: tabular-nums;
}
.change-desc { margin-top: 4px; font-size: 12.5px; color: var(--paper-dim); }
.excerpts { margin-top: 8px; }
.excerpts-title {
  font-size: 10.5px; color: var(--paper-faint); font-family: var(--mono);
  letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 4px;
}
.excerpt {
  border-left: 2px solid var(--edge); padding: 3px 0 3px 10px; margin-bottom: 5px;
  font-family: var(--font-her); font-size: 13px; color: var(--paper-dim); line-height: 1.75;
}

.proposal {
  border: 1px solid var(--edge-soft); border-radius: var(--radius);
  background: var(--emulsion); padding: 12px;
}
.proposal + .proposal { margin-top: 8px; }
.proposal-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.proposal-edit { margin-top: 9px; }
.inline-edit { margin-top: 8px; display: flex; flex-direction: column; gap: 8px; }

/* =====================================================================
 * 日记 / 相册 / 提示词层
 * ===================================================================== */

.diary { border-left: 2px solid var(--safelight-edge); padding: 2px 0 2px 12px; margin-bottom: 14px; }
.diary-head { display: flex; align-items: baseline; gap: 9px; }
.diary-date { font-family: var(--mono); font-size: 11px; color: var(--safelight); letter-spacing: 0.06em; }
/* 她的日记 —— 衬线。 */
.diary .pre-wrap, .diary-body {
  font-family: var(--font-her); font-size: 14.5px; line-height: 1.85; color: var(--paper);
  white-space: pre-wrap; margin-top: 4px;
}

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px; }
.photo-cell {
  border: 1px solid var(--edge-soft); border-radius: var(--radius);
  background: var(--emulsion); overflow: hidden;
}
.photo-img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; display: block; background: var(--base-2); }
.photo-missing {
  aspect-ratio: 1 / 1; display: flex; align-items: center; justify-content: center;
  color: var(--paper-faint); font-size: 12px; background: var(--base-2);
}
.photo-caption { padding: 7px 9px; font-size: 12px; color: var(--paper-dim); }

.layer {
  border: 1px solid var(--edge-soft); border-radius: var(--radius);
  background: var(--emulsion); padding: 10px 12px;
}
.layer + .layer { margin-top: 8px; }
.layer-head { display: flex; align-items: center; gap: 9px; }
.layer-name { font-size: 12.5px; color: var(--paper); }
.layer-meta { font-size: 10.5px; color: var(--paper-faint); font-family: var(--mono); }

.kv-row {
  display: flex; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--edge-soft);
  font-size: 12.5px;
}
.kv-key { width: 148px; flex: none; color: var(--paper-faint); font-family: var(--mono); font-size: 11.5px; }
.kv-val { flex: 1; min-width: 0; word-break: break-word; }

/* =====================================================================
 * 表格
 * ===================================================================== */

.table-wrap { overflow-x: auto; border: 1px solid var(--edge-soft); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.table th, .table td {
  text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--edge-soft);
  vertical-align: top;
}
.table th {
  color: var(--paper-faint); font-weight: 500; font-family: var(--mono);
  font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase;
  background: var(--base-2);
}
.table tr:last-child td { border-bottom: none; }

/* =====================================================================
 * 弹层：模态 / 抽屉 / 搜索 / 吐司
 * ===================================================================== */

.modal-overlay {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  background: rgba(8, 9, 11, .66); padding: 20px;
}
.modal {
  width: 100%; max-width: 560px; max-height: 86vh; display: flex; flex-direction: column;
  background: var(--emulsion); border: 1px solid var(--edge); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.modal-wide { max-width: 860px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--edge-soft);
}
.modal-title { font-size: 14px; font-weight: 600; }
.modal-body { padding: 16px; overflow-y: auto; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px;
  border-top: 1px solid var(--edge-soft);
}
.confirm-text { white-space: pre-wrap; }
.voice-text pre { max-height: 50vh; }

.drawer-overlay {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0; inset: 0; z-index: 55;
  background: rgba(8, 9, 11, .55);
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 92vw); z-index: 56;
  display: flex; flex-direction: column;
  background: var(--emulsion); border-left: 1px solid var(--edge);
  box-shadow: var(--shadow);
}
.drawer-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 13px 16px; border-bottom: 1px solid var(--edge-soft);
}
.drawer-title { font-size: 14px; font-weight: 600; }
.drawer-body { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; }
.drawer-foot { padding: 12px 16px; border-top: 1px solid solid var(--edge-soft); border-top: 1px solid var(--edge-soft); }

.toast-root {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px; max-width: 90vw;
  padding: 9px 14px; border-radius: var(--radius);
  background: var(--emulsion-2); border: 1px solid var(--edge); color: var(--paper);
  box-shadow: var(--shadow-sm); font-size: 13px; pointer-events: auto;
}
.toast-msg { flex: 1; }
.toast-success { border-color: rgba(143, 167, 156, .45); }
.toast-error { border-color: rgba(198, 72, 58, .5); }
.toast-action {
  border: none; background: transparent; color: var(--safelight); cursor: pointer;
  white-space: nowrap; font-size: 12.5px;
}

.search-overlay {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0; inset: 0; z-index: 70;
  display: flex; flex-direction: column; align-items: center;
  background: rgba(8, 9, 11, .72); padding: 12vh 16px 16px;
}
.search-box {
  width: 100%; max-width: 620px; display: flex; gap: 8px; align-items: center;
}
.search-box input { flex: 1; padding: 11px 14px; font-size: 15px; }
.search-results {
  width: 100%; max-width: 620px; max-height: 62vh; overflow-y: auto; margin-top: 12px;
}
.search-bucket { margin-bottom: 14px; }
.search-bucket-title {
  font-size: 10.5px; color: var(--paper-faint); font-family: var(--mono);
  letter-spacing: 0.1em; text-transform: uppercase; margin-bottom: 6px;
}
.search-item {
  display: block; width: 100%; text-align: left; border: 1px solid var(--edge-soft);
  background: var(--emulsion); border-radius: var(--radius); padding: 8px 11px;
  margin-bottom: 6px; cursor: pointer; color: var(--paper-dim);
}
.search-item:hover { border-color: var(--safelight-edge); color: var(--paper); }
.search-item-text { font-size: 13px; }
.search-item mark { background: var(--safelight-wash); color: var(--safelight); }

.hit-row {
  display: flex; align-items: center; gap: 10px; padding: 7px 0;
  border-bottom: 1px solid var(--edge-soft);
}
.hit-name { font-size: 13px; color: var(--paper); }
.hit-meta { font-size: 11.5px; color: var(--paper-faint); font-family: var(--mono); }

/* =====================================================================
 * 工具条 / 其它
 * ===================================================================== */

.tool-chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px;
  border: 1px solid var(--edge-soft); border-radius: 2px; background: var(--base-2);
  font-size: 11px; color: var(--paper-dim); font-family: var(--mono);
}
.toolbar .tool-chip { margin-right: 4px; }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.split-left, .split-right { min-width: 0; }

.dropzone {
  border: 1px dashed var(--edge); border-radius: var(--radius); padding: 18px;
  text-align: center; color: var(--paper-faint); font-size: 12.5px; background: var(--base-2);
  transition: border-color .15s ease, color .15s ease;
}
.dropzone.is-over { border-color: var(--safelight); color: var(--safelight); }

.appearance-preview {
  border: 1px solid var(--edge-soft); border-radius: var(--radius);
  background: var(--base-2); padding: 12px;
}
.bot-avatar-lg { width: 72px; height: 72px; border-radius: 3px; border: 1px solid var(--edge); }

.review { display: flex; flex-direction: column; gap: 8px; }
.turn-label { font-family: var(--mono); font-size: 11px; }

/* =====================================================================
 * 响应式
 * ===================================================================== */

@media (max-width: 900px) {
  .only-narrow { display: inline-flex; }
  .split { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 48px; bottom: 0; left: 0; z-index: 45;
    transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow);
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .console-nav {
    width: 100%; flex: none; display: flex; gap: 14px; overflow-x: auto;
    border-right: none; border-bottom: 1px solid var(--edge-soft); padding: 8px 12px;
  }
  .nav-group + .nav-group { margin-top: 0; }
  .nav-group { display: flex; align-items: center; gap: 6px; }
  .nav-group-title { display: none; }
  .nav-item { width: auto; white-space: nowrap; border-left: none; border-bottom: 2px solid transparent; padding: 4px 8px; }
  .nav-item.is-active { border-left: none; border-bottom-color: var(--safelight); }
  .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
}

@media (max-width: 560px) {
  .topbar-mid .chip kbd { display: none; }
  .stat-row { grid-template-columns: 1fr 1fr; }
  .hrow-label { width: 84px; }
  .msg { max-width: 92%; }
  .msg-assistant .bubble { font-size: 14.5px; }
  .mem-row-full { flex-direction: column; gap: 8px; }
  .mem-actions { align-self: flex-end; }
  /* 窄屏上 placeholder 会折行，输入框要留够两行的高度，否则文字被裁掉。 */
  #composer-input { min-height: 46px; }
  .composer { padding: 8px 12px 10px; }
}

/* =====================================================================
 * 动效克制
 * ===================================================================== */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  .mem-row-full { animation: none; opacity: 1; filter: none; }
}

/* =====================================================================
 * 兼容性回退：flex 的 gap（Chrome 84+ / Firefox 63+ / Safari 14.1+）
 * =====================================================================
 * flex 容器的 gap 在老 Safari（≤14.0）上不生效 → 元素会挤在一起。
 * 用 @supports 给主要布局容器补一份 margin 版间距；
 * 支持 gap 的浏览器完全不受影响（gap 优先级更高）。
 */
@supports not (gap: 1px) {
  .row-between > * + * { margin-left: 12px; }
  .checkbox-row > * + * { margin-left: 6px; }
  .switch-row > * + * { margin-left: 8px; }
  .toolbar > * + * { margin-left: 8px; }
  .card-head > * + * { margin-left: 12px; }
  .tag-list > * + * { margin-left: 4px; }
  .loading > * + * { margin-left: 8px; }
  .chart-hbar .hrow > * + * { margin-left: 10px; }
  .pips > * + * { margin-left: 3px; }
  .dim-head > * + * { margin-left: 8px; }
  .login-actions > * + * { margin-left: 8px; }
  .topbar > * + * { margin-left: 12px; }
  .topbar-mid > * + * { margin-left: 8px; }
  .chip > * + * { margin-left: 6px; }
  .bot-item > * + * { margin-left: 8px; }
  .conv-item > * + * { margin-top: 1px; }
  .msg-list > * + * { margin-top: 14px; }
  .day-sep > * + * { margin-left: 10px; }
  .msg > * + * { margin-top: 3px; }
  .msg-meta > * + * { margin-left: 8px; }
  .mem-row-full > * + * { margin-left: 12px; }
  .mem-head > * + * { margin-left: 8px; }
  .mem-actions > * + * { margin-left: 6px; }
  .quick-bar > * + * { margin-left: 8px; }
  .quick-list > * + * { margin-left: 6px; }
  .composer-row > * + * { margin-left: 8px; }
  .msg-actions > * + * { margin-left: 4px; }
  .dots > * + * { margin-left: 4px; }
  .turn-indicator > * + * { margin-left: 8px; }
  .stat-row > * + * { margin-left: 10px; }
  .card-head > * + * { margin-left: 12px; }
  .layer-head > * + * { margin-left: 9px; }
  .proposal-head > * + * { margin-left: 8px; }
  .change-head > * + * { margin-left: 8px; }
  .dim-row > * + * { margin-left: 10px; }
  .modal-foot > * + * { margin-left: 8px; }
  .toast > * + * { margin-left: 10px; }
  .search-box > * + * { margin-left: 8px; }
  .panel-head > * + * { margin-left: 10px; }
  .chat-head > * + * { margin-left: 10px; }
  .hit-row > * + * { margin-left: 10px; }
  .btn > * + * { margin-left: 6px; }
  .user-menu > * + * { margin-top: 2px; }
}
