/* ================================================================
   admin.css — 共鸣者工坊（后台管理）
   设计理念：柔光玻璃卡片 · 温润表单 · 紧凑布局
   ================================================================ */

/* ================================================================
   自定义下拉菜单（替代浏览器原生 select）
   设计语言：圆角胶囊按钮 + 品牌色箭头 + 统一弹出动画
   ================================================================ */
.custom-select {
  position: relative;
  width: 100%;
}

.custom-select-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-main);
  font-size: 0.9375rem;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition: all var(--duration-fast) var(--ease-out);
}

.custom-select-btn:hover {
  border-color: rgba(var(--brand-rgb), 0.35);
  background: var(--brand-soft);
}

.custom-select.open .custom-select-btn {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(var(--brand-rgb), 0.12);
}

.cs-value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cs-arrow {
  font-size: 0.75rem;
  color: var(--brand);
  flex-shrink: 0;
  transition: transform var(--duration-fast) var(--ease-out);
}

.custom-select.open .cs-arrow {
  transform: rotate(180deg);
}

.custom-select-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 10001;
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  padding: 4px;
  max-height: 260px;
  overflow-y: auto;
}

.custom-select-menu.open {
  display: block;
  animation: pop-fade-down var(--duration-normal) var(--ease-out);
}

.custom-select-option {
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 0.9375rem;
  color: var(--text-2);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
}

.custom-select-option:hover {
  background: var(--brand-soft);
  color: var(--brand);
}

.custom-select-option.active {
  background: var(--brand);
  color: #fff;
  font-weight: 600;
}

/* 深色主题自定义下拉 */
.theme-dark .custom-select-btn {
  background: var(--surface-2);
  border-color: var(--border);
}

.theme-dark .custom-select-btn:hover {
  background: rgba(var(--brand-rgb), 0.15);
  border-color: rgba(var(--brand-rgb), 0.3);
}

.theme-dark .custom-select-menu {
  background: var(--surface);
  border-color: var(--border);
}

.theme-dark .custom-select-option:hover {
  background: rgba(var(--brand-rgb), 0.15);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-main);
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

/* --- 顶部应用栏 --- */
.admin-topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-6);
  padding-top: calc(var(--space-3) + env(safe-area-inset-top));
  padding-left: calc(var(--space-6) + env(safe-area-inset-left));
  padding-right: calc(var(--space-6) + env(safe-area-inset-right));
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  border-bottom: 1px solid var(--glass-border);
  box-shadow: var(--shadow-xs);
}

.admin-topbar-left {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  min-width: 0;
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.admin-brand-logo {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: var(--radius);
  background: var(--brand-grad);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.375rem;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(var(--brand-rgb), 0.3);
}

.admin-brand-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.admin-brand-title {
  font-size: 1.1875rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 返回与关闭按钮 */
.admin-back,
.admin-close {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 var(--space-4);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-family: var(--font-main);
  font-size: 0.875rem;
  font-weight: 600;
  box-shadow: var(--shadow-xs);
  transition: all var(--duration-fast) var(--ease-out);
}

.admin-back .ic {
  font-size: 1rem;
  line-height: 1;
}

.admin-back:hover {
  background: var(--brand-soft);
  color: var(--brand);
  border-color: rgba(var(--brand-rgb), 0.2);
  transform: translateX(-2px);
}

.admin-close {
  width: 38px;
  padding: 0;
  font-size: 1rem;
}

.admin-close:hover {
  background: var(--brand-soft);
  color: var(--brand);
  border-color: rgba(var(--brand-rgb), 0.2);
  transform: rotate(90deg);
}

.admin-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.admin-actions .btn-primary,
.admin-actions .btn-ghost {
  white-space: nowrap;
}

/* --- 底部 dock --- */
.admin-dock {
  position: fixed;
  left: 50%;
  bottom: var(--space-5);
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  max-width: calc(100vw - var(--space-5));
  padding: 10px var(--space-4) 8px;
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-lg);
}

.admin-dock .admin-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 60px;
  padding: 6px 2px 4px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text-2);
  border-radius: var(--radius);
  transform-origin: bottom center;
  transition: all var(--duration-fast) var(--ease-spring);
}

.admin-dock .admin-nav-item .nav-icon {
  font-size: 1.375rem;
  line-height: 1;
}

.admin-dock .admin-nav-item span:not(.nav-icon) {
  font-size: 0.6875rem;
  line-height: 1.1;
  text-align: center;
  font-weight: 600;
}

.admin-dock .admin-nav-item:hover {
  background: rgba(var(--brand-rgb), 0.08);
  color: var(--brand);
  transform: translateY(-4px) scale(1.08);
}

.admin-dock .admin-nav-item.active {
  background: var(--brand-grad);
  color: #fff;
  transform: translateY(-4px) scale(1.05);
  box-shadow: 0 6px 16px rgba(var(--brand-rgb), 0.35);
}

/* dock 内模块切换 */
.dock-modules {
  display: flex;
  align-items: center;
  gap: 2px;
}

.dock-modules .admin-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  flex-shrink: 0;
  min-width: 52px;
  padding: 6px 8px;
  border: none;
  background: transparent;
  cursor: pointer;
  font: inherit;
  color: var(--text-2);
  border-radius: var(--radius);
  transform-origin: bottom center;
  transition: all var(--duration-fast) var(--ease-out);
}

.dock-modules .admin-nav-item .nav-icon {
  font-size: 1.0625rem;
  line-height: 1;
}

.dock-modules .admin-nav-item span:not(.nav-icon) {
  font-size: 0.6875rem;
  line-height: 1.1;
  text-align: center;
  font-weight: 600;
}

.dock-modules .admin-nav-item:hover {
  background: rgba(var(--brand-rgb), 0.08);
  color: var(--brand);
  transform: translateY(-3px);
}

.dock-modules .admin-nav-item.active {
  background: var(--brand-grad);
  color: #fff;
  font-weight: 700;
  transform: translateY(-3px);
  box-shadow: 0 4px 12px rgba(var(--brand-rgb), 0.35);
}

