/* =========================================================================
   課文讀寫合一 (reading_writing.css)
   專為臺灣國小二～四年級及特殊教育學生打造的溫暖、低刺激、無障礙學習樣式
   ========================================================================= */

:root {
  --bg-cream: #faf8f5;
  --bg-card: #ffffff;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --border-light: #e2e8f0;
  
  /* 五大步驟主題柔和色 */
  --step-read: #059669;
  --step-read-bg: #ecfdf5;
  --step-find: #0284c7;
  --step-find-bg: #f0f9ff;
  --step-seq: #d97706;
  --step-seq-bg: #fffbeb;
  --step-speak: #e11d48;
  --step-speak-bg: #fff1f2;
  --step-write: #4f46e5;
  --step-write-bg: #eef2ff;
}

body {
  background-color: var(--bg-cream);
  color: var(--text-main);
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
}

/* 適合閱讀障礙之字體設定模式 */
body.font-mode-large .reader-paragraph {
  font-size: 24px !important;
  line-height: 2.2 !important;
}

body.font-mode-normal .reader-paragraph {
  font-size: 20px !important;
  line-height: 1.9 !important;
}

body.spacing-mode-loose .reader-paragraph {
  line-height: 2.3 !important;
  letter-spacing: 0.06em !important;
}

body.spacing-mode-normal .reader-paragraph {
  line-height: 1.9 !important;
  letter-spacing: 0.04em !important;
}

/* =========================================================================
   學生清晰閱讀無障礙字體規範 (避免筆畫粗黑黏連、維持清晰字重與間距)
   ========================================================================= */

/* 逐字課文元件：避免粗體、適當字距 */
.reading-char {
  font-weight: 500;
  margin-inline: 0.03em;
  transition: color 0.12s ease-in-out;
}
.reading-char.reading-read {
  color: #d97706 !important;
}

/* 課文逐字閱讀內文與重點摘要 */
.student-reading-text,
.reader-paragraph {
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  font-weight: 500 !important;
  letter-spacing: 0.04em !important;
  line-height: 1.85 !important;
  color: #1e293b;
}

/* 題目與理解問題 */
.student-question-text {
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  font-weight: 500 !important;
  letter-spacing: 0.04em !important;
  line-height: 1.75 !important;
  color: #0f172a;
}

/* 故事山、因果歷程、步驟事件說明 */
.story-mountain-text {
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  font-weight: 500 !important;
  letter-spacing: 0.04em !important;
  line-height: 1.75 !important;
  color: #1e293b;
}

/* 選項與提示文字 */
.student-option-text,
.student-hint-text {
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  font-weight: 500 !important;
  letter-spacing: 0.03em !important;
  line-height: 1.7 !important;
}

/* 學生作答輸入框 (textarea / input) 降低過黑字重 */
.student-input-text {
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  font-weight: 500 !important;
  letter-spacing: 0.03em !important;
  line-height: 1.75 !important;
}

/* 上下排列注音與國字間距防禦規則 */
ruby {
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  font-weight: 500;
  ruby-position: over;
  margin-inline: 0.05em;
}
rt {
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  font-weight: 400;
  font-size: 0.5em;
  line-height: 1;
  letter-spacing: 0.02em;
  user-select: none;
}

/* 段落朗讀中之溫暖高亮提示 (淡藍/淡黃色外框，無刺眼動畫) */
.tts-speaking-highlight {
  border-color: #38bdf8 !important;
  background-color: #f0f9ff !important;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.25) !important;
  transition: all 0.3s ease;
}

/* 觸控友善大按鈕 (規範 >= 44px) */
.btn-touch {
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  touch-action: manipulation;
}

/* 無障礙 Focus 狀態提示 */
button:focus-visible, 
input:focus-visible, 
textarea:focus-visible, 
select:focus-visible {
  outline: 3px solid #6366f1 !important;
  outline-offset: 2px !important;
}

