/* ============ 基础变量与重置 ============ */
:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-2: #475569;
  --muted: #94a3b8;
  --primary: #0891b2;
  --primary-dark: #0e7490;
  --primary-soft: #ecfeff;
  --danger: #dc2626;
  --warn: #d97706;
  --warn-soft: #fffbeb;
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .06);
  --radius: 12px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 600; }
p { margin: 0; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ============ 顶部导航 ============ */
.topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
}
.brand:hover { text-decoration: none; }
.brand-logo {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  background: var(--primary-soft);
  border-radius: 10px;
  font-size: 18px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 15px; }
.brand-text small { color: var(--muted); font-size: 11px; margin-top: 2px; }

.topnav { display: flex; align-items: center; gap: 12px; }
.topnav a { color: var(--text-2); font-size: 13px; }

.avatar-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 2px solid var(--border);
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  background: var(--primary-soft);
  display: grid; place-items: center;
}
.avatar-btn img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.avatar-btn img:not([src]), .avatar-btn img[src=""] { display: none; }
.avatar-btn::after {
  content: "👤";
  font-size: 16px;
}
.avatar-btn:has(img[src]:not([src=""]))::after { display: none; }

/* ============ 按钮 ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s ease;
  background: var(--panel);
  color: var(--text);
  white-space: nowrap;
}
.btn:hover { border-color: var(--border-strong); }
.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-primary:disabled { background: var(--border-strong); border-color: var(--border-strong); cursor: not-allowed; }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text-2); }
.btn-ghost:hover { background: var(--panel-2); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; padding: 11px; font-size: 14px; }
.btn:disabled { cursor: not-allowed; opacity: .7; }

/* ============ 主布局 ============ */
.layout {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel-left { position: sticky; top: 76px; max-height: calc(100vh - 96px); overflow-y: auto; }
.panel-right { display: flex; flex-direction: column; max-height: calc(100vh - 96px); }

.panel-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
}
.panel-head h2 { font-size: 16px; margin-bottom: 4px; }
.panel-head p { font-size: 12px; }
.panel-head.between {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.panel-head.between h2 { margin: 0; }

.view { padding: 20px; }
.view + .view { border-top: 1px solid var(--border); }
.back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  font-weight: 600;
  color: var(--primary-dark);
  background: var(--primary-soft);
  padding: 7px 14px;
  border-radius: 8px;
  margin-bottom: 12px;
  text-decoration: none;
  transition: background .15s;
}
.back:hover {
  background: #cffafe;
  text-decoration: none;
}

/* ============ 功能卡片网格 ============ */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.feature-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  cursor: pointer;
  transition: all .15s ease;
  background: var(--panel);
  text-align: left;
}
.feature-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(8, 145, 178, .12);
}
.feature-card .icon { font-size: 22px; display: block; margin-bottom: 6px; }
.feature-card .name { font-weight: 600; font-size: 13px; display: block; margin-bottom: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feature-card .desc { font-size: 11px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.notice-card {
  background: var(--primary-soft);
  border: 1px solid #a5f3fc;
  border-radius: var(--radius-sm);
  padding: 14px;
}
.notice-card h3 { font-size: 13px; margin-bottom: 6px; color: var(--primary-dark); }
.notice-card p { font-size: 12px; color: var(--text-2); }

.warn-card {
  background: var(--warn-soft);
  border: 1px solid #fde68a;
  color: #92400e;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 12px;
  margin: 12px 0;
}

/* ============ 表单 ============ */
.form-row { margin-bottom: 14px; }
.form-row label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 6px;
}
.form-row input[type="text"],
.form-row input[type="number"],
.form-row select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--panel);
  color: var(--text);
  transition: border-color .15s;
  font-family: inherit;
}
.form-row input:focus, .form-row select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(8, 145, 178, .1);
}

/* ============ 拖拽上传 ============ */
.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  transition: all .15s;
  background: var(--panel-2);
  margin-bottom: 14px;
  position: relative;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.dropzone-clear {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(220, 38, 38, .85);
  color: #fff;
  border: none;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  z-index: 2;
  transition: background .15s;
}
.dropzone-clear:hover { background: var(--danger); }

