:root {
  --bg: #f8f7f4;
  --panel: #ffffff;
  --sidebar: #f2f1ed;
  --text: #1c1b19;
  --muted: #66645f;
  --faint: #9b9993;
  --border: #e7e5e0;
  --hover: rgba(0, 0, 0, 0.045);
  --active: rgba(0, 0, 0, 0.075);
  --accent: #c2410c;
  --accent-2: #ea7a3c;
  --accent-text: #ffffff;
  --accent-soft: #fcefe6;
  --danger: #c0262d;
  --ok: #15803d;
  --user-bubble: #efede8;
  --code-bg: #f4f3f0;
  --glass: rgba(248, 247, 244, 0.78);
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.14);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04), 0 6px 20px rgba(0, 0, 0, 0.06);
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151517;
    --panel: #1f1f22;
    --sidebar: #19191b;
    --text: #ededeb;
    --muted: #a3a29d;
    --faint: #767570;
    --border: #2c2c30;
    --hover: rgba(255, 255, 255, 0.055);
    --active: rgba(255, 255, 255, 0.09);
    --accent: #f0864a;
    --accent-2: #f5a66f;
    --accent-text: #1a0d05;
    --accent-soft: #33221a;
    --danger: #f2686e;
    --ok: #4ade80;
    --user-bubble: #2a2a2e;
    --code-bg: #111113;
    --glass: rgba(21, 21, 23, 0.78);
    --shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
svg { flex-shrink: 0; }
#app { height: 100dvh; }

/* ---------- 通用控件 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 0 14px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--panel); white-space: nowrap;
}
.btn:hover { background: var(--hover); }
a.btn { text-decoration: none; color: var(--text); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { color: var(--danger); }
.btn.sm { min-height: 30px; padding: 0 10px; font-size: 13px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px;
  border: 0; background: transparent; border-radius: 9px; color: var(--muted);
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.input, select.input, textarea.input {
  width: 100%; min-height: 38px; padding: 8px 11px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--panel); outline: none;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { resize: vertical; min-height: 80px; line-height: 1.5; }
label.field { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
label.field > span:first-child { font-weight: 600; color: var(--text); }
.hint { font-size: 12px; color: var(--faint); }
.row { display: flex; gap: 10px; align-items: center; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.spacer { flex: 1; }

.switch { position: relative; display: inline-block; vertical-align: middle; width: 38px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch i { position: absolute; inset: 0; background: var(--border); border-radius: 99px; transition: .2s; cursor: pointer; }
.switch i::after { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + i { background: var(--ok); }
.switch input:checked + i::after { transform: translateX(16px); }

.avatar {
  display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 8px;
  font-size: 13px; font-weight: 700; color: #fff; flex-shrink: 0; line-height: 1;
}

#toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg); padding: 9px 18px; border-radius: 99px; font-size: 14px; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: .2s; z-index: 100; max-width: calc(100vw - 32px);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { background: var(--danger); color: #fff; }

/* ---------- 登录 ---------- */
.login {
  height: 100%; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(600px 360px at 50% 18%, var(--accent-soft), transparent 70%), var(--bg);
}
.login form {
  width: min(360px, 100%); display: grid; gap: 14px; padding: 32px 28px 28px; text-align: center;
  background: var(--panel); border: 1px solid var(--border); border-radius: 22px; box-shadow: var(--shadow-sm);
}
.login .hero-logo { margin: 0 auto 2px; }
.login h1 { margin: 0; font-size: 24px; letter-spacing: .5px; }
.login p { margin: -6px 0 6px; color: var(--muted); font-size: 14px; }
.login .input { min-height: 46px; border-radius: 12px; text-align: center; font-size: 16px; }
.login .btn.primary { min-height: 46px; border-radius: 12px; font-size: 16px; }
.login .err { color: var(--danger); font-size: 13px; min-height: 1em; }

