:root {
    --bg: #0f1216;
    --panel: #171b21;
    --line: #262c35;
    --text: #e6e9ef;
    --muted: #8b93a1;
    --accent: #4f8cff;
    --accent-dark: #3d74dc;
    --danger: #ff5d5d;
  }
  * { box-sizing: border-box; }
  /* 关键：作者样式的 display 会覆盖 hidden 属性的默认效果，必须显式兜底 */
  [hidden] { display: none !important; }
  .bar { height: 6px; background: #222833; border-radius: 999px; overflow: hidden; }
  .bar-fill { height: 100%; width: 0; background: linear-gradient(90deg, #4f8cff, #7fb0ff); transition: width .25s; }
  #uploadBarWrap { width: 180px; margin-top: 10px; }
  #jobPanel {
    border: 1px solid var(--line); border-radius: 10px; padding: 10px;
    display: flex; flex-direction: column; gap: 8px;
  }
  .job-row { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
  .job-msg { font-size: 12px; color: var(--muted); line-height: 1.5; }
  #toastBox {
    position: fixed; right: 20px; bottom: 20px; z-index: 99;
    display: flex; flex-direction: column; gap: 8px; max-width: 320px;
  }
  .toast {
    background: #1d242e; border: 1px solid var(--line); border-left: 3px solid var(--accent);
    padding: 10px 14px; border-radius: 8px; font-size: 13px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
  }
  body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
    font-size: 14px;
  }
  header {
    padding: 20px 28px 16px;
    border-bottom: 1px solid var(--line);
  }
  header h1 { margin: 0 0 4px; font-size: 19px; font-weight: 600; }
  header p { margin: 0; color: var(--muted); font-size: 13px; }
  main {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 18px;
    padding: 18px 28px 28px;
    align-items: start;
  }
  #panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: sticky;
    top: 18px;
  }
  #dropzone {
    border: 1px dashed #3a424f;
    border-radius: 10px;
    padding: 18px 12px;
    text-align: center;
    color: var(--muted);
    cursor: pointer;
    transition: .18s;
    font-size: 13px;
    line-height: 1.6;
  }
  #dropzone:hover, #dropzone.over { border-color: var(--accent); color: var(--text); background: #1b2029; }
  #dropzone strong { color: var(--text); font-weight: 600; }
  #fileInfo {
    display: none;
    font-size: 12px;
    color: var(--muted);
    background: #12161c;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px 10px;
    line-height: 1.7;
    word-break: break-all;
  }
  .group { display: flex; flex-direction: column; gap: 8px; }
  .group > label { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; }
  .group > label b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
  .seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .seg button {
    background: #12161c;
    border: 1px solid var(--line);
    color: var(--muted);
    border-radius: 8px;
    padding: 8px 4px;
    font-size: 12px;
    cursor: pointer;
    transition: .15s;
    font-family: inherit;
  }
  .seg button:hover { border-color: #3a4452; color: var(--text); }
  .seg button.active { background: #1c2c4a; border-color: var(--accent); color: #cfe0ff; }
  .hint { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.6; }
  input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: #2b323c;
    outline: none;
  }
  input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px; height: 14px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: 2px solid #0f1216;
  }
  .row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  button.ghost, button.primary, a.primary {
    font-family: inherit;
    border-radius: 9px;
    padding: 9px 12px;
    font-size: 13px;
    cursor: pointer;
    border: 1px solid var(--line);
    background: #12161c;
    color: var(--text);
    transition: .15s;
    text-align: center;
    text-decoration: none;
    display: inline-block;
  }
  button.ghost:hover { border-color: #3a4452; }
  button.primary, a.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    font-weight: 600;
  }
  button.primary:hover, a.primary:hover { background: var(--accent-dark); }
  button.primary:disabled {
    background: #253046;
    border-color: #253046;
    color: #6d7b93;
    cursor: not-allowed;
  }
  button.small, a.small { padding: 6px 12px; font-size: 12px; }
  #status { font-size: 12px; min-height: 18px; line-height: 1.5; color: var(--muted); }
  #status.err { color: var(--danger); }
  #stage {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 14px;
    min-height: 320px;
  }
  .stage-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    font-size: 12px;
    color: var(--muted);
  }
  .stage-head b { color: var(--text); font-size: 13px; font-weight: 600; }
  #canvasWrap {
    position: relative;
    min-height: 260px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #101419;
    border-radius: 10px;
    padding: 10px;
    overflow: auto;
  }
  #canvas { display: none; max-width: 100%; max-height: 74vh; cursor: crosshair; touch-action: none; }
  #placeholder { color: #5b6577; font-size: 13px; padding: 90px 0; }
  #spinner {
    position: absolute;
    inset: 0;
    background: rgba(15, 18, 22, .78);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: #cfd6e2;
    font-size: 13px;
    z-index: 5;
  }
  #spinner::before {
    content: "";
    width: 26px; height: 26px;
    border: 3px solid #2b3648;
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .8s linear infinite;
  }
  @keyframes spin { to { transform: rotate(360deg); } }
  #sourceWrap { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 14px; }
  #sourceVideo {
    display: block;
    max-width: 100%;
    max-height: 74vh;
    margin: 0 auto;
    border-radius: 8px;
    background: #000;
  }
  #resultWrap { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 14px; }
  .result-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 13px;
  }
  #resultImg, #resultVideo {
    display: block;
    max-width: 100%;
    max-height: 74vh;
    margin: 0 auto;
    border-radius: 8px;
    background: #000;
  }
  .badge {
    display: inline-block;
    font-size: 11px;
    color: #9fd0ff;
    background: #1c2c4a;
    border-radius: 999px;
    padding: 2px 8px;
    margin-left: 6px;
  }
  /* 顶部模块切换 */
  .tabs { display: flex; gap: 8px; margin-top: 14px; }
  .tabs button {
    background: #12161c;
    border: 1px solid var(--line);
    color: var(--muted);
    border-radius: 9px;
    padding: 7px 14px;
    font-size: 13px;
    cursor: pointer;
    font-family: inherit;
    transition: .15s;
  }
  .tabs button:hover { border-color: #3a4452; color: var(--text); }
  .tabs button.active { background: #1c2c4a; border-color: var(--accent); color: #cfe0ff; }
  /* 抖音/快手去水印模块 */
  #sharePanel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    position: sticky;
    top: 18px;
  }
  #shareLink {
    width: 100%;
    min-height: 120px;
    resize: vertical;
    background: #12161c;
    border: 1px solid var(--line);
    border-radius: 10px;
    color: var(--text);
    padding: 10px 12px;
    font-size: 13px;
    line-height: 1.6;
    font-family: inherit;
    outline: none;
    transition: .15s;
  }
  #shareLink:focus { border-color: var(--accent); }
  #shareStage {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 14px;
    min-height: 320px;
  }
  #shareEmpty { color: #5b6577; font-size: 13px; text-align: center; padding: 90px 0; }
  #shareLoading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: #cfd6e2;
    font-size: 13px;
    padding: 80px 0;
  }
  #shareLoading::before {
    content: "";
    width: 26px; height: 26px;
    border: 3px solid #2b3648;
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .8s linear infinite;
  }
  #shareResult { margin-top: 4px; }
  #shareMeta { font-size: 13px; color: var(--muted); }
  #shareVideo {
    display: block;
    max-width: 100%;
    max-height: 74vh;
    margin: 0 auto;
    border-radius: 8px;
    background: #000;
  }
  /* PDF 转 Word 模块 */
  #pdfPanel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    position: sticky;
    top: 18px;
  }
  #pdfDropzone {
    border: 1px dashed #3a424f;
    border-radius: 10px;
    padding: 22px 12px;
    text-align: center;
    color: var(--muted);
    cursor: pointer;
    transition: .18s;
    font-size: 13px;
    line-height: 1.7;
  }
  #pdfDropzone:hover, #pdfDropzone.over { border-color: var(--accent); color: var(--text); background: #1b2029; }
  #pdfDropzone strong { color: var(--text); font-weight: 600; }
  #pdfDropzone.disabled { opacity: .55; cursor: not-allowed; }
  #pdfFileInfo {
    display: none;
    font-size: 12px;
    color: var(--muted);
    background: #12161c;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 9px 10px;
    line-height: 1.7;
    white-space: pre-line;
    word-break: break-all;
  }
  #pdfStatus { font-size: 12px; min-height: 18px; line-height: 1.5; color: var(--muted); }
  #pdfStatus.err { color: var(--danger); }
  #pdfStage {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 14px;
    min-height: 320px;
  }
  #pdfEmpty { color: #5b6577; font-size: 13px; text-align: center; padding: 90px 0; }
  #pdfProgressWrap {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #12161c;
  }
  #pdfProgressWrap.indeterminate .bar-fill {
    width: 35% !important;
    animation: pdfSlide 1.2s ease-in-out infinite;
  }
  @keyframes pdfSlide {
    from { transform: translateX(-110%); }
    to { transform: translateX(320%); }
  }
  #pdfResult { margin-top: 4px; }
  #pdfPreview {
    margin: 12px 0 8px;
    padding: 16px;
    max-height: 54vh;
    overflow: auto;
    background: #101419;
    border: 1px solid var(--line);
    border-radius: 10px;
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    line-height: 1.8;
    white-space: pre-wrap;
    word-break: break-word;
  }
  @media (max-width: 900px) {
    main { grid-template-columns: 1fr; padding: 14px; }
    #panel, #sharePanel, #pdfPanel, #miniPanel, #appPanel { position: static; }
    header { padding: 16px 18px; }
  }

  /* ---------- 微信小程序 / App 入口 ---------- */
  #miniPanel, #appPanel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    position: sticky;
    top: 18px;
  }
  #miniStage, #appStage {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 16px;
    min-height: 320px;
  }
  .qr-box {
    width: 200px;
    max-width: 100%;
    aspect-ratio: 1 / 1;
    margin: 0 auto;
    background: #101419;
    border: 1px solid var(--line);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
  }
  .qr-box img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 8px;
    background: #fff;
  }
  .qr-empty {
    font-size: 12px;
    color: var(--muted);
    text-align: center;
    line-height: 1.6;
    padding: 0 14px;
  }
  .entry-name {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
  }
  .entry-name .badge { margin-left: 4px; }
  #appDownload, #appIos { display: block; text-align: center; }
  .feature-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
  }
  .feature-card {
    background: #12161c;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12px;
    color: var(--muted);
    line-height: 1.7;
  }
  .feature-card b { color: var(--text); font-size: 13px; }
  .steps {
    margin: 18px 0 0;
    padding-left: 20px;
    color: var(--muted);
    font-size: 13px;
    line-height: 2;
  }
  .steps li::marker { color: var(--accent); }
  .hint.err, #miniStatus.err, #appStatus.err { color: var(--danger); }

  @media (max-width: 900px) {
    .feature-grid { grid-template-columns: 1fr; }
  }

  /* ---------- 手机端 ---------- */
  @media (max-width: 600px) {
    header { padding: 14px 14px 10px; }
    header h1 { font-size: 17px; }
    header p { font-size: 12px; }
    .tabs {
      overflow-x: auto;
      white-space: nowrap;
      padding-bottom: 4px;
      -webkit-overflow-scrolling: touch;
      scrollbar-width: none;
    }
    .tabs::-webkit-scrollbar { display: none; }
    .tabs button { flex: 0 0 auto; padding: 8px 12px; }
    main { gap: 12px; padding: 12px 14px 20px; }
    #canvasWrap { padding: 6px; }
    #canvas { max-height: 60vh; }
    #sourceVideo, #resultImg, #resultVideo, #shareVideo { max-height: 60vh; }
    button.ghost, button.primary, a.primary, .seg button {
      min-height: 40px;
      padding: 10px 12px;
    }
    .stage-head { font-size: 11px; flex-wrap: wrap; }
    .row { grid-template-columns: 1fr; }
  }
