/* ==========================================================================
   生图工作台 — 样式（移动优先 · 樱桃红主题 · 深浅双色）
   ========================================================================== */

:root {
  --bg: #f5f5f7;
  --bg-2: #ffffff;
  --bg-3: #eeeef2;
  --bg-hover: #f0f0f4;
  --text: #1b1b20;
  --text-2: #70707c;
  --text-3: #a0a0ab;
  --border: #e6e6ec;
  --primary: #e0533d;
  --primary-hover: #c9452f;
  --primary-weak: #fdefec;
  --on-primary: #ffffff;
  --danger: #d64545;
  --ok: #1fa36b;
  --bubble-user: #e0533d;
  --bubble-user-text: #ffffff;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 3px rgba(20, 20, 30, .07), 0 4px 16px rgba(20, 20, 30, .05);
  --shadow-lg: 0 8px 40px rgba(20, 20, 30, .18);
  --sb-w: 264px;
  --tb-h: 54px;
  --tab-h: 58px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #141416;
  --bg-2: #1e1e22;
  --bg-3: #29292f;
  --bg-hover: #26262c;
  --text: #ececf1;
  --text-2: #9c9ca8;
  --text-3: #6d6d78;
  --border: #2e2e36;
  --primary: #e8624c;
  --primary-hover: #f0745f;
  --primary-weak: #33221f;
  --bubble-user: #d34e38;
  --shadow: 0 1px 3px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .2);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

/* ---------- 基础 ---------- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* 版本角标：右下角小圆点，一眼看出浏览器加载的是哪一版前端 */
.ver-badge {
  position: fixed;
  right: 10px;
  bottom: 10px;
  z-index: 9999;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .5px;
  color: #fff;
  background: rgba(20, 20, 30, .55);
  pointer-events: none;
  user-select: none;
}
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  overscroll-behavior: none;
}
button { font-family: inherit; border: none; background: none; color: inherit; cursor: pointer; padding: 0; }
input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
textarea { resize: none; }
[hidden] { display: none !important; }
::selection { background: rgba(224, 83, 61, .25); }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 10px; color: var(--text-2);
  transition: background .15s, color .15s;
  flex: none;
}
.icon-btn:active { background: var(--bg-3); }

.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--primary); color: var(--on-primary);
  border-radius: var(--radius-sm); font-weight: 600; font-size: 15px;
  padding: 11px 18px; transition: background .15s, transform .1s, opacity .15s;
}
.btn-primary:active { transform: scale(.97); }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-block { width: 100%; }

/* ---------- 登录页 ---------- */
.login-wrap {
  min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px 18px calc(24px + var(--safe-b));
  background:
    radial-gradient(1000px 500px at 15% -10%, rgba(224, 83, 61, .10), transparent 60%),
    radial-gradient(800px 500px at 110% 110%, rgba(224, 83, 61, .08), transparent 55%),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 400px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 34px 26px 26px;
  text-align: center;
  animation: rise .4s cubic-bezier(.2, .9, .3, 1.2);
}
@keyframes rise { from { opacity: 0; transform: translateY(16px) scale(.97); } }
.login-logo { margin-bottom: 10px; }
.login-card h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: .5px; }
.login-sub { color: var(--text-2); margin: 0 0 24px; font-size: 13.5px; }
.field { display: block; text-align: left; margin-bottom: 15px; }
.field-label { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 6px; font-weight: 600; }
.field input {
  width: 100%; padding: 12px 13px;
  background: var(--bg); border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.field input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(224, 83, 61, .14); }
.key-input-wrap { position: relative; display: block; }
.key-input-wrap input { padding-right: 46px; }
.eye-btn {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  color: var(--text-3); border-radius: 8px;
}
.login-error {
  background: rgba(214, 69, 69, .1); color: var(--danger);
  border-radius: var(--radius-sm); padding: 10px 12px; font-size: 13px;
  margin-bottom: 14px; text-align: left; word-break: break-all;
}
.login-tip { font-size: 12px; color: var(--text-3); margin: 16px 0 0; }

