/* Lexend, self-hosted (SIL Open Font License, see fonts/OFL.txt).
   Hosting fonts yourself means visitors' browsers never contact Google Fonts. */
@font-face {
  font-family: "Lexend";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/lexend-latin-ext-400-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}
@font-face {
  font-family: "Lexend";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/lexend-latin-400-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
  font-family: "Lexend";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../fonts/lexend-latin-ext-500-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}
@font-face {
  font-family: "Lexend";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../fonts/lexend-latin-500-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
  font-family: "Lexend";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/lexend-latin-ext-600-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}
@font-face {
  font-family: "Lexend";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/lexend-latin-600-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

/* Layout: one centered 800px column. Mobile stacks content → preview → style;
   from 700px the preview sits in a sticky right column beside the controls. */
:root {
  --bg: #ffffff;
  --ink: #1f1d30;
  --yellow: #fec72e;
  --orange: #ffab2f;
  --line: #d5d4dd;
  --tint: #fff5d6;
  --surface: #f7f7f9;
  --alert: #e34449;
  --alert-tint: #fdeced;
  --font: "Lexend", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }   /* lets the script hide panels, messages, and the cookie banner */
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-weight: 400;
  font-size: 16px;
  line-height: 1.5;
}

a {
  color: var(--yellow);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}
a:hover, a:active, a:focus-visible { color: var(--orange); }

:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.wrap { max-width: 800px; margin-inline: auto; padding-inline: 16px; }

/* ---------- Header ---------- */
.site-header { background: var(--ink); color: var(--bg); }
.site-header .wrap { display: flex; align-items: center; padding-block: 12px; }
.logo-link { display: inline-flex; line-height: 0; border-radius: 4px; }
.logo {
  width: 116px;
  height: 48px;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
}

/* ---------- Ad slots ---------- */
.ad-slot {
  margin-block: 16px;
  min-height: 100px;            /* reserves room so the page doesn't jump when the ad loads */
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.ad-slot--placeholder {
  border-radius: 8px;
  background: var(--surface);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
@media (min-width: 700px) { .ad-slot { min-height: 90px; } }

/* ---------- Intro ---------- */
.intro { text-align: center; padding-block: 16px 4px; }
.intro h1 {
  margin: 0 0 8px;
  font-size: 1.75rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
.intro p { margin: 0 auto; max-width: 34em; text-wrap: pretty; }
.intro strong { font-weight: 600; }
@media (min-width: 700px) { .intro h1 { font-size: 2.125rem; } }

/* ---------- Tool layout ---------- */
.tool {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "content" "preview" "custom";
  gap: 40px;
  padding-block: 16px;
}
.panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding-block: 8px;
  text-align: center;
  container-type: inline-size;
}
.panel h2 { margin: 0; font-size: 1.125rem; font-weight: 600; line-height: 1.3; }
.panel-content { grid-area: content; }
.panel-preview { grid-area: preview; }
.panel-custom  { grid-area: custom; }

@media (min-width: 700px) {
  .tool {
    grid-template-columns: minmax(0, 1fr) 280px;
    column-gap: 40px;
    grid-template-areas: "content preview" "custom preview";
    align-items: start;
  }
  .panel-preview { position: sticky; top: calc(16px + env(safe-area-inset-top, 0px)); }
}

/* ---------- Fields ---------- */
.field { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.field-label { font-size: 0.9375rem; font-weight: 500; }
.hint { margin: 0; font-size: 0.8125rem; line-height: 1.5; text-wrap: pretty; }

.input, .select, .textarea {
  width: 100%;
  font: inherit;
  font-size: 1rem;            /* 16px stops iOS from zooming in on focus */
  color: var(--ink);
  background: var(--surface);
  border: 2px solid transparent;
  border-radius: 8px;
  padding: 10px 12px;
  text-align: left;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--ink); outline: none; }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible, input[type="color"]:focus-visible { outline: none; }
input[type="color"]:focus { border-color: var(--yellow); }
.input:disabled { color: rgba(31, 29, 48, 0.4); cursor: not-allowed; }
.textarea { resize: vertical; min-height: 96px; line-height: 1.45; }
.select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 40px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--ink) 50%),
    linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}
