/*
 * 世数边框选择器（gen-border-picker.js）。框图 / 改色变量来自 gen_border_frame.css，须一并引入。
 * 实底框按欧式世数框比例缩放：框宽 --gbp-w，双线 = 外框 + 内白环 + 内黑环。
 */

.gbp {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: stretch;
}
.gbp [hidden] {
  display: none !important;
}
.gbp-config {
  flex: 1 1 360px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.gbp-group-title {
  font-size: 11px;
  font-weight: 500;
  color: #6b7280;
  margin-bottom: 8px;
}
.gbp-tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.gbp-input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

/* 样式卡片 */
.gbp-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 64px;
  padding: 8px 4px 6px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}
.gbp-tile:hover {
  border-color: rgba(139, 0, 0, 0.45);
}
.gbp-tile.is-checked {
  border-color: #8b0000;
  background: #fffaf8;
  box-shadow: 0 0 0 2px rgba(139, 0, 0, 0.14);
}
.gbp-tile.is-checked::after {
  content: '';
  position: absolute;
  top: 4px;
  right: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #8b0000 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 6.2l2 2 4-4.4' fill='none' stroke='%23fff' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 12px 12px no-repeat;
}
.gbp-input:focus-visible + .gbp-tile-box {
  outline: 2px solid rgba(139, 0, 0, 0.45);
  outline-offset: 2px;
}
.gbp-tile-box {
  height: 58px;
  width: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: #f8f5f0;
}
.gbp-tile-name {
  font-size: 11px;
  line-height: 1.3;
  color: #4b5563;
  white-space: nowrap;
}
.gbp-tile.is-checked .gbp-tile-name {
  color: #8b0000;
  font-weight: 600;
}

