/* ══════════════ 主题变量 ══════════════ */
:root {
  --bg:        #ffffff;
  --bg-soft:   #f7f8fa;
  --panel:     #ffffff;
  --panel-2:   #f1f3f4;
  --panel-3:   #e8eaed;
  --line:      #e3e6ea;
  --line-2:    #d6dae0;
  --fg:        #1f2328;
  --fg-dim:    #5f6368;
  --fg-dim2:   #8a9099;
  --accent:    #1a73e8;
  --accent-fg: #ffffff;
  --accent-soft:#e8f0fe;
  --ok:        #137333;
  --ok-soft:   #e6f4ea;
  --amber:     #b06000;
  --amber-soft:#fef7e0;
  --warn:      #d93025;
  --warn-soft: #fce8e6;
  --radius:    12px;
  --radius-sm: 8px;
  --shadow:    0 1px 3px rgba(60,64,67,.14), 0 4px 12px rgba(60,64,67,.08);
  --shadow-sm: 0 1px 2px rgba(60,64,67,.12);
  --code-bg:   #f6f8fa;
}
[data-theme="dark"] {
  --bg:        #0f1115;
  --bg-soft:   #15181e;
  --panel:     #1a1e25;
  --panel-2:   #222731;
  --panel-3:   #2b313c;
  --line:      #2a303a;
  --line-2:    #38404d;
  --fg:        #e6e8ec;
  --fg-dim:    #9aa1ac;
  --fg-dim2:   #6f7783;
  --accent:    #8ab4f8;
  --accent-fg: #16233a;
  --accent-soft:#1e2a41;
  --ok:        #81c995;
  --ok-soft:   #1c2a22;
  --amber:     #fdd663;
  --amber-soft:#33291a;
  --warn:      #f28b82;
  --warn-soft: #33211f;
  --shadow:    0 1px 3px rgba(0,0,0,.5), 0 6px 18px rgba(0,0,0,.35);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --code-bg:   #12151a;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  transition: background .18s, color .18s;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
code {
  background: var(--panel-2); padding: 1.5px 6px; border-radius: 5px;
  font-size: .88em; color: var(--fg);
}
pre {
  background: var(--code-bg); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 13px 15px; overflow: auto;
  margin: 10px 0; font-size: 13px; line-height: 1.6;
}

/* ══════════════ 通用组件 ══════════════ */
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px 22px; margin-bottom: 14px;
}
.card.flat { box-shadow: var(--shadow-sm); }
h1 { font-size: 22px; margin: 0 0 6px; font-weight: 600; letter-spacing: -.2px; }
h2 { font-size: 14px; margin: 24px 0 10px; color: var(--fg-dim); font-weight: 600; }
.sub { color: var(--fg-dim); font-size: 13.5px; margin-bottom: 18px; }
/* 页内切换链接的当前项（运行状态页的时间窗） */
.sub a.cur {
  color: var(--accent); background: var(--accent-soft);
  border-radius: 10px; padding: 2px 8px; font-weight: 600;
}
.sub a.cur:hover { text-decoration: none; }

.flash { padding: 11px 15px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 14px; }
.flash.ok { background: var(--ok-soft); color: var(--ok); border: 1px solid color-mix(in srgb, var(--ok) 30%, transparent); }
.flash.bad { background: var(--warn-soft); color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); }
.flash.warn { background: var(--warn-soft); color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); }
.flash .flash-x { float: right; margin-left: 12px; font-weight: bold; opacity: .5; cursor: pointer; }
.flash .flash-x:hover { opacity: 1; }

