:root {
  --ink: #172129;
  --muted: #65717a;
  --line: #d6d8d5;
  --paper: #fbfbf7;
  --desk: #ecece7;
  --blue: #079dcc;
  --blue-dark: #087ea2;
  --card-width-mm: 40mm;
  --card-height-mm: 50mm;
  color-scheme: light;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", Arial, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html { min-width: 320px; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background-color: var(--desk);
  background-image:
    radial-gradient(circle at 20% 30%, rgba(255, 255, 255, .68) 0 1px, transparent 1.5px),
    radial-gradient(circle at 74% 68%, rgba(24, 33, 41, .045) 0 1px, transparent 1.4px),
    repeating-linear-gradient(96deg, transparent 0 8px, rgba(255,255,255,.22) 8px 9px, transparent 9px 17px);
  background-size: 9px 9px, 13px 13px, auto;
}

button, input { font: inherit; }
button { color: inherit; }

.topbar {
  height: 68px;
  padding: 0 clamp(20px, 4vw, 58px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(39, 47, 51, .18);
  background: rgba(251, 251, 247, .88);
  backdrop-filter: blur(12px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 750;
  letter-spacing: .02em;
  text-decoration: none;
}

.brand-mark {
  width: 34px;
  height: 34px;
  flex: none;
  overflow: hidden;
  border-radius: 50%;
  background: transparent;
}

.brand-logo {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  border: 0;
  transform: scale(1.08);
}

.privacy-note {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: .8125rem;
}

.privacy-note span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #23965e;
  box-shadow: 0 0 0 3px rgba(35, 150, 94, .12);
}

.workspace {
  width: min(1160px, calc(100% - 40px));
  min-height: calc(100vh - 116px);
  margin: 24px auto;
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(380px, .92fr);
  overflow: hidden;
  border: 1px solid rgba(44, 50, 53, .2);
  background-color: var(--paper);
  background-image:
    linear-gradient(90deg, rgba(30, 37, 40, .018) 1px, transparent 1px),
    linear-gradient(rgba(30, 37, 40, .014) 1px, transparent 1px);
  background-size: 19px 19px;
  box-shadow: 0 20px 60px rgba(35, 38, 39, .09);
}

.editor, .preview-panel { padding: clamp(28px, 4vw, 52px); }
.editor { border-right: 1px solid var(--line); }

.section-heading {
  position: relative;
  margin-bottom: 32px;
}
.heading-copy { padding-right: 118px; }
.kicker {
  margin: 0 0 7px;
  color: var(--blue-dark);
  font-family: Arial, sans-serif;
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .16em;
}

h1, h2 { margin: 0; letter-spacing: -.035em; }
h1 { font-size: clamp(1.8rem, 3vw, 2.55rem); line-height: 1.08; }
h2 { font-size: 1.35rem; line-height: 1.15; }
.heading-copy > p:last-child {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: .9375rem;
  line-height: 1.7;
}

.pat-widget {
  position: absolute;
  inset: 0 0 0 auto;
  width: auto;
  aspect-ratio: 1;
  padding: 0;
  overflow: visible;
  border: 0;
  cursor: pointer;
  background: transparent;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.pat-widget:focus-visible { outline: 3px solid rgba(7, 157, 204, .22); outline-offset: 3px; }
.pat-avatar {
  position: absolute;
  inset: 0;
  display: block;
  transform-origin: 50% 100%;
}
.pat-avatar img { display: block; width: 100%; height: 100%; object-fit: contain; }
.pat-avatar img[hidden] { display: none; }
.pat-widget.is-patting .pat-avatar { animation: pat-squish .52s cubic-bezier(.2,.8,.2,1); }

@keyframes pat-squish {
  0%, 100% { transform: translateY(0) scale(1); }
  34% { transform: translateY(7%) scale(1.07, .88); }
  58% { transform: translateY(1%) scale(.98, 1.03); }
}

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

.field-wide { grid-column: 1 / -1; }
.field { display: grid; gap: 8px; }
.field > label, .size-picker legend {
  color: #344149;
  font-size: .875rem;
  font-weight: 700;
}

.field input {
  width: 100%;
  min-height: 44px;
  padding: 0 13px;
  border: 1px solid #c7cbc9;
  border-radius: 3px;
  outline: none;
  color: var(--ink);
  background: rgba(255, 255, 255, .72);
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

.field input:hover { border-color: #99a2a5; }
.field input:focus {
  border-color: var(--blue);
  background: white;
  box-shadow: 0 0 0 3px rgba(7, 157, 204, .13);
}
.field input[aria-invalid="true"] { border-color: #b64035; }

.field-wide + .field-grid { margin-top: 19px; }

.size-picker {
  margin: 26px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  border: 0;
}

.size-picker legend { margin-bottom: 9px; }
.size-picker label { position: relative; cursor: pointer; }
.size-picker input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.size-picker label > span {
  min-height: 68px;
  padding: 13px 14px;
  display: grid;
  align-content: center;
  gap: 4px;
  border: 1px solid #c8cdcb;
  border-radius: 3px;
  background: rgba(255, 255, 255, .58);
  transition: border-color .16s ease, background .16s ease, box-shadow .16s ease;
}
.size-picker b { font-size: .9375rem; }
.size-picker small { color: var(--muted); font-size: .75rem; }
.size-picker input:checked + span {
  border-color: var(--blue);
  background: rgba(7, 157, 204, .065);
  box-shadow: inset 4px 0 0 var(--blue);
}
.size-picker input:focus-visible + span { outline: 3px solid rgba(7, 157, 204, .2); outline-offset: 2px; }

.preview-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: rgba(237, 238, 233, .52);
}

.preview-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.size-badge {
  flex: none;
  padding: 6px 9px;
  border: 1px solid rgba(7, 126, 162, .28);
  border-radius: 2px;
  color: var(--blue-dark);
  background: rgba(255,255,255,.64);
  font: 700 .75rem/1 Arial, sans-serif;
  letter-spacing: .03em;
}

.preview-stage {
  position: relative;
  width: min(278px, calc(100% - 42px));
  margin: 52px auto 28px;
}

.pass-canvas {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid #40484c;
  background: #fff;
  box-shadow: 0 13px 25px rgba(27, 34, 37, .16), 0 2px 3px rgba(27, 34, 37, .12);
}

.measure {
  position: absolute;
  color: #788287;
  font: 700 .6875rem/1 Arial, sans-serif;
  letter-spacing: .03em;
}
.measure::before, .measure::after { content: ""; position: absolute; background: #aeb5b5; }
.measure-top { left: 0; right: 0; top: -24px; height: 13px; border-top: 1px solid #aeb5b5; text-align: center; }
.measure-top::before, .measure-top::after { width: 1px; height: 7px; top: -4px; }
.measure-top::before { left: 0; }
.measure-top::after { right: 0; }
.measure-top span { position: relative; top: -17px; padding: 0 5px; background: #f2f2ed; }
.measure-side { right: -29px; top: 0; bottom: 0; width: 13px; border-right: 1px solid #aeb5b5; }
.measure-side::before, .measure-side::after { width: 7px; height: 1px; right: -4px; }
.measure-side::before { top: 0; }
.measure-side::after { bottom: 0; }
.measure-side span {
  position: absolute;
  top: 50%;
  left: 10px;
  padding: 5px 0;
  white-space: nowrap;
  background: #f2f2ed;
  transform: translateY(-50%) rotate(90deg);
}

.render-status {
  min-height: 18px;
  margin: 0 0 14px;
  color: var(--muted);
  text-align: center;
  font-size: .75rem;
}
.render-status.is-error { color: #a12f27; }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.button {
  min-height: 45px;
  padding: 0 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 3px;
  cursor: pointer;
  font-size: .8125rem;
  font-weight: 750;
  transition: transform .12s ease, background .16s ease, border-color .16s ease;
}
.button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: square; stroke-linejoin: miter; }
.button:hover { transform: translateY(-1px); }
.button:active { transform: translateY(0); }
.button:focus-visible { outline: 3px solid rgba(7, 157, 204, .22); outline-offset: 2px; }
.button-primary { color: white; background: var(--blue-dark); }
.button-primary:hover { background: #076f8e; }
.button-secondary { border-color: #aeb5b5; background: rgba(255,255,255,.72); }
.button-secondary:hover { border-color: #7f898c; background: white; }
.button:disabled {
  cursor: not-allowed;
  opacity: .48;
  transform: none;
}
.print-tip { margin: auto 0 0; padding-top: 18px; color: var(--muted); font-size: .75rem; line-height: 1.5; text-align: center; }

@media (max-width: 860px) {
  .workspace { grid-template-columns: 1fr; width: min(620px, calc(100% - 24px)); }
  .editor { border-right: 0; border-bottom: 1px solid var(--line); }
  .preview-panel { min-height: 650px; }
}

@media (max-width: 520px) {
  .topbar { height: 60px; padding: 0 16px; }
  .privacy-note { font-size: 0; gap: 0; }
  .privacy-note span { width: 8px; height: 8px; }
  .workspace { margin: 12px auto; width: calc(100% - 20px); }
  .editor, .preview-panel { padding: 26px 20px; }
  .heading-copy { padding-right: 104px; }
  .heading-copy > p:last-child { max-width: 175px; }
  .field-grid { grid-template-columns: 1fr; }
  .field-wide { grid-column: auto; }
  .size-picker { grid-template-columns: 1fr; }
  .actions { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
  .pat-widget.is-patting .pat-avatar { animation-duration: .01ms !important; }
}

@page { margin: 10mm; }
@media print {
  body { background: white; }
  body * { visibility: hidden !important; }
  .preview-panel .pass-canvas {
    visibility: visible !important;
    position: fixed;
    left: 0;
    top: 0;
    width: var(--card-width-mm);
    height: var(--card-height-mm);
    border: 0;
    box-shadow: none;
  }
}