/* 颜色设置 */
.gbp-colors {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border-radius: 10px;
  background: #f9fafb;
  border: 1px solid #f3f4f6;
}
.gbp-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
}
.gbp-row-label {
  width: 56px;
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 600;
  color: #374151;
}
.gbp-seg {
  display: inline-flex;
  padding: 2px;
  border-radius: 8px;
  background: #eceef1;
}
.gbp-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.gbp-choice {
  position: relative;
  cursor: pointer;
}
.gbp-choice-body {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #4b5563;
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.gbp-choice--frame .gbp-choice-body {
  padding: 4px 10px;
  border-radius: 6px;
}
.gbp-choice--frame.is-checked .gbp-choice-body {
  background: #fff;
  color: #8b0000;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}
.gbp-choice--ink .gbp-choice-body {
  padding: 3px 10px 3px 6px;
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  background: #fff;
}
.gbp-choice--ink:hover .gbp-choice-body {
  border-color: rgba(139, 0, 0, 0.45);
}
.gbp-choice--ink.is-checked .gbp-choice-body {
  border-color: #8b0000;
  color: #8b0000;
  font-weight: 600;
  box-shadow: 0 0 0 2px rgba(139, 0, 0, 0.12);
}
.gbp-choice.is-disabled {
  cursor: not-allowed;
}
.gbp-choice.is-disabled .gbp-choice-body {
  opacity: 0.38;
  border-style: dashed;
}
.gbp-input:focus-visible + .gbp-choice-body {
  outline: 2px solid rgba(139, 0, 0, 0.45);
  outline-offset: 1px;
}
.gbp-swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.18);
  flex-shrink: 0;
}
.gbp-swatch--black { background: #000; }
.gbp-swatch--white { background: #fff; }
.gbp-swatch--red { background: #c4091f; }
.gbp-swatch--frame-original { background: conic-gradient(#000 0 50%, #c4091f 50% 100%); }
.gbp-swatch--frame-black { background: #000; }
.gbp-swatch--frame-red { background: #c4091f; }

/* 预览 */
.gbp-preview {
  flex: 0 0 236px;
  display: flex;
  flex-direction: column;
  border: 1px solid #ece7df;
  border-radius: 12px;
  background: #fbf8f2;
  overflow: hidden;
}
.gbp-preview-title {
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
  border-bottom: 1px solid #ece7df;
}
.gbp-stage {
  flex: 1;
  min-height: 190px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 18px 12px;
  background: #fff;
  margin: 10px;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
.gbp-sample {
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
  gap: 4px;
}
.gbp-preview-caption {
  padding: 0 12px 10px;
  font-size: 11px;
  color: #6b7280;
  text-align: center;
  min-height: 1.4em;
}

/* 世数框：缩略图与预览共用 */
.gbp-label {
  --gbp-w: 30px;
  writing-mode: vertical-rl;
  text-orientation: upright;
  box-sizing: border-box;
  width: var(--gbp-w);
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  font-family: "SimSun", "Songti SC", serif;
  font-weight: bold;
  letter-spacing: 0.1em;
  background: var(--gen-frame-ink, #000);
  color: var(--gen-solid-text, #fff);
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
.gbp-label--preview {
  font-size: 15px;
  min-height: 92px;
  padding: 10px 0;
}
.gbp-label--mini {
  --gbp-w: 16px;
  min-height: 46px;
  font-size: 9px;
  padding: 4px 0;
}
.gbp-label.generation-label--border-double {
  border: 1px solid var(--gen-frame-ink, #000);
  box-shadow: inset 0 0 0 1.2px #fff, inset 0 0 0 2.2px var(--gen-frame-ink, #000);
}
.gbp-label.generation-label--border-rounded {
  border-radius: 6px;
}
.gbp-label.generation-label--border-rounded_double {
  border: 1px solid var(--gen-frame-ink, #000);
  border-radius: 8px;
  box-shadow: inset 0 0 0 1.2px #fff, inset 0 0 0 2.2px var(--gen-frame-ink, #000);
}
.gbp-label--mini.generation-label--border-double,
.gbp-label--mini.generation-label--border-rounded_double {
  box-shadow: inset 0 0 0 1px #fff, inset 0 0 0 1.6px var(--gen-frame-ink, #000);
}
.gbp-label--mini.generation-label--border-rounded { border-radius: 3px; }
.gbp-label--mini.generation-label--border-rounded_double { border-radius: 5px; }
.gbp-label.generation-label--border-none {
  background: transparent;
  color: #000;
}
.gbp-label.generation-label--border-beige {
  background: #fdfbc8;
  color: #000;
  box-shadow: 0 0 0 3px #dddddb;
}
.gbp-label.generation-label--border-color1,
.gbp-label.generation-label--border-color2,
.gbp-label.generation-label--border-color3,
.gbp-label.generation-label--border-color4,
.gbp-label.generation-label--border-color5,
.gbp-label.generation-label--border-color6,
.gbp-label.generation-label--border-color7,
.gbp-label.generation-label--border-yuntou {
  background: transparent;
  border: 0;
  border-image: var(--gen-frame-src) var(--gen-frame-slice) fill /
    calc(var(--gbp-w) * var(--gen-frame-cap)) 50% stretch;
  color: var(--gen-outline-text, #000);
  padding-block: calc(var(--gbp-w) * var(--gen-frame-cap) + 2px);
}

/* 字辈：欧/苏/卷轴缺省随框色（卷轴的彩色样式 1～7 另取框线红，JS 挂 --outline-red），宝塔/潮汕缺省黑 */
.gbp-zibei {
  writing-mode: vertical-rl;
  text-orientation: upright;
  font-family: "SimSun", "Songti SC", serif;
  font-weight: bold;
  font-size: 15px;
  color: var(--gen-zibei-ink, #000);
}
.gbp-stage--zibei-follow .gbp-zibei {
  color: var(--gen-zibei-ink, var(--gen-frame-ink, #000));
}
.gbp-stage--zibei-follow .gbp-zibei--outline-red {
  color: var(--gen-zibei-ink, var(--gen-outline-ink, #c4091f));
}

/* 谱眉纹样（book.html「谱眉样式」）：借用同一套卡片与预览外观；选中态直接跟 radio，无须 JS 同步 */
.pumei-style-tile {
  width: 76px;
}
.gbp-tile.pumei-style-tile:has(> .gbp-input:checked) {
  border-color: #8b0000;
  background: #fffaf8;
  box-shadow: 0 0 0 2px rgba(139, 0, 0, 0.14);
}
.gbp-tile.pumei-style-tile:has(> .gbp-input:checked)::after {
  content: '';
  position: absolute;
  top: 4px;
  right: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #8b0000 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 6.2l2 2 4-4.4' fill='none' stroke='%23fff' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 12px 12px no-repeat;
}
.gbp-tile.pumei-style-tile:has(> .gbp-input:checked) .gbp-tile-name {
  color: #8b0000;
  font-weight: 600;
}
.pumei-style-tile .gbp-tile-box {
  width: 44px;
  height: 80px;
  overflow: hidden;
  background: #fff;
  border: 1px solid #f0ebe3;
}
.pumei-style-tile .gbp-tile-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
}
.pumei-style-preview {
  flex: 0 0 248px;
  position: sticky;
  top: 12px;
  align-self: flex-start;
}
.pumei-style-preview-stage {
  min-height: 480px;
  padding: 12px;
}
.pumei-style-preview-fallback {
  display: block;
  height: 456px;
  width: auto;
}
