/* 主题变量：统一管理颜色、阴影、边框等设计基准 */
:root {
  --bg: #f5f4f0;
  --bg-deep: #e9e7e2;
  --ink: #101113;
  --muted: #6b6f76;
  --accent: #f4f4f5;
  --accent-2: #d4d4d8;
  --card: rgba(255, 255, 255, 0.72);
  --line: rgba(16, 17, 19, 0.12);
  --outline: rgba(16, 17, 19, 0.18);
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.12);
}

/* 深色主题：覆盖变量并调整背景渐变 */
body[data-theme="dark"] {
  --bg: #0a0b0e;
  --bg-deep: #0f1116;
  --ink: #f5f5f5;
  --muted: #a1a1aa;
  --accent: #f4f4f5;
  --accent-2: #d4d4d8;
  --card: rgba(0, 0, 0, 0.42);
  --line: rgba(255, 255, 255, 0.12);
  --outline: rgba(63, 63, 70, 0.8);
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  color-scheme: dark;
  background: radial-gradient(circle at 18% 0%, rgba(255, 255, 255, 0.08), transparent 45%),
    radial-gradient(circle at 80% 10%, rgba(255, 255, 255, 0.05), transparent 50%),
    linear-gradient(160deg, var(--bg) 0%, var(--bg-deep) 100%);
}

/* 全局基础规则：统一盒模型 */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* 通用隐藏属性 */
[hidden] {
  display: none !important;
}

/* 页面基础样式与背景氛围 */
body {
  margin: 0;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 20% 0%, rgba(255, 255, 255, 0.18), transparent 40%),
    radial-gradient(circle at 80% 10%, rgba(255, 255, 255, 0.1), transparent 45%),
    linear-gradient(160deg, var(--bg) 0%, var(--bg-deep) 100%);
  min-height: 100vh;
  color-scheme: light;
}

/* 弹窗打开时禁止页面滚动 */
body.modal-open {
  overflow: hidden;
}

/* 顶部栏布局：左右两侧按钮 + 中间品牌 */
.top-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.top-bar > :first-child {
  justify-self: start;
}

.top-bar > :last-child {
  justify-self: end;
}

/* 设置页顶部栏：简化布局 */
.top-bar.simple {
  display: flex;
  justify-content: space-between;
}

/* 顶部提示条（toast） */
.notice {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  opacity: 0;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.6);
  color: var(--ink);
  font-size: 0.85rem;
  letter-spacing: 0.01em;
  z-index: 320;
  pointer-events: none;
  backdrop-filter: blur(12px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.notice.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.notice[data-tone="error"] {
  color: #f2cfcf;
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(55, 20, 20, 0.6);
}

/* 品牌文字样式 */
.brand {
  font-family: "DM Serif Display", serif;
  font-size: 1.05rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--ink);
  font-weight: 500;
  text-align: center;
}

/* 模型提示条（可放在标题下方） */
.model-indicator {
  display: flex;
  justify-content: center;
  margin: 6px 0 20px;
}

/* 返回/设置链接按钮 */
.settings-link {
  text-decoration: none;
  color: var(--muted);
  border: 1px solid var(--outline);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  background: transparent;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.settings-link:hover {
  color: var(--ink);
  border-color: var(--line);
}

.settings-link.large {
  padding: 10px 22px;
  font-size: 1rem;
  font-weight: 600;
}

/* 页面内容最大宽度与内边距 */
.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 48px 24px calc(72px + env(safe-area-inset-bottom));
}

/* 独立登录页容器：收窄宽度并居中 */
.auth-page {
  max-width: 560px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* 登录页仅保留单列布局 */
.auth-grid {
  grid-template-columns: minmax(0, 1fr);
}

/* Hero 区域：介绍文本 + 信息卡片 */
.hero {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 32px;
  align-items: center;
  margin-bottom: 42px;
}

/* 紧凑版 Hero（用于设置页） */
.hero.compact {
  margin-bottom: 32px;
}

/* Hero 标题样式 */
.hero-text h1 {
  font-family: "DM Serif Display", serif;
  font-size: clamp(2.4rem, 4vw, 3.5rem);
  margin: 8px 0 12px;
}

/* 小标题（上方的提示文字） */
.kicker {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.75rem;
  color: var(--muted);
}

/* 导语文字 */
.lead {
  font-size: 1.05rem;
  color: var(--muted);
  max-width: 420px;
}

/* Hero 右侧卡片 */
.hero-card {
  background: var(--card);
  border-radius: 22px;
  padding: 24px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  animation: floatIn 0.8s ease both;
}

/* 小徽章标签 */
.badge {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(15, 15, 18, 0.08);
  color: var(--ink);
  font-weight: 600;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 12px;
}

/* 说明性文字 */
.meta {
  color: var(--muted);
  margin: 0;
}

/* 通用网格布局：左右两栏或自适应多列 */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
}

