:root {
  --ink: #0f172a;
  --ink-2: #334155;
  --ink-3: #64748b;
  --line: #e6eaf2;
  --surface: #ffffff;
  --surface-2: #f7f8fc;
  --brand: #fe2c55;
  --brand-2: #25f4ee;
  --ok: #10b981;
  --radius: 18px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06), 0 2px 8px rgba(15, 23, 42, .05);
  --shadow-md: 0 10px 30px -12px rgba(15, 23, 42, .18), 0 2px 10px rgba(15, 23, 42, .05);
  --shadow-lg: 0 30px 70px -30px rgba(15, 23, 42, .3);
}

* { box-sizing: border-box; }

/* 保证 hidden 属性优先级高于组件自身的 display 声明 */
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: #fbfcfe;
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
  overflow-x: hidden;
}

/* ---------- 背景装饰 ---------- */
.bg-decor { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.blob { position: absolute; border-radius: 50%; filter: blur(80px); opacity: .5; }
.blob-a { width: 480px; height: 480px; top: -220px; left: -140px; background: radial-gradient(circle, rgba(254,44,85,.26), transparent 68%); }
.blob-b { width: 520px; height: 520px; top: -180px; right: -200px; background: radial-gradient(circle, rgba(37,244,238,.28), transparent 68%); }

/* ---------- 顶部 ---------- */
.topbar {
  position: relative; z-index: 2;
  width: 100%; max-width: 780px; margin: 0 auto; padding: 22px 20px 0;
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand-mark {
  width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, #111827, #1f2937); color: var(--brand-2);
  box-shadow: 0 6px 16px -8px rgba(17, 24, 39, .8);
}
.brand-text { font-weight: 700; font-size: 16px; letter-spacing: -.2px; }

main {
  position: relative; z-index: 1; flex: 1 0 auto;
  width: 100%; max-width: 780px; margin: 0 auto; padding: 20px 20px 40px;
}

/* ---------- 输入区 ---------- */
.tool {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-md); padding: 14px;
}
.input-wrap { position: relative; }
#input {
  width: 100%; min-height: 92px; resize: vertical; padding: 15px 42px 15px 15px;
  border: 1.5px solid var(--line); border-radius: 13px; background: var(--surface-2);
  font-family: inherit; font-size: 15px; color: var(--ink); line-height: 1.7;
  outline: none; transition: border-color .18s, box-shadow .18s, background .18s;
}
#input::placeholder { color: #9aa6b8; }
#input:focus { border-color: #c7cfdd; background: #fff; box-shadow: 0 0 0 4px rgba(254,44,85,.08); }
.clear-btn {
  position: absolute; top: 11px; right: 11px; width: 28px; height: 28px; border-radius: 8px;
  border: 1px solid var(--line); background: #fff; color: var(--ink-3); cursor: pointer;
  display: grid; place-items: center; transition: all .16s;
}
.clear-btn:hover { color: var(--brand); border-color: #ffd0da; background: #fff5f7; }

.btn-primary {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  margin-top: 12px; width: 100%;
  padding: 13px 26px; border: none; border-radius: 12px; cursor: pointer;
  font-size: 15px; font-weight: 600; font-family: inherit; color: #fff; text-decoration: none;
  background: linear-gradient(120deg, #fe2c55, #ff5c8a 45%, #111827 130%);
  box-shadow: 0 12px 26px -14px rgba(254, 44, 85, .95);
  transition: transform .16s, box-shadow .16s, filter .16s;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 16px 30px -14px rgba(254,44,85,1); }
.btn-primary:active { transform: translateY(0); }
/* 按钮图标：解析态为空（自动收起），下载态显示箭头 */
.btn-ico { display: none; }
.btn-ico.has { display: inline-flex; align-items: center; }
.btn-primary.is-loading .btn-ico { display: none; }
.btn-primary.is-loading .btn-label { opacity: .55; }
.btn-primary.is-loading { pointer-events: none; filter: saturate(.8); }
.btn-spinner { display: none; width: 15px; height: 15px; border-radius: 50%; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; animation: spin .7s linear infinite; }
.btn-primary.is-loading .btn-spinner { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 提示条 ---------- */
.notice {
  display: flex; gap: 11px; align-items: flex-start; margin-top: 14px; padding: 13px 15px;
  border-radius: 13px; border: 1px solid #ffe0b2; background: #fffaf1; color: #92400e;
  font-size: 14px; animation: fade .25s ease;
}
.notice.error { border-color: #fecdd3; background: #fff5f6; color: #b91c3c; }
.notice.ok { border-color: #bbf7d0; background: #f2fdf7; color: #047857; }
.notice-icon { flex: none; margin-top: 1px; }
.notice p { margin: 0; }

/* ---------- 加载态 ---------- */
.skeleton { margin-top: 16px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-sm); }
.sk-line, .sk-media { border-radius: 10px; background: linear-gradient(90deg, #eef1f7 25%, #f7f9fc 50%, #eef1f7 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; }
.sk-line { height: 14px; margin-top: 12px; }
.sk-line.w60 { width: 60%; } .sk-line.w40 { width: 40%; }
.sk-media { height: 220px; border-radius: 14px; }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes fade { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* ---------- 结果 ---------- */
.result {
  margin-top: 16px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); overflow: hidden;
  animation: rise .35s cubic-bezier(.2,.8,.3,1);
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.result-body { display: grid; grid-template-columns: minmax(0, .92fr) minmax(0, 1.08fr); gap: 22px; padding: 18px; }

.media-frame {
  position: relative; border-radius: 15px; overflow: hidden; background: #0b1220;
  aspect-ratio: 9 / 13; display: grid; place-items: center; box-shadow: var(--shadow-md);
}
.media-frame video { width: 100%; height: 100%; object-fit: contain; display: block; background: #0b1220; }
.media-frame img { width: 100%; height: 100%; object-fit: contain; display: block; }
.result.is-image .media-frame { background: #f1f5f9; }

.info-col { min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.tag {
  align-self: flex-start; font-size: 12px; font-weight: 600; padding: 4px 11px; border-radius: 999px;
  color: #fff; background: linear-gradient(120deg, var(--brand), #ff6a8e); margin-bottom: 12px;
}
.tag.image { background: linear-gradient(120deg, #6366f1, #8b5cf6); }
.work-title { margin: 0 0 8px; font-size: 17px; line-height: 1.5; font-weight: 650; letter-spacing: -.2px; word-break: break-word; }
.byline { margin: 0 0 16px; font-size: 13px; color: var(--ink-3); word-break: break-word; }

/* 图集分组标题 */
.quality-label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-3); letter-spacing: .3px; margin-bottom: 8px; }

/* 图集 */
.gallery-wrap { padding: 0 18px 18px; }
.gallery { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.gallery-item { position: relative; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: #f1f5f9; aspect-ratio: 3/4; }
.gallery-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery-item .gi-dl {
  position: absolute; right: 6px; bottom: 6px; padding: 3px 8px; border-radius: 7px; font-size: 11px;
  background: rgba(15,23,42,.72); color: #fff; text-decoration: none; backdrop-filter: blur(4px);
}
.gallery-item .gi-idx { position: absolute; left: 6px; top: 6px; font-size: 11px; color: #fff; background: rgba(15,23,42,.6); padding: 2px 7px; border-radius: 6px; }

/* ---------- 页脚 ---------- */
.footer { position: relative; z-index: 1; width: 100%; max-width: 780px; margin: 0 auto; padding: 0 20px 36px; }
.footer p { font-size: 12.5px; color: var(--ink-3); margin: 0; text-align: center; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 34px; transform: translate(-50%, 12px);
  background: rgba(15, 23, 42, .94); color: #fff; padding: 11px 20px; border-radius: 12px;
  font-size: 14px; z-index: 99; box-shadow: 0 18px 40px -18px rgba(15,23,42,.9);
  opacity: 0; transition: opacity .22s, transform .22s; max-width: 88vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: rgba(190, 24, 93, .95); }
.toast.ok { background: rgba(5, 122, 85, .95); }

/* ---------- 响应式 ---------- */
@media (max-width: 620px) {
  .result-body { grid-template-columns: 1fr; gap: 16px; }
  .media-frame { aspect-ratio: 9 / 12; }
  .gallery { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