/* ---------- 应用布局 ---------- */
#app-view { height: 100dvh; display: flex; overflow: hidden; }
#main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }
.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* ---------- 侧边栏 ---------- */
#sidebar {
  width: var(--sb-w); flex: none;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: none; flex-direction: column;
  min-height: 0;
}
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 12px 8px 16px; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 16px; }
.view-switch { display: flex; gap: 6px; padding: 6px 12px; }
.view-tab {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 0; border-radius: 10px; font-size: 13.5px; font-weight: 600;
  color: var(--text-2); background: var(--bg-3);
  transition: background .15s, color .15s;
}
.view-tab.active { background: var(--primary-weak); color: var(--primary); }
.btn-new-conv { margin: 8px 12px 6px; padding: 10px 14px; }
.conv-list { flex: 1; overflow-y: auto; padding: 4px 8px 10px; min-height: 0; }
.conv-list::-webkit-scrollbar { width: 4px; }
.conv-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.conv-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%; text-align: left; padding: 10px 10px;
  border-radius: 10px; font-size: 13.5px; color: var(--text-2);
  transition: background .13s, color .13s;
}
.conv-item svg { flex: none; opacity: .7; }
.conv-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-item.active { background: var(--bg-3); color: var(--text); font-weight: 600; }
.conv-empty { text-align: center; color: var(--text-3); font-size: 12.5px; padding: 26px 0; }
.side-foot { border-top: 1px solid var(--border); padding: 8px; }
.side-user {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 8px; border-radius: 10px; text-align: left;
  transition: background .13s;
}
.side-user:active { background: var(--bg-3); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  background: var(--primary-weak); display: inline-flex; align-items: center; justify-content: center;
  font-size: 17px;
}
.avatar.big { width: 46px; height: 46px; font-size: 23px; }
.side-user-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.side-user-name { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-user-sub { font-size: 11.5px; color: var(--text-3); }
.side-user-arrow { color: var(--text-3); }

#drawer-mask {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .42);
  z-index: 40; animation: fade .18s;
}
@keyframes fade { from { opacity: 0; } }

/* 手机端：抽屉覆盖整个屏幕（含 tabbar），不再露出右侧 */
@media (max-width: 767.98px) {
  #sidebar.is-drawer-open {
    position: fixed !important; inset: 0 !important;
    width: 100vw !important; height: 100dvh !important;
    z-index: 60 !important; box-shadow: var(--shadow-lg);
    animation: slide-right .2s;
  }
  #drawer-close { display: inline-flex !important; }
}
@keyframes slide-right { from { transform: translateX(-100%); } to { transform: translateX(0); } }