/* 面板进入动画（轻微上浮） */
.grid > .panel {
  animation: panelIn 0.7s ease both;
}

.grid > .panel:nth-child(1) {
  animation-delay: 0.04s;
}

.grid > .panel:nth-child(2) {
  animation-delay: 0.1s;
}

.grid > .panel:nth-child(3) {
  animation-delay: 0.16s;
}

.grid > .panel:nth-child(4) {
  animation-delay: 0.22s;
}

/* 卡片面板：用于表单、结果、设置等区域 */
.panel {
  background: var(--card);
  backdrop-filter: blur(14px);
  border-radius: 20px;
  padding: 24px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

/* 面板标题 */
.panel h2 {
  margin-top: 0;
  margin-bottom: 16px;
  font-size: 1.2rem;
}

/* 表单字段：统一纵向布局与间距 */
.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
  font-size: 0.95rem;
  width: 100%;
}

/* 输入堆叠：把文本区与上传区组合成一个整体 */
.input-stack {
  display: grid;
  gap: 0;
  padding: 0;
  border-radius: 18px;
  border: 1px solid var(--outline);
  background: rgba(0, 0, 0, 0.28);
  overflow: hidden;
}

/* 输入聚焦时的高亮边框 */
.input-stack:focus-within {
  border-color: var(--line);
}

/* 堆叠内部的字段间距 */
.input-stack .field {
  margin-bottom: 0;
  padding: 14px 16px;
  gap: 10px;
}

/* 堆叠内分隔线 */
.input-stack .field + .field {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* 上传字段的额外内边距 */
.input-stack .field.file {
  padding-top: 12px;
}

/* 字段行：左右对齐的文本与按钮 */
.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* 文本域容器：便于放置“粘贴”按钮 */
.textarea-wrap {
  position: relative;
  width: 100%;
  display: block;
}

/* 文本域基础尺寸 */
.textarea-wrap textarea {
  width: 100%;
  display: block;
  padding: 16px 104px 60px 14px;
  min-height: 140px;
}

/* 堆叠内文本域：透明背景以融入容器 */
.input-stack .textarea-wrap textarea {
  background: transparent;
  border: 0;
  padding: 0 96px 44px 0;
  min-height: 140px;
}

/* 一键粘贴按钮 */
.paste-button {
  position: absolute;
  right: 0;
  bottom: 0;
  top: auto;
  transform: none;
  width: auto;
  min-width: 72px;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--outline);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  box-shadow: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* 表单控件统一外观 */
.field input,
.field textarea,
.field select {
  border-radius: 14px;
  border: 1px solid var(--outline);
  padding: 12px 14px;
  font-size: 0.95rem;
  font-family: inherit;
  background: rgba(255, 255, 255, 0.75);
  color: var(--ink);
}

/* 文本域允许竖向拖拽调整高度 */
.field textarea {
  resize: vertical;
}

/* 聚焦状态：边框高亮、去掉默认 outline */
.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: var(--line);
}

/* Key 输入框：用圆点遮罩，防止直接泄露 */
.key-input.masked {
  -webkit-text-security: disc;
  text-security: disc;
  color: transparent;
  text-shadow: 0 0 8px rgba(16, 17, 19, 0.6);
  caret-color: var(--ink);
}

/* 上传拖拽/点击区域 */
.dropzone {
  position: relative;
  border-radius: 16px;
  border: 1px dashed var(--outline);
  background: rgba(255, 255, 255, 0.4);
  padding: 18px;
  min-height: 120px;
  display: grid;
  place-items: center;
  gap: 12px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}

/* 堆叠内 dropzone 的背景更深 */
.input-stack .dropzone {
  background: rgba(0, 0, 0, 0.2);
  border-color: rgba(255, 255, 255, 0.12);
}

