  @font-face {
    font-family: 'ZhuoteQingya';
    src: url('../assets/zhuote-qingya.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
  }
  /* Design System: Vibrant & Block-based / Newsletter pattern */
  :root {
    --color-primary: #E11D48;
    --color-on-primary: #FFFFFF;
    --color-secondary: #FB7185;
    --color-accent: #2563EB;
    --color-background: #AD1C42;
    --color-surface: #FFFFFF;
    --color-foreground: #0F172A;
    --color-muted: #F1F5F9;
    --color-border: #E2E8F0;
    --color-text-secondary: #64748B;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.10);
    --transition: 150ms ease;
  }

  * { box-sizing: border-box; margin: 0; padding: 0; }

  body {
    font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', 'Inter', sans-serif;
    background: var(--color-background);
    min-height: 100vh;
    padding: 10px 18px 18px;
    color: var(--color-background);
    line-height: 1.5;
  }

  .container {
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: minmax(380px, 460px) minmax(0, 1fr);
    gap: 24px;
    align-items: start;
  }

  .editor-panel,
  .preview-panel {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--color-border);
  }

  .preview-panel {
    position: sticky;
    top: 18px;
    display: flex;
    flex-direction: column;
  }

  h1.site-title {
    width: 100%;
    max-width: 1180px;
    margin-left: auto;
    margin-right: auto;
    text-align: left;
    font-size: 18px;
    line-height: 1.1;
    font-weight: 600;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 28px;
    margin-bottom: 12px;
    flex: 0 0 auto;
  }

  .input-group {
    margin-bottom: 20px;
  }

  .field-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 4px;
  }

  .field-row .field-label {
    margin-bottom: 0;
  }

  .utility-btn {
    appearance: none;
    -webkit-appearance: none;
    border: 1px solid rgba(173, 28, 66, 0.18);
    border-radius: 999px;
    padding: 6px 11px;
    background: #FFF1F5;
    color: var(--color-background);
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    line-height: 1;
    white-space: nowrap;
    transition: background var(--transition), border-color var(--transition), transform var(--transition);
  }

  .utility-btn:hover {
    background: #FFE4EC;
    border-color: rgba(173, 28, 66, 0.32);
    transform: translateY(-1px);
  }

  .input-help {
    margin-top: 7px;
    font-size: 12px;
    color: #94A3B8;
  }

  label.field-label,
  label.checkbox-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-background);
    text-transform: uppercase;
    margin-bottom: 4px;
    letter-spacing: 0.2px;
  }
  label.checkbox-label {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0 8px;
  }
  .checkbox-label .checkbox-text {
    line-height: 16px;
  }
  label .desc {
    display: block;
    font-size: 12px;
    font-weight: 400;
    color: #aaa;
    text-transform: none;
    margin-bottom: 8px;
    letter-spacing: 0;
  }
  .checkbox-label .desc {
    flex-basis: 100%;
    margin-left: 24px;
  }
  .checkbox-label input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 16px;
    height: 16px;
  }
  .checkbox-label .checkmark {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 1.5px solid var(--color-border);
    border-radius: 3px;
    background: var(--color-surface);
    flex-shrink: 0;
    position: relative;
    transition: background var(--transition), border-color var(--transition);
  }
  .checkbox-label input[type="checkbox"]:checked + .checkmark {
    background: var(--color-background);
    border-color: var(--color-background);
  }
  .checkbox-label input[type="checkbox"]:checked + .checkmark::after {
    content: '';
    position: absolute;
    left: 3px;
    top: 1px;
    width: 5px;
    height: 8px;
    border: 1.5px solid #fff;
    border-top: none;
    border-left: none;
    transform: rotate(45deg);
  }
  input:disabled, textarea:disabled {
    opacity: 0.4;
    cursor: not-allowed;
  }
  .input-group input[type="text"]:disabled {
    background: var(--color-muted);
  }

  input[type="text"], textarea {
    width: 100%;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    font-size: 15px;
    font-family: inherit;
    color: #1a1a1a;
    background: var(--color-surface);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
    resize: none;
  }

  input[type="text"]:focus, textarea:focus {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
  }
  input::placeholder,
  textarea::placeholder {
    color: #A8B0BC;
  }

  #titleInput {
    min-height: 90px;
    height: auto;
  }

  #contentInput {
    min-height: 380px;
    height: auto;
  }

  .style-section {
    margin-bottom: 24px;
  }

  .style-section-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-secondary);
    margin-bottom: 10px;
  }

  .style-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin-top: 12px;
    align-items: stretch;
  }

  .style-btn {
    appearance: none;
    -webkit-appearance: none;
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    padding: 7px;
    min-height: 82px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    font-family: inherit;
    line-height: 1.15;
    text-align: center;
    transition: all var(--transition);
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: stretch;
    justify-content: space-between;
    position: relative;
    z-index: 1;
  }
  .style-btn > span:last-child {
    min-height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    word-break: break-word;
    overflow-wrap: anywhere;
  }
  .style-btn:hover { transform: translateY(-1px); }
  .style-swatch {
    display: block;
    height: 30px;
    border-radius: 5px;
    border: 1px solid rgba(0,0,0,0.08);
    position: relative;
    overflow: hidden;
  }
  .style-swatch::after {
    content: 'Aa';
    position: absolute;
    left: 8px;
    top: 5px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0;
  }
  .style-btn[data-style="fresh"]   { background: #E8F5F3; color: #1A6B65; }
  .style-btn[data-style="warm"]     { background: #FDF6EC; color: #8B5A2B; }
  .style-btn[data-style="noir"]     { background: #1C1C1E; color: #F5F5F7; }
  .style-btn[data-style="cyber"]    { background: #0A0A0F; color: #00F5FF; }
  .style-btn[data-style="ink"]      { background: #F2EDE4; color: #2C2C2C; }
  .style-btn[data-style="forest"]   { background: #1A2F1A; color: #C8E6C9; }
  .style-btn[data-style="sunset"]   { background: #2D1B0E; color: #FFCC80; }
  .style-btn[data-style="nordic"]   { background: #F0F4F8; color: #37474F; }
  .style-btn[data-style="rose"]     { background: #FFF1F5; color: #BE123C; }
  .style-btn[data-style="ocean"]    { background: #E0F2FE; color: #075985; }
  .style-btn[data-style="lavender"] { background: #F3E8FF; color: #6D28D9; }
  .style-btn[data-style="matrix"]   { background: #03120A; color: #6EE7B7; }
  .style-btn[data-style="fresh"].active   { box-shadow: 0 0 0 2.5px #1A6B65; }
  .style-btn[data-style="warm"].active    { box-shadow: 0 0 0 2.5px #8B5A2B; }
  .style-btn[data-style="noir"].active     { box-shadow: 0 0 0 2.5px #555; }
  .style-btn[data-style="cyber"].active    { box-shadow: 0 0 0 2.5px #00F5FF; }
  .style-btn[data-style="ink"].active      { box-shadow: 0 0 0 2.5px #2C2C2C; }
  .style-btn[data-style="forest"].active   { box-shadow: 0 0 0 2.5px #4CAF50; }
  .style-btn[data-style="sunset"].active   { box-shadow: 0 0 0 2.5px #FF9800; }
  .style-btn[data-style="nordic"].active   { box-shadow: 0 0 0 2.5px #607D8B; }
  .style-btn[data-style="rose"].active      { box-shadow: 0 0 0 2.5px #BE123C; }
  .style-btn[data-style="ocean"].active     { box-shadow: 0 0 0 2.5px #0284C7; }
  .style-btn[data-style="lavender"].active  { box-shadow: 0 0 0 2.5px #8B5CF6; }
  .style-btn[data-style="matrix"].active    { box-shadow: 0 0 0 2.5px #10B981; }
  .style-btn[data-style="fresh"] .style-swatch {
    background: radial-gradient(circle, rgba(26,107,101,0.22) 1.5px, transparent 2px) 0 0/9px 9px, #E8F5F3;
  }
  .style-btn[data-style="warm"] .style-swatch {
    background: repeating-radial-gradient(circle at 90% 100%, transparent 0 9px, rgba(139,90,43,0.18) 10px 11px), #FDF6EC;
  }
  .style-btn[data-style="noir"] .style-swatch {
    background: linear-gradient(rgba(255,255,255,0.08) 1px, transparent 1px) 0 0/12px 12px, linear-gradient(90deg, rgba(255,255,255,0.08) 1px, transparent 1px) 0 0/12px 12px, #1C1C1E;
  }
  .style-btn[data-style="cyber"] .style-swatch {
    background: repeating-linear-gradient(45deg, rgba(0,245,255,0.18) 0 1px, transparent 1px 10px), #0A0A0F;
  }
  .style-btn[data-style="ink"] .style-swatch {
    background: repeating-linear-gradient(84deg, rgba(44,44,44,0.14) 0 1px, transparent 1px 8px), #F2EDE4;
  }
  .style-btn[data-style="forest"] .style-swatch {
    background: repeating-linear-gradient(28deg, rgba(200,230,201,0.14) 0 1px, transparent 1px 13px), #1A2F1A;
  }
  .style-btn[data-style="sunset"] .style-swatch {
    background: repeating-conic-gradient(from 210deg at 50% 100%, rgba(255,160,50,0.18) 0 8deg, transparent 8deg 16deg), #2D1B0E;
  }
  .style-btn[data-style="nordic"] .style-swatch {
    background: repeating-radial-gradient(circle at 15% 20%, transparent 0 8px, rgba(55,71,79,0.14) 9px 10px), #F0F4F8;
  }
  .style-btn[data-style="rose"] .style-swatch {
    background: radial-gradient(circle, rgba(190,18,60,0.18) 1.5px, transparent 2px) 0 0/9px 9px, #FFF1F5;
  }
  .style-btn[data-style="ocean"] .style-swatch {
    background: repeating-radial-gradient(circle at 90% 100%, transparent 0 9px, rgba(7,89,133,0.16) 10px 11px), #E0F2FE;
  }
  .style-btn[data-style="lavender"] .style-swatch {
    background: repeating-radial-gradient(circle at 15% 20%, transparent 0 8px, rgba(109,40,217,0.15) 9px 10px), #F3E8FF;
  }
  .style-btn[data-style="matrix"] .style-swatch {
    background: linear-gradient(rgba(110,231,183,0.12) 1px, transparent 1px) 0 0/10px 10px, linear-gradient(90deg, rgba(110,231,183,0.12) 1px, transparent 1px) 0 0/10px 10px, #03120A;
  }
  .style-btn[data-style="fresh"] .style-swatch::after { color: #1A6B65; }
  .style-btn[data-style="warm"] .style-swatch::after { color: #8B5A2B; }
  .style-btn[data-style="noir"] .style-swatch::after { color: #F5F5F7; }
  .style-btn[data-style="cyber"] .style-swatch::after { color: #00F5FF; text-shadow: 0 0 8px #00F5FF; }
  .style-btn[data-style="ink"] .style-swatch::after { color: #2C2C2C; }
  .style-btn[data-style="forest"] .style-swatch::after { color: #C8E6C9; }
  .style-btn[data-style="sunset"] .style-swatch::after { color: #FFCC80; }
  .style-btn[data-style="nordic"] .style-swatch::after { color: #37474F; }
  .style-btn[data-style="rose"] .style-swatch::after { color: #BE123C; }
  .style-btn[data-style="ocean"] .style-swatch::after { color: #075985; }
  .style-btn[data-style="lavender"] .style-swatch::after { color: #6D28D9; }
  .style-btn[data-style="matrix"] .style-swatch::after { color: #6EE7B7; text-shadow: 0 0 8px rgba(110,231,183,0.7); }

  .generate-btn {
    width: 100%;
    padding: 14px;
    background: var(--color-foreground);
    color: var(--color-on-primary);
    border: none;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    text-transform: uppercase;
    cursor: pointer;
    transition: opacity var(--transition), transform var(--transition);
    margin-bottom: 28px;
  }
  .generate-btn:hover { opacity: 0.88; }
  .generate-btn:active { opacity: 0.75; }
  .generate-btn:disabled,
  .download-all-btn:disabled {
    opacity: 0.6;
    cursor: wait;
  }
  .status-message {
    display: none;
    margin-top: -14px;
    margin-bottom: 22px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    line-height: 1.4;
  }
  .status-message.show { display: block; }
  .status-message.info {
    background: #EFF6FF;
    color: #1D4ED8;
    border: 1px solid #BFDBFE;
  }
  .status-message.success {
    background: #ECFDF5;
    color: #047857;
    border: 1px solid #A7F3D0;
  }
  .status-message.error {
    background: #FFF1F2;
    color: #BE123C;
    border: 1px solid #FECDD3;
  }

  .preview-area {
    display: flex;
    flex-direction: column;
  }
  .preview-area h2 {
    font-size: 13px;
    font-weight: 500;
    color: var(--color-background);
    text-transform: uppercase;
    letter-spacing: 0.2px;
    margin-bottom: 12px;
  }
  .preview-empty {
    min-height: 360px;
    border: 1.5px dashed var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-muted);
    color: var(--color-text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 24px;
    font-size: 14px;
    margin-bottom: 20px;
  }
  .preview-area.show .preview-empty {
    display: none;
  }
  .preview-grid {
    display: none;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    align-items: start;
    margin-bottom: 20px;
  }
  .preview-area.show .preview-grid {
    display: grid;
  }
  .preview-item {
    position: relative;
    cursor: pointer;
    border-radius: var(--radius-sm);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition), box-shadow var(--transition);
    width: 100%;
  }
  .preview-item:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
  .preview-item canvas {
    display: block;
    width: 100%;
    height: auto;
    image-rendering: auto;
  }
  .preview-item .page-num {
    position: absolute;
    bottom: 6px;
    right: 6px;
    font-size: 11px;
    font-weight: 500;
    color: rgba(255,255,255,0.9);
    background: rgba(0,0,0,0.35);
    padding: 2px 8px;
    border-radius: 4px;
    letter-spacing: 0.3px;
  }
  .preview-download {
    position: absolute;
    left: 6px;
    bottom: 6px;
    border: none;
    background: rgba(15,23,42,0.72);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    font-family: inherit;
    padding: 3px 8px;
    border-radius: 4px;
    cursor: pointer;
  }
  .preview-download:hover {
    background: rgba(15,23,42,0.9);
  }
  .preview-tip {
    display: none;
    text-align: center;
    font-size: 12px;
    color: var(--color-text-secondary);
    margin-bottom: 16px;
  }
  .preview-area.show .preview-tip {
    display: block;
  }

  .download-all-btn {
    display: none;
    width: 100%;
    padding: 13px;
    background: var(--color-primary);
    color: #fff;
    border: 1.5px solid var(--color-primary);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    text-transform: uppercase;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition), transform var(--transition);
  }
  .preview-area.show .download-all-btn {
    display: block;
  }
  .download-all-btn:hover { background: var(--color-secondary); border-color: var(--color-secondary); }
  .download-all-btn:active { opacity: 0.75; }

  .preview-tip {
    text-align: center;
    font-size: 12px;
    color: var(--color-text-secondary);
    margin-bottom: 16px;
  }

  /* ---- Image modal ---- */
  .img-modal {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.92);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    touch-action: none;
  }
  .img-modal.show { display: flex; }
  .modal-img {
    max-width: 92vw;
    max-height: 78vh;
    border-radius: 8px;
    box-shadow: 0 4px 32px rgba(0,0,0,0.5);
    user-select: none;
    -webkit-user-drag: none;
    touch-action: pan-y;
  }
  .modal-close {
    position: absolute;
    top: 16px; right: 16px;
    cursor: pointer;
    width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(255,255,255,0.1);
    border-radius: 50%;
    border: none;
    padding: 0;
  }
  .modal-close svg { width: 20px; height: 20px; stroke: #fff; stroke-width: 2; opacity: 0.8; }
  .modal-close:hover svg { opacity: 1; }
  .modal-download {
    margin-top: 14px;
    background: rgba(255,255,255,0.15);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 24px;
    padding: 10px 28px;
    font-size: 15px;
    cursor: pointer;
    transition: background 0.2s;
    font-family: inherit;
  }
  .modal-download:hover { background: rgba(255,255,255,0.25); }
  .modal-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,0.15);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    width: 52px; height: 52px;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    user-select: none;
    touch-action: manipulation;
  }
  .modal-nav svg {
    width: 28px;
    height: 28px;
    stroke: currentColor;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
  .style-btn:focus-visible,
  .generate-btn:focus-visible,
  .download-all-btn:focus-visible,
  .preview-download:focus-visible,
  .modal-close:focus-visible,
  .modal-download:focus-visible,
  .modal-nav:focus-visible,
  input:focus-visible + .checkmark {
    outline: 3px solid rgba(37, 99, 235, 0.35);
    outline-offset: 2px;
  }
  .modal-nav:hover { background: rgba(255,255,255,0.25); }
  .modal-nav:active { background: rgba(255,255,255,0.35); }
  .modal-nav.prev { left: 12px; }
  .modal-nav.next { right: 12px; }
  .modal-counter {
    color: rgba(255,255,255,0.6);
    font-size: 14px;
    margin-top: 12px;
    letter-spacing: 0.5px;
  }

  @media (max-width: 820px) {
    body {
      min-height: 100vh;
      padding: 0 12px 20px;
    }
    .container {
      display: block;
      max-width: 560px;
      min-height: auto;
    }
    .editor-panel,
    .preview-panel {
      border-radius: var(--radius-lg);
      box-shadow: var(--shadow-md);
      border: 1px solid var(--color-border);
      padding: 16px;
    }
    .editor-panel { margin-bottom: 12px; }
    .preview-panel {
      position: static;
      min-height: 0;
    }
    .style-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    h1.site-title {
      max-width: 560px;
      font-size: 16px;
      margin-top: 32px;
    }
    .preview-empty { min-height: 220px; }
    .preview-grid {
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 8px;
    }
    .modal-nav { width: 56px; height: 56px; font-size: 26px; }
    .modal-nav.prev { left: 8px; }
    .modal-nav.next { right: 8px; }
    .modal-img { max-width: 96vw; max-height: 72vh; }
    .modal-download { padding: 10px 20px; font-size: 14px; }
  }