/* ---------- 顶栏 ---------- */
.topbar {
  height: var(--tb-h); flex: none;
  display: flex; align-items: center; gap: 4px;
  padding: 0 10px 0 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
  position: relative; z-index: 5;
}
.topbar-title {
  flex: 1; min-width: 0; font-weight: 600; font-size: 15.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---------- 聊天 ---------- */
.msg-list {
  flex: 1; overflow-y: auto; min-height: 0;
  padding: 18px 14px 10px;
  scroll-behavior: smooth;
}
.chat-welcome { text-align: center; color: var(--text-3); padding: 12vh 20px 0; animation: rise .4s; }
.welcome-icon { font-size: 44px; margin-bottom: 10px; }
.chat-welcome h2 { font-size: 18px; color: var(--text-2); margin: 0 0 6px; }
.chat-welcome p { margin: 0; font-size: 13.5px; }

.msg { display: flex; gap: 10px; margin-bottom: 20px; animation: msg-in .25s ease; }
@keyframes msg-in { from { opacity: 0; transform: translateY(8px); } }
.msg-user { flex-direction: row-reverse; }
.msg-avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; background: var(--bg-3); margin-top: 2px;
}
.msg-user .msg-avatar { background: var(--primary-weak); }
.msg-body { max-width: min(86%, 720px); min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.msg-user .msg-body { align-items: flex-end; }
.bubble {
  padding: 10px 14px; border-radius: 16px;
  font-size: 14.5px; line-height: 1.65;
  overflow-wrap: break-word; word-break: break-word;
  min-width: 0;
}
.msg-user .bubble {
  background: var(--bubble-user); color: var(--bubble-user-text);
  border-bottom-right-radius: 5px;
  white-space: pre-wrap;
}
.msg-ai .bubble {
  background: var(--bg-2); border: 1px solid var(--border);
  border-bottom-left-radius: 5px;
  box-shadow: var(--shadow);
}
.msg-err .bubble { background: rgba(214, 69, 69, .08); border-color: rgba(214, 69, 69, .35); color: var(--danger); }

/* 思考过程折叠块 */
.reasoning {
  border-left: 3px solid var(--border);
  color: var(--text-3); font-size: 12.5px;
  padding: 2px 0 2px 10px; margin-bottom: 2px;
}
.reasoning summary { cursor: pointer; color: var(--text-3); user-select: none; list-style: none; display: flex; align-items: center; gap: 5px; }
.reasoning summary::before { content: "▸"; transition: transform .15s; }
.reasoning[open] summary::before { transform: rotate(90deg); }
.reasoning .reasoning-body { white-space: pre-wrap; margin-top: 6px; max-height: 240px; overflow-y: auto; }
.reasoning.streaming summary::before { animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

/* Markdown 元素（在 .bubble 内） */
.bubble p { margin: 0 0 8px; } .bubble p:last-child { margin-bottom: 0; }
.bubble h1, .bubble h2, .bubble h3, .bubble h4 { margin: 12px 0 6px; line-height: 1.4; }
.bubble h1 { font-size: 1.3em; } .bubble h2 { font-size: 1.2em; } .bubble h3 { font-size: 1.1em; }
.bubble ul, .bubble ol { margin: 6px 0; padding-left: 22px; }
.bubble li { margin: 3px 0; }
.bubble blockquote { margin: 8px 0; padding: 4px 12px; border-left: 3px solid var(--primary); background: var(--primary-weak); border-radius: 0 8px 8px 0; color: var(--text-2); }
.bubble a { color: var(--primary); text-decoration: underline; text-underline-offset: 2px; }
.bubble code {
  font-family: ui-monospace, "SF Mono", Consolas, "Courier New", monospace;
  font-size: .88em; background: var(--bg-3); padding: 2px 6px; border-radius: 6px;
}
.bubble table { border-collapse: collapse; margin: 8px 0; font-size: .92em; display: block; max-width: 100%; overflow-x: auto; }
.bubble th, .bubble td { border: 1px solid var(--border); padding: 5px 10px; text-align: left; }
.bubble th { background: var(--bg-3); }
.bubble hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }

.codeblock { margin: 8px 0; border-radius: 12px; overflow: hidden; background: #1b1b21; border: 1px solid #303039; }
.codeblock-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 12px; background: #26262e; color: #9a9aa8; font-size: 11.5px;
}
.codeblock-copy { color: #b9b9c6; font-size: 12px; padding: 3px 8px; border-radius: 6px; }
.codeblock-copy:active { background: rgba(255, 255, 255, .12); }
.codeblock pre {
  margin: 0; padding: 12px 14px; overflow-x: auto;
  color: #e8e8f0; font-size: 12.8px; line-height: 1.6;
  font-family: ui-monospace, "SF Mono", Consolas, "Courier New", monospace;
}
[data-theme="dark"] .codeblock { background: #111114; }

.cursor-blink::after {
  content: "▍"; color: var(--primary);
  animation: blink .85s steps(1) infinite; margin-left: 1px;
}
@keyframes blink { 50% { opacity: 0; } }

.msg-tools { display: flex; gap: 2px; opacity: 0; transition: opacity .15s; }
.msg:hover .msg-tools, .msg:focus-within .msg-tools { opacity: 1; }
.tool-btn {
  font-size: 12px; color: var(--text-3); padding: 4px 8px; border-radius: 7px;
  display: inline-flex; align-items: center; gap: 4px;
}
.tool-btn:active { background: var(--bg-3); color: var(--text); }

.typing-dots { display: inline-flex; gap: 4px; padding: 4px 0; }
.typing-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); animation: bounce 1.2s infinite; }
.typing-dots i:nth-child(2) { animation-delay: .15s; }
.typing-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 60%, 100% { transform: none; opacity: .4; } 30% { transform: translateY(-4px); opacity: 1; } }

/* ---------- 输入区 ---------- */
.composer {
  flex: none; display: flex; align-items: flex-end; gap: 8px;
  padding: 8px 12px calc(8px + var(--safe-b));
  background: var(--bg-2); border-top: 1px solid var(--border);
}
.composer-box {
  flex: 1; min-width: 0;
  background: var(--bg); border: 1.5px solid var(--border);
  border-radius: 18px; padding: 9px 12px 8px;
  transition: border-color .15s, box-shadow .15s;
}
.composer-box:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(224, 83, 61, .12); }
#chat-input {
  width: 100%; border: none; outline: none; background: transparent;
  font-size: 15px; line-height: 1.5; max-height: 132px; display: block;
}
.model-chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; color: var(--text-3); font-weight: 600;
  margin-top: 4px; padding: 2px 0;
}
.model-chip:active { color: var(--primary); }
.send-btn {
  width: 42px; height: 42px; flex: none; border-radius: 50%;
  background: var(--primary); color: var(--on-primary);
  display: flex; align-items: center; justify-content: center;
  transition: transform .12s, opacity .15s, background .15s;
  margin-bottom: 2px;
}
.send-btn:active { transform: scale(.92); }
.send-btn:disabled { opacity: .4; }
.send-btn.stop { background: var(--text); animation: pulse 1.2s infinite; }

