:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --line: #e5e8ef;
  --line-strong: #d5dae4;
  --text: #0f172a;
  --muted: #667085;
  --accent: #2f6bff;
  --accent-hover: #1f57e0;
  --accent-soft: #edf3ff;
  --ok: #10b981;
  --danger: #e5484d;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px -12px rgba(16, 24, 40, .18);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, p { margin: 0; }
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 12.5px;
  background: #f3f5f9;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 6px;
  color: #344054;
}
code.block { display: block; padding: 10px 12px; margin: 10px 0; overflow-x: auto; }
.muted { color: var(--muted); font-size: 12.5px; margin-top: 8px; }

.wrap { width: min(1040px, calc(100% - 40px)); margin: 0 auto; }

/* ---------- 顶栏 ---------- */
.topbar {
  background: rgba(255, 255, 255, .86);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { font-size: 16px; font-weight: 650; letter-spacing: -.01em; }
.brand p { font-size: 12px; color: var(--muted); }
.logo {
  width: 38px; height: 38px; border-radius: 11px; flex: 0 0 auto;
  background: linear-gradient(135deg, #2f6bff, #6ea8ff);
  box-shadow: 0 6px 16px -8px rgba(47, 107, 255, .8);
  position: relative;
}
.logo::before {
  content: ""; position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M6 16l4.6-5.6 3.2 3.4 2.2-2 2 4.2z'/%3E%3Ccircle cx='15.6' cy='8.4' r='1.8'/%3E%3C/svg%3E") center/22px no-repeat;
}
.topbar-right { display: flex; align-items: center; gap: 8px; }
.stat {
  display: flex; flex-direction: column; align-items: center;
  padding: 4px 12px; border-left: 1px solid var(--line);
}
.stat b { font-size: 13px; font-weight: 650; }
.stat span { font-size: 11px; color: var(--muted); }

/* 顶栏开关（缩略图） */
.switch {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  font-size: 12.5px; color: var(--muted); user-select: none;
  padding: 0 4px;
}
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  position: relative; width: 34px; height: 20px; border-radius: 999px;
  background: #d7dce6; transition: background .18s ease; flex: none;
}
.switch-thumb {
  position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(16,24,40,.25);
  transition: transform .18s ease;
}
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(14px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent-soft); outline-offset: 2px; }
.switch input:disabled + .switch-track { opacity: .6; }