label { display: block; font-size: 13px; color: var(--fg-dim); margin: 14px 0 5px; }
input[type=text], input[type=password], input[type=number], select, textarea {
  background: var(--bg); border: 1px solid var(--line-2); color: var(--fg);
  border-radius: var(--radius-sm); padding: 9px 12px; font: inherit; width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
button {
  background: var(--accent); color: var(--accent-fg); border: 0;
  border-radius: var(--radius-sm); padding: 9px 16px; font: inherit;
  font-weight: 500; cursor: pointer; transition: background .15s, box-shadow .15s;
}
button:hover { box-shadow: var(--shadow-sm); filter: brightness(.96); }
button.ghost { background: transparent; border: 1px solid var(--line-2); color: var(--fg); }
button.ghost:hover { background: var(--panel-2); }
button.danger { background: transparent; border: 1px solid var(--line-2); color: var(--warn); }
button.danger:hover { background: var(--warn-soft); }
button.link { background: none; color: var(--fg-dim); padding: 0; font-weight: 400; }
button.link:hover { color: var(--fg); box-shadow: none; filter: none; }
button:disabled { opacity: .45; cursor: not-allowed; }
/* 「最近一次失败」行的 ×：小、不抢注意力，悬停才显红色 */
button.fail-close {
  background: transparent; border: 0; padding: 2px 7px;
  color: var(--fg-dim2); font-size: 14px; line-height: 1;
  border-radius: 6px; flex: 0 0 auto;
}
button.fail-close:hover { color: var(--warn); background: var(--warn-soft); box-shadow: none; filter: none; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--fg-dim); font-weight: 600; font-size: 12.5px; }
tbody tr:hover td { background: var(--bg-soft); }
tr:last-child td { border-bottom: 0; }
td input, td select { padding: 6px 9px; font-size: 13px; }

/* 表格里的「操作」单元格：统一按钮间距。
   以前三个按钮靠 inline-form 的空格分隔，间距不匀、窄屏还会折行。 */
.acts { display: flex; gap: 6px; align-items: center; flex-wrap: nowrap; }
.acts form { margin: 0; display: inline-flex; }
.acts button { padding: 7px 12px; }
/* 「新增」行：和数据行区分开，一眼看出这是录入行不是已有数据 */
tr.newrow td { background: var(--bg-soft); }
tr.newrow td:first-child { border-top-left-radius: var(--radius-sm); }
tr.newrow td:last-child { border-top-right-radius: var(--radius-sm); }

.pill {
  display: inline-block; font-size: 12px; padding: 2.5px 9px; border-radius: 20px;
  border: 1px solid var(--line-2); color: var(--fg-dim); white-space: nowrap;
}
.pill.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, transparent); background: var(--ok-soft); }
.pill.bad { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 35%, transparent); background: var(--warn-soft); }
.hint { color: var(--fg-dim2); font-size: 12.5px; line-height: 1.75; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > div { flex: 1; min-width: 150px; }

.copy {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 10px 12px;
}
.copy .v { font-family: ui-monospace, Menlo, monospace; font-size: 13px; overflow-x: auto; white-space: nowrap; }
.copy button { padding: 5px 12px; font-size: 12.5px; flex: 0 0 auto; }

.stats { display: flex; gap: 12px; flex-wrap: wrap; }
.stat {
  flex: 1; min-width: 118px; background: var(--bg-soft);
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 13px 15px;
}
.stat .n { font-size: 22px; font-weight: 600; letter-spacing: -.3px; }
.stat .l { font-size: 12px; color: var(--fg-dim); margin-top: 2px; }

/* ══════════════ 顶栏 ══════════════ */
/* 顶栏高度：聊天区/首页的布局要按它扣高度。手机上顶栏变两行（见下方窄屏规则），高度加高 */
:root { --header-h: 56px; }
header {
  display: flex; align-items: center; gap: 18px;
  padding: 0 20px; height: var(--header-h);
  background: var(--bg); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 50;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--fg); font-size: 16px; }
