.hs-wg { display: flex; flex-direction: column; align-items: center; width: 100%; }
.hs-wg-studio-top {
  position: relative;
  width: 100%;
  max-width: 960px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  z-index: 20;
}
.hs-wg-dock {
  width: 100%;
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--ink) 12%, transparent);
  border-radius: var(--radius);
  box-shadow: var(--shadow-dock);
  padding: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}
.hs-wg-input-wrap {
  flex: 1 1 240px;
  min-width: 0;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px 2px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid color-mix(in srgb, var(--ink) 10%, transparent);
  transition: border-color 160ms ease, background-color 160ms ease;
}
.hs-wg-input-wrap:focus-within {
  background: var(--surface);
  border-color: var(--primary);
}
.hs-wg-input {
  flex: 1;
  min-width: 60px;
  border: 0;
  background: transparent;
  font-family: var(--font-hanzi);
  font-size: 20px;
  font-weight: 600;
  color: var(--ink);
  outline: none;
}
.hs-wg-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.hs-wg-clear-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 150ms ease, color 150ms ease;
}
.hs-wg-clear-btn:hover { background: var(--surface-ctrl); color: var(--ink); }

.hs-wg-seg {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  border: 1px solid color-mix(in srgb, var(--ink) 8%, transparent);
  flex-shrink: 0;
}
.hs-wg-seg-btn {
  min-height: 36px;
  padding: 4px 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 160ms ease, color 160ms ease;
}
.hs-wg-seg-btn:hover { color: var(--ink); }
.hs-wg-seg-btn.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(27, 26, 24, 0.1);
}

.hs-wg-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.hs-wg-cust-btn {
  padding: 8px 12px;
  font-size: 13px;
  background: var(--bg);
}
.hs-wg-cust-btn[aria-expanded="true"] {
  background: var(--surface-ctrl);
  border-color: color-mix(in srgb, var(--ink) 25%, transparent);
}
.hs-wg-cust-btn[aria-expanded="true"] .hs-wg-caret { transform: rotate(180deg); }
.hs-wg-caret { transition: transform 180ms ease; }

.hs-wg-presets {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}
.hs-wg-presets-lbl {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-right: 2px;
  white-space: nowrap;
}
.hs-wg-presets .hs-chip {
  min-height: 30px;
  padding: 3px 10px;
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  border: 1px solid color-mix(in srgb, var(--ink) 10%, transparent);
  color: var(--muted);
  font-weight: 500;
}
.hs-wg-presets .hs-chip:hover {
  background: var(--surface);
  border-color: var(--border);
  color: var(--ink);
}

.hs-wg-drawer {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-paper);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.hs-wg-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.hs-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.hs-field label { font-size: 12px; font-weight: 700; color: var(--muted); }
.hs-field select, .hs-field input[type="text"] {
  width: 100%; height: 40px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg); color: var(--ink);
  font-size: 14px; font-weight: 500;
}
.hs-wg-toggles {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap; padding-top: 12px;
  border-top: 1px solid var(--border);
}
.hs-chk-row { display: flex; gap: 16px; flex-wrap: wrap; }
.hs-chk-lbl { display: inline-flex; align-items: center; gap: 7px; font-size: 14px; font-weight: 500; cursor: pointer; color: var(--ink); }
.hs-chk-lbl input { width: 16px; height: 16px; accent-color: var(--primary); }
.hs-wg-status { font-size: 13px; color: var(--accent); font-weight: 500; margin: 0; }

