:root {
  color-scheme: light;
  --bg: #FAF8F5; --surface: #FFFFFF; --text: #1B1A18; --muted: #5E5A54;
  --border: #D9D4CC; --control-border: #8A857C;
  --accent: #B93A0B; --accent-hover: #9A2F08; --on-accent: #FFFFFF;
  --error: #B3261E; --error-bg: #FDECEA; --ok: #0B6B55; --ok-bg: #E4F4EF;
  --focus: #1F5FBF; --ad-bg: #EFEBE4; --preview-bg: #F1EDE6;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --fs-xs: .8125rem; --fs-sm: .9375rem; --fs-base: 1rem; --fs-lg: 1.25rem;
  --fs-xl: clamp(1.5rem, 5.5vw, 2rem); --lh-body: 1.55; --lh-head: 1.2;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  --r-sm: 6px; --r-md: 12px; --r-pill: 999px; --tap: 44px; --page-w: 1040px; --gutter: 16px;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #14161A; --surface: #1D2026; --text: #F1EEE9; --muted: #A8A39A;
    --border: #33373F; --control-border: #7C7870;
    --accent: #FF8A5B; --accent-hover: #FFA17B; --on-accent: #14161A;
    --error: #FF8C84; --error-bg: #3A1E1D; --ok: #5FD3B0; --ok-bg: #16322B;
    --focus: #7FB0FF; --ad-bg: #1A1D22; --preview-bg: #252830;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: var(--fs-base)/var(--lh-body) var(--font);
  padding: env(safe-area-inset-top, 0) 0 env(safe-area-inset-bottom, 0);
}
main, .site-header, .site-footer { max-width: var(--page-w); margin: 0 auto; padding-inline: var(--gutter); }
h1, h2 { line-height: var(--lh-head); }
h1 { font-size: var(--fs-xl); margin: var(--s4) 0 var(--s1); }
h2 { font-size: var(--fs-lg); margin: var(--s6) 0 var(--s3); }
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

.site-header { display: flex; align-items: center; justify-content: space-between; min-height: 56px; gap: var(--s3); }
.brand { display: inline-flex; align-items: center; gap: var(--s2); color: var(--text); text-decoration: none; font-weight: 700; }
.header-links { display: flex; gap: var(--s4); font-size: var(--fs-sm); }
.sub { margin: 0 0 var(--s4); color: var(--muted); }

label, .group-label { display: block; font-weight: 600; font-size: var(--fs-sm); margin: var(--s3) 0 var(--s1); }
.help { margin: var(--s1) 0 0; color: var(--muted); font-size: var(--fs-xs); }
input[type="url"], input[type="text"] {
  width: 100%; min-height: var(--tap); padding: 0 var(--s3); font: inherit; font-size: 16px;
  color: var(--text); background: var(--surface); border: 1px solid var(--control-border); border-radius: var(--r-sm);
}
button {
  min-height: var(--tap); padding: 0 var(--s4); font: inherit; font-weight: 600; cursor: pointer;
  color: var(--text); background: var(--surface); border: 1px solid var(--control-border); border-radius: var(--r-sm);
}
button.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
button.primary:hover:not(:disabled) { background: var(--accent-hover); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.wide { width: 100%; }
.chip { margin-top: var(--s2); border-radius: var(--r-pill); font-weight: 500; font-size: var(--fs-sm); }

.link-input { display: flex; gap: var(--s2); }
.link-input button { flex: none; }
.message { margin: var(--s2) 0 0; font-size: var(--fs-sm); min-height: 1.4em; }
.message.error { color: var(--error); background: var(--error-bg); padding: var(--s2) var(--s3); border-radius: var(--r-sm); }
.message.error::before { content: "⚠ "; }
.message.ok { color: var(--ok); }

.workspace { display: grid; gap: var(--s5); margin-top: var(--s4); }
.preview { margin: 0; background: var(--preview-bg); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--s4); }
.preview svg { display: block; width: 100%; height: auto; max-height: 30vh; }
.preview.sample svg { opacity: .5; }
.preview figcaption { font-size: var(--fs-xs); color: var(--muted); text-align: center; margin-top: var(--s2); }
.readout { font-size: var(--fs-sm); color: var(--muted); margin: var(--s2) 0 0; font-variant-numeric: tabular-nums; }

.downloads { margin-top: var(--s4); }
.downloads h2 { margin-top: 0; }
.button-pair { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); margin-top: var(--s3); }
.privacy { font-size: var(--fs-xs); color: var(--muted); margin-top: var(--s3); }