/* 进度条 */
.progress-bar {
  width: 100%;
  height: 10px;
  background: var(--border);
  border-radius: 5px;
  overflow: hidden;
  margin: 12px 0 8px;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #22d3ee);
  border-radius: 5px;
  width: 0%;
  transition: width .25s ease;
}
.progress-text {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}
.dropzone .dz-icon { font-size: 28px; display: block; margin-bottom: 6px; }
.dropzone .dz-text { font-size: 13px; color: var(--text-2); }
.dropzone .dz-hint { font-size: 11px; color: var(--muted); margin-top: 4px; }

.file-list { list-style: none; padding: 0; margin: 0 0 14px; }
.file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  background: var(--panel);
  font-size: 12px;
}
.file-item .fi-icon { font-size: 16px; flex-shrink: 0; }
.file-item .fi-info { flex: 1; min-width: 0; }
.file-item .fi-name {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-weight: 500;
}
.file-item .fi-meta { color: var(--muted); font-size: 11px; }
.file-item .fi-remove {
  background: none; border: none; cursor: pointer; color: var(--muted);
  font-size: 16px; padding: 0 4px; line-height: 1;
}
.file-item .fi-remove:hover { color: var(--danger); }

/* 图片缩略图排序面板 */
.img-sort-panel { margin-bottom: 14px; }
.sort-hint {
  font-size: 12px;
  color: var(--text-2);
  background: var(--primary-soft);
  border: 1px solid #a5f3fc;
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 10px;
  line-height: 1.6;
}
.sort-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.sort-controls input[type="number"] {
  width: 150px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
}
.sort-controls input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(8,145,178,.1);
}
.thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 8px;
}
.thumb-item {
  position: relative;
  aspect-ratio: 1 / 1;
  border: 2px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  background: var(--panel-2);
  transition: all .15s;
  display: flex;
  flex-direction: column;
}
.thumb-item:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}
.thumb-item img {
  width: 100%;
  flex: 1;
  min-height: 0;
  object-fit: cover;
  display: block;
}
.thumb-index {
  position: absolute;
  top: 4px;
  left: 4px;
  background: rgba(0,0,0,.65);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  z-index: 2;
}
.thumb-item.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(8,145,178,.3);
  padding-top: 24px;
}
.thumb-item.selected .thumb-index {
  top: 28px;
}
.thumb-check {
  position: absolute;
  top: 4px;
  right: 4px;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: none;
  place-items: center;
  z-index: 2;
}
.thumb-item.selected .thumb-check { display: grid; }
.thumb-remove {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: rgba(220,38,38,.85);
  color: #fff;
  border: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
  display: none;
  padding: 0;
}
.thumb-item:hover .thumb-remove { display: block; }
.thumb-remove:hover { background: var(--danger); }

/* ============ 右侧预览 ============ */
.preview-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}
.preview-hero {
  background: linear-gradient(135deg, #0891b2 0%, #0e7490 100%);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 18px;
  margin-bottom: 16px;
}
.preview-hero h3 { font-size: 15px; margin-bottom: 4px; }
.preview-hero p { font-size: 12px; opacity: .9; }

.preview-section { margin-bottom: 16px; }
.preview-section h4 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  margin: 0 0 8px;
  font-weight: 600;
}
.kv-list {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.kv-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
}
.kv-row:last-child { border-bottom: none; }
.kv-row .k { color: var(--text-2); }
.kv-row .v { font-weight: 500; text-align: right;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60%; }

