:root {
  color: #27304b;
  background: #f7f7fc;
  font-family: Inter, "Noto Sans SC", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
  --ink: #27304b;
  --muted: #72788e;
  --canvas: #ffffff;
  --page: #f7f7fc;
  --surface-muted: #f3f2ff;
  --line: #e2e4ef;
  --line-strong: #cfd3e3;
  --accent: #6257d9;
  --accent-strong: #4e44be;
  --accent-soft: #eeecff;
  --focus: #0f7bcb;
  --shadow: 0 24px 60px rgb(39 48 75 / 12%);
  --shadow-soft: 0 10px 28px rgb(39 48 75 / 8%);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--page);
}

body {
  position: relative;
  isolation: isolate;
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background: radial-gradient(circle at 12% 0%, #ffffff 0, transparent 32rem), var(--page);
}

body::before,
body::after {
  position: fixed;
  z-index: -1;
  display: block;
  width: 18rem;
  height: 18rem;
  border-radius: 50%;
  content: "";
  filter: blur(1px);
  pointer-events: none;
}

body::before {
  top: 8rem;
  right: -9rem;
  background: rgb(220 216 255 / 42%);
}

body::after {
  bottom: -9rem;
  left: -8rem;
  background: rgb(255 227 221 / 38%);
}

button,
input,
select {
  font: inherit;
}

button,
input,
select,
.mode-panel,
.preview-card,
.font-option-card {
  transition: border-color 160ms ease, background-color 160ms ease, box-shadow 160ms ease, color 160ms ease, transform 160ms ease;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
.font-option input:focus-visible + .font-option-card {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.app-shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: clamp(48px, 8vw, 86px) 0 40px;
}

.hero {
  max-width: 720px;
  margin-bottom: 34px;
}

.hero-kicker {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.brand-mark {
  display: grid;
  width: 30px;
  height: 30px;
  border-radius: 10px;
  background: var(--accent);
  color: #ffffff;
  place-items: center;
  box-shadow: 0 8px 18px rgb(98 87 217 / 28%);
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.16em;
}

h1,
h2,
p {
  margin-top: 0;
}

h1,
h2 {
  color: var(--ink);
  line-height: 1.12;
}

h1 {
  margin-bottom: 14px;
  font-size: clamp(2.45rem, 6vw, 4.4rem);
  letter-spacing: -0.055em;
}

h2 {
  margin-bottom: 0;
  font-size: 1.42rem;
  letter-spacing: -0.025em;
}

.hero-lede {
  margin-bottom: 18px;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.16rem);
  line-height: 1.65;
}

.hero-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.hero-tags span {
  padding: 7px 11px;
  border: 1px solid #dedcff;
  border-radius: 999px;
  background: rgb(255 255 255 / 68%);
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 700;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(310px, 0.84fr) minmax(0, 1.16fr);
  gap: 26px;
  align-items: start;
}

.controls-card,
.preview-card {
  border: 1px solid rgb(255 255 255 / 82%);
  border-radius: 28px;
  background: rgb(255 255 255 / 84%);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.controls-card {
  padding: 22px;
}

.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 6px;
  border: 1px solid #e6e4f8;
  border-radius: 16px;
  background: var(--surface-muted);
}

.mode-tabs button {
  min-height: 44px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.mode-tabs button:hover,
.mode-tabs button.is-active {
  background: var(--canvas);
  color: var(--ink);
  box-shadow: var(--shadow-soft);
  transform: translateY(-1px);
}

.mode-panel {
  display: grid;
  gap: 15px;
  padding-top: 24px;
}

.mode-panel[data-mode="draw"],
.mode-panel[data-mode="type"] {
  grid-template-columns: 1fr;
}

.mode-panel[hidden] {
  display: none;
}

.mode-panel.is-active {
  animation: panel-in 180ms ease-out;
}

.panel-intro {
  display: grid;
  gap: 5px;
  margin-bottom: 2px;
}

.panel-intro p:last-child {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.5;
}

.panel-kicker {
  margin-bottom: 0;
  color: var(--accent-strong);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.12em;
}

#signatureCanvas {
  width: 100%;
  height: 210px;
  min-height: 210px;
  border: 1px dashed #bbc2d7;
  border-radius: 18px;
  background-color: #fcfcff;
  background-image: linear-gradient(rgb(98 87 217 / 5%) 1px, transparent 1px), linear-gradient(90deg, rgb(98 87 217 / 5%) 1px, transparent 1px);
  background-position: -1px -1px;
  background-size: 24px 24px;
  box-shadow: inset 0 1px 8px rgb(39 48 75 / 4%);
  touch-action: none;
}

.field-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: center;
}

.color-row {
  grid-template-columns: 1fr auto;
}

label,
legend {
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 800;
}

input[type="text"],
select {
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgb(255 255 255 / 88%);
  color: var(--ink);
  box-shadow: inset 0 1px 2px rgb(39 48 75 / 3%);
}

input[type="text"]::placeholder {
  color: #a2a6b5;
}

input[type="text"]:hover,
select:hover {
  border-color: var(--line-strong);
}

input[type="color"] {
  width: 44px;
  height: 36px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--canvas);
  cursor: pointer;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

output {
  min-width: 42px;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: right;
}

.font-picker {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.field-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.field-heading legend {
  padding: 0;
}

#fontStyleValue {
  min-width: 0;
  padding: 5px 9px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.72rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.font-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.font-option {
  position: relative;
  display: block;
  min-width: 0;
}

.font-option input {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
  opacity: 0;
}

.font-option-card {
  display: grid;
  min-height: 84px;
  padding: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgb(255 255 255 / 66%);
  box-shadow: 0 3px 10px rgb(39 48 75 / 3%);
}

.font-option-card:hover {
  border-color: #bbb5f2;
  background: #ffffff;
  transform: translateY(-2px);
}

.font-option input:checked + .font-option-card {
  border-color: var(--accent);
  background: linear-gradient(145deg, #ffffff, var(--accent-soft));
  box-shadow: 0 8px 20px rgb(98 87 217 / 15%);
}

.font-option-sample {
  align-self: center;
  overflow: hidden;
  color: var(--ink);
  font-size: 1.34rem;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.font-option-name {
  margin-top: 8px;
  color: var(--ink);
  font-size: 0.77rem;
  font-weight: 800;
}

.font-option-meta {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.68rem;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.button-row button {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgb(255 255 255 / 82%);
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 800;
}

.button-row button:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
  transform: translateY(-1px);
}

.preview-card {
  position: relative;
  min-height: 548px;
  padding: clamp(24px, 4vw, 34px);
  overflow: hidden;
}

.preview-card::before {
  position: absolute;
  top: -7rem;
  right: -5rem;
  width: 17rem;
  height: 17rem;
  border-radius: 50%;
  background: rgb(235 232 255 / 50%);
  content: "";
  pointer-events: none;
}

.preview-heading,
.export-area {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.preview-heading .eyebrow {
  margin-bottom: 7px;
}

.transparent-badge {
  padding: 7px 10px;
  border: 1px solid #d6d1ff;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.75rem;
  font-weight: 800;
  white-space: nowrap;
}

.preview-frame {
  position: relative;
  display: grid;
  min-height: 360px;
  margin: 26px 0;
  overflow: hidden;
  border: 1px solid #e1e3ee;
  border-radius: 20px;
  place-items: center;
  background-color: #ffffff;
  background-image: linear-gradient(45deg, #eef0f5 25%, transparent 25%), linear-gradient(-45deg, #eef0f5 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #eef0f5 75%), linear-gradient(-45deg, transparent 75%, #eef0f5 75%);
  background-position: 0 0, 0 14px, 14px -14px, -14px 0;
  background-size: 28px 28px;
  box-shadow: inset 0 1px 8px rgb(39 48 75 / 5%);
}

#previewCanvas {
  width: 100%;
  height: 100%;
}

#emptyHint {
  position: absolute;
  max-width: 250px;
  margin: 0;
  padding: 11px 14px;
  border: 1px solid rgb(255 255 255 / 82%);
  border-radius: 12px;
  background: rgb(255 255 255 / 78%);
  color: var(--muted);
  line-height: 1.55;
  text-align: center;
  box-shadow: 0 6px 18px rgb(39 48 75 / 5%);
  backdrop-filter: blur(8px);
}

#statusMessage {
  display: flex;
  align-items: center;
  min-height: 40px;
  margin-bottom: 0;
  padding: 9px 12px;
  border: 1px solid #e7e5f8;
  border-radius: 12px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.4;
}

#downloadButton {
  min-height: 48px;
  padding: 0 20px;
  border: 1px solid var(--accent);
  border-radius: 13px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 800;
  white-space: nowrap;
  box-shadow: 0 10px 22px rgb(98 87 217 / 24%);
}

#downloadButton:not(:disabled):hover {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
  transform: translateY(-2px);
}

.privacy-note {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 28px auto 0;
  color: var(--muted);
  font-size: 0.84rem;
  text-align: center;
}

.privacy-note span:first-child {
  color: var(--accent);
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 28px, 560px);
    padding-top: 42px;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .controls-card,
  .preview-card {
    border-radius: 22px;
  }

  .controls-card {
    padding: 18px;
  }

  .preview-card {
    min-height: 0;
    padding: 20px;
  }

  .preview-frame {
    min-height: 260px;
  }

  .preview-heading,
  .export-area {
    align-items: flex-start;
    flex-direction: column;
  }

  #downloadButton {
    width: 100%;
  }
}

@media (max-width: 420px) {
  .font-grid {
    gap: 8px;
  }

  .font-option-card {
    min-height: 78px;
    padding: 10px;
  }

  .font-option-sample {
    font-size: 1.18rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
