/* 轱辘 VI · 海报 Logo 规范摆放工具样式 */
@font-face {
  font-family: 'JINGDONGLangZhengTi2';
  src: url('./assets/fonts/JINGDONGLangZhengTi2-Bold.woff2') format('woff2'),
       url('./assets/fonts/JINGDONGLangZhengTi2-Bold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'JINGDONGLangZhengTi2';
  src: url('./assets/fonts/JINGDONGLangZhengTi2-Regular.woff2') format('woff2'),
       url('./assets/fonts/JINGDONGLangZhengTi2-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --paper: #f3f2ed;
  --ink: #111;
  --muted: #8a877f;
  --line: #d8d5cc;
  --accent: #6c5ce7;
  --accent-soft: #a29bfe;
  --green: #27ae60;
  --red: #c3352b;
  --brand-red: #e2211c;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.5;
}
button, input, select { font: inherit; }
button { cursor: pointer; }

.vi-shell { min-height: 100dvh; display: flex; flex-direction: column; }

/* 顶栏 */
.topbar {
  height: 72px; padding: 0 clamp(18px, 4vw, 58px);
  display: flex; align-items: center; gap: 28px;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
  background: rgba(243, 242, 237, .88);
  backdrop-filter: blur(18px);
  position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 800; letter-spacing: -.055em; font-size: 22px; text-decoration: none; color: var(--ink); white-space: nowrap; }
.brand-dot { color: var(--accent); }
.topnav { display: flex; gap: 6px; margin-left: auto; }
.topnav a { padding: 9px 13px; border-radius: 999px; color: #666; font-size: 14px; text-decoration: none; transition: background .2s, color .2s; }
.topnav a:hover { background: #111; color: #fff; }

/* 页面 */
.vi-page { width: min(1400px, calc(100% - 48px)); margin: 0 auto; padding: 36px 0 60px; flex: 1; }

.vi-intro { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(280px, .6fr); align-items: end; gap: 48px; padding: 18px 0 32px; border-bottom: 1px solid var(--line); }
.gallery-index { margin: 0 0 16px; color: var(--accent); font-size: 12px; font-weight: 700; letter-spacing: .16em; }
.vi-intro h1 { max-width: 800px; margin: 0; font-size: clamp(48px, 7vw, 96px); letter-spacing: -.08em; line-height: .85; }
.intro-desc { max-width: 54ch; margin: 22px 0 0; color: #666; font-size: 15px; line-height: 1.75; }

.vi-download-block { display: grid; gap: 0; padding-top: 14px; justify-items: stretch; }
.vi-mascot { width: 60%; justify-self: center; display: block; }
.vi-download-btn { display: block; text-align: center; padding: 14px 18px; background: var(--accent); color: #fff; text-decoration: none; font-weight: 700; font-size: 14px; letter-spacing: -.01em; border-radius: 12px; transition: background .15s ease; line-height: 1.4; }
.vi-download-btn:hover { background: #5b4bd0; }
.vi-download-hint { color: var(--muted); font-size: 11px; text-align: center; margin-top: 12px; }

/* Workspace */
.vi-workspace { display: grid; grid-template-columns: 360px 1fr; gap: 24px; margin-top: 28px; align-items: start; }

/* Cards */
.vi-card { background: rgba(255,255,255,.6); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; margin-bottom: 16px; }
.vi-card-head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; font-size: 15px; }
.vi-card-body { padding: 18px; }

/* Upload */
.vi-upload-zone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: 36px 20px; border: 2px dashed var(--line); border-radius: 14px;
  background: rgba(255,255,255,.5); cursor: pointer; transition: border-color .2s, background .2s; text-align: center;
}
.vi-upload-zone:hover, .vi-upload-zone.drag { border-color: var(--accent); background: rgba(108,92,231,.05); }
.upload-icon { font-size: 36px; color: var(--accent); }
.vi-upload-zone strong { font-size: 15px; }
.vi-upload-zone small { color: var(--muted); font-size: 12px; }

/* Poster Info */
.vi-poster-info { margin-top: 14px; padding: 12px 14px; background: rgba(108,92,231,.06); border-radius: 10px; font-size: 13px; }
.info-row { display: flex; justify-content: space-between; padding: 3px 0; }
.info-row span { color: var(--muted); }
.info-row strong { font-variant-numeric: tabular-nums; }

/* Logo Grid */
.logo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.logo-option {
  display: flex; flex-direction: column; background: #fff; border: 2px solid var(--line);
  border-radius: 10px; cursor: pointer; transition: all .2s; padding: 12px; text-align: left; position: relative;
}
.logo-option:hover { border-color: #999; }
.logo-option.active { border-color: var(--accent); background: rgba(108,92,231,.06); }
.logo-preview {
  min-height: 72px; display: flex; align-items: center; justify-content: center;
  margin-bottom: 8px; background: #fff; border-radius: 6px; padding: 8px;
}
.logo-preview img { max-width: 100%; max-height: 100px; width: auto; height: auto; object-fit: contain; }
.logo-name { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.logo-desc { font-size: 11px; color: var(--muted); }
.logo-option.active::after {
  content: '✓'; position: absolute; top: 6px; right: 8px; width: 16px; height: 16px;
  border-radius: 50%; background: var(--accent); color: #fff; font-size: 10px; font-weight: 700;
  display: grid; place-items: center;
}

/* Specs */
.spec-list { display: flex; flex-direction: column; gap: 8px; }
.spec-item {
  display: flex; justify-content: space-between; align-items: center; font-size: 13px;
  padding: 8px 12px; background: rgba(108,92,231,.04); border-radius: 8px;
}
.spec-item span { color: var(--muted); font-size: 12px; }
.spec-item strong { font-variant-numeric: tabular-nums; font-size: 13px; }

/* Controls */
.ctrl-group { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.ctrl-label { font-size: 13px; font-weight: 600; display: flex; justify-content: space-between; }
.ctrl-label output { color: var(--accent); font-weight: 700; }
input[type="range"] { width: 100%; accent-color: var(--accent); }

/* Buttons */
.btn { min-height: 40px; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--ink); padding: 0 16px; font-size: 14px; transition: all .15s; }
.btn:hover { border-color: #777; }
.btn-dark { background: #111; color: #fff; border-color: #111; }
.btn-dark:hover { background: #333; }
.btn-dark:disabled { background: #aaa; border-color: #aaa; cursor: not-allowed; }
.btn-small { min-height: 32px; padding: 0 12px; font-size: 12px; }
.btn-ghost { background: transparent; border: none; color: var(--muted); }
.btn-ghost:hover { color: var(--ink); }

/* Preview */
.vi-preview { background: rgba(255,255,255,.5); border: 1px solid var(--line); border-radius: 16px; padding: 20px; display: flex; flex-direction: column; min-height: 600px; }
.preview-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; gap: 10px; }
.preview-info { display: flex; align-items: center; gap: 12px; font-size: 13px; color: #666; }
.preview-badge { background: rgba(39,174,96,.14); color: var(--green); padding: 2px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.canvas-wrap {
  flex: 1; display: grid; place-items: center; position: relative; overflow: auto; min-height: 400px;
  background: repeating-conic-gradient(rgba(0,0,0,.03) 0% 25%, transparent 0% 50%) 50% / 20px 20px; border-radius: 12px;
}
.canvas-stage { position: relative; display: inline-block; max-width: 100%; box-shadow: 0 8px 28px rgba(0,0,0,.1); }
#poster-image { display: block; max-width: 100%; height: auto; }
#logo-layer { position: absolute; top: 0; left: 0; cursor: move; user-select: none; }
#logo-layer img { width: 100%; height: 100%; display: block; pointer-events: none; }
.guide-overlay { position: absolute; inset: 0; pointer-events: none; }
.safe-area { position: absolute; border: 1.5px dashed #00C2FF; background: rgba(0,194,255,.06); pointer-events: none; }
.safe-label { position: absolute; background: #00C2FF; color: #fff; font-size: 10px; font-weight: 600; padding: 1px 6px; border-radius: 3px; font-variant-numeric: tabular-nums; }
.empty-canvas { text-align: center; color: var(--muted); padding: 80px 20px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty-canvas strong { font-size: 15px; }
.empty-canvas small { font-size: 13px; }

.vi-notice { margin-top: 16px; padding: 12px 16px; background: rgba(108,92,231,.06); border: 1px solid rgba(108,92,231,.2); border-radius: 10px; font-size: 13px; color: #555; line-height: 1.7; }

.vi-foot { padding: 24px clamp(18px, 4vw, 58px); border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 13px; flex-wrap: wrap; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%) translateY(20px);
  background: #111; color: #fff; padding: 12px 22px; border-radius: 12px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: all .25s; z-index: 1000;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* PDF Modal */
.pdf-modal {
  position: fixed; inset: 0; z-index: 300; background: rgba(0,0,0,.5); backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center; padding: 32px;
}
.pdf-modal.show { display: flex; }
.pdf-modal-content { background: #fff; border-radius: 16px; width: 100%; max-width: 1100px; height: 90vh; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 24px 64px rgba(0,0,0,.3); }
.pdf-modal-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--line); gap: 12px; }
.pdf-modal-title { font-size: 15px; font-weight: 600; flex: 1; }
.pdf-modal-actions { display: flex; align-items: center; gap: 8px; }
.pdf-download-link { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; font-size: 13px; font-weight: 600; background: rgba(108,92,231,.1); color: var(--accent); border-radius: 8px; text-decoration: none; transition: all .2s; }
.pdf-download-link:hover { background: var(--accent); color: #fff; }
.pdf-modal-close { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; color: var(--muted); border: none; background: none; font-size: 22px; cursor: pointer; }
.pdf-modal-close:hover { background: rgba(0,0,0,.06); color: var(--ink); }
.pdf-modal-body { flex: 1; overflow-y: auto; display: flex; flex-direction: column; align-items: center; padding: 16px; gap: 8px; background: var(--paper); }
.pdf-gallery { width: 100%; display: flex; flex-direction: column; align-items: center; }
.pdf-gallery img { max-width: 900px; width: 100%; height: auto; display: block; border-radius: 6px; box-shadow: 0 2px 12px rgba(0,0,0,.1); margin-bottom: 8px; }

/* 警告弹窗 */
.warn-modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: none; align-items: center; justify-content: center; z-index: 9999; }
.warn-modal.show { display: flex; }
.warn-modal-box { background: #fff; border-radius: 16px; width: 90%; max-width: 420px; padding: 28px 24px 20px; box-shadow: 0 24px 64px rgba(0,0,0,.3); text-align: center; }
.warn-modal-icon { font-size: 40px; margin-bottom: 12px; }
.warn-modal-title { font-size: 17px; font-weight: 700; margin-bottom: 12px; }
.warn-modal-msg { font-size: 14px; color: #555; line-height: 1.7; white-space: pre-line; margin-bottom: 20px; }
.warn-modal-btn { padding: 8px 32px; border: none; border-radius: 8px; background: var(--ink); color: #fff; font-size: 14px; font-weight: 600; cursor: pointer; }
.warn-modal-btn:hover { opacity: .85; }

/* Mobile */
@media (max-width: 1024px) {
  .vi-workspace { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .topbar { height: 62px; padding: 0 16px; gap: 8px; }
  .vi-page { width: calc(100% - 28px); padding-top: 20px; }
  .vi-intro { grid-template-columns: 1fr; gap: 20px; padding-bottom: 24px; }
  .vi-intro h1 { font-size: clamp(42px, 14vw, 64px); }
  .vi-foot { flex-direction: column; gap: 4px; }
}

/* ====== Tabs ====== */
.vi-tabs-row { display:flex; align-items:center; justify-content:space-between; gap:24px; margin-top:28px; border-bottom:1px solid var(--line); }
.vi-tabs { display: flex; gap: 4px; padding: 0 4px; }
.vi-usage-stats { display:flex; align-items:center; gap:12px; padding:0 12px 12px; color:var(--muted); font-size:12px; white-space:nowrap; }
.vi-usage-stats strong { color:var(--ink); font-size:18px; font-weight:600; font-variant-numeric:tabular-nums; }
.vi-usage-stats i { width:1px; height:18px; background:var(--line); }
.vi-tab {
  padding: 12px 24px; font-size: 15px; font-weight: 600; border: none; background: none;
  color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; transition: all .2s;
}
.vi-tab:hover { color: var(--ink); }
.vi-tab.active { color: var(--ink); border-bottom-color: var(--ink); }
.vi-tab-panel { display: none; }
.vi-tab-panel.active { display: block; }

/* ====== Format Feature ====== */
.vi-card-hint { font-size: 12px; color: var(--muted); font-weight: 400; }
.vi-upload-zone-sm { padding: 22px 16px; }
.vi-upload-zone-sm .upload-icon { font-size: 28px; }
.vi-upload-zone-sm strong { font-size: 14px; }
.vi-upload-zone-sm small { font-size: 11px; }

.fmt-file-list { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; max-height: 200px; overflow-y: auto; }
.fmt-file-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: rgba(255,255,255,.6);
  border: 1px solid var(--line); border-radius: 8px; font-size: 13px;
}
.fmt-file-item img { width: 36px; height: 36px; object-fit: cover; border-radius: 6px; flex-shrink: 0; }
.fmt-file-item .fmt-file-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fmt-file-item .fmt-file-dim { color: var(--muted); font-size: 11px; flex-shrink: 0; }
.fmt-file-item .fmt-file-rm { border: none; background: none; color: var(--muted); cursor: pointer; font-size: 16px; padding: 2px 6px; border-radius: 4px; }
.fmt-file-item .fmt-file-rm:hover { background: rgba(0,0,0,.08); color: var(--red); }

.fmt-tpl-preview, .fmt-qr-preview { margin-top: 12px; position: relative; }
.fmt-tpl-preview img { width: 100%; border-radius: 8px; border: 1px solid var(--line); }
.fmt-qr-preview { display: flex; align-items: center; gap: 12px; }
.fmt-qr-preview img { width: 80px; height: 80px; object-fit: contain; border: 1px solid var(--line); border-radius: 6px; }
.fmt-remove-btn { flex-shrink: 0; }
.fmt-qr-divider { display: flex; align-items: center; gap: 10px; margin: 14px 0 10px; color: var(--muted); font-size: 11px; }
.fmt-qr-divider::before, .fmt-qr-divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.fmt-qr-divider span { white-space: nowrap; }
.fmt-qr-link-row { display: flex; align-items: stretch; gap: 8px; }
.fmt-qr-link-row .fmt-text-input { min-width: 0; flex: 1; }
.fmt-qr-link-row .btn { min-width: 92px; white-space: nowrap; }
.fmt-qr-link-hint { display: block; margin-top: 7px; color: var(--muted); font-size: 10px; line-height: 1.5; }

/* Template Selector Grid */
.fmt-template-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.fmt-template-option {
  display: flex; flex-direction: column; align-items: stretch; padding: 0;
  background: #fff; border: 2px solid var(--line); border-radius: 10px;
  cursor: pointer; transition: all .2s; overflow: hidden;
}
.fmt-template-option:hover { border-color: #999; }
.fmt-template-option.active { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(108,92,231,.15); }
.fmt-template-preview { width: 100%; aspect-ratio: 9/16; background: #f5f5f0; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.fmt-template-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.fmt-template-preview-h { aspect-ratio: 16/9; }
.fmt-template-name { font-size: 12px; font-weight: 600; padding: 8px 10px; text-align: center; border-top: 1px solid var(--line); }

.fmt-text-group { margin-bottom: 14px; }
.fmt-text-group:last-child { margin-bottom: 0; }
.fmt-text-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
.fmt-text-label small { font-weight: 400; color: var(--muted); font-size: 11px; margin-left: 4px; }
.fmt-text-input {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 14px; background: rgba(255,255,255,.7); transition: border-color .2s;
}
.fmt-text-input:focus { outline: none; border-color: var(--accent); }

.fmt-process-btn { width: 100%; min-height: 48px; font-size: 15px; font-weight: 700; margin-top: 4px; }
.fmt-process-btn:disabled { opacity: .5; cursor: not-allowed; }

/* Mobile fix for format */
@media (max-width: 760px) {
  .vi-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .vi-tab { white-space: nowrap; padding: 10px 16px; }
  .vi-tabs-row { align-items:stretch; flex-direction:column; gap:10px; }
  .vi-tabs { overflow-x:auto; }
  .vi-usage-stats { justify-content:flex-end; padding:0 4px 10px; font-size:10px; }
  .vi-usage-stats strong { font-size:15px; }
  .fmt-qr-link-row { flex-direction: column; }
}

/* 加载进度浮层 */
.loading-overlay {
  position: fixed; inset: 0; z-index: 99999;
  background: var(--paper);
  display: flex; align-items: center; justify-content: center;
  transition: opacity .4s, visibility .4s;
}
.loading-overlay.hidden { opacity: 0; visibility: hidden; }
.loading-box { text-align: center; }
.loading-spinner {
  width: 48px; height: 48px; margin: 0 auto 20px;
  border: 3px solid rgba(108,92,231,.15);
  border-top-color: var(--accent);
  border-radius: 50%; animation: ld-spin .8s linear infinite;
}
@keyframes ld-spin { to { transform: rotate(360deg); } }
.loading-text { font-size: 15px; color: #666; margin-bottom: 16px; }
.loading-progress { width: 240px; height: 4px; background: rgba(0,0,0,.08); border-radius: 2px; overflow: hidden; margin: 0 auto; }
.loading-progress-bar { height: 100%; width: 0%; background: var(--accent); border-radius: 2px; transition: width .3s ease; }
.loading-pct { font-size: 13px; color: var(--muted); margin-top: 8px; font-variant-numeric: tabular-nums; }