/* ---------- 绘画视图 ---------- */
.paint-panel { padding: 14px 14px 4px; flex: none; }
.paint-input-wrap {
  background: var(--bg-2); border: 1.5px solid var(--border); border-radius: 16px;
  padding: 11px 13px; transition: border-color .15s, box-shadow .15s;
}
.paint-input-wrap:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(224, 83, 61, .12); }
#image-prompt { width: 100%; border: none; outline: none; background: transparent; font-size: 14.5px; line-height: 1.55; }
.paint-opts { display: none; }  /* 旧类隐藏，新结构用 .opt-block/.opt-row */
.opt-block { margin-top: 14px; }
.opt-title { font-size: 12.5px; color: var(--text-2); font-weight: 700; margin-bottom: 8px; }
.opt-row { display: flex; flex-wrap: wrap; gap: 8px 22px; }
.opt-row .opt-block { flex: 1; min-width: 220px; margin-top: 14px; }

.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-size: 13px; padding: 7px 14px; border-radius: 999px;
  background: var(--bg-3); color: var(--text-2); font-weight: 500;
  transition: background .15s, color .15s, transform .1s;
}
.chip:active { transform: scale(.95); }
.chip.active { background: var(--primary); color: var(--on-primary); font-weight: 600; }

/* 比例网格：4 列，2k/4k 选项带两行字 */
.ratio-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
}
.ratio-chip {
  background: var(--bg-3); color: var(--text-2);
  border-radius: 12px; padding: 10px 4px;
  font-size: 13px; font-weight: 600; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 1px; line-height: 1.2;
  transition: background .15s, color .15s, transform .1s;
}
.ratio-chip em { font-style: normal; font-size: 13px; }
.ratio-chip span { font-size: 10px; color: var(--text-3); font-weight: 700; letter-spacing: .5px; }
.ratio-chip:active { transform: scale(.95); }
.ratio-chip.active { background: var(--primary); color: var(--on-primary); }
.ratio-chip.active span { color: rgba(255, 255, 255, .85); }

/* 透明背景开关行 */
.opt-toggle {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  margin-top: 14px; padding: 13px 14px;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 14px;
  cursor: pointer;
}
.opt-toggle-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.opt-toggle-name { font-size: 14.5px; font-weight: 600; }
.opt-toggle-hint { font-size: 11.5px; color: var(--text-3); }

.btn-generate { width: 100%; margin-top: 16px; padding: 13px; font-size: 15.5px; }
.btn-generate.loading { opacity: .75; }

