:root {
    --paper: #F7F5EF;
    --paper-raised: #FFFFFF;
    --ink: #23241F;
    --ink-soft: #6B6A62;
    --line: #DEDACB;
    --line-strong: #C6C1AE;
    --stamp: #A63A32;
    --stamp-soft: #F1DEDB;
    --slate: #3B5166;
    --slate-soft: #E4EAEF;
    --focus: #3B5166;
    --danger: #B23A34;
    --font-serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  }

  :root:not([data-theme="light"]) {
    @media (prefers-color-scheme: dark) {
      --paper: #1B1C18;
      --paper-raised: #232420;
      --ink: #EDEAE0;
      --ink-soft: #A6A399;
      --line: #38392F;
      --line-strong: #4A4B3E;
      --stamp: #D6786F;
      --stamp-soft: #3A2521;
      --slate: #8FB0CB;
      --slate-soft: #212D35;
      --focus: #8FB0CB;
    }
  }

  :root[data-theme="dark"] {
    --paper: #1B1C18;
    --paper-raised: #232420;
    --ink: #EDEAE0;
    --ink-soft: #A6A399;
    --line: #38392F;
    --line-strong: #4A4B3E;
    --stamp: #D6786F;
    --stamp-soft: #3A2521;
    --slate: #8FB0CB;
    --slate-soft: #212D35;
    --focus: #8FB0CB;
  }

  * { box-sizing: border-box; }

  body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-sans);
    -webkit-font-smoothing: antialiased;
  }

  .app {
    max-width: 1400px;
    margin: 0 auto;
    padding: 28px 20px 64px;
  }

  header.top {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
  }

  header.top h1 {
    font-family: var(--font-serif);
    font-weight: 600;
    font-size: 1.6rem;
    margin: 0;
    letter-spacing: 0.01em;
  }

  header.top p {
    margin: 4px 0 0;
    color: var(--ink-soft);
    font-size: 0.92rem;
    max-width: 46ch;
  }

  .lang-switch {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
  }

  .lang-switch-label {
    font-size: 0.8rem;
    color: var(--ink-soft);
    white-space: nowrap;
  }

  .lang-switch select {
    padding: 6px 8px;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    background: var(--paper-raised);
    color: var(--ink);
    font-family: inherit;
    font-size: 0.82rem;
  }

  .layout {
    display: grid;
    grid-template-columns: minmax(320px, 420px) 1fr;
    gap: 24px;
    align-items: start;
  }

  @media (max-width: 900px) {
    .layout { grid-template-columns: 1fr; }
    .panel, .preview-wrap { position: static !important; }
  }

  /* ---- form panel ---- */
  .panel {
    background: var(--paper-raised);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 20px 20px 8px;
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
  }

  .section {
    border-bottom: 1px solid var(--line);
    padding-bottom: 16px;
    margin-bottom: 16px;
  }

  .section:last-of-type { border-bottom: none; }

  .section h2 {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
    color: var(--ink-soft);
    margin: 0 0 12px;
  }

  .field {
    margin-bottom: 10px;
  }

  .field label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    margin-bottom: 4px;
    color: var(--ink);
  }

  .field label .req {
    color: var(--stamp);
    margin-left: 2px;
  }

  .field input,
  .field textarea,
  .field select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    background: var(--paper);
    color: var(--ink);
    font-family: inherit;
    font-size: 0.88rem;
  }

  .field textarea { resize: vertical; min-height: 56px; }

  .field input:focus,
  .field textarea:focus,
  .field select:focus {
    outline: 2px solid var(--focus);
    outline-offset: 1px;
  }

  .field.invalid input,
  .field.invalid textarea {
    border-color: var(--danger);
    background: var(--stamp-soft);
  }

  .field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .logo-upload {
    display: flex;
    align-items: center;
    gap: 12px;
  }

  .logo-preview {
    width: 56px;
    height: 56px;
    border-radius: 8px;
    border: 1px dashed var(--line-strong);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
    color: var(--ink-soft);
    font-size: 0.65rem;
    text-align: center;
    background: var(--paper);
  }

  .logo-preview img { width: 100%; height: 100%; object-fit: contain; }

  .btn-file {
    font-size: 0.8rem;
    padding: 7px 12px;
    border-radius: 6px;
    border: 1px solid var(--line-strong);
    background: var(--paper);
    color: var(--ink);
    cursor: pointer;
  }

  .btn-file input { display: none; }

  .align-options {
    display: flex;
    gap: 16px;
  }

  .align-option {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    font-weight: 400;
    color: var(--ink);
    cursor: pointer;
  }

  .align-option input { width: auto; }

  .link-btn {
    background: none;
    border: none;
    color: var(--slate);
    font-size: 0.78rem;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
    text-underline-offset: 2px;
  }

  /* items table in the form */
  .item-row {
    display: grid;
    grid-template-columns: 1fr 52px 76px 28px;
    gap: 6px;
    margin-bottom: 6px;
    align-items: start;
  }

  .item-row input { font-size: 0.85rem; padding: 7px 8px; }

  .remove-item {
    background: none;
    border: none;
    color: var(--ink-soft);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 7px 0;
  }
  .remove-item:hover { color: var(--danger); }

  .add-item-btn {
    margin-top: 4px;
    background: var(--slate-soft);
    color: var(--slate);
    border: none;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
  }

  .field-row.totals {
    grid-template-columns: 1fr 100px;
    align-items: end;
  }

  .actions {
    position: sticky;
    bottom: -8px;
    background: var(--paper-raised);
    padding: 12px 0 16px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
  }

  .btn {
    flex: 1;
    min-width: 110px;
    padding: 11px 14px;
    border-radius: 7px;
    border: none;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
  }

  .btn-primary { background: var(--stamp); color: #FDF8F6; }
  .btn-secondary { background: var(--slate); color: #F3F7FA; }
  .btn-ghost { background: transparent; color: var(--ink-soft); border: 1px solid var(--line-strong); flex: 0 0 auto; min-width: unset; padding: 11px 12px; }

  .btn:disabled { opacity: 0.5; cursor: not-allowed; }

  .error-banner {
    display: none;
    background: var(--stamp-soft);
    color: var(--stamp);
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 0.8rem;
    margin-bottom: 10px;
  }
  .error-banner.show { display: block; }

  /* ---- preview ---- */
  .preview-wrap {
    position: sticky;
    top: 20px;
  }

  .ad-slot {
    border: 1px dashed var(--line-strong);
    border-radius: 8px;
    color: var(--ink-soft);
    font-size: 0.72rem;
    text-align: center;
    padding: 10px;
    margin-bottom: 16px;
    background: var(--paper-raised);
  }

  .ad-slot:empty {
    display: none;
  }

  #invoice {
    background: #FFFFFF;
    border: 1px solid #DEDACB;
    border-radius: 10px;
    padding: 48px;
    color: #23241F;
    max-width: 780px;
    margin: 0 auto;
  }

  #invoice * { color: inherit; }

  .inv-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    border-bottom: 2px solid #23241F;
    padding-bottom: 20px;
    margin-bottom: 24px;
  }

  .inv-head.center-logo {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .inv-head.center-logo .inv-business,
  .inv-head.center-logo .inv-title-block {
    text-align: center;
    flex: none;
  }

  .inv-head.center-logo .inv-business .meta {
    white-space: normal;
  }

  .inv-head.center-logo .inv-title-block {
    margin-top: 4px;
  }

  .inv-logo-slot {
    width: 88px;
    height: 88px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .inv-logo-slot img { max-width: 100%; max-height: 100%; object-fit: contain; }

  .inv-business { flex: 1; min-width: 0; }

  .inv-business .name {
    font-family: var(--font-serif);
    font-size: 1.3rem;
    font-weight: 700;
    margin: 0 0 4px;
  }

  .inv-business .meta {
    font-size: 0.8rem;
    line-height: 1.5;
    color: #55564C;
    white-space: pre-line;
  }

  .inv-title-block {
    text-align: right;
    flex-shrink: 0;
  }

  .inv-title-block .title {
    font-family: var(--font-serif);
    font-size: 1.9rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    margin: 0;
  }

  .inv-title-block .num {
    font-size: 0.85rem;
    color: #55564C;
    margin-top: 4px;
  }

  .inv-parties {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 28px;
    flex-wrap: wrap;
  }

  .inv-parties .block { min-width: 200px; }

  .inv-parties .label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #8A897C;
    margin-bottom: 6px;
  }

  .inv-parties .value {
    font-size: 0.88rem;
    line-height: 1.55;
    white-space: pre-line;
  }

  .inv-dates {
    text-align: right;
  }

  .inv-dates .row {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    font-size: 0.85rem;
    margin-bottom: 3px;
  }
  .inv-dates .row .k { color: #8A897C; }

  table.items {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
  }

  table.items thead th {
    text-align: left;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #8A897C;
    border-bottom: 1px solid #23241F;
    padding: 0 8px 8px 0;
    font-weight: 600;
  }

  table.items thead th.num { text-align: right; }

  table.items tbody td {
    padding: 9px 8px 9px 0;
    border-bottom: 1px solid #E4E1D5;
    font-size: 0.88rem;
    vertical-align: top;
  }

  table.items tbody td.num { text-align: right; white-space: nowrap; }

  .inv-totals {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 24px;
  }

  .inv-totals table { border-collapse: collapse; min-width: 260px; }

  .inv-totals td {
    padding: 5px 0;
    font-size: 0.88rem;
  }

  .inv-totals td.k { color: #55564C; padding-right: 24px; }
  .inv-totals td.v { text-align: right; }

  .inv-totals tr.grand td {
    border-top: 2px solid #23241F;
    padding-top: 10px;
    font-weight: 700;
    font-size: 1.05rem;
  }

  .inv-notes {
    border-top: 1px solid #E4E1D5;
    padding-top: 16px;
    font-size: 0.82rem;
    color: #55564C;
    white-space: pre-line;
    line-height: 1.6;
  }

  .inv-notes .label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #8A897C;
    margin-bottom: 6px;
  }

  .empty-hint {
    color: #A6A399;
    font-style: italic;
  }

  .no-print { }

  footer.credit {
    text-align: center;
    color: var(--ink-soft);
    font-size: 0.75rem;
    margin-top: 28px;
  }

  .seo-content {
    max-width: 720px;
    margin: 48px auto 0;
    padding-top: 32px;
    border-top: 1px solid var(--line);
  }

  .seo-content h2 {
    font-family: var(--font-serif);
    font-size: 1.15rem;
    font-weight: 600;
    margin: 28px 0 10px;
  }

  .seo-content h2:first-child { margin-top: 0; }

  .seo-content p,
  .seo-content li {
    font-size: 0.92rem;
    line-height: 1.65;
    color: var(--ink-soft);
  }

  .seo-content ol {
    padding-left: 20px;
    margin: 0;
  }

  .seo-content li { margin-bottom: 8px; }
  .seo-content li strong { color: var(--ink); }

  .faq details {
    border-bottom: 1px solid var(--line);
    padding: 12px 0;
  }

  .faq summary {
    font-weight: 600;
    font-size: 0.92rem;
    cursor: pointer;
    color: var(--ink);
  }

  .faq details p {
    margin: 10px 0 0;
  }

  @media print {
    .no-print {
      display: none !important;
    }

    html, body {
      background: #FFFFFF;
      margin: 0;
      padding: 0;
    }

    .app {
      max-width: none;
      margin: 0;
      padding: 0;
    }

    .layout {
      display: block;
    }

    .preview-wrap {
      position: static;
    }

    #invoice {
      border: none;
      border-radius: 0;
      box-shadow: none;
      padding: 0;
      max-width: 100%;
      margin: 0;
    }

    @page {
      margin: 14mm;
    }
  }


  /* ---- colour tokens for links + native controls ---- */
  :root { --link: #1D4F91; --ok: #1B7A43; color-scheme: light dark; }
  :root[data-theme="light"] { color-scheme: light; }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) { --link: #9DC4F0; --ok: #6FCF97; }
  }
  :root[data-theme="dark"] { --link: #9DC4F0; --ok: #6FCF97; color-scheme: dark; }

  /* ---- shared site nav ---- */
  .site-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px 20px;
    flex-wrap: wrap;
    margin-bottom: 24px;
    padding: 8px 8px 8px 16px;
    background: var(--paper-raised);
    border: 1px solid var(--line-strong);
    border-radius: 12px;
  }
  .site-nav .brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-serif);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--ink);
    text-decoration: none;
  }
  .site-nav .nav-links { display: flex; gap: 4px; flex-wrap: wrap; }
  .site-nav .nav-links a {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--ink);
    text-decoration: none;
    padding: 9px 16px;
    border-radius: 8px;
    border: 1px solid transparent;
  }
  .site-nav .nav-links a:hover { background: var(--slate-soft); border-color: var(--line-strong); }
  .site-nav .nav-links a[aria-current="page"] { background: var(--ink); color: var(--paper); }
  .site-nav a:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
  @media (max-width: 560px) {
    .site-nav { padding: 10px; }
    .site-nav .brand { width: 100%; padding-left: 6px; }
    .site-nav .nav-links { width: 100%; }
    .site-nav .nav-links a { flex: 1; text-align: center; }
  }


  /* ---- Article Styles ---- */
  .article-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 20px 64px;
    line-height: 1.7;
    font-family: var(--font-sans);
  }
  /* inside the .app wrapper the page already has a gutter, so don't double it */
  .app .article-container { padding-left: 0; padding-right: 0; }

  .article-header {
    text-align: center;
    margin: 40px 0 36px;
  }
  .article-header h1 {
    font-family: var(--font-serif);
    font-size: clamp(1.8rem, 4vw, 2.5rem);
    color: var(--ink);
    margin: 0 0 12px;
    line-height: 1.2;
    letter-spacing: -0.01em;
    text-wrap: balance;
  }
  .article-header p {
    color: var(--ink-soft);
    font-size: 1.1rem;
    line-height: 1.55;
    max-width: 60ch;
    margin: 0 auto;
    text-wrap: balance;
  }

  .article-content h2 {
    font-family: var(--font-serif);
    font-size: 1.5rem;
    line-height: 1.3;
    color: var(--ink);
    margin: 44px 0 20px;
    border-left: 4px solid var(--stamp);
    padding-left: 15px;
    text-wrap: balance;
  }
  .article-content p {
    margin: 0 0 20px;
    color: var(--ink-soft);
    font-size: 1.05rem;
  }
  .article-content ol, .article-content ul {
    margin: 0 0 20px;
    padding-left: 1.4em;
    color: var(--ink-soft);
  }
  .article-content li {
    margin-bottom: 10px;
  }
  .article-content li strong {
    color: var(--ink);
  }

  /* links: --link is readable on both themes (browser-default blue is not on dark) */
  .article-content a:not(.cta-btn) {
    color: var(--link);
    font-weight: 500;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
  }
  .article-content a:not(.cta-btn):hover { text-decoration-thickness: 2px; }
  .article-content a:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
    border-radius: 2px;
  }

  /* call-to-action box */
  .cta-box {
    background: var(--slate-soft);
    border: 1px solid var(--slate);
    padding: 32px 28px;
    border-radius: 12px;
    text-align: center;
    margin: 44px 0;
  }
  .cta-box h3 {
    margin: 0 0 8px;
    font-family: var(--font-serif);
    font-size: 1.35rem;
    line-height: 1.3;
    color: var(--ink);
    text-wrap: balance;
  }
  .article-content .cta-box p {
    margin: 0 auto;
    max-width: 52ch;
    color: var(--ink);
  }
  .cta-btn {
    display: inline-block;
    max-width: 100%;
    margin-top: 20px;
    padding: 12px 24px;
    background: var(--stamp);
    color: var(--paper);          /* white on the lighter dark-mode accent was ~3:1 */
    border-radius: 8px;
    font-weight: 600;
    text-decoration: none;
    transition: opacity 0.2s;
  }
  .cta-btn:hover { opacity: 0.9; }
  .cta-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }

  /* checklist */
  .checklist {
    background: var(--paper-raised);
    border: 1px solid var(--line);
    padding: 25px;
    border-radius: 12px;
    margin: 25px 0;
  }
  .checklist ul {
    list-style: none;
    padding: 0;
    margin: 0;
  }
  .checklist li {
    margin-bottom: 12px;
    padding-left: 25px;
    position: relative;
  }
  .checklist li:last-child { margin-bottom: 0; }
  .checklist li:before {
    content: "✓";
    position: absolute;
    left: 0;
    color: var(--ok);
    font-weight: 700;
  }

  /* "7 mistakes" cards */
  .mistake-card {
    background: var(--paper-raised);
    border: 1px solid var(--line-strong);
    padding: 22px;
    border-radius: 12px;
    margin: 20px 0;
  }
  /* direct child only: a bare `.mistake-card strong` also turned "The Fix:" into a heading */
  .mistake-card > strong {
    display: block;
    margin-bottom: 10px;
    color: var(--stamp);
    font-family: var(--font-serif);
    font-size: 1.2rem;
    line-height: 1.3;
  }
  .article-content .mistake-card p { margin: 0; }
  .fix-box {
    background: var(--slate-soft);
    border-left: 3px solid var(--slate);
    padding: 14px 16px;
    border-radius: 8px;
    margin-top: 16px;
    font-size: 0.95rem;
    color: var(--ink);
  }
  .fix-box strong { color: var(--slate); }

  /* currency cards: 3 across (an even 3x2), 2 across on phones */
  .currency-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin: 25px 0;
  }
  .currency-card {
    background: var(--paper-raised);
    border: 1px solid var(--line);
    padding: 16px 12px;
    border-radius: 8px;
    text-align: center;
    color: var(--ink-soft);
    font-size: 0.88rem;
    line-height: 1.4;
  }
  /* a <br> after a block-level <strong> renders as an empty line */
  .currency-card br { display: none; }
  .currency-card strong {
    display: block;
    margin-bottom: 4px;
    color: var(--stamp);
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.04em;
  }
  @media (max-width: 520px) {
    .currency-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .cta-box { padding: 26px 18px; }
  }

  /* ---- button text contrast in both themes ---- */
  .btn-primary, .btn-secondary { color: var(--paper); }

  /* ---- date fields + small screens ---- */
  .field-row > .field { min-width: 0; }
  .field input[type="date"] { display: block; min-width: 0; max-width: 100%; min-height: 38px; }
  .inv-dates .row span:last-child { font-weight: 600; }
  @media (max-width: 480px) {
    .field-row:not(.totals) { grid-template-columns: 1fr; }
  }
  @media (max-width: 600px) {
    #invoice { padding: 20px; }
    .inv-head { flex-wrap: wrap; }
    .inv-parties .block { min-width: 0; }
  }

  /* ---- layout hardening: no sideways overflow on phones ---- */
  .layout > *, .panel { min-width: 0; }
  .item-row { grid-template-columns: minmax(0, 1fr) 52px 76px 28px; }
  .item-row input {
    width: 100%;
    min-width: 0;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    background: var(--paper);
    color: var(--ink);
    font-family: inherit;
  }
  .item-row input:focus { outline: 2px solid var(--focus); outline-offset: 1px; }
  @media (max-width: 900px) {
    .panel { max-height: none; overflow: visible; }
    .actions { bottom: 0; padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
  }

  /* ---- background remover page ---- */
  header.top.rm-hero h1 { font-size: clamp(1.8rem, 4.5vw, 2.5rem); line-height: 1.1; letter-spacing: -0.01em; }
  header.top.rm-hero p { font-size: 1rem; max-width: 60ch; line-height: 1.6; }
  .rm-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
    list-style: none;
    margin: 14px 0 0;
    padding: 0;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--ink-soft);
  }
  .rm-badges li::before { content: "✓"; margin-right: 6px; font-weight: 700; color: var(--stamp); }

  /* layout: single centred drop zone first, two columns once an image is loaded */
  .rm-layout { grid-template-columns: 1fr; }
  .rm-layout:not(.has-image) { max-width: 820px; margin: 0 auto; }
  .rm-layout:not(.has-image) .panel,
  .rm-layout:not(.has-image) .rm-tip { display: none; }
  .rm-layout.has-image { grid-template-columns: minmax(280px, 340px) minmax(0, 1fr); }
  .rm-main { min-width: 0; }
  @media (max-width: 900px) {
    .rm-layout.has-image { grid-template-columns: 1fr; }
    .rm-layout.has-image .rm-main { order: -1; }
    .rm-layout .panel { max-height: none; overflow: visible; }
    .rm-layout .actions {
      bottom: 0;
      padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
      border-top: 1px solid var(--line);
      margin: 0 -20px;
      padding-left: 20px;
      padding-right: 20px;
    }
  }

  /* drop zone */
  .rm-drop {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 380px;
    padding: 40px 24px;
    text-align: center;
    background: var(--paper-raised);
    border: 2px dashed var(--line-strong);
    border-radius: 16px;
    color: var(--ink-soft);
    font-size: 0.92rem;
    cursor: pointer;
    transition: border-color 0.15s, background-color 0.15s;
  }
  .rm-drop:hover { border-color: var(--slate); background: var(--slate-soft); }
  .rm-drop.over { border-color: var(--stamp); background: var(--stamp-soft); }
  .rm-drop:focus-within { outline: 3px solid var(--focus); outline-offset: 3px; }
  .rm-drop input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
  .rm-drop-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--slate-soft);
    color: var(--slate);
    margin-bottom: 6px;
  }
  .rm-drop strong {
    font-family: var(--font-serif);
    font-size: clamp(1.25rem, 3.5vw, 1.6rem);
    font-weight: 600;
    color: var(--ink);
  }
  .rm-drop-btn {
    margin-top: 6px;
    padding: 12px 24px;
    border-radius: 8px;
    background: var(--stamp);
    color: var(--paper);
    font-weight: 600;
    font-size: 0.95rem;
  }
  .rm-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 8px; }
  .rm-chips i {
    font-style: normal;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 3px 9px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    color: var(--ink-soft);
    background: var(--paper);
  }
  .rm-privacy { font-size: 0.8rem; margin: 4px 0 0; }

  /* before / after panes */
  .rm-panes { display: none; gap: 16px; }
  .rm-panes.on {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  }
  .rm-pane {
    background: var(--paper-raised);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 14px;
    min-width: 0;
  }
  .rm-pane-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
    min-height: 26px;
  }
  .rm-pane h2 {
    margin: 0;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-soft);
  }
  .rm-stage {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 240px;
    padding: 8px;
    border-radius: 8px;
    overflow: hidden;
    background-color: var(--paper);
    background-image:
      linear-gradient(45deg, var(--line) 25%, transparent 25%, transparent 75%, var(--line) 75%),
      linear-gradient(45deg, var(--line) 25%, transparent 25%, transparent 75%, var(--line) 75%);
    background-size: 0 0;
  }
  .rm-stage.chk { background-size: 16px 16px; background-position: 0 0, 8px 8px; }
  .rm-stage.white { background: #FFFFFF; }
  .rm-stage.black { background: #111111; }
  .rm-stage.green { background: #2E9D5B; }
  .rm-stage canvas { display: block; max-width: 100%; max-height: 60vh; width: auto; height: auto; }
  #rmOrig { cursor: crosshair; }
  .rm-tip {
    margin: 14px 0 0;
    padding: 10px 14px;
    border-radius: 8px;
    background: var(--slate-soft);
    color: var(--ink);
    font-size: 0.85rem;
    line-height: 1.5;
  }

  /* preview background dots */
  .rm-dots { display: flex; align-items: center; gap: 8px; font-size: 0.75rem; color: var(--ink-soft); }
  .rm-dots span { margin-right: 2px; }
  .rm-dots button {
    width: 24px;
    height: 24px;
    padding: 0;
    border-radius: 50%;
    border: 2px solid var(--line-strong);
    cursor: pointer;
  }
  .rm-dots button[aria-pressed="true"] { border-color: var(--ink); box-shadow: 0 0 0 2px var(--paper-raised), 0 0 0 4px var(--ink); }
  .rm-dots button:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
  .rm-dots [data-bg="chk"] {
    background-color: var(--paper-raised);
    background-image:
      linear-gradient(45deg, var(--line-strong) 25%, transparent 25%, transparent 75%, var(--line-strong) 75%),
      linear-gradient(45deg, var(--line-strong) 25%, transparent 25%, transparent 75%, var(--line-strong) 75%);
    background-size: 8px 8px;
    background-position: 0 0, 4px 4px;
  }
  .rm-dots [data-bg="white"] { background: #FFFFFF; }
  .rm-dots [data-bg="black"] { background: #111111; }
  .rm-dots [data-bg="green"] { background: #2E9D5B; }

  /* controls panel */
  .rm-layout .panel { border-radius: 14px; }
  .rm-layout .btn-file input { display: block; position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
  .rm-choose {
    position: relative;
    display: block;
    width: 100%;
    padding: 11px 14px;
    text-align: center;
    font-size: 0.88rem;
    font-weight: 600;
    border-radius: 8px;
    background: var(--paper);
    border: 1px solid var(--line-strong);
    color: var(--ink);
    cursor: pointer;
  }
  .rm-choose:hover { background: var(--slate-soft); }
  .rm-choose:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
  .rm-status { margin: 10px 0 0; font-size: 0.8rem; color: var(--ink-soft); overflow-wrap: anywhere; min-height: 1.2em; }
  .rm-bgrow { display: flex; align-items: center; gap: 12px; font-size: 0.8rem; color: var(--ink-soft); line-height: 1.45; }
  .rm-bgrow b { display: block; font-size: 0.9rem; color: var(--ink); font-variant-numeric: tabular-nums; }
  .rm-sw { width: 40px; height: 40px; border-radius: 8px; border: 1px solid var(--line-strong); flex: none; }
  .field label.rm-lbl { display: flex; justify-content: space-between; }
  .field label.rm-lbl output { color: var(--ink-soft); font-weight: 500; font-variant-numeric: tabular-nums; }

  .rm-layout .field input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: var(--line-strong);
    margin: 10px 0;
    cursor: pointer;
  }
  .rm-layout .field input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--slate);
    border: 3px solid var(--paper-raised);
    box-shadow: 0 0 0 1px var(--slate);
  }
  .rm-layout .field input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--slate);
    border: 3px solid var(--paper-raised);
    box-shadow: 0 0 0 1px var(--slate);
  }
  .rm-layout .field input[type="range"]:disabled { opacity: 0.45; cursor: not-allowed; }

  .rm-seg { display: flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; }
  .rm-seg button {
    flex: 1;
    padding: 10px 8px;
    border: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: inherit;
    font-size: 0.8rem;
    cursor: pointer;
  }
  .rm-seg button + button { border-left: 1px solid var(--line-strong); }
  .rm-seg button[aria-pressed="true"] { background: var(--slate); color: var(--paper); font-weight: 600; }
  .rm-seg button:disabled { opacity: 0.5; cursor: not-allowed; }
  .rm-seg button:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }

  @media (max-width: 600px) {
    .rm-drop { min-height: 300px; padding: 32px 16px; }
    .rm-stage { min-height: 180px; }
    .rm-pane { padding: 10px; }
  }

  header.top.rm-hero { justify-content: center; text-align: center; }
  header.top.rm-hero > div { width: 100%; }
  header.top.rm-hero p { margin-left: auto; margin-right: auto; }
  header.top.rm-hero .rm-badges { justify-content: center; }


  /* ---- placeholder text: the browser default (#757575) is under 4.5:1 on these backgrounds ---- */
  input::placeholder, textarea::placeholder { color: var(--ink-soft); opacity: 1; }

  /* ---- footer links + related reading ---- */
  footer.credit p { margin: 0; }
  footer.credit a { color: var(--link); text-underline-offset: 3px; }
  footer.credit a:hover { text-decoration-thickness: 2px; }
  footer.credit a:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 2px; }
  .footer-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px 20px;
    margin: 12px 0;
    font-size: 0.8125rem;
  }
  .footer-links a { padding: 6px 0; }

  .app .article-container { padding-bottom: 32px; }
  .related { max-width: 800px; margin: 8px auto 0; }
  .related h2 {
    margin: 0 0 14px;
    font-family: var(--font-serif);
    font-size: 1.25rem;
    color: var(--ink);
  }
  .related ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
  }
  .related a {
    display: block;
    height: 100%;
    padding: 16px 18px;
    background: var(--paper-raised);
    border: 1px solid var(--line-strong);
    border-radius: 12px;
    text-decoration: none;
  }
  .related a:hover { border-color: var(--slate); background: var(--slate-soft); }
  .related a:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
  .related strong {
    display: block;
    margin-bottom: 6px;
    font-family: var(--font-serif);
    font-size: 1.05rem;
    line-height: 1.3;
    color: var(--link);
  }
  .related span { display: block; font-size: 0.9rem; line-height: 1.5; color: var(--ink-soft); }
  .related a:hover span { color: var(--ink); }
  @media (max-width: 640px) { .related ul { grid-template-columns: 1fr; } }
