/* 出産予定日計算 */
#app-pregnancy .pg-panel,
#app-pregnancy .pg-result {
    background: var(--bs-tertiary-bg);
    border-radius: .5rem;
}
#app-pregnancy .pg-result { border-left: 4px solid var(--bs-primary); }

#app-pregnancy .pg-choice {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .5rem;
}
#app-pregnancy .pg-choice .btn { white-space: nowrap; padding-inline: .25rem; font-size: .95rem; }

#app-pregnancy .pg-due { font-size: clamp(1.5rem, 6vw, 2.25rem); line-height: 1.2; }

/* カレンダー: 区分は小見出し行＋淡い背景（色だけに頼らない） */
#app-pregnancy .pg-cal th[scope="row"] { width: 4.5rem; white-space: nowrap; }
#app-pregnancy .pg-cal td { font-variant-numeric: tabular-nums; }
#app-pregnancy .pg-sec th {
    background: var(--bs-secondary-bg);
    font-size: .9rem;
    padding-top: .6rem;
}
#app-pregnancy .pg-early > * { background-color: rgba(124, 90, 195, .05); }
#app-pregnancy .pg-mid > * { background-color: rgba(59, 130, 246, .06); }
#app-pregnancy .pg-late > * { background-color: rgba(230, 162, 60, .08); }
#app-pregnancy .pg-now > * { font-weight: 700; box-shadow: inset 0 -2px 0 var(--bs-primary); }
#app-pregnancy .pg-tag {
    background: var(--bs-secondary-bg);
    color: var(--bs-body-color);
    border: 1px solid var(--bs-border-color);
    font-weight: 600;
}