.dock-sep {
  width: 1px;
  align-self: center;
  height: 28px;
  margin: 0 var(--space-1);
  background: var(--border);
  border-radius: 1px;
}

/* --- 主内容区 --- */
.admin-main {
  position: relative;
  z-index: 1;
  max-width: 1440px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-8) var(--space-16);
  min-width: 0;
}

.admin-page-title {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: var(--space-1);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.admin-page-desc {
  font-size: 0.875rem;
  color: var(--text-2);
  margin-bottom: var(--space-4);
  line-height: 1.6;
}

/* 版权提示 */
.copyright-notice {
  margin-top: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  line-height: 1.7;
  color: #92400e;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-left: 4px solid #f59e0b;
}

/* --- 玻璃卡片 section --- */
.admin-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5) var(--space-6);
  margin-bottom: var(--space-4);
  box-shadow: var(--shadow-xs);
  transition: all var(--duration-normal) var(--ease-out);
}

.admin-section:last-child {
  margin-bottom: 0;
}

.admin-section:hover {
  box-shadow: var(--shadow-sm);
  transform: translateY(-2px);
}

.admin-section-head {
  margin-bottom: var(--space-4);
}

.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  position: relative;
  padding-left: 12px;
}

.section-title::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 1em;
  border-radius: 2px;
  background: var(--brand-grad);
}

.section-desc {
  font-size: 0.8125rem;
  color: var(--text-2);
  margin-top: var(--space-1);
  line-height: 1.6;
}

.admin-section--note {
  background: var(--brand-soft);
  border-color: rgba(var(--brand-rgb), 0.15);
}

.admin-section--note .section-title::before {
  background: var(--brand-700);
}

/* --- 表单字段 --- */
.field {
  margin-bottom: var(--space-4);
}

.field:last-child {
  margin-bottom: 0;
}

.field > label {
  display: block;
  margin-bottom: var(--space-2);
  font-weight: 600;
  color: var(--text-2);
  font-size: 0.875rem;
}

/* 通用表单输入框样式（覆盖所有类型） */
.field input[type=text],
.field input[type=password],
.field input[type=number],
.field input[type=email],
.field input[type=url],
.field input[type=search],
.field input:not([type]),
.field textarea,
.field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: 0.9375rem;
  color: var(--text);
  background: var(--surface);
  transition: all var(--duration-fast) var(--ease-out);
  box-shadow: var(--shadow-xs);
}

/* 自定义下拉框：去掉浏览器原生外观，套用设计语言箭头 */
.field select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 38px;
  cursor: pointer;
  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='%23818cf8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
}

.field select:hover {
  border-color: rgba(var(--brand-rgb), 0.35);
  background-color: var(--brand-soft);
}

.field select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(var(--brand-rgb), 0.12);
  outline: none;
}

/* 深色主题输入框 */
.theme-dark .field input[type=text],
.theme-dark .field input[type=password],
.theme-dark .field input[type=number],
.theme-dark .field input[type=email],
.theme-dark .field input[type=url],
.theme-dark .field input[type=search],
.theme-dark .field input:not([type]),
.theme-dark .field textarea,
.theme-dark .field select {
  background: var(--surface-2);
  border-color: var(--border);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.field textarea {
  resize: vertical;
  line-height: 1.6;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(var(--brand-rgb), 0.12);
}

.form-group {
  margin-bottom: var(--space-4);
}

.form-group label {
  display: block;
  margin-bottom: var(--space-1);
  font-weight: 700;
  color: var(--text-2);
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.form-group select {
  width: 100%;
  padding: 10px 38px 10px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-family: var(--font-main);
  font-size: 0.9375rem;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  cursor: pointer;
  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='%23818cf8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
}

.form-group select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(var(--brand-rgb), 0.12);
}

/* --- 按钮 --- */
.btn-primary {
  background: var(--brand-grad);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-main);
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(var(--brand-rgb), 0.3);
  transition: all var(--duration-fast) var(--ease-out);
}

.btn-primary:hover {
  box-shadow: 0 6px 20px rgba(var(--brand-rgb), 0.4);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: scale(0.97);
}

.btn-primary.danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.btn-ghost {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-2);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-main);
  font-size: 0.875rem;
  font-weight: 600;
  transition: all var(--duration-fast) var(--ease-out);
}

.btn-ghost:hover {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-soft);
}

.btn-ghost:active {
  transform: scale(0.97);
}

.btn-ghost.danger {
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.3);
}

.btn-ghost.danger:hover {
  background: #fef2f2;
  border-color: #ef4444;
}

.config-io-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.config-io-bar .btn-ghost {
  flex-shrink: 0;
}

.admin-note {
  display: block;
  font-size: 0.8125rem;
  color: var(--brand-700);
  background: var(--brand-soft);
  border: 1px solid rgba(var(--brand-rgb), 0.15);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  margin: var(--space-1) 0 var(--space-4);
  line-height: 1.6;
}

.admin-note.warn {
  color: #991b1b;
  background: #fef2f2;
  border-color: #fecaca;
}

/* --- 两列字段 --- */
.field-row {
  display: flex;
  gap: var(--space-4);
}

.field-row .field {
  flex: 1;
  margin-bottom: var(--space-4);
}

/* --- 预览框 --- */
.preview-box {
  display: flex;
  gap: var(--space-5);
  margin-top: var(--space-3);
}

.preview-item {
  flex: 1;
  text-align: center;
}