/* 悬停时边框高亮 */
.dropzone:hover {
  border-color: var(--line);
}

/* 键盘聚焦时可见的外边框 */
.dropzone:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.2);
  outline-offset: 3px;
}

/* 空状态：图标 + 提示文案 */
.dropzone-empty {
  display: grid;
  gap: 10px;
  justify-items: center;
}

/* 空状态图标 */
.dropzone-empty svg {
  width: 28px;
  height: 28px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* 预览容器 */
.dropzone-preview {
  display: grid;
  gap: 12px;
  width: 100%;
}

/* 缩略图网格布局 */
.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 10px;
}

/* 单个缩略图容器 */
.preview-item {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.25);
}

/* 缩略图样式 */
.preview-item img {
  width: 100%;
  height: 72px;
  object-fit: cover;
  display: block;
}

/* 缩略图右上角的删除按钮 */
.preview-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.6);
  color: #f5f5f5;
  font-size: 0.85rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* 预览下方的文件信息 + 清空按钮 */
.preview-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

/* 真正的 file input 隐藏，只用来触发文件选择 */
.file-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}

/* 选中文件名：超长时省略 */
.file-name {
  font-size: 0.85rem;
  color: var(--muted);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 小徽章容器（例如提示/警告） */
.meta-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 6px 0 18px;
}

/* 胶囊标签（通用） */
.pill {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.75rem;
  background: rgba(15, 15, 18, 0.08);
  border: 1px solid rgba(16, 17, 19, 0.12);
  color: var(--muted);
  letter-spacing: 0.02em;
}

/* 警示状态的胶囊 */
.pill.warn {
  color: #e6b9b9;
  border-color: rgba(255, 255, 255, 0.16);
}

/* 低对比度胶囊 */
.pill.subtle {
  background: rgba(15, 15, 18, 0.06);
  border-color: rgba(16, 17, 19, 0.1);
}

/* 按钮基础样式 */
button {
  width: 100%;
  padding: 12px 18px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--accent);
  color: #0a0a0a;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.22);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 28px rgba(0, 0, 0, 0.28);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
}

/* 幽灵按钮：轻量外观 */
.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--outline);
  box-shadow: none;
}

/* 幽灵按钮的悬停状态 */
.ghost:hover {
  color: var(--ink);
  border-color: var(--line);
  box-shadow: none;
}

/* 键盘聚焦可见轮廓 */
.ghost:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.2);
  outline-offset: 2px;
}

/* 粘贴按钮在 button 基础上的覆盖 */
button.paste-button {
  width: auto;
  box-shadow: none;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--outline);
  color: var(--muted);
}

/* 小号按钮 */
.ghost.small {
  padding: 6px 12px;
  font-size: 0.9rem;
}

/* 大号按钮 */
.ghost.large {
  padding: 10px 22px;
  font-size: 1rem;
  font-weight: 600;
}

/* 文本型链接按钮 */
.text-link {
  background: transparent;
  border: none;
  padding: 0;
  color: var(--muted);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

/* 图标按钮：用于顶部栏 */
.icon-button {
  width: 40px;
  height: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  box-shadow: none;
}

/* 图标按钮的悬停状态 */
.icon-button:hover {
  transform: none;
  box-shadow: none;
}

/* 图标线条样式 */
.icon-button svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.paste-button:hover {
  color: var(--ink);
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.12);
}

/* 输出区头部：标题 + 操作按钮 */
.output-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

/* 输出区右侧操作区 */
.output-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* 输出区按钮的尺寸 */
.output-actions button {
  width: auto;
}

/* 状态标签：就绪/处理中 */
.status {
  font-size: 0.85rem;
  color: var(--muted);
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--outline);
  background: rgba(255, 255, 255, 0.7);
}

/* 加载中时的状态样式 */
.status.loading {
  color: var(--ink);
  border-color: var(--line);
}

/* 旋转加载指示器 */
.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--outline);
  border-top-color: var(--ink);
  animation: spin 0.9s linear infinite;
}

/* 答案展示区域 */
.answer {
  min-height: 220px;
  padding: 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
  white-space: pre-wrap;
  line-height: 1.6;
  font-size: 0.98rem;
}

/* 历史记录列表容器 */
.history-list {
  display: grid;
  gap: 14px;
}

