* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Noto Sans TC', 'Helvetica Neue', sans-serif;
  background: linear-gradient(135deg, #F8F6FA 0%, #EDE8F5 50%, #F5F0FA 100%);
  min-height: 100vh;
}

/* Header */
.header {
  background: linear-gradient(135deg, #4A2C6A 0%, #6B4D8A 60%, #7B5EA0 100%);
  color: white;
  padding: 16px 28px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 3px 12px rgba(74, 44, 106, 0.25);
  position: relative;
}

.header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #E8C547, #F4A261, #E8C547);
}

.header h1 {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.header .sub {
  font-size: 11px;
  color: #D8C8F0;
  letter-spacing: 0.3px;
}

/* Layout */
.main {
  max-width: 1800px;
  margin: 0 auto;
  padding: 20px 16px;
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 16px;
}

@media(max-width:960px) {
  .main {
    grid-template-columns: 1fr;
  }
}

@media(max-width:480px) {
  .main {
    padding: 10px 8px;
  }
  .header {
    padding: 12px 14px;
  }
  .header h1 {
    font-size: 16px;
  }
  .panel-head {
    padding: 10px 12px;
    font-size: 13px;
  }
}

/* Panels */
.panel {
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(74, 44, 106, 0.08), 0 1px 3px rgba(0, 0, 0, 0.04);
  overflow: visible;
  border: 1px solid rgba(74, 44, 106, 0.06);
}

.panel-head {
  padding: 13px 18px;
  font-size: 14px;
  font-weight: 700;
  border-bottom: none;
  border-radius: 12px 12px 0 0;
}

.panel-head.input {
  background: linear-gradient(135deg, #E8E0F0 0%, #F0EBF7 100%);
  color: #4A2C6A;
  border-bottom: 2px solid #E0D4F0;
}

.panel-head.preview {
  background: linear-gradient(135deg, #FFF3E8 0%, #FFF8F0 100%);
  color: #9C4A1A;
  border-bottom: 2px solid #FFE8D0;
}

.panel-body {
  padding: 18px;
}

/* Buttons */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: all .2s;
}

.btn-go {
  background: linear-gradient(135deg, #6B4D8A, #5A3D7A);
  color: white;
  box-shadow: 0 2px 6px rgba(107, 77, 138, 0.3);
}

.btn-go:hover {
  background: linear-gradient(135deg, #5A3D7A, #4A2C6A);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(107, 77, 138, 0.35);
}

.btn-go:active {
  transform: translateY(0);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 11px;
  border-radius: 12px;
}

.btn:disabled {
  opacity: .4;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* Wizard */
.wizard {
  background: linear-gradient(180deg, #F8F5FC 0%, #F0EBF7 100%);
  border: 1px solid #E0D4F0;
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 10px;
}

.wizard label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #4A2C6A;
  margin: 10px 0 5px;
}

.wizard label:first-child {
  margin-top: 0;
}

.wizard input[type=text],
.wizard select,
.wizard textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #D0C4E0;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  background: white;
  transition: border-color .2s, box-shadow .2s;
}

.wizard input:focus,
.wizard select:focus,
.wizard textarea:focus {
  border-color: #6B4D8A;
  outline: none;
  box-shadow: 0 0 0 3px rgba(107, 77, 138, 0.12);
}

.wizard textarea {
  min-height: 80px;
  resize: vertical;
}

.step-label {
  display: inline-block;
  background: linear-gradient(135deg, #6B4D8A, #5A3D7A);
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 10px;
  margin-right: 6px;
}

.copy-toast {
  font-size: 12px;
  color: #6B4D8A;
  font-weight: 700;
  margin-top: 6px;
  min-height: 18px;
}

textarea.json-input {
  width: 100%;
  min-height: 180px;
  border: 2px dashed #C4B0D8;
  border-radius: 10px;
  padding: 14px;
  font-family: 'Menlo', 'Monaco', 'Consolas', monospace;
  font-size: 12px;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  background: #FAFAFE;
  transition: all .2s;
}

textarea.json-input:focus {
  border-color: #6B4D8A;
  background: white;
  box-shadow: 0 0 0 3px rgba(107, 77, 138, 0.1);
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.chip {
  padding: 4px 12px;
  border-radius: 14px;
  font-size: 11px;
  font-weight: 600;
}

.chip-ok {
  background: #E8E0F0;
  color: #4A2C6A;
}

.chip-err {
  background: #FEE;
  color: #C00;
}

.stats {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.difficulty-desc {
  font-size: 11px;
  color: #777;
  margin-top: 5px;
  min-height: 16px;
  line-height: 1.5;
}

/* Scaffold 2-column layout */
.sc-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  align-items: start;
}

@media(max-width:1200px) {
  .sc-layout {
    grid-template-columns: 1fr;
  }
}

.sc-fill-col {
  min-width: 0;
}

.sc-result-col {
  position: sticky;
  top: 16px;
  align-self: start;
}

/* Scaffold UI */
.scaffold {
  font-family: 'Noto Serif TC', serif;
  line-height: 2.2;
  padding: 16px;
  background: white;
  border: 1px solid #E8E0F0;
  border-radius: 10px;
  font-size: 15px;
  color: #2A2A2A;
}

/* Scaffold tabs */
.sc-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  flex-wrap: wrap;
  border-bottom: 2px solid #E0D4F0;
  padding-bottom: 0;
}

.sc-tab {
  padding: 6px 16px;
  border: 1px solid #D8CCE8;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  background: #F5F0FA;
  color: #9080A8;
  font-size: 12px;
  font-family: 'Noto Sans TC', sans-serif;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  top: 2px;
}

.sc-tab:hover {
  background: #EDE4F7;
  color: #6B4D8A;
}

.sc-tab.active {
  background: white;
  color: #4A2C6A;
  font-weight: 700;
  border-color: #E0D4F0;
  border-bottom: 2px solid white;
}

.sc-tab-pane {
  display: none;
}

.sc-tab-pane.active {
  display: block;
}

.scaffold .sc-title {
  font-size: 16px;
  font-weight: 800;
  color: #4A2C6A;
  margin-bottom: 4px;
}

.scaffold .sc-source {
  text-align: center;
  font-size: 11px;
  color: #A090B0;
  margin-bottom: 10px;
  font-style: italic;
}

/* Cover image prompt */
.sc-cover-prompt {
  margin: 8px 0 12px;
  border: 1px solid #E0D4F0;
  border-radius: 8px;
  font-family: 'Noto Sans TC', sans-serif;
  font-size: 12px;
  overflow: hidden;
}

.sc-cover-toggle {
  padding: 6px 12px;
  background: #F8F4FC;
  cursor: pointer;
  font-weight: 600;
  color: #6B4D8A;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sc-cover-toggle:hover {
  background: #F0E8F8;
}

.sc-cover-arrow {
  font-size: 10px;
  transition: transform 0.2s;
}

.sc-cover-prompt.open .sc-cover-arrow {
  transform: rotate(90deg);
}

.sc-cover-body {
  display: none;
  padding: 10px 12px;
}

.sc-cover-prompt.open .sc-cover-body {
  display: block;
}

.sc-cover-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.sc-cover-label {
  font-weight: 600;
  color: #4A2C6A;
  font-size: 11px;
}

.sc-cover-copy {
  padding: 2px 10px !important;
  font-size: 10px !important;
  background: #E8E0F0 !important;
  color: #4A2C6A !important;
  border: none !important;
}

.sc-cover-text {
  font-size: 11px;
  color: #666;
  line-height: 1.5;
  padding: 4px 8px;
  background: #FAFAFA;
  border-radius: 4px;
  margin-bottom: 8px;
  word-break: break-all;
}

.scaffold .sc-segment {
  margin-bottom: 10px;
  text-indent: 2em;
}

.sc-blank {
  display: inline-block;
  position: relative;
  min-width: 64px;
  text-align: center;
  border-bottom: 2px dashed #C4B0D8;
  cursor: pointer;
  transition: all .2s;
  padding: 0 2px;
  margin: 0 1px;
}

.sc-blank:hover {
  border-bottom-color: #6B4D8A;
  background: rgba(107, 77, 138, 0.06);
  border-radius: 4px 4px 0 0;
}

.sc-blank.filled {
  border-bottom-color: #6B4D8A;
  color: #4A2C6A;
  font-weight: 700;
  border-bottom-style: solid;
}

.sc-blank .sc-hint {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  color: #B0A0C0;
  white-space: nowrap;
  pointer-events: none;
  font-family: 'Noto Sans TC', sans-serif;
}

/* Popup */
.sc-popup {
  display: none;
  position: fixed;
  background: white;
  border: 1px solid #E0D4F0;
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(74, 44, 106, 0.2), 0 2px 8px rgba(0, 0, 0, 0.06);
  padding: 14px;
  z-index: 1000;
  min-width: 220px;
  max-width: 280px;
  font-size: 13px;
  font-family: 'Noto Sans TC', sans-serif;
}

.sc-popup.open {
  display: block;
  animation: popIn .15s ease-out;
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.sc-popup .pop-label {
  font-size: 10px;
  color: #A090B0;
  margin-bottom: 6px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sc-popup .pop-hint {
  font-size: 12px;
  color: #6B4D8A;
  margin-bottom: 8px;
  font-style: italic;
  padding: 6px 10px;
  background: #F8F5FC;
  border-radius: 6px;
  border-left: 3px solid #C4B0D8;
}

.sc-sug {
  padding: 7px 12px;
  border-radius: 8px;
  cursor: pointer;
  margin: 3px 0;
  transition: all .15s;
  font-weight: 500;
}

.sc-sug:hover {
  background: #F0EBF7;
  color: #4A2C6A;
}

.sc-sug.selected {
  background: linear-gradient(135deg, #6B4D8A, #5A3D7A);
  color: white;
}

.sc-custom {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid #D0C4E0;
  border-radius: 8px;
  font-size: 12px;
  font-family: inherit;
  margin-top: 6px;
  transition: border-color .2s;
}

.sc-custom:focus {
  border-color: #6B4D8A;
  outline: none;
  box-shadow: 0 0 0 3px rgba(107, 77, 138, 0.12);
}

/* Result area */
.sc-result {
  margin-top: 0;
  padding: 14px;
  background: linear-gradient(180deg, #F8F5FC, #F0EBF7);
  border-radius: 10px;
  border: 1px solid #E0D4F0;
}

.sc-result-title {
  font-size: 14px;
  font-weight: 700;
  color: #4A2C6A;
  margin-bottom: 10px;
}

.sc-result-text {
  font-size: 16px;
  line-height: 2.2;
  color: #333;
  font-family: 'Noto Serif TC', serif;
}

.sc-result-text .w-original {
  color: #A0A0A0;
}

.sc-result-text .w-suggestion {
  color: #2D6A4F;
  font-weight: 700;
  border-bottom: 2px solid rgba(45, 106, 79, 0.3);
  padding-bottom: 1px;
}

.sc-result-text .w-custom {
  color: #C75050;
  font-weight: 700;
  border-bottom: 2px solid rgba(199, 80, 80, 0.3);
  padding-bottom: 1px;
}

.sc-blank.filled.from-sug {
  border-bottom-color: #2D6A4F;
}

.sc-blank.filled.from-custom {
  border-bottom-color: #C75050;
}

/* Sentence-A skeleton block */
.sc-sentence-block {
  display: block;
  background: linear-gradient(135deg, #F8F4FC, #F0E8F8);
  border: 1.5px dashed #C4B0D8;
  border-radius: 10px;
  padding: 10px 14px;
  margin: 8px 0;
  text-indent: 0;
}

.sc-sentence-block.filled {
  border-color: #6B4D8A;
  border-style: solid;
  background: linear-gradient(135deg, #F5F0FA, #EDE4F7);
}

.sc-sentence-block.from-same {
  border-color: #9C6B28;
}

.sc-sentence-technique {
  display: inline-block;
  font-size: 10px;
  background: #E8E0F0;
  color: #4A2C6A;
  padding: 1px 7px;
  border-radius: 10px;
}

.sc-sentence-hint {
  font-size: 11px;
  color: #6B4D8A;
  font-style: italic;
}

.sc-sentence-structure {
  font-size: 14px;
  line-height: 2.2;
  color: #333;
}

.sc-slot {
  display: inline-block;
  min-width: 48px;
  max-width: 160px;
  border: none;
  border-bottom: 2px dashed #C4B0D8;
  background: rgba(255, 255, 255, 0.6);
  padding: 1px 4px;
  font-size: 13px;
  color: #4A2C6A;
  font-family: 'Noto Sans TC', sans-serif;
  text-align: center;
  transition: border-color 0.2s;
  border-radius: 0;
  margin: 0 1px;
  vertical-align: baseline;
}

.sc-slot:focus {
  outline: none;
  border-bottom-color: #6B4D8A;
  border-bottom-style: solid;
  background: rgba(255, 255, 255, 0.9);
}

.sc-slot.has-value {
  border-bottom-style: solid;
  border-bottom-color: #6B4D8A;
  font-weight: 700;
}

.sc-sentence-preview {
  margin-top: 6px;
  font-size: 11px;
  color: #999;
  border-top: 1px solid #E0D4F0;
  padding-top: 4px;
}

.sc-sentence-preview .assembled {
  color: #4A2C6A;
  font-weight: 500;
}

.sc-legend {
  display: flex;
  gap: 16px;
  font-size: 11px;
  margin-top: 10px;
  flex-wrap: wrap;
  color: #666;
}

.sc-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.sc-legend .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

/* 字帖 */
.cb-controls-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.cb-controls-grid label {
  display: flex;
  flex-direction: column;
  font-size: 11px;
  color: #666;
  font-weight: 500;
  gap: 3px;
}

.cb-controls-grid select,
.cb-controls-grid input[type=text] {
  padding: 6px 8px;
  border: 1px solid #D0C4E0;
  border-radius: 6px;
  font-size: 12px;
  font-family: inherit;
  background: white;
}

.cb-controls-grid select:focus,
.cb-controls-grid input[type=text]:focus {
  border-color: #6B4D8A;
  outline: none;
}

.copybook-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin: 12px 0;
}

.copybook-controls select,
.copybook-controls label {
  font-size: 12px;
}

.cb-actions {
  display: flex;
  gap: 8px;
  margin: 12px 0 4px;
}

.copybook {
  --cell: 40px;
  display: grid;
  gap: 0;
  border: 2px solid #444;
  background: #fff;
  width: fit-content;
  margin: 0 auto;
  border-radius: 2px;
}

.cb-cell {
  width: var(--cell);
  height: var(--cell);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #B0B0B0;
  position: relative;
  font-family: var(--cb-font, 'KaiTi', 'BiauKai', 'DFKai-SB', serif);
  font-size: calc(var(--cell)*0.75);
  color: #333;
}

.cb-cell.trace {
  color: var(--trace-color, rgba(0, 0, 0, 0.1));
}

.cb-cell.empty {
  color: transparent;
}

/* 直書時特定標點旋轉 90°（破折號、刪節號、括號等） */
.cb-rotate {
  display: inline-block;
  transform: rotate(90deg);
}

/* 田字格 */
.cb-tian .cb-cell::before,
.cb-tian .cb-cell::after {
  content: '';
  position: absolute;
  background: #D0D0D0;
}

.cb-tian .cb-cell::before {
  width: 1px;
  height: 100%;
  left: 50%;
  top: 0;
}

.cb-tian .cb-cell::after {
  height: 1px;
  width: 100%;
  top: 50%;
  left: 0;
}

/* 米字格 */
.cb-mi .cb-cell::before {
  content: '';
  position: absolute;
  width: 141%;
  height: 1px;
  background: #D0D0D0;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(45deg);
}

.cb-mi .cb-cell::after {
  content: '';
  position: absolute;
  width: 141%;
  height: 1px;
  background: #D0D0D0;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-45deg);
}

.cb-mi .cb-cell .mi-cross {
  position: absolute;
  inset: 0;
}

.cb-mi .cb-cell .mi-cross::before {
  content: '';
  position: absolute;
  width: 1px;
  height: 100%;
  left: 50%;
  top: 0;
  background: #D0D0D0;
}

.cb-mi .cb-cell .mi-cross::after {
  content: '';
  position: absolute;
  height: 1px;
  width: 100%;
  top: 50%;
  left: 0;
  background: #D0D0D0;
}

/* 九宮格 */
.cb-jiu .cb-cell {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr 1fr;
}

.cb-jiu .cb-cell .jiu-sub {
  border: 1px dashed #ddd;
}

.cb-jiu .cb-cell .jiu-char {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 直式 */
.copybook.cb-vertical {
  grid-auto-flow: column;
  direction: rtl;
}

.cb-divider {
  border: none;
  border-top: 2px dashed #E0D4F0;
  margin: 16px 0;
}

/* History */
.history-section {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px 32px;
}

.history-toggle {
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.history-toggle:hover {
  color: #6B4D8A;
}

.hist-item {
  display: grid;
  grid-template-columns: 120px 1fr 50px 30px;
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 12px;
  transition: background .15s;
}

.hist-item:nth-child(odd) {
  background: #FAFAFE;
}

.hist-item:hover {
  background: #F0EBF7;
}

.hist-bar {
  display: flex;
  height: 14px;
  border-radius: 7px;
  overflow: hidden;
}

.hist-bar-custom {
  background: linear-gradient(90deg, #E85D5D, #C75050);
}

.hist-bar-sug {
  background: linear-gradient(90deg, #4CAF7D, #2D6A4F);
}

.hist-bar-empty {
  background: #E8E0F0;
}

.hist-pct {
  font-size: 11px;
  font-weight: 700;
  text-align: right;
}

/* --- 舊版角標（僅網頁預覽用） --- */
/* 注意：字帖用的 .cb-mark 在下方另有定義，會覆蓋這裡 */
.sc-blank .cb-mark {
  position: absolute;
  top: 1px;
  right: 2px;
  font-size: 8px;
  font-family: 'Noto Sans TC', sans-serif;
  color: #777;
  line-height: 1;
}

/* Print (替換：純粹黑白列印美學) */
/* ═══════════════════════════════════════════════════════════════
   印刷版型：黑白經典 / 森林蜜桃（彩色）
   用 CSS 變數讓網頁預覽與列印自動切換，確保所見即所得
   ═══════════════════════════════════════════════════════════════ */

/* 預設黑白版 */
.copybook-sheet {
  --theme-title: #000;
  --theme-subtitle: #666;
  --theme-body: #333;
  --theme-meta: #777;
  --theme-outer-border: #333;
  --theme-inner-border: #999;
  --theme-guide: #D5D5D5;           /* 田字格/米字格的引導線 */
  --theme-paper: #fff;
  --theme-accent: #333;             /* 班級欄底線、分隔 */
  --theme-mark: #888;               /* 右上角「創/參」 */
}

/* 森林蜜桃彩色版 */
.copybook-sheet.theme-peach {
  --theme-title: #4A2C6A;           /* 主標深紫 */
  --theme-subtitle: #E8A598;        /* 副標蜜桃 */
  --theme-body: #3D2A4F;
  --theme-meta: #8B6F9F;
  --theme-outer-border: #2D5F3F;    /* 森林綠粗外框 */
  --theme-inner-border: #A8C5A0;    /* 淡綠內框 */
  --theme-guide: #E0D0E8;           /* 淡紫引導線 */
  --theme-paper: #FFFDF7;           /* 象牙白紙張 */
  --theme-accent: #4A2C6A;
  --theme-mark: #C26D60;            /* 蜜桃紅角標 */
}

/* A4 紙張預覽容器：讓網頁預覽就像一張真實紙 */
.copybook-sheet {
  width: 210mm;
  min-height: 297mm;
  padding: 8.5mm 10mm 10mm;
  margin: 0 auto 16px;
  background: var(--theme-paper);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
  box-sizing: border-box;
  position: relative;
  page-break-after: always;
}

.copybook-sheet:last-child {
  page-break-after: auto;
}

.cb-sheet-title {
  text-align: center;
  font-size: 20pt;
  font-weight: 700;
  color: var(--theme-title);
  letter-spacing: 3pt;
  margin-bottom: 2mm;
  font-family: var(--cb-font, 'KaiTi', 'BiauKai', serif);
}

.cb-sheet-school {
  text-align: center;
  font-size: 11pt;
  color: var(--theme-subtitle);
  letter-spacing: 4pt;
  margin-bottom: 1mm;
}

.cb-sheet-source {
  text-align: center;
  font-size: 10pt;
  color: var(--theme-subtitle);
  font-style: italic;
  margin-bottom: 3mm;
}

.cb-sheet-meta {
  text-align: right;
  font-size: 11pt;
  color: var(--theme-body);
  border-bottom: 0.75pt solid var(--theme-accent);
  padding-bottom: 2pt;
  margin-bottom: 3mm;
}

.cb-sheet-stats {
  text-align: center;
  font-size: 10pt;
  color: var(--theme-body);
  margin-bottom: 1mm;
  letter-spacing: 0.5pt;
}

.cb-sheet-stats b {
  color: var(--theme-title);
}

.cb-sheet-legend {
  text-align: center;
  font-size: 8pt;
  color: var(--theme-meta);
  margin-bottom: 4mm;
}

/* copybook 表格在 sheet 內的樣式 */
.copybook-sheet .copybook {
  border: 1.5pt solid var(--theme-outer-border);
  background: var(--theme-paper);
}

.copybook-sheet .cb-cell {
  border: 0.5pt solid var(--theme-inner-border);
}

/* 各種格線主題化（彩色版引導線變淡紫） */
.copybook-sheet .cb-tian .cb-cell::before,
.copybook-sheet .cb-tian .cb-cell::after,
.copybook-sheet .cb-mi .cb-cell::before,
.copybook-sheet .cb-mi .cb-cell::after,
.copybook-sheet .cb-mi .cb-cell .mi-cross::before,
.copybook-sheet .cb-mi .cb-cell .mi-cross::after {
  background: var(--theme-guide);
}

.copybook-sheet .cb-jiu .cb-cell .jiu-sub {
  border-color: var(--theme-guide);
}

/* 右上角角標 [創]/[參]/[原]（字帖版） */
.cb-mark {
  position: absolute;
  top: 1px;
  right: 2px;
  font-size: 6pt;
  line-height: 1;
  font-family: 'Noto Sans TC', sans-serif;
  font-weight: 700;
}

/* 字帖角標顏色：預設用主題色，可由 copybook-sheet 的色系覆蓋 */
.copybook .cb-mark-custom { color: #C75050; }
.copybook .cb-mark-sug    { color: #2D6A4F; }
.copybook .cb-mark-same   { color: #9C6B28; }

/* 彩色版（森林蜜桃）角標用主題色 */
.copybook-sheet.theme-peach .cb-mark-custom { color: var(--theme-title); }
.copybook-sheet.theme-peach .cb-mark-sug    { color: #2D6A4F; }
.copybook-sheet.theme-peach .cb-mark-same   { color: #9C6B28; }

/* ═══════════════════════════════════════════════════════════════
   列印樣式：A4 所見即所得（按 Cmd/Ctrl+P 選「另存為 PDF」即獲得 PDF）
   ═══════════════════════════════════════════════════════════════ */
@page {
  size: A4;
  margin: 0;
}

@media print {
  body {
    background: white !important;
    margin: 0 !important;
    padding: 0 !important;
  }
}

/* ═══════════════════════════════════════════════════════════════
   列印專用 class：由 printCopybook() 在列印前加到 body 上
   不使用 @media print，而是普通 class，瀏覽器一定會套用
   搭配 @page 的 A4 設定達成「所見即所得」PDF
   ═══════════════════════════════════════════════════════════════ */
body.printing-copybook {
  background: white !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* 只顯示 copybookWrapper；其他 body 直下元素全部強制隱藏 */
body.printing-copybook > * {
  display: none !important;
}
body.printing-copybook > #copybookWrapper {
  display: block !important;
  max-width: none !important;
  padding: 0 !important;
  margin: 0 !important;
}

/* 字帖 panel 本身：去除所有多餘裝飾 */
body.printing-copybook #copybookSection {
  display: block !important;
  box-shadow: none !important;
  border: none !important;
  border-radius: 0 !important;
  overflow: visible !important;
}

/* 隱藏字帖 panel 內的控制項，只留字帖內容 */
body.printing-copybook #copybookSection .panel-head,
body.printing-copybook #copybookSection .cb-controls-grid,
body.printing-copybook #copybookSection .cb-actions {
  display: none !important;
}

body.printing-copybook #copybookSection .panel-body {
  padding: 0 !important;
}

body.printing-copybook #copybookArea {
  background: transparent !important;
  padding: 0 !important;
}

/* A4 紙張容器在列印時：移除陰影、正好填滿頁面 */
body.printing-copybook .copybook-sheet {
  box-shadow: none !important;
  margin: 0 !important;
  width: 210mm !important;
  min-height: 297mm !important;
  page-break-after: always;
  page-break-inside: avoid;
}

body.printing-copybook .copybook-sheet:last-child {
  page-break-after: auto;
}

body.printing-copybook .copybook {
  page-break-inside: avoid;
  margin: 0 auto;
}

body.printing-copybook .cb-header {
  page-break-inside: avoid;
}

body.printing-copybook .cb-divider {
  display: none !important;
}

/* 讓顏色能印出來（不要瀏覽器自動去背） */
body.printing-copybook * {
  -webkit-print-color-adjust: exact !important;
  print-color-adjust: exact !important;
}

/* ═══ 大字版 ═══ */
.scaffold.large-print .sc-title {
  font-size: 24px;
  margin-bottom: 8px;
}
.scaffold.large-print .sc-source {
  font-size: 15px;
  margin-bottom: 14px;
}
.scaffold.large-print .sc-segment {
  font-size: 20px;
  line-height: 2.2;
  margin-bottom: 18px;
}
.scaffold.large-print .sc-blank {
  min-width: 90px;
  padding: 2px 6px;
  border-bottom-width: 3px;
}
.scaffold.large-print .sc-blank .sc-hint {
  font-size: 12px;
  top: -22px;
}
.scaffold.large-print .sc-blank .sc-val {
  font-size: 20px;
}
.scaffold.large-print .sc-popup {
  font-size: 16px;
  min-width: 260px;
  max-width: 340px;
  padding: 18px;
}
.scaffold.large-print .sc-popup .pop-hint {
  font-size: 15px;
}
.scaffold.large-print .sc-popup .pop-label {
  font-size: 13px;
}
.scaffold.large-print .sc-sug {
  font-size: 16px;
  padding: 8px 14px;
}
.scaffold.large-print .sc-custom {
  font-size: 16px;
  padding: 8px 10px;
}
.scaffold.large-print .sc-slot {
  font-size: 18px;
  padding: 6px 8px;
}
.scaffold.large-print .sc-slot-label {
  font-size: 14px;
}
.scaffold.large-print .sc-sentence-block {
  padding: 16px;
  margin: 12px 0;
}
.sc-result.large-print .sc-result-title {
  font-size: 18px;
}
.sc-result.large-print .sc-result-text {
  font-size: 20px;
  line-height: 2.2;
}
.sc-result.large-print .sc-legend {
  font-size: 13px;
}