.preview-item img,
.preview-item video {
  max-height: 150px;
  max-width: 100%;
  border: 1px dashed var(--border-2);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.preview-label {
  font-size: 0.75rem;
  color: var(--text-soft);
  margin-bottom: var(--space-1);
  display: block;
}

.preview-item img.preview-logo {
  max-height: 80px;
}

.preview-item img.preview-favicon {
  max-height: 64px;
}

.preview-item img.preview-bg {
  max-height: 160px;
}

/* --- 分段控件 --- */
.seg {
  display: inline-flex;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 3px;
  border: 1px solid var(--border);
}

.seg-item {
  border: none;
  background: transparent;
  padding: 8px 16px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  font-family: var(--font-main);
  font-size: 0.875rem;
  color: var(--text-2);
  font-weight: 600;
  transition: all var(--duration-fast) var(--ease-out);
}

.seg-item.on {
  background: var(--brand-grad);
  color: #fff;
  box-shadow: 0 2px 8px rgba(var(--brand-rgb), 0.3);
}

/* --- 上传卡片 --- */
.upload-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

.upload-card {
  border: 1px dashed var(--border-2);
  border-radius: var(--radius-sm);
  padding: var(--space-4);
  background: var(--surface-2);
  transition: all var(--duration-fast) var(--ease-out);
}

.upload-card:hover {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.upload-card-title {
  display: block;
  font-weight: 700;
  color: var(--text-2);
  margin-bottom: var(--space-3);
  font-size: 0.875rem;
}

/* ================================================================
   自定义文件选择按钮（替代浏览器内置灰色方形）
   通过 ::file-selector-button 完全自定义「选择文件」按钮外观，
   保持全站设计语言：圆角胶囊 + 品牌色 + 柔和阴影。
   ================================================================ */
.upload-card input[type=file] {
  width: 100%;
  font-size: 0.8125rem;
  color: var(--text-soft);
  cursor: pointer;
  border: none;
  background: transparent;
  padding: 0;
}

/* 核心：自定义「选择文件」按钮 */
.upload-card input[type=file]::file-selector-button {
  font-family: var(--font-main);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--brand);
  background: var(--brand-soft);
  border: 1px solid rgba(var(--brand-rgb), 0.25);
  border-radius: var(--radius-sm);
  padding: 9px 18px;
  margin-right: 10px;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition: all var(--duration-normal) var(--ease-out);
}

.upload-card input[type=file]::file-selector-button:hover {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.upload-card input[type=file]::file-selector-button:active {
  transform: translateY(0) scale(0.97);
}

/* 深色主题文件选择按钮 */
.theme-dark .upload-card input[type=file]::file-selector-button {
  background: rgba(var(--brand-rgb), 0.15);
  border-color: rgba(var(--brand-rgb), 0.3);
  color: var(--brand);
}

.theme-dark .upload-card input[type=file]::file-selector-button:hover {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

/* ================================================================
   全局兜底：所有可见的 file input（不在 upload-card 内）也套用统一按钮
   ================================================================ */
input[type=file]:not([hidden]) {
  font-family: var(--font-main);
  font-size: 0.8125rem;
  color: var(--text-soft);
  cursor: pointer;
}

input[type=file]:not([hidden])::file-selector-button {
  font-family: var(--font-main);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--brand);
  background: var(--brand-soft);
  border: 1px solid rgba(var(--brand-rgb), 0.25);
  border-radius: var(--radius-sm);
  padding: 9px 18px;
  margin-right: 10px;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition: all var(--duration-normal) var(--ease-out);
}

input[type=file]:not([hidden])::file-selector-button:hover {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

input[type=file]:not([hidden])::file-selector-button:active {
  transform: translateY(0) scale(0.97);
}

.theme-dark input[type=file]:not([hidden])::file-selector-button {
  background: rgba(var(--brand-rgb), 0.15);
  border-color: rgba(var(--brand-rgb), 0.3);
  color: var(--brand);
}

.theme-dark input[type=file]:not([hidden])::file-selector-button:hover {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

/* --- 颜色选择行 --- */
.color-row {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  flex-wrap: wrap;
}

.color-row input[type=color] {
  width: 44px;
  height: 36px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface);
  cursor: pointer;
}

.color-row .arrow {
  color: var(--text-soft);
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  font-weight: 500 !important;
}

.checkbox-line input {
  width: auto !important;
}

/* --- 背景预览 --- */
.bg-preview {
  height: 160px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  overflow: hidden;
  background: var(--surface-2);
}

/* 预览 section 跨列占满整个宽度 */
.bg-preview-section {
  column-span: all;
}

.bg-preview-full {
  height: 220px;
}

/* --- 瀑布流布局 --- */
.admin-masonry {
  column-count: 2;
  column-gap: var(--space-5);
}

.admin-masonry > .admin-section,
.admin-masonry > .qa-row,
.admin-masonry > .menu-item-card {
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
  margin: 0 0 var(--space-5);
  width: 100%;
}

@media (min-width: 1500px) {
  .admin-masonry { column-count: 3; }
}

@media (max-width: 820px) {
  .admin-masonry { column-count: 1; }
}

.admin-stack {
  max-width: 780px;
}

.admin-stack > .admin-section {
  margin-bottom: var(--space-6);
  padding: var(--space-6);
}

.admin-stack > .admin-section:last-child {
  margin-bottom: 0;
}

.admin-stack .admin-section-head {
  margin-bottom: var(--space-5);
}

.admin-stack .field {
  margin-bottom: var(--space-5);
}

.admin-stack .field:last-child {
  margin-bottom: 0;
}

.admin-stack .field-row {
  margin-bottom: var(--space-5);
}

.admin-stack .field-row .field {
  margin-bottom: 0;
}

@media (max-width: 600px) {
  .field-row {
    flex-direction: column;
    gap: 0;
  }

  .field-row .field {
    margin-bottom: var(--space-4);
  }
}

/* --- 菜单栏目布局 --- */
.mi-tip {
  font-size: 0.8125rem;
  color: var(--text-2);
  margin-bottom: var(--space-4);
  line-height: 1.6;
}

.mi-tip b {
  color: var(--brand);
}

.mn-pagehead {
  margin-bottom: 2px;
}

.mn-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: var(--space-5);
  align-items: start;
  margin-top: var(--space-2);
}

@media (max-width: 900px) {
  .mn-layout { grid-template-columns: 1fr; }
}

.mn-listpanel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  box-shadow: var(--shadow-xs);
  position: sticky;
  top: 72px;
}

.mn-listhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}

