/* 免费AI工具站 — 原生 CSS，无外部依赖。
   设计：浅色 / 深色两套主题，全部由 CSS 变量驱动。
   主题由 <html data-theme="dark|light"> 控制；无属性时为浅色。
   默认主题由 index.html head 里的内联脚本在首屏前按 localStorage
   或 prefers-color-scheme 设定，app.js 只负责切换按钮与系统变化跟随。 */

* { box-sizing: border-box; }

/* ---------- 设计变量：浅色主题 ---------- */
:root {
  color-scheme: light;
  --bg: #f5f5f4;
  --sidebar-bg: #fafaf9;
  --surface: #ffffff;
  --surface-hover: #f5f5f4;
  --text: #1c1917;
  --muted: #78716c;
  --border: #e7e5e4;
  --border-strong: #d6d3d1;
  --input-bg: #ffffff;
  --primary: #0f766e;
  --primary-hover: #115e59;
  --primary-text: #ffffff;
  --primary-soft: #e2f3f1;
  --primary-soft-text: #0f766e;
  --primary-ring: rgba(15, 118, 110, 0.18);
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --notice-bg: #fffbeb;
  --notice-border: #fcd34d;
  --ok: #16a34a;
  --shadow-sm: 0 1px 2px rgba(28, 25, 23, 0.05);
  --shadow-md: 0 4px 12px rgba(28, 25, 23, 0.08);
  --shadow-lg: 0 12px 32px rgba(28, 25, 23, 0.14);
  --overlay-bg: rgba(28, 25, 23, 0.45);
  --bubble-user-bg: #0f766e;
  --bubble-user-text: #ffffff;
  --bubble-assistant-bg: #f5f5f4;
  --tag-bg: #eef2ff;
  --tag-text: #3730a3;
  --tag-video-bg: #fdf2f8;
  --tag-video-text: #9d174d;
  --tag-failed-bg: #fef2f2;
  --tag-failed-text: #dc2626;
  --placeholder-bg: #e7e5e4;
  --track-bg: #e7e5e4;
  --result-bg: #fafaf9;
  --segment-bg: #ececea;
  --segment-active-bg: #ffffff;
  --selection-bg: rgba(15, 118, 110, 0.18);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-full: 999px;
  --sidebar-width: 248px;
}

/* ---------- 设计变量：深色主题 ---------- */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1c1917;
  --sidebar-bg: #211d1b;
  --surface: #292524;
  --surface-hover: #35302c;
  --text: #f5f5f4;
  --muted: #a8a29e;
  --border: #44403c;
  --border-strong: #57534e;
  --input-bg: #1c1917;
  --primary: #2dd4bf;
  --primary-hover: #5eead4;
  --primary-text: #042f2e;
  --primary-soft: rgba(45, 212, 191, 0.14);
  --primary-soft-text: #5eead4;
  --primary-ring: rgba(45, 212, 191, 0.25);
  --danger: #f87171;
  --danger-bg: rgba(248, 113, 113, 0.12);
  --danger-border: rgba(248, 113, 113, 0.4);
  --notice-bg: rgba(251, 191, 36, 0.1);
  --notice-border: rgba(251, 191, 36, 0.4);
  --ok: #4ade80;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.45);
  --overlay-bg: rgba(0, 0, 0, 0.6);
  --bubble-user-bg: #115e59;
  --bubble-user-text: #f0fdfa;
  --bubble-assistant-bg: #35302c;
  --tag-bg: rgba(129, 140, 248, 0.18);
  --tag-text: #c7d2fe;
  --tag-video-bg: rgba(244, 114, 182, 0.18);
  --tag-video-text: #fbcfe8;
  --tag-failed-bg: rgba(248, 113, 113, 0.15);
  --tag-failed-text: #fca5a5;
  --placeholder-bg: #44403c;
  --track-bg: #44403c;
  --result-bg: #211d1b;
  --segment-bg: #1c1917;
  --segment-active-bg: #44403c;
  --selection-bg: rgba(45, 212, 191, 0.3);
}

