:root {
  --paper: #f3efe6;
  --ink: #141414;
  --muted: #3e3933;
  --line: #ddd4c6;
  --white: #fffdf8;
  --red: #b10d0a;
  --red-hot: #e10600;
  --safe-bg: #e4f6ea;
  --safe: #0c5c32;
  --shadow: 0 22px 50px rgba(20, 20, 20, 0.08);
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: auto; }
body { overflow-anchor: none; }
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 100% -10%, rgba(225, 6, 0, 0.09), transparent 60%),
    radial-gradient(700px 380px at -10% 8%, rgba(29, 78, 216, 0.07), transparent 55%),
    var(--paper);
  line-height: 1.45;
}
img { max-width: 100%; height: auto; display: block; }
button, input { font: inherit; color: inherit; }
a { color: inherit; }
::selection { background: #ffd2cc; }

.skip {
  position: absolute;
  left: 12px;
  top: -60px;
  background: var(--white);
  padding: 10px 12px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  z-index: 5;
}
.skip:focus { top: 12px; }

.stripe { display: flex; height: 8px; }
.stripe i { flex: 1; display: block; }
.stripe i:nth-child(1) { background: #ff3b30; }
.stripe i:nth-child(2) { background: #ff7a00; }
.stripe i:nth-child(3) { background: #ffd000; }
.stripe i:nth-child(4) { background: #3dcc6e; }
.stripe i:nth-child(5) { background: #0f8a4b; }
.stripe i:nth-child(6) { background: #1d4ed8; }
.stripe i:nth-child(7) { background: #6d4aff; }
.stripe i:nth-child(8) { background: #141414; }

.wrap {
  width: min(1120px, calc(100% - 32px));
  margin-inline: auto;
}

.header-bar, .footer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.header-bar { min-height: 64px; }
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 6px 0;
  font-weight: 800;
  letter-spacing: -0.04em;
  font-size: 1.15rem;
  text-decoration: none;
}
.mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--red);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 0.95rem;
}
.nav, .footer-bar nav { display: flex; align-items: center; gap: 4px; }
.nav a, .footer-bar a {
  text-decoration: none;
  font-weight: 650;
  padding: 10px 8px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  border-radius: 8px;
}
.nav a:hover, .footer-bar a:hover { text-decoration: underline; text-underline-offset: 3px; }
.nav a[aria-current="page"] { text-decoration: underline; text-underline-offset: 3px; }

.hero { padding: 8px 0 8px; }
h1 {
  margin: 0;
  font-size: clamp(2.05rem, 5.2vw, 3.5rem);
  line-height: 0.96;
  letter-spacing: -0.045em;
  font-weight: 800;
  max-width: 16em;
  text-wrap: balance;
}
.lede {
  margin: 14px 0 0;
  font-size: 1.12rem;
  max-width: 38rem;
  color: var(--muted);
}
.privacy-note {
  margin: 18px 0 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--safe-bg);
  color: var(--safe);
  font-weight: 700;
  border-radius: 999px;
  padding: 8px 12px 8px 10px;
  max-width: 100%;
}
.privacy-note span { min-width: 0; }
.privacy-note svg { flex: 0 0 auto; }

.card {
  margin-top: 16px;
  background: var(--white);
  border: 2px solid var(--ink);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 14px;
}
.choose {
  width: 100%;
  min-height: 200px;
  border: 0;
  border-radius: 18px;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  padding: 28px 16px;
  cursor: pointer;
}
.idle.hot .choose,
.idle.hot { background: #fff4f2; }
.idle {
  border-radius: 18px;
  outline: 2px dashed transparent;
}
.idle.hot { outline-color: var(--red-hot); }
.dots { display: flex; gap: 8px; margin-bottom: 8px; }
.dots span {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #fff;
}
.dots span:nth-child(1) { background: #e10600; }
.dots span:nth-child(2) { background: #ffd000; color: #141414; }
.dots span:nth-child(3) { background: #1d4ed8; }
.choose-title { font-size: clamp(1.45rem, 4vw, 2rem); font-weight: 800; letter-spacing: -0.03em; }
.choose-sub { color: var(--muted); margin: 0; }
.btn, .choose .cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 12px 18px;
  border-radius: 999px;
  font-weight: 750;
  border: 2px solid var(--ink);
  cursor: pointer;
  text-decoration: none;
}
.choose .cta { margin-top: 10px; background: var(--ink); color: #fff; }
.btn-pdf { background: var(--red); border-color: var(--red); color: #fff; }
.btn-pdf:hover { background: #8e0b08; }
.btn-ghost { background: #fff; color: var(--ink); }
.btn-ghost:hover { background: var(--ink); color: #fff; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:disabled:hover { background: inherit; color: inherit; }
.btn-pdf:disabled:hover { background: var(--red); color: #fff; }
.btn-update { background: var(--ink); color: #fff; border: 2px solid var(--ink); margin-top: 12px; }
.file {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  border: 0;
}

.busy {
  min-height: 270px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 28px 18px 22px;
}
.busy-label { margin: 0; font-size: 1.45rem; font-weight: 800; letter-spacing: -0.03em; }
.bar {
  margin-top: 14px;
  height: 10px;
  background: #efe8dc;
  border-radius: 99px;
  overflow: hidden;
}
.bar span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--red);
  border-radius: 99px;
  transition: width 0.35s ease;
}
.phases { list-style: none; padding: 0; margin: 16px 0 0; }
.phases li {
  position: relative;
  padding: 4px 0 4px 22px;
  color: #8a8176;
}
.phases li::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ddd4c6;
  position: absolute;
  left: 0;
  top: 0.55em;
}
.phases li.on { color: var(--ink); font-weight: 800; }
.phases li.on::before { background: var(--red); }
.phases li.done { color: var(--safe); }
.phases li.done::before { background: var(--safe); }

.alert {
  margin: 0 0 12px;
  background: #fff1ef;
  color: #8d120f;
  border-radius: 12px;
  padding: 12px 14px;
  font-weight: 700;
}

.result-top { display: grid; gap: 12px; }
.toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: #f3efe6;
  padding: 4px;
  border-radius: 999px;
}
.toggle button {
  border: 0;
  background: transparent;
  min-height: 44px;
  border-radius: 999px;
  font-weight: 750;
  cursor: pointer;
}
.toggle button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.downloads { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.downloads .btn-pdf { grid-column: 1 / -1; }
.ready {
  margin: 4px 0;
  color: var(--muted);
  font-weight: 650;
  line-height: 1.3;
  height: 2.7em;
  min-height: 2.7em;
  overflow: hidden;
}
.ready:focus { outline: none; }
.frame {
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.frame canvas { width: 100%; height: auto; display: block; }
.palette-title { margin: 16px 0 8px; font-weight: 800; letter-spacing: -0.03em; font-size: 1.15rem; }
.palette {
  --pal-cols: 4;
  --pal-rows: 4;
  --pal-row: 64px;
  --pal-gap: 10px;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(var(--pal-cols), minmax(0, 1fr));
  align-content: start;
  gap: var(--pal-gap);
  min-height: calc(var(--pal-rows) * var(--pal-row) + (var(--pal-rows) - 1) * var(--pal-gap));
  padding: 0;
  margin: 0;
}
.palette li { min-width: 0; height: var(--pal-row); overflow: hidden; text-align: center; }
.is-skeleton .hex { color: transparent; }
.chip {
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 1rem;
}
.hex {
  display: block;
  margin-top: 4px;
  height: 16px;
  font-size: 12px;
  line-height: 16px;
  letter-spacing: 0;
  text-transform: uppercase;
  color: var(--muted);
}
.notice {
  margin: 0 0 8px;
  background: #fff6d8;
  color: #3e3208;
  border-radius: 12px;
  padding: 10px 12px;
  font-weight: 650;
}
.linkish {
  margin-top: 8px;
  background: none;
  border: 0;
  padding: 10px 0;
  font-weight: 750;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  min-height: 44px;
}

.settings { margin-top: 14px; background: var(--white); border: 1px solid var(--line); border-radius: 18px; }
.settings summary {
  cursor: pointer;
  list-style: none;
  padding: 6px 14px;
  min-height: 56px;
  height: 56px;
  box-sizing: border-box;
  display: flex;
  justify-content: space-between;
  gap: 8px 12px;
  align-items: center;
  flex-wrap: wrap;
  overflow: hidden;
  font-weight: 800;
  line-height: 1.25;
}
.settings summary::-webkit-details-marker { display: none; }
.sum-value {
  flex: 1 1 100%;
  font-size: 0.92rem;
  font-weight: 550;
  color: var(--muted);
  text-align: left;
  white-space: nowrap;
}
.settings-body { padding: 0 16px 16px; display: grid; gap: 14px; }
.slider-top, .seg-label { display: flex; justify-content: space-between; font-weight: 750; margin-bottom: 6px; }
input[type="range"] { width: 100%; accent-color: var(--red); height: 44px; }
.pair { display: grid; gap: 12px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.seg button {
  min-height: 44px;
  border-radius: 12px;
  border: 1.5px solid var(--ink);
  background: #fff;
  font-weight: 750;
  cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--ink); color: #fff; }

.seo { padding-bottom: 28px; }
.seo h2 {
  font-size: clamp(1.45rem, 3vw, 2rem);
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin: 2.4rem 0 0.55rem;
  max-width: 22em;
  text-wrap: balance;
}
.seo p, .seo li { font-size: 1.05rem; max-width: 68ch; }
.steps { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 16px; }
.steps li { display: grid; grid-template-columns: 42px 1fr; gap: 12px; align-items: start; }
.steps .num {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
}
.steps h3 { margin: 8px 0 4px; font-size: 1.1rem; }
.steps p { margin: 0; }
.ba { display: grid; gap: 14px; margin-top: 14px; }
.ba figure { margin: 0; background: var(--white); border-radius: 16px; padding: 8px; border: 1px solid var(--line); }
.ba img { width: 100%; border-radius: 10px; background: #fff; }
.ba figcaption { padding: 8px 6px 4px; font-size: 0.92rem; color: var(--muted); }
.tips { padding-left: 1.1rem; }
.tips li { margin: 0.4rem 0; }
.faq h3 { margin: 1.1rem 0 0.25rem; font-size: 1.08rem; text-wrap: balance; }
.faq p { margin: 0; }
.faq a, .prose a, .credit a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 2px;
}
.credit { font-size: 0.92rem; color: var(--muted); }

.site-footer { border-top: 1px solid var(--line); margin-top: 20px; padding: 18px 0 28px; }
.footer-bar { align-items: flex-start; flex-wrap: wrap; }
.footer-bar nav { flex-wrap: wrap; }
.footer-bar p { margin: 8px 0; color: var(--muted); }

.prose { padding: 12px 0 36px; max-width: 68ch; }
.prose h1 {
  font-size: clamp(2rem, 5vw, 3.1rem);
  max-width: none;
  margin: 0.2em 0 0.45em;
}
.prose h2 { font-size: 1.25rem; letter-spacing: -0.03em; margin: 1.5em 0 0.35em; }
.prose a { font-weight: 750; }

:focus-visible { outline: 3px solid var(--red-hot); outline-offset: 3px; }

@media (min-width: 520px) {
  .pair { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 720px) {
  .card { padding: 18px; }
  .choose, .busy { min-height: 240px; }
  .settings-body { grid-template-columns: 1fr 1fr; }
  .pair { grid-column: 1 / -1; }
}
@media (min-width: 840px) {
  .ba { grid-template-columns: 1fr 1fr 1fr; }
}
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
#idle,
.result-preview {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
#busy {
  position: absolute;
  inset: 0;
  z-index: 2;
  min-height: 0;
  margin: 0;
  padding: 0;
  display: block;
  background: rgba(255, 253, 248, 0.94);
  border-radius: inherit;
}
#busy .busy-label {
  position: absolute;
  left: 24px;
  right: 24px;
  top: 50%;
  margin: 0;
  transform: translateY(-50%);
  text-align: center;
}
#busy .busy-label::before {
  content: "";
  display: block;
  width: 36px;
  height: 36px;
  margin: 0 auto 12px;
  border-radius: 50%;
  border: 3px solid #e6dfd3;
  border-top-color: var(--red);
  animation: photopbn-spin 0.8s linear infinite;
}
#busy .bar {
  position: absolute;
  left: 48px;
  right: 48px;
  top: calc(50% + 52px);
  width: auto;
  margin: 0;
}
#busy .phases { display: none; }
@keyframes photopbn-spin { to { transform: rotate(360deg); } }
.result-preview {
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
  background: #e4ddd0;
}
.result-preview .frame {
  position: relative;
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  max-width: 100%;
  min-height: 0;
  margin: 0;
  background: #e4ddd0;
}
.result-preview canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: contain;
  background: #e4ddd0;
}
.result-tools.is-held { visibility: hidden; }
.skeleton-chip { background: #e6dfd3; color: transparent; }
@media (max-width: 1099px) {
  .studio { display: flex; flex-direction: column; align-items: stretch; }
  .card {
    order: 1;
    width: 100%;
    aspect-ratio: 3 / 4;
    height: auto;
    min-height: 0;
    flex: 0 0 auto;
    overflow: hidden;
  }
  .card[data-state="busy"],
  .card[data-state="result"] { aspect-ratio: 1 / 1; }
  .choose, .busy, .result-preview { min-height: 0; height: 100%; }
  .result-tools { order: 2; overflow: visible; max-height: none; }
  .result-tools.is-held { display: none; }
  .side { order: 3; }
}
@media (min-width: 1100px) {
  .header-bar { min-height: 52px; }
  h1 { font-size: 2.2rem; max-width: none; }
  .lede { margin-top: 6px; font-size: 1.02rem; }
  .privacy-note { margin-top: 8px; }
  .studio {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
    grid-template-rows: auto auto;
    grid-template-areas:
      "preview settings"
      "preview tools";
    column-gap: 14px;
    row-gap: 6px;
    align-items: start;
    align-content: start;
    justify-items: stretch;
    margin-top: 8px;
    min-height: 0;
  }
  .studio .card {
    grid-area: preview;
    align-self: stretch;
    margin-top: 0;
    min-height: 0;
    height: auto;
    max-height: none;
    overflow: hidden;
    width: 100%;
  }
  .choose, .busy { min-height: 0; height: 100%; }
  .result-tools {
    grid-area: tools;
    align-self: start;
    max-height: none;
    overflow: visible;
  }
  .side { grid-area: settings; align-self: start; display: block; }
  .settings { margin-top: 0; }
  .settings summary { min-height: 56px; height: 56px; }
  .result-top { gap: 8px; }
  .palette-title { margin: 4px 0 4px; font-size: 1rem; }
  .palette { --pal-row: 52px; --pal-gap: 6px; }
  .chip { height: 34px; }
  .hex { margin-top: 2px; }
}
@media (max-width: 520px) {
  .footer-bar { flex-direction: column; align-items: flex-start; gap: 0; }
}
@media (max-width: 389px) {
  .wrap { width: min(1120px, calc(100% - 24px)); }
  .header-bar { gap: 8px; }
  .nav { gap: 0; }
  .nav a { padding: 10px 4px; font-size: 0.82rem; }
  .brand { font-size: 1rem; gap: 6px; }
  .choose { min-height: 240px; padding: 22px 12px; }
  h1 { font-size: 2.05rem; }
  .sum-value { font-size: 0.92rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .bar span { transition: none; }
  #busy .busy-label::before { animation: none; }
}