/* やること・準備物（区切りは下線と余白。カードにしない） */
#app-pregnancy .pg-phase {
    margin: 1rem 0 .25rem;
    padding-bottom: .25rem;
    border-bottom: 2px solid var(--bs-border-color);
}
#app-pregnancy .pg-item {
    padding: .6rem 0;
    border-bottom: 1px solid var(--bs-border-color-translucent);
}
#app-pregnancy .pg-item .form-check-label { line-height: 1.5; }
#app-pregnancy .pg-when { font-weight: 600; margin: .15rem 0; padding-left: 1.5em; }
#app-pregnancy .pg-item > .small.text-muted { padding-left: 1.5em; }
#app-pregnancy .pg-who {
    background: var(--bs-secondary-bg);
    color: var(--bs-body-color);
    border: 1px solid var(--bs-border-color);
    font-weight: 600;
    white-space: normal;
    text-align: left;
}
#app-pregnancy .pg-check-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: .35rem 1rem;
    padding: .25rem 0 .5rem;
}
@media (min-width: 768px) {
    #app-pregnancy .pg-check-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* 済んだものだけ取り消し線（印刷内容の選択や「覚えておく」には付けない） */
#app-pregnancy .form-check-input[data-key]:checked + .form-check-label { text-decoration: line-through; color: var(--bs-secondary-color); }

/* 印刷用の紙面は画面では出さない */
#app-pregnancy #pg-print { display: none; }

/* ================= 印刷（A4） ================= */
@media print {
    @page { size: A4; margin: 12mm 12mm 14mm; }
    /* ダークテーマの color-scheme: dark が残ると、紙の余白が黒く塗られる */
    :root, html[data-bs-theme] { color-scheme: light !important; }
    html, body { background: #fff !important; color: #000 !important; }
    /* サイト共通のヘッダー・フッター・ナビを隠し、紙面だけを出す */
    body > *:not(#app-pregnancy) { display: none !important; }
    #app-pregnancy > *:not(#pg-print) { display: none !important; }
    #app-pregnancy { max-width: none !important; width: 100% !important; margin: 0 !important; padding: 0 !important; }
    #app-pregnancy #pg-print {
        display: block !important;
        color: #000;
        font-size: 9.5pt;
        line-height: 1.5;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    #pg-print h1 { font-size: 15pt; font-weight: 700; margin: 0 0 2mm; }
    #pg-print h2 { font-size: 12pt; font-weight: 700; margin: 0 0 2mm; padding-bottom: 1mm; border-bottom: 1.5pt solid #000; break-after: avoid; }
    #pg-print h3 { font-size: 10pt; font-weight: 700; margin: 0 0 1mm; break-after: avoid; }
    #pg-print .pg-p-meta { font-size: 8.5pt; color: #444; margin-bottom: 3mm; }
    #pg-print .pg-p-sec { margin-bottom: 5mm; }
    /* やることの後ろに続く節は新しいページから（表やリストを途中で切らない）。
       結果のすぐ後ろなら同じページに続ける（1ページ目が見出しだけにならないように） */
    #pg-print .pg-p-todo + .pg-p-check,
    #pg-print .pg-p-todo + .pg-p-cal,
    #pg-print .pg-p-check + .pg-p-cal { break-before: page; }
    #pg-print .pg-p-sum { border-collapse: collapse; margin-bottom: 2mm; }
    #pg-print .pg-p-sum th, #pg-print .pg-p-sum td { border: .75pt solid #555; padding: 1.5mm 3mm; text-align: left; }
    #pg-print .pg-p-sum th { background: #eee; font-weight: 700; }
    #pg-print .pg-p-due { font-size: 13pt; font-weight: 700; }
    #pg-print .pg-p-table { width: 100%; border-collapse: collapse; }
    #pg-print .pg-p-table thead { display: table-header-group; }
    #pg-print .pg-p-table th, #pg-print .pg-p-table td { border: .75pt solid #555; padding: 1.2mm 2mm; vertical-align: top; text-align: left; }
    #pg-print .pg-p-table thead th { background: #e6e6e6; }
    #pg-print .pg-p-table tr { break-inside: avoid; }
    #pg-print .pg-p-phase th { background: #f1f1f1; font-weight: 700; }
    #pg-print .pg-p-ck { width: 9mm; text-align: center !important; }
    #pg-print .pg-p-when { width: 38%; }
    #pg-print .pg-p-title { font-weight: 700; }
    #pg-print .pg-p-who { display: inline-block; margin-left: 2mm; padding: 0 1.5mm; border: .5pt solid #777; font-size: 7.5pt; font-weight: 400; }
    #pg-print .pg-p-note { font-size: 8pt; color: #333; }
    #pg-print .pg-p-small { font-size: 8pt; color: #333; margin: 2mm 0 0; }
    #pg-print .pg-p-none { margin: 0; }
    #pg-print .pg-p-caltable th:first-child { width: 14mm; }
    /* 0〜42週（47行）を A4 1枚に収める */
    #pg-print .pg-p-caltable td, #pg-print .pg-p-caltable th { padding: .35mm 2mm; font-size: 8.5pt; line-height: 1.3; }
    #pg-print .pg-p-caltable tr.is-now th, #pg-print .pg-p-caltable tr.is-now td { font-weight: 700; background: #fff3cd; }
    /* 準備物は2段組。グループの途中で段や改ページをまたがない */
    #pg-print .pg-p-cols { column-count: 2; column-gap: 8mm; }
    #pg-print .pg-p-group { break-inside: avoid; margin-bottom: 4mm; }
    #pg-print .pg-p-group ul { list-style: none; margin: 0; padding: 0; }
    #pg-print .pg-p-group li { display: flex; align-items: flex-start; gap: 2mm; padding: .6mm 0; break-inside: avoid; }
    /* チェック欄は線で描く（フォントに ✓ が無くても崩れない） */
    #pg-print .pg-box { position: relative; display: inline-block; flex: 0 0 auto; width: 3.6mm; height: 3.6mm; margin-top: .6mm; border: .9pt solid #000; background: #fff; }
    #pg-print .pg-box.is-on::after {
        content: "";
        position: absolute;
        left: 1.05mm; top: .15mm;
        width: 1.2mm; height: 2.3mm;
        border: solid #000;
        border-width: 0 .9pt .9pt 0;
        transform: rotate(45deg);
    }
    #pg-print .is-done .pg-p-title, #pg-print li.is-done { color: #555; }
    #pg-print .pg-p-foot { margin-top: 4mm; }
}
