:root {
  --bg: #ffffff;
  --bg-soft: #f7f7f5;
  --bg-sink: #f1efea;
  --line: #e4e2dc;
  --line-strong: #d3d1c7;
  --text: #2c2c2a;
  --text-soft: #5f5e5a;
  --text-dim: #8a8983;
  --accent: #185fa5;
  --accent-soft: #e6f1fb;
  --warn: #854f0b;
  --warn-soft: #faeeda;
  --err: #a32d2d;
  --err-soft: #fcebeb;
  --ok: #0f6e56;
  --ok-soft: #e1f5ee;
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

.hidden { display: none !important; }
.muted { color: var(--text-dim); font-size: 13px; }
.error { color: var(--err); font-size: 13px; min-height: 18px; margin: 0; }
.row { display: flex; align-items: center; gap: 8px; }

button {
  font: inherit;
  border: 1px solid var(--line-strong);
  background: var(--bg);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 14px;
  cursor: pointer;
}
button:hover { background: var(--bg-soft); }
button:disabled { opacity: .5; cursor: default; }
button.ghost { border-color: transparent; background: transparent; color: var(--text-soft); padding: 4px 8px; }
button.ghost:hover { background: var(--bg-sink); }

.login {
  height: 100%;
  display: grid;
  place-items: center;
  background: var(--bg-soft);
  padding: 20px;
}
.login-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px;
  width: min(360px, 100%);
  display: grid;
  gap: 14px;
}
.login-card h1 { margin: 0; font-size: 20px; font-weight: 500; }
.login-card p { margin: 0; }
.login-card label { display: grid; gap: 6px; font-size: 13px; color: var(--text-soft); }
.login-card input {
  font: inherit;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--bg);
}
.login-card button { background: var(--accent); color: #fff; border-color: var(--accent); padding: 10px; }
.login-card button:hover { background: #134b83; }

.layout { display: grid; grid-template-columns: 268px 1fr; height: 100%; }

.sidebar {
  border-right: 1px solid var(--line);
  background: var(--bg-soft);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.sidebar-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 12px 8px 16px;
}
.sidebar-head strong { font-weight: 500; font-size: 13px; color: var(--text-soft); }
.filter {
  margin: 0 12px 8px;
  font: inherit;
  font-size: 13px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
}
.thread-list { overflow-y: auto; padding: 0 8px 16px; flex: 1; min-height: 0; }
.thread-item {
  position: relative;
  padding: 9px 26px 9px 30px;
  border-radius: 8px;
  cursor: pointer;
  display: grid;
  gap: 2px;
  margin-bottom: 2px;
}
.thread-item:hover { background: var(--bg-sink); }
/* 选中的会话：更深的底色 + 左侧蓝色指示条，一眼可辨 */
.thread-item.active {
  background: #cfdef2;
  box-shadow: inset 3px 0 0 var(--accent);
}
.thread-item.active .t { font-weight: 600; }
/* 会话行左侧的展开箭头 */
.thread-exp {
  position: absolute;
  left: 3px;
  top: 7px;
  width: 22px;
  height: 22px;
  padding: 0;
  line-height: 1;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--text-dim);
  font-size: 14px;
  cursor: pointer;
}
.thread-item.active .thread-exp { color: var(--accent); }
.thread-exp:hover { background: var(--line-strong); color: var(--text); }
/* 侧栏会话行下面展开的文件列表 */
.thread-files {
  margin: 0 0 4px 10px;
  padding: 4px 0 4px 10px;
  border-left: 2px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.side-file {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  min-width: 0;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 3px 6px;
  border-radius: 5px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.side-file:hover { background: var(--bg-sink); }
.side-file.dir { color: var(--accent); }
.side-file .sf-size { color: var(--text-dim); font-size: 10px; margin-left: auto; padding-left: 6px; }
.side-files-msg { font-size: 11px; color: var(--text-dim); padding: 4px 6px; }
.thread-item .t { font-size: 13px; line-height: 1.4; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.thread-item .s { font-size: 11px; color: var(--text-dim); }

/* 每行的「更多」按钮：平时隐藏，hover 或已选中时出现 */
.thread-menu-btn {
  position: absolute;
  top: 6px;
  right: 4px;
  width: 20px;
  height: 20px;
  padding: 0;
  line-height: 1;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--text-dim);
  font-size: 15px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s;
}
.thread-item:hover .thread-menu-btn,
.thread-item.active .thread-menu-btn { opacity: 1; }
.thread-menu-btn:hover { background: var(--line); color: var(--text); }

.thread-menu {
  position: absolute;
  top: 24px;
  right: 4px;
  z-index: 30;
  min-width: 108px;
  padding: 4px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--bg);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.16);
  display: flex;
  flex-direction: column;
}
.thread-menu button {
  border: 0;
  background: transparent;
  text-align: left;
  padding: 6px 9px;
  border-radius: 5px;
  font-size: 12.5px;
  color: var(--text);
  cursor: pointer;
}
.thread-menu button:hover { background: var(--bg-sink); }
.thread-menu button.danger { color: var(--err, #c0392b); }
.thread-menu button.danger:hover { background: var(--err-soft, #fdecea); }

.rename-input {
  font: inherit;
  font-size: 13px;
  width: 100%;
  box-sizing: border-box;
  padding: 2px 6px;
  border: 1px solid var(--accent);
  border-radius: 5px;
  background: var(--bg);
  color: var(--text);
  outline: none;
}

.archive-toggle {
  margin: 8px 10px 0;
  padding: 6px 10px;
  font-size: 12px;
  text-align: left;
  border: 1px dashed var(--line-strong);
  border-radius: 7px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
}
.archive-toggle:hover { background: var(--bg-sink); color: var(--text); }
.archive-toggle.on { border-style: solid; border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

.main { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.thread-title { font-weight: 500; font-size: 14px; }
.thread-meta { font-size: 11px; color: var(--text-dim); font-family: var(--mono); }

.conn { font-size: 11px; padding: 3px 8px; border-radius: 999px; background: var(--bg-sink); color: var(--text-dim); }
.conn.on { background: var(--ok-soft); color: var(--ok); }
.conn.retry { background: var(--warn-soft); color: var(--warn); }

.stream { flex: 1; overflow-y: auto; padding: 20px 20px 8px; min-height: 0; }

.msg { margin-bottom: 18px; display: flex; gap: 10px; }
.msg .body { max-width: min(760px, 100%); min-width: 0; }

.msg.user { justify-content: flex-end; }
.msg.user .body {
  background: var(--accent-soft);
  border: 1px solid #cfe2f5;
  border-radius: 12px;
  padding: 10px 14px;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg.agent .body { padding: 2px 0; }
.msg.agent .markdown { word-break: break-word; }

.avatar {
  width: 24px; height: 24px; border-radius: 6px; flex: none;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 500;
  background: var(--bg-sink); color: var(--text-soft);
}

.markdown p { margin: 0 0 10px; }
.markdown p:last-child { margin-bottom: 0; }
.markdown ul, .markdown ol { margin: 0 0 10px; padding-left: 22px; }
.markdown li { margin: 2px 0; }
.markdown code {
  font-family: var(--mono);
  font-size: 12.5px;
  background: var(--bg-sink);
  padding: 1px 5px;
  border-radius: 4px;
}
.markdown pre {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  overflow-x: auto;
  margin: 0 0 10px;
}
.markdown pre code { background: none; padding: 0; font-size: 12.5px; line-height: 1.55; }
.markdown a { color: var(--accent); }
.markdown h1, .markdown h2, .markdown h3 { font-size: 14px; font-weight: 500; margin: 14px 0 8px; }
.markdown blockquote { margin: 0 0 10px; padding-left: 12px; border-left: 3px solid var(--line-strong); color: var(--text-soft); }

details.fold {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-soft);
  margin-bottom: 12px;
  overflow: hidden;
}
details.fold > summary {
  cursor: pointer;
  padding: 8px 12px;
  font-size: 12.5px;
  color: var(--text-soft);
  list-style: none;
  display: flex;
  gap: 8px;
  align-items: center;
}
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::before { content: "▸"; font-size: 10px; color: var(--text-dim); }
details.fold[open] > summary::before { content: "▾"; }
details.fold .fold-body { padding: 0 12px 12px; }
details.fold pre {
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 340px;
  overflow: auto;
  color: var(--text-soft);
}

.tag {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--bg-sink);
  color: var(--text-soft);
  font-family: var(--mono);
}
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.err { background: var(--err-soft); color: var(--err); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }

.notice {
  font-size: 12.5px;
  padding: 8px 12px;
  border-radius: 8px;
  margin-bottom: 12px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--text-soft);
  white-space: pre-wrap;
  word-break: break-word;
}
.notice.error { background: var(--err-soft); border-color: #f3cccc; color: var(--err); }
/* 失败原因下方的处理建议，字号小一点、不和错误正文抢注意力 */
.notice .err-tip { margin-top: 6px; font-size: 12px; line-height: 1.6; color: #7a5a56; }
.notice.warning { background: var(--warn-soft); border-color: #f0dfb8; color: var(--warn); }

/* 等待 Codex 响应时的提示条：三点跳动 + 当前阶段 + 已等待时长 */
.pending-box {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-radius: 10px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--text-soft);
  font-size: 12.5px;
}
.pending-box .dots { display: inline-flex; gap: 3px; }
.pending-box .dots i {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent);
  opacity: 0.35;
  animation: dotPulse 1.2s infinite ease-in-out;
}
.pending-box .dots i:nth-child(2) { animation-delay: 0.18s; }
.pending-box .dots i:nth-child(3) { animation-delay: 0.36s; }
@keyframes dotPulse {
  0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}
.pending-box .pending-time {
  font-size: 11px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  border-left: 1px solid var(--line);
  padding-left: 10px;
}

/* 审批卡片：点击允许/拒绝后按钮置灰、不可再点 */
.notice button.ap-done {
  opacity: 0.55;
  cursor: not-allowed;
  filter: grayscale(1);
}
.notice button.ap-done.chosen {
  opacity: 0.85;
  filter: grayscale(0);
  font-weight: 600;
}
.notice button.ap-done.chosen.deny { color: var(--err); }

.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0;
  color: var(--text-dim);
  font-size: 11px;
}
.divider::before, .divider::after { content: ""; height: 1px; background: var(--line); flex: 1; }

.streaming::after {
  content: "";
  display: inline-block;
  width: 7px; height: 14px;
  margin-left: 2px;
  background: var(--accent);
  vertical-align: -2px;
  animation: blink 1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.composer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 20px 18px;
  border-top: 1px solid var(--line);
  background: var(--bg);
}
/* 输入区外壳：聚焦时整块高亮，内部 textarea 不再自己画边框 */
.composer-shell {
  position: relative;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--bg);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.composer-shell:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer-row { display: flex; gap: 8px; align-items: flex-end; padding: 4px 6px 0 4px; }
.composer.dragging { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.composer textarea {
  flex: 1;
  font: inherit;
  resize: none;
  padding: 9px 8px;
  border: 0;
  border-radius: 10px;
  max-height: 200px;
  background: transparent;
  line-height: 1.5;
  outline: none;
}
/* 只作用于「发送」这一个按钮。之前写成 .composer button，
   会把浮层里的命令行 / 模型行也一起染成深蓝底白字，选中项直接看不见字 */
.composer #send { background: var(--accent); color: #fff; border-color: var(--accent); padding: 10px 18px; }
.composer #send:hover { background: #134b83; }
.composer #send:disabled { opacity: .55; }
/* 中断按钮：回合进行中才出现（app.js 控制 hidden），红色示意「停止」 */
.composer #stop { background: #fff5f5; color: #c0392b; border-color: #eec3c0; padding: 10px 14px; font-weight: 500; }
.composer #stop:hover { background: #ffe9e7; border-color: #c0392b; }
.composer #stop:disabled { opacity: .55; }
.composer #stop.hidden { display: none; }
.composer .attach-btn {
  height: 38px;
  width: 38px;
  flex: none;
  padding: 0;
  display: grid;
  place-items: center;
  background: transparent;
  color: var(--text-soft);
  border-color: transparent;
}
.composer .attach-btn:hover { background: var(--bg-sink); color: var(--text); }

/* 工具条：模型选择 + 提示 */
.composer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 10px 7px;
}
.composer-foot .foot-left { display: flex; align-items: center; gap: 4px; min-width: 0; }
.composer .model-btn,
.composer .perm-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px 3px 7px;
  font-size: 12px;
  line-height: 1.5;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--text-soft);
  max-width: 62%;
}
.composer .perm-btn { max-width: 40%; }
.composer .model-btn:hover,
.composer .perm-btn:hover { background: var(--bg-sink); color: var(--text); border-color: transparent; }
.composer .model-btn.open,
.composer .perm-btn.open { background: var(--accent-soft); color: var(--accent); }
.model-btn .m-dot { width: 6px; height: 6px; border-radius: 999px; background: var(--ok); flex: none; }
.perm-btn .p-shield { flex: none; opacity: .85; }
.perm-btn .p-shield { color: var(--ok); }
.perm-btn.danger { color: var(--err); }
.perm-btn.danger .p-shield { color: var(--err); }
.perm-btn.danger.open { background: var(--err-soft); color: var(--err); }
.model-btn .m-eff {
  font-family: var(--mono);
  font-size: 10.5px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--bg-sink);
  color: var(--text-soft);
}
.model-btn #model-name,
.perm-btn #perm-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.composer-hint { font-size: 11px; color: var(--text-dim); white-space: nowrap; }
.composer-hint kbd {
  font-family: var(--mono);
  font-size: 10.5px;
  padding: 0 4px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--bg-soft);
  color: var(--text-soft);
}

/* 向上弹出的浮层（命令 / 模型） */
.pop {
  position: absolute;
  left: 6px;
  bottom: calc(100% + 8px);
  z-index: 40;
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  box-shadow: 0 12px 34px rgba(20, 20, 18, 0.16);
  overflow: hidden;
}

.slash-menu { right: 6px; min-width: min(470px, calc(100% - 12px)); padding: 5px; max-height: 340px; overflow-y: auto; }
.slash-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 10.5px;
  color: var(--text-dim);
  padding: 4px 8px 6px;
  letter-spacing: .04em;
  position: sticky;
  top: -5px;
  background: var(--bg);
  z-index: 1;
}
.slash-head .n { color: var(--text-dim); font-family: var(--mono); }
.slash-group {
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: .08em;
  padding: 8px 9px 3px;
  border-top: 1px solid var(--line);
  margin-top: 2px;
}
.slash-group:first-of-type { border-top: 0; margin-top: 0; padding-top: 3px; }
.slash-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 6px 9px;
  border-radius: 7px;
  cursor: pointer;
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  color: var(--text);
}
.slash-item:hover { background: var(--bg-soft); }
.slash-item.on { background: var(--accent-soft); color: var(--text); }
.slash-item .c { font-family: var(--mono); font-size: 12.5px; color: var(--accent); flex: none; min-width: 104px; }
.slash-item.on .c { color: var(--accent); }
.slash-item .d { font-size: 12px; color: var(--text-soft); flex: 1; min-width: 0; }
.slash-item.on .d { color: var(--text-soft); }
.slash-item .a { font-size: 10.5px; color: var(--text-dim); font-family: var(--mono); flex: none; }
.slash-item.off { opacity: .5; }
.slash-item.off .c { color: var(--text-dim); }
.slash-item .a.term {
  font-family: inherit;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 0 5px;
  font-size: 10px;
  color: var(--text-dim);
}
.slash-empty { padding: 12px; font-size: 12px; color: var(--text-dim); text-align: center; }

