<style>
  html, body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
  }

  body {
    font-family: -apple-system, sans-serif;
    padding: 20px;
    max-width: 1000px;
    margin: 0 auto;
    position: relative;
    background: #f8fafc;
    overflow-x: hidden;
  }

  /* ==========================================================
     ✅ 简约动态背景
     ========================================================== */
  .bg-layer {
    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
    background: linear-gradient(135deg, #f8fafc 0%, #eef4fb 50%, #f5f7ff 100%);
  }

  .bg-blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.55;
    will-change: transform;
  }

  .bg-blob.b1 {
    width: 480px; height: 480px; top: -120px; left: -100px;
    background: radial-gradient(circle at 30% 30%, #eaf1fa 0%, #a8d0f5 60%, transparent 100%);
    animation: float1 24s ease-in-out infinite;
  }
  .bg-blob.b2 {
    width: 420px; height: 420px; top: 30%; right: -120px;
    background: radial-gradient(circle at 60% 40%, #b8a8f0 0%, #d0c8f5 60%, transparent 100%);
    animation: float2 30s ease-in-out infinite;
  }
  .bg-blob.b3 {
    width: 380px; height: 380px; bottom: -100px; left: 30%;
    background: radial-gradient(circle at 40% 60%, #a8e0e0 0%, #c8f0f0 60%, transparent 100%);
    animation: float3 26s ease-in-out infinite;
  }
  .bg-blob.b4 {
    width: 300px; height: 300px; top: 60%; left: -80px;
    background: radial-gradient(circle at 50% 50%, #f0c8d8 0%, #f5e0e8 60%, transparent 100%);
    animation: float4 32s ease-in-out infinite;
  }

  @keyframes float1 {
    0%, 100%   { transform: translate(0, 0) scale(1); }
    33%        { transform: translate(60px, 40px) scale(1.08); }
    66%        { transform: translate(-30px, 80px) scale(0.95); }
  }
  @keyframes float2 {
    0%, 100%   { transform: translate(0, 0) scale(1); }
    50%        { transform: translate(-80px, 60px) scale(1.1); }
  }
  @keyframes float3 {
    0%, 100%   { transform: translate(0, 0) scale(1); }
    33%        { transform: translate(-60px, -50px) scale(1.05); }
    66%        { transform: translate(40px, -30px) scale(0.96); }
  }
  @keyframes float4 {
    0%, 100%   { transform: translate(0, 0) scale(1); }
    50%        { transform: translate(70px, -60px) scale(1.12); }
  }

  /* ==========================================================
     ✅ 附加线面动效
     ========================================================== */
  .bg-line {
    position: absolute;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(74, 144, 226, 0.35), transparent);
    will-change: transform;
  }
  .bg-line.l1 { width: 60%; top: 20%; left: -20%; animation: lineMove1 28s linear infinite; }
  .bg-line.l2 {
    width: 50%; top: 55%; right: -20%;
    background: linear-gradient(90deg, transparent, rgba(184, 168, 240, 0.32), transparent);
    animation: lineMove2 34s linear infinite;
  }
  .bg-line.l3 {
    width: 40%; top: 75%; left: -15%;
    background: linear-gradient(90deg, transparent, rgba(168, 224, 224, 0.32), transparent);
    animation: lineMove3 40s linear infinite;
  }

  @keyframes lineMove1 {
    0%   { transform: translateX(-100%) translateY(0); }
    100% { transform: translateX(200%) translateY(20px); }
  }
  @keyframes lineMove2 {
    0%   { transform: translateX(100%) translateY(0); }
    100% { transform: translateX(-200%) translateY(-20px); }
  }
  @keyframes lineMove3 {
    0%   { transform: translateX(-100%) translateY(0); }
    100% { transform: translateX(200%) translateY(-15px); }
  }

  .bg-ring {
    position: absolute;
    border-radius: 50%;
    border: 1px solid rgba(74, 144, 226, 0.15);
    will-change: transform, opacity;
  }
  .bg-ring.r1 {
    width: 180px; height: 180px; top: 12%; right: 8%;
    border-color: rgba(74, 144, 226, 0.18);
    animation: ringPulse1 22s ease-in-out infinite;
  }
  .bg-ring.r2 {
    width: 260px; height: 260px; bottom: 15%; left: 5%;
    border-color: rgba(184, 168, 240, 0.15);
    animation: ringPulse2 28s ease-in-out infinite;
  }
  .bg-ring.r3 {
    width: 120px; height: 120px; top: 55%; right: 25%;
    border-color: rgba(168, 224, 224, 0.2);
    animation: ringPulse1 26s ease-in-out infinite reverse;
  }

  @keyframes ringPulse1 {
    0%, 100% { transform: scale(1) rotate(0deg); opacity: 0.6; }
    50%      { transform: scale(1.15) rotate(180deg); opacity: 1; }
  }
  @keyframes ringPulse2 {
    0%, 100% { transform: scale(1) rotate(0deg); opacity: 0.5; }
    50%      { transform: scale(0.88) rotate(-180deg); opacity: 1; }
  }

  .bg-dot {
    position: absolute;
    border-radius: 50%;
    background: rgba(74, 144, 226, 0.4);
    will-change: transform, opacity;
  }
  .bg-dot.d1 { width: 6px; height: 6px; top: 30%; left: 15%; animation: dotFloat1 16s ease-in-out infinite; }
  .bg-dot.d2 {
    width: 4px; height: 4px; top: 65%; right: 20%;
    background: rgba(184, 168, 240, 0.5);
    animation: dotFloat2 20s ease-in-out infinite;
  }
  .bg-dot.d3 {
    width: 5px; height: 5px; bottom: 25%; left: 45%;
    background: rgba(168, 224, 224, 0.5);
    animation: dotFloat3 18s ease-in-out infinite;
  }
  .bg-dot.d4 {
    width: 3px; height: 3px; top: 45%; right: 40%;
    background: rgba(240, 200, 216, 0.6);
    animation: dotFloat1 22s ease-in-out infinite reverse;
  }

  @keyframes dotFloat1 {
    0%, 100% { transform: translate(0, 0); opacity: 0.5; }
    50%      { transform: translate(20px, -30px); opacity: 1; }
  }
  @keyframes dotFloat2 {
    0%, 100% { transform: translate(0, 0); opacity: 0.5; }
    50%      { transform: translate(-25px, 20px); opacity: 1; }
  }
  @keyframes dotFloat3 {
    0%, 100% { transform: translate(0, 0); opacity: 0.5; }
    50%      { transform: translate(15px, 25px); opacity: 1; }
  }

  .bg-diagonal {
    position: absolute;
    inset: 0;
    background-image:
      repeating-linear-gradient(
        45deg,
        rgba(74, 144, 226, 0.025) 0px,
        rgba(74, 144, 226, 0.025) 1px,
        transparent 1px,
        transparent 24px
      );
    animation: diagonalShift 90s linear infinite;
    will-change: background-position;
  }

  @keyframes diagonalShift {
    0%   { background-position: 0 0; }
    100% { background-position: 200px 200px; }
  }

  @media (max-width: 600px) {
    .bg-line.l2,
    .bg-ring.r3,
    .bg-dot.d4 {
      display: none;
    }
  }

  .box,
  .mode-switch,
  .mode-desc,
  .zipname-row,
  #processBtn,
  #progressWrap,
  #logWrap {
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }

  .box,
  #logWrap { background: rgba(255, 255, 255, 0.85); }
  .mode-desc { background: rgba(250, 251, 252, 0.85); }
  .sort-row,
  .compress-row { background: rgba(248, 251, 253, 0.85); }

  h2 {
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    margin-bottom: 15px;
  }

  .box { border: 2px dashed #ccc; border-radius: 8px; padding: 20px; text-align: center; margin-bottom: 15px; }
  .box.dragover { border-color: #4a90e2; background: #f0f7ff; }
  input[type="file"] { display: none; }
  select, button { padding: 8px 16px; border-radius: 6px; border: 1px solid #ccc; font-size: 14px; }
  button { background: #4a90e2; color: #fff; border: none; cursor: pointer; margin-top: 30px; }
  button:disabled { background: #ccc; cursor: not-allowed; }
  button.danger { background: #9d5353; }
  button.small { padding: 15px 20px; font-size: 14px; margin-top: 0; }
  button.ghost { background: transparent; color: #4a90e2; border: 1px solid #4a90e2; }
  button.success { background: #93b4a1; }
  .row { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }

  #progressWrap { display: none; margin-top: 15px; }
  #progressWrap.visible { display: block; }
  #progressLabel { display: flex; justify-content: space-between; font-size: 12px; color: #666; margin-bottom: 6px; }
  #progressLabel .filename { color: #4a90e2; max-width: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #progressBar { height: 8px; background: #eef2f7; border-radius: 4px; overflow: hidden; }
  #progressFill { height: 100%; width: 0%; background: linear-gradient(90deg, #4a90e2, #6db3f2); border-radius: 4px; transition: width 0.2s ease-out; }

  #logWrap { margin-top: 15px; background: #fafbfc; border-radius: 6px; padding: 12px; display: none; }
  #logWrap.visible { display: block; }
  #log { font-size: 13px; color: #666; white-space: pre-wrap; line-height: 1.6; max-height: 80px; overflow: hidden; transition: max-height 0.3s; word-break: break-all; }
  #log.expanded { max-height: 600px; overflow-y: auto; }
  #logToggle { display: none; margin-top: 8px; background: transparent; color: #4a90e2; border: none; padding: 0; font-size: 12px; cursor: pointer; text-decoration: underline; }
  #logToggle.visible { display: inline-block; }

  .hint { font-size: 12px; color: #999; margin-top: 5px; }

  table.excel-preview {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    font-size: 12px;
    table-layout: auto;
  }
  table.excel-preview th,
  table.excel-preview td {
    border: 1px solid #eee;
    padding: 4px 8px;
    text-align: left;
    white-space: nowrap;
    vertical-align: top;
  }
  table.excel-preview th { background: #f5f7fa; font-weight: 600; color: #555; }
  table.excel-preview th:first-child,
  table.excel-preview td:first-child {
    width: 32px; min-width: 32px; max-width: 32px;
    text-align: center; color: #999; font-size: 11px;
  }
  table.excel-preview th:nth-child(2),
  table.excel-preview td:nth-child(2) { min-width: 70px; }
  table.excel-preview td { word-break: break-all; }
  table.excel-preview tbody tr:nth-child(even) { background: #fcfdfe; }

  .size-row { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
  .size-item { display: flex; align-items: center; gap: 6px; font-size: 13px; }
  .size-item input[type="number"] { width: 60px; padding: 4px 8px; border: 1px solid #ccc; border-radius: 4px; text-align: center; font-size: 13px; }
  .size-item input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }

  .manage-row { display: flex; align-items: center; gap: 10px; margin-top: 20px; flex-wrap: wrap; margin-bottom: 20px;}

  .mode-switch { display: flex; background: #f0f2f5; border-radius: 8px; padding: 4px; margin-bottom: 15px; }
  .mode-switch button { flex: 1; background: transparent; color: #666; border: none; margin: 0; padding: 10px 16px; border-radius: 6px; font-size: 14px; cursor: pointer; transition: all 0.2s; margin-top: 0; }
  .mode-switch button.active { background: #fff; color: #4a90e2; font-weight: 600; box-shadow: 0 2px 6px rgba(0,0,0,0.08); }

  .mode-desc { font-size: 12px; color: #888; background: #fafbfc; padding: 10px 12px; border-radius: 6px; margin-bottom: 12px; line-height: 1.6; white-space: pre-wrap; }

  .sort-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; font-size: 13px; color: #444; background: #f8fbfd; padding: 8px 12px; border-radius: 6px; }
  .sort-row input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }
  .sort-row label { cursor: pointer; }

  .zipname-row { display: flex; align-items: center; gap: 10px; margin-top: 12px; font-size: 16px; color: #444; }
  .zipname-row label { white-space: nowrap; }
  .zipname-row input { flex: 1; padding: 6px 10px; border: 1px solid #ccc; border-radius: 6px; font-size: 13px; min-width: 100px; }
  .zipname-row input:focus { outline: none; border-color: #4a90e2; box-shadow: 0 0 0 2px rgba(74,144,226,0.15); }

  .compress-row { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; font-size: 13px; color: #444; background: #f8fbfd; padding: 10px 12px; border-radius: 6px; }
  .compress-row .line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
  .compress-row input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }
  .compress-row input[type="number"] { width: 70px; padding: 4px 8px; font-size: 13px; border: 1px solid #ccc; border-radius: 4px; text-align: center; }

  .modal-mask { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.5); z-index: 999; align-items: center; justify-content: center; padding: 20px; }
  .modal-mask.visible { display: flex; }
  .modal { background: #fff; border-radius: 10px; padding: 20px; max-width: 600px; width: 100%; max-height: 85vh; display: flex; flex-direction: column; box-shadow: 0 10px 40px rgba(0,0,0,0.2); }
  .modal h3 { margin-bottom: 10px; font-size: 16px; color: #333; }
  .modal .tip { font-size: 12px; color: #666; line-height: 1.6; margin-bottom: 12px; background: #f8fbfd; padding: 10px; border-radius: 6px; }
  .modal .tip code { background: #e8f4ff; color: #4a90e2; padding: 1px 5px; border-radius: 3px; font-size: 12px; }
  .modal textarea { flex: 1; width: 100%; min-height: 300px; padding: 12px; font-family: 'SF Mono', Monaco, Consolas, monospace; font-size: 12px; line-height: 1.5; border: 1px solid #ddd; border-radius: 6px; resize: vertical; box-sizing: border-box; background: #fafbfc; color: #333; }
  .modal-actions { display: flex; gap: 10px; margin-top: 12px; justify-content: flex-end; }
  .modal-actions button { margin-top: 0; }

  /* ==========================================================
     ✅ 模板卡片网格
     ========================================================== */
  .template-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-top: 12px;
  }

  @media (max-width: 800px) {
    .template-grid { grid-template-columns: repeat(3, 1fr); }
  }
  @media (max-width: 600px) {
    .template-grid { grid-template-columns: repeat(2, 1fr); }
  }

  .template-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 14px 8px;
    border: 2px solid #eef2f7;
    border-radius: 10px;
    background: #fafbfc;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    min-height: 100px;
    position: relative;
    user-select: none;
  }
  .template-card:hover { border-color: #c8d8e8; background: #f5f9ff; }
  .template-card.active {
    border-color: #4a90e2;
    background: #eaf3ff;
    box-shadow: 0 2px 8px rgba(74,144,226,0.15);
  }
  .template-card .card-icon {
    width: 32px; height: 32px;
    margin-bottom: 8px;
    display: flex; align-items: center; justify-content: center;
    color: #4a90e2;
  }
  .template-card .card-icon svg { width: 100%; height: 100%; display: block; }
  .template-card.user-card .card-icon { color: #e69500; }
  .template-card.add-card .card-icon { color: #cedad3; }
  .template-card .card-name {
    font-size: 13px; font-weight: 600; color: #333;
    margin-bottom: 4px;
    word-break: break-all;
    line-height: 1.3;
    max-width: 100%;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
  .template-card .card-tag {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    color: #333;
    white-space: nowrap;
    font-weight: bold;
  }
  .template-card .card-tag.cycle { background: #e3d3b9; }
  .template-card .card-tag.map { background: #cedad3; }

  .template-card.add-card {
    border-style: dashed;
    border-color: #b8c9dc;
    background: transparent;
  }
  .template-card.add-card:hover { border-color: #cedad3; background: #f2fbf6; }
  .template-card.add-card .card-name { color: #cedad3; font-size: 13px; }
  
      /* ✅ 命名表预览搜索框 */
    .preview-search-row {
      margin-top: 10px;
      display: flex;
      align-items: center;
      gap: 10px;
      flex-wrap: nowrap;
    }
    .preview-search-row input {
      flex: 1 1 auto;
      min-width: 0;
      height: 34px;
      padding: 0 10px;
      border: 1px solid #ccc;
      border-radius: 6px;
      font-size: 13px;
      box-sizing: border-box;
      transition: border-color 0.2s;
      margin: 0;
    }
    .preview-search-row input:focus {
      border-color: #4a90e2;
      outline: none;
    }
    .preview-search-row .search-clear {
      flex: 0 0 auto;
      height: 34px;
      padding: 0 14px;
      background: #f0f0f0;
      border: 1px solid #ccc;
      border-radius: 6px;
      font-size: 12px;
      cursor: pointer;
      white-space: nowrap;
      transition: background 0.2s;
      /* ✅ 关键：清除全局 button 的 margin-top，并让文字垂直居中 */
      margin: 0;
      line-height: 1;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      box-sizing: border-box;
      color: #333;
    }
    .preview-search-row .search-clear:hover {
      background: #e0e0e0;
    }
    .preview-search-row .search-count {
      flex: 0 0 auto;
      font-size: 12px;
      color: #888;
      white-space: nowrap;
      line-height: 34px;
    }
	.icon-svg-img {
	    width: 100%;
	    height: 100%;
	    display: block;
	    object-fit: contain;
	}
		/* ==========================================================
     ✅ 卡片配色方案（每个模板根据名字自动分配颜色）
     ========================================================== */
			.template-card {
				--card-accent: #7cb8f0;
				--card-border: #d8e8f8;
				--card-bg-hover: #eaf4ff;
				--card-bg-active: #deedff;
				--card-tag-bg: #dbeafe;
				--card-tag-color: #3b6ea5;
			}

			.template-card .card-icon {
				color: var(--card-accent);
			}

			.template-card:hover {
				border-color: var(--card-border);
				background: var(--card-bg-hover);
			}

			.template-card.active {
				border-color: var(--card-accent);
				background: var(--card-bg-active);
				box-shadow: 0 2px 8px rgba(124, 184, 240, 0.25);
			}

			.template-card .card-tag {
				background: var(--card-tag-bg);
				color: var(--card-tag-color);
			}

			/* 用户模板卡片：右上角小橙点标记 */
			.template-card.user-card::after {
				content: '';
				position: absolute;
				top: 6px;
				right: 6px;
				width: 6px;
				height: 6px;
				border-radius: 50%;
				background: #e69500;
				opacity: 0.7;
			}

			/* ✅ 自定义彩色 SVG 图标（保留原色，不跟随 currentColor） */
			.card-icon.custom-color svg {
				color: inherit;
				width: 100%;
				height: 100%;
			}
</style>