/* ---------- 按钮 ---------- */
.btn {
  appearance: none; border: 1px solid var(--line-strong); background: #fff;
  color: var(--text); border-radius: 10px; padding: 8px 14px; cursor: pointer;
  font-size: 13px; font-weight: 550; font-family: inherit; transition: .15s ease;
  white-space: nowrap;
}
.btn:hover { background: #f8fafc; border-color: #c6ccd8; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: #eef1f6; color: var(--text); border-color: transparent; }
.btn-mini { padding: 4px 10px; font-size: 12px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn-danger { color: var(--danger); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.pill {
  display: inline-block; min-width: 22px; text-align: center;
  padding: 1px 8px; border-radius: 999px; background: var(--accent-soft);
  color: var(--accent); font-size: 12px; font-weight: 600;
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.section { margin-top: 28px; }
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 12px;
}
.section-head h2 { font-size: 14px; font-weight: 650; display: flex; align-items: center; gap: 8px; }
.section-actions { display: flex; align-items: center; gap: 8px; }

/* ---------- 上传区 ---------- */
.upload-card { margin-top: 24px; padding: 14px; }
.dropzone {
  border: 1.5px dashed var(--line-strong);
  border-radius: 13px;
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: .18s ease;
  background: linear-gradient(180deg, #fbfcfe, #fff);
}
.dropzone:hover { border-color: #b9c6e6; background: #f9fbff; }
.dropzone.dragging { border-color: var(--accent); background: var(--accent-soft); }
.dz-icon {
  width: 52px; height: 52px; margin: 0 auto 12px; border-radius: 14px;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
}
.dropzone h2 { font-size: 15px; font-weight: 600; }
.dropzone p { font-size: 12.5px; color: var(--muted); margin-top: 6px; }

.progress-list { display: none; padding: 12px 6px 2px; }
.progress-list.show { display: block; }
.progress-item { display: flex; align-items: center; gap: 10px; padding: 7px 4px; font-size: 12.5px; }
.progress-item .pname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.bar { width: 140px; height: 5px; border-radius: 99px; background: #edf0f6; overflow: hidden; flex: 0 0 auto; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width .2s; }
.progress-item.done .bar i { background: var(--ok); }
.progress-item.err .pname { color: var(--danger); }

/* ---------- 结果 ---------- */
.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.result-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column;
}
.result-thumb {
  height: 132px; background: #f3f5f9 repeating-conic-gradient(#eef1f6 0% 25%, #f7f9fc 0% 50%) 50% / 16px 16px;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.result-thumb img { width: 100%; height: 100%; object-fit: contain; }
.result-body { padding: 10px 12px 12px; }
.result-name { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-url {
  margin-top: 8px; font-size: 11.5px; color: #475467; background: #f7f9fc;
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.result-actions { display: flex; align-items: center; gap: 6px; margin-top: 9px; }
.result-actions .meta { margin-left: auto; font-size: 11px; color: var(--muted); }
.tag {
  font-size: 11px; color: var(--ok); background: #ecfdf3;
  border: 1px solid #d1fadf; border-radius: 6px; padding: 1px 6px;
}

/* ---------- 最近上传 ---------- */
.recent-list { padding: 6px; }
.recent-row {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 10px; border-radius: 10px;
}
.recent-row:hover { background: #f8fafc; }
.recent-row img {
  width: 40px; height: 40px; border-radius: 8px; object-fit: cover;
  border: 1px solid var(--line); background: #f3f5f9; flex: 0 0 auto;
}
.recent-main { flex: 1; min-width: 0; }
.recent-main .nm {
  font-size: 12.5px; color: #344054; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.recent-main .sub { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.recent-actions { display: flex; gap: 4px; }
.empty { padding: 34px; text-align: center; color: var(--muted); font-size: 13px; }

/* ---------- API ---------- */
.api-card { padding: 18px; }
.api-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.api-grid h3 { font-size: 13px; font-weight: 650; margin-bottom: 2px; }
.token-row { display: flex; align-items: center; gap: 6px; margin: 8px 0; }
.token-row code { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.snippet { margin-top: 16px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.snippet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; background: #f8fafc; border-bottom: 1px solid var(--line);
  font-size: 12px; color: var(--muted);
}
.snippet pre {
  margin: 0; padding: 14px 16px; overflow-x: auto; font-size: 12px; line-height: 1.7;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: #344054; background: #fff;
}
.seg { display: inline-flex; background: #eef1f6; border-radius: 9px; padding: 2px; }
.seg button {
  appearance: none; border: 0; background: transparent; color: var(--muted);
  font-size: 12px; padding: 4px 10px; border-radius: 7px; cursor: pointer; font-family: inherit;
}
.seg button.active { background: #fff; color: var(--text); box-shadow: 0 1px 2px rgba(16,24,40,.08); }

.foot {
  display: flex; gap: 8px; align-items: center; justify-content: center;
  color: var(--muted); font-size: 12px; padding: 36px 0 30px; flex-wrap: wrap;
}

/* ---------- 登录 ---------- */
.login-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 370px; background: var(--card); border: 1px solid var(--line);
  border-radius: 18px; padding: 28px; box-shadow: 0 20px 50px -30px rgba(16, 24, 40, .35);
}
.login-card .brand { margin-bottom: 22px; }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%; border: 1px solid var(--line-strong); border-radius: 10px;
  padding: 10px 12px; font-size: 14px; font-family: inherit; outline: none;
  background: #fff; color: var(--text);
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47,107,255,.12); }
.form-error { color: var(--danger); font-size: 12.5px; margin: 0 0 12px; }
.login-foot { text-align: center; font-size: 11.5px; color: var(--muted); margin-top: 16px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 12px);
  background: #101828; color: #fff; padding: 9px 16px; border-radius: 10px;
  font-size: 12.5px; opacity: 0; pointer-events: none; transition: .22s ease; z-index: 50;
  box-shadow: 0 12px 30px -12px rgba(16,24,40,.5);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 720px) {
  .api-grid { grid-template-columns: 1fr; }
  .stat { display: none; }
  .topbar-right .btn { padding: 6px 10px; }
  .result-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .section-actions { flex-wrap: wrap; }
  .bar { width: 80px; }
}