.mn-listtitle {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text);
}

.mn-listtitle em {
  font-style: normal;
  color: var(--brand);
  background: var(--brand-soft);
  border-radius: 6px;
  padding: 1px 8px;
  margin-left: 4px;
  font-size: 0.75rem;
}

.mn-addbtn {
  background: var(--brand-grad);
  color: #fff;
  border: none;
  padding: 6px 12px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  font-family: var(--font-main);
  font-size: 0.8125rem;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(var(--brand-rgb), 0.3);
  transition: all var(--duration-fast) var(--ease-out);
}

.mn-addbtn:hover {
  box-shadow: 0 4px 12px rgba(var(--brand-rgb), 0.4);
  transform: translateY(-1px);
}

.mn-addbtn:active {
  transform: translateY(1px);
}

.mn-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.mn-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  user-select: none;
}

.mn-item:hover {
  border-color: rgba(var(--brand-rgb), 0.3);
  background: var(--surface);
}

.mn-item.active {
  border-color: var(--brand);
  background: var(--brand-soft);
  box-shadow: 0 0 0 2px rgba(var(--brand-rgb), 0.1);
}

.mn-item.dragging {
  opacity: 0.45;
}

.mn-item.drag-over {
  border-style: dashed;
  border-color: var(--brand);
}

.mn-drag {
  color: var(--text-soft);
  cursor: grab;
  font-size: 1rem;
  flex-shrink: 0;
  line-height: 1;
}

.mn-item-icon {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border-radius: 6px;
  font-size: 1rem;
  overflow: hidden;
}

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

.mn-item-title {
  display: block;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mn-item-meta {
  display: block;
  font-size: 0.6875rem;
  color: var(--text-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.mn-item-actions {
  flex-shrink: 0;
  display: flex;
  gap: 4px;
}

.mn-item-del {
  width: 24px;
  height: 24px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-soft);
  font-size: 0.8125rem;
  transition: all var(--duration-fast) var(--ease-out);
}

.mn-item-del:hover {
  color: #ef4444;
  background: #fef2f2;
  border-color: rgba(239, 68, 68, 0.3);
}

.mn-addrow {
  width: 100%;
  margin-top: var(--space-3);
  padding: var(--space-3);
  border: 1.5px dashed var(--border-2);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--brand);
  cursor: pointer;
  font-family: var(--font-main);
  font-size: 0.8125rem;
  font-weight: 700;
  transition: all var(--duration-fast) var(--ease-out);
}

.mn-addrow:hover {
  border-color: rgba(var(--brand-rgb), 0.4);
  background: var(--brand-soft);
}

.mn-editpanel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5) var(--space-6);
  box-shadow: var(--shadow-xs);
  min-height: 360px;
}

.mn-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  color: var(--text-soft);
  font-size: 0.9375rem;
  text-align: center;
  padding: 0 var(--space-5);
}

.mn-edit-head {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border);
}

.mn-edit-title {
  font-size: 1rem;
  color: var(--text-2);
}

.mn-edit-title b {
  color: var(--brand);
  font-weight: 700;
}

.mn-edit-subbar {
  display: flex;
  align-items: stretch;
  gap: var(--space-3);
}

.mn-subtabs {
  flex: 1;
  display: flex;
  gap: var(--space-1);
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.mn-subtabs::-webkit-scrollbar {
  display: none;
}

.mn-subtab {
  flex-shrink: 0;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--surface-2);
  color: var(--text-2);
  font-family: var(--font-main);
  font-size: 0.8125rem;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--duration-fast) var(--ease-out);
}

.mn-subtab:hover {
  background: var(--surface);
}

.mn-subtab.active {
  background: var(--brand-grad);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(var(--brand-rgb), 0.3);
}

.mn-sub-actions {
  flex-shrink: 0;
  display: flex;
  gap: var(--space-1);
  align-items: center;
}

.mn-mini-btn {
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text-2);
  transition: all var(--duration-fast) var(--ease-out);
}

.mn-mini-btn:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.mn-mini-btn.danger:hover {
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.4);
  background: #fef2f2;
}

.mn-fields {
  display: flex;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
  flex-wrap: wrap;
}

.mn-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mn-field-grow {
  flex: 1 1 180px;
}

.mn-field label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-2);
}

.mn-field input {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--font-main);
  font-size: 0.875rem;
  background: var(--surface);
  color: var(--text);
  transition: all var(--duration-fast) var(--ease-out);
}

.mn-f-icon {
  width: 90px;
  text-align: center;
}

.mn-field input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(var(--brand-rgb), 0.12);
}

.mn-subname {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: var(--space-3);
}

.mn-subname label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-2);
}

.mn-f-subtitle {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--font-main);
  font-size: 0.875rem;
  background: var(--surface);
  color: var(--text);
}

.mn-f-subtitle:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(var(--brand-rgb), 0.12);
}

.mn-rte-host {
  margin: var(--space-1) 0;
}

.mi-preview-wrap {
  margin-top: var(--space-2);
}

.mi-preview-label {
  font-size: 0.75rem;
  color: var(--text-soft);
}

.mi-preview {
  margin-top: var(--space-1);
  padding: var(--space-3);
  border: 1px dashed var(--border-2);
  border-radius: var(--radius-xs);
  background: var(--surface-2);
  min-height: 40px;
  font-size: 0.875rem;
  overflow-x: auto;
}

.mi-preview h3, .mi-preview h4 {
  margin: var(--space-1) 0 4px;
  color: var(--text);
}

.mi-preview ul {
  padding-left: 20px;
  margin: 4px 0;
}

.mi-preview p {
  margin: 4px 0;
  line-height: 1.6;
}

.mi-preview div[style] {
  max-width: 100%;
}