/* 拖曳排序卡片樣式 */
.draggable-card {
  cursor: grab;
  touch-action: pan-y;
  transition: transform 0.2s cubic-bezier(0.2, 0, 0, 1), box-shadow 0.2s ease, opacity 0.2s ease;
}

.draggable-card:active {
  cursor: grabbing;
}

.draggable-card.is-dragging {
  opacity: 0.45;
  transform: scale(0.97);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
}

.draggable-card.drag-over {
  border-color: #f59e0b !important;
  background-color: #fffbeb !important;
  transform: translateY(-2px);
}

/* 圖片未載入或錯誤時之溫和替代視覺 (不顯示瀏覽器破圖符號) */
.img-fallback-box {
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border: 2px dashed #cbd5e1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1.5rem;
  color: #64748b;
  min-height: 180px;
  border-radius: 1rem;
}

/* 故事山步驟卡片連結條 */
.mountain-step-card {
  position: relative;
}

.mountain-step-card::after {
  content: '➔';
  position: absolute;
  right: -14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  color: #94a3b8;
  font-weight: 900;
}

@media (max-width: 768px) {
  .mountain-step-card::after {
    content: '↓';
    right: 50%;
    top: auto;
    bottom: -16px;
    transform: translateX(50%);
  }
}

.mountain-step-card:last-child::after {
  display: none;
}

