:root {
  --bg: #f7f3ea;
  --paper: rgba(255, 255, 255, 0.88);
  --paper-strong: #ffffff;
  --ink: #173028;
  --muted: #5d746c;
  --green: #24b167;
  --green-soft: #d5f3de;
  --pink: #f58cab;
  --shadow: 0 24px 80px rgba(33, 77, 53, 0.12);
  --radius: 24px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 212, 220, 0.55), transparent 24%),
    radial-gradient(circle at top right, rgba(171, 231, 194, 0.55), transparent 22%),
    linear-gradient(180deg, #fcfaf4, var(--bg));
}

.shell {
  width: min(1080px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 40px 0 56px;
}

.hero,
.card,
.result-card,
.footer-note {
  background: var(--paper);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(36, 177, 103, 0.14);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero {
  padding: 32px;
  position: relative;
  overflow: hidden;
}

.hero::after {
  content: "";
  position: absolute;
  inset: auto -70px -70px auto;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(245, 140, 171, 0.18), transparent 65%);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--green);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 13px;
}

h1,
h2 {
  margin: 0;
  font-family: "KaiTi", "STKaiti", serif;
}

h1 {
  font-size: clamp(32px, 5vw, 52px);
  line-height: 1.08;
}

h2 {
  font-size: clamp(24px, 3vw, 34px);
}

.lede {
  max-width: 720px;
  margin: 16px 0 0;
  color: var(--muted);
  line-height: 1.8;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}

.badge {
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--paper-strong);
  border: 1px solid rgba(36, 177, 103, 0.18);
  color: var(--muted);
  font-size: 14px;
}

.card,
.result-card {
  margin-top: 22px;
  padding: 28px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-wide {
  grid-column: 1 / -1;
}

.field span {
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(36, 177, 103, 0.2);
  font-size: 16px;
  font-family: inherit;
  outline: none;
  resize: vertical;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

input:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 4px rgba(36, 177, 103, 0.12);
}

.hint {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  justify-content: flex-start;
  margin-top: 6px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 20px;
  border-radius: 16px;
  border: 1px solid transparent;
  text-decoration: none;
  font-weight: 700;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button.primary {
  color: #fff;
  background: linear-gradient(135deg, #21aa62, #3dc07d);
  box-shadow: 0 12px 28px rgba(33, 170, 98, 0.22);
}

.button.ghost {
  color: var(--green);
  background: rgba(36, 177, 103, 0.08);
  border-color: rgba(36, 177, 103, 0.18);
}

.notice {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: 16px;
}

.notice.error {
  color: #8e2140;
  background: rgba(245, 140, 171, 0.14);
  border: 1px solid rgba(245, 140, 171, 0.25);
}

.notice.success {
  color: #15573a;
  background: rgba(36, 177, 103, 0.12);
  border: 1px solid rgba(36, 177, 103, 0.24);
}

.result-card {
  display: grid;
  gap: 18px;
}

.result-card p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.stroke-preview {
  display: grid;
  gap: 28px;
  --preview-scale-x: 1;
  --preview-scale-y: 1;
}

.stroke-preview.is-mirrored-x {
  --preview-scale-x: -1;
}

.stroke-preview.is-mirrored-y {
  --preview-scale-y: -1;
}

.stroke-preview .stroke-svg {
  transform: scale(var(--preview-scale-x), var(--preview-scale-y));
  transform-origin: center;
}

.practice-page {
  display: grid;
  gap: 14px;
}

.practice-page-header {
  display: grid;
  gap: 4px;
}

.practice-page-title {
  margin: 0;
  font-size: 20px;
  font-family: "KaiTi", "STKaiti", serif;
  color: var(--ink);
}

.practice-page-note {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.practice-sheet {
  width: min(100%, 860px);
  background: #fff;
  border: 1px solid rgba(36, 177, 103, 0.18);
  box-shadow: 0 20px 48px rgba(23, 48, 40, 0.08);
  overflow: hidden;
}

.practice-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  row-gap: 10px;
  background: #fff;
}

.practice-cell {
  position: relative;
  overflow: hidden;
  aspect-ratio: 1 / 1;
  border-top: 1.8px solid #24b167;
  border-right: 1.8px solid #24b167;
  border-bottom: 1.8px solid #24b167;
  container-type: size;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(36, 177, 103, 0.28) 0 3px,
      transparent 3px 7px
    ) center / 1.5px 100% no-repeat,
    repeating-linear-gradient(
      to right,
      rgba(36, 177, 103, 0.28) 0 3px,
      transparent 3px 7px
    ) center / 100% 1.5px no-repeat,
    #fff;
}

.practice-cell:nth-child(12n + 1) {
  border-left: 1.8px solid #24b167;
}

.practice-glyph {
  position: absolute;
  inset: 8% 10% 10% 10%;
  display: grid;
  place-items: center;
}

.stroke-svg {
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0.82;
}

.stroke-path.reference {
  fill: #1a2f28;
}

.stroke-path.stage {
  fill: #f2a0b5;
}

.fallback-char {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: "KaiTi", "STKaiti", serif;
  font-size: clamp(28px, 5vw, 54px);
  font-size: 78cqh;
  line-height: 1;
  color: #f2a0b5;
  opacity: 0.8;
}

.preview-shell {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 780px;
  padding: 16px;
  border: 1px solid rgba(36, 177, 103, 0.16);
  border-radius: 18px;
  background: #fff;
  overflow: hidden;
}

.preview-image {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 12px;
  box-shadow: 0 18px 40px rgba(23, 48, 40, 0.12);
}

.preview-hint {
  margin: 0;
  color: var(--muted);
  text-align: center;
}

.footer-note {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px 24px;
  margin-top: 22px;
  padding: 18px 22px;
  color: var(--muted);
}

code {
  padding: 2px 6px;
  border-radius: 8px;
  background: rgba(36, 177, 103, 0.1);
  color: var(--green);
}

.loading-text {
  align-self: center;
  color: var(--muted);
  font-size: 14px;
}

.is-hidden {
  display: none;
}

button:disabled {
  opacity: 0.7;
  cursor: wait;
}

@media (max-width: 760px) {
  .shell {
    width: min(100vw - 20px, 1080px);
    padding: 20px 0 28px;
  }

  .hero,
  .card,
  .result-card {
    padding: 20px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .practice-page-title {
    font-size: 18px;
  }

  .practice-page-note {
    font-size: 13px;
  }

  .footer-note {
    padding: 16px 18px;
  }
}