.result-card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
}
.result-card .rc-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.result-card .rc-title { font-weight: 600; font-size: 13px; }
.result-card .rc-badge {
  background: #dcfce7; color: #166534;
  font-size: 11px; padding: 2px 8px; border-radius: 999px; font-weight: 500;
}
.result-list { list-style: none; padding: 0; margin: 0; }
.result-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.result-item:last-child { border-bottom: none; }
.result-item .ri-name {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.result-item .ri-size { color: var(--muted); font-size: 11px; flex-shrink: 0; }
.result-item .ri-dl {
  background: var(--primary); color: #fff; border: none;
  padding: 4px 10px; border-radius: 6px; font-size: 11px; cursor: pointer;
  flex-shrink: 0;
}
.result-item .ri-dl:hover { background: var(--primary-dark); }

.empty-preview {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}
.empty-preview .ep-icon { font-size: 40px; margin-bottom: 10px; }

.stats-bar {
  display: flex; gap: 10px; margin-bottom: 16px;
}
.stat-chip {
  flex: 1;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  text-align: center;
}
.stat-chip .num { font-size: 18px; font-weight: 700; color: var(--primary); }
.stat-chip .lbl { font-size: 11px; color: var(--muted); }

/* ============ 弹窗 ============ */
.modal {
  position: fixed; inset: 0;
  z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-mask {
  position: absolute; inset: 0;
  background: rgba(15, 23, 42, .5);
  backdrop-filter: blur(2px);
}
.modal-card {
  position: relative;
  background: var(--panel);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 360px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  animation: modalIn .2s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to { opacity: 1; transform: none; }
}
.modal-card h3 { font-size: 16px; margin-bottom: 6px; }
.modal-close {
  position: absolute; top: 10px; right: 12px;
  background: none; border: none; font-size: 22px;
  color: var(--muted); cursor: pointer; line-height: 1;
}
.modal-close:hover { color: var(--text); }
.qr-box {
  width: 180px; height: 180px;
  margin: 14px auto 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px;
  background: #fff;
  display: grid; place-items: center;
}
.qr-box img { width: 100%; height: 100%; object-fit: contain; display: block; }
.qr-box img:not([src]), .qr-box img[src=""] { display: none; }
.qr-box::after {
  content: "二维码占位";
  color: var(--muted); font-size: 12px;
}
.qr-box:has(img[src]:not([src=""]))::after { display: none; }
.qr-name { font-size: 13px; font-weight: 500; margin-top: 4px; }

.reward-card .reward-cat { font-size: 40px; margin-bottom: 8px; }
.reward-card .reward-text {
  font-size: 13px; color: var(--text-2);
  line-height: 1.7; margin-bottom: 8px;
}
#rewardCloseBtn {
  background: var(--border-strong);
  color: #fff;
  border-color: var(--border-strong);
  margin-top: 12px;
}
#rewardCloseBtn:not(:disabled) {
  background: var(--primary);
  border-color: var(--primary);
}

/* ============ Toast ============ */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
  animation: toastIn .2s ease;
  max-width: 90vw;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ============ PDF 页面缩略图浏览 ============ */
.pdf-thumb-scroll {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 8px 4px 12px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}
.pdf-thumb-scroll::-webkit-scrollbar { height: 6px; }
.pdf-thumb-scroll::-webkit-scrollbar-track { background: var(--panel-2); border-radius: 3px; }
.pdf-thumb-scroll::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
.pdf-thumb-item {
  flex-shrink: 0;
  width: 90px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  position: relative;
  background: #fff;
  scroll-snap-align: start;
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.pdf-thumb-item:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,.12);
}
.pdf-thumb-item.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-soft);
}
.pdf-thumb-item img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  object-position: top;
  display: block;
}
.pdf-thumb-num {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: rgba(0,0,0,.7);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 8px;
  line-height: 1.4;
}
.pdf-thumb-item.selected .pdf-thumb-num {
  background: var(--primary);
}

/* ============ 旋转按钮 ============ */
.rotate-btns {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
}
.rotate-btn {
  flex: 1;
  padding: 10px 16px;
  font-size: 14px;
}
.rotate-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.rotate-angle-display {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  min-width: 50px;
  text-align: center;
}
.rotate-arrow-display {
  font-size: 28px;
  color: var(--primary);
  min-width: 50px;
  text-align: center;
  display: inline-block;
  transition: transform .25s ease;
  line-height: 1;
  user-select: none;
}

/* ============ 复选框标签 ============ */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-2);
  user-select: none;
}
.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--primary);
}

/* ============ 水印预览 ============ */
.wm-preview-wrap {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
  overflow: hidden;
}
.wm-preview-img {
  max-width: 100%;
  max-height: 500px;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,.1);
}

/* ============ 响应式：手机端 ============ */
@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
    padding: 12px;
    gap: 12px;
  }
  .panel-left, .panel-right {
    position: static;
    max-height: none;
  }
  .topbar-inner { padding: 10px 14px; }
  .brand-text small { display: none; }
  .topnav a { display: none; }
  .feature-grid { grid-template-columns: 1fr; }
  .stats-bar { flex-wrap: wrap; }
  .stat-chip { min-width: calc(50% - 5px); }
  .back { font-size: 15px; padding: 9px 16px; }
}
