:root {
  color-scheme: light;
  --bg: #f4f1ea;
  --surface: #fffdf8;
  --surface-strong: #ffffff;
  --ink: #1e2428;
  --muted: #667071;
  --line: #d8d2c5;
  --line-strong: #b9b09f;
  --accent: #176c4f;
  --accent-strong: #0d563d;
  --blue: #235a9f;
  --red: #a51d2d;
  --gold: #b8791a;
  --shadow: 0 4px 6px rgba(36, 38, 34, 0.04), 0 18px 48px rgba(36, 38, 34, 0.10);
  --radius: 10px;
  --content: 1220px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  scroll-behavior: smooth;
}

body {
  display: flex;
  flex-direction: column;
  margin: 0;
  min-height: 100vh;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
}

main {
  flex: 1 0 auto;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

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

a {
  color: inherit;
  text-decoration: none;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid rgba(30, 36, 40, 0.08);
  background: rgba(255, 253, 248, 0.92);
  backdrop-filter: blur(14px);
}

.header-inner {
  width: min(100% - 32px, var(--content));
  min-height: 68px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 7px;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--muted);
  font-size: 12px;
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 18px;
  color: #465050;
  font-size: 14px;
}

.top-nav a {
  padding: 8px 0;
  border-bottom: 2px solid transparent;
}