.model-pop { width: min(380px, calc(100% - 12px)); max-height: min(64vh, 460px); overflow-y: auto; padding: 6px; }
.pop-head { font-size: 10.5px; color: var(--text-dim); padding: 6px 8px 6px; letter-spacing: .04em; }
.model-row {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  width: 100%;
  padding: 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  color: var(--text);
}
.model-row:hover { background: var(--bg-soft); }
.model-row.on { background: var(--accent-soft); color: var(--text); }
.m-radio {
  width: 13px; height: 13px; flex: none; margin-top: 3px;
  border-radius: 999px; border: 1.5px solid var(--line-strong); background: var(--bg);
}
.model-row.on .m-radio { border-color: var(--accent); border-width: 4px; }
.m-text { display: grid; gap: 1px; min-width: 0; }
.m-title { font-size: 12.5px; display: flex; align-items: baseline; gap: 6px; }
.m-title .m-id { font-family: var(--mono); font-size: 10.5px; color: var(--text-dim); }
.m-desc { font-size: 11.5px; color: var(--text-dim); line-height: 1.45; }
.pop-sep { height: 1px; background: var(--line); margin: 6px 8px; }
.pop-label { font-size: 10.5px; color: var(--text-dim); padding: 2px 8px 6px; letter-spacing: .04em; }
.effort-row { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 8px 2px; }
.effort-chip {
  font-size: 11.5px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--bg);
  color: var(--text-soft);
  cursor: pointer;
  line-height: 1.6;
}
.effort-chip:hover { background: var(--bg-soft); color: var(--text); }
.effort-chip.on {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 500;
}
.pop-hint { font-size: 10.5px; color: var(--text-dim); padding: 8px 8px 4px; line-height: 1.5; }

