﻿:root {
  color-scheme: light dark;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  --paper: #f7f9fc;
  --surface: #fff;
  --ink: #172435;
  --muted: #526174;
  --line: #dce3ea;
  --link: #215b9e;
  --hover-line: #82a6cc;
  --hover-surface: #edf4fc;
  --error: #a32c25;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #111923;
    --surface: #182331;
    --ink: #e7edf5;
    --muted: #aab8c8;
    --line: #36475b;
    --link: #a1ccf8;
    --hover-line: #6f9bc7;
    --hover-surface: #22354b;
    --error: #ffada6;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); line-height: 1.5; }
.container { width: min(1120px, calc(100% - 3rem)); margin-inline: auto; }
.topbar { background: #102a43; color: #fff; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-block: 1.15rem; }
.eyebrow { display: block; color: #bad2e8; font-size: .8rem; letter-spacing: .09em; text-transform: uppercase; font-weight: 700; }
.brand, .team { color: inherit; text-decoration: none; }
.brand:hover, .team:hover, .brand:focus-visible, .team:focus-visible { color: #bad2e8; text-decoration: underline; text-underline-offset: .2em; }
.brand { display: inline-flex; align-items: center; gap: .65rem; font-weight: 750; font-size: 1.35rem; line-height: 1.2; }
.brand img { flex: none; }
.team { display: inline-flex; align-items: center; gap: .65rem; line-height: 1.25; font-size: .875rem; font-weight: 650; }
.team img { border-radius: 9px; }
main { padding-block: clamp(2rem, 6vw, 4.5rem); }
h1 { margin: 0 0 .65rem; max-width: 22ch; font-size: clamp(2rem, 5vw, 3.5rem); letter-spacing: -.045em; line-height: 1.08; }
.intro { color: var(--muted); margin: 0 0 1.75rem; }
.card { max-width: 900px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); padding: clamp(1rem, 3vw, 1.75rem); box-shadow: 0 5px 18px #102a430b; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.field { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; padding: 1.1rem; border: 1px solid var(--line); background: var(--paper); border-radius: 8px; }
.field:hover, .field:focus-within { border-color: var(--hover-line); }
.field h2 { align-self: stretch; margin: 0 0 .9rem; text-align: center; font-size: 1.1rem; }
input, button { font: inherit; }
input[type="file"] { width: 100%; min-width: 0; font-size: .9rem; }
input::file-selector-button { padding: .5rem .7rem; margin-right: .5rem; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; font: inherit; font-weight: 650; }
input:not(:disabled)::file-selector-button:hover, input:focus-visible::file-selector-button { background: var(--hover-surface); border-color: var(--hover-line); }
.letterhead-picker { position: relative; display: flex; align-items: center; gap: .5rem; width: 100%; min-width: 0; margin-bottom: .85rem; font-size: .9rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: 0; overflow: hidden; clip-path: inset(50%); }
.letterhead-picker input[type="file"] { width: 1px; margin: 0; }
.file-choice { flex: none; padding: .5rem .7rem; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); cursor: pointer; font-weight: 650; }
.letterhead-picker input:not(:disabled) + .file-choice:hover, .letterhead-picker input:focus-visible + .file-choice { background: var(--hover-surface); border-color: var(--hover-line); }
.letterhead-picker input:focus-visible + .file-choice { outline: 3px solid #76a8de; outline-offset: 3px; }
.letterhead-picker input:disabled + .file-choice { cursor: wait; opacity: .7; }
#letterhead-filename { min-width: 0; overflow-wrap: anywhere; }
button { cursor: pointer; font-weight: 700; }
button:disabled { cursor: wait; opacity: .7; }
.text-button { color: var(--link); padding: 0; border: 0; background: transparent; margin-top: .6rem; font-size: .9rem; text-decoration: underline; }
.text-button:hover:enabled, .text-button:focus-visible { text-decoration-thickness: 2px; text-underline-offset: .15em; }
.preview { position: relative; display: grid; place-items: center; align-self: stretch; height: 20rem; margin-top: auto; padding: 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
.field input, .field .text-button { margin-bottom: .85rem; }
.field .text-button { margin-top: -.25rem; }
.preview canvas { display: block; max-width: 100%; max-height: 18rem; width: auto; height: auto; background: white; box-shadow: 0 1px 5px #0003; }
.preview .preview-message { margin: 0; text-align: center; font-size: .9rem; }
.preview-picker { position: absolute; inset: 0; width: 100%; padding: 0; border: 0; border-radius: inherit; background: transparent; }
.preview-picker:hover, .preview-picker:focus-visible { box-shadow: inset 0 0 0 2px var(--hover-line); }
.preview-message[data-error] { color: var(--error); }
.preview-message[data-rendered] { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.actions { display: flex; align-items: center; flex-direction: column; gap: .75rem; margin-top: 1.25rem; }
.merge-buttons { display: flex; flex-wrap: wrap; justify-content: center; gap: .75rem; }
.primary { border: 0; border-radius: 7px; background: #2565a7; color: white; padding: .7rem 1rem; }
.primary:hover:enabled, .primary:focus-visible { background: #174b86; }
.secondary-link { color: var(--link); font-size: .9rem; font-weight: 650; }
#status { color: var(--muted); font-size: .9rem; margin: .8rem 0 0; }
#status:empty { display: none; }
#status[data-error] { color: var(--error); }
:focus-visible { outline: 3px solid #76a8de; outline-offset: 3px; }
@media (prefers-reduced-motion: no-preference) {
  .field, .primary, .file-choice, input::file-selector-button { transition: background-color .16s ease, border-color .16s ease; }
}
@media (max-width: 620px) {
  .container { width: calc(100% - 2rem); }
  .fields { grid-template-columns: 1fr; }
  .team img { width: 32px; height: 32px; }
}
@media (max-width: 400px) {
  .topbar-inner { gap: .625rem; }
  .brand, .team { gap: .4rem; }
  .brand { font-size: 1.1rem; }
  .brand img { width: 34px; height: 34px; }
  .eyebrow, .team { font-size: .75rem; }
}
