/* ==========================================================================
   数据制图 · 印刷校样台
   设计语言：蓝灰中性色打底，墨色文字，克制的品牌蓝只用于“当前状态”和主操作。
   组件只消费 --token；深色外观在 dark.css 中替换同一组 token。
   ========================================================================== */

@font-face { font-family: "Source Han Serif SC"; src: url("/fonts/Regular.otf") format("opentype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Source Han Serif SC"; src: url("/fonts/Bold.otf") format("opentype"); font-weight: 600 900; font-display: swap; }
@font-face { font-family: "Site YaHei"; src: local("Microsoft YaHei"), local("微软雅黑"); font-display: swap; }
@font-face { font-family: "Site SimSun"; src: local("SimSun"), local("宋体"); font-display: swap; }
@font-face { font-family: "Site SimHei"; src: local("SimHei"), local("黑体"); font-display: swap; }
@font-face { font-family: "Site KaiTi"; src: local("KaiTi"), local("楷体"); font-display: swap; }
@font-face { font-family: "Site FangSong"; src: local("FangSong"), local("仿宋"); font-display: swap; }

.publication-copy { margin-top: 14px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); }
.publication-copy h3 { margin: 0; font-size: 14px; }
.publication-label { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; }
.publication-label label { margin: 0; }
.publication-label output { margin-left: 6px; color: var(--muted); font-size: 12px; font-weight: normal; }
.publication-copy input, .publication-copy textarea { width: 100%; margin-top: 6px; }
.publication-copy [aria-invalid="true"] { border-color: var(--danger); }

:root {
  color-scheme: light;

  /* 纸面、台面与卡片：延续旧版蓝灰中性色 */
  --paper: #f3f5fa;
  --paper-2: #e9edf5;
  --surface: #ffffff;
  --surface-2: #f3f5fa;
  --surface-3: #e9edf5;
  --stage: #e4e9f2;
  --thumb: #edf1f8;

  /* 墨色文字 */
  --ink: #1d293d;
  --ink-2: #394961;
  --muted: #63718a;
  --faint: #8a97ad;

  /* 线与标记 */
  --line: #e2e7f0;
  --line-2: #c8d3e5;
  --mark: #aab7c9;

  /* 品牌蓝：只做强调，不做大面积底色 */
  --accent: #3469cc;
  --accent-strong: #2b56a8;
  --accent-solid: #3469cc;
  --accent-soft: #eaf0ff;
  --accent-line: #c9d8f5;
  --on-accent: #ffffff;

  /* 状态 */
  --ok: #2f7d5c;
  --danger: #b42318;
  --danger-soft: #fdf0ee;

  --shadow-1: 0 1px 2px rgba(30, 41, 61, .05), 0 14px 30px -24px rgba(30, 41, 61, .32);
  --shadow-2: 0 28px 70px -34px rgba(20, 30, 48, .42);

  --radius-lg: 16px;
  --radius-md: 11px;
  --radius-sm: 8px;

  --font-display: "Source Han Serif SC", "Songti SC", "STSong", Georgia, serif;
  --font-ui: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;

  --ease: cubic-bezier(.22, .8, .26, 1);
  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2363718a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");

  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

:root[data-ui-font="source_han_serif"] { --font-ui: "Source Han Serif SC", serif; --font-display: var(--font-ui); }
:root[data-ui-font="microsoft_yahei"] { --font-ui: "Site YaHei", sans-serif; --font-display: var(--font-ui); }
:root[data-ui-font="simsun"] { --font-ui: "Site SimSun", serif; --font-display: var(--font-ui); }
:root[data-ui-font="simhei"] { --font-ui: "Site SimHei", sans-serif; --font-display: var(--font-ui); }
:root[data-ui-font="kaiti"] { --font-ui: "Site KaiTi", serif; --font-display: var(--font-ui); }
:root[data-ui-font="fangsong"] { --font-ui: "Site FangSong", serif; --font-display: var(--font-ui); }

.ui-font-control { display: flex; align-items: center; gap: 6px; margin: 0; white-space: nowrap; font-weight: 400; }
.ui-font-control > span { margin: 0; color: var(--muted); font-size: 10px; }
.ui-font-control select { width: 112px; height: 32px; margin: 0; padding: 0 24px 0 8px; font-size: 11px; }
.ui-font-status { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (max-width: 640px) {
  .ui-font-control > span { display: none; }
  .ui-font-control select { width: 98px; }
}
@media (max-width: 420px) { .topbar .brand-word { display: none; } }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scrollbar-gutter: stable; }
body { margin: 0; background: var(--paper); }

h1, h2, h3, p, dl, dd, dt { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
img { max-width: 100%; }

:where(button, input, select, textarea, a, summary):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}
::selection { background: var(--accent-soft); color: var(--accent-strong); }

/* ------------------------------------------------------------ 文字与按钮 */

.text-button {
  padding: 4px 1px;
  border: 0;
  background: none;
  font-family: var(--font-ui);
  font-size: 11px;
  letter-spacing: .02em;
  color: var(--muted);
  text-underline-offset: 3px;
  transition: color .16s var(--ease);
}
.text-button:hover { color: var(--accent); text-decoration: underline; }

.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 11px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-family: var(--font-ui);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink-2);
  white-space: nowrap;
  transition: border-color .16s var(--ease), color .16s var(--ease), background .16s var(--ease);
}
.ghost-button:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.ghost-button svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.primary-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--accent-solid);
  border-radius: 9px;
  background: var(--accent-solid);
  color: var(--on-accent);
  font-family: var(--font-ui);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: .02em;
  box-shadow: 0 10px 22px -16px var(--accent-solid);
  transition: background .16s var(--ease), transform .1s var(--ease), box-shadow .16s var(--ease);
}
.primary-button:hover:not(:disabled) { background: var(--accent-strong); border-color: var(--accent-strong); }
.primary-button:active:not(:disabled) { transform: translateY(1px); }
.primary-button svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; opacity: .85; }

