@media print {
  @page {
    size: A4;
    margin: 12mm;
  }

  :root {
    --paper-bg: #ffffff;
    --paper-text: #183D35;
    --paper-muted: #52645C;
    --paper-line: #52645C;
    --paper-soft: #F0F2EC;
    --paper-watermark: rgba(24, 61, 53, 0.12);
    --paper-font: -apple-system, BlinkMacSystemFont, 'PingFang TC', 'Noto Sans TC', 'Microsoft JhengHei', system-ui, sans-serif;
  }

  html,
  html:root:root,
  html:root[data-theme="dark"],
  html:root[data-theme="light"] {
    color-scheme: light;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    --bg: var(--paper-bg);
    --surface: var(--paper-bg);
    --surface-2: var(--paper-soft);
    --surface-3: var(--paper-soft);
    --text: var(--paper-text);
    --text-2: var(--paper-muted);
    --text-3: var(--paper-muted);
    --border: var(--paper-line);
    background: var(--paper-bg);
  }

  * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    animation: none !important;
    transition: none !important;
  }

  body {
    margin: 0;
    padding: 0;
    background: var(--paper-bg);
    color: var(--paper-text);
    font-family: var(--paper-font);
    font-size: 10pt;
    line-height: 1.45;
  }

  /* 隱藏互動介面 */
  #app,
  #sheet-root,
  #dialog-root,
  #toast-root,
  #lock-root,
  #confetti-root,
  #topbar,
  #tabbar,
  .l-topbar,
  .l-tabbar,
  .l-tabbar__brand,
  .l-tabbar__main,
  .l-tabbar__extra,
  .l-tabbar__pro,
  .l-tabbar__item,
  .l-tabbar__item--sub,
  .u-skip,
  .c-help-btn,
  .c-demo-banner,
  .u-no-print {
    display: none !important;
  }

  /* 熱圖不列印（報告改以表格呈現） */
  .c-heat,
  .c-heat__cell,
  .c-heatmap,
  .s-report-heatmap,
  [data-heatmap] {
    display: none !important;
  }

  #print-root {
    display: block !important;
    position: static;
    width: auto;
    margin: 0;
    padding: 0;
    background: var(--paper-bg);
    color: var(--paper-text);
  }

  .s-report-paper {
    width: auto;
    max-width: none;
    margin: 0;
    padding: 0;
    box-shadow: none;
    border: 0;
    border-radius: 0;
    aspect-ratio: auto;
    background: var(--paper-bg);
    color: var(--paper-text);
    overflow: visible;
  }

  /* 標題與文字 */
  .s-report-paper h1 {
    margin: 0 0 1mm;
    font-size: 16pt;
    line-height: 1.25;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--paper-text);
  }

  .s-report-paper h2 {
    margin: 0 0 1.5mm;
    font-size: 11pt;
    line-height: 1.3;
    font-weight: 650;
    color: var(--paper-text);
    break-after: avoid;
  }

  .s-report-paper h3 {
    margin: 0 0 1mm;
    font-size: 9.5pt;
    line-height: 1.3;
    font-weight: 600;
    color: var(--paper-text);
    break-after: avoid;
  }

  .s-report-paper p {
    margin: 0 0 1.5mm;
    orphans: 2;
    widows: 2;
  }

  .s-report-paper a,
  .s-report-paper a:visited {
    color: inherit;
    text-decoration: none;
  }

  a[href]::after,
  a[href^="tel:"]::after,
  a[href^="#"]::after {
    content: none !important;
  }

  /* 頁首 */
  .s-report-head {
    margin: 0 0 4mm;
    padding: 0 0 2mm;
    border-bottom: 0.5pt solid var(--paper-line);
  }

  .s-report-note {
    margin: 0;
    font-size: 9pt;
    line-height: 1.4;
    color: var(--paper-muted);
  }

  .s-report-meta {
    margin: 1mm 0 0;
    font-size: 8.5pt;
    color: var(--paper-muted);
  }

  /* 區段 */
  .s-report-section,
  .s-report-paper section {
    margin: 0 0 4mm;
    padding: 0;
    background: none;
    box-shadow: none;
    border-radius: 0;
  }

  /* 第一頁與附頁 */
  .s-report-card {
    break-after: page;
    page-break-after: always;
  }

  .s-report-card:last-child {
    break-after: auto;
    page-break-after: auto;
  }

  .s-report-annex {
    break-before: page;
    page-break-before: always;
  }

  .s-report-annex:first-child {
    break-before: auto;
    page-break-before: auto;
  }

  /* 看診問題框 */
  .s-report-questions {
    margin: 0 0 4mm;
    padding: 2mm 3mm;
    border: 0.5pt solid var(--paper-line);
    border-radius: 0;
    background: none;
    break-inside: avoid;
  }

  .s-report-questions h2,
  .s-report-questions h3 {
    margin-bottom: 1mm;
  }

  .s-report-questions ol {
    margin: 0;
    padding-left: 5mm;
    list-style: decimal;
  }

  .s-report-questions li {
    margin: 0 0 1mm;
    font-size: 10pt;
    line-height: 1.4;
    break-inside: avoid;
  }

  /* 時間軸：0.5pt 線、用藥點為實心圓、身體感受以文字標註 */
  .s-report-timeline {
    position: relative;
    margin: 0 0 4mm;
    padding: 0;
    border: 0;
    background: none;
    break-inside: avoid;
  }

  .s-report-timeline__row,
  .s-report-timeline__lane {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 1.5mm;
    min-height: 6mm;
    padding: 1mm 0;
    border-top: 0.5pt solid var(--paper-line);
  }

  .s-report-timeline__row:last-child,
  .s-report-timeline__lane:last-child {
    border-bottom: 0.5pt solid var(--paper-line);
  }

  .s-report-timeline__week {
    flex: 0 0 auto;
    min-width: 14mm;
    font-size: 8pt;
    color: var(--paper-muted);
    font-variant-numeric: tabular-nums;
  }

  .s-report-timeline__line {
    border: 0;
    border-top: 0.5pt solid var(--paper-line);
    height: 0;
    margin: 0;
    background: none;
  }

  .s-report-timeline__point {
    display: inline-flex;
    align-items: center;
    gap: 1mm;
    font-size: 8.5pt;
    line-height: 1.3;
    color: var(--paper-text);
  }

  .s-report-timeline__dot {
    display: inline-block;
    flex: 0 0 auto;
    width: 2.2mm;
    height: 2.2mm;
    border-radius: 50%;
    background: var(--paper-text);
    border: 0.5pt solid var(--paper-text);
  }

  /* 本次未使用、待詢問醫師：以空心圓區別，不靠顏色 */
  .s-report-timeline__dot.is-outcome {
    background: var(--paper-bg);
  }

  .s-report-timeline__feel {
    font-size: 8.5pt;
    line-height: 1.3;
    color: var(--paper-text);
    background: none;
    border: 0;
  }

  .s-report-timeline__flag {
    font-size: 8.5pt;
    font-weight: 700;
    color: var(--paper-text);
    border: 0.5pt solid var(--paper-text);
    padding: 0 1mm;
    background: none;
  }

  /* 表格 */
  .s-report-paper table {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
    font-size: 8.5pt;
    line-height: 1.35;
    font-variant-numeric: tabular-nums;
    color: var(--paper-text);
    background: none;
  }

  .s-report-paper th,
  .s-report-paper td {
    border: 0.5pt solid var(--paper-line);
    padding: 0.8mm 1.5mm;
    text-align: left;
    vertical-align: top;
    background: none;
    position: static;
    font-size: inherit;
  }

  .s-report-paper th {
    font-weight: 600;
    background: var(--paper-soft);
  }

  .s-report-paper td.is-num,
  .s-report-paper td.u-num {
    text-align: right;
  }

  .s-report-paper thead {
    display: table-header-group;
  }

  .s-report-paper tr {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .s-report-paper caption {
    caption-side: top;
    text-align: left;
    margin-bottom: 1mm;
    font-weight: 600;
  }

  .s-report-paper td.is-missing {
    font-style: italic;
    color: var(--paper-muted);
  }

  .s-report-paper .c-table-wrap,
  .s-report-paper .s-report-table-wrap {
    overflow: visible;
    max-height: none;
  }

  /* 量測表超過 16 列時 */
  .s-report-paper .is-dense,
  .s-report-paper .is-dense th,
  .s-report-paper .is-dense td {
    font-size: 7pt;
    line-height: 1.25;
  }

  .s-report-paper .is-dense th,
  .s-report-paper .is-dense td {
    padding: 0.4mm 1mm;
  }

  /* 圖表 */
  .s-report-chart {
    margin: 0 0 4mm;
    break-inside: avoid;
  }

  .s-report-chart svg,
  .s-report-paper .c-chart svg,
  .s-report-paper svg.s-report-svg {
    display: block;
    width: 100%;
    height: 60mm;
    max-width: 100%;
  }

  /* 頁尾免責聲明 */
  .s-report-footer,
  .s-report-disclaimer {
    margin: 4mm 0 0;
    padding-top: 2mm;
    border-top: 0.5pt solid var(--paper-line);
    font-size: 7.5pt;
    line-height: 1.4;
    color: var(--paper-muted);
  }

  /* 示範資料浮水印 */
  body.has-demo::after {
    content: "示範資料";
    position: fixed;
    top: 50%;
    left: 50%;
    z-index: 9999;
    transform: translate(-50%, -50%) rotate(-30deg);
    font-size: 72pt;
    font-weight: 700;
    letter-spacing: 0.1em;
    white-space: nowrap;
    color: var(--paper-watermark);
    pointer-events: none;
  }
}

