/* Email signature generator. The tool stays in greys so the only colour on the page is the user's brand, inside the preview.
   Layout: one column on phones (preview first); form | sticky preview from 1000px; install guide underneath. */
:root {
  --bg: #F3F4F6;
  --surface: #FFFFFF;
  --sunken: #ECEEF2;
  --line: #E0E3E9;
  --line-strong: #C9CED7;
  --ink: #15171C;
  --muted: #5C6370;
  --primary: #15171C;
  --primary-hover: #2D313A;
  --primary-fg: #FFFFFF;
  --focus: #2563EB;
  --ok: #15803D;
  --warn-bg: #FFF7E6;
  --warn-line: #F0D59C;
  --warn-fg: #7A4B00;
  --info-bg: #EEF2F8;
  --info-line: #D5DDEA;
  --info-fg: #374151;
  --shadow: 0 1px 2px rgba(16, 18, 24, 0.08);
  /* The message preview is a white page in both themes, like most inboxes. */
  --paper: #FFFFFF;
  --paper-fg: #1A1C21;
  --paper-muted: #6B7280;
  --paper-line: #ECEEF2;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mail: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0E1013;
    --surface: #16191E;
    --sunken: #1D2127;
    --line: #272C34;
    --line-strong: #39404B;
    --ink: #ECEEF1;
    --muted: #9AA1AD;
    --primary: #ECEEF1;
    --primary-hover: #FFFFFF;
    --primary-fg: #15171C;
    --focus: #60A5FA;
    --ok: #4ADE80;
    --warn-bg: #2A2110;
    --warn-line: #4D3B14;
    --warn-fg: #F5C46B;
    --info-bg: #1A2029;
    --info-line: #2B3441;
    --info-fg: #C9D1DD;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
button, input, select, textarea { font: inherit; color: inherit; }
b { font-weight: 600; }

.page {
  max-width: 1200px;
  margin: 0 auto;
  padding-block: max(24px, env(safe-area-inset-top, 0px)) max(48px, env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: grid;
  gap: 24px;
}

/* Header */
.top { display: grid; gap: 8px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); min-width: 0; }
.brand-mark { width: 30px; height: 30px; flex: none; }
.brand-mark rect { fill: var(--ink); }
.brand-mark path { fill: none; stroke: var(--bg); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.wordmark { margin: 0; font-size: 22px; line-height: 28px; font-weight: 650; letter-spacing: -0.015em; text-wrap: balance; }
.lede { margin: 0; max-width: 62ch; color: var(--muted); font-size: 15px; text-wrap: pretty; }

.label {
  margin: 0;
  font-size: 12px;
  line-height: 16px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

.notice {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px;
  background: var(--info-bg);
  border: 1px solid var(--info-line);
  border-radius: 8px;
  color: var(--info-fg);
}
.notice p { margin: 0; }

/* Main grid */
.layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-items: start; }
@media (min-width: 1000px) {
  .layout { grid-template-columns: minmax(0, 440px) minmax(0, 1fr); gap: 24px; }
  .editor { grid-column: 1; grid-row: 1; }
  .preview-col { grid-column: 2; grid-row: 1; position: sticky; top: 16px; }
  .preview-sticky { max-height: calc(100vh - 32px); overflow-y: auto; padding-right: 2px; }
}
.preview-col, .editor { min-width: 0; }

/* Editor */
.editor {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.editor-intro {
  display: grid; gap: 6px;
  padding: 14px 20px;
  background: var(--sunken);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
}
.editor-intro p { margin: 0; }
.intro-actions { display: flex; gap: 16px; flex-wrap: wrap; }

.group {
  margin: 0;
  padding: 18px 20px 20px;
  border: 0;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 14px;
  min-width: 0;
}
.group:last-of-type { border-bottom: 0; }
.group legend {
  float: left;
  width: 100%;
  padding: 0;
  margin: 0 0 2px;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}
.group > .hint, .group > .bi-hints { margin-top: -6px; }
.bi-hints .hint { margin: 0; }
.group legend + * { clear: both; }
.group-hint { margin: -6px 0 0; color: var(--muted); font-size: 12.5px; }
.group .group-hint:last-child { margin: 0; }

.row2 { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
@media (min-width: 480px) { .row2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.field { display: grid; gap: 6px; min-width: 0; }
.field > label, .field-label, .color-field > label {
  font-size: 13px; line-height: 18px; font-weight: 500; color: var(--ink);
  display: flex; justify-content: space-between; gap: 8px;
}
.field output { color: var(--muted); font-weight: 400; font-variant-numeric: tabular-nums; }
.hint { color: var(--muted); font-size: 12px; line-height: 17px; }

input[type="text"], input[type="tel"], input[type="email"], input[type="url"], input[type="number"], select, textarea {
  width: 100%;
  min-width: 0;
  height: 36px;
  padding: 0 10px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--ink);
  font-size: 14px;
}
select { padding-right: 28px; }
textarea { height: auto; min-height: 120px; padding: 8px 10px; line-height: 1.5; font-size: 13px; resize: vertical; }
::placeholder { color: var(--muted); opacity: 0.75; }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--focus); outline-offset: 1px; border-color: var(--focus);
}

.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink); cursor: pointer; width: max-content; max-width: 100%; }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--primary); flex: none; }
input[type="range"] { width: 100%; accent-color: var(--primary); margin: 4px 0; }