.brand:hover { text-decoration: none; }
.brand .logo { color: var(--accent); font-size: 19px; }
header nav { display: flex; gap: 2px; flex: 1; }
header nav a {
  color: var(--fg-dim); padding: 7px 14px; border-radius: 20px; font-size: 14px;
}
header nav a:hover { color: var(--fg); background: var(--panel-2); text-decoration: none; }
header nav a.active { color: var(--accent); background: var(--accent-soft); }
.userbox { display: flex; align-items: center; gap: 8px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-fg); font-size: 13px; font-weight: 600;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-lg { width: 56px; height: 56px; font-size: 20px; }
.avatar-xs { width: 22px; height: 22px; font-size: 11px; }
.usrwho { display: inline-flex; align-items: center; gap: 6px; }
/* 顶栏下拉菜单（管理 / 用户头像）：按钮 + 浮出小面板，同一时间只开一个 */
.dd { position: relative; display: inline-flex; }
.dd-btn {
  display: inline-flex; align-items: center; gap: 5px;
  background: transparent; border: 0; color: var(--fg-dim);
  padding: 6px 10px; border-radius: 999px; font-size: 14px; cursor: pointer;
}
.dd-btn:hover { color: var(--fg); background: var(--panel-2); }
.dd-caret { flex: 0 0 auto; transition: transform .15s; color: var(--fg-dim2); }
.dd.open .dd-caret { transform: rotate(180deg); }
.dd-menu {
  position: absolute; top: calc(100% + 8px); right: 0; min-width: 140px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); padding: 6px; display: none; z-index: 60;
}
.dd.open .dd-menu { display: block; }
.dd-item {
  display: block; width: 100%; text-align: left;
  padding: 8px 11px; border-radius: 8px; font-size: 13.5px;
  color: var(--fg); text-decoration: none; background: transparent; border: 0; cursor: pointer;
}
.dd-item:hover { background: var(--panel-2); text-decoration: none; }
.dd-item.cur { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
/* 头像按钮：圆形，hover 加圈提示可点 */
.dd-btn:has(.avatar) { padding: 2px; border-radius: 50%; }
.dd-btn:has(.avatar):hover { background: transparent; box-shadow: 0 0 0 2px var(--accent-soft); }
.dd-user {
  padding: 7px 11px 9px; font-size: 12.5px; color: var(--fg-dim);
  border-bottom: 1px solid var(--line); margin-bottom: 5px;
  max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.iconbtn {
  background: transparent; border: 0; color: var(--fg-dim); padding: 7px;
  border-radius: 50%; line-height: 0; cursor: pointer;
}
.iconbtn:hover { background: var(--panel-2); color: var(--fg); box-shadow: none; filter: none; }

main { max-width: 1080px; margin: 0 auto; padding: 28px 22px 70px; }
main.wide { max-width: none; padding: 0; }
/* 多列表格的页面（管理页 / 运行状态 / 用户详情…）用这个：1080px 塞 8 列会挤成一团 */
main.wide-page { max-width: 1500px; }
/* 窄屏时表格横向滚动，别把输入框压成一条线 */
@media (max-width: 900px) {
  main.wide-page .card { overflow-x: auto; }
  main.wide-page table { min-width: 760px; }
}

/* ══════════════ 登录 / 注册 ══════════════ */
.auth { max-width: 400px; margin: 8vh auto; position: relative; }
/* 登录/注册页的主题切换（顶栏 userbox 没渲染时也能切） */
.auth .auth-theme { position: absolute; top: 0; right: 0; }
.auth .brand-big { text-align: center; font-size: 30px; font-weight: 600; letter-spacing: -.5px; margin-bottom: 6px; }
.auth .brand-big .logo { color: var(--accent); }
.auth .sub2 { text-align: center; color: var(--fg-dim); font-size: 14px; margin-bottom: 26px; }
.auth .card { padding: 26px; box-shadow: var(--shadow); }
.auth button[type=submit] { width: 100%; margin-top: 20px; padding: 11px; }
.auth .alt { text-align: center; margin-top: 16px; font-size: 13.5px; color: var(--fg-dim); }

/* ══════════════ 首页（Google 风） ══════════════ */
.home { min-height: calc(100vh - var(--header-h)); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 20px; margin-top: calc(-1 * var(--header-h)); }
.home-inner { width: 100%; max-width: 620px; text-align: center; }
.home-logo { font-size: 56px; font-weight: 600; letter-spacing: -2px; margin-bottom: 18px; }
.home-logo .logo { color: var(--accent); }

.searchbox {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel); border: 1px solid var(--line-2);
  border-radius: 26px; padding: 6px 8px 6px 20px;
  box-shadow: var(--shadow-sm); transition: box-shadow .18s, border-color .18s;
}
.searchbox:focus-within { box-shadow: var(--shadow); border-color: transparent; }
.searchbox input {
  border: 0; background: none; padding: 12px 0; font-size: 16px;
}
.searchbox input:focus { box-shadow: none; }
.searchbox .go { flex: 0 0 auto; border-radius: 50%; width: 40px; height: 40px; padding: 0; font-size: 16px; }
.home-foot { margin-top: 40px; color: var(--fg-dim2); font-size: 12.5px; }

/* ══════════════ 对话页（三栏） ══════════════ */
/* position: relative —— 手机上 .side/.rail 是 absolute 抽屉，
   定位基准必须是 .chatlayout 而不是视口，否则面板会钻到顶栏后面 */
.chatlayout { display: flex; height: calc(100vh - var(--header-h)); overflow: hidden; position: relative; }

.side {
  flex: 0 0 260px; background: var(--bg-soft); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; transition: margin-left .2s, opacity .2s;
}
/* 负边距取 340（大于任何宽度，含手机上的 320），整块移出可视区，不挡点击 */
.side.hide { margin-left: -340px; opacity: 0; pointer-events: none; }
.side-top { padding: 12px; }
.side-top .newbtn { width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; }
.side-list { flex: 1; overflow-y: auto; padding: 0 8px 12px; }
.side-item {
  display: block; padding: 9px 11px; border-radius: var(--radius-sm); color: var(--fg);
  border: 1px solid transparent; margin-bottom: 2px;
}
.side-item:hover { background: var(--panel-2); text-decoration: none; }
.side-item.active { background: var(--panel); border-color: var(--line-2); box-shadow: var(--shadow-sm); }
.side-item .t { display: block; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-item .m { display: block; font-size: 11.5px; color: var(--fg-dim2); margin-top: 2px; }
.side-foot { padding: 10px 12px; border-top: 1px solid var(--line); }

.center { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.ctop {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--bg);
}
.ctop .title { font-size: 14.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctop select { width: auto; min-width: 150px; padding: 6px 10px; font-size: 13.5px; border-radius: 20px; }
.grow { flex: 1; }

.msgs { flex: 1; overflow-y: auto; padding: 28px 20px 8px; }
.msgwrap { max-width: 780px; margin: 0 auto; }
.msg { display: flex; gap: 14px; margin-bottom: 26px; }
.msg .av {
  flex: 0 0 30px; width: 30px; height: 30px; border-radius: 50%; overflow: hidden;
  display: grid; place-items: center; font-size: 13px; font-weight: 600; margin-top: 2px;
}
.msg .av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.msg.user .av { background: var(--panel-3); color: var(--fg-dim); }
.msg.assistant .av { background: var(--accent); color: var(--accent-fg); }
.msg .col { flex: 1; min-width: 0; }
.msg .head { display: flex; align-items: center; gap: 9px; margin-bottom: 6px; font-size: 12.5px; color: var(--fg-dim2); }
.msg .head .who { color: var(--fg); font-weight: 500; font-size: 13.5px; }
.msg .body { font-size: 15px; line-height: 1.78; word-break: break-word; }
.msg.user .body {
  background: var(--panel-2); border-radius: 14px; padding: 10px 15px;
  white-space: pre-wrap; display: inline-block; max-width: 100%;
}
.msg.assistant .body > *:first-child { margin-top: 0; }
.msg.assistant .body p { margin: 0 0 12px; }
.msg.assistant .body p:last-child { margin-bottom: 0; }
.msg.assistant .body ul, .msg.assistant .body ol { margin: 0 0 12px; padding-left: 24px; }
.msg.assistant .body li { margin: 4px 0; }
.msg.assistant .body h3 { font-size: 17px; margin: 20px 0 9px; font-weight: 600; }
.msg.assistant .body blockquote {
  margin: 0 0 12px; padding: 2px 16px; border-left: 3px solid var(--line-2); color: var(--fg-dim);
}
.msg.assistant .body table { margin: 0 0 12px; font-size: 14px; }
.msg.assistant .body th, .msg.assistant .body td { padding: 6px 10px; }
.msg.assistant .body pre { position: relative; }
.msg.assistant .body pre .copycode {
  position: absolute; top: 8px; right: 8px; padding: 3px 10px; font-size: 11.5px;
  background: var(--panel); border: 1px solid var(--line-2); color: var(--fg-dim);
  opacity: 0; transition: opacity .15s; box-shadow: none;
}
.msg.assistant .body pre:hover .copycode { opacity: 1; }
.msg .tools { margin-top: 8px; display: flex; gap: 8px; opacity: 0; transition: opacity .15s; }
.msg:hover .tools { opacity: 1; }
.msg .tools button {
  padding: 3px 10px; font-size: 12px; background: transparent;
  border: 1px solid var(--line-2); color: var(--fg-dim);
}
.msg .err { color: var(--warn); }

.empty { color: var(--fg-dim); text-align: center; padding: 14vh 20px; font-size: 14.5px; line-height: 1.9; }
.empty .big { font-size: 40px; margin-bottom: 16px; color: var(--accent); }

.composer { padding: 10px 20px 16px; }
.composer .box {
  max-width: 780px; margin: 0 auto; display: flex; gap: 8px; align-items: flex-end;
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 22px;
  padding: 8px 8px 8px 18px; box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s;
}
.composer .box:focus-within { border-color: var(--accent); box-shadow: var(--shadow); }
.composer textarea {
  border: 0; background: none; padding: 8px 0; resize: none; max-height: 200px;
  font-size: 15px; line-height: 1.6;
}
.composer textarea:focus { box-shadow: none; }
.composer .send { flex: 0 0 38px; height: 38px; padding: 0; border-radius: 50%; font-size: 15px; }

/* ── 右侧面板 ── */
.rail {
  flex: 0 0 320px; background: var(--bg-soft); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; transition: margin-right .2s, opacity .2s;
}
.rail.hide { margin-right: -340px; opacity: 0; pointer-events: none; }
.rail-top {
  display: flex; align-items: center; gap: 8px; padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.rail-top .t { font-size: 13.5px; font-weight: 600; flex: 1; }
.rail-body { flex: 1; overflow-y: auto; padding: 14px; }
.rail-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 10px; }
.rail-card .k { font-size: 12px; color: var(--fg-dim2); }
.rail-card .v { font-size: 14px; margin-top: 2px; }
.rail-file { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm); margin-bottom: 10px; overflow: hidden; }
.rail-file .fh {
  display: flex; align-items: center; gap: 8px; padding: 9px 12px;
  border-bottom: 1px solid var(--line); font-size: 12.5px; color: var(--fg-dim);
}
.rail-file .fh .name { flex: 1; font-family: ui-monospace, Menlo, monospace; color: var(--fg); }
.rail-file .fh button { padding: 3px 9px; font-size: 11.5px; background: transparent; border: 1px solid var(--line-2); color: var(--fg-dim); }
.rail-file pre { margin: 0; border: 0; border-radius: 0; max-height: 210px; font-size: 12px; }

/* 抽屉背后的遮罩：桌面不渲染（手机上见下方窄屏规则） */
.scrim { display: none; }

/* ── 打字动画 ── */
.typing i {
  display: inline-block; width: 6px; height: 6px; margin-right: 3px; border-radius: 50%;
  background: var(--fg-dim2); animation: blink 1.3s infinite;
}
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,60%,100% { opacity: .25 } 30% { opacity: 1 } }

/* ── 滚动条 ── */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--panel-3); border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--line-2); background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ── 窄屏 ── */
@media (max-width: 1100px) { .rail { flex-basis: 280px; } }
/* 手机上左右面板是抽屉：默认收起（见 chat.html 的初始化 JS，
   除非用户之前明确打开过），展开时盖在对话区上，背后有遮罩，点遮罩关闭 */
