:root {
  color-scheme: light;
  --bg: #f3f0e8;
  --paper: #fbfaf6;
  --ink: #171717;
  --muted: #6d6960;
  --line: #d9d4c8;
  --soft: #ebe7dd;
  --button-ink: #fbfaf6;
  --dot: rgba(23, 23, 23, .08);
  --warning: #98501e;
  --error: #b42d2d;
  --preview-site-color: #285f58;
  --shadow: 0 18px 50px rgba(32, 28, 20, .07);
  --duration-fast: 140ms;
  --duration-ui: 200ms;
  --duration-panel: 240ms;
  --ease-out: cubic-bezier(.23, 1, .32, 1);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #141412;
  --paper: #1c1c19;
  --ink: #f3efe5;
  --muted: #aaa59a;
  --line: #34332e;
  --soft: #262620;
  --button-ink: #151513;
  --dot: rgba(255, 255, 255, .07);
  --warning: #d99058;
  --error: #ef7c75;
  --preview-site-color: #e2b86d;
  --shadow: 0 18px 50px rgba(0, 0, 0, .22);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Helvetica Neue", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  line-height: 1.5;
  transition: background-color var(--duration-ui), color var(--duration-ui);
}
body.export-open { overflow: hidden; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
button:disabled { cursor: wait; opacity: .6; }
[hidden] { display: none !important; }
.shell { width: min(1040px, calc(100% - 40px)); margin-inline: auto; }

.site-header {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.brand {
  color: inherit;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .06em;
  text-decoration: none;
  text-transform: uppercase;
}
.header-actions, .language-switch { display: flex; align-items: center; gap: 8px; }
.language-switch {
  gap: 0;
  min-height: 44px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
}
.language-switch button {
  min-width: 44px;
  height: 44px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
}
.language-switch button[aria-pressed="true"] { background: var(--ink); color: var(--button-ink); }
.icon-button, .text-button { border: 0; background: transparent; cursor: pointer; }
.icon-button {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
}
.button-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.button-with-icon { display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.hero { max-width: 760px; padding: 94px 0 84px; }
h1, h2, h3, p { margin-top: 0; }
h1 {
  max-width: 700px;
  margin-bottom: 20px;
  font-family: Georgia, "Songti SC", serif;
  font-size: clamp(42px, 8vw, 76px);
  font-weight: 400;
  letter-spacing: -.025em;
  line-height: 1.05;
}
.hero > p:last-child { max-width: 540px; color: var(--muted); font-size: 16px; }
.showcase, .maker { margin-bottom: 110px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 18px; }
.section-heading h2, .export-header h2 {
  margin-bottom: 0;
  font-family: Georgia, "Songti SC", serif;
  font-size: clamp(26px, 4vw, 38px);
  font-weight: 400;
}
.section-note { margin: 0; color: var(--muted); font-size: 13px; }
.text-button { min-height: 44px; padding: 6px 0; border-bottom: 1px solid currentColor; font-size: 13px; }
.paper {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  background:
    linear-gradient(var(--dot) 1px, transparent 1px),
    linear-gradient(90deg, var(--dot) 1px, transparent 1px),
    var(--paper);
  background-size: 22px 22px;
  box-shadow: var(--shadow);
  transition: background-color var(--duration-ui), border-color var(--duration-ui), box-shadow var(--duration-ui);
}
.paper::after {
  position: absolute;
  inset: 0;
  border: 8px solid color-mix(in srgb, var(--paper) 86%, transparent);
  content: "";
  pointer-events: none;
}
.stage { min-height: 370px; display: grid; place-items: center; }
.showcase-paper { min-height: 300px; display: grid; place-items: center; }
.paper svg.signature-svg { display: block; width: min(92%, 900px); height: auto; opacity: 0; transition: opacity var(--duration-panel) var(--ease-out); }
.paper svg.signature-svg.is-visible { opacity: 1; }
.empty-state { color: var(--muted); font-size: 13px; }
.stage-loading {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  color: var(--muted);
  font-size: 12px;
  backdrop-filter: blur(2px);
  animation: fade-in var(--duration-ui) both;
}
.spinner { width: 16px; height: 16px; border: 1.5px solid var(--line); border-top-color: var(--ink); border-radius: 50%; animation: spin .8s linear infinite; }
.toolbar { display: flex; gap: 8px; align-items: center; justify-content: center; padding: 16px 0 30px; }
.toolbar button, .url-form button, .export-action {
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--paper);
  cursor: pointer;
  transition: background-color var(--duration-fast), border-color var(--duration-fast), transform var(--duration-fast);
}
.primary-button { border-color: var(--ink) !important; background: var(--ink) !important; color: var(--button-ink); }
.settings {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
  padding: 28px;
  border: 1px solid var(--line);
  background: var(--paper);
  transition: background-color var(--duration-ui), border-color var(--duration-ui);
}
.control { min-width: 0; display: flex; flex-direction: column; gap: 7px; }
.playback-control { min-width: 0; margin: 0; padding: 0; border: 0; }
.playback-control legend { margin-bottom: 7px; padding: 0; color: var(--muted); font-size: 12px; }
.playback-control .choice-grid { grid-template-columns: 1fr 1fr; gap: 6px; }
.playback-control .choice-grid label { min-width: 0; min-height: 44px; padding: 8px; font-size: 11px; }
.control-label { min-height: 20px; display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 12px; }
.control-label output, .control-label span { color: var(--ink); }
.field-row { min-height: 44px; display: flex; align-items: center; }
.control small { min-height: 18px; color: var(--muted); font-size: 10px; }
input[type="text"], input[type="url"], select {
  width: 100%;
  height: 44px;
  padding: 0 10px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  transition: border-color var(--duration-fast), background-color var(--duration-fast);
}
input[type="text"]:focus, input[type="url"]:focus, select:focus { border-bottom-color: var(--ink); }
.color-control { gap: 10px; }
input[type="color"] {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
}
.color-control input[type="text"] { min-width: 0; font: 12px ui-monospace, SFMono-Regular, monospace; text-transform: uppercase; }
.color-control input.is-invalid { border-color: var(--error); }
.field-error { color: var(--error) !important; }
.range-row { padding-inline: 2px; }
input[type="range"] {
  --range-progress: 0%;
  width: 100%;
  height: 44px;
  margin: 0;
  appearance: none;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(to right, var(--ink) 0 var(--range-progress), var(--line) var(--range-progress) 100%);
}
input[type="range"]::-webkit-slider-thumb {
  width: 18px; height: 18px; margin-top: -7px; appearance: none;
  border: 2px solid var(--paper); border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 1px var(--ink);
}
input[type="range"]::-moz-range-track { height: 4px; border-radius: 999px; background: var(--line); }
input[type="range"]::-moz-range-progress { height: 4px; border-radius: 999px; background: var(--ink); }
input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; border: 2px solid var(--paper); border-radius: 50%; background: var(--ink); }
.message { min-height: 40px; padding: 10px 2px; color: var(--muted); font-size: 12px; opacity: 0; transition: opacity var(--duration-ui); }
.message.is-visible { opacity: 1; }
.message.is-warning { color: var(--warning); }
.message.is-error { color: var(--error); }
.custom-font-panel {
  margin-top: 0;
  padding: 20px;
  border: 1px solid var(--line);
  background: var(--paper);
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity var(--duration-panel), transform var(--duration-panel) var(--ease-out);
}
.custom-font-panel.is-open { opacity: 1; transform: none; }
.file-row input { max-width: 100%; }
.url-form { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 12px; margin-top: 18px; }
.font-picker { position: relative; min-width: 0; }
.font-picker-trigger {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 10px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}
.font-picker-value { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.font-picker-trigger[aria-expanded="true"] { border-bottom-color: var(--ink); }
.font-picker-trigger[aria-expanded="true"] .select-chevron { transform: rotate(180deg); }
.font-picker-popover {
  position: absolute;
  z-index: 10;
  top: calc(100% + 7px);
  inset-inline: 0;
  width: auto;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--paper);
  box-shadow: 0 10px 24px rgba(0, 0, 0, .14);
}
.font-picker-list { max-height: 392px; overflow-y: auto; padding: 5px; }
.font-option {
  width: 100%;
  min-height: 76px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(110px, .9fr);
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border: 0;
  border-radius: 2px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
}
.font-option[aria-selected="true"] { background: var(--soft); box-shadow: inset 0 0 0 1px var(--ink); }
.font-option:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; }
.font-meta { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.font-preview {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin-top: 4px;
  font-family: cursive;
  font-size: 27px;
  line-height: 1.35;
  text-align: center;
  white-space: nowrap;
}
.font-preview svg { display: block; width: 100%; height: 48px; margin-inline: auto; }
.font-picker-footer { padding: 4px 10px; border-top: 1px solid var(--line); }
.font-picker-footer .text-button { width: 100%; justify-content: flex-start; }
.site-footer { padding: 30px 0 54px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.site-footer p { max-width: 850px; margin-bottom: 8px; }
.back-to-top {
  position: fixed;
  z-index: 8;
  right: max(20px, env(safe-area-inset-right));
  bottom: calc(20px + env(safe-area-inset-bottom));
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity var(--duration-ui), transform var(--duration-ui) var(--ease-out);
}
.back-to-top.is-visible { opacity: 1; pointer-events: auto; transform: none; }
.back-to-top svg { width: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.export-scrim { position: fixed; z-index: 20; inset: 0; background: rgba(10, 10, 9, .38); backdrop-filter: blur(2px); animation: fade-in var(--duration-ui) both; }
.export-panel {
  position: fixed;
  z-index: 21;
  top: 0;
  right: 0;
  width: min(480px, 100%);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
  border-left: 1px solid var(--line);
  background: var(--paper);
  box-shadow: -8px 0 22px rgba(0, 0, 0, .12);
  transform: translateX(100%);
  transition: transform var(--duration-panel) var(--ease-out);
}
.export-panel.is-open { transform: none; }
.export-header { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 28px 28px 20px; border-bottom: 1px solid var(--line); background: var(--paper); }
.export-header h2 { font-size: 30px; }
.export-body { min-height: 0; flex: 1 1 auto; overflow-y: auto; padding: 20px 28px 28px; overscroll-behavior: contain; }
.export-warning { margin-bottom: 14px; padding: 10px 12px; border: 1px solid color-mix(in srgb, var(--warning) 45%, var(--line)); color: var(--warning); font-size: 12px; }
.export-preview { margin-bottom: 20px; }
.export-preview-header {
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.export-preview-header h3 {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.export-preview-replay { min-height: 32px; padding-block: 2px; }
.export-preview-stage {
  position: relative;
  height: 180px;
  min-width: 0;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  overflow: hidden;
  border: 1px solid var(--line);
  background-color: var(--paper);
  transition: background-color var(--duration-fast), border-color var(--duration-fast);
}
.export-preview-stage.is-transparent {
  background-color: #f7f5ef;
  background-image:
    linear-gradient(45deg, #32322e 25%, transparent 25%),
    linear-gradient(-45deg, #32322e 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #32322e 75%),
    linear-gradient(-45deg, transparent 75%, #32322e 75%);
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
}
.export-preview-art {
  position: absolute;
  inset: 0;
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 20px 24px;
}
.export-preview-art svg {
  display: block;
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  overflow: hidden;
}
.export-preview-badges {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: flex;
  gap: 5px;
  pointer-events: none;
}
.export-preview-badges span {
  padding: 3px 6px;
  border: 1px solid color-mix(in srgb, var(--line) 82%, transparent);
  border-radius: 3px;
  background: color-mix(in srgb, var(--paper) 97%, var(--bg));
  color: var(--muted);
  font: 9px/1.2 ui-monospace, SFMono-Regular, monospace;
}
.export-crop { min-width: 0; margin: 0 0 20px; padding: 0; border: 0; }
.export-crop legend { display: block; margin-bottom: 9px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.export-tabs { display: grid; grid-template-columns: 1fr 1fr; margin-bottom: 22px; border-bottom: 1px solid var(--line); }
.export-tabs button { position: relative; min-height: 44px; padding: 0; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.export-tabs button::after { position: absolute; right: 0; bottom: -1px; left: 0; height: 2px; background: transparent; content: ""; }
.export-tabs button[aria-selected="true"] { color: var(--ink); }
.export-tabs button[aria-selected="true"]::after { background: var(--ink); }
.export-tab-panel fieldset { min-width: 0; margin: 0 0 24px; padding: 0; border: 0; }
.export-tab-panel legend, .code-preview-label { display: block; margin-bottom: 9px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.choice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.choice-grid label, .choice-stack label {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  cursor: pointer;
}
.choice-stack { display: grid; gap: 8px; }
.choice-stack small { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; font-weight: 400; }
.choice-grid label:has(input:checked), .choice-stack label:has(input:checked) { border-color: var(--ink); background: var(--soft); }
input[type="radio"] { accent-color: var(--ink); }
.theme-colors { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.theme-colors label { min-height: 44px; display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 11px; }
.theme-colors input { width: 40px; height: 40px; }
.select-row { min-height: 52px; display: grid; grid-template-columns: 1fr 140px; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); font-size: 12px; }
.select-row input[type="color"] { justify-self: end; }
.custom-select { position: relative; min-width: 0; }
.custom-select-trigger {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  transition: border-color var(--duration-fast), background-color var(--duration-fast);
}
.select-chevron {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform var(--duration-fast);
}
.custom-select-trigger[aria-expanded="true"] { border-color: var(--ink); }
.custom-select-trigger[aria-expanded="true"] .select-chevron { transform: rotate(180deg); }
.custom-select-options {
  position: absolute;
  z-index: 4;
  top: calc(100% + 5px);
  right: 0;
  left: 0;
  max-height: 220px;
  overflow-y: auto;
  margin: 0;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--paper);
  box-shadow: 0 5px 14px rgba(0, 0, 0, .1);
  list-style: none;
}
.custom-select-options li {
  min-height: 40px;
  display: flex;
  align-items: center;
  padding: 7px 9px;
  border-radius: 2px;
  color: var(--muted);
  cursor: pointer;
  outline: 0;
}
.custom-select-options li[aria-selected="true"] { background: var(--soft); color: var(--ink); }
.custom-select-options li:focus-visible { box-shadow: inset 0 0 0 1px var(--ink); color: var(--ink); }
.export-action { width: 100%; min-height: 48px; }
.code-preview { width: 100%; min-height: 260px; margin-bottom: 12px; padding: 14px; resize: vertical; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font: 11px/1.5 ui-monospace, SFMono-Regular, monospace; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade-in { from { opacity: 0; } }

@media (hover: hover) and (pointer: fine) {
  .toolbar button:hover, .url-form button:hover, .export-action:hover, .font-option:hover { background: var(--soft); }
  .custom-select-trigger:hover, .custom-select-options li:hover { background: var(--soft); color: var(--ink); }
  .back-to-top:hover { transform: translateY(-2px); }
}
button:active, .font-option:active { transform: scale(.97); }

@media (max-width: 1024px) {
  .settings { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero { padding: 76px 0 70px; }
}
@media (max-width: 599px) {
  .showcase, .maker { margin-bottom: 76px; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .settings { grid-template-columns: 1fr; padding: 20px; }
  .stage { min-height: 270px; }
  .showcase-paper { min-height: 230px; }
  .url-form { grid-template-columns: 1fr; }
  .url-form button { width: 100%; }
  .toolbar button { min-width: 120px; }
  .export-panel {
    top: auto;
    bottom: 0;
    width: 100%;
    height: min(88dvh, 760px);
    padding: 0;
    border-top: 1px solid var(--line);
    border-left: 0;
    border-radius: 18px 18px 0 0;
    transform: translateY(100%);
  }
  .export-panel.is-open { transform: none; }
  .export-header { padding: 18px 20px 14px; }
  .export-body { padding: 18px 20px calc(22px + env(safe-area-inset-bottom)); }
  .export-preview-stage { height: 150px; }
  .export-preview-art { padding: 18px 20px; }
}
@media (max-width: 389px) {
  .shell { width: calc(100% - 32px); }
  .hero { padding: 60px 0 56px; }
  .header-actions { gap: 5px; }
  .brand { font-size: 12px; }
  .settings { padding: 16px; }
  .choice-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-property: color, background-color, border-color, opacity !important; transition-duration: 80ms !important; }
  button:active, .font-option:active, .back-to-top, .export-panel, .custom-font-panel { transform: none !important; }
}