/* ============================================================
   獨立報告文件（原生版存成 HTML 或送交列印 plugin）
   不依賴 tokens.css，自行定義 --paper-* 變數；不包在 media 內。
   ============================================================ */
@page {
  size: A4;
  margin: 12mm;
}

.is-standalone-report {
  --paper-bg: #ffffff;
  --paper-text: #183D35;
  --paper-muted: #52645C;
  --paper-line: #52645C;
  --paper-soft: #F0F2EC;
  --paper-watermark: rgba(24, 61, 53, 0.12);
  --paper-font: -apple-system, BlinkMacSystemFont, 'PingFang TC', 'Noto Sans TC', 'Microsoft JhengHei', system-ui, sans-serif;
  color-scheme: light;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.is-standalone-report,
.is-standalone-report body {
  margin: 0;
  background: var(--paper-bg);
  color: var(--paper-text);
  font-family: var(--paper-font);
  font-size: 10pt;
  line-height: 1.45;
}

.is-standalone-report * {
  box-sizing: border-box;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.is-standalone-report .s-report-paper {
  width: auto;
  max-width: 186mm;
  margin: 0 auto;
  padding: 0;
  box-shadow: none;
  border: 0;
  border-radius: 0;
  aspect-ratio: auto;
  background: var(--paper-bg);
  color: var(--paper-text);
  overflow: visible;
}

.is-standalone-report .s-report-paper h1 {
  margin: 0 0 1mm;
  font-size: 16pt;
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--paper-text);
}

.is-standalone-report .s-report-paper h2 {
  margin: 0 0 1.5mm;
  font-size: 11pt;
  line-height: 1.3;
  font-weight: 650;
  color: var(--paper-text);
  break-after: avoid;
}

.is-standalone-report .s-report-paper h3 {
  margin: 0 0 1mm;
  font-size: 9.5pt;
  line-height: 1.3;
  font-weight: 600;
  color: var(--paper-text);
  break-after: avoid;
}

.is-standalone-report .s-report-paper p {
  margin: 0 0 1.5mm;
  orphans: 2;
  widows: 2;
}

.is-standalone-report a,
.is-standalone-report a:visited {
  color: inherit;
  text-decoration: none;
}

.is-standalone-report a[href]::after {
  content: none !important;
}

.is-standalone-report .s-report-head {
  margin: 0 0 4mm;
  padding: 0 0 2mm;
  border-bottom: 0.5pt solid var(--paper-line);
}

.is-standalone-report .s-report-note {
  margin: 0;
  font-size: 9pt;
  line-height: 1.4;
  color: var(--paper-muted);
}

.is-standalone-report .s-report-meta {
  margin: 1mm 0 0;
  font-size: 8.5pt;
  color: var(--paper-muted);
}

.is-standalone-report .s-report-section,
.is-standalone-report .s-report-paper section {
  margin: 0 0 4mm;
  padding: 0;
  background: none;
  box-shadow: none;
  border-radius: 0;
}

.is-standalone-report .s-report-card {
  break-after: page;
  page-break-after: always;
}

.is-standalone-report .s-report-card:last-child {
  break-after: auto;
  page-break-after: auto;
}

.is-standalone-report .s-report-annex {
  break-before: page;
  page-break-before: always;
}

.is-standalone-report .s-report-annex:first-child {
  break-before: auto;
  page-break-before: auto;
}

.is-standalone-report .s-report-questions {
  margin: 0 0 4mm;
  padding: 2mm 3mm;
  border: 0.5pt solid var(--paper-line);
  border-radius: 0;
  background: none;
  break-inside: avoid;
}

.is-standalone-report .s-report-questions h2,
.is-standalone-report .s-report-questions h3 {
  margin-bottom: 1mm;
}

.is-standalone-report .s-report-questions ol {
  margin: 0;
  padding-left: 5mm;
  list-style: decimal;
}

.is-standalone-report .s-report-questions li {
  margin: 0 0 1mm;
  font-size: 10pt;
  line-height: 1.4;
  break-inside: avoid;
}

.is-standalone-report .s-report-timeline {
  position: relative;
  margin: 0 0 4mm;
  padding: 0;
  border: 0;
  background: none;
  break-inside: avoid;
}

.is-standalone-report .s-report-timeline__row,
.is-standalone-report .s-report-timeline__lane {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 1.5mm;
  min-height: 6mm;
  padding: 1mm 0;
  border-top: 0.5pt solid var(--paper-line);
}

.is-standalone-report .s-report-timeline__row:last-child,
.is-standalone-report .s-report-timeline__lane:last-child {
  border-bottom: 0.5pt solid var(--paper-line);
}

.is-standalone-report .s-report-timeline__week {
  flex: 0 0 auto;
  min-width: 14mm;
  font-size: 8pt;
  color: var(--paper-muted);
  font-variant-numeric: tabular-nums;
}

.is-standalone-report .s-report-timeline__line {
  border: 0;
  border-top: 0.5pt solid var(--paper-line);
  height: 0;
  margin: 0;
  background: none;
}

.is-standalone-report .s-report-timeline__point {
  display: inline-flex;
  align-items: center;
  gap: 1mm;
  font-size: 8.5pt;
  line-height: 1.3;
  color: var(--paper-text);
}

.is-standalone-report .s-report-timeline__dot {
  display: inline-block;
  flex: 0 0 auto;
  width: 2.2mm;
  height: 2.2mm;
  border-radius: 50%;
  background: var(--paper-text);
  border: 0.5pt solid var(--paper-text);
}

.is-standalone-report .s-report-timeline__dot.is-outcome {
  background: var(--paper-bg);
}

.is-standalone-report .s-report-timeline__feel {
  font-size: 8.5pt;
  line-height: 1.3;
  color: var(--paper-text);
  background: none;
  border: 0;
}

.is-standalone-report .s-report-timeline__flag {
  font-size: 8.5pt;
  font-weight: 700;
  color: var(--paper-text);
  border: 0.5pt solid var(--paper-text);
  padding: 0 1mm;
  background: none;
}

.is-standalone-report .s-report-paper table {
  width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
  font-size: 8.5pt;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
  color: var(--paper-text);
  background: none;
}

.is-standalone-report .s-report-paper th,
.is-standalone-report .s-report-paper td {
  border: 0.5pt solid var(--paper-line);
  padding: 0.8mm 1.5mm;
  text-align: left;
  vertical-align: top;
  background: none;
  position: static;
  font-size: inherit;
}

.is-standalone-report .s-report-paper th {
  font-weight: 600;
  background: var(--paper-soft);
}

.is-standalone-report .s-report-paper td.is-num,
.is-standalone-report .s-report-paper td.u-num {
  text-align: right;
}

.is-standalone-report .s-report-paper thead {
  display: table-header-group;
}

.is-standalone-report .s-report-paper tr {
  break-inside: avoid;
  page-break-inside: avoid;
}

.is-standalone-report .s-report-paper caption {
  caption-side: top;
  text-align: left;
  margin-bottom: 1mm;
  font-weight: 600;
}

.is-standalone-report .s-report-paper td.is-missing {
  font-style: italic;
  color: var(--paper-muted);
}

.is-standalone-report .s-report-paper .c-table-wrap,
.is-standalone-report .s-report-paper .s-report-table-wrap {
  overflow: visible;
  max-height: none;
}

.is-standalone-report .s-report-paper .is-dense,
.is-standalone-report .s-report-paper .is-dense th,
.is-standalone-report .s-report-paper .is-dense td {
  font-size: 7pt;
  line-height: 1.25;
}

.is-standalone-report .s-report-paper .is-dense th,
.is-standalone-report .s-report-paper .is-dense td {
  padding: 0.4mm 1mm;
}

.is-standalone-report .s-report-chart {
  margin: 0 0 4mm;
  break-inside: avoid;
}

.is-standalone-report .s-report-chart svg,
.is-standalone-report .s-report-paper .c-chart svg,
.is-standalone-report .s-report-paper svg.s-report-svg {
  display: block;
  width: 100%;
  height: 60mm;
  max-width: 100%;
}

/* 熱圖不列印、不顯示於獨立報告 */
.is-standalone-report .c-heat,
.is-standalone-report .c-heat__cell,
.is-standalone-report .c-heatmap,
.is-standalone-report .s-report-heatmap,
.is-standalone-report [data-heatmap] {
  display: none !important;
}

.is-standalone-report .s-report-footer,
.is-standalone-report .s-report-disclaimer {
  margin: 4mm 0 0;
  padding-top: 2mm;
  border-top: 0.5pt solid var(--paper-line);
  font-size: 7.5pt;
  line-height: 1.4;
  color: var(--paper-muted);
}

/* 示範資料浮水印（獨立文件） */
.is-standalone-report.has-demo::after,
.is-standalone-report body.has-demo::after,
.is-standalone-report.has-demo body::after {
  content: "示範資料";
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 9999;
  transform: translate(-50%, -50%) rotate(-30deg);
  font-size: 72pt;
  font-weight: 700;
  letter-spacing: 0.1em;
  white-space: nowrap;
  color: var(--paper-watermark);
  pointer-events: none;
}