/* ---------- 基础 ---------- */

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
  transition: background-color 0.2s ease, color 0.2s ease;
}

::selection { background: var(--selection-bg); }

a { color: var(--primary); }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}

button { font-family: inherit; }

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 14px; }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0; }

/* 细滚动条（聊天列表 / 消息区 / 横向页签） */
.chat-messages::-webkit-scrollbar,
.chat-list::-webkit-scrollbar,
.tabs::-webkit-scrollbar,
.frame-picker::-webkit-scrollbar { width: 6px; height: 6px; }
.chat-messages::-webkit-scrollbar-thumb,
.chat-list::-webkit-scrollbar-thumb,
.tabs::-webkit-scrollbar-thumb,
.frame-picker::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 3px;
}
.chat-messages, .chat-list { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }

/* ---------- 应用外壳：侧边栏 + 主内容 ---------- */

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.sidebar {
  background: var(--sidebar-bg);
  border-bottom: 1px solid var(--border);
  padding: 12px 12px 10px;
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border-radius: 11px;
  background: var(--primary);
  color: var(--primary-text);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
}
.brand-text { min-width: 0; }
.brand-text h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.3;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.subtitle { margin: 1px 0 0; color: var(--muted); font-size: 12px; white-space: nowrap; }

/* 主题切换按钮：品牌行最右侧，移动端与桌面端都在同一位置 */
.theme-toggle {
  margin-left: auto;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.theme-toggle:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-hover); }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ---------- 页签导航 ---------- */

/* 移动端：横向滚动胶囊条；桌面端（见下方媒体查询）：纵向侧边栏菜单 */
.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 2px;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  min-height: 40px;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.tab-btn:hover { border-color: var(--border-strong); background: var(--surface-hover); }
.tab-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-text);
}
.tab-icon { width: 18px; height: 18px; flex: 0 0 auto; }

/* ---------- 主内容区 ---------- */

.main-wrap { flex: 1; min-width: 0; }

main {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 16px 16px 48px;
}

.tab-panel { display: none; }
.tab-panel.active { display: flex; flex-direction: column; gap: 16px; }

/* 表单类面板收窄，行宽更舒适 */
.panel-narrow { width: 100%; max-width: 720px; margin-left: auto; margin-right: auto; }

/* ---------- 卡片 ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  transition: background-color 0.2s ease, border-color 0.2s ease;
}
.card h2 { margin: 0 0 12px; font-size: 17px; font-weight: 700; }
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.card-head h2 { margin: 0; }

/* ---------- 表单 ---------- */

.field-label {
  display: block;
  font-weight: 600;
  font-size: 14px;
  margin: 14px 0 6px;
}
.field-label:first-child { margin-top: 0; }

textarea, input[type="text"], input[type="password"], input[type="number"], select {
  width: 100%;
  padding: 11px 12px;
  font-size: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--input-bg);
  color: var(--text);
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.2s ease;
}
textarea { resize: vertical; line-height: 1.6; }
textarea:hover, input[type="text"]:hover, input[type="password"]:hover,
input[type="number"]:hover, select:hover { border-color: var(--border-strong); }
textarea:focus, input[type="text"]:focus, input[type="password"]:focus,
input[type="number"]:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}
textarea:disabled, input:disabled, select:disabled {
  background: var(--surface-hover);
  color: var(--muted);
  cursor: not-allowed;
}
::placeholder { color: var(--muted); opacity: 0.85; }

select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2378716c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 38px;
  cursor: pointer;
}
:root[data-theme="dark"] select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23a8a29e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
}
select:disabled { cursor: not-allowed; }

input[type="file"] {
  width: 100%;
  font-size: 14px;
  padding: 12px;
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  background: var(--result-bg);
  color: var(--text);
  cursor: pointer;
}
input[type="file"]:hover { border-color: var(--primary); }