/* 权限面板：四个档位，danger 档用红色区分 */
.perm-pop { width: min(420px, calc(100% - 12px)); }
.perm-row { align-items: flex-start; }
.perm-row.danger .m-title { color: var(--err); }
.perm-row.danger.on { background: var(--err-soft); }
.perm-row.danger.on .m-radio { border-color: var(--err); }
.perm-row .m-badge {
  font-size: 10px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--bg-sink);
  color: var(--text-dim);
  line-height: 1.6;
}
.perm-row.danger .m-badge { background: var(--err-soft); color: var(--err); }
.perm-confirm {
  margin: 4px 8px 8px;
  padding: 9px 10px;
  border-radius: 8px;
  background: var(--err-soft);
  border: 1px solid #f1c9c9;
  color: var(--text);
  font-size: 11.5px;
  line-height: 1.55;
}
.perm-confirm .pc-row { display: flex; gap: 8px; margin-top: 8px; }
.perm-confirm button {
  font: inherit;
  font-size: 11.5px;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--line-strong);
  background: var(--bg);
  color: var(--text-soft);
  cursor: pointer;
}
.perm-confirm button.go { background: var(--err); border-color: var(--err); color: #fff; }
.perm-detail {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-dim);
  padding: 2px 8px 4px;
  line-height: 1.6;
}