/* 透明图片：画廊里用棋盘格背景 */
.g-item.is-alpha {
  background-color: #f5f5f7;
  background-image:
    linear-gradient(45deg, #d8d8dd 25%, transparent 25%, transparent 75%, #d8d8dd 75%),
    linear-gradient(45deg, #d8d8dd 25%, transparent 25%, transparent 75%, #d8d8dd 75%);
  background-size: 16px 16px;
  background-position: 0 0, 8px 8px;
}
.g-item.is-alpha .g-badge { background: rgba(224, 83, 61, .88); }

.gallery-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 8px; flex: none;
}
.gallery-title { font-weight: 700; font-size: 15px; }
.gallery-title em { font-style: normal; color: var(--text-3); font-weight: 500; font-size: 12.5px; margin-left: 4px; }
.gallery {
  flex: 1; overflow-y: auto; min-height: 0;
  padding: 4px 14px calc(14px + var(--safe-b));
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
  align-content: start;
}
.gallery-empty { grid-column: 1 / -1; text-align: center; color: var(--text-3); padding-top: 60px; font-size: 13.5px; }
.g-item {
  position: relative; border-radius: 14px; overflow: hidden;
  background: var(--bg-3); aspect-ratio: 1; cursor: pointer;
  border: 1px solid var(--border);
}
.g-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.g-item .g-badge {
  position: absolute; left: 7px; top: 7px;
  font-size: 10.5px; background: rgba(0, 0, 0, .45); color: #fff;
  padding: 2px 8px; border-radius: 999px; backdrop-filter: blur(4px);
}
.g-item .g-skeleton {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px;
  background: linear-gradient(110deg, var(--bg-3) 30%, var(--bg-hover) 45%, var(--bg-3) 60%);
  background-size: 220% 100%; animation: shimmer 1.6s infinite;
  color: var(--text-3); font-size: 12px;
}
@keyframes shimmer { to { background-position-x: -120%; } }
.g-spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--primary);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 我的视图 ---------- */
.me-scroll {
  flex: 1; overflow-y: auto; min-height: 0;
  padding: 14px 14px calc(20px + var(--safe-b));
}
.me-card {
  background: linear-gradient(135deg, var(--primary) 0%, #c9452f 100%);
  color: #fff; border-radius: 18px; padding: 18px;
  box-shadow: 0 6px 20px rgba(224, 83, 61, .35);
}
.me-card .avatar { background: rgba(255, 255, 255, .22); }
.me-card-row { display: flex; align-items: center; gap: 13px; }
.me-key { font-weight: 700; font-size: 15.5px; letter-spacing: .5px; }
.me-sub { font-size: 12px; opacity: .85; }
.me-stats { display: flex; margin-top: 16px; border-top: 1px solid rgba(255, 255, 255, .25); padding-top: 13px; }
.me-stat { flex: 1; text-align: center; display: flex; flex-direction: column; gap: 1px; }
.me-stat b { font-size: 16px; }
.me-stat span { font-size: 11px; opacity: .8; }

.me-group {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 16px;
  margin-top: 14px; overflow: hidden;
}
.me-group-title {
  font-size: 12px; color: var(--text-3); font-weight: 700;
  padding: 12px 15px 2px; text-transform: uppercase; letter-spacing: .5px;
}
.me-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 13px 15px; font-size: 14.5px;
  border-bottom: 1px solid var(--border);
  width: 100%; text-align: left; background: none;
}
.me-item:last-child { border-bottom: none; }
.me-item.col { flex-direction: column; align-items: stretch; gap: 8px; }
.me-item > span:first-child { flex: none; color: var(--text); }
.me-item.static { color: var(--text); }
.me-val { color: var(--text-2); font-size: 13px; word-break: break-all; text-align: right; }
.me-item select {
  border: none; outline: none; background: var(--bg-3); color: var(--text);
  border-radius: 8px; padding: 7px 10px; font-size: 13.5px; max-width: 55vw;
}
.me-item textarea {
  border: 1.5px solid var(--border); background: var(--bg); border-radius: 10px;
  padding: 9px 11px; font-size: 13.5px; outline: none; width: 100%;
}
.me-item textarea:focus { border-color: var(--primary); }
.me-item.action { color: var(--text); justify-content: center; font-weight: 500; }
.me-item.action:active { background: var(--bg-3); }
.me-item.action.danger { color: var(--danger); }
.me-item input[type="range"] { width: 100%; accent-color: var(--primary); }
.toggle { appearance: none; -webkit-appearance: none; width: 46px; height: 27px; border-radius: 999px; background: var(--bg-3); position: relative; transition: background .18s; flex: none; cursor: pointer; }
.toggle::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 21px; height: 21px;
  border-radius: 50%; background: #fff; transition: transform .18s;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .25);
}
.toggle:checked { background: var(--ok); }
.toggle:checked::after { transform: translateX(19px); }
.me-version { text-align: center; color: var(--text-3); font-size: 11.5px; padding: 18px 0 4px; }

/* ---------- 手机底部导航 ---------- */
#tabbar {
  flex: none; display: flex;
  background: var(--bg-2); border-top: 1px solid var(--border);
  padding-bottom: var(--safe-b);
}
.tab-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0 7px; color: var(--text-3); font-size: 10.5px; font-weight: 500;
  transition: color .15s;
}
.tab-btn.active { color: var(--primary); }