.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 32px;
  padding: 0 7px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-family: var(--font-ui);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: .01em;
  white-space: nowrap;
  color: var(--ink-2);
  transition: border-color .16s var(--ease), color .16s var(--ease), background .16s var(--ease);
}
.secondary-button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.download-icon { width: 13px; height: 13px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#save-design { border-color: var(--accent-line); color: var(--accent-strong); background: var(--accent-soft); }
#save-design:hover:not(:disabled) { border-color: var(--accent); background: var(--surface); }

.add-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 32px;
  padding: 0 11px;
  border: 1px dashed var(--line-2);
  border-radius: var(--radius-sm);
  background: transparent;
  font-family: var(--font-ui);
  font-size: 11px;
  color: var(--ink-2);
  transition: border-color .16s var(--ease), color .16s var(--ease), background .16s var(--ease);
}
.add-button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* ------------------------------------------------------------ 表单控件 */

label {
  display: block;
  margin: 0 0 7px;
  font-family: var(--font-ui);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--ink-2);
}
label span { margin-left: 6px; font-size: 10.5px; font-weight: 400; color: var(--muted); letter-spacing: 0; }

input, textarea, select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 12.5px;
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease), background .16s var(--ease);
}
input, textarea { padding: 8px 10px; }
textarea { line-height: 1.65; resize: vertical; }
select {
  padding: 8px 30px 8px 10px;
  appearance: none;
  background-image: var(--select-arrow);
  background-repeat: no-repeat;
  background-position: right 9px center;
  background-size: 14px;
  font-size: 12px;
}
input:hover, textarea:hover, select:hover { border-color: var(--faint); }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input[type="number"] { font-variant-numeric: tabular-nums; }
input[type="color"] { height: 34px; padding: 3px; cursor: pointer; }
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 5px; }
input[type="range"] { height: 20px; padding: 0; border: 0; background: transparent; accent-color: var(--accent-solid); cursor: pointer; }