.attach-bar { display: flex; flex-wrap: wrap; gap: 8px; }
.attach-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 4px 6px 4px 8px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  max-width: 280px;
  color: var(--text-soft);
}
.attach-chip img { width: 22px; height: 22px; object-fit: cover; border-radius: 4px; display: block; flex: none; }
.attach-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-size { color: var(--text-dim); font-size: 11px; flex: none; }
.attach-chip.uploading { color: var(--text-dim); font-style: italic; }
.attach-del {
  border: none;
  background: none;
  padding: 0 2px;
  font-size: 15px;
  line-height: 1;
  color: var(--text-dim);
  cursor: pointer;
  border-radius: 4px;
}
.attach-del:hover { color: var(--err); background: var(--bg-sink); }

.user-stack { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; min-width: 0; max-width: min(760px, 100%); }
.msg-attachments { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.msg-attach {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 6px 10px;
  background: var(--bg);
  border: 1px solid #cfe2f5;
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
  max-width: 260px;
}
.msg-attach.img { padding: 4px; }
.msg-attach img { max-width: 220px; max-height: 160px; border-radius: 8px; display: block; }
.msg-attach span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-attach:hover { border-color: var(--accent); }

.sidebar-foot {
  border-top: 1px solid var(--line);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.admin-panel {
  border-top: 1px solid var(--line);
  padding: 10px 12px;
  display: grid;
  gap: 8px;
  background: var(--bg);
  max-height: 45%;
  overflow-y: auto;
}
.admin-head { font-size: 11px; color: var(--text-dim); }
.member-list { display: grid; gap: 4px; }
.member-row { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-soft); }
.member-row .role { font-size: 10px; padding: 0 6px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.admin-panel .filter { margin: 0; }
button.wide { width: 100%; padding: 7px; font-size: 13px; }

.empty { color: var(--text-dim); text-align: center; padding: 60px 20px; font-size: 13px; }

/* ---------- 本轮输出文件卡片 ---------- */
.out-files {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-soft);
  padding: 8px;
  max-width: min(560px, 100%);
}
.out-files .of-head {
  font-size: 11px;
  color: var(--text-dim);
  padding: 2px 4px 8px;
  letter-spacing: .03em;
}
.out-file {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 7px;
  background: var(--bg);
  border: 1px solid var(--line);
  margin-bottom: 6px;
}
.out-file:last-child { margin-bottom: 0; }
.out-file:hover { border-color: var(--accent); }
.out-file svg { flex: none; color: var(--text-soft); }
.out-file .of-name {
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1;
}
.out-file .of-size { font-size: 11px; color: var(--text-dim); flex: none; font-family: var(--mono); }
.out-file .of-acts { display: flex; gap: 4px; flex: none; }
.out-file .of-acts a {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  text-decoration: none;
}
.out-file .of-acts a:hover { background: #d5e7f8; }

/* ---------- 顶栏「文件」按钮与右侧面板 ---------- */
#files-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 3px 10px;
  color: var(--text-soft);
}
#files-btn:hover, #files-btn.open { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }

.files-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(320px, 86vw);
  z-index: 60;
  background: var(--bg);
  border-left: 1px solid var(--line);
  box-shadow: -10px 0 30px rgba(20, 20, 18, 0.10);
  display: flex;
  flex-direction: column;
}
.files-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 12px 8px 14px;
  border-bottom: 1px solid var(--line);
}
.files-head strong { font-size: 13px; font-weight: 500; }
.files-crumb {
  padding: 8px 14px;
  font-size: 12px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-soft);
  overflow-x: auto;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 2px;
}
.files-crumb .crumb {
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 12px;
  padding: 1px 3px;
  cursor: pointer;
  border-radius: 4px;
}
.files-crumb .crumb:hover { background: var(--accent-soft); }
.files-crumb .c-sep { color: var(--text-dim); }
.files-list { flex: 1; overflow-y: auto; padding: 6px 8px; min-height: 0; }
.file-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 8px;
  border: 0;
  background: transparent;
  border-radius: 7px;
  cursor: pointer;
  text-align: left;
  color: var(--text);
  font: inherit;
  font-size: 12.5px;
}
.file-row:hover { background: var(--bg-sink); }
.file-row.is-dir .f-name { color: var(--accent); font-weight: 500; }
.f-check {
  flex: none;
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--line-strong);
  border-radius: 4px;
  background: var(--bg);
  color: transparent;
  font-size: 11px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
}
.f-check:hover { border-color: var(--accent); color: var(--line-strong); }
.f-check.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.files-del { color: var(--err); }
.files-del:hover { background: var(--err-soft); color: var(--err); }
.f-ico { flex: none; font-size: 13px; display: inline-flex; }
.f-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.f-meta { flex: none; font-size: 10.5px; color: var(--text-dim); font-family: var(--mono); }
.f-acts { display: flex; gap: 3px; flex: none; }
.f-acts a, .f-acts .f-ref {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--bg);
  color: var(--text-soft);
  text-decoration: none;
  cursor: pointer;
  font-family: inherit;
  line-height: 1.6;
}
.f-acts a:hover, .f-acts .f-ref:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.files-empty { color: var(--text-dim); font-size: 12px; text-align: center; padding: 28px 12px; line-height: 1.8; }
.files-foot {
  border-top: 1px solid var(--line);
  padding: 7px 14px;
  font-size: 10.5px;
  color: var(--text-dim);
}