.counter { font-size: 0.75rem; font-variant-numeric: tabular-nums; margin: 0; }
.counter.is-over { color: var(--alert); font-weight: 500; }

.input-row { display: flex; gap: 8px; }
.input-row .input { flex: 1; min-width: 0; }

.mode-panel { display: flex; flex-direction: column; gap: 16px; }

/* ---------- Segmented choices (radio buttons) ---------- */
.segmented { border: 0; margin: 0; padding: 0; min-width: 0; }
.segmented legend { padding: 0; margin: 0 0 8px; width: 100%; }
.seg-options {
  display: grid;
  grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr));
  gap: 6px;
}
.seg-option { position: relative; display: block; cursor: pointer; }
.seg-option input {
  position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0;
}
.seg-option span {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  min-height: 46px;
  height: 100%;
  padding: 8px 4px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--bg);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.2;
  transition: background-color 0.15s;
}
.seg-option span { overflow-wrap: anywhere; }
/* 4-choice rows (error correction, shape) drop to a 2 × 2 grid when the panel is narrow */
@container (max-width: 459px) {
  .seg-options[style*="--cols:4"] { --cols: 2 !important; grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.seg-option span small { font-size: 0.75rem; font-weight: 400; font-variant-numeric: tabular-nums; }
.seg-option span svg { width: 22px; height: 22px; }
.seg-option:hover input:not(:checked) + span { background: var(--tint); }
.seg-option input:checked + span { background: var(--yellow); }
.seg-option input:focus-visible + span { outline: 3px solid var(--orange); outline-offset: 2px; }

/* ---------- Sliders ---------- */
.range-head { display: flex; justify-content: center; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; }
.range-value {
  font-size: 0.875rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  padding: 1px 8px;
  border-radius: 6px;
  background: var(--tint);
}
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 28px;
  margin: 0;
  background: transparent;
  cursor: pointer;
  --fill: 50%;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 8px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: linear-gradient(to right, var(--yellow) var(--fill), var(--bg) var(--fill));
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px; height: 22px;
  margin-top: -9px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--bg);
}
input[type="range"]::-moz-range-track {
  height: 8px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--bg);
}
input[type="range"]::-moz-range-progress {
  height: 8px;
  border-radius: 999px;
  background: var(--yellow);
}
input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--bg);
}

/* ---------- Colors ---------- */
.color-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; }
input[type="color"] {
  -webkit-appearance: none;
  appearance: none;
  flex: none;
  width: 46px; height: 46px;
  padding: 0;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--bg);
  cursor: pointer;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 3px; }
input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 4px; }
input[type="color"]::-moz-color-swatch { border: 0; border-radius: 4px; }
.input-hex { text-transform: uppercase; font-variant-numeric: tabular-nums; }

.check {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 0.875rem;
  cursor: pointer;
}
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--yellow); cursor: pointer; }