.field-group {
  border: none;
  padding: 0;
  margin: 16px 0 0;
}
.field-group legend {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  padding: 0;
  margin-bottom: 8px;
}

.radio {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 6px;
  font-size: 15px;
  cursor: pointer;
  min-height: 46px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.radio:last-of-type { margin-bottom: 0; }
.radio:hover { border-color: var(--border-strong); background: var(--surface-hover); }
.radio:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.radio input { width: 18px; height: 18px; flex: 0 0 auto; accent-color: var(--primary); margin: 0; }
.radio.disabled { color: var(--muted); cursor: not-allowed; background: var(--surface-hover); }

/* ---------- 按钮 ---------- */

.btn {
  padding: 11px 18px;
  font-size: 15px;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  min-height: 46px;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.btn:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.btn:active { background: var(--surface-hover); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); font-weight: 600; }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.primary:disabled, .btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.small { padding: 8px 14px; min-height: 38px; font-size: 14px; border-radius: 9px; }
.btn-block { width: 100%; margin-top: 14px; }
.btn.danger { color: var(--danger); border-color: var(--danger-border); }
.btn.danger:hover { background: var(--danger-bg); }

.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.flex-1 { flex: 1 1 160px; min-width: 0; }

/* ---------- 提示 / 错误 / 标签 ---------- */

.error {
  color: var(--danger);
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  margin: 12px 0 0;
  word-break: break-word;
}
.notice {
  background: var(--notice-bg);
  border: 1px solid var(--notice-border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  margin: 12px 0;
}
.notice a { color: var(--primary); font-weight: 600; }

.tag {
  display: inline-block;
  font-size: 12px;
  font-weight: 500;
  background: var(--tag-bg);
  color: var(--tag-text);
  border-radius: var(--radius-full);
  padding: 2px 8px;
  margin-right: 4px;
}
.tag.video { background: var(--tag-video-bg); color: var(--tag-video-text); }
.tag.failed { background: var(--tag-failed-bg); color: var(--tag-failed-text); }

.result-box {
  background: var(--result-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-top: 12px;
  font-size: 15px;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 48px;
}

/* ---------- 创作 ---------- */

.status-line {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  font-size: 14px;
  box-shadow: var(--shadow-sm);
}
.status-line .online, .status-line .offline {
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.status-line .online { color: var(--ok); }
.status-line .offline { color: var(--danger); }
.status-line .online::before, .status-line .offline::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  flex: 0 0 auto;
}

.create-grid { display: flex; flex-direction: column; gap: 16px; }
.create-form, .create-output { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

/* 分段控制器：出图 / 生视频 */
.mode-switch {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--segment-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.mode-btn {
  flex: 1;
  padding: 10px 12px;
  font-size: 15px;
  font-weight: 500;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  min-height: 44px;
  transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.mode-btn:hover { color: var(--text); }
.mode-btn.active {
  background: var(--segment-active-bg);
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.output-status { margin-bottom: 10px; font-size: 15px; }
.output-media img, .output-media video {
  width: 100%;
  max-height: 70vh;
  object-fit: contain;
  border-radius: var(--radius);
  background: #000;
  display: block;
}

.history-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.history-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  padding: 0;
  font-family: inherit;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.history-item:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.history-item img, .history-item video {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  background: #111;
}
.history-item .thumb-placeholder {
  width: 100%;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--placeholder-bg);
  color: var(--muted);
  font-size: 13px;
}
.history-item .meta { padding: 10px; }
.history-item .prompt {
  font-size: 13px;
  margin: 0 0 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.frame-picker {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 4px 0 8px;
}
.frame-option {
  flex: 0 0 auto;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  padding: 0;
  background: var(--surface);
  color: var(--text);
  width: 104px;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.frame-option:hover { border-color: var(--border-strong); }
.frame-option.selected { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.frame-option img { width: 100%; height: 100px; object-fit: cover; display: block; }
.frame-option .cap { font-size: 12px; padding: 6px 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- 对话 / 代码 ---------- */

.chat-toolbar { padding: 14px 16px; }
.chat-toolbar .notice { margin-bottom: 0; }

.chat-layout { display: flex; flex-direction: column; gap: 16px; min-height: 0; }
.chat-list-card, .chat-main-card { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.chat-list { display: flex; flex-direction: column; gap: 4px; max-height: 260px; overflow-y: auto; }
.chat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  border: none;
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-size: 14px;
  min-height: 46px;
  transition: background-color 0.15s ease;
}
.chat-item:hover { background: var(--surface-hover); }
.chat-item.active { background: var(--primary-soft); color: var(--primary-soft-text); font-weight: 600; }
.chat-item .title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item .del {
  color: var(--danger);
  background: none;
  border: none;
  font-size: 15px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  flex: 0 0 auto;
}
.chat-item .del:hover { background: var(--danger-bg); }
@media (hover: hover) {
  .chat-item .del { opacity: 0; }
  .chat-item:hover .del, .chat-item:focus-within .del { opacity: 1; }
}

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1 1 auto;
  min-height: 220px;
  max-height: 55vh;
  overflow-y: auto;
  margin-bottom: 12px;
  padding: 2px;
}
/* 空态提示在消息区内居中 */
.chat-messages > .muted:only-child { margin: auto; text-align: center; }
.msg {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  max-width: 88%;
}
.msg.user {
  align-self: flex-end;
  background: var(--bubble-user-bg);
  color: var(--bubble-user-text);
  border-bottom-right-radius: 6px;
}
.msg.assistant {
  align-self: flex-start;
  background: var(--bubble-assistant-bg);
  color: var(--text);
  border-bottom-left-radius: 6px;
}

/* 输入框做成一体式编辑器：聚焦时整框高亮 */
.chat-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 8px 8px 8px 12px;
  background: var(--input-bg);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.chat-input-row:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.chat-input-row textarea {
  flex: 1;
  min-width: 0;
  border: none;
  box-shadow: none;
  padding: 9px 4px;
  min-height: 46px;
  max-height: 160px;
  background: transparent;
}
.chat-input-row textarea:focus { box-shadow: none; }
.chat-input-row .btn { flex: 0 0 auto; border-radius: 11px; min-height: 44px; }

/* ---------- 识图 / 翻译 / 语音 / 向量 ---------- */

.preview img {
  max-width: 100%;
  max-height: 320px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-top: 10px;
  display: block;
}

.translate-grid { display: grid; gap: 16px; }
.translate-col { display: flex; flex-direction: column; min-width: 0; }
.translate-col textarea { flex: 1; }
.translate-col .result-box { flex: 1; margin-top: 6px; }

audio { width: 100%; margin-top: 12px; }

/* ---------- 设置 ---------- */

#providerForms { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.provider-form {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--surface);
}
.provider-form h3 { margin: 0 0 4px; font-size: 15px; font-weight: 700; }
.provider-form .configured { color: var(--ok); font-weight: 600; font-size: 13px; }
.provider-form .not-configured { color: var(--danger); font-weight: 600; font-size: 13px; }
.provider-form .quota { color: var(--muted); font-size: 13px; margin: 2px 0 8px; }
.provider-form .btn { margin-top: 12px; }

.usage-row { padding: 10px 0; border-top: 1px solid var(--border); font-size: 14px; }
.usage-row:first-child { border-top: none; padding-top: 0; }
.usage-row .bar {
  height: 8px;
  background: var(--track-bg);
  border-radius: var(--radius-full);
  margin-top: 8px;
  overflow: hidden;
}
.usage-row .bar > div { height: 100%; background: var(--primary); border-radius: var(--radius-full); }

/* ---------- 遮罩：登录 / 配置向导 ---------- */

.login-overlay, .wizard-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--overlay-bg);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  overflow-y: auto;
  padding: 24px 16px;
  display: flex;
  justify-content: center;
}
.login-overlay { align-items: center; }
.wizard-overlay { align-items: flex-start; padding-top: 48px; padding-bottom: 32px; }

.login-card {
  width: 100%;
  max-width: 400px;
  margin: 0;
  padding: 32px 28px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.login-mark {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  border-radius: 14px;
  background: var(--primary);
  color: var(--primary-text);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
}
.login-card h2 { margin: 0 0 4px; font-size: 20px; }
.login-card .muted { margin: 0 0 4px; }
.login-card .field-label { text-align: left; }
.login-card .btn { margin-top: 14px; }

.wizard-card {
  width: 100%;
  max-width: 560px;
  margin: 0;
  padding: 24px;
  box-shadow: var(--shadow-lg);
}
.wizard-card h2 { margin: 0 0 4px; }
.wizard-card h3 { margin: 0 0 4px; font-size: 17px; }
.wizard-step { margin: 0 0 12px; }
.wizard-card a { color: var(--primary); font-weight: 600; }
.wizard-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}
.wizard-actions .btn { flex: 1 1 auto; }

body.wizard-open, body.login-open { overflow: hidden; }

/* ---------- 桌面端（≥900px）：侧边栏导航 ---------- */

@media (min-width: 900px) {
  .app-shell { flex-direction: row; }

  .sidebar {
    width: var(--sidebar-width);
    flex: 0 0 var(--sidebar-width);
    height: 100vh;
    height: 100dvh;
    position: sticky;
    top: 0;
    border-bottom: none;
    border-right: 1px solid var(--border);
    padding: 20px 12px;
    gap: 20px;
    overflow-y: auto;
  }

  .brand-text h1 { font-size: 19px; }
  .subtitle { display: block; }

  /* 纵向菜单：整行可点，图标 + 文字 */
  .tabs {
    flex-direction: column;
    overflow: visible;
    gap: 3px;
    padding: 0;
  }
  .tab-btn {
    width: 100%;
    padding: 10px 12px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--text);
    font-size: 15px;
    min-height: 44px;
    gap: 11px;
  }
  .tab-btn:hover { background: var(--surface-hover); }
  .tab-btn.active { background: var(--primary-soft); color: var(--primary-soft-text); font-weight: 600; }
  .tab-icon { width: 20px; height: 20px; }

  main { padding: 28px 32px; }

  .card { padding: 20px; }

  textarea, input[type="text"], input[type="password"], input[type="number"], select { font-size: 15px; }

  /* 创作：左表单右输出 */
  .create-grid {
    display: grid;
    grid-template-columns: minmax(340px, 440px) minmax(0, 1fr);
    align-items: start;
  }

  /* 语音：TTS 与 STT 并排 */
  #panel-voice.active {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: start;
  }

  /* 翻译：原文与译文并排 */
  .translate-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }

  /* 设置：供应商两列 */
  #providerForms { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }

  /* 对话：占满视口高度，会话列表 + 消息区 + 输入框 */
  #panel-chat.active {
    height: calc(100vh - 56px);
    height: calc(100dvh - 56px);
    min-height: 540px;
  }
  .chat-layout { flex: 1; flex-direction: row; align-items: stretch; min-height: 0; }
  .chat-list-card { flex: 0 0 260px; }
  .chat-main-card { flex: 1; }
  .chat-list { flex: 1; max-height: none; min-height: 0; }
  .chat-messages { flex: 1; max-height: none; min-height: 0; }
}

/* ---------- 宽屏（≥1100px）：历史 3 列 ---------- */

@media (min-width: 1100px) {
  .history-list { grid-template-columns: repeat(3, 1fr); }
}

/* ---------- 小屏收紧 ---------- */

@media (max-width: 899px) {
  .brand .subtitle { display: none; }
  .brand-mark { width: 32px; height: 32px; border-radius: 9px; }
  .brand-text h1 { font-size: 17px; }
  .theme-toggle { width: 34px; height: 34px; }
}

/* ---------- 减动效 ---------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; }
}
