:root {
  --radius: 16px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

:root[data-theme="dark"] {
  --bg: #0b0d14;
  --bg-2: #101420;
  --surface: #171d2c;
  --surface-2: #1e2536;
  --input: #111725;
  --border: rgba(255, 255, 255, .085);
  --border-strong: rgba(255, 255, 255, .16);
  --text: #eef1f9;
  --text-2: #a5aec3;
  --text-3: #727d96;
  --accent: #8d7cf8;
  --accent-2: #4ea4f7;
  --accent-soft: rgba(141, 124, 248, .14);
  --user-bubble: linear-gradient(135deg, #725ef0, #4a8cf0);
  --danger: #ff7485;
  --ok: #4ad39c;
  --warn: #f2b75c;
  --shadow: 0 16px 48px rgba(0, 0, 0, .4);
  --glow: radial-gradient(900px 500px at 78% -10%, rgba(97, 92, 220, .15), transparent 65%), radial-gradient(700px 460px at 12% 105%, rgba(46, 132, 205, .10), transparent 65%);
}

:root[data-theme="light"] {
  --bg: #f5f6fa;
  --bg-2: #ffffff;
  --surface: #ffffff;
  --surface-2: #f0f2f8;
  --input: #f6f7fb;
  --border: rgba(20, 28, 50, .1);
  --border-strong: rgba(20, 28, 50, .2);
  --text: #1a2030;
  --text-2: #5a6479;
  --text-3: #8a93a7;
  --accent: #6f5ce7;
  --accent-2: #2f83dd;
  --accent-soft: rgba(111, 92, 231, .1);
  --user-bubble: linear-gradient(135deg, #725ef0, #4a8cf0);
  --danger: #d9485d;
  --ok: #199c6c;
  --warn: #b9821e;
  --shadow: 0 12px 40px rgba(30, 40, 70, .14);
  --glow: radial-gradient(900px 500px at 78% -10%, rgba(111, 92, 231, .09), transparent 65%), radial-gradient(700px 460px at 12% 105%, rgba(46, 132, 205, .07), transparent 65%);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea { font-family: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

.app {
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr) 322px;
  height: 100vh;
  height: 100dvh;
  width: 100%;
}

/* ---------- 通用按钮 ---------- */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; flex: 0 0 auto;
  border: 1px solid transparent; border-radius: 12px;
  background: transparent; color: var(--text-2);
  transition: background .18s, color .18s, border-color .18s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:active { transform: scale(.95); }
.text-btn {
  border: 0; background: transparent; color: var(--accent);
  font-size: 12.5px; padding: 5px 2px; font-weight: 600;
}
.text-btn:hover { text-decoration: underline; }
.btn {
  border: 1px solid var(--border); border-radius: 11px;
  background: var(--accent); color: #fff; font-size: 13px; font-weight: 600;
  padding: 9px 15px; min-height: 38px;
}
.btn:hover { filter: brightness(1.1); }
.btn.ghost { background: var(--surface-2); color: var(--text-2); }
.btn.ghost:hover { color: var(--text); filter: none; }
.btn.danger { color: var(--danger); }
.btn-row { display: flex; gap: 8px; margin-top: 10px; }
.note { color: var(--text-3); font-size: 11.5px; line-height: 1.65; margin: 8px 0 0; }

/* ---------- 侧栏 ---------- */
.sidebar {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--bg-2); border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 11px; padding: 18px 16px 16px; }
.brand-mark {
  width: 38px; height: 38px; flex: 0 0 auto; border-radius: 13px;
  display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 6px 20px rgba(122, 100, 240, .35);
}
.brand-mark svg { width: 21px; height: 21px; }
.brand-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.brand-text strong { font-size: 15.5px; letter-spacing: .5px; }
.brand-text span { font-size: 10.5px; color: var(--text-3); white-space: nowrap; }
.sidebar-close { margin-left: auto; display: none; }

.new-chat {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin: 4px 14px 20px; height: 44px; flex: 0 0 auto;
  border: 1px solid var(--border-strong); border-radius: 13px;
  background: var(--accent-soft); color: var(--text);
  font-size: 13.5px; font-weight: 600;
  transition: border-color .2s, background .2s;
}
.new-chat:hover { border-color: var(--accent); background: rgba(141, 124, 248, .2); }
.new-chat svg { width: 17px; height: 17px; color: var(--accent); }
.section-label {
  padding: 0 18px 10px; color: var(--text-3);
  font-size: 11px; font-weight: 700; letter-spacing: 1.2px;
}
.session-list { flex: 1; min-height: 0; overflow-y: auto; padding: 0 10px 12px; }
.session-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 10px; margin-bottom: 4px; border-radius: 12px;
  border: 1px solid transparent; color: var(--text-2); cursor: pointer;
  transition: background .16s, border-color .16s;
}
.session-item:hover { background: var(--surface-2); }
.session-item.active { background: var(--accent-soft); border-color: rgba(141, 124, 248, .3); color: var(--text); }
.session-avatar {
  width: 28px; height: 28px; flex: 0 0 auto; border-radius: 9px;
  display: grid; place-items: center; font-size: 12px; font-weight: 700; color: #fff;
}
.session-body { flex: 1; min-width: 0; }
.session-title { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-sub { font-size: 10.5px; color: var(--text-3); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-del {
  border: 0; background: transparent; color: var(--text-3); padding: 4px;
  opacity: 0; border-radius: 8px; display: grid; place-items: center;
}
.session-item:hover .session-del, .session-item:focus-within .session-del { opacity: 1; }
.session-del:hover { color: var(--danger); background: var(--surface); }
.session-del svg { width: 15px; height: 15px; }
.empty-sessions { padding: 18px 12px; color: var(--text-3); font-size: 12px; line-height: 1.7; }

.sidebar-foot { border-top: 1px solid var(--border); padding: 13px 16px calc(13px + env(safe-area-inset-bottom)); }
.status-row { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-2); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); flex: 0 0 auto; box-shadow: 0 0 0 3px rgba(242, 183, 92, .14); }
.dot.ready { background: var(--ok); box-shadow: 0 0 0 3px rgba(74, 211, 156, .14); }
.dot.error { background: var(--danger); box-shadow: 0 0 0 3px rgba(255, 116, 133, .14); }
.foot-row { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.ver { font-size: 10.5px; color: var(--text-3); }

/* ---------- 主区 ---------- */
.main {
  display: flex; flex-direction: column; min-width: 0; min-height: 0;
  background: var(--bg); background-image: var(--glow);
}
.topbar {
  height: 64px; flex: 0 0 auto; display: flex; align-items: center; gap: 10px;
  padding: 0 16px; border-bottom: 1px solid var(--border);
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px); position: relative; z-index: 5;
}
.menu-btn { display: none; }
.panel-open { display: none; }
.top-avatar { width: 38px; height: 38px; font-size: 15px; border-radius: 12px; flex: 0 0 auto; }
.avatar { display: grid; place-items: center; color: #fff; font-weight: 700; box-shadow: 0 4px 14px rgba(0, 0, 0, .18); }
.top-meta { min-width: 0; }
.top-meta h1 { font-size: 15px; margin: 0; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-meta p { font-size: 11.5px; margin: 2px 0 0; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-spacer { flex: 1; }

.chat-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scroll-behavior: smooth; }
.messages { max-width: 840px; margin: 0 auto; padding: 26px 22px 10px; display: flex; flex-direction: column; gap: 22px; }

.msg { display: flex; gap: 11px; align-items: flex-start; animation: rise .26s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.msg.user { flex-direction: row-reverse; }
.msg-avatar { width: 34px; height: 34px; border-radius: 11px; flex: 0 0 auto; font-size: 13px; margin-top: 2px; }
.msg-stack { max-width: min(78%, 660px); min-width: 0; display: flex; flex-direction: column; }
.msg.user .msg-stack { align-items: flex-end; }
.bubble {
  padding: 13px 17px; border-radius: 18px; font-size: 14.5px; line-height: 1.78;
  word-break: break-word; overflow-wrap: anywhere;
}
.msg.assistant .bubble { background: var(--surface); border: 1px solid var(--border); border-top-left-radius: 5px; }
.msg.user .bubble { background: var(--user-bubble); color: #fff; border-top-right-radius: 5px; box-shadow: 0 6px 20px rgba(86, 96, 220, .22); }
.md { white-space: pre-wrap; }
.md p { margin: 0 0 8px; }
.md p:last-child { margin-bottom: 0; }
.md strong { font-weight: 700; }
.md em { opacity: .9; }
.md code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .88em; background: rgba(140, 140, 180, .18); padding: 1px 5px; border-radius: 5px; }
.md pre { white-space: pre; overflow-x: auto; background: var(--input); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin: 8px 0; font-size: 12.5px; line-height: 1.6; }
.md pre code { background: transparent; padding: 0; }
.md blockquote { margin: 6px 0; padding-left: 10px; border-left: 3px solid var(--accent); color: var(--text-2); }
.msg-actions { display: flex; gap: 4px; margin-top: 6px; opacity: 0; transition: opacity .18s; }
.msg:hover .msg-actions, .msg:focus-within .msg-actions { opacity: 1; }
.msg.user .msg-actions { justify-content: flex-end; }
.mini-btn {
  border: 0; background: transparent; color: var(--text-3); font-size: 11.5px;
  padding: 4px 7px; border-radius: 7px; display: inline-flex; align-items: center; gap: 4px;
}
.mini-btn:hover { background: var(--surface-2); color: var(--text); }
.mini-btn svg { width: 13px; height: 13px; }
.reasoning {
  margin-bottom: 8px; border: 1px dashed var(--border-strong); border-radius: 10px;
  background: var(--input); font-size: 12px; color: var(--text-3);
}
.reasoning summary { cursor: pointer; padding: 7px 11px; list-style: none; user-select: none; }
.reasoning summary::-webkit-details-marker { display: none; }
.reasoning summary::before { content: "▸ "; color: var(--accent); }
.reasoning[open] summary::before { content: "▾ "; }
.reasoning .reasoning-body { padding: 0 11px 10px; white-space: pre-wrap; line-height: 1.6; max-height: 220px; overflow-y: auto; }
.cursor { display: inline-block; width: 2px; height: 1em; vertical-align: -.15em; margin-left: 2px; background: var(--accent); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.msg-time { font-size: 10.5px; color: var(--text-3); margin-top: 6px; padding: 0 4px; }

/* 欢迎页 */
.welcome { text-align: center; padding: 34px 12px 10px; }
.welcome-avatar {
  width: 74px; height: 74px; margin: 0 auto 18px; border-radius: 24px;
  display: grid; place-items: center; font-size: 30px; color: #fff; font-weight: 700;
  box-shadow: 0 14px 36px rgba(0, 0, 0, .25);
}
.welcome h2 { font-size: 23px; margin: 0 0 8px; letter-spacing: .5px; }
.welcome .sub { color: var(--text-2); font-size: 13.5px; line-height: 1.9; max-width: 480px; margin: 0 auto 20px; }
.welcome-speak { color: var(--text-3); font-size: 12px; margin-bottom: 20px; }
.quick-roles { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 18px; }
.quick-role {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 13px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  color: var(--text-2); font-size: 12.5px;
}
.quick-role:hover { border-color: var(--accent); color: var(--text); }
.quick-role .mini-avatar { width: 20px; height: 20px; border-radius: 7px; display: grid; place-items: center; font-size: 10px; color: #fff; font-weight: 700; }

/* 输入区 */
.composer-area {
  flex: 0 0 auto; padding: 10px 20px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 62%, transparent);
}
.starter-row {
  max-width: 840px; margin: 0 auto 8px; display: flex; gap: 7px;
  overflow-x: auto; scrollbar-width: none; padding: 2px 0;
}
.starter-row::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--text-2); font-size: 12px; padding: 7px 13px;
  white-space: nowrap;
}
.chip:hover { border-color: var(--accent); color: var(--text); }
.composer {
  max-width: 840px; margin: 0 auto; display: flex; align-items: flex-end; gap: 8px;
  padding: 9px 9px 9px 15px; border: 1px solid var(--border-strong); border-radius: 18px;
  background: var(--surface); box-shadow: var(--shadow);
  transition: border-color .2s;
}
.composer:focus-within { border-color: var(--accent); }
#input {
  flex: 1; min-width: 0; max-height: 160px; border: 0; outline: 0; resize: none;
  background: transparent; color: var(--text); font-size: 14.5px; line-height: 1.6;
  padding: 8px 0; scrollbar-width: thin;
}
#input::placeholder { color: var(--text-3); }
.composer-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; padding-bottom: 1px; }
.gen-hint { font-size: 11px; color: var(--text-3); white-space: nowrap; }
.stop-btn {
  border: 1px solid var(--border-strong); border-radius: 11px; background: transparent;
  color: var(--danger); font-size: 12px; padding: 8px 10px; height: 38px; white-space: nowrap;
}
.stop-btn:hover { background: rgba(255, 116, 133, .1); }
.send-btn {
  width: 40px; height: 40px; border: 0; border-radius: 13px; color: #fff;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 6px 18px rgba(111, 92, 231, .32);
  transition: transform .16s, opacity .16s;
}
.send-btn:hover { transform: translateY(-1px); }
.send-btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.send-btn svg { width: 19px; height: 19px; }
.foot-hint { text-align: center; font-size: 10.5px; color: var(--text-3); margin: 8px 0 0; }

/* ---------- 右侧面板 ---------- */
.panel { display: flex; flex-direction: column; min-height: 0; background: var(--bg-2); border-left: 1px solid var(--border); }
.panel-head {
  height: 64px; flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px; border-bottom: 1px solid var(--border);
}
.panel-head h2 { font-size: 14px; margin: 0; }
.panel-close { display: none; }
.panel-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 18px calc(24px + env(safe-area-inset-bottom)); }
.panel-section { padding-bottom: 20px; margin-bottom: 20px; border-bottom: 1px solid var(--border); }
.panel-section:last-child { border-bottom: 0; margin-bottom: 0; }
.panel-section h3 { font-size: 12px; margin: 0 0 12px; letter-spacing: .6px; color: var(--text-2); }
.section-head { display: flex; align-items: center; justify-content: space-between; }
.role-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.role-card {
  display: flex; align-items: center; gap: 8px; padding: 9px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface); text-align: left;
  color: var(--text); min-width: 0; transition: border-color .18s, background .18s;
}
.role-card:hover { border-color: var(--accent); }
.role-card.active { border-color: var(--accent); background: var(--accent-soft); }
.role-card .avatar { width: 30px; height: 30px; border-radius: 10px; flex: 0 0 auto; font-size: 12px; }
.role-card .r-name { font-size: 12px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.role-card .r-desc { font-size: 10px; color: var(--text-3); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.role-card .role-edit, .role-card .role-del {
  margin-left: auto; color: var(--text-3); border: 0; background: transparent;
  font-size: 11px; padding: 2px; line-height: 1; flex: 0 0 auto;
}
.role-card .role-edit + .role-del { margin-left: 2px; font-size: 14px; }
.role-card .role-edit:hover { color: var(--accent); }
.role-card .role-del:hover { color: var(--danger); }

.field { display: block; margin: 15px 0 0; }
.field-top { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-2); margin-bottom: 7px; }
.field-top b { color: var(--accent); font-variant-numeric: tabular-nums; }
.field input[type="range"] { width: 100%; accent-color: var(--accent); height: 20px; margin: 0; }
.field small { display: block; font-size: 10.5px; color: var(--text-3); margin-top: 5px; line-height: 1.5; }
.switch-field { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; font-size: 12px; color: var(--text-2); cursor: pointer; }
.switch-field input { position: absolute; opacity: 0; pointer-events: none; }
.switch-field i { width: 38px; height: 22px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border-strong); position: relative; transition: background .2s; }
.switch-field i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--text-3); transition: transform .2s, background .2s; }
.switch-field input:checked + i { background: var(--accent); border-color: var(--accent); }
.switch-field input:checked + i::after { transform: translateX(16px); background: #fff; }
.box-input {
  width: 100%; background: var(--input); color: var(--text); border: 1px solid var(--border);
  border-radius: 11px; padding: 10px 11px; font-size: 12.5px; line-height: 1.65; resize: vertical; outline: 0;
}
.box-input:focus { border-color: var(--accent); }
.lan-list { display: flex; flex-direction: column; gap: 7px; margin-top: 10px; }
.lan-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 11px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
}
.lan-item code { font-size: 11.5px; color: var(--text); word-break: break-all; }
.lan-item button { border: 0; background: transparent; color: var(--accent); font-size: 11.5px; white-space: nowrap; }