/* 开关：用于“占比 / 水印 / 左右标注”等布尔项 */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  cursor: pointer;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink-2);
}
.switch-row > span { margin: 0; font-size: 11.5px; font-weight: 500; color: var(--ink-2); }
.switch-row input[type="checkbox"] {
  appearance: none;
  position: relative;
  flex: none;
  width: 38px;
  height: 22px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: var(--surface-3);
  cursor: pointer;
  transition: background .18s var(--ease), border-color .18s var(--ease);
}
.switch-row input[type="checkbox"]::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(20, 15, 8, .25);
  transition: transform .18s var(--ease);
}
.switch-row input[type="checkbox"]:checked { background: var(--accent-solid); border-color: var(--accent-solid); }
.switch-row input[type="checkbox"]:checked::before { transform: translateX(16px); }
.switch-row input[type="checkbox"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.field-row > div { min-width: 0; }
.field-row:first-child { margin-top: 0; }

.field-hint {
  margin: 8px 0 0;
  font-family: var(--font-ui);
  font-size: 10.5px;
  line-height: 1.7;
  color: var(--muted);
}
.field-hint:last-child { margin-bottom: 0; }

.hint-details { margin-top: 7px; }
.hint-details summary {
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
  color: var(--faint);
  cursor: pointer;
  text-underline-offset: 3px;
}
.hint-details summary::-webkit-details-marker { display: none; }
.hint-details summary::before { content: "?"; display: inline-grid; place-items: center; width: 13px; height: 13px; border: 1px solid currentColor; border-radius: 50%; font-size: 8px; line-height: 1; }
.hint-details summary:hover { color: var(--accent); text-decoration: underline; }
.hint-details p { margin: 6px 0 0; max-width: 62ch; font-size: 10.5px; line-height: 1.7; color: var(--muted); }

.unit { font-family: var(--font-ui); font-size: 11px; color: var(--muted); }

/* ------------------------------------------------------------ 面板与分节 */

.panel {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-1);
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: var(--surface);
}
.step-no {
  display: grid;
  place-items: center;
  flex: none;
  width: 26px;
  height: 26px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: var(--surface);
  font-family: var(--font-ui);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: .04em;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}
.panel-title { min-width: 0; }
.panel-title h2 {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: .03em;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.panel-title p { margin-top: 2px; font-size: 9.5px; letter-spacing: .04em; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel-actions { display: flex; align-items: center; gap: 4px; margin-left: auto; flex: none; }

.spec-pill {
  margin-left: auto;
  flex: none;
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  font-family: var(--font-ui);
  font-size: 9.5px;
  font-variant-numeric: tabular-nums;
  letter-spacing: .08em;
  color: var(--muted);
  cursor: help;
}

/* ------------------------------------------------------------ 图表结构列表 */

.template-list { display: flex; flex-direction: column; gap: 2px; padding: 8px; }

.template-button {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 9px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-2);
  text-align: left;
  transition: background .16s var(--ease), border-color .16s var(--ease), color .16s var(--ease), transform .16s var(--ease);
}
.template-button::before {
  content: "";
  position: absolute;
  left: 0;
  top: 11px;
  bottom: 11px;
  width: 2px;
  border-radius: 2px;
  background: var(--accent);
  opacity: 0;
  transition: opacity .16s var(--ease);
}
.template-button svg {
  width: 27px;
  height: 25px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: .58;
  transition: opacity .16s var(--ease), color .16s var(--ease);
}
.template-button strong { display: block; font-family: var(--font-ui); font-size: 12.5px; font-weight: 600; letter-spacing: .01em; }
.template-button small { display: block; margin-top: 2px; font-family: var(--font-ui); font-size: 8.5px; letter-spacing: .14em; color: var(--faint); }
.template-button:hover { background: var(--surface-2); color: var(--ink); transform: translateX(1px); }
.template-button:hover svg { opacity: .85; }
.template-button.active { background: var(--accent-soft); border-color: var(--accent-line); color: var(--ink); }
.template-button.active::before { opacity: 1; }
.template-button.active svg { color: var(--accent); opacity: 1; }
.template-button.active small { color: var(--accent); }

.aside-note {
  margin: 6px 10px 12px;
  padding: 12px;
  border-radius: 10px;
  background: var(--surface-2);
}
.aside-note-title { display: block; margin-bottom: 8px; font-family: var(--font-ui); font-size: 9px; font-weight: 600; letter-spacing: .16em; color: var(--accent); }
.aside-note dl { display: flex; flex-direction: column; gap: 5px; }
.aside-note dl div { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.aside-note dt { font-size: 10.5px; color: var(--muted); }
.aside-note dd { font-family: var(--font-ui); font-size: 10px; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.aside-note p { margin-top: 9px; padding-top: 8px; border-top: 1px solid var(--line); font-size: 9.5px; line-height: 1.65; color: var(--muted); }

/* ------------------------------------------------------------ 版式卡片 */

.layout-choices { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; }

.layout-choice {
  position: relative;
  min-width: 0;
  padding: 4px 4px 6px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink-2);
  text-align: left;
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease), transform .16s var(--ease);
}
.layout-choice:hover { border-color: var(--line-2); box-shadow: var(--shadow-1); transform: translateY(-1px); }
.layout-choice.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.layout-choice img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: contain;
  margin-bottom: 5px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--thumb);
}
.layout-choice strong { display: block; padding: 0 1px; font-family: var(--font-ui); font-size: 9.5px; font-weight: 500; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.layout-choice small { display: none; }
.layout-choice.active strong { color: var(--accent-strong); font-weight: 600; }
.layout-note { margin-top: 9px; }
.layout-note:empty { display: none; }

.theme-tools { display: grid; gap: 8px; margin-bottom: 10px; }
.theme-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.theme-filters button { padding: 6px 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--ink-2); }
.theme-filters button[aria-pressed="true"] { color: var(--accent-strong); border-color: var(--accent); background: var(--surface-2); }
.theme-tools small { color: var(--muted); }
.theme-card[hidden] { display: none; }