/* 单条历史记录（可展开） */
.history-item {
  border-radius: 16px;
  border: 1px solid var(--line);
  padding: 14px;
  background: rgba(255, 255, 255, 0.6);
  display: grid;
  gap: 10px;
  backdrop-filter: blur(10px);
}

/* 展开时的提示文字 */
.history-item[open] .history-open {
  color: var(--ink);
}

/* <summary> 行布局 */
.history-summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.92rem;
  font-weight: 600;
}

/* 去掉默认三角标记 */
.history-summary::-webkit-details-marker {
  display: none;
}

/* “查看详情”提示文字 */
.history-open {
  font-size: 0.85rem;
  color: var(--muted);
}

/* 历史记录中的附加信息（如图片名） */
.history-meta {
  font-size: 0.85rem;
  color: var(--muted);
}

.history-images {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}

.history-images img {
  width: 100%;
  height: 96px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--line);
}

/* 历史记录中的正文块 */
.history-block {
  font-size: 0.92rem;
  line-height: 1.5;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  white-space: pre-wrap;
}

/* 历史为空时的占位文字 */
.history-empty {
  color: var(--muted);
  font-size: 0.9rem;
}

/* 弹窗容器：覆盖全屏，默认隐藏 */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: opacity 0.25s ease;
  z-index: 200;
}

/* 弹窗打开时：显示并接收事件 */
.modal.is-open {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
}

/* 默认禁止弹窗内元素交互（打开时再启用） */
.modal * {
  pointer-events: none;
}

/* 打开后恢复弹窗内交互 */
.modal.is-open * {
  pointer-events: auto;
}

/* 遮罩层 */
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 7, 10, 0.6);
  backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity 0.25s ease;
}

/* 遮罩显示状态 */
.modal.is-open .modal-backdrop {
  opacity: 1;
}

/* 弹窗主体卡片 */
.modal-card {
  position: relative;
  width: min(960px, 92vw);
  max-height: 86vh;
  overflow: hidden;
  border-radius: 24px;
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  transform: translateY(16px) scale(0.98);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  z-index: 2;
}

/* 登录弹窗尺寸更紧凑，避免空白过多 */
.login-modal .modal-card {
  width: min(520px, 92vw);
}

/* 弹窗进入动画 */
.modal.is-open .modal-card {
  transform: translateY(0) scale(1);
  opacity: 1;
}

/* 弹窗头部：标题与操作 */
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 20px 24px 12px;
  border-bottom: 1px solid var(--line);
}

/* 弹窗标题 */
.modal-head h2 {
  margin: 0 0 6px;
}

/* 弹窗副标题 */
.modal-sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

/* 弹窗右侧操作区 */
.modal-actions {
  display: flex;
  gap: 8px;
}

/* 弹窗内容区（可滚动） */
.modal-body {
  padding: 20px 24px 26px;
  overflow: auto;
  max-height: calc(86vh - 84px);
}

/* 使用次数详情标签页 */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.tab {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
}

.tab.is-active {
  background: var(--ink);
  color: var(--bg);
  border-color: transparent;
}

.chart-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.chart-range {
  font-size: 0.85rem;
  color: var(--muted);
}

.usage-chart {
  width: 100%;
  height: 160px;
  display: block;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--line);
  margin-bottom: 12px;
}

body[data-theme="dark"] .usage-chart {
  background: rgba(0, 0, 0, 0.35);
}

/* 错误提示卡片 */
.error {
  margin-top: 12px;
  color: #8b1d1d;
  background: rgba(255, 235, 235, 0.7);
  border: 1px solid rgba(139, 29, 29, 0.12);
  border-radius: 12px;
  padding: 10px 12px;
}

/* 错误标题行：标题 + 查看详情按钮 */
.error-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.9rem;
}

/* 详细错误信息 */
.error-details {
  margin-top: 8px;
  color: #7a1a1a;
  font-size: 0.88rem;
  white-space: pre-wrap;
}

/* 面板按钮区 */
.panel-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

/* 面板按钮的统一宽度 */
.panel-actions button {
  width: auto;
  flex: 1;
}

/* 辅助说明文字 */
.hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 10px;
}

/* Key 列表与用量列表容器 */
.key-list,
.usage-list {
  display: grid;
  gap: 8px;
}

/* Key 与用量的胶囊条目 */
.key-pill,
.usage-row {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 0.85rem;
  background: rgba(255, 255, 255, 0.6);
}