/* ---------- 遮罩 / 弹窗 / 提示 ---------- */
.scrim {
  position: fixed; inset: 0; z-index: 18; background: rgba(0, 0, 0, .55);
  opacity: 0; pointer-events: none; transition: opacity .22s;
}
.scrim.show { opacity: 1; pointer-events: auto; }
.modal-layer { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(3, 5, 12, .6); backdrop-filter: blur(6px); }
.modal {
  width: min(560px, 100%); max-height: min(86dvh, 760px); display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 20px;
  box-shadow: var(--shadow); animation: rise .22s ease both;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 15px; margin: 0; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot { padding: 14px 18px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.form-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 13px; }
.form-row label { font-size: 12px; color: var(--text-2); }
.form-row input, .form-row textarea, .form-row select {
  width: 100%; background: var(--input); color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; padding: 9px 11px; font-size: 13px; outline: 0; resize: vertical;
}
.form-row select { resize: none; }
.form-row input:focus, .form-row textarea:focus, .form-row select:focus { border-color: var(--accent); }
.form-two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-body .lan-list { margin-top: 0; }
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 14px);
  z-index: 100; padding: 10px 18px; border-radius: 12px; font-size: 12.5px;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border-strong);
  box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  max-width: min(90vw, 420px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 响应式 ---------- */
@media (max-width: 1180px) {
  .app { grid-template-columns: 258px minmax(0, 1fr); }
  .panel {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 22;
    width: min(90vw, 344px); transform: translateX(102%);
    transition: transform .24s ease; box-shadow: var(--shadow);
  }
  .panel.open { transform: none; }
  .panel-open, .panel-close { display: inline-flex; }
}
@media (max-width: 820px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 22;
    width: min(86vw, 300px); transform: translateX(-102%);
    transition: transform .24s ease; box-shadow: var(--shadow);
  }
  .sidebar.open { transform: none; }
  .menu-btn, .sidebar-close { display: inline-flex; }
  .topbar { height: 58px; padding: 0 8px; gap: 6px; }
  .top-avatar { width: 34px; height: 34px; border-radius: 11px; font-size: 13px; }
  .top-meta h1 { font-size: 14px; }
  .top-meta p { display: none; }
  .icon-btn { width: 36px; height: 36px; }
  .messages { padding: 18px 12px 8px; gap: 16px; }
  .msg-stack { max-width: 86%; }
  .bubble { font-size: 14px; padding: 11px 14px; }
  .msg-actions { opacity: 1; }
  .composer-area { padding: 8px 10px calc(9px + env(safe-area-inset-bottom)); }
  .composer { padding: 7px 7px 7px 12px; border-radius: 16px; }
  #input { font-size: 16px; } /* 避免 iOS 聚焦时自动缩放 */
  .foot-hint { display: none; }
  .gen-hint { display: none; }
  .welcome { padding: 22px 6px 6px; }
  .welcome h2 { font-size: 20px; }
  .welcome-avatar { width: 62px; height: 62px; font-size: 25px; border-radius: 20px; }
  .modal { border-radius: 18px; }
}
@media (max-width: 380px) {
  .role-grid { grid-template-columns: 1fr; }
  .top-meta { max-width: 108px; }
}
/* ---------- 登录遮罩 ---------- */
.auth-layer {
  position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(700px 420px at 50% 0%, rgba(111, 92, 231, .18), transparent 70%), var(--bg);
  backdrop-filter: blur(10px);
}
.auth-card {
  width: min(380px, 100%); padding: 30px 26px calc(26px + env(safe-area-inset-bottom));
  border: 1px solid var(--border-strong); border-radius: 22px;
  background: var(--surface); box-shadow: var(--shadow); text-align: center;
}
.auth-mark {
  width: 52px; height: 52px; margin: 0 auto 16px; border-radius: 17px;
  display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 28px rgba(111, 92, 231, .35);
}
.auth-mark svg { width: 26px; height: 26px; }
.auth-card h2 { font-size: 19px; margin: 0 0 8px; }
.auth-sub { font-size: 12.5px; color: var(--text-2); line-height: 1.7; margin: 0 0 22px; }
.auth-card form { display: flex; flex-direction: column; gap: 10px; }
.auth-card input[type="password"] {
  width: 100%; background: var(--input); color: var(--text); border: 1px solid var(--border-strong);
  border-radius: 12px; padding: 12px 13px; font-size: 15px; outline: 0; text-align: center; letter-spacing: 1px;
}
.auth-card input[type="password"]:focus { border-color: var(--accent); }
.auth-card .btn { width: 100%; min-height: 44px; border-radius: 12px; }
.auth-error { color: var(--danger); font-size: 12px; margin: 12px 0 0; line-height: 1.6; }
.auth-note { color: var(--text-3); font-size: 10.5px; line-height: 1.7; margin: 18px 0 0; }
.lan-label { font-size: 10px; color: var(--text-3); margin-top: 3px; }
.lan-item code { display: block; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