.ref-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 1px 4px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  font-family: var(--font-ui);
  font-size: 7px;
  font-style: normal;
  letter-spacing: .02em;
  color: var(--muted);
  backdrop-filter: blur(4px);
}

/* ------------------------------------------------------------ 配色卡片 */

.theme-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 7px; }

.theme-card {
  position: relative;
  min-width: 0;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  text-align: left;
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease), transform .16s var(--ease);
}
.theme-card:hover { border-color: var(--line-2); transform: translateY(-1px); box-shadow: var(--shadow-1); }
.theme-card.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

.theme-swatch {
  position: relative;
  display: block;
  height: 28px;
  overflow: hidden;
  border-radius: 4px;
  border: 1px solid var(--line-2);
}
.sw-header { position: absolute; inset: 0 0 auto 0; height: 10px; }
.sw-title, .sw-accent { position: absolute; left: 5px; height: 3px; border-radius: 2px; }
.sw-title { top: var(--sw-top, 7px); right: 28%; height: 4px; opacity: .92; }
.sw-accent { top: calc(var(--sw-top, 7px) + 8px); width: 28%; }
.sw-dot { position: absolute; right: 5px; bottom: 4px; width: 7px; height: 7px; border-radius: 50%; }

.theme-name { display: block; margin-top: 4px; padding: 0 1px; font-family: var(--font-ui); font-size: 9.5px; font-weight: 500; line-height: 1.35; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.theme-card.active .theme-name { color: var(--accent-strong); font-weight: 600; }
.theme-card.active::after {
  content: "✓";
  position: absolute;
  right: 6px;
  top: 6px;
  display: grid;
  place-items: center;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--accent-solid);
  color: var(--on-accent);
  font-size: 7px;
  line-height: 1;
  box-shadow: 0 0 0 1px var(--surface);
}

/* ------------------------------------------------------------ 标题设计 */

.header-style-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 7px; }

