/* 授業の教材（ワークシートと先生向けの手引き）の共通の見た目。A4 縦に印刷する前提で、画面でも読める */
:root {
  --ink: #1d2430;
  --muted: #5b6573;
  --line: #9aa4b2;
  --soft: #eef2f7;
  --accent: #1f5fbf;
  --paper: #ffffff;
  --desk: #e7ebf0;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--desk);
  color: var(--ink);
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic UI", "Yu Gothic", "Meiryo", "Noto Sans JP", sans-serif;
  font-size: 10.5pt;
  line-height: 1.6;
}

.toolbar {
  position: sticky;
  top: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  background: #fff;
  border-bottom: 1px solid #d0d6de;
  font-size: 10pt;
  z-index: 1;
}
.toolbar a, .toolbar button {
  font: inherit;
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: #fff;
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
}
.toolbar .primary { background: var(--accent); color: #fff; }

/* 紙 1 枚ぶん */
.sheet {
  width: 210mm;
  max-width: 100%;
  min-height: 297mm;
  margin: 16px auto;
  padding: 14mm 15mm;
  background: var(--paper);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

h1 { font-size: 16pt; margin: 0 0 2mm; line-height: 1.3; }
h2 {
  font-size: 11.5pt;
  margin: 6mm 0 2mm;
  padding: 1mm 2.5mm;
  background: var(--soft);
  border-left: 4px solid var(--accent);
}
h3 { font-size: 10.5pt; margin: 4mm 0 1.5mm; }
p { margin: 1.5mm 0; }
.unit { color: var(--muted); font-size: 9.5pt; margin: 0; }
.lead { font-size: 11.5pt; font-weight: bold; }
.muted { color: var(--muted); font-size: 9.5pt; }

.head { display: flex; flex-direction: column; gap: 2mm; border-bottom: 2px solid var(--ink); padding-bottom: 2mm; }
.name { display: flex; justify-content: flex-end; gap: 3mm; font-size: 10pt; white-space: nowrap; }
.name span { display: inline-block; border-bottom: 1px solid var(--ink); min-width: 12mm; text-align: right; }
.name .long { min-width: 38mm; }

table { border-collapse: collapse; width: 100%; margin: 2mm 0; }
th, td { border: 1px solid var(--line); padding: 1.5mm 2mm; vertical-align: top; text-align: left; }
th { background: var(--soft); font-weight: bold; }
table.record td, table.record th { text-align: center; height: 8mm; vertical-align: middle; }
table.record td.given { background: #fafbfc; font-weight: bold; }

/* 書き込む欄 */
.write { border: 1px solid var(--line); border-radius: 2mm; min-height: 18mm; padding: 2mm 3mm; margin: 2mm 0; }
.write.tall { min-height: 28mm; }
.write .hint { color: var(--muted); font-size: 9pt; }
.choices { display: flex; flex-wrap: wrap; gap: 2mm 6mm; margin: 1mm 0 2mm; }
.choices span::before { content: "□ "; }

.row { display: flex; gap: 6mm; align-items: flex-start; }
.row > * { flex: 1; min-width: 0; }

.graph { margin: 2mm 0; }
.graph svg { width: 100%; height: auto; display: block; }

.box { border: 1px dashed var(--line); border-radius: 2mm; padding: 2mm 3mm; margin: 2mm 0; font-size: 9.5pt; }
ol, ul { margin: 1mm 0; padding-left: 6mm; }
li { margin: 0.5mm 0; }
code { font-family: Consolas, "Courier New", monospace; font-size: 9.5pt; }

@media screen and (max-width: 800px) {
  .sheet { padding: 16px; min-height: 0; margin: 0 0 12px; box-shadow: none; }
  .head, .row { flex-direction: column; align-items: stretch; gap: 8px; }
  .name { flex-wrap: wrap; white-space: normal; }
  table { font-size: 9pt; }
}

/* 紙の上下の余白は @page で取り、長い手引きは次の紙へ流す（.sheet ごとに紙を改める） */
@page { size: A4 portrait; margin: 10mm 0; }
@media print {
  body { background: #fff; }
  .toolbar { display: none; }
  .sheet { margin: 0; box-shadow: none; width: 210mm; min-height: 0; padding: 0 15mm; break-after: page; }
  .sheet:last-of-type { break-after: auto; }
  tr, li, .box, .write, .graph, .row { break-inside: avoid; }
  h2, h3 { break-after: avoid; }
  h2 { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  th, td.given { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