.mi-preview img,
.mi-preview video {
  max-width: 100%;
  border-radius: 6px;
  margin: var(--space-1) 0;
  display: block;
}

.mi-preview img.rte-media-thumb {
  max-height: 120px;
  width: auto;
  object-fit: cover;
  cursor: zoom-in;
}

.mi-preview video.rte-media-thumb {
  max-height: 140px;
  width: auto;
  object-fit: cover;
  cursor: pointer;
}

.rte-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: var(--space-2) 0 0;
  padding: var(--space-1);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
}

.rte-btn {
  min-width: 30px;
  height: 30px;
  padding: 0 6px;
  border: 1px solid transparent;
  background: var(--surface);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8125rem;
  color: var(--text-2);
  transition: all var(--duration-fast) var(--ease-out);
}

.rte-btn:hover {
  background: var(--brand-soft);
  border-color: rgba(var(--brand-rgb), 0.2);
  color: var(--brand);
}

.rte-btn:active {
  transform: translateY(1px);
}

.rte-btn b { font-weight: 700; }
.rte-btn i { font-style: italic; }
.rte-btn u { text-decoration: underline; }

.mi-content.rte {
  min-height: 120px;
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface);
  font-size: 0.9375rem;
  line-height: 1.6;
  overflow-y: auto;
}

.mi-content.rte:empty:before {
  content: attr(data-placeholder);
  color: var(--text-soft);
}

.rte-source {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.5;
  resize: vertical;
}

.mi-rte-host {
  margin: var(--space-2) 0 var(--space-1);
}

.mi-rte-content {
  min-height: 80px;
  max-height: 300px;
  overflow: auto;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 0.9375rem;
  line-height: 1.7;
  color: var(--text);
  outline: none;
  transition: all var(--duration-fast) var(--ease-out);
}

.mi-rte-content:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(var(--brand-rgb), 0.12);
}

.mi-rte-content p {
  margin: 0 0 var(--space-2);
}

.mi-rte-content .rte-h1 {
  font-size: 1.375rem;
  font-weight: 700;
  margin: var(--space-3) 0 var(--space-1);
}

.mi-rte-content .rte-h2 {
  font-size: 1.125rem;
  font-weight: 700;
  margin: var(--space-2) 0 var(--space-1);
}

.mi-rte-content .rte-h3 {
  font-size: 1rem;
  font-weight: 700;
  margin: var(--space-1) 0;
}

.mi-rte-content .rte-quote {
  border-left: 3px solid var(--brand);
  padding-left: 10px;
  color: var(--text-2);
  margin: var(--space-2) 0;
}

.mi-rte-content .rte-ul,
.mi-rte-content .rte-ol {
  padding-left: 22px;
  margin: var(--space-1) 0;
}

.mi-rte-content .rte-li {
  margin: 2px 0;
}

.mi-rte-content .rte-link {
  color: var(--brand);
  text-decoration: underline;
}

.mi-rte-content .rte-b { font-weight: 700; }
.mi-rte-content .rte-i { font-style: italic; }
.mi-rte-content .rte-u { text-decoration: underline; }

.mi-rte-content .rte-code {
  font-family: var(--font-mono);
  background: var(--surface-2);
  padding: 1px 4px;
  border-radius: 4px;
  font-size: 0.875em;
}

.lex-media-host {
  margin: var(--space-1) 0;
  line-height: 0;
}

.mi-rte-content .rte-img {
  max-width: 100%;
  border-radius: 6px;
}

.mi-rte-content .rte-source,
.rte-source {
  width: 100%;
  min-height: 120px;
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.5;
  resize: vertical;
  box-sizing: border-box;
  margin: var(--space-2) 0;
  background: var(--surface);
}

.rte-source:focus {
  outline: none;
  border-color: var(--brand);
}

.menu-toolbar-wrap {
  position: sticky;
  top: 0;
  z-index: 6;
  margin: var(--space-1) 0 var(--space-4);
  padding: var(--space-1) 48px var(--space-1) 0;
  background: var(--surface);
}

.menu-shared-toolbar {
  margin: 0;
}

.rte-btn.rte-sep {
  width: 1px;
  min-width: 1px;
  padding: 0;
  height: 20px;
  align-self: center;
  background: var(--border);
  border: none;
  box-shadow: none;
  cursor: default;
}

.rte-btn.rte-sep:hover {
  background: var(--border);
}

.mn-icon-row {
  display: flex;
  gap: var(--space-2);
  align-items: stretch;
}

.mn-icon-row .mn-f-icon {
  width: 80px;
  text-align: center;
  font-size: 1rem;
}

.mn-emoji-btn {
  padding: 0 var(--space-4);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text-2);
  transition: all var(--duration-fast) var(--ease-out);
  white-space: nowrap;
}

.mn-emoji-btn:hover {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-soft);
}

.emoji-popover {
  position: absolute;
  z-index: 10001;
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: var(--space-2);
  animation: pop-fade-down var(--duration-normal) var(--ease-out);
}

.emoji-search {
  margin-bottom: var(--space-2);
}

.emoji-search input {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--font-main);
  font-size: 0.875rem;
  outline: none;
  background: var(--surface);
}

.emoji-search input:focus {
  border-color: var(--brand);
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  max-height: 240px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.emoji-cell {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
  padding: 6px 0;
  border-radius: 6px;
  transition: background var(--duration-fast);
}

.emoji-cell:hover,
.emoji-cell:active {
  background: var(--brand-soft);
}

.emoji-empty {
  padding: var(--space-4);
  text-align: center;
  color: var(--text-soft);
  font-size: 0.875rem;
  grid-column: 1 / -1;
}

.coltype-popover {
  position: absolute;
  z-index: 10001;
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: var(--space-2);
  animation: pop-fade-down var(--duration-normal) var(--ease-out);
}

.coltype-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-1);
}

.coltype-cell {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface);
  padding: 8px 10px;
  cursor: pointer;
  min-width: 100px;
  font-size: 0.9375rem;
  color: var(--text);
  transition: all var(--duration-fast) var(--ease-out);
}

