.sp-root {
  --sp-size: 300px;
  --sp-accent: #5057ae;
  --sp-ink: #333956;
  --sp-guide: #c9c8dc;
  color: var(--sp-ink);
  min-width: 0;
}
.sp-root *, .sp-demo * { box-sizing: border-box; }
.sp-root [hidden], .sp-demo [hidden] { display: none !important; }
.sp-tools, .sp-sizes, .sp-caption, .sp-assess { display: flex; align-items: center; }
.sp-tools { justify-content: space-between; flex-wrap: wrap; gap: 8px 12px; margin-bottom: 16px; }
.sp-root button {
  font: inherit;
  font-size: .875rem;
  font-weight: 600;
  letter-spacing: .02em;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.sp-root button:focus-visible { outline: 3px solid #716ce0; outline-offset: 3px; }
.sp-root button:disabled { color: #767885; cursor: default; opacity: .7; }
.sp-icon {
  width: 1.05rem; height: 1.05rem;
  flex: none; fill: none; stroke: currentColor; stroke-width: 1.6;
  stroke-linecap: round; stroke-linejoin: round;
}
.sp-root .sp-trace, .sp-root .sp-erase, .sp-root .sp-action {
  display: inline-flex; align-items: center; justify-content: center; gap: .42rem;
  color: var(--sp-accent); background: white;
  border: 1px solid #dcdce9;
  border-radius: 8px; min-height: 38px; padding: 6px 12px;
}
.sp-root .sp-trace[aria-pressed="true"] { background: #f0effb; border-color: #9996d7; }
.sp-sizes { gap: 2px; background: #f3f4f8; border: 1px solid #e2e3ee; border-radius: 9px; padding: 3px; }
.sp-sizes > svg { color: #777a91; margin: 0 5px; }
.sp-root .sp-size { border: 0; min-height: 30px; border-radius: 6px; padding: 4px 11px; background: transparent; color: #666b80; }
.sp-root .sp-size[aria-pressed="true"] { background: #fff; color: #454b9a; box-shadow: 0 1px 4px #353a6326; }
.sp-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--sp-size)), max-content));
  justify-content: center; gap: 18px 20px;
}
.sp-cell { width: min(100%, var(--sp-size)); min-width: 0; scroll-margin-block: 16px; }
.sp-caption { justify-content: space-between; margin-bottom: 6px; gap: .25rem; }
.sp-char-label { color: #686d84; font-size: .875rem; font-weight: 600; }
.sp-root .sp-erase { color: #666a80; font-size: .8125rem; min-height: 32px; padding: 3px 4px; border: 0; background: transparent; }
.sp-erase .sp-icon { width: .9rem; height: .9rem; }
.sp-frame {
  position: relative; isolation: isolate; width: 100%; aspect-ratio: 1;
  border-radius: 11px; border: 1.5px solid #a8a8c2; overflow: hidden;
  background: #fffefa;
}
.sp-frame::before, .sp-frame::after {
  content: ""; position: absolute; pointer-events: none; z-index: 0;
}
.sp-frame::before { left: 50%; top: 0; bottom: 0; width: 1px; background: repeating-linear-gradient(to bottom,var(--sp-guide, #c9c8dc) 0 6px,transparent 6px 12px); }
.sp-frame::after { top: 50%; left: 0; right: 0; height: 1px; background: repeating-linear-gradient(to right,var(--sp-guide, #c9c8dc) 0 6px,transparent 6px 12px); }
.sp-host {
  position: absolute; inset: 0; z-index: 1; overflow: hidden;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  touch-action: none;
}
.sp-host > svg { display: block; width: 100%; height: 100%; touch-action: none; }
.sp-host.sp-locked { pointer-events: none; }
.sp-cell[data-state="error"] .sp-frame { border-color: #bb4b4b; box-shadow: 0 0 0 2px #f5d8d3; }
.sp-cell[data-state="done"] .sp-frame { border-color: #73a58b; background-color: #fcfffc; }
.sp-status, .sp-demo-status { margin-top: 6px; color: #575d76; font-size: .875rem; line-height: 1.5; }
.sp-status:empty, .sp-demo-status:empty { display: none; }
.sp-cell[data-state="error"] .sp-status { color: #a03435; font-weight: 600; }
.sp-cell[data-state="done"] .sp-status { color: #32664e; font-weight: 600; }
.sp-ghost, .sp-demo-glyph {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-family: 'Kaiti SC', 'KaiTi', 'STKaiti', 'Songti SC', 'Noto Serif CJK SC', serif;
  line-height: 1; font-weight: 400; color: #efc6c0; user-select: none; pointer-events: none;
}
.sp-ghost { font-size: calc(var(--sp-size) * .81); visibility: hidden; }
.sp-tracing .sp-ghost { visibility: visible; }
.sp-ink { position: absolute; inset: 0; }
.sp-ink polyline { fill: none; stroke: #34396a; stroke-width: 5.8; stroke-linecap: round; stroke-linejoin: round; }
.sp-review { margin-top: 8px; }
.sp-assess { flex-wrap: wrap; gap: 6px; }
.sp-root .sp-confirm { color: white; background: #5057ae; border-color: #5057ae; }
.sp-demo { display:flex; align-items:center; justify-content:center; flex-wrap:wrap; gap:16px; width:100%; }
.sp-demo-frame { width:min(180px,100%); flex:none; }
.sp-demo-glyph { font-size: 122px; color: #353957; }
@media (max-width: 680px), (pointer: coarse) and (max-width: 960px) {
  .sp-grid { grid-template-columns: minmax(0,var(--sp-size)); gap: 18px; }
}
@media (pointer:coarse) {
  .sp-root .sp-trace, .sp-root .sp-action { min-height: 44px; }
  .sp-root .sp-size, .sp-root .sp-erase { min-height: 38px; }
}

.sp-guides,.sp-demo-choices,.sp-demo-controls { display:flex; align-items:center; flex-wrap:wrap; gap:7px; }
.sp-demo-panel { border:1px solid #e3deed; border-radius:12px; padding:12px; margin-bottom:16px; background:#faf9fd; }
.sp-demo-panel[hidden],.sp-demo-controls[hidden] { display:none; }
.sp-root .sp-trace[aria-expanded="true"],.sp-demo-choices button[aria-pressed="true"] { background:#f0effb; border-color:#9996d7; }
.sp-demo-choices { justify-content:center; margin-bottom:10px; }
.sp-demo-frame>svg { position:relative; z-index:1; display:block; width:100%; height:100%; }
.sp-demo-details { flex:0 1 245px; }
.sp-demo-status { color:#403b61; font-weight:650; line-height:1.6; margin:0 0 9px; }
.sp-demo-controls .sp-action { background:white; color:#4b467e; border:1px solid #dcdce9; border-radius:7px; font-size:14px; padding:6px 9px; min-height:36px; }
.sp-demo-controls .sp-action:disabled { opacity:.45; cursor:default; }
.sp-demo-panel .sp-demo-controls { gap:6px; }
@media(max-width:540px){ .sp-demo-panel .sp-demo {gap:8px;} .sp-demo-panel .sp-demo-status {text-align:center;} .sp-demo-panel .sp-demo-controls {justify-content:center;} }
