/* QIMG 前端样式表
 * 由 index.php 内联 <style> 抽出，index.php 不再保留 UI 样式代码。
 */
:root, :root[data-theme="light"] {
  color-scheme: light;
  --bg: #fdfdfd;
  --bg-gradient: none;
  --panel: rgba(255,255,255,0.85);
  --panel-border: rgba(15,23,42,0.06);
  --text: #0f172a;
  --text-muted: #475569;
  --text-faint: #64748b;
  --h1-accent: #64748b;
  --primary: #111827;
  --primary-strong: #000000;
  --primary-glow: rgba(17,24,39,0.12);
  --accent: #374151;
  --shadow: 0 20px 50px rgba(15,23,42,0.05);
  --card-shadow: 0 4px 20px rgba(15,23,42,0.03);
  --input-bg: #ffffff;
  --code-bg: #0f172a;
  --warn-bg: rgba(17,24,39,0.08);
  --warn-text: #374151;
  --ok: #111827;
  --codec-ready: #15803d;
  --codec-fail: #dc2626;
  --hero-btn-bg: #111827;
  --hero-btn-text: #ffffff;
  --solid-btn-bg: #111827;
  --solid-btn-text: #ffffff;
  --solid-btn-border: transparent;
  --drop-border: #111827;
  --drop-border-hover: #000000;
  --drop-dash: #9ca3af;
  --drop-dash-hover: #6b7280;
  --topbar-bg: rgba(253,253,253,0.72);
  --topbar-border: #d4d4d8;
  --glow-c1: rgba(99,102,241,0.16);
  --glow-c2: rgba(236,72,153,0.13);
  --glow-c3: rgba(56,189,248,0.10);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000000;
  --bg-gradient: linear-gradient(180deg, #000000 0%, #000000 100%);
  --panel: #0a0a0a;
  --panel-border: rgba(255,255,255,0.06);
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-faint: #64748b;
  --h1-accent: #94a3b8;
  --primary: #f9fafb;
  --primary-hover: #ffffff;
  --primary-strong: #ffffff;
  --primary-glow: rgba(255,255,255,0.18);
  --accent: #9ca3af;
  --topbar-bg: rgba(0,0,0,0.55);
  --topbar-border: #3f3f46;
  --shadow: 0 20px 50px rgba(0,0,0,0.35);
  --card-shadow: 0 4px 20px rgba(0,0,0,0.25);
  --input-bg: #141414;
  --code-bg: #000000;
  --warn-bg: rgba(255,255,255,0.10);
  --warn-text: #d1d5db;
  --ok: #e5e7eb;
  --codec-ready: #34d399;
  --codec-fail: #f87171;
  --hero-btn-bg: #1f1f1f;
  --hero-btn-text: #ffffff;
  --solid-btn-bg: #1a1a1a;
  --solid-btn-text: #ffffff;
  --solid-btn-border: rgba(255,255,255,0.14);
  --drop-border: rgba(255,255,255,0.24);
  --drop-border-hover: rgba(255,255,255,0.45);
  --drop-dash: rgba(255,255,255,0.30);
  --drop-dash-hover: rgba(255,255,255,0.55);
  --glow-c1: rgba(99,102,241,0.22);
  --glow-c2: rgba(236,72,153,0.16);
  --glow-c3: rgba(56,189,248,0.14);
}

/* ============ 页面背景流光（B 方案 + 三团缓慢漂移） ============ */
.glow-layer { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.glow-layer i { position: absolute; display: block; border-radius: 50%; filter: blur(38px); will-change: transform; }
.glow-a {
  width: 1200px; height: 700px; left: 50%; top: -18%;
  background: radial-gradient(closest-side, var(--glow-c1), transparent 72%);
  animation: driftA 22s ease-in-out infinite;
}
.glow-b {
  width: 700px; height: 560px; left: 108%; top: 88%;
  background: radial-gradient(closest-side, var(--glow-c2), transparent 72%);
  animation: driftB 28s ease-in-out infinite;
}
.glow-c {
  width: 620px; height: 620px; left: -6%; top: 62%;
  background: radial-gradient(closest-side, var(--glow-c3), transparent 75%);
  animation: driftC 34s ease-in-out infinite;
}
@keyframes driftA {
  0%   { transform: translate(-50%,-50%) translate3d(0,0,0) scale(1); }
  33%  { transform: translate(-50%,-50%) translate3d(7%,5%,0) scale(1.14); }
  66%  { transform: translate(-50%,-50%) translate3d(-6%,3%,0) scale(0.94); }
  100% { transform: translate(-50%,-50%) translate3d(0,0,0) scale(1); }
}
@keyframes driftB {
  0%   { transform: translate(-50%,-50%) translate3d(0,0,0) scale(1); }
  33%  { transform: translate(-50%,-50%) translate3d(-9%,-6%,0) scale(1.18); }
  66%  { transform: translate(-50%,-50%) translate3d(5%,-3%,0) scale(0.92); }
  100% { transform: translate(-50%,-50%) translate3d(0,0,0) scale(1); }
}
@keyframes driftC {
  0%   { transform: translate(-50%,-50%) translate3d(0,0,0) scale(1); }
  33%  { transform: translate(-50%,-50%) translate3d(8%,-7%,0) scale(1.16); }
  66%  { transform: translate(-50%,-50%) translate3d(-4%,6%,0) scale(0.96); }
  100% { transform: translate(-50%,-50%) translate3d(0,0,0) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .glow-layer i { animation: none !important; }
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { min-height: 100%; background-color: var(--bg); background-image: var(--bg-gradient); background-repeat: no-repeat; background-size: 100% 100%; }
body { min-height: 100vh; font-family: "Inter", system-ui, sans-serif; color: var(--text); background: transparent; transition: background 0.3s, color 0.3s; line-height: 1.6; touch-action: manipulation; }
button, .drop-zone, .copy-btn { touch-action: manipulation; }
.shell { position: relative; z-index: 1; width: min(1080px, calc(100vw - 32px)); margin: 0 auto; padding: 0 0 48px; }
.header { position: sticky; top: 0; z-index: 50; margin-bottom: 24px; padding: 7px 0; background: var(--topbar-bg); backdrop-filter: blur(16px) saturate(180%); -webkit-backdrop-filter: blur(16px) saturate(180%); border-bottom: 1px solid var(--topbar-border); }
.header-inner { width: min(1080px, calc(100vw - 32px)); margin: 0 auto; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 8px; }
.brand-logo { width: 26px; height: 26px; display: block; object-fit: contain; }
[data-theme="dark"] .brand-logo,
[data-theme="dark"] .upload-brand img { filter: brightness(0) invert(1); }
.upload-brand { position: absolute; top: 13px; left: 20px; z-index: 2; display: inline-flex; align-items: center; gap: 7px; max-width: calc(100% - 130px); min-width: 0; }
.upload-brand img { width: 20px; height: 20px; display: block; object-fit: contain; flex-shrink: 0; }
.upload-brand span { font-family: "Outfit", sans-serif; font-size: 14px; font-weight: 700; color: var(--text); letter-spacing: 0.01em; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.header-actions { display: flex; align-items: center; gap: 10px; }

.gh-link {
  display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 50%; padding: 0; border: 1px solid var(--panel-border); background: var(--panel); color: var(--text); cursor: pointer; box-shadow: var(--card-shadow); transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); text-decoration: none; flex-shrink: 0;
}
.gh-link span { display: none; }
.gh-link:hover { background: var(--input-bg); transform: translateY(-2px); box-shadow: 0 6px 15px rgba(0, 0, 0, 0.08); }
.gh-link:active { transform: scale(0.96); }
.gh-link svg { fill: currentColor; stroke: none; width: 16px; height: 16px; }

.icon-btn { position: relative; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--panel-border); background: var(--panel); cursor: pointer; color: var(--text); transition: background 0.2s, transform 0.2s; flex-shrink: 0; }
.icon-btn:hover { background: var(--input-bg); transform: translateY(-2px); }
.icon-btn svg { position: absolute; inset: 0; margin: auto; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: opacity 0.25s, transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); }
.icon-btn .sun-icon { opacity: 0; transform: rotate(-90deg) scale(0.4); }
.icon-btn .moon-icon { opacity: 0; transform: rotate(90deg) scale(0.4); }
:root[data-theme="light"] .icon-btn .moon-icon { opacity: 1; transform: rotate(0deg) scale(1); }
:root[data-theme="dark"] .icon-btn .sun-icon { opacity: 1; transform: rotate(0deg) scale(1); }
:root:not([data-theme]) .icon-btn .moon-icon { opacity: 1; transform: rotate(0deg) scale(1); }

.hero h1 .h1-accent { color: var(--h1-accent); }
.hero { padding: 0 0 8px; background: none; box-shadow: none; backdrop-filter: none; margin-bottom: 22px; }
.hero-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 20px; width: 100%; }
.stat { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-width: 0; }
.stat-num { font-family: "Outfit", sans-serif; font-size: 19px; font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; line-height: 1.2; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.stat-label { font-size: 12.5px; color: var(--text-faint); text-align: center; white-space: nowrap; }
.more-wrap { position: relative; flex-shrink: 0; }
.more-btn .dots-icon { fill: currentColor; stroke: none; width: 17px; height: 17px; }
.more-menu { position: absolute; top: calc(100% + 8px); right: 0; z-index: 60; min-width: 84px; padding: 5px; border-radius: 12px; border: 1px solid var(--panel-border); background: var(--panel); box-shadow: var(--card-shadow); display: none; }
.more-menu.show { display: block; }
.more-menu a { display: block; padding: 9px 10px; border-radius: 8px; font-size: 13px; font-weight: 500; color: var(--text-muted); text-decoration: none; white-space: nowrap; transition: background 0.2s, color 0.2s; }
.more-menu a:hover { background: var(--input-bg); color: var(--primary); }
h1 { font-family: "Outfit", sans-serif; font-weight: 800; font-size: clamp(26px, 4vw, 42px); line-height: 1.25; background: linear-gradient(120deg, var(--text) 0%, var(--primary) 60%, var(--accent) 100%); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; margin-bottom: 12px; }
.lead { color: var(--text-muted); font-size: 15px; }

.codec-tag { position: absolute; top: 13px; right: 20px; z-index: 2; display: inline-flex; align-items: center; gap: 6px; padding: 4px 0; border-radius: 0; font-size: 11px; font-family: "JetBrains Mono", monospace; background: transparent; color: var(--text-muted); }
.codec-tag i { width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); display: block; transform-origin: center; --codec-glow: rgba(148,163,184,0.55); animation: codecBreathe 2.2s ease-in-out infinite; }
.codec-tag.ready i { background: var(--codec-ready); --codec-glow: rgba(16,185,129,0.55); }
.codec-tag.fail i { background: var(--codec-fail); --codec-glow: rgba(220,38,38,0.55); }
@keyframes codecBreathe {
  0%   { transform: scale(1);    opacity: 1;    box-shadow: 0 0 0 0 var(--codec-glow); }
  70%  { transform: scale(1.55); opacity: 0.28; box-shadow: 0 0 0 7px rgba(0,0,0,0); }
  100% { transform: scale(1);    opacity: 1;    box-shadow: 0 0 0 0 rgba(0,0,0,0); }
}
@media (prefers-reduced-motion: reduce) {
  .codec-tag i { animation: none; }
  .codec-tag.ready i { box-shadow: 0 0 0 3px rgba(16,185,129,0.18); }
  .codec-tag.fail i { box-shadow: 0 0 0 3px rgba(220,38,38,0.18); }
}

.upload-card { position: relative; padding: 46px 20px 20px; border: 1px solid var(--panel-border); border-radius: 20px; background: var(--panel); box-shadow: var(--card-shadow); margin-bottom: 22px; }
.drop-zone { border: 1.5px dashed var(--drop-dash); border-radius: 12px; padding: 22px 16px; margin-bottom: 18px; text-align: center; cursor: pointer; transition: all 0.3s, border-color 0.3s; position: relative; }
.drop-zone { -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none; }
.drop-zone.dragover { border-color: var(--drop-dash-hover); background: var(--primary-glow); }
@media (hover: hover) and (pointer: fine) {
  .drop-zone:hover { border-color: var(--drop-dash-hover); background: var(--primary-glow); }
}
.drop-zone svg { width: 39px; height: 39px; stroke: var(--primary); margin-bottom: 8px; }
.drop-zone p { color: var(--text-muted); font-size: 14px; }
.drop-zone .hint { font-size: 11.5px; color: var(--text-faint); margin-top: 6px; }
.drop-zone .up-icon { width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 14px; border: 1px solid var(--panel-border); background: var(--hover-bg); display: flex; align-items: center; justify-content: center; color: var(--text-muted); }
.drop-zone .up-icon svg { width: 26px; height: 26px; stroke: currentColor; margin-bottom: 0; }
.drop-zone .pick { display: none; margin: 0 0 12px; font-size: 14px; color: var(--text-muted); font-weight: 600; }
.drop-zone .pick.show { display: block; }
.drop-zone .fmt-tags { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 12px; }
.drop-zone .fmt-tags span { padding: 3px 9px; border-radius: 6px; border: 1px solid var(--panel-border); background: var(--hover-bg); color: var(--text-faint); font-size: 11px; font-weight: 600; letter-spacing: 0.3px; font-family: "Outfit", sans-serif; }
#fileInput { display: none; }
.drop-zone.uploading { pointer-events: none; }


.warn-banner { margin: 0 0 14px; padding: 10px 14px; border-radius: 10px; background: var(--warn-bg); color: var(--warn-text); font-size: 12px; display: none; }
.warn-banner.show { display: block; }

.result-card { padding: 24px; border: 1px solid var(--panel-border); border-radius: 20px; background: var(--panel); box-shadow: var(--card-shadow); margin-top: 22px; margin-bottom: 22px; display: none; }
.result-card.show { display: block; }
.preview-img { max-width: 100%; max-height: 300px; border-radius: 12px; border: 1px solid var(--panel-border); margin-bottom: 12px; display: block; }
.compress-info { font-size: 12.5px; color: var(--text-muted); font-family: "JetBrains Mono", monospace; margin-bottom: 14px; }
.compress-info b { color: var(--ok); font-weight: 600; }
.format-tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.format-tab { padding: 6px 15px; border-radius: 999px; font-family: "Outfit", sans-serif; font-size: 12.5px; font-weight: 600; border: 1px solid var(--panel-border); background: transparent; color: var(--text-muted); cursor: pointer; transition: all 0.2s; touch-action: manipulation; }
.format-tab:hover { border-color: var(--primary); color: var(--primary); }
.format-tab.is-active { background: var(--primary); border-color: var(--primary); color: var(--bg); }
.format-pane { display: none; }
.format-pane.is-active { display: block; }
.url-row { display: flex; gap: 8px; align-items: center; }
.url-row code { flex: 1; font-family: "JetBrains Mono", monospace; font-size: 12px; background: var(--code-bg); color: #ffffff; padding: 10px 14px; border-radius: 8px; overflow-x: auto; white-space: nowrap; }
.copy-btn { flex-shrink: 0; padding: 10px 18px; border-radius: 8px; border: 1px solid var(--solid-btn-border); font-family: "Outfit", sans-serif; font-weight: 600; font-size: 13px; color: var(--solid-btn-text); background: var(--solid-btn-bg); cursor: pointer; transition: all 0.2s; }
.copy-btn.copied { background: var(--solid-btn-bg); color: var(--solid-btn-text); }


.footer { margin-top: 32px; padding: 22px 16px; text-align: center; color: var(--text-muted); font-size: 13.5px; line-height: 1.9; }
.footer > div { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; }
.footer svg { width: 16px; height: 16px; flex-shrink: 0; color: var(--primary); fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.footer svg[data-solid="true"] { fill: currentColor; stroke: none; }
.footer a { color: var(--primary); text-decoration: none; border-bottom: 1px solid var(--primary-glow); transition: color 0.2s ease, border-bottom-color 0.2s ease; font-weight: 500; display: inline-flex; align-items: center; gap: 4px; }
.footer a:hover { color: var(--primary-hover); border-bottom-color: var(--primary); }
.footer .dot { display: inline-block; opacity: 0.5; }
.footer a.beian { color: var(--text-muted); border-bottom: 0; font-weight: 400; }
.footer a.beian:hover { color: var(--primary); }

.top-grid { display: grid; grid-template-columns: 1fr; gap: 22px; }
.top-grid .hero, .top-grid .upload-card { margin-bottom: 0; }

.q-mask { position: fixed; inset: 0; z-index: 9999; display: none; align-items: center; justify-content: center; padding: 24px; background: rgba(0,0,0,0.36); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.q-mask.show { display: flex; }
.q-box { width: 100%; max-width: 330px; padding: 24px 22px 18px; border-radius: 18px; border: 1px solid var(--panel-border); background: var(--panel); box-shadow: var(--shadow); text-align: center; animation: qPop 0.22s cubic-bezier(0.16, 1, 0.3, 1); }
@keyframes qPop { from { opacity: 0; transform: scale(0.94); } to { opacity: 1; transform: scale(1); } }
.q-title { font-size: 14.5px; font-weight: 600; line-height: 1.65; color: var(--text); word-break: break-all; }
.q-msg { margin-top: 9px; font-size: 13px; line-height: 1.65; color: var(--text-muted); font-variant-numeric: tabular-nums; -webkit-font-variant-numeric: tabular-nums; }
.q-msg.hide { display: none; }
.q-btn { display: block; margin: 20px auto 0; min-width: 104px; padding: 12px 30px; border: 0; border-radius: 999px; background: var(--text); color: var(--bg); font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer; transition: opacity 0.2s; }
.q-btn:hover { opacity: 0.86; }

@media (min-width: 980px) {
  .shell { width: min(1180px, calc(100vw - 48px)); }
  .top-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
  .result-card { padding: 28px; }
  .drop-zone { padding: 30px 20px; }
  .upload-card { padding: 46px 26px 26px; }
}

@media (max-width: 720px) {
  .hero { padding: 0 0 4px; }
  .hero-stats { gap: 10px; margin-top: 16px; }
  .stat-num { font-size: 17px; }
  .stat-label { font-size: 11.5px; }
  .upload-card { padding: 44px 14px 16px; }
  .upload-brand { top: 12px; left: 14px; gap: 6px; max-width: calc(100% - 110px); }
  .upload-brand img { width: 18px; height: 18px; }
  .upload-brand span { font-size: 13px; }
  .codec-tag { top: 12px; right: 14px; font-size: 10.5px; padding: 4px 10px; }
  .drop-zone { padding: 18px 12px; margin-bottom: 16px; }
  .drop-zone svg { width: 35px; height: 35px; }
  .drop-zone p { font-size: 13px; }
  .drop-zone .hint { font-size: 11px; }
  .drop-zone .up-icon { width: 50px; height: 50px; border-radius: 12px; }
  .drop-zone .up-icon svg { width: 24px; height: 24px; }
}

/* ===== 最近上传（本地记录）===== */
.history-card {
  padding: 20px;
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: var(--card-shadow);
  margin-top: 22px;
}
.history-card h3 {
  font-family: "Outfit", sans-serif;
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 12px;
}
/* 固定两列 × 三行 = 最多六张，格子随容器宽度撑开 */
.history-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.history-item {
  position: relative;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--input-bg);
}
.history-thumb {
  position: relative;
  height: 104px;
  background: var(--panel-border);
  overflow: hidden;
}
.history-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.history-item .copy-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  border: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity .2s;
  cursor: pointer;
}
.history-item:hover .copy-overlay,
.history-item .copy-overlay:focus-visible {
  opacity: 1;
}
.history-item .copy-overlay span {
  color: #fff;
  font-size: 11px;
  font-weight: 600;
}

/* 触屏无 hover，遮罩常显，否则手机上根本点不到「复制链接」 */
@media (hover: none) {
  .history-item .copy-overlay { opacity: 1; background: rgba(0, 0, 0, 0.42); }
}

@media (min-width: 980px) {
  .history-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .history-thumb { height: 170px; }
  .history-card { padding: 26px; }
}

/* ── 图片预览层（点击上传结果图放大）─────────────────── */
.vp-lb {
  position: fixed; inset: 0; z-index: 300;
  display: none; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.9);
  padding: 24px;
}
.vp-lb.show { display: flex; }
.vp-lb img {
  max-width: 100%; max-height: 100%;
  object-fit: contain; border-radius: 10px; display: block;
}
.vp-lb-close {
  position: absolute; top: 16px; right: 16px;
  width: 38px; height: 38px; border-radius: 50%;
  border: 0; padding: 0; cursor: pointer;
  background: rgba(255, 255, 255, 0.16); color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.vp-lb-close svg {
  width: 18px; height: 18px; fill: none;
  stroke: currentColor; stroke-width: 2.4; stroke-linecap: round;
}
.result-card .preview-img { cursor: zoom-in; }