.coltype-cell:hover,
.coltype-cell:active {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.coltype-ic {
  font-size: 1.125rem;
  line-height: 1;
}

.coltype-lbl {
  font-weight: 600;
}

.mn-list-empty {
  padding: var(--space-5) var(--space-3);
  margin: var(--space-2) 0;
  text-align: center;
  color: var(--text-soft);
  font-size: 0.875rem;
  border: 1px dashed var(--border-2);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.mn-media-editor {
  margin: var(--space-1) 0;
}

.mn-media-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  margin-bottom: var(--space-3);
}

.mn-media-bar .mn-mini-btn {
  width: auto;
  height: auto;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.8125rem;
  white-space: nowrap;
}

.mn-media-url {
  flex: 1 1 220px;
  min-width: 160px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--font-main);
  font-size: 0.875rem;
  background: var(--surface);
  color: var(--text);
}

.mn-media-url:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(var(--brand-rgb), 0.12);
}

.mn-media-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.mn-media-card {
  position: relative;
  width: 120px;
  height: 120px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
}

.mn-media-thumb {
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  object-fit: cover;
  display: block;
  background: #000;
}

.mn-media-card video.mn-media-thumb {
  object-fit: contain;
}

.mn-media-del {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  font-size: 0.75rem;
  line-height: 1;
  cursor: pointer;
  transition: background var(--duration-fast);
}

.mn-media-del:hover {
  background: #ef4444;
}

.mn-media-empty {
  width: 100%;
  padding: var(--space-4) var(--space-3);
  text-align: center;
  color: var(--text-soft);
  font-size: 0.875rem;
  border: 1px dashed var(--border-2);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.mn-media-note {
  margin: var(--space-1) 0;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
  font-size: 0.8125rem;
  line-height: 1.6;
}

/* --- 问答列表 --- */
.qa-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-bottom: var(--space-1);
}

.qa-row {
  display: flex;
  gap: var(--space-3);
  align-items: stretch;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
}

.qa-row-fields {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}

.qa-row-top {
  display: flex;
  gap: var(--space-2);
  align-items: stretch;
}

.qa-row-top .adm_q {
  flex: 1;
}

.qa-row-top .adm_w {
  flex-shrink: 0;
  width: 72px;
  text-align: center;
}

.qa-row-fields input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--font-main);
  font-size: 0.875rem;
  background: var(--surface);
}

.qa-row-fields input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(var(--brand-rgb), 0.12);
}

.qa-del {
  flex-shrink: 0;
  align-self: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-xs);
  cursor: pointer;
  color: #ef4444;
  font-size: 0.875rem;
  transition: all var(--duration-fast) var(--ease-out);
}

.qa-del:hover {
  background: #fef2f2;
  border-color: rgba(239, 68, 68, 0.4);
}

.qa-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

/* --- 粘贴导入弹层（统一动画：遮罩淡入 + 卡片缩放弹出） --- */
.qa-paste-modal {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
  background: rgba(15, 23, 42, 0.5);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  animation: pop-fade-in var(--duration-normal) var(--ease-out);
}

.qa-paste-card {
  width: min(560px, 92vw);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  box-shadow: var(--shadow-xl);
  animation: pop-fade-zoom var(--duration-normal) var(--ease-out);
}

.qa-paste-head {
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: var(--space-2);
}

.qa-paste-tip {
  font-size: 0.8125rem;
  color: var(--text-2);
  line-height: 1.6;
  margin: 0 0 var(--space-4);
}

.qa-paste-area {
  width: 100%;
  min-height: 200px;
  box-sizing: border-box;
  resize: vertical;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--surface);
}

.qa-paste-area:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(var(--brand-rgb), 0.12);
}

.qa-paste-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

/* --- 后台网关 --- */
.admin-gateway {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  flex-direction: column;
  align-items: center;
  padding: var(--space-10) var(--space-6);
  overflow: auto;
  background: var(--bg);
}

.gateway-inner {
  width: 100%;
  max-width: 900px;
  margin: auto 0;
  text-align: center;
}

.gateway-head {
  margin-bottom: var(--space-8);
}

.gateway-logo {
  width: 40px;
  height: 40px;
  margin: 0 auto var(--space-4);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.125rem;
  background: var(--brand-grad);
  box-shadow: 0 4px 12px rgba(var(--brand-rgb), 0.3);
}

.gateway-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius);
}

.gateway-title {
  font-size: 1.625rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: var(--space-2);
}

.gateway-sub {
  font-size: 0.9375rem;
  color: var(--text-2);
}

.gateway-decks {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  text-align: left;
}

.deck-title {
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 var(--space-4);
}

.deck-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 152px));
  gap: var(--space-4);
}

.gateway-card {
  position: relative;
  cursor: pointer;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  aspect-ratio: 9 / 16;
  min-height: 0;
  transition: all var(--duration-normal) var(--ease-out);
}

.gateway-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: rgba(var(--brand-rgb), 0.3);
}

.gateway-card-thumb {
  width: 100%;
  height: auto;
  flex: 1;
  min-height: 80px;
  border-radius: var(--radius-sm);
  background: var(--brand-soft) center/cover no-repeat;
  background-image: url('../img/0.png?v=3');
}

.gateway-card-icon {
  font-size: 1.625rem;
  line-height: 1;
  margin-bottom: 4px;
}

.gateway-card-id {
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--brand);
}

.gateway-card-title {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text);
}

.gateway-card-go {
  margin-top: auto;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--brand);
}

.gateway-card.add-card {
  align-items: center;
  justify-content: center;
  text-align: center;
  border-style: dashed;
  border-color: rgba(var(--brand-rgb), 0.3);
  background: var(--surface-2);
  color: var(--brand);
  min-height: 0;
}

.gateway-card.add-card:hover {
  border-color: var(--brand);
}