/* ---------- 手机 / 窄屏自适应 ---------- */
/* 桌面端隐藏汉堡按钮 */
.sidebar-toggle { display: none; }
.sidebar-backdrop { display: none; }

@media (max-width: 760px) {
  /* dvh：移动端地址栏伸缩时高度跟随，输入法弹出不截断 */
  html, body { height: 100vh; height: 100dvh; }
  .layout { grid-template-columns: 1fr; height: 100%; }

  /* 侧栏变为抽屉：默认隐藏，点 ☰ 拉出，点遮罩收起 */
  .sidebar { display: none; }
  .sidebar.open {
    display: flex;
    position: fixed;
    inset: 0 auto 0 0;
    width: min(84%, 340px);
    z-index: 30;
    box-shadow: 0 0 30px rgba(0,0,0,.20);
  }
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.30);
    z-index: 25;
  }
  .sidebar-toggle { display: inline-flex; align-items: center; justify-content: center; font-size: 17px; }

  /* 顶栏：标题溢出省略，按钮不挤 */
  .topbar { padding: 8px 10px; gap: 8px; }
  .thread-title { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .thread-meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* 对话区：边距收紧给内容留宽度 */
  .stream { padding: 12px 12px 6px; }
  .msg .body { max-width: 100%; }

  /* 输入区：16px 防 iOS 聚焦自动放大；按钮加大到手指可点的尺寸 */
  .composer { padding: 8px 10px 12px; }
  .composer textarea { font-size: 16px; padding: 8px 6px; }
  .composer button, .composer .ghost { min-height: 34px; }
  #send { min-width: 56px; }
  /* 窄屏没有位置放提示语，优先保住设置按钮 */
  .composer-hint { display: none; }
  .composer .model-btn, .composer .perm-btn { max-width: none; }
  #files-btn { font-size: 0; gap: 0; padding: 5px 10px; } /* 窄屏只留图标 */

  /* 文件面板：手机上接近全宽 */
  .files-panel { width: min(360px, 94vw); }
  .files-list .file-row { padding: 9px 8px; } /* 行高加大便于触控 */

  /* 弹出菜单/浮层不超出屏幕 */
  .slash-menu, .model-pop, .perm-pop { max-width: calc(100vw - 24px); }
}