@media (max-width: 900px) {
  .side {
    position: absolute; top: 0; left: 0; z-index: 40;
    width: min(280px, 85vw); height: calc(100vh - var(--header-h));
    box-shadow: var(--shadow);
  }
  .rail {
    position: absolute; top: 0; right: 0; z-index: 40;
    width: min(320px, 85vw); height: calc(100vh - var(--header-h));
    box-shadow: var(--shadow);
  }
  .msg .av { display: none; }
  .scrim {
    display: block; position: absolute; inset: 0; z-index: 30;
    background: rgba(15, 17, 21, .45); opacity: 0; pointer-events: none;
    transition: opacity .2s;
  }
  .scrim.on { opacity: 1; pointer-events: auto; }
}
@media (max-width: 640px) {
  /* 顶栏回到一行，与网页版同布局（logo 左 / 导航中间 / 用户区右），高度回到基础 56px。
     窄屏缩字：导航 12px（原 14px）+ 小内边距，logo 缩 14px，用户区/行距收窄——
     把中间窗口尽量撑宽：375px 屏约 147px，「对话/API/留言」3 项完整显示，
     当前页自动居中。中间导航 = 「滑动选择导航」：左右滑动按导航顺序切页（JS 在 base.html），
     点选保留；窗口外的项只被窗口边缘裁掉（正常左右滑窗）。登录/注册页没有 nav，不受影响 */
  header:has(nav) { padding: 0 10px; gap: 6px; }
  header nav { min-width: 0; overflow-x: auto; scrollbar-width: none; }
  header nav::-webkit-scrollbar { display: none; }
  /* 关键：导航项是 flex 子项，默认 flex:0 1 auto 会随窄容器收缩，把字挤得显示不全；
     锁死不收缩，文字宽度保持完整 */
  header nav a { flex: 0 0 auto; font-size: 12px; padding: 5px 8px; }
  header:has(nav) .brand { font-size: 14px; }
  header:has(nav) .brand .logo { font-size: 16px; }
  header:has(nav) .userbox { gap: 6px; }
  main { padding: 20px 14px 60px; }
  .home-logo { font-size: 42px; }
  .msgs { padding: 18px 14px 6px; }
  .composer { padding: 8px 12px 14px; }
  /* 对话页顶栏：隐藏 tokens 提示（token 数右栏里仍有）；
     模型名可能很长（select 宽度=最长选项名），让下拉框可收缩、名称自然截断，
     按钮 nowrap 防止「删除」被挤成竖排；这样任何模型名都不会把右侧控件挤出屏幕 */
  .ctop { padding: 8px 10px; gap: 8px; }
  .ctop .hint { display: none; }
  .ctop select { flex: 0 1 auto; min-width: 0; max-width: 70%; }
  .ctop button { white-space: nowrap; }
  /* iOS 对 font-size<16px 的输入框聚焦时会自动放大整页，手机上输入框统一 16px */
  .composer textarea { font-size: 16px; }
}

