/* ============================================================
   AI 对话 — 响应式样式表
   主题：浅色为默认，[data-theme="dark"] 覆盖
   ============================================================ */

:root {
  --bg: #f7f8fa;
  --panel: #ffffff;
  --panel-2: #f2f3f5;
  --text: #1a1d21;
  --muted: #6b7280;
  --faint: #9aa1ab;
  --border: #e4e6eb;
  --border-strong: #d3d7de;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef0ff;
  --user-bubble: #4f46e5;
  --user-text: #ffffff;
  --danger: #dc2626;
  --code-bg: #f4f5f7;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 40px rgba(16, 24, 40, .16);
  --sidebar-w: 268px;
  --radius: 12px;
}

[data-theme="dark"] {
  --bg: #0f1115;
  --panel: #171a20;
  --panel-2: #1e222a;
  --text: #e8eaed;
  --muted: #9aa2ad;
  --faint: #6b7280;
  --border: #272b33;
  --border-strong: #333944;
  --accent: #6366f1;
  --accent-hover: #7c7ff3;
  --accent-soft: #1e2036;
  --user-bubble: #4f46e5;
  --user-text: #ffffff;
  --danger: #f87171;
  --code-bg: #12151a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .35);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; }

/* hidden 属性必须压得住任何 display 声明，否则 .modal{display:flex} 之类会把它顶掉 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial,
    "Noto Sans SC", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  display: flex;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }

svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- 通用按钮 ---------- */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 10px;
  color: var(--muted); flex: 0 0 auto;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
.icon-btn:active { transform: scale(.95); }

.ghost-btn {
  padding: 9px 16px; border-radius: 10px;
  border: 1px solid var(--border-strong); color: var(--text);
  background: transparent; font-size: 14px; font-weight: 500;
  transition: background .15s, border-color .15s;
}
.ghost-btn:hover { background: var(--panel-2); }

.primary-btn {
  padding: 9px 20px; border-radius: 10px;
  background: var(--accent); color: #fff; font-size: 14px; font-weight: 600;
  transition: background .15s;
}
.primary-btn:hover { background: var(--accent-hover); }

.mini-btn {
  padding: 5px 10px; border-radius: 8px; font-size: 12px;
  border: 1px solid var(--border-strong); color: var(--muted);
  transition: background .15s, color .15s;
}
.mini-btn:hover { background: var(--panel-2); color: var(--text); }

/* ============================================================
   侧边栏
   ============================================================ */
.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  background: var(--panel); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; height: 100%;
  z-index: 40;
}

.sidebar-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 14px 10px;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 15.5px; }
.brand-dot {
  width: 22px; height: 22px; border-radius: 7px; flex: 0 0 auto;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  box-shadow: 0 2px 8px rgba(99, 102, 241, .4);
}
.brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-close { display: none; }

.new-chat {
  display: flex; align-items: center; gap: 9px;
  margin: 4px 12px 12px; padding: 11px 14px;
  border-radius: 11px; border: 1px solid var(--border-strong);
  color: var(--text); font-size: 14px; font-weight: 600;
  transition: background .15s, border-color .15s;
}
.new-chat:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.new-chat svg { width: 18px; height: 18px; }

.conv-list { flex: 1; overflow-y: auto; padding: 0 8px 8px; }
.conv-list::-webkit-scrollbar { width: 6px; }
.conv-list::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }

.conv-item {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 10px; border-radius: 9px; margin-bottom: 2px;
  font-size: 13.5px; color: var(--muted); cursor: pointer;
  transition: background .13s, color .13s;
}
.conv-item:hover { background: var(--panel-2); color: var(--text); }
.conv-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.conv-title { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-del {
  opacity: 0; flex: 0 0 auto; width: 24px; height: 24px; border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center; color: var(--faint);
  transition: opacity .15s, background .15s, color .15s;
}
.conv-item:hover .conv-del { opacity: 1; }
.conv-del:hover { background: var(--border); color: var(--danger); }
.conv-del svg { width: 15px; height: 15px; }
.conv-empty { padding: 18px 12px; color: var(--faint); font-size: 13px; text-align: center; }

.sidebar-foot {
  border-top: 1px solid var(--border); padding: 8px;
  display: flex; flex-direction: column; gap: 2px;
}
.foot-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 9px; font-size: 14px; color: var(--muted);
  transition: background .13s, color .13s;
}
.foot-btn:hover { background: var(--panel-2); color: var(--text); }
.foot-btn svg { width: 18px; height: 18px; }
.ico-moon { display: none; }
[data-theme="dark"] .ico-sun { display: none; }
[data-theme="dark"] .ico-moon { display: block; }

.overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .45);
  opacity: 0; pointer-events: none; transition: opacity .22s; z-index: 35;
}
.overlay.show { opacity: 1; pointer-events: auto; }

/* ============================================================
   主区
   ============================================================ */
.main {
  flex: 1; min-width: 0; height: 100%;
  display: flex; flex-direction: column; background: var(--bg);
}

.topbar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--panel) 82%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  position: relative; z-index: 20;
}
.menu-btn { display: none; }
.topbar-right { display: flex; align-items: center; gap: 2px; margin-left: auto; }

.model-picker { position: relative; }
.model-picker select {
  appearance: none; -webkit-appearance: none;
  padding: 8px 32px 8px 13px; border-radius: 10px;
  border: 1px solid var(--border-strong); background: var(--panel);
  font-size: 14px; font-weight: 600; color: var(--text);
  max-width: 46vw; text-overflow: ellipsis; cursor: pointer;
}
.model-picker::after {
  content: ""; position: absolute; right: 13px; top: 50%;
  width: 7px; height: 7px; margin-top: -5px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(45deg); pointer-events: none;
}
.model-picker select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- 聊天滚动区 ---------- */
.chat-scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; scroll-behavior: smooth; }
.chat-scroll::-webkit-scrollbar { width: 8px; }
.chat-scroll::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
.chat-scroll::-webkit-scrollbar-track { background: transparent; }

.chat-inner {
  max-width: 820px; margin: 0 auto; padding: 24px 20px 8px;
  display: flex; flex-direction: column; gap: 20px;
}

/* ---------- 欢迎屏 ---------- */
.welcome { text-align: center; padding: 8vh 8px 0; }
.welcome-logo {
  width: 60px; height: 60px; margin: 0 auto 20px; border-radius: 18px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 28px rgba(99, 102, 241, .35);
}
.welcome-logo svg { width: 30px; height: 30px; stroke: #fff; stroke-width: 1.7; }
.welcome h1 { font-size: 26px; margin: 0 0 8px; font-weight: 700; letter-spacing: -.3px; }
.welcome-sub { color: var(--muted); margin: 0 0 30px; font-size: 14px; }
.welcome-sub code { background: var(--code-bg); padding: 2px 6px; border-radius: 5px; font-size: 12.5px; }

.suggestions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; max-width: 620px; margin: 0 auto; }
.suggestions button {
  text-align: left; padding: 14px 16px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--panel);
  font-size: 13.5px; color: var(--text); line-height: 1.5;
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.suggestions button:hover { border-color: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow); }