/* ---------- 主布局 ---------- */
.layout { display: grid; grid-template-columns: 272px 1fr; height: 100%; }
.sidebar {
  background: var(--sidebar); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; min-height: 0;
  padding-top: env(safe-area-inset-top);
}
.sidebar-head { padding: 12px; display: grid; gap: 8px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; padding: 2px 4px; }
.brand img { width: 24px; height: 24px; }
.new-chat {
  justify-content: flex-start; background: var(--panel); border-radius: 12px; min-height: 40px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04); font-weight: 600;
}
.new-chat svg { color: var(--accent); }
.search { position: relative; }
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.search input { padding-left: 32px; min-height: 34px; background: var(--panel); }
.conv-list { flex: 1; overflow-y: auto; padding: 4px 8px 12px; }
.conv-group { font-size: 12px; color: var(--faint); padding: 12px 8px 4px; font-weight: 600; }
.conv {
  display: flex; align-items: center; gap: 4px; padding: 0 4px 0 10px; height: 36px;
  border-radius: 8px; cursor: pointer; color: var(--text); font-size: 14px;
}
.conv:hover { background: var(--hover); }
.conv.active { background: var(--active); }
.conv .t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv .icon-btn { width: 28px; height: 28px; opacity: 0; }
.conv:hover .icon-btn, .conv.active .icon-btn { opacity: 1; }
/* 触屏：只在当前对话上显示重命名/删除，列表更清爽，也避免误触 */
@media (hover: none) { .conv:not(.active) .icon-btn { display: none; } }
.sidebar-foot { border-top: 1px solid var(--border); padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); display: grid; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 10px; border-radius: 8px;
  border: 0; background: transparent; text-align: left; color: var(--text); width: 100%;
}
.nav-item:hover { background: var(--hover); }
.nav-item.active { background: var(--active); font-weight: 600; }
.empty-list { color: var(--faint); font-size: 13px; padding: 16px 10px; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); position: relative; }
.topbar {
  display: flex; align-items: center; gap: 6px; padding: 8px 12px; min-height: 56px;
  padding-top: calc(8px + env(safe-area-inset-top));
  position: relative; z-index: 20; border-bottom: 1px solid transparent; transition: border-color .2s, background .2s;
}
.main.scrolled .topbar {
  background: var(--glass); border-bottom-color: var(--border);
  -webkit-backdrop-filter: saturate(1.6) blur(16px); backdrop-filter: saturate(1.6) blur(16px);
}
.topbar .menu-btn { display: none; }
.topbar h2 { margin: 0; font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 模型切换 */
.model-picker { position: relative; min-width: 0; }
.model-btn {
  display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 10px 0 7px; border-radius: 10px;
  border: 0; background: transparent; max-width: 100%; font-weight: 600;
}
.model-btn:hover, .model-btn[aria-expanded="true"] { background: var(--hover); }
.model-btn > svg { color: var(--faint); transition: transform .2s; }
.model-btn[aria-expanded="true"] > svg { transform: rotate(180deg); }
.sheet-bg, .sheet-title { display: none; }
.model-btn .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-btn .prov { color: var(--faint); font-weight: 400; font-size: 13px; white-space: nowrap; }
.model-menu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 30; width: min(340px, calc(100vw - 24px));
  max-height: min(70vh, 520px); overflow-y: auto; padding: 6px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow);
}
.model-menu .grp { font-size: 12px; color: var(--faint); font-weight: 600; padding: 10px 10px 4px; }
.model-opt {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 9px;
  border: 0; background: transparent; text-align: left;
}
.model-opt:hover { background: var(--hover); }
.model-opt .n { flex: 1; min-width: 0; }
.model-opt .n div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-opt .n small { color: var(--faint); font-size: 12px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-opt.sel { background: var(--accent-soft); }
.model-opt .check { color: var(--accent); }
.model-menu .none { padding: 14px; color: var(--muted); font-size: 14px; }

/* 消息区 */
.thread { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.thread-inner { max-width: 820px; margin: 0 auto; padding: 8px 20px 24px; }
.hero-logo {
  width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center;
  background: var(--panel); border: 1px solid var(--border);
  box-shadow: 0 10px 30px color-mix(in srgb, var(--accent) 22%, transparent), var(--shadow-sm);
}
.hero-logo img { width: 38px; height: 38px; }
.welcome {
  min-height: 62vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 10px; padding: 24px 4px; color: var(--muted); animation: rise .4s ease both;
}
.welcome .hero-logo { margin-bottom: 8px; }
.welcome h1 { margin: 0; color: var(--text); font-size: 26px; font-weight: 700; letter-spacing: .3px; }
.welcome p { margin: 0; font-size: 14px; }
.welcome p b { color: var(--text); font-weight: 600; }
.suggest { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 18px; width: min(560px, 100%); }
.suggest.one { display: flex; justify-content: center; }
.sg {
  display: grid; gap: 3px; text-align: left; padding: 13px 14px; border-radius: 16px;
  background: var(--panel); border: 1px solid var(--border); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  transition: transform .15s, border-color .15s, background .15s;
}
.sg b { font-size: 14px; color: var(--text); font-weight: 600; }
.sg span { font-size: 13px; color: var(--faint); line-height: 1.45; }
.sg:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.sg:active { transform: scale(.97); background: var(--hover); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

.msg { margin: 20px 0; animation: rise .25s ease both; }
.msg.user { display: flex; justify-content: flex-end; }
.msg.user .bubble {
  background: var(--user-bubble); padding: 10px 15px; border-radius: 20px 20px 6px 20px;
  max-width: min(85%, 640px); white-space: pre-wrap; word-break: break-word;
}
.msg.assistant .who { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.msg.assistant .who .avatar { width: 22px; height: 22px; font-size: 11px; border-radius: 6px; }
.msg .actions { display: flex; gap: 2px; margin-top: 4px; color: var(--faint); align-items: center; font-size: 12px; }
.msg .actions .icon-btn { width: 30px; height: 30px; }
.msg .actions .meta { margin-left: 6px; }
.msg.user .actions { justify-content: flex-end; }
.msg-wrap { display: flex; flex-direction: column; align-items: flex-end; width: 100%; }
.err-box { margin-top: 8px; padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); font-size: 14px; word-break: break-word; }
.err-box.soft { background: var(--hover); color: var(--muted); }

details.reasoning { margin: 0 0 10px; border-left: 2px solid var(--border); padding-left: 12px; color: var(--muted); font-size: 14px; }
details.reasoning summary { cursor: pointer; user-select: none; font-size: 13px; color: var(--faint); list-style: none; }
details.reasoning summary::-webkit-details-marker { display: none; }
details.reasoning summary::before { content: "▸ "; }
details.reasoning[open] summary::before { content: "▾ "; }
details.reasoning .r-body { white-space: pre-wrap; margin-top: 6px; }

.typing { display: inline-flex; gap: 4px; padding: 8px 0; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* Markdown */
.md { word-break: break-word; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p, .md ul, .md ol, .md blockquote, .md .table-wrap, .md .code { margin: 0 0 12px; }
.md h1, .md h2, .md h3, .md h4 { margin: 20px 0 10px; line-height: 1.35; }
.md h1 { font-size: 1.45em; } .md h2 { font-size: 1.25em; } .md h3 { font-size: 1.1em; } .md h4 { font-size: 1em; }
.md ul, .md ol { padding-left: 1.5em; }
.md li { margin: 3px 0; }
.md li > ul, .md li > ol { margin: 4px 0; }
.md li.task { list-style: none; margin-left: -1.3em; }
.md blockquote { border-left: 3px solid var(--border); padding: 2px 0 2px 14px; color: var(--muted); }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }
.md code { font-family: var(--mono); font-size: .88em; background: var(--code-bg); padding: 1px 5px; border-radius: 5px; }
.md .code { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--code-bg); }
.md .code-head { display: flex; justify-content: space-between; align-items: center; padding: 4px 6px 4px 12px; font-size: 12px; color: var(--faint); border-bottom: 1px solid var(--border); }
.md .code-head button { border: 0; background: transparent; color: var(--muted); font-size: 12px; padding: 3px 8px; border-radius: 6px; }
.md .code-head button:hover { background: var(--hover); }
.md pre { margin: 0; padding: 12px 14px; overflow-x: auto; font-size: 13px; line-height: 1.55; }
.md pre code { background: none; padding: 0; font-size: inherit; }
.md .table-wrap { overflow-x: auto; }
.md table { border-collapse: collapse; font-size: 14px; min-width: 50%; }
.md th, .md td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.md th { background: var(--hover); }

/* 输入框 */
.composer-wrap { padding: 8px 16px calc(14px + env(safe-area-inset-bottom)); position: relative; }
.composer-wrap::before {
  content: ""; position: absolute; left: 0; right: 0; bottom: 100%; height: 24px; pointer-events: none;
  background: linear-gradient(to bottom, transparent, var(--bg));
}
.composer {
  max-width: 820px; margin: 0 auto; background: var(--panel); border: 1px solid var(--border);
  border-radius: 26px; padding: 8px 8px 8px 18px; display: flex; gap: 8px; align-items: flex-end;
  box-shadow: var(--shadow-sm); transition: border-color .2s, box-shadow .2s;
}
.composer:focus-within {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 10%, transparent), var(--shadow-sm);
}
.composer textarea {
  flex: 1; border: 0; outline: none; resize: none; background: transparent; max-height: 40vh;
  min-height: 24px; padding: 6px 0; line-height: 1.5; font-size: 16px;
}
.send-btn {
  width: 38px; height: 38px; border-radius: 50%; border: 0; display: grid; place-items: center;
  background: linear-gradient(140deg, var(--accent-2), var(--accent)); color: var(--accent-text); flex-shrink: 0;
  box-shadow: 0 4px 12px color-mix(in srgb, var(--accent) 35%, transparent); transition: transform .12s, background .2s;
}
.send-btn:active { transform: scale(.9); }
.send-btn:disabled { background: var(--active); color: var(--faint); box-shadow: none; cursor: default; }
.send-btn.stop { background: var(--text); color: var(--bg); }
.composer-note { max-width: 820px; margin: 6px auto 0; text-align: center; font-size: 12px; color: var(--faint); }

/* ---------- 后台 ---------- */
.admin { flex: 1; overflow-y: auto; }
.admin-inner { max-width: 980px; margin: 0 auto; padding: 4px 20px 40px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tab { border: 0; background: transparent; padding: 10px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab.active { color: var(--text); border-color: var(--accent); font-weight: 600; }
.section-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.section-head h3 { margin: 0; font-size: 17px; }
.section-head p { margin: 0; color: var(--muted); font-size: 13px; flex-basis: 100%; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; display: grid; gap: 10px; align-content: start;
}
.card.off { opacity: .6; }
.card-top { display: flex; align-items: center; gap: 10px; }
.card-top .avatar { width: 34px; height: 34px; border-radius: 10px; font-size: 15px; }
.card-top .n { flex: 1; min-width: 0; }
.card-top .n b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-top .n small { color: var(--faint); font-size: 12px; }
.kv { font-size: 13px; color: var(--muted); display: grid; gap: 2px; }
.kv code { font-family: var(--mono); font-size: 12px; word-break: break-all; color: var(--text); }
.badge { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 99px; background: var(--hover); color: var(--muted); font-weight: 600; }
.badge.ok { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.badge.warn { background: var(--accent-soft); color: var(--accent); }
.card-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; font-size: 14px; }
.table th, .table td { padding: 9px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table th { font-size: 12px; color: var(--faint); font-weight: 600; background: var(--hover); }
.table tr:last-child td { border-bottom: 0; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table .mono { font-family: var(--mono); font-size: 12px; color: var(--muted); word-break: break-all; }
.table-scroll { overflow-x: auto; border-radius: var(--radius); }
.prov-group { margin-bottom: 22px; }
.prov-group h4 { margin: 0 0 8px; display: flex; align-items: center; gap: 8px; font-size: 14px; }

/* 弹窗 */
.modal-bg {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.4); z-index: 50; display: grid; place-items: center; padding: 16px;
  animation: fade .15s;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  background: var(--panel); border-radius: 16px; width: min(520px, 100%); max-height: calc(100dvh - 32px);
  display: flex; flex-direction: column; box-shadow: var(--shadow); border: 1px solid var(--border);
}
.modal-head { display: flex; align-items: center; padding: 14px 14px 10px 20px; }
.modal-head h3 { margin: 0; font-size: 17px; flex: 1; }
.modal-body { padding: 4px 20px 16px; overflow-y: auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.modal-body .row > .input { flex: 1; min-width: 0; }
.modal-foot { display: flex; gap: 8px; padding: 12px 20px 16px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.pick-list { border: 1px solid var(--border); border-radius: 10px; max-height: 46vh; overflow-y: auto; }
.pick-list label { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--border); font-size: 14px; cursor: pointer; }
.pick-list label:last-child { border-bottom: 0; }
.pick-list label.added { color: var(--faint); }
.pick-list .mono { font-family: var(--mono); font-size: 13px; word-break: break-all; }
.overlay { display: none; }

/* ---------- 手机 ---------- */
@keyframes sheet-up { from { transform: translateY(100%); } }
@media (max-width: 820px) {
  body { font-size: 16px; }
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(310px, 86vw); z-index: 40; border-right: 0;
    border-radius: 0 22px 22px 0; transform: translateX(-104%);
    transition: transform .28s cubic-bezier(.2, .8, .2, 1); box-shadow: var(--shadow);
  }
  .sidebar-head { padding: 14px 12px 8px; gap: 10px; }
  .brand { font-size: 17px; padding: 4px 6px; }
  .brand img { width: 28px; height: 28px; }
  .search input { min-height: 40px; border-radius: 12px; }
  .conv { height: 44px; border-radius: 10px; font-size: 15px; }
  .nav-item { height: 46px; border-radius: 10px; font-size: 15px; }
  .layout.nav-open .sidebar { transform: none; }
  .overlay {
    display: block; position: fixed; inset: 0; z-index: 35; pointer-events: none;
    background: rgba(0, 0, 0, 0.4); opacity: 0; transition: opacity .28s;
  }
  .layout.nav-open .overlay { opacity: 1; pointer-events: auto; }
  .topbar .menu-btn { display: inline-grid; }
  .topbar { padding-left: 6px; padding-right: 6px; gap: 2px; }
  .topbar .icon-btn { width: 40px; height: 40px; border-radius: 12px; }
  .topbar h2 { font-size: 17px; }
  .model-picker { flex: 0 1 auto; }
  .model-btn {
    height: 38px; padding: 0 10px 0 5px; border-radius: 99px; gap: 7px; font-size: 15px;
    background: var(--panel); border: 1px solid var(--border); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  }
  .model-btn .avatar { width: 26px; height: 26px; border-radius: 50%; font-size: 12px; }
  .model-btn .prov { display: none; }

  /* 模型选择：从底部弹出 */
  .sheet-bg { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.4); z-index: 45; animation: fade .2s; }
  .model-menu {
    position: fixed; top: auto; left: 0; right: 0; bottom: 0; z-index: 46; width: 100%;
    max-height: 72dvh; padding: 8px 10px calc(12px + env(safe-area-inset-bottom));
    border-radius: 22px 22px 0 0; border-width: 1px 0 0; animation: sheet-up .28s cubic-bezier(.2, .8, .2, 1);
  }
  .sheet-title { display: block; text-align: center; font-weight: 600; font-size: 15px; padding: 18px 0 8px; position: relative; }
  .sheet-title::before, .modal::before {
    content: ""; position: absolute; top: 6px; left: 50%; width: 36px; height: 5px; margin-left: -18px;
    border-radius: 99px; background: var(--border);
  }
  .model-opt { padding: 11px 12px; border-radius: 12px; }
  .model-opt .avatar { width: 32px; height: 32px; border-radius: 10px; }

  .thread-inner { padding: 4px 16px 20px; }
  .msg.user .bubble { max-width: 86%; }
  .msg .actions .icon-btn { width: 34px; height: 34px; }
  .welcome { min-height: 66vh; }
  .welcome h1 { font-size: 23px; }
  .md pre { font-size: 12.5px; }
  .composer-wrap { padding: 6px 10px calc(10px + env(safe-area-inset-bottom)); }
  .composer { border-radius: 24px; padding-left: 16px; }
  .send-btn { width: 40px; height: 40px; }

  .admin-inner { padding: 4px 14px 32px; }
  .grid2 { grid-template-columns: 1fr; }
  .modal-bg { place-items: end center; padding: 0; }
  .modal {
    border-radius: 22px 22px 0 0; width: 100%; max-height: 92dvh; padding-bottom: env(safe-area-inset-bottom);
    position: relative; border-width: 1px 0 0; animation: sheet-up .28s cubic-bezier(.2, .8, .2, 1);
  }
  .modal-head { padding-top: 22px; }
  .hide-sm { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