.key-pill.invalid {
  border-color: rgba(139, 29, 29, 0.4);
  color: #8b1d1d;
  background: rgba(255, 235, 235, 0.7);
}

/* 用量汇总文字 */
.usage-summary {
  font-size: 0.95rem;
  margin-bottom: 12px;
}

.voiceprint-card {
  margin: 14px 0 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.55);
}

.admin-block {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
}

.admin-head-row h3,
.admin-block h3 {
  margin: 0;
  font-size: 1rem;
}

.admin-users-list {
  display: grid;
  gap: 12px;
  max-height: 48vh;
  overflow: auto;
}

.admin-user-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.62);
}

.admin-user-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.admin-user-actions button {
  flex: 1;
}

.admin-user-actions {
  flex-wrap: wrap;
}

.admin-user-history {
  margin: 8px 0 0;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
  white-space: pre-wrap;
  font-size: 0.82rem;
  line-height: 1.4;
}

.auth-message[data-tone="error"] {
  color: #8b1d1d;
}

.voiceprint-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 14px;
  background: rgba(255, 255, 255, 0.48);
}

.voiceprint-card .panel-actions {
  margin-bottom: 8px;
}

#voiceprintStatus[data-tone="success"],
#adminConsoleStatus[data-tone="success"],
#unifiedApiStatus[data-tone="success"],
#adminUsersStatus[data-tone="success"],
.admin-user-status[data-tone="success"] {
  color: #1d6b3c;
}

#voiceprintStatus[data-tone="warn"],
#adminConsoleStatus[data-tone="warn"],
#unifiedApiStatus[data-tone="warn"],
#adminUsersStatus[data-tone="warn"],
.admin-user-status[data-tone="warn"] {
  color: #9a6a15;
}

#voiceprintStatus[data-tone="error"],
#adminConsoleStatus[data-tone="error"],
#unifiedApiStatus[data-tone="error"],
#adminUsersStatus[data-tone="error"],
.admin-user-status[data-tone="error"] {
  color: #8b1d1d;
}

.admin-panel {
  grid-column: 1 / -1;
}

.admin-block {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  margin-top: 14px;
  background: rgba(255, 255, 255, 0.52);
}

.admin-block h3 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.admin-head-row h3 {
  margin: 0;
}

.admin-users-list {
  display: grid;
  gap: 10px;
}

.admin-user-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.62);
  padding: 10px 12px;
}

.admin-user-summary {
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 600;
}

.admin-user-summary::-webkit-details-marker {
  display: none;
}

.admin-user-role {
  display: inline-flex;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 0.8rem;
  color: var(--muted);
}

.admin-user-body {
  margin-top: 12px;
}

body[data-theme="dark"] .auth-message[data-tone="error"] {
  color: #f0caca;
}

body[data-theme="dark"] .voiceprint-card,
body[data-theme="dark"] .admin-user-card,
body[data-theme="dark"] .admin-user-history {
  background: rgba(0, 0, 0, 0.36);
}

body[data-theme="dark"] #voiceprintStatus[data-tone="success"],
body[data-theme="dark"] #adminConsoleStatus[data-tone="success"],
body[data-theme="dark"] #unifiedApiStatus[data-tone="success"],
body[data-theme="dark"] #adminUsersStatus[data-tone="success"],
body[data-theme="dark"] .admin-user-status[data-tone="success"] {
  color: #9ae5b7;
}

body[data-theme="dark"] #voiceprintStatus[data-tone="warn"],
body[data-theme="dark"] #adminConsoleStatus[data-tone="warn"],
body[data-theme="dark"] #unifiedApiStatus[data-tone="warn"],
body[data-theme="dark"] #adminUsersStatus[data-tone="warn"],
body[data-theme="dark"] .admin-user-status[data-tone="warn"] {
  color: #f3d18c;
}

body[data-theme="dark"] #voiceprintStatus[data-tone="error"],
body[data-theme="dark"] #adminConsoleStatus[data-tone="error"],
body[data-theme="dark"] #unifiedApiStatus[data-tone="error"],
body[data-theme="dark"] #adminUsersStatus[data-tone="error"],
body[data-theme="dark"] .admin-user-status[data-tone="error"] {
  color: #f0caca;
}

/* 设置页网格：比默认更紧凑 */
.settings-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