/* ================= 列印樣式 (@media print) ================= */
@media print {
  @page {
    size: A4 portrait;
    margin: 0;
  }
  
  html, body {
    background: #ffffff !important;
    color: #000000 !important;
    margin: 0 !important;
    padding: 0 !important;
    font-family: 'Noto Sans TC', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Microsoft JhengHei", sans-serif !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .no-print,
  #app-header,
  #step-nav-bar,
  main,
  #step-content-area,
  #bottom-nav-bar,
  #reader-controls-bar,
  #print-modal-backdrop,
  .btn-print-hide {
    display: none !important;
  }

  .print-only-container {
    display: block !important;
    width: 190mm !important;
    max-width: 190mm !important;
    margin: 0 auto !important;
    padding: 0 !important;
  }

  /* 物理 A4 直式單頁限制 (190mm × 277mm) */
  #printWorksheet {
    width: 190mm !important;
    max-width: 190mm !important;
    margin: 10mm auto !important;
    padding: 0 !important;
    box-sizing: border-box !important;
    background: #ffffff !important;
    color: #000000 !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  #printWorksheet * {
    box-sizing: border-box !important;
  }

  /* 頂部 Header (~15mm) */
  #printWorksheet .print-header {
    width: 100% !important;
    border-bottom: 2px solid #0f172a !important;
    padding-bottom: 2mm !important;
    margin-bottom: 3.5mm !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: flex-end !important;
  }

  #printWorksheet .print-title {
    font-size: 15pt !important;
    font-weight: 900 !important;
    line-height: 1.2 !important;
    color: #0f172a !important;
    margin: 0 !important;
  }

  #printWorksheet .print-subtitle {
    font-size: 9pt !important;
    color: #64748b !important;
    font-weight: 700 !important;
    margin-top: 1mm !important;
  }

  #printWorksheet .print-meta {
    font-size: 10pt !important;
    font-weight: 700 !important;
    color: #1e293b !important;
    text-align: right !important;
    line-height: 1.5 !important;
    white-space: nowrap !important;
  }

  /* 區塊標題 */
  #printWorksheet .print-section-title {
    font-size: 11pt !important;
    font-weight: 900 !important;
    color: #0f172a !important;
    margin: 0 0 2mm 0 !important;
    line-height: 1.2 !important;
  }

  /* 學習單 A：四大重點 2×2 格子 (高度增加 2 倍至 32mm，無底橫線，給足書寫空間) */
  #printWorksheet .print-keypoints-grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 3mm !important;
    width: 100% !important;
    margin-bottom: 4mm !important;
  }

  /* 學習單 A：五大重點 (3+2 佈局，高度 22mm，完美融入 A4 單頁) */
  #printWorksheet .print-keypoints-grid-5 {
    display: grid !important;
    grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
    gap: 2.5mm !important;
    width: 100% !important;
    margin-bottom: 3.5mm !important;
  }

  #printWorksheet .print-keypoints-grid-5 .print-keypoint-item {
    height: 22mm !important;
    min-height: 22mm !important;
    padding: 2mm 3mm !important;
  }

  #printWorksheet .print-keypoints-grid-5 .print-keypoint-item:nth-child(1),
  #printWorksheet .print-keypoints-grid-5 .print-keypoint-item:nth-child(2),
  #printWorksheet .print-keypoints-grid-5 .print-keypoint-item:nth-child(3) {
    grid-column: span 2 !important;
  }

  #printWorksheet .print-keypoints-grid-5 .print-keypoint-item:nth-child(4),
  #printWorksheet .print-keypoints-grid-5 .print-keypoint-item:nth-child(5) {
    grid-column: span 3 !important;
  }

  #printWorksheet .print-keypoint-item {
    border: 1px solid #94a3b8 !important;
    border-radius: 2.5mm !important;
    padding: 3mm 4mm !important;
    font-size: 10.5pt !important;
    line-height: 1.4 !important;
    height: 32mm !important;
    min-height: 32mm !important;
    background: #ffffff !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
  }

  #printWorksheet .print-keypoint-label {
    font-weight: 900 !important;
    color: #0f172a !important;
    font-size: 11pt !important;
  }

  #printWorksheet .print-keypoint-val {
    font-weight: 700 !important;
    color: #334155 !important;
    margin-top: 1.5mm !important;
    word-break: break-word !important;
    flex: 1 !important;
  }

  /* 2×2 四格圖片專屬 Grid */
  #printWorksheet .print-story-grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 3.5mm !important;
    width: 100% !important;
  }

  /* 3×2 六格圖片專屬 Grid (新詩/主題情境用) */
  #printWorksheet .print-story-grid-6 {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 2.5mm !important;
    width: 100% !important;
  }

  /* 5 格圖片專屬 Grid (第一排 3 張，第二排 2 張置中) */
  #printWorksheet .print-story-grid-5 {
    display: grid !important;
    grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
    gap: 2.5mm !important;
    width: 100% !important;
  }

  #printWorksheet .print-story-grid-5 > :nth-child(1),
  #printWorksheet .print-story-grid-5 > :nth-child(2),
  #printWorksheet .print-story-grid-5 > :nth-child(3) {
    grid-column: span 2 !important;
  }

  #printWorksheet .print-story-grid-5 > :nth-child(4) {
    grid-column: 2 / span 2 !important;
  }

  #printWorksheet .print-story-grid-5 > :nth-child(5) {
    grid-column: 4 / span 2 !important;
  }

  /* 學習單 A (閱讀重點) 圖片卡片：高度調整為 72mm，確保與雙倍重點框完美共存於單頁 */
  #printWorksheet .print-story-card-focus {
    width: 100% !important;
    height: 72mm !important;
    min-width: 0 !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 2.5mm !important;
    padding: 1.5mm !important;
    background: #ffffff !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
  }

  #printWorksheet .print-story-card-focus .img-box {
    width: 100% !important;
    height: 63mm !important;
    min-height: 63mm !important;
    max-height: 63mm !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
    background: #f8fafc !important;
    border-radius: 1.5mm !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  /* 學習單 A (五格/六格情境) 圖片卡片：高度 58mm，3×2 或 3+2 佈局單頁完美共存 */
  #printWorksheet .print-story-card-focus-6,
  #printWorksheet .print-story-card-focus-5 {
    width: 100% !important;
    height: 58mm !important;
    min-width: 0 !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 2mm !important;
    padding: 1.2mm !important;
    background: #ffffff !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
  }

  #printWorksheet .print-story-card-focus-6 .img-box,
  #printWorksheet .print-story-card-focus-5 .img-box {
    width: 100% !important;
    height: 48mm !important;
    min-height: 48mm !important;
    max-height: 48mm !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
    background: #f8fafc !important;
    border-radius: 1.2mm !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  /* 學習單 B (讀寫整合) 圖片卡片：高度 42mm，精簡緊湊 */
  #printWorksheet .print-story-card-integrated {
    width: 100% !important;
    height: 42mm !important;
    min-width: 0 !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 2mm !important;
    padding: 1.2mm !important;
    background: #ffffff !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
  }

  #printWorksheet .print-story-card-integrated .img-box {
    width: 100% !important;
    height: 34mm !important;
    min-height: 34mm !important;
    max-height: 34mm !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
    background: #f8fafc !important;
    border-radius: 1.5mm !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  /* 學習單 B (五格/六格情境) 圖片卡片：高度 34mm，3×2 或 3+2 佈局單頁完美共存 */
  #printWorksheet .print-story-card-integrated-6,
  #printWorksheet .print-story-card-integrated-5 {
    width: 100% !important;
    height: 34mm !important;
    min-width: 0 !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 1.5mm !important;
    padding: 1mm !important;
    background: #ffffff !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
  }

  #printWorksheet .print-story-card-integrated-6 .img-box,
  #printWorksheet .print-story-card-integrated-5 .img-box {
    width: 100% !important;
    height: 26mm !important;
    min-height: 26mm !important;
    max-height: 26mm !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
    background: #f8fafc !important;
    border-radius: 1mm !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  /* 核心：圖片不超出、不變形、嚴格 contain */
  #printWorksheet .print-story-card img,
  #printWorksheet .print-story-card-focus-6 img,
  #printWorksheet .print-story-card-focus-5 img,
  #printWorksheet .print-story-card-integrated-6 img,
  #printWorksheet .print-story-card-integrated-5 img {
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    object-fit: contain !important;
    object-position: center !important;
    display: block !important;
  }

  #printWorksheet .print-card-caption {
    font-size: 9.5pt !important;
    font-weight: 800 !important;
    text-align: center !important;
    color: #1e293b !important;
    line-height: 1.3 !important;
    padding-top: 1mm !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  /* 學習單 B：四步造句區 (每行 height 14.5mm，上下間距充足，僅單條實體底線) */
  #printWorksheet .print-sentences-box {
    width: 100% !important;
    border: none !important;
    padding: 0 !important;
    margin-bottom: 3.5mm !important;
    background: transparent !important;
  }

  #printWorksheet .print-sentence-row {
    font-size: 11pt !important;
    line-height: 1.4 !important;
    height: 14mm !important;
    min-height: 14mm !important;
    display: flex !important;
    align-items: flex-end !important;
    border-bottom: none !important;
    padding: 0 0 1.5mm 0 !important;
    margin-bottom: 1.5mm !important;
  }

  #printWorksheet .print-sentence-row:last-child {
    margin-bottom: 0 !important;
  }

  /* 學習單 B：五句摘要專用緊湊行 (height 10.5mm，5 句合占 ~53mm) */
  #printWorksheet .print-sentence-row-5 {
    font-size: 10pt !important;
    line-height: 1.3 !important;
    height: 10.5mm !important;
    min-height: 10.5mm !important;
    display: flex !important;
    align-items: flex-end !important;
    border-bottom: none !important;
    padding: 0 0 1mm 0 !important;
    margin-bottom: 1.2mm !important;
  }

  #printWorksheet .print-sentence-row-5 .print-sentence-label {
    font-weight: 900 !important;
    color: #1e293b !important;
    width: 25mm !important;
    flex-shrink: 0 !important;
    padding-bottom: 0.8mm !important;
  }

  #printWorksheet .print-sentence-row-5 .print-sentence-content {
    font-weight: 700 !important;
    color: #0f172a !important;
    flex: 1 !important;
    border-bottom: 1.5px solid #64748b !important;
    min-height: 6mm !important;
    padding-left: 2mm !important;
    padding-bottom: 0.8mm !important;
  }

  #printWorksheet .print-sentence-label {
    font-weight: 900 !important;
    color: #1e293b !important;
    width: 20mm !important;
    flex-shrink: 0 !important;
    padding-bottom: 1mm !important;
  }

  #printWorksheet .print-sentence-content {
    font-weight: 700 !important;
    color: #0f172a !important;
    flex: 1 !important;
    border-bottom: 1.5px solid #64748b !important;
    min-height: 7mm !important;
    padding-left: 2mm !important;
    padding-bottom: 1mm !important;
  }

  /* 學習單 B：第三區把四句連成一篇小短文 (單一大型作文線，無外框) */
  #printWorksheet .print-section-header-row {
    display: flex !important;
    align-items: baseline !important;
    gap: 2.5mm !important;
    margin-top: 3mm !important;
    margin-bottom: 1.5mm !important;
  }

  #printWorksheet .print-section-hint {
    font-size: 9.5pt !important;
    font-weight: 700 !important;
    color: #64748b !important;
  }

  #printWorksheet .print-prompt-text {
    font-size: 9.5pt !important;
    font-weight: 700 !important;
    color: #334155 !important;
    margin-bottom: 2mm !important;
    line-height: 1.3 !important;
  }

  #printWorksheet .print-essay-box {
    width: 100% !important;
    border: none !important;
    padding: 0 !important;
    background: transparent !important;
  }

  #printWorksheet .print-essay-lines {
    width: 100% !important;
    display: flex !important;
    flex-direction: column !important;
  }

  #printWorksheet .print-essay-line {
    width: 100% !important;
    height: 10.5mm !important;
    border-bottom: 1.5px solid #94a3b8 !important;
    box-sizing: border-box !important;
  }

  #printWorksheet .print-essay-content {
    font-size: 11pt !important;
    line-height: 1.8 !important;
    font-weight: 700 !important;
    color: #0f172a !important;
    white-space: pre-wrap !important;
    min-height: 55mm !important;
  }

  /* =========================================================================
     五上專屬版型：文意五大重點框加大、2欄×3列圖卡放大、特教友善大行距書寫線
     ========================================================================= */

  /* 五上第一頁：文意五大重點框加高至 28.5mm (約 1.3 倍) */
  #printWorksheet .print-keypoints-grid-g5 {
    display: grid !important;
    grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
    gap: 2.5mm !important;
    width: 100% !important;
    margin-bottom: 2.5mm !important;
  }

  #printWorksheet .print-keypoints-grid-g5 .print-keypoint-item {
    height: 28.5mm !important;
    min-height: 28.5mm !important;
    padding: 2mm 3mm !important;
    border: 1.2px solid #94a3b8 !important;
    border-radius: 2mm !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
  }

  #printWorksheet .print-keypoints-grid-g5 .print-keypoint-item:nth-child(1),
  #printWorksheet .print-keypoints-grid-g5 .print-keypoint-item:nth-child(2),
  #printWorksheet .print-keypoints-grid-g5 .print-keypoint-item:nth-child(3) {
    grid-column: span 2 !important;
  }

  #printWorksheet .print-keypoints-grid-g5 .print-keypoint-item:nth-child(4),
  #printWorksheet .print-keypoints-grid-g5 .print-keypoint-item:nth-child(5) {
    grid-column: span 3 !important;
  }

  #printWorksheet .print-keypoints-grid-g5 .print-keypoint-label {
    font-size: 10.5pt !important;
    font-weight: 900 !important;
    color: #0f172a !important;
  }

  #printWorksheet .print-keypoints-grid-g5 .print-keypoint-val {
    font-size: 10pt !important;
    color: #334155 !important;
    margin-top: 1mm !important;
    flex: 1 !important;
  }

  /* 五上第一頁：六張圖卡改為 2 欄 × 3 列 (每排 2 張，共 3 列，卡片高 46mm) */
  #printWorksheet .print-story-grid-g5 {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 2.5mm !important;
    width: 100% !important;
    margin-bottom: 2mm !important;
  }

  #printWorksheet .print-story-card-g5 {
    width: 100% !important;
    height: 46mm !important;
    min-width: 0 !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 2mm !important;
    padding: 1.2mm 2mm !important;
    background: #ffffff !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    box-sizing: border-box !important;
  }

  #printWorksheet .print-story-card-g5 .img-box {
    width: 100% !important;
    height: 38mm !important;
    min-height: 38mm !important;
    max-height: 38mm !important;
    overflow: hidden !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: #f8fafc !important;
    border-radius: 1mm !important;
  }

  #printWorksheet .print-story-card-g5 img {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
  }

  #printWorksheet .print-story-card-g5 .print-card-caption {
    font-size: 9.5pt !important;
    font-weight: 800 !important;
    text-align: center !important;
    color: #1e293b !important;
    line-height: 1.2 !important;
    padding-top: 0.8mm !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  /* 五上第一頁：底部補充短反思區 (補滿頁面，安全下緣距 10~18mm) */
  #printWorksheet .print-reflection-block {
    width: 100% !important;
    border: 1px dashed #cbd5e1 !important;
    border-radius: 2mm !important;
    padding: 2mm 3mm !important;
    background: #fdfefe !important;
    margin-top: 2mm !important;
    box-sizing: border-box !important;
  }

  #printWorksheet .print-reflection-title {
    font-size: 10pt !important;
    font-weight: 900 !important;
    color: #0f172a !important;
    margin-bottom: 1.5mm !important;
  }

  #printWorksheet .print-reflection-line {
    width: 100% !important;
    height: 9.5mm !important;
    border-bottom: 1.5px solid #64748b !important;
  }

  /* 五上第二頁：用 5 句話說重點＋凱瑟琳特質 (特教大行距 13.5mm) */
  #printWorksheet .print-sentence-row-g5 {
    font-size: 10.5pt !important;
    line-height: 1.3 !important;
    height: 13.5mm !important;
    min-height: 13.5mm !important;
    display: flex !important;
    align-items: flex-end !important;
    border-bottom: none !important;
    padding: 0 0 1.2mm 0 !important;
    margin-bottom: 1mm !important;
  }

  #printWorksheet .print-sentence-row-g5 .print-sentence-label {
    font-weight: 900 !important;
    color: #1e293b !important;
    font-size: 10.5pt !important;
    flex-shrink: 0 !important;
    padding-bottom: 0.8mm !important;
  }

  #printWorksheet .print-sentence-row-g5 .print-sentence-content {
    font-weight: 700 !important;
    color: #0f172a !important;
    flex: 1 !important;
    border-bottom: 1.5px solid #64748b !important;
    min-height: 8.5mm !important;
    padding-left: 2mm !important;
    padding-bottom: 0.8mm !important;
  }

  /* 五上第二頁：生活經驗短文寫作大橫線 (行距 15.5mm，特教友善延伸近頁底) */
  #printWorksheet .print-essay-lines-g5 {
    width: 100% !important;
    display: flex !important;
    flex-direction: column !important;
  }

  #printWorksheet .print-essay-line-g5 {
    width: 100% !important;
    height: 15.5mm !important;
    border-bottom: 1.5px solid #64748b !important;
    box-sizing: border-box !important;
  }

  /* =========================================================================
     二上低年級學習單專屬排版優化 (不影響五上)
     ========================================================================= */
  /* 學習單 A：四大重點加高 25%~30%，充足留白給低年級手寫 */
  #printWorksheet.worksheet-grade2 .print-keypoints-grid .print-keypoint-item {
    height: 40mm !important;
    min-height: 40mm !important;
    padding: 3.5mm 4mm !important;
  }

  /* 學習單 A：故事順序圖 (2×2) 放大約 15%~18%，嚴格 contain 不裁切，單頁完美填滿 */
  #printWorksheet.worksheet-grade2 .print-story-card-focus {
    height: 78mm !important;
  }

  #printWorksheet.worksheet-grade2 .print-story-card-focus .img-box {
    height: 69mm !important;
    min-height: 69mm !important;
    max-height: 69mm !important;
  }

  #printWorksheet.worksheet-grade2 .print-story-card-focus img {
    object-fit: contain !important;
  }

  #printWorksheet.worksheet-grade2 .print-story-card-focus .print-card-caption {
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    line-height: 1.2 !important;
    padding-top: 1mm !important;
  }

  /* 學習單 A：底部簡短書寫線（一句話說重點），填補頁尾留白 */
  #printWorksheet.worksheet-grade2 .print-reflection-g2 {
    margin-top: 3.5mm !important;
    margin-bottom: 0 !important;
    display: flex !important;
    align-items: baseline !important;
    gap: 2.5mm !important;
    width: 100% !important;
  }

  #printWorksheet.worksheet-grade2 .print-reflection-g2 .print-reflection-title {
    font-size: 10.5pt !important;
    font-weight: 900 !important;
    color: #0f172a !important;
    white-space: nowrap !important;
    margin: 0 !important;
  }

  #printWorksheet.worksheet-grade2 .print-reflection-g2 .print-reflection-line {
    flex: 1 !important;
    height: 6.5mm !important;
    border-bottom: 1.5px solid #64748b !important;
    box-sizing: border-box !important;
  }

  /* 學習單 B：四步造句區標題與上下間距 */
  #printWorksheet.worksheet-grade2 .print-sec2-title-g2 {
    margin-top: 4.5mm !important;
    margin-bottom: 3mm !important;
  }

  #printWorksheet.worksheet-grade2 .print-sentences-box {
    width: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 1.5mm !important;
    margin-bottom: 3.5mm !important;
  }

  /* 學習單 B：四步造句獨立橫列 (48px 標籤 + 提示與底線內容欄) */
  #printWorksheet.worksheet-grade2 .print-sentence-grid-row {
    display: grid !important;
    grid-template-columns: 48px 1fr !important;
    column-gap: 2.5mm !important;
    min-height: 18mm !important;
    padding: 3mm 0 !important;
    line-height: 1.6 !important;
    box-sizing: border-box !important;
    page-break-inside: avoid !important;
  }

  #printWorksheet.worksheet-grade2 .print-step-tag {
    width: 48px !important;
    font-size: 11pt !important;
    font-weight: 900 !important;
    color: #0f172a !important;
    align-self: start !important;
    white-space: nowrap !important;
    line-height: 1.5 !important;
    padding-top: 0.5mm !important;
  }

  #printWorksheet.worksheet-grade2 .print-step-content-col {
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    gap: 1.5mm !important;
    width: 100% !important;
  }

  #printWorksheet.worksheet-grade2 .print-step-prompt-text {
    font-size: 10.5pt !important;
    font-weight: 700 !important;
    color: #1e293b !important;
    line-height: 1.5 !important;
    word-break: break-word !important;
    white-space: normal !important;
  }

  #printWorksheet.worksheet-grade2 .print-step-write-line {
    width: 100% !important;
    min-height: 7.5mm !important;
    border-bottom: 1.5px solid #64748b !important;
    color: #0f172a !important;
    font-size: 11pt !important;
    font-weight: 700 !important;
    line-height: 1.5 !important;
    padding-bottom: 0.5mm !important;
  }

  /* 學習單 B：短文寫作標題與大行距橫線 */
  #printWorksheet.worksheet-grade2 .print-sec3-header-g2 {
    margin-top: 4.5mm !important;
    margin-bottom: 1.5mm !important;
  }

  #printWorksheet.worksheet-grade2 .print-essay-line {
    height: 10mm !important;
    border-bottom: 1.5px solid #94a3b8 !important;
  }
}

.print-only-container {
  display: none;
}