.gateway-card-del {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.9);
  color: #ef4444;
  font-size: 0.8125rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition: all var(--duration-fast) var(--ease-out);
}

.gateway-card-del:hover {
  background: #fef2f2;
  transform: scale(1.08);
}

.gateway-card-del:active {
  transform: scale(0.94);
}

.pswp-video-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.pswp-video-wrap video {
  max-width: 92vw;
  max-height: 82vh;
  width: auto;
  height: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow-xl);
  background: #000;
}

/* --- 中小屏优化 --- */
@media (max-width: 1024px) {
  .admin-main {
    padding: var(--space-5) var(--space-6) var(--space-12);
  }

  .admin-section {
    padding: var(--space-4) var(--space-5);
    border-radius: 15px;
  }

  .admin-page-title {
    font-size: 1.25rem;
  }

  .admin-section-head {
    margin-bottom: var(--space-3);
  }

  .admin-dock {
    padding: 8px 10px;
    gap: 2px;
  }

  .admin-dock .admin-nav-item {
    width: 58px;
    padding: 6px 2px 4px;
  }

  .admin-dock .admin-nav-item .nav-icon {
    font-size: 1.25rem;
  }

  .gateway-card {
    padding: var(--space-3);
  }

  .gateway-card-thumb {
    height: auto;
  }

  .upload-grid {
    gap: var(--space-3);
  }

  .upload-card {
    padding: var(--space-3);
  }

  .mn-media-card {
    width: 108px;
    height: 108px;
  }

  .preview-box {
    gap: var(--space-4);
  }

  .bg-preview {
    height: 140px;
  }

  .admin-masonry {
    column-gap: var(--space-4);
  }

  .admin-masonry > .admin-section,
  .admin-masonry > .qa-row,
  .admin-masonry > .menu-item-card {
    margin: 0 0 var(--space-4);
  }

  .mn-editpanel {
    min-height: 280px;
    padding: var(--space-4) var(--space-5);
  }

  .mn-listpanel {
    top: 66px;
    padding: var(--space-3);
  }
}

