  :root {
    --ink: #1c2019;
    --paper: #faf8f2;
    --red-deep: #6d1626;
    --red-mid: #93273f;
    --red-tint: #f7e9ea;
    --gold: #b8912f;
    --gold-soft: #e9dbb0;
    --line: #e3d5d7;
    --radius: 4px;
  }

  * { box-sizing: border-box; }
  html { scroll-behavior: smooth; }
  
  body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: 'Inter', sans-serif;
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
  }

  @media (prefers-reduced-motion: reduce) {
    * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  }

  h1, h2, h3 { font-family: 'Fraunces', serif; font-weight: 500; margin: 0; color: var(--red-deep); }
  a { color: inherit; }

  header.site { background: var(--red-deep); color: var(--paper); padding: 22px 24px; border-bottom: 3px solid var(--gold); }
  .header-inner { max-width: 760px; margin: 0 auto; display: flex; align-items: center; gap: 16px; }
  
  /* Logo */
  .logo {
    width: 46px;
    height: 46px;
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
  }

  header.site h1 { color: var(--paper); font-size: clamp(18px, 2.6vw, 22px); font-weight: 500; line-height: 1.35; }
  header.site p { margin: 2px 0 0; font-size: 13.5px; color: #e3c3c8; }

  main {
    flex: 1;
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
    padding: 40px 24px 80px;
  }

  .back { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--red-mid); text-decoration: none; margin-bottom: 28px; }
  .back:hover { text-decoration: underline; }

  .generator-container h2 { font-size: clamp(26px, 4vw, 34px); line-height: 1.25; }
  .generator-container .subtitle { margin-top: 16px; font-size: 16px; color: #453a3c; max-width: 56ch; }

  #certForm { display: flex; gap: 12px; margin-top: 28px; flex-wrap: wrap; }
  #certForm input[type="text"] {
    flex: 1;
    min-width: 240px;
    padding: 12px 16px;
    font-size: 15px;
    font-family: inherit;
    color: var(--ink);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    transition: border-color 0.2s, box-shadow 0.2s;
  }
  #certForm input[type="text"]::placeholder { color: #8a7a7d; }
  #certForm input[type="text"]:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 3px var(--gold-soft);
  }

  #certForm button, #downloadBtn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--red-deep);
    color: var(--paper);
    font-family: inherit;
    font-size: 14.5px;
    font-weight: 500;
    padding: 12px 24px;
    border-radius: var(--radius);
    border: 1px solid var(--red-deep);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
  }
  #certForm button:hover, #downloadBtn:hover { background: var(--paper); color: var(--red-deep); }
  #certForm button:focus-visible, #downloadBtn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

  #loader {
    display: none;
    align-items: center;
    gap: 12px;
    margin-top: 24px;
    padding: 16px 20px;
    background: var(--red-tint);
    border-radius: var(--radius);
    color: var(--red-deep);
    font-weight: 500;
    font-size: 14.5px;
  }
  #loader p { margin: 0; }
  .spinner {
    width: 22px;
    height: 22px;
    border: 3px solid var(--gold-soft);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    flex: none;
  }
  @keyframes spin { to { transform: rotate(360deg); } }

  #preview {
    display: none;
    margin-top: 32px;
    padding: 24px;
    background: #fff;
    border: 1px solid var(--line);
    border-left: 3px solid var(--red-mid);
    border-radius: var(--radius);
  }
  #preview h3 { font-size: 18px; margin-bottom: 16px; }
  #previewImg {
    max-width: 100%;
    height: auto;
    border: 1px solid var(--line);
    border-radius: calc(var(--radius) / 2);
    display: block;
  }

  #downloadBtn { display: none; margin-top: 24px; padding: 14px 28px; }
  .version-info { margin-top: 12px; font-size: 12.5px; color: #8a7a7d; }

  @media (max-width: 520px) {
    #certForm { flex-direction: column; }
    #certForm button { width: 100%; }
    #downloadBtn { width: 100%; }
    #preview { padding: 16px; }
  }

  footer.site { background: var(--red-deep); color: #e3c3c8; text-align: center; padding: 26px 24px; font-size: 13px; border-top: 3px solid var(--gold); }
  footer.site .fname { font-family: 'Fraunces', serif; color: var(--paper); font-size: 15px; display: block; margin-bottom: 4px; }