/* ---------- 消息 ---------- */
.msg { display: flex; gap: 12px; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.msg.user { flex-direction: row-reverse; }

.avatar {
  width: 30px; height: 30px; border-radius: 9px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff; margin-top: 2px;
}
.msg.user .avatar { background: #64748b; }
.msg.assistant .avatar { background: linear-gradient(135deg, #6366f1, #8b5cf6); }
.avatar svg { width: 17px; height: 17px; stroke: #fff; stroke-width: 2; }

.bubble-col { min-width: 0; max-width: calc(100% - 44px); display: flex; flex-direction: column; }
.msg.user .bubble-col { align-items: flex-end; }

.bubble {
  padding: 11px 15px; border-radius: var(--radius);
  overflow-wrap: anywhere; word-break: break-word;
}
.msg.user .bubble {
  background: var(--user-bubble); color: var(--user-text);
  border-bottom-right-radius: 4px;
}
.msg.assistant .bubble {
  background: var(--panel); border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.msg.assistant.error .bubble { border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }

.bubble > :first-child { margin-top: 0; }
.bubble > :last-child { margin-bottom: 0; }
.bubble p { margin: 0 0 10px; }
.bubble h1, .bubble h2, .bubble h3 { margin: 16px 0 8px; line-height: 1.35; font-weight: 700; }
.bubble h1 { font-size: 1.32em; } .bubble h2 { font-size: 1.18em; } .bubble h3 { font-size: 1.05em; }
.bubble ul, .bubble ol { margin: 0 0 10px; padding-left: 1.5em; }
.bubble li { margin: 3px 0; }
.bubble a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.bubble blockquote {
  margin: 0 0 10px; padding: 2px 0 2px 13px;
  border-left: 3px solid var(--border-strong); color: var(--muted);
}
.bubble hr { border: none; border-top: 1px solid var(--border); margin: 14px 0; }
.bubble code {
  background: var(--code-bg); padding: 2px 5px; border-radius: 5px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: .88em;
}
.msg.user .bubble code { background: rgba(255, 255, 255, .2); }

.bubble table { border-collapse: collapse; width: 100%; margin: 0 0 10px; font-size: .93em; display: block; overflow-x: auto; }
.bubble th, .bubble td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.bubble th { background: var(--panel-2); font-weight: 600; }

/* 代码块 */
.code-block { margin: 0 0 12px; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); background: var(--code-bg); }
.code-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 10px 6px 13px; background: var(--panel-2);
  font-size: 11.5px; color: var(--muted); font-weight: 600;
  letter-spacing: .3px; text-transform: uppercase;
}
.code-copy {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 6px; font-size: 11.5px;
  color: var(--muted); text-transform: none; letter-spacing: 0; font-weight: 500;
  transition: background .15s, color .15s;
}
.code-copy:hover { background: var(--border); color: var(--text); }
.code-copy svg { width: 13px; height: 13px; }
.code-block pre { margin: 0; padding: 13px; overflow-x: auto; }
.code-block pre code {
  background: none; padding: 0; font-size: 13px; line-height: 1.62;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  white-space: pre;
}

/* 思考过程 */
.reasoning {
  margin: 0 0 10px; border: 1px dashed var(--border-strong);
  border-radius: 10px; background: var(--panel-2); overflow: hidden;
}
.reasoning summary {
  padding: 8px 12px; font-size: 12.5px; color: var(--muted);
  cursor: pointer; user-select: none; list-style: none;
  display: flex; align-items: center; gap: 7px; font-weight: 600;
}
.reasoning summary::-webkit-details-marker { display: none; }
.reasoning summary::before {
  content: ""; width: 6px; height: 6px; border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor; transform: rotate(-45deg);
  transition: transform .18s; margin-left: 2px;
}
.reasoning[open] summary::before { transform: rotate(45deg); }
.reasoning .reason-body {
  padding: 0 12px 10px; font-size: 13px; color: var(--muted);
  white-space: pre-wrap; overflow-wrap: anywhere;
  max-height: 320px; overflow-y: auto; border-top: 1px solid var(--border);
  padding-top: 9px;
}

/* 光标 & 状态 */
.cursor { display: inline-block; width: 7px; height: 1.05em; background: var(--accent); border-radius: 1px; vertical-align: -2px; margin-left: 2px; animation: blink 1s steps(2, start) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.thinking { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13.5px; }
.thinking i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: bounce 1.2s infinite; }
.thinking i:nth-child(2) { animation-delay: .15s; }
.thinking i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* 消息操作条 */
.msg-actions { display: flex; gap: 2px; margin-top: 5px; opacity: 0; transition: opacity .18s; }
.msg:hover .msg-actions { opacity: 1; }
@media (hover: none) { .msg-actions { opacity: 1; } }
.msg-actions button {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 9px; border-radius: 7px; font-size: 12px; color: var(--faint);
  transition: background .15s, color .15s;
}
.msg-actions button:hover { background: var(--panel-2); color: var(--text); }
.msg-actions svg { width: 14px; height: 14px; }
.msg-meta { font-size: 11.5px; color: var(--faint); margin-top: 4px; }

/* ============================================================
   输入区
   ============================================================ */
.composer-wrap { padding: 6px 20px calc(14px + env(safe-area-inset-bottom)); background: var(--bg); }
.composer {
  position: relative; max-width: 820px; margin: 0 auto;
  background: var(--panel); border: 1px solid var(--border-strong);
  border-radius: 18px; box-shadow: var(--shadow);
  display: flex; align-items: flex-end; gap: 6px;
  padding: 8px 8px 8px 16px;
  transition: border-color .15s, box-shadow .15s;
}
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow); }
.composer textarea {
  flex: 1; border: none; background: none; resize: none; outline: none;
  max-height: 200px; min-height: 24px; padding: 7px 0; font-size: 15px;
  line-height: 1.55; overflow-y: auto;
}
.composer textarea::placeholder { color: var(--faint); }
.composer-actions { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.params-btn { width: 36px; height: 36px; }
.params-btn.active { background: var(--accent-soft); color: var(--accent); }

.send-btn {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--accent); color: #fff; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s, transform .1s, opacity .15s;
}
.send-btn:hover { background: var(--accent-hover); }
.send-btn:active { transform: scale(.93); }
.send-btn:disabled { opacity: .4; cursor: not-allowed; }
.send-btn svg { width: 19px; height: 19px; }
.send-btn .ico-stop { display: none; fill: currentColor; }
.send-btn.streaming { background: var(--text); }
.send-btn.streaming .ico-send { display: none; }
.send-btn.streaming .ico-stop { display: block; }

.disclaimer { text-align: center; font-size: 11.5px; color: var(--faint); margin: 8px 0 0; }

/* 参数浮层 */
.popover {
  position: absolute; bottom: calc(100% + 10px); right: 0;
  width: 288px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow-lg); padding: 14px; z-index: 30;
  animation: fade .16s ease;
}
.pop-row { margin-bottom: 14px; }
.pop-row:last-child { margin-bottom: 0; }
.pop-row > label { display: flex; align-items: center; justify-content: space-between; font-size: 13px; color: var(--muted); margin-bottom: 7px; font-weight: 500; }
.p-val { color: var(--accent); font-weight: 600; font-variant-numeric: tabular-nums; }
.pop-row input[type="range"] { width: 100%; accent-color: var(--accent); }
.pop-row select { width: 100%; padding: 7px 10px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--panel); font-size: 13.5px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; }
.switch-row > label { margin: 0; font-size: 13px; color: var(--muted); }