.top-nav a:hover,
.top-nav a:focus-visible {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.hero-band {
  width: min(100% - 32px, var(--content));
  margin: 34px auto 18px;
  display: grid;
  grid-template-columns: 1fr;
}

.hero-copy {
  max-width: 860px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 12px;
  font-size: 44px;
  line-height: 1.08;
}

h2 {
  margin-bottom: 8px;
  font-size: 32px;
  line-height: 1.18;
}

h3 {
  margin-bottom: 14px;
  font-size: 17px;
  font-weight: 700;
}

.hero-copy p:last-child {
  max-width: 760px;
  margin-bottom: 0;
  color: #485150;
  font-size: 17px;
}

.tool-shell {
  width: min(100% - 32px, var(--content));
  margin: 0 auto 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: clip;
}

.tool-heading {
  min-height: 96px;
  padding: 26px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
  background: #fffaf0;
}

.tool-heading h2 {
  margin-bottom: 0;
}

.tool-heading h1 {
  margin-bottom: 0;
  font-size: 32px;
  line-height: 1.18;
}

.segmented {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f7f1e6;
}

.segment {
  min-height: 36px;
  padding: 7px 14px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: #4b5552;
}

.segment.is-active {
  background: var(--surface-strong);
  color: var(--ink);
  box-shadow: 0 1px 5px rgba(32, 31, 28, 0.12);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  min-height: 660px;
}

.workspace-main {
  min-width: 0;
  border-right: 1px solid var(--line);
  background: #fbf7ee;
}

.signature-area {
  min-width: 0;
  padding: 24px;
  background: transparent;
}

.signature-area + .signature-area {
  border-top: 1px solid var(--line);
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.section-heading h3 {
  margin-bottom: 0;
}

.canvas-toolbar {
  min-height: 40px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 10px;
  border: 1px solid rgba(23, 108, 79, 0.22);
  border-radius: 999px;
  background: rgba(23, 108, 79, 0.08);
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
}

.privacy-note {
  color: var(--muted);
  font-size: 13px;
}

.canvas-frame {
  position: relative;
  min-height: 480px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background-color: #fff;
  overflow: hidden;
}

.canvas-frame[data-background="transparent"] {
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #f0ece3 25%, transparent 25%),
    linear-gradient(-45deg, #f0ece3 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f0ece3 75%),
    linear-gradient(-45deg, transparent 75%, #f0ece3 75%);
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
}

.canvas-frame[data-background="paper"] {
  background: #fff;
}

.canvas-frame[data-background="grid"] {
  background-color: #fff;
  background-image:
    linear-gradient(rgba(35, 90, 159, 0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(35, 90, 159, 0.12) 1px, transparent 1px);
  background-size: 28px 28px;
}

.signature-canvas {
  display: block;
  width: 100%;
  height: 480px;
  touch-action: none;
}

.name-input-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  margin-bottom: 18px;
}

.name-input-row label {
  font-weight: 700;
}

.name-input-row input {
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

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

.style-option {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.style-option.is-active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.style-option canvas {
  display: block;
  width: 100%;
  height: 130px;
  margin-bottom: 10px;
  border: 1px solid #ece6d9;
  border-radius: 6px;
  background:
    linear-gradient(45deg, #f5f1e9 25%, transparent 25%),
    linear-gradient(-45deg, #f5f1e9 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f5f1e9 75%),
    linear-gradient(-45deg, transparent 75%, #f5f1e9 75%);
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
}

.style-option strong,
.style-option small {
  display: block;
}

.style-option small {
  margin-top: 2px;
  color: var(--muted);
}

.control-panel {
  min-width: 0;
  padding: 22px;
  background: #fffdf8;
}

.control-section {
  padding-bottom: 20px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.control-section:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: 0;
}

.field-group {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.field-group:last-child {
  margin-bottom: 0;
}

.field-group label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #37413f;
  font-weight: 700;
}

.swatch-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.swatch,
.color-input {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--swatch);
}

.swatch.is-active {
  outline: 3px solid rgba(23, 108, 79, 0.22);
  border-color: var(--accent);
}

.color-input {
  padding: 0;
  overflow: hidden;
}

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

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

.button-grid .wide {
  grid-column: 1 / -1;
}

.tool-button,
.primary-button {
  min-height: 42px;
  padding: 9px 12px;
  border-radius: 6px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
  font-weight: 700;
}

.tool-button:hover,
.tool-button:focus-visible {
  border-color: var(--accent);
}

.tool-button:active {
  background: var(--accent);
  color: #fff;
}

.tool-button.danger {
  color: var(--red);
}

.primary-button {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.primary-button:hover,
.primary-button:focus-visible {
  background: var(--accent-strong);
}

.primary-button:active {
  background: var(--accent-strong);
  transform: scale(0.97);
}

.control-help {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
}

.content-band,
.faq-band {
  width: min(100% - 32px, var(--content));
  margin: 0 auto 42px;
}

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

.content-grid article,
.faq-inner {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 24px;
}

.content-grid p:last-child {
  margin-bottom: 0;
}

.faq-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

details {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

summary {
  min-height: 48px;
  padding: 13px 16px;
  cursor: pointer;
  font-weight: 800;
}

details p {
  margin: 0;
  padding: 0 16px 16px;
  color: #485150;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 20;
  max-width: min(420px, calc(100% - 32px));
  padding: 10px 14px;
  border-radius: 6px;
  background: #1e2428;
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translate(-50%, 16px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.noscript {
  padding: 16px;
  background: #a51d2d;
  color: #fff;
  text-align: center;
}

.site-footer {
  flex: 0 0 auto;
  padding: 8px 16px 12px;
  color: rgba(102, 112, 113, 0.48);
  font-size: 10px;
  line-height: 1.2;
  text-align: center;
}

.site-footer a {
  color: inherit;
  text-decoration: none;
}

.site-footer a:hover {
  color: rgba(102, 112, 113, 0.72);
}

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .workspace-main {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .control-panel {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
  }

  .control-section {
    padding-bottom: 0;
    margin-bottom: 0;
    border-bottom: 0;
  }

  .signature-canvas,
  .canvas-frame {
    min-height: 380px;
    height: 380px;
  }
}

@media (max-width: 720px) {
  .header-inner,
  .hero-band,
  .tool-shell,
  .content-band,
  .faq-band {
    width: min(100% - 20px, var(--content));
  }

  .header-inner {
    min-height: 62px;
  }

  .top-nav {
    display: none;
  }

  h1 {
    font-size: 32px;
  }

  h2 {
    font-size: 24px;
  }

  .tool-heading {
    align-items: stretch;
    flex-direction: column;
    padding: 18px;
  }

  .segmented {
    width: 100%;
  }

  .segment {
    flex: 1;
    min-width: 0;
    padding-left: 8px;
    padding-right: 8px;
  }

  .signature-area,
  .control-panel {
    padding: 16px;
  }

  .canvas-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .signature-canvas,
  .canvas-frame {
    min-height: 300px;
    height: 300px;
  }

  .name-input-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .generated-preview,
  .content-grid,
  .control-panel {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 420px) {
  .button-grid {
    grid-template-columns: 1fr;
  }

  .button-grid .wide {
    grid-column: auto;
  }

  .signature-canvas,
  .canvas-frame {
    min-height: 260px;
    height: 260px;
  }
}