/* ---------- 弹层（sheet） ---------- */
.sheet { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
.sheet-mask { position: absolute; inset: 0; background: rgba(0, 0, 0, .42); animation: fade .18s; }
.sheet-panel {
  position: relative; width: 100%; max-width: 420px; max-height: 72dvh; overflow-y: auto;
  background: var(--bg-2); border-radius: 20px 20px 0 0;
  padding: 8px 12px calc(14px + var(--safe-b));
  animation: slide-up .22s cubic-bezier(.2, .9, .3, 1);
}
@keyframes slide-up { from { transform: translateY(40%); opacity: .5; } }
.sheet-handle { width: 38px; height: 4px; border-radius: 4px; background: var(--border); margin: 6px auto 10px; }
.sheet-title { text-align: center; font-weight: 700; font-size: 15px; padding: 4px 0 10px; }
.sheet-action {
  display: flex; width: 100%; align-items: center; justify-content: center;
  padding: 14px; font-size: 15px; font-weight: 500; border-radius: 12px;
}
.sheet-action:active { background: var(--bg-3); }
.sheet-action.danger { color: var(--danger); }
.model-sheet-list { display: flex; flex-direction: column; gap: 4px; padding-bottom: 6px; }
.model-option {
  text-align: left; padding: 13px 14px; border-radius: 12px; font-size: 14.5px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  border: 1.5px solid transparent;
}
.model-option:active { background: var(--bg-3); }
.model-option.active { background: var(--primary-weak); border-color: var(--primary); color: var(--primary); font-weight: 600; }
.model-empty { text-align: center; color: var(--text-3); padding: 26px 0; font-size: 13.5px; }

/* ---------- 灯箱 ---------- */
#lightbox { position: fixed; inset: 0; z-index: 70; display: flex; align-items: center; justify-content: center; }
.lb-mask { position: absolute; inset: 0; background: rgba(0, 0, 0, .88); animation: fade .18s; }
.lb-body {
  position: relative; margin: 0; max-width: min(94vw, 900px); max-height: 88dvh;
  display: flex; flex-direction: column; gap: 10px; animation: rise .25s;
}
#lb-img { max-width: 100%; max-height: 66dvh; object-fit: contain; border-radius: 10px; background: #111; }
.lb-caption { color: #ddd; }
.lb-prompt {
  font-size: 13px; line-height: 1.5; max-height: 64px; overflow-y: auto;
  color: #bbb; margin-bottom: 10px; word-break: break-word;
}
.lb-actions { display: flex; gap: 8px; }
.lb-btn {
  flex: 1; text-align: center; padding: 10px 6px; border-radius: 11px;
  background: rgba(255, 255, 255, .12); color: #fff; font-size: 13.5px; font-weight: 500;
  text-decoration: none; transition: background .15s;
}
.lb-btn:active { background: rgba(255, 255, 255, .22); }
.lb-btn.danger { background: rgba(214, 69, 69, .25); color: #ffb3b3; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(76px + var(--safe-b));
  transform: translateX(-50%) translateY(20px);
  background: rgba(28, 28, 34, .94); color: #fff;
  padding: 10px 20px; border-radius: 999px; font-size: 13.5px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  z-index: 99; max-width: 86vw; text-align: center;
}
[data-theme="dark"] #toast { background: rgba(240, 240, 246, .95); color: #17171a; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ==========================================================================
   桌面端 (≥768px)：侧边栏常驻，隐藏 tabbar
   ========================================================================== */
@media (min-width: 768px) {
  .drawer-only { display: none !important; }
  #tabbar { display: none; }
  #sidebar { display: flex; }
  .msg-list { padding: 26px 24px 12px; }
  .msg-body { max-width: min(78%, 760px); }
  .msg-tools { opacity: 0; }
  .msg:hover .msg-tools { opacity: 1; }
  .composer { padding: 10px 18px calc(12px); }
  .paint-panel { max-width: 860px; width: 100%; margin: 0 auto; padding-top: 22px; }
  .gallery { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); padding: 4px 22px 22px; }
  .gallery-head { max-width: 860px; width: 100%; margin: 0 auto; padding: 20px 0 8px; }
  .me-scroll { max-width: 620px; width: 100%; margin: 0 auto; }
  .sheet { align-items: center; }
  .sheet-panel { border-radius: 20px; padding-bottom: 14px; }
  .sheet-handle { display: none; }
  #toast { bottom: 34px; }
}
@media (min-width: 1024px) {
  .gallery { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
}

/* 手机端时隐藏桌面专属行 */
@media (max-width: 767.98px) {
  .desktop-only-row { display: none; }
}

/* 滚动条（桌面） */
@media (hover: hover) {
  ::-webkit-scrollbar { width: 8px; height: 8px; }
  ::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }
  ::-webkit-scrollbar-thumb:hover { background: var(--text-3); }
  ::-webkit-scrollbar-track { background: transparent; }
}

/* 减少动效偏好 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