.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span {
  position: absolute; inset: 0; border-radius: 999px;
  background: var(--border-strong); transition: background .18s;
}
.switch span::before {
  content: ""; position: absolute; left: 3px; top: 3px;
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  transition: transform .18s; box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::before { transform: translateX(18px); }

/* ============================================================
   设置弹窗
   ============================================================ */
.modal {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(15, 17, 21, .5); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fade .18s ease;
}
.modal-card {
  width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto;
  background: var(--panel); border-radius: 18px; box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 10px; }
.modal-head h2 { margin: 0; font-size: 18px; font-weight: 700; }
.modal-body { padding: 6px 20px 4px; }
.field { margin-bottom: 16px; }
.field > label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field > label .req { color: var(--danger); }
.field input[type="text"], .field input[type="url"], .field input[type="password"], .field textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--border-strong); background: var(--panel-2);
  font-size: 14px; outline: none; transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
}
.field textarea { resize: vertical; line-height: 1.55; }
.field input:focus, .field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field .hint { font-size: 12px; color: var(--faint); margin: 6px 0 0; line-height: 1.5; }
.field .hint code { background: var(--code-bg); padding: 1px 5px; border-radius: 4px; font-size: 11.5px; }
.input-row { display: flex; gap: 8px; }
.input-row input { flex: 1; }
.field-row { display: flex; gap: 16px; align-items: flex-start; }
.field-row .field { flex: 1; margin-bottom: 16px; }
.field-row .field > label { display: flex; align-items: center; justify-content: space-between; }