/* 触屏设备没有 hover：复制按钮（消息的「复制」、代码块右上角）常显 */
@media (hover: none) {
  .msg .tools, .msg .body pre .copycode { opacity: 1; }
}

/* 长表折叠：只显前 N 行（状态页操作记录 5 行、日志页 8 行），其余行 .xtra 隐藏；
   点「展开全部」给 table 加 .unfolded 展开 / 「收起」复位。列表都是最新在前。 */
.xtra { display: none; }
table.unfolded .xtra { display: table-row; }
button.fold { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
              color: var(--fg-dim); font-size: 12px; padding: 2px 10px; cursor: pointer;
              vertical-align: middle; margin-left: 8px; }
button.fold:hover { color: var(--fg); border-color: var(--accent); }

/* 第八轮：管理页 sub 行的导航按键（← 管理 / ← 日志 / ← 状态），按键样式而非纯链接 */
.navkey { display: inline-block; margin-left: 6px; padding: 3px 12px;
          border: 1px solid var(--line); border-radius: 999px;
          color: var(--fg-dim); font-size: 12.5px; }
.navkey:hover { color: var(--fg); border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }

/* 第八轮：对话列表话题行 ✎ 重命名 / × 删除。常显（不靠 hover），重命名中隐藏 */
.side-item { position: relative; }
.side-item .tact { position: absolute; top: 50%; transform: translateY(-50%);
                   width: 20px; height: 20px; margin: 0; padding: 0; border: 0; border-radius: 6px;
                   background: transparent; color: var(--fg-dim2); font-size: 12px;
                   display: flex; align-items: center; justify-content: center; cursor: pointer; }
.side-item .tact[data-act="del"] { right: 7px; }
.side-item .tact[data-act="rename"] { right: 29px; }
.side-item .tact:hover { color: var(--fg); background: var(--panel-3); }
.side-item .tact[data-act="del"]:hover { color: var(--warn); }
.side-item .tact:disabled { visibility: hidden; }
.side-item .t, .side-item .m { padding-right: 44px; }   /* 右侧留给按钮，标题不滑到下面 */
.side-item.editing .tact { visibility: hidden; }         /* 重命名中不显示按钮 */
.rename-in { width: 100%; font-size: 13px; padding: 2px 6px;
             border: 1px solid var(--accent); border-radius: 6px;
             background: var(--panel-2); color: var(--fg); }
@media (max-width: 900px) {
  .rename-in { font-size: 16px; }   /* iOS 对 <16px 输入框聚焦会放大整页 */
}

/* 第八轮：模型回复下方的 token 统计（参考 Cheezy：更暗的小字） */
.msg .meta { color: var(--fg-dim2); font-size: 12px; margin-top: 4px; }