/* Segmented control */
.seg {
  display: inline-flex; flex-wrap: wrap; gap: 2px;
  width: max-content; max-width: 100%;
  padding: 3px;
  background: var(--sunken);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.seg label { position: relative; }
.seg input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.seg span {
  display: block;
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 13px; line-height: 20px; font-weight: 500;
  color: var(--muted);
}
.seg input:checked + span { background: var(--surface); color: var(--ink); box-shadow: var(--shadow), 0 0 0 1px var(--line); }
.seg input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 1px; }

.logo-opts { display: grid; gap: 14px; }
.upload-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  max-width: 100%;
  padding: 2px 4px 2px 10px;
  background: var(--sunken);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12.5px;
}
.chip > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-x {
  width: 22px; height: 22px; border: 0; border-radius: 50%;
  background: none; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1;
}
.chip-x:hover { background: var(--line); color: var(--ink); }
.chip-x:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }

/* Two languages: paired boxes, each tagged with its language */
.pair { display: grid; gap: 6px; min-width: 0; }
.li { display: flex; min-width: 0; }
.li > input, .li > textarea { flex: 1 1 auto; min-width: 0; }
.lang-tag { display: none; }
.bi .lang-tag {
  display: flex; align-items: center; flex: none;
  width: 76px;
  padding: 0 8px;
  background: var(--sunken);
  border: 1px solid var(--line-strong);
  border-right: 0;
  border-radius: 8px 0 0 8px;
  color: var(--muted);
  font-size: 12px; font-weight: 500;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.bi .li > textarea + *, .bi .li .lang-tag { align-self: stretch; }
.bi .li > input, .bi .li > textarea { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.bi .li > textarea { min-height: 120px; }

.in-brand {
  display: inline-block;
  margin-left: 6px;
  padding: 0 7px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px; line-height: 17px; font-weight: 500;
  vertical-align: 2px;
  white-space: nowrap;
}

.std { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.std .linkbtn { font-size: 12px; }

/* Affiliations */
.aff-list { display: grid; gap: 16px; }
.aff-list:empty { display: none; }
.aff-row { display: grid; gap: 10px; min-width: 0; }
.aff-row + .aff-row { padding-top: 16px; border-top: 1px solid var(--line); }
.aff-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.aff-title { font-size: 13px; font-weight: 600; }
.aff-size { display: grid; gap: 6px; }
.size-inputs { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; }
.num { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 600; }
.num input { width: 76px; }
.unit { color: var(--muted); font-size: 12px; }
.native { flex-basis: 100%; }
.opt { color: var(--muted); font-weight: 400; }
.add-btn { justify-self: start; }
.icon-btn.small { width: 28px; height: 28px; }
.icon-btn.lock[aria-pressed="true"] { color: var(--ink); background: var(--sunken); }
.icon-btn {
  width: 36px; height: 36px; padding: 0;
  display: inline-grid; place-items: center;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
}
.icon-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:hover { background: var(--sunken); color: var(--ink); }
.icon-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Colours */
.colors { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.color-field { display: grid; gap: 6px; min-width: 0; }
.color-input { display: flex; gap: 6px; min-width: 0; }
.color-input input[type="color"] {
  flex: none;
  width: 36px; height: 36px; padding: 3px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  cursor: pointer;
}
.color-input input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.color-input input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 5px; }
.color-input input[type="color"]::-moz-color-swatch { border: 0; border-radius: 5px; }
.color-input input[type="color"]:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.color-input input[type="text"] { font-family: var(--mono); font-size: 13px; text-transform: uppercase; }

.saved { margin: 0; min-height: 0; padding: 0 20px; color: var(--muted); font-size: 12px; }
.saved:not(:empty) { padding-block: 0 14px; }

/* Buttons */
.btn {
  height: 36px;
  padding: 0 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--ink);
  font-size: 14px; font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
}
.btn.small { height: 32px; padding: 0 12px; font-size: 13px; }
.btn svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn:hover { background: var(--sunken); }
.btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-fg); }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.done:not(.primary) { color: var(--ok); }
input[type="file"]:focus-visible + .btn, .upload-row label.btn:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }

.linkbtn {
  padding: 0; border: 0; background: none;
  color: var(--ink);
  font-size: 13px; font-weight: 500;
  text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px;
  cursor: pointer;
}
.linkbtn:hover { text-decoration-color: currentColor; }
.linkbtn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
.linkbtn.inline { font-size: inherit; }

@media (prefers-reduced-motion: no-preference) {
  .btn, .seg span, .chip-x { transition: background-color .12s ease, color .12s ease, border-color .12s ease, box-shadow .12s ease; }
  .meter-bar span { transition: width .2s ease; }
}

/* Preview */
.preview-sticky { display: grid; gap: 14px; }
.pv-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.pv-sub { color: var(--muted); font-size: 12px; }

.paper {
  background: var(--paper);
  color: var(--paper-fg);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  font-family: var(--mail);
  font-size: 14px;
  line-height: 1.55;
  min-width: 0;
}
.mail-head {
  display: flex; flex-wrap: wrap; gap: 10px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--paper-line);
  color: var(--paper-muted);
  font-size: 13px;
}
.mail-head b { color: var(--paper-fg); font-weight: 500; }
.mail-body { display: grid; gap: 12px; padding: 20px 24px 28px; }
.mail-body p { margin: 0; }
.sig-scroll { overflow-x: auto; padding-top: 6px; }
#sig.natural { width: max-content; }
.sig-empty { color: var(--paper-muted); font-style: italic; }
@media (max-width: 480px) {
  .mail-head { padding: 10px 16px; }
  .mail-body { padding: 16px 16px 22px; }
}

.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.status { min-height: 20px; margin-top: -6px; color: var(--muted); font-size: 13px; }
.status.ok { color: var(--ok); }

.warnings { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.warnings:empty { display: none; }
.warnings li {
  display: grid; grid-template-columns: 16px minmax(0, 1fr); gap: 10px; align-items: start;
  padding: 10px 12px;
  border: 1px solid var(--info-line);
  background: var(--info-bg);
  color: var(--info-fg);
  border-radius: 8px;
  font-size: 13px; line-height: 19px;
}
.warnings li.warn { border-color: var(--warn-line); background: var(--warn-bg); color: var(--warn-fg); }
.warnings svg { width: 16px; height: 16px; margin-top: 2px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.meter { display: grid; gap: 6px; }
.meter-row { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.meter-bar { height: 4px; background: var(--sunken); border-radius: 999px; overflow: hidden; }
.meter-bar span { display: block; height: 100%; width: 0; background: var(--muted); border-radius: inherit; }
.meter.over .meter-row { color: var(--warn-fg); }
.meter.over .meter-bar span { background: var(--warn-fg); }

.team {
  display: flex; align-items: center; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.team > div { flex: 1 1 260px; min-width: 0; }
.team h3 { margin: 0; font-size: 14px; font-weight: 600; }
.team p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

details.code { border-top: 1px solid var(--line); padding-top: 12px; }
details.code summary { cursor: pointer; font-size: 13px; font-weight: 500; width: max-content; }
details.code summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
details.code pre {
  margin: 10px 0 0;
  max-height: 320px;
  overflow: auto;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  font: 400 12px/1.6 var(--mono);
  white-space: pre;
  tab-size: 2;
}

/* Guide */
.guide { display: grid; gap: 14px; padding-top: 8px; }
.guide .label + .apps, .guide .label + .faq { margin-top: -4px; }
.apps { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
@media (min-width: 640px) { .apps { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1000px) { .apps { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.app {
  display: grid; gap: 8px; align-content: start;
  padding: 16px 18px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.app h3 { margin: 0; font-size: 15px; font-weight: 600; }
.app ol { margin: 0; padding-left: 18px; display: grid; gap: 5px; }
.app li::marker { color: var(--muted); font-variant-numeric: tabular-nums; }
.app .aside { margin: 4px 0 0; color: var(--muted); font-size: 12.5px; line-height: 18px; }

.faq { margin: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; border-top: 1px solid var(--line); }
@media (min-width: 760px) { .faq { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 32px; } }
.faq > div { padding: 14px 0; border-bottom: 1px solid var(--line); }
.faq dt { font-weight: 600; }
.faq dd { margin: 4px 0 0; color: var(--muted); max-width: 62ch; }

.foot { color: var(--muted); font-size: 12.5px; border-top: 1px solid var(--line); padding-top: 16px; }
.foot p { margin: 0; }
.foot a { color: var(--ink); text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.foot a:hover { text-decoration-color: currentColor; }
.foot a:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