.hs-wg-pages {
  margin-top: 20px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 28px;
  align-items: center;
}
.hs-sheet-paper {
  position: relative;
  width: 100%;
  max-width: 820px;
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--ink) 12%, transparent);
  border-radius: 4px;
  box-shadow: var(--shadow-paper);
  padding: 28px 32px;
  color: var(--ink);
}
.hs-sheet-paper::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--surface-alt);
  border: 1px solid color-mix(in srgb, var(--ink) 10%, transparent);
  border-radius: 4px;
  transform: translate(7px, 7px) rotate(0.45deg);
  z-index: -1;
}
.hs-sheet-seal {
  position: absolute;
  top: 16px;
  right: 18px;
  width: 26px;
  height: 26px;
  pointer-events: none;
  opacity: 0.92;
}
.hs-sheet-head {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 16px;
  padding-bottom: 10px; margin-bottom: 16px; padding-right: 44px;
  border-bottom: 2px solid var(--ink); flex-wrap: wrap;
}
.hs-sheet-title { font-family: var(--font-display); font-size: 20px; font-weight: 700; margin: 0; color: var(--ink); }
.hs-sheet-meta { display: flex; gap: 20px; font-size: 13px; color: var(--muted); }
.hs-meta-blank { display: inline-block; width: 104px; border-bottom: 1px solid var(--muted); margin-left: 4px; }
.hs-sheet-rows { display: flex; flex-direction: column; gap: 15px; }
.hs-entry { display: flex; flex-direction: column; gap: 6px; }
.hs-entry-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 13px; }
.hs-entry-info { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.hs-entry-py { font-weight: 700; color: var(--primary-dark); }
.hs-entry-mean { color: var(--muted); }
.hs-entry-strokes { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.hs-entry-anim-btn {
  border: 1px solid var(--border); background: var(--bg); color: var(--ink);
  font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 6px; cursor: pointer;
  transition: border-color 150ms ease, color 150ms ease, background-color 150ms ease;
}
.hs-entry-anim-btn:hover { border-color: var(--primary); color: var(--primary-dark); background: var(--primary-tint); }
.hs-strip-row { display: flex; flex-wrap: wrap; gap: 4px; }
.hs-strip-box {
  width: 28px; height: 28px; border: 1px solid var(--border);
  background: var(--bg); border-radius: 3px;
  display: inline-flex; align-items: center; justify-content: center;
}
.hs-strip-box svg { width: 24px; height: 24px; display: block; }
.hs-cell-grid { display: grid; gap: 4px; }
.hs-cell-btn {
  padding: 0; border: 0; background: transparent; cursor: pointer;
  display: block; width: 100%; aspect-ratio: 1 / 1; border-radius: 2px;
  transition: box-shadow 150ms ease;
}
.hs-cell-btn:hover { box-shadow: 0 0 0 2px var(--primary); }
.hs-cell-box { width: 100%; aspect-ratio: 1 / 1; }
.hs-cell-box svg, .hs-cell-btn svg { width: 100%; height: 100%; display: block; }
.hs-sheet-foot {
  margin-top: 16px; padding-top: 8px; border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; font-size: 12px; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.hs-wg-empty { text-align: center; padding: 36px 16px; color: var(--muted); font-size: 15px; }

.hs-modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(27, 26, 24, 0.56);
  display: flex; align-items: center; justify-content: center;
  padding: 16px; z-index: 80;
}
.hs-modal-card {
  width: 100%; max-width: 400px;
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border); box-shadow: var(--shadow-paper); padding: 24px;
}
.hs-modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.hs-modal-head .hs-modal-title { margin: 0; font-size: 22px; font-weight: 700; font-family: var(--font-display); color: var(--ink); }
.hs-modal-canvas {
  width: 220px; height: 220px; margin: 12px auto;
  border: 2px solid var(--grid-red); border-radius: 8px; background: var(--bg); position: relative;
}
.hs-modal-actions { display: flex; gap: 8px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }

@media (max-width: 960px) {
  .hs-wg-dock { flex-wrap: wrap; }
  .hs-wg-input-wrap { flex: 1 1 100%; }
  .hs-wg-seg { flex: 1 1 auto; }
  .hs-wg-seg-btn { flex: 1 1 auto; }
  .hs-wg-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .hs-wg-dock { padding: 8px; gap: 6px; }
  .hs-wg-seg { width: 100%; }
  .hs-wg-seg-btn { padding: 4px 8px; font-size: 12px; }
  .hs-wg-actions { width: 100%; }
  .hs-wg-actions .hs-btn { flex: 1 1 auto; padding: 8px 10px; font-size: 13px; }
  .hs-wg-presets {
    width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    justify-content: flex-start;
    padding: 2px 0;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .hs-wg-presets::-webkit-scrollbar { display: none; }
  .hs-wg-presets .hs-chip { flex-shrink: 0; }
  .hs-wg-pages { margin-top: 14px; }
  .hs-wg-options { grid-template-columns: 1fr; }
  .hs-sheet-paper { padding: 14px 14px; }
  .hs-sheet-paper::before { display: none; }
  .hs-sheet-head { padding-right: 36px; margin-bottom: 12px; }
  .hs-sheet-title { font-size: 17px; }
  .hs-sheet-meta { gap: 12px; font-size: 12px; }
  .hs-meta-blank { width: 64px; }
}
@media print {
  .hs-wg-pages { margin-top: 0 !important; gap: 0 !important; }
  .hs-sheet-paper {
    max-width: none !important; border: 0 !important; box-shadow: none !important;
    border-radius: 0 !important; padding: 8mm 10mm !important;
    break-after: page; page-break-after: always;
  }
  .hs-sheet-paper::before { display: none !important; }
  .hs-sheet-paper:last-child { break-after: auto; page-break-after: auto; }
  .hs-entry-anim-btn { display: none !important; }
}