/* ---------- Preview ---------- */
.stage {
  position: relative;
  width: 100%;
  max-width: 268px;
  aspect-ratio: 1;
  margin-inline: auto;
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
  background: var(--bg);
}
.stage.is-transparent {
  background-image: conic-gradient(#ebebf0 25%, var(--bg) 0 50%, #ebebf0 0 75%, var(--bg) 0);
  background-size: 16px 16px;
}
#preview { display: block; width: 100%; height: 100%; }
.stage-empty {
  position: absolute; inset: 14px;
  display: grid; place-items: center;
  padding: 16px;
  font-size: 0.875rem;
  background: var(--bg);
}

.messages { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; text-align: left; }
.messages:empty { display: none; }
.msg {
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--surface);
  font-size: 0.8125rem;
  line-height: 1.45;
}
.msg--error { background: var(--alert-tint); box-shadow: inset 0 0 0 1px var(--alert); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px;
  padding: 8px 12px;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.2;
  color: var(--ink);
  background: var(--bg);
  border: 2px solid var(--ink);
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.15s;
}
.btn:hover { background: var(--tint); }
.btn-primary { background: var(--yellow); }
.btn-primary:hover { background: var(--orange); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:disabled:hover { background: var(--bg); }
.btn-primary:disabled, .btn-primary:disabled:hover { background: var(--yellow); }
.btn-small { min-height: 40px; padding: 6px 12px; flex: none; }

.save-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
@container (min-width: 460px) {
  .save-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .save-grid .btn-primary { grid-column: 1 / -1; }
}
.save-status { margin: 0; font-size: 0.8125rem; }
/* takes no space until there's a message, so the gap under the buttons matches the gap above them */
.save-status:empty { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.formats { text-align: left; padding-top: 4px; }
.formats h3 { margin: 0 0 10px; font-size: 0.875rem; font-weight: 600; text-align: center; }
.formats dl {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px 12px;
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.45;
}
.formats dt { font-weight: 600; }
.formats dd { margin: 0; }

/* ---------- Info / FAQ ---------- */
.info { padding-block: 24px 8px; text-align: center; }
.info h2 { margin: 0 0 14px; font-size: 1.25rem; font-weight: 600; }
.faq-list { display: flex; flex-direction: column; gap: 8px; max-width: 640px; margin-inline: auto; text-align: left; }
.faq { border-radius: 10px; background: var(--ink); color: var(--bg); }
.faq summary {
  position: relative;
  list-style: none;
  padding: 14px 48px 14px 16px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 10px;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "";
  position: absolute; right: 18px; top: 50%;
  width: 14px; height: 14px;
  transform: translateY(-50%);
  background:
    linear-gradient(currentColor, currentColor) center / 14px 2px no-repeat,
    linear-gradient(currentColor, currentColor) center / 2px 14px no-repeat;
  transition: background-size 0.2s;
}
.faq[open] summary::after {
  background:
    linear-gradient(currentColor, currentColor) center / 14px 2px no-repeat,
    linear-gradient(currentColor, currentColor) center / 2px 0 no-repeat;
}
.faq summary:hover { background: #373456; }
.faq[open] summary:hover { border-radius: 10px 10px 0 0; }
.faq-body { padding: 0 16px 16px; font-size: 0.9375rem; }
.faq-body p { margin: 0; }
.faq-body p + p { margin-top: 10px; }

/* ---------- Footer ---------- */
.site-footer { margin-top: 24px; background: var(--ink); color: var(--bg); text-align: center; font-size: 0.875rem; }
.site-footer .wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; padding-block: 14px 24px; }
.site-footer p { margin: 0; }
.link-btn {
  padding: 0;
  font: inherit;
  color: var(--yellow);
  background: none;
  border: 0;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  cursor: pointer;
}
.link-btn:hover, .link-btn:focus-visible { color: var(--orange); }

/* ---------- Cookie banner ---------- */
.cookie-banner {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  max-height: 25vh;
  max-height: 25dvh;            /* phones and tablets: at most 25% of the screen */
  overflow-y: auto;
  padding: 8px 16px calc(8px + env(safe-area-inset-bottom, 0px));
  background: var(--bg);
  border-top: 2px solid var(--ink);
  box-shadow: 0 -6px 20px rgba(31, 29, 48, 0.08);
}
.cookie-inner {
  max-width: 768px;
  margin-inline: auto;
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 6px 16px;
}
.cookie-text { flex: 1 1 280px; margin: 0; font-size: 0.78rem; line-height: 1.4; text-align: left; }
.cookie-actions { display: flex; gap: 8px; flex: 1 1 100%; }
.cookie-actions .btn { flex: 1; min-height: 34px; padding: 4px 14px; font-size: 0.8125rem; }
@media (min-width: 600px) {
  .cookie-actions { flex: 0 0 auto; }
  .cookie-actions .btn { flex: none; }
}
@media (min-width: 1025px) {
  .cookie-banner { max-height: 10vh; max-height: 10dvh; }   /* desktop: at most 10% */
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}