.options fieldset { border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); margin: 0 0 var(--s3); padding: var(--s2) var(--s4) var(--s4); }
.options legend { font-weight: 700; padding: 0 var(--s1); }
.options output { font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; margin-left: var(--s1); }
input[type="range"] { width: 100%; min-height: var(--tap); accent-color: var(--accent); }
.segmented { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s2); }
.segmented .group-label { width: 100%; margin-bottom: 0; }
.segmented label, .check {
  display: inline-flex; align-items: center; gap: var(--s2); margin: 0; min-height: var(--tap); padding: 0 var(--s3);
  border: 1px solid var(--control-border); border-radius: var(--r-sm); font-weight: 500; cursor: pointer;
}
.check { margin-top: var(--s3); border: 0; padding: 0; }
.segmented label:has(input:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
input[type="radio"], input[type="checkbox"] { accent-color: var(--accent); width: 18px; height: 18px; margin: 0; }

.swatches { display: flex; flex-wrap: wrap; gap: var(--s2); }
.swatch { width: var(--tap); height: var(--tap); padding: 0; border-radius: var(--r-pill); border: 2px solid var(--border); }
.swatch[aria-checked="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent); }

.ad-slot {
  display: flex; align-items: center; justify-content: center; min-height: 100px; margin: var(--s6) auto 0;
  max-width: var(--page-w); background: var(--ad-bg); border-radius: var(--r-md); color: var(--muted); font-size: var(--fs-xs);
  margin-inline: var(--gutter);
}

.content { max-width: 720px; }
.steps { padding-left: 1.25em; }
.steps li { margin-bottom: var(--s2); }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: var(--fs-sm); }
th, td { text-align: left; padding: var(--s2) var(--s3); border-bottom: 1px solid var(--border); vertical-align: top; }
th { width: 30%; }
details { border-bottom: 1px solid var(--border); padding: var(--s3) 0; }
summary { cursor: pointer; font-weight: 600; min-height: 28px; }
details p { margin: var(--s2) 0 0; }

.site-footer { margin-top: var(--s7); padding-block: var(--s5); border-top: 1px solid var(--border); font-size: var(--fs-sm); }
.disclaimer { color: var(--muted); font-size: var(--fs-xs); }

@media (max-width: 767px) {
  .preview-column { display: contents; }
  .preview { position: sticky; top: env(safe-area-inset-top, 0); z-index: 1; }
  .readout { order: 1; }
  .workspace { display: flex; flex-direction: column; gap: var(--s3); }
  .preview { order: 0; }
  .options { order: 2; }
  .downloads { order: 3; }
}
@media (min-width: 768px) {
  .workspace { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: start; }
  .preview-column { position: sticky; top: var(--s4); }
  .ad-slot { min-height: 90px; margin-inline: auto; }
}
.help.error-text { color: var(--error); font-weight: 600; }
.tool-cards { display: grid; gap: var(--s4); grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin-top: var(--s5); }
.tool-card { display: block; padding: var(--s4); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); color: var(--text); text-decoration: none; }
.tool-card:hover { border-color: var(--accent); }
.tool-card svg { width: 100%; height: 72px; }
.tool-card h2 { margin: var(--s3) 0 var(--s1); font-size: var(--fs-lg); }
.tool-card p { margin: 0; color: var(--muted); font-size: var(--fs-sm); }
.tool-card.soon { opacity: .6; }
.header-links a[aria-current="page"] { color: var(--text); font-weight: 600; text-decoration: none; }
#content-form input[type="text"], #content-form input[type="url"] { margin-bottom: var(--s1); }
.drop-zone { display: flex; align-items: center; min-height: 72px; padding: var(--s3) var(--s4); border: 2px dashed var(--control-border); border-radius: var(--r-md); background: var(--surface); font-weight: 400; cursor: pointer; }
.drop-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop-zone:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.preview canvas { display: block; width: 100%; height: auto; max-height: 40vh; object-fit: contain; border-radius: var(--r-sm); }
@media (max-width: 479px) { .brand span { display: none; } .header-links { gap: var(--s3); } }

.gear { border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); padding: var(--s4); margin-top: var(--s6); }
.gear h2 { margin-top: 0; }
.gear ul { margin: 0; padding-left: 1.2em; }
.gear li { margin: var(--s2) 0; }
.gear .disclosure { font-size: var(--fs-xs); color: var(--muted); margin: var(--s3) 0 0; }

.pro-entry { min-height: 32px; padding: 0 var(--s3); border-radius: var(--r-pill); font-size: var(--fs-sm); }
.pro-panel {
  width: min(28rem, calc(100% - 2 * var(--gutter))); color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--s5);
}
.pro-panel::backdrop { background: rgba(0, 0, 0, .45); }
.pro-panel h2 { margin-top: 0; }
.pro-reason { font-weight: 600; margin: 0 0 var(--s2); }
.pro-checkout {
  display: flex; align-items: center; justify-content: center; min-height: var(--tap); margin-top: var(--s3);
  background: var(--accent); color: var(--on-accent); border-radius: var(--r-sm); font-weight: 600; text-decoration: none;
}
.pro-checkout:hover { background: var(--accent-hover); color: var(--on-accent); }
.pro-close { margin-top: var(--s3); }