.modal-foot-actions { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.test-result { font-size: 12.5px; color: var(--muted); }
.test-result.ok { color: #16a34a; }
.test-result.bad { color: var(--danger); }

.modal-foot {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 14px 20px calc(18px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border); margin-top: 8px;
}

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%) translateY(10px);
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 10px;
  font-size: 13.5px; box-shadow: var(--shadow-lg); z-index: 80;
  opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============================================================
   私有门 —— 首次使用需输入访问密钥
   ------------------------------------------------------------
   密钥由 Pages 变量 ACCESS_KEY 指定。前端只负责"好看 + 记住"，
   真正的强制点在 functions/v1/[[path]].js（绕过前端直接打 /v1/*
   也会因为没有 x-access-key 而拿 401）。
   ============================================================ */
.gate {
  position: fixed; inset: 0; z-index: 90;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  animation: fade .18s ease;
}
.gate-card {
  width: 100%; max-width: 384px; text-align: center;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 20px; box-shadow: var(--shadow-lg);
  padding: 34px 26px 26px;
}
.gate-logo {
  width: 52px; height: 52px; margin: 0 auto 16px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 15px; background: var(--accent-soft); color: var(--accent);
}
.gate-logo svg { width: 26px; height: 26px; }
.gate-card h2 { margin: 0 0 8px; font-size: 19px; font-weight: 700; }
.gate-sub {
  margin: 0 0 20px; font-size: 13px; color: var(--muted);
  line-height: 1.6; text-align: center;
}
.gate-card input[type="password"] {
  width: 100%; padding: 11px 13px; border-radius: 11px;
  border: 1px solid var(--border-strong); background: var(--panel-2);
  font-size: 14px; outline: none; text-align: center;
  letter-spacing: .05em; transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
}
.gate-card input[type="password"]:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.gate-err { margin: 10px 0 0; font-size: 12.5px; color: var(--danger); }
.gate-btn { width: 100%; margin-top: 16px; }
.gate-btn:disabled { opacity: .55; cursor: default; }
.gate-btn:disabled:hover { background: var(--accent); }

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 900px) {
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    transform: translateX(-100%); transition: transform .24s cubic-bezier(.4, 0, .2, 1);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: none; }
  .sidebar-close { display: inline-flex; }
  .menu-btn { display: inline-flex; }
  .chat-inner { padding: 16px 14px 8px; }
  .composer-wrap { padding: 6px 12px calc(12px + env(safe-area-inset-bottom)); }
  .welcome { padding-top: 5vh; }
  .welcome h1 { font-size: 22px; }
  .suggestions { grid-template-columns: 1fr; }
  .popover { width: calc(100vw - 32px); right: -4px; }
  .field-row { flex-direction: column; gap: 0; }
  .msg-actions { opacity: 1; }
}

@media (max-width: 420px) {
  body { font-size: 14.5px; }
  .chat-inner { padding: 12px 10px 6px; gap: 16px; }
  .bubble-col { max-width: calc(100% - 40px); }
  .avatar { width: 26px; height: 26px; }
}

/* 打印 */
@media print {
  .sidebar, .topbar, .composer-wrap, .msg-actions { display: none !important; }
  .chat-scroll { overflow: visible; height: auto; }
  body { overflow: visible; height: auto; }
}