.header-style-button {
  min-width: 0;
  display: grid;
  gap: 5px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 9px;
  text-align: left;
  cursor: pointer;
  transition: border-color .16s var(--ease), color .16s var(--ease), box-shadow .16s var(--ease);
}
.header-style-button:hover { border-color: var(--line-2); color: var(--ink-2); }
.header-style-button[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); color: var(--ink); }
.header-style-swatch { position: relative; display: block; height: 30px; overflow: hidden; border-radius: 4px; background: #073d8e; }
.header-style-swatch i { position: absolute; height: 4px; left: 20%; right: 20%; top: 10px; border-radius: 1px; background: #fff; }
.header-style-swatch i + i { top: 20px; left: 28%; right: 28%; height: 3px; }
.header-style-button[data-style="auto"] .header-style-swatch { background: linear-gradient(125deg, #faf8f2 0 40%, #073d8e 40% 72%, #08182b 72%); }
.header-style-button[data-style="editorial"] .header-style-swatch { background: #faf8f2; border-bottom: 2px solid #c9001b; }
.header-style-button[data-style="editorial"] i { left: 10%; right: 20%; background: #162d49; }
.header-style-button[data-style="editorial"] i + i { right: 40%; background: #c9001b; }
.header-style-button[data-style="frame"] .header-style-swatch { background: #fff; border: 3px solid #2466a7; }
.header-style-button[data-style="frame"] i { background: #082653; top: 8px; }
.header-style-button[data-style="frame"] i + i { background: #c9001b; top: 18px; }
.header-style-button[data-style="ribbon"] i + i { top: 18px; height: 8px; background: #df071b; }
.header-style-button[data-style="tech"] .header-style-swatch { background: #08182b; border-left: 2px solid #29b9ff; border-right: 2px solid #29b9ff; }
.header-style-button[data-style="tech"] i + i { background: #29b9ff; }
.header-style-button[data-style="contrast"] .header-style-swatch { background: #142033; border-bottom: 3px solid #ffd477; }
.header-style-button[data-style="paper"] .header-style-swatch,
.header-style-button[data-style="sidebar"] .header-style-swatch,
.header-style-button[data-style="double"] .header-style-swatch { background: #fff; }
.header-style-button[data-style="paper"] i,
.header-style-button[data-style="sidebar"] i,
.header-style-button[data-style="double"] i { background: #17283e; }
.header-style-button[data-style="sidebar"] .header-style-swatch { border-left: 4px solid #7251ac; }
.header-style-button[data-style="double"] .header-style-swatch { border-top: 3px double #17283e; border-bottom: 3px double #17283e; }

.header-height-controls { display: grid; grid-template-columns: minmax(0, 1fr) 68px 12px; gap: 8px; align-items: center; margin-top: 6px; }
.header-height-controls input[type="number"] { padding: 6px 8px; }

/* ------------------------------------------------------------ 文字样式 */

.text-style-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px 10px;
  margin-top: 9px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
}
.style-caption { display: flex; align-items: baseline; gap: 7px; margin-top: 11px; font-size: 10px; font-weight: 600; color: var(--ink-2); }
.style-caption span { font-size: 9.5px; font-weight: 400; color: var(--muted); }
.style-details { margin-top: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.style-details > summary { display: flex; align-items: baseline; gap: 7px; padding: 9px 11px; list-style: none; cursor: pointer; font-size: 10.5px; font-weight: 600; color: var(--ink-2); }
.style-details > summary::-webkit-details-marker { display: none; }
.style-details > summary::after { content: "展开"; margin-left: auto; font-size: 9px; font-weight: 400; color: var(--faint); }
.style-details[open] > summary::after { content: "收起"; }
.style-details > summary:hover { color: var(--accent); }
.style-details > summary span { font-size: 9.5px; font-weight: 400; color: var(--muted); }
.style-details .text-style-controls { margin: 0; border: 0; border-top: 1px solid var(--line); border-radius: 0 0 10px 10px; padding: 11px; }
.text-style-controls label { min-width: 0; margin: 0; font-size: 10.5px; font-weight: 500; color: var(--muted); }
.text-style-controls label > select { margin-top: 4px; height: 26px; padding: 2px 24px 2px 7px; background-position: right 6px center; font-size: 10px; border-color: var(--line); }
.text-style-controls input, .text-style-controls select { width: 100%; min-width: 0; margin-top: 4px; }
.text-style-controls input[type="number"], .text-style-controls input[type="text"] { padding: 6px 8px; font-size: 11.5px; }
.text-style-controls input[type="color"] { height: 30px; margin-top: 4px; }
.text-style-controls input[type="color"]:disabled {
  border-style: dashed;
  background: repeating-linear-gradient(135deg, var(--surface) 0 5px, var(--surface-2) 5px 10px);
  cursor: not-allowed;
}
.text-style-controls input[type="color"]:disabled::-webkit-color-swatch { opacity: 0; }
.text-style-controls input:disabled { opacity: 1; }
.auto-title-size { width: auto; margin-top: 5px; padding: 3px 7px; border: 1px solid var(--line-2); border-radius: 5px; background: var(--surface); color: var(--accent); font-family: var(--font-ui); font-size: 9.5px; }
.auto-title-size:hover { border-color: var(--accent); }

.highlight-editor { grid-column: 1 / -1; padding-top: 9px; border-top: 1px solid var(--line); }
.highlight-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-family: var(--font-ui); font-size: 10.5px; color: var(--ink-2); }
.highlight-heading button, .keyword-row button { border: 1px solid var(--line); border-radius: 5px; background: var(--surface); color: var(--ink-2); cursor: pointer; }
.highlight-heading button { height: 24px; padding: 0 7px; font-size: 10px; }
.highlight-heading button:hover { border-color: var(--accent); color: var(--accent); }
.highlight-heading button:disabled { opacity: .45; cursor: default; }
.keyword-row { display: grid; grid-template-columns: minmax(0, 1fr) 34px 26px; align-items: center; gap: 6px; margin-top: 7px; }
.keyword-row input { margin-top: 0; height: 28px; }
.keyword-row input[type="color"] { height: 28px; padding: 2px; }
.keyword-row button { height: 28px; font-size: 15px; line-height: 1; }
.keyword-row button:hover { border-color: var(--danger); color: var(--danger); }

/* ------------------------------------------------------------ 榜单条数 */

#ranking-count-field { margin-top: 0; }
.ranking-count-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ranking-count-controls > button {
  height: 28px;
  padding: 0 11px;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  background: var(--surface);
  font-family: var(--font-ui);
  font-size: 10.5px;
  color: var(--ink-2);
  transition: border-color .16s var(--ease), color .16s var(--ease), background .16s var(--ease);
}
.ranking-count-controls > button:hover { border-color: var(--accent); color: var(--accent); }
.ranking-count-controls > button.is-active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
.ranking-custom { display: flex; align-items: center; gap: 5px; margin-left: 2px; }
.ranking-custom input { width: 58px; height: 28px; padding: 3px 7px; font-size: 11px; text-align: center; }
.ranking-custom button { height: 28px; padding: 0 9px; border: 1px solid var(--line-2); border-radius: 6px; background: var(--surface-2); font-family: var(--font-ui); font-size: 10.5px; color: var(--ink-2); }
.ranking-custom button:hover { border-color: var(--accent); color: var(--accent); }
#ranking-count-field:not([hidden]) ~ #numeric-data { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
#ranking-count-field .switch-row { margin-top: 12px; }

/* ------------------------------------------------------------ 数据表 */

.table-scroll {
  max-height: 330px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
}
.table-scroll table { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; }
.table-scroll thead { position: sticky; top: 0; z-index: 1; background: var(--surface-2); }
.table-scroll th {
  padding: 8px;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-ui);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: .07em;
  text-align: left;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.table-scroll th:first-child { width: 38px; text-align: center; }
.table-scroll th:last-child { width: 30px; }
.table-scroll td { padding: 0; border-bottom: 1px solid var(--line); }
.table-scroll tbody tr:last-child td { border-bottom: 0; }
.table-scroll tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 62%, transparent); }
.table-scroll td:first-child { text-align: center; font-family: var(--font-ui); font-size: 9.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.table-scroll td input {
  width: 100%;
  padding: 8px;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-size: 11.5px;
}
.table-scroll td input:focus { outline: none; box-shadow: inset 0 0 0 1px var(--accent); background: var(--accent-soft); }
.table-scroll td input[type="number"] { text-align: right; font-variant-numeric: tabular-nums; appearance: textfield; }
.table-scroll td input::-webkit-inner-spin-button { appearance: none; }
.column-heading { display: flex; align-items: center; gap: 2px; }
.column-heading input { width: 100%; min-width: 0; padding: 5px 2px; border: 0; border-bottom: 1px dashed var(--line-2); border-radius: 0; font: inherit; color: inherit; background: transparent; }
.column-heading button { flex: 0 0 22px; padding: 2px; border: 0; background: transparent; color: var(--muted); }
.restore-columns { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.restore-columns:empty { display: none; }
.restore-columns button { padding: 6px 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--muted); font: inherit; cursor: pointer; }
#data-table:has(.column-heading) th:first-child { width: 65px; }
.flag-table { min-width: 620px; }
.flag-table th:nth-child(2) { width: 150px; }
.flag-name { display: flex; align-items: center; gap: 5px; }
.flag-name input { min-width: 0; flex: 1; }
.row-flag { width: 20px; height: 14px; flex: none; object-fit: contain; }

.delete-row { width: 24px; height: 24px; margin: 0 auto; padding: 0; border: 0; border-radius: 5px; background: none; font-size: 15px; line-height: 1; color: var(--faint); }
.delete-row:hover { background: var(--danger-soft); color: var(--danger); }

.data-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin: 0 0 9px; }
.data-help { margin: 0 0 8px; }
.sort-field { display: flex; align-items: center; gap: 6px; margin: 0 0 0 auto; font-size: 10px; font-weight: 400; color: var(--muted); white-space: nowrap; }
.sort-field select { width: auto; height: 28px; padding: 2px 26px 2px 8px; background-position: right 7px center; font-size: 10px; border-color: var(--line); }

/* ------------------------------------------------------------ 地图编辑 */

#map-mode { margin-bottom: 4px; }
#map-editor .field-row:first-of-type { margin-top: 12px; }

.map-swatches { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.map-swatches button { width: 38px; height: 28px; padding: 0; border: 2px solid var(--surface); border-radius: 6px; box-shadow: 0 0 0 1px var(--line-2); cursor: pointer; }
.map-swatches button[aria-pressed="true"] { outline: 2px solid var(--accent); outline-offset: 2px; }

.map-color-settings { margin: 12px 0; padding: 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.map-color-heading { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 11px; color: var(--ink-2); }
#map-active-color-chip { width: 20px; height: 20px; border-radius: 5px; border: 1px solid var(--line-2); }
.map-color-settings label:not(.switch-row) { margin-top: 9px; }
.map-color-size-control { display: flex; align-items: center; gap: 10px; }
.map-color-size-control input[type="range"] { flex: 1; min-width: 0; }
.map-color-size-control input[type="number"] { width: 68px; padding: 6px 8px; }

.map-edit-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.map-edit-actions button { height: 28px; padding: 0 9px; border: 1px solid var(--line-2); border-radius: 6px; background: var(--surface); font-family: var(--font-ui); font-size: 10.5px; color: var(--ink-2); }
.map-edit-actions button:hover { border-color: var(--accent); color: var(--accent); }
.map-edit-actions button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); }

#map-selection { min-height: 20px; }
#map-canvas { width: 100%; display: block; margin-bottom: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); touch-action: none; overflow: visible; }
#map-canvas path[data-name] { cursor: crosshair; }
#map-canvas path[data-name]:hover, #map-canvas path[data-name]:focus { stroke: #ffda60; stroke-width: 3; outline: none; }
#map-svg-text text { cursor: grab; user-select: none; filter: drop-shadow(2px 3px 0 #101827); }

.provinces { margin: 10px 0; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.provinces summary { list-style: none; padding: 8px 10px; font-size: 10.5px; color: var(--muted); cursor: pointer; }
.provinces summary::-webkit-details-marker { display: none; }
.provinces summary:hover { color: var(--accent); }
.provinces[open] summary { border-bottom: 1px solid var(--line); }
.map-provinces { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; padding: 8px; }
.map-provinces button { height: 28px; padding: 0 7px; border: 1px solid var(--line); border-left: 4px solid var(--province-color, var(--line-2)); border-radius: 5px; background: var(--surface); font-family: var(--font-ui); font-size: 10px; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.map-provinces button:hover { border-color: var(--accent); border-left-color: var(--province-color, var(--accent)); }

.map-annotation { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 9px 0; padding: 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2); }
.map-annotation label { margin: 0; font-size: 10px; font-weight: 500; color: var(--muted); }
.map-annotation label:first-child { grid-column: 1 / -1; }
.map-annotation input { margin-top: 4px; padding: 6px 8px; font-size: 11px; }

.subhead { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 16px 0 9px; padding-top: 13px; border-top: 1px solid var(--line); }
.subhead h3 { font-family: var(--font-ui); font-size: 11.5px; font-weight: 600; color: var(--ink); }

.extra-panel { margin-top: 10px; padding: 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.extra-panel .subhead { margin-top: 0; padding-top: 0; border-top: 0; }
.map-placement-control { display: grid; grid-template-columns: minmax(0, 1fr) 62px; gap: 10px; align-items: center; margin-bottom: 9px; }
.map-placement-control input[type="range"] { width: 100%; min-width: 0; }
.map-placement-control input[type="number"] { padding: 5px 7px; }
#map-drag-toggle { width: 100%; margin-top: 4px; }
#map-drag-toggle[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); }

/* ------------------------------------------------------------ 预览与纸张 */

.preview-mount-note { font-size: 10px; color: var(--muted); }

.preview-stage {
  position: relative;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background-color: var(--stage);
  background-image: radial-gradient(color-mix(in srgb, var(--mark) 38%, transparent) .8px, transparent .8px);
  background-size: 14px 14px;
  transition: background-color .2s var(--ease);
}
.paper-mount { position: relative; width: 100%; margin: 0 auto; }
.paper {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border-radius: 2px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(20, 30, 48, .12), 0 26px 48px -28px rgba(20, 30, 48, .48);
  transition: opacity .25s var(--ease), filter .25s var(--ease);
}
.paper img { display: block; width: 100%; height: 100%; object-fit: contain; }
.paper img[hidden] { display: none; }
#preview-empty { display: grid; place-items: center; height: 100%; padding: 24px; text-align: center; font-size: 11.5px; line-height: 1.8; color: var(--muted); }

.crop { position: absolute; width: 12px; height: 12px; border: 0 solid var(--mark); opacity: .9; pointer-events: none; }
.crop-tl { top: -6px; left: -6px; border-top-width: 1px; border-left-width: 1px; }
.crop-tr { top: -6px; right: -6px; border-top-width: 1px; border-right-width: 1px; }
.crop-bl { bottom: -6px; left: -6px; border-bottom-width: 1px; border-left-width: 1px; }
.crop-br { bottom: -6px; right: -6px; border-bottom-width: 1px; border-right-width: 1px; }

/* 绘制中的状态：顶边扫描条 */
.preview-stage::after {
  content: "";
  position: absolute;
  top: -1px;
  left: 24px;
  right: 24px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0;
  transition: opacity .2s var(--ease);
}
.preview-stage.busy::after { opacity: 1; animation: press-scan 1.1s var(--ease) infinite; }
.preview-stage.busy .paper { opacity: .62; filter: saturate(.85); }
@keyframes press-scan {
  0% { transform: scaleX(.18); transform-origin: left; opacity: .2; }
  50% { transform: scaleX(1); transform-origin: left; opacity: 1; }
  100% { transform: scaleX(.18); transform-origin: right; opacity: .2; }
}

#preview-image.map-draggable { cursor: grab; touch-action: none; user-select: none; }
#preview-image.map-dragging { cursor: grabbing; }

.preview-footnote { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 10px; margin-top: 9px; font-size: 9px; letter-spacing: .03em; color: var(--muted); }
.preview-footnote #image-info { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.size-field { display: flex; align-items: center; gap: 6px; margin: 0; flex: none; }
.size-field > span { margin: 0; font-family: var(--font-ui); font-size: 9px; font-weight: 400; letter-spacing: .02em; color: var(--muted); }
.size-field select { width: auto; height: 26px; padding: 2px 22px 2px 7px; background-position: right 6px center; border-color: var(--line); font-size: 9px; color: var(--ink-2); }

#status { display: flex; align-items: flex-start; gap: 7px; min-height: 34px; padding: 9px 0 6px; font-size: 10.5px; line-height: 1.6; color: var(--muted); }
#status::before { content: ""; flex: none; width: 5px; height: 5px; margin-top: 6px; border-radius: 50%; background: currentColor; opacity: .6; }
#status.error { color: var(--danger); }
#status.error::before { opacity: 1; }
#status.stale { color: var(--muted); }
#paste-error, #json-error { margin-top: 6px; font-size: 11px; color: var(--danger); }

/* ------------------------------------------------------------ 弹窗、提示 */

dialog {
  width: 620px;
  max-width: 94vw;
  padding: 20px 22px 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-2);
}
dialog::backdrop { background: rgba(15, 23, 36, .42); backdrop-filter: blur(4px); }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.dialog-heading h2 { font-family: var(--font-display); font-size: 17px; font-weight: 600; }
.icon-button { padding: 0 4px; border: 0; background: none; font-size: 22px; line-height: 1; color: var(--muted); }
.icon-button:hover { color: var(--accent); }
dialog p { margin: 6px 0; font-size: 11.5px; line-height: 1.7; color: var(--muted); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.dialog-actions .primary-button { width: auto; justify-content: center; padding: 0 16px; }
.dialog-actions .secondary-button { height: 40px; padding: 0 14px; font-size: 11.5px; }
.json-example-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 12px 0 14px; }
.json-example-tools label { margin: 0; }
.json-example-tools select { width: auto; max-width: 100%; }
#json-text { font-family: var(--font-ui); font-size: 12px; line-height: 1.65; }
#paste-columns { margin-top: 2px; }

#error-notification {
  position: fixed;
  top: 72px;
  right: 22px;
  z-index: 1000;
  max-width: min(400px, calc(100vw - 44px));
  padding: 13px 16px;
  border: 1px solid color-mix(in srgb, var(--danger) 34%, var(--line));
  border-left: 3px solid var(--danger);
  border-radius: 10px;
  background: var(--surface);
  color: var(--danger);
  box-shadow: var(--shadow-2);
  font-size: 12px;
  line-height: 1.6;
  overflow-wrap: anywhere;
  animation: toast-in .22s var(--ease);
}
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

.page-footer {
  max-width: 1720px;
  margin: 0 auto;
  padding: 18px 3.2% 26px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-top: 1px solid var(--line);
  font-family: var(--font-ui);
  font-size: 9px;
  letter-spacing: .1em;
  color: var(--faint);
}

/* ------------------------------------------------------------ 动效偏好 */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