/* 页脚小字 */
.footer {
  margin-top: 32px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.85rem;
}

/* 动画：卡片轻浮入场 */
@keyframes floatIn {
  from {
    transform: translateY(16px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* 动画：面板淡入 */
@keyframes panelIn {
  from {
    transform: translateY(14px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* 动画：加载旋转 */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* 深色主题：组件级别的细节覆盖 */
body[data-theme="dark"] .panel {
  background: var(--card);
}

body[data-theme="dark"] .hero-card,
body[data-theme="dark"] .key-pill,
body[data-theme="dark"] .usage-row,
body[data-theme="dark"] .history-item,
body[data-theme="dark"] .history-block,
body[data-theme="dark"] .dropzone {
  background: rgba(0, 0, 0, 0.35);
}

body[data-theme="dark"] .key-pill.invalid {
  color: #f2cfcf;
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(68, 30, 30, 0.35);
}

body[data-theme="dark"] .badge {
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
}

body[data-theme="dark"] .modal-card {
  background: rgba(5, 5, 7, 0.7);
}

body[data-theme="dark"] .field input,
body[data-theme="dark"] .field textarea,
body[data-theme="dark"] .field select,
body[data-theme="dark"] .status,
body[data-theme="dark"] .answer {
  background: rgba(0, 0, 0, 0.35);
  color: var(--ink);
  border-color: var(--outline);
}

body[data-theme="dark"] .pill {
  background: rgba(24, 24, 27, 0.6);
  border-color: rgba(255, 255, 255, 0.08);
  color: #a1a1aa;
}

body[data-theme="dark"] .pill.warn {
  color: #f2cfcf;
  border-color: rgba(255, 255, 255, 0.16);
}

body[data-theme="dark"] .pill.subtle {
  background: rgba(24, 24, 27, 0.55);
  border-color: rgba(255, 255, 255, 0.1);
}

body[data-theme="dark"] .key-input.masked {
  text-shadow: 0 0 8px rgba(245, 245, 245, 0.55);
}

body[data-theme="dark"] .dropzone-preview img {
  border-color: var(--outline);
}

body[data-theme="dark"] .status {
  border-color: var(--outline);
}

body[data-theme="dark"] .ghost {
  color: var(--muted);
  border-color: var(--outline);
}

body[data-theme="dark"] .error {
  background: rgba(68, 30, 30, 0.35);
  color: #f0caca;
  border-color: rgba(255, 255, 255, 0.12);
}

body[data-theme="dark"] .error-details {
  color: #e4b8b8;
}

/* 移动端适配：缩小间距、调整布局 */
@media (max-width: 720px) {
  .page {
    padding: 32px 18px calc(96px + env(safe-area-inset-bottom));
  }

  .hero-card {
    order: -1;
  }

  .top-bar {
    grid-template-columns: auto 1fr auto;
    margin-bottom: 20px;
  }

  .brand {
    font-size: 0.95rem;
    letter-spacing: 0.22em;
  }

  .grid {
    gap: 16px;
  }

  .panel {
    padding: 18px;
  }

  .input-stack {
    border-radius: 16px;
  }

  .input-stack .field {
    padding: 12px 14px;
  }

  .input-stack .field.file {
    padding-top: 10px;
  }

  .input-stack .textarea-wrap textarea {
    padding: 0 84px 38px 0;
    min-height: 120px;
  }

  .textarea-wrap textarea {
    min-height: 120px;
    padding: 14px 96px 56px 12px;
  }

  .paste-button {
    min-width: 68px;
    min-height: 36px;
    font-size: 0.78rem;
  }

  .notice {
    top: calc(env(safe-area-inset-top) + 8px);
    font-size: 0.8rem;
    padding: 8px 14px;
  }

  .dropzone {
    min-height: 110px;
    padding: 14px;
  }

  .preview-meta {
    flex-direction: column;
    align-items: flex-start;
  }

  .preview-meta .icon-button {
    align-self: flex-end;
  }

  .output-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .output-actions {
    width: 100%;
    justify-content: space-between;
  }

  .panel-actions {
    flex-direction: column;
  }

  .voiceprint-card,
  .admin-block,
  .admin-user-card {
    padding: 12px;
  }

  .admin-user-summary {
    flex-direction: column;
    align-items: flex-start;
  }
}