/* --- 移动端优化 --- */
@media (max-width: 768px) {
  html, body {
    height: 100%;
    overflow: hidden;
  }

  #adminPanel {
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }

  .admin-main {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  .admin-topbar {
    padding: var(--space-2) var(--space-3);
    gap: var(--space-1);
  }

  .admin-topbar-left {
    gap: var(--space-2);
    flex-shrink: 0;
  }

  .admin-brand-title {
    font-size: 0.9375rem;
    max-width: 120px;
  }

  .admin-actions {
    gap: 4px;
    flex-shrink: 1;
    min-width: 0;
    justify-content: flex-end;
  }

  .admin-actions .btn-primary,
  .admin-actions .btn-ghost {
    padding: 8px 10px;
    font-size: 0.8125rem;
  }

  .admin-back {
    height: 36px;
    padding: 0 10px;
    font-size: 0.8125rem;
  }

  .admin-close {
    width: 36px;
    height: 36px;
  }

  .admin-dock {
    left: 50%;
    right: auto;
    bottom: calc(var(--space-3) + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    width: auto;
    max-width: calc(100vw - var(--space-6));
    border-radius: var(--radius-2xl);
    justify-content: flex-start;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    background-color: var(--surface);
    background-image: none;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  @supports not ((backdrop-filter: blur(2px)) or (-webkit-backdrop-filter: blur(2px))) {
    .admin-dock {
      background-color: var(--surface);
      background-image: none;
    }
  }

  @media (prefers-reduced-transparency: reduce) {
    .admin-dock {
      backdrop-filter: none;
      -webkit-backdrop-filter: none;
      background-color: var(--surface);
      background-image: none;
    }
  }

  .admin-dock::-webkit-scrollbar {
    display: none;
  }

  .admin-dock .admin-nav-item {
    width: auto;
    flex-shrink: 0;
    min-width: 54px;
    padding: 5px 5px;
    gap: 2px;
  }

  .admin-dock .admin-nav-item .nav-icon {
    font-size: 1.125rem;
  }

  .admin-dock .admin-nav-item span:not(.nav-icon) {
    font-size: 0.625rem;
  }

  .admin-dock .admin-nav-item:hover,
  .admin-dock .admin-nav-item.active {
    transform: translateY(-2px) scale(1.04);
  }

  .admin-main {
    padding: var(--space-4) var(--space-4) calc(124px + env(safe-area-inset-bottom));
    max-width: 100%;
  }

  .admin-page-desc {
    font-size: 0.8125rem;
  }

  .admin-section {
    padding: var(--space-4) var(--space-3);
    border-radius: 13px;
    margin-bottom: var(--space-4);
  }

  .field > label {
    font-size: 0.875rem;
  }

  .field input[type=text],
  .field input:not([type]),
  .field textarea,
  .field select {
    padding: 10px;
    font-size: 0.9375rem;
  }

  .seg {
    display: flex;
    width: 100%;
  }

  .seg-item {
    flex: 1;
    text-align: center;
    padding: 10px 6px;
    font-size: 0.8125rem;
  }

  .upload-grid {
    grid-template-columns: 1fr;
    gap: var(--space-3);
  }

  .admin-masonry {
    column-count: 1;
    column-gap: 0;
  }

  .admin-masonry > .admin-section,
  .admin-masonry > .qa-row,
  .admin-masonry > .menu-item-card {
    margin: 0 0 var(--space-4);
  }

  .qa-row {
    flex-wrap: wrap;
  }

  .qa-row-fields {
    flex: 1 1 100%;
  }

  .qa-row-top {
    flex-wrap: wrap;
  }

  .qa-row-top .adm_w {
    flex: 1 1 100%;
    width: 100%;
  }

  .mn-listpanel {
    position: static;
    top: auto;
  }

  .mn-layout {
    gap: var(--space-4);
  }

  .mn-editpanel {
    padding: var(--space-4);
    min-height: 0;
  }

  .mn-fields {
    flex-direction: column;
  }

  .mn-field-grow {
    flex: 1;
  }

  .mn-icon-row {
    flex-wrap: wrap;
  }

  .menu-toolbar-wrap {
    position: static;
    padding: 0;
    margin: 0 0 var(--space-3);
    background: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .mn-media-bar {
    gap: var(--space-1);
  }

  .mn-media-url {
    flex: 1 1 100%;
  }

  .mn-media-card {
    width: 96px;
    height: 96px;
  }

  .qa-paste-modal {
    padding: var(--space-3);
  }

  .qa-paste-card {
    width: 100%;
    padding: var(--space-4);
  }

  .qa-paste-area {
    min-height: 160px;
  }

  .emoji-popover,
  .coltype-popover {
    max-width: 92vw;
  }

  .deck-cards {
    grid-template-columns: repeat(auto-fill, minmax(140px, 152px));
    gap: var(--space-3);
  }

  .gateway-card {
    min-height: 0;
  }

  .gateway-card-thumb {
    height: auto;
  }

  .gateway-title {
    font-size: 1.375rem;
  }

  .gateway-head {
    margin-bottom: var(--space-6);
  }
}

@media (max-width: 480px) {
  .admin-brand-logo {
    width: 36px;
    height: 36px;
    flex-basis: 36px;
    font-size: 1.125rem;
  }

  .admin-brand-title {
    display: none;
  }

  .admin-section {
    padding: var(--space-3);
    border-radius: var(--radius-sm);
  }

  .admin-page-title {
    font-size: 1.125rem;
  }

  .admin-dock .admin-nav-item .nav-icon {
    font-size: 1rem;
  }

  .admin-dock .admin-nav-item span:not(.nav-icon) {
    font-size: 0.5625rem;
  }

  .admin-dock {
    padding: 7px 8px calc(7px + env(safe-area-inset-bottom));
  }

  .mn-media-card {
    width: 84px;
    height: 84px;
    border-radius: var(--radius-xs);
  }

  .gateway-card {
    min-height: 0;
    padding: 10px;
  }

  .gateway-card-thumb {
    height: auto;
    border-radius: var(--radius-xs);
  }

  .deck-cards {
    gap: var(--space-2);
  }

  .gateway-io {
    flex-direction: column;
  }

  .gateway-io .btn-ghost {
    width: 100%;
  }

  .admin-actions .lbl {
    display: none;
  }

  .admin-actions .btn-primary .lbl {
    display: inline;
  }

  .admin-back .lbl {
    display: none;
  }

  /* 网关卡牌：更大触摸目标 + 更清晰的标题 */
  .gateway-card {
    padding: 12px;
  }

  .gateway-card-title {
    font-size: 0.9375rem;
  }

  .gateway-card-del {
    width: 28px;
    height: 28px;
  }

  /* 表单按钮触摸目标 */
  .admin-actions .btn-primary,
  .admin-actions .btn-ghost {
    min-height: 40px;
  }

  .qa-del {
    width: 40px;
    height: 40px;
  }

  .mn-item-del {
    width: 32px;
    height: 32px;
  }

  /* 弹层移动端适配 */
  .qa-paste-modal,
  .admin-lock {
    padding: var(--space-3);
  }

  .qa-paste-card,
  .admin-lock-card {
    padding: var(--space-5);
  }
}

.gateway-io {
  margin-top: var(--space-8);
  padding-top: var(--space-6);
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
  justify-content: center;
}

.gateway-io-title {
  width: 100%;
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-2);
  margin-bottom: var(--space-1);
}

.gateway-io .btn-ghost {
  flex-shrink: 0;
}

.bind-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.bind-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
}

.bind-name {
  font-weight: 700;
  color: var(--text);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bind-id {
  font-size: 0.8125rem;
  color: var(--text-soft);
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

/* --- 后台密码锁 --- */
.admin-lock {
  position: fixed;
  inset: 0;
  z-index: 10001;
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
  background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
  animation: pop-fade-in var(--duration-normal) var(--ease-out);
}

.admin-lock-card {
  width: min(380px, 92vw);
  box-sizing: border-box;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-8) var(--space-7);
  box-shadow: var(--shadow-xl);
  text-align: center;
  animation: pop-fade-zoom var(--duration-normal) var(--ease-out);
}

.admin-lock-logo {
  font-size: 2rem;
  line-height: 1;
}

.admin-lock-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text);
  margin: var(--space-3) 0 var(--space-1);
}

.admin-lock-sub {
  font-size: 0.875rem;
  color: var(--text-2);
  margin: 0 0 var(--space-5);
}

.admin-lock .field {
  text-align: left;
  margin-top: var(--space-3);
}

.admin-lock-input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: 0.9375rem;
}

.admin-lock-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(var(--brand-rgb), 0.12);
}

.admin-lock-btn {
  width: 100%;
  margin-top: var(--space-5);
  padding: 12px;
  font-size: 0.9375rem;
}

.admin-lock-err {
  color: #ef4444;
  font-size: 0.8125rem;
  min-height: 1.1em;
  margin-top: var(--space-3);
}

.admin-lock-hint {
  font-size: 0.6875rem;
  color: var(--text-soft);
  line-height: 1.6;
  margin: var(--space-4) 0 0;
}

body.lock-active {
  overflow: hidden;
}

.gateway-io-sep {
  width: 100%;
  height: 0;
}

@media (min-width: 901px) {
  body.has-sidebar .admin-gateway {
    left: var(--sb-w);
  }

  body.has-sidebar.sidebar-collapsed .admin-gateway {
    left: var(--sb-rail);
  }
}

/* ================================================================
   兼容兜底：旧版腾讯 X5 / 内核不支持 aspect-ratio 时，
   竖向网关卡片用最小高度兜底，避免塌陷为内容高度。
   ================================================================ */
@supports not (aspect-ratio: 1 / 1) {
  .gateway-card {
    min-height: 360px;
  }
}
