/* 講義與老師版。講義的 .sheet 永遠是白紙（列印用），所以在裡面重新定義成淺色 */
.doc-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding-block: 18px 6px; }
.doc-bar h1 { font-size: 1.7rem; margin-right: auto; }
.doc-bar select { font: inherit; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.doc-note { color: var(--muted); margin: 0 0 18px; font-size: .95rem; }

.sheets { display: grid; gap: 28px; justify-items: center; padding-bottom: 60px; }
.sheet {
  --bg: #FFFFFF; --surface: #FFFFFF; --sunk: #EEF1F6; --ink: #172031; --muted: #556073; --line: #CCD4E1;
  --blue: #2F6DA3; --blue-ink: #FFFFFF; --blue-soft: #E1EBF6; --yellow: #F2C21B; --yellow-ink: #3B2F00; --yellow-soft: #FFF5CF;
  --good: #1F8A55; --good-soft: #E0F2E8; --bad: #C8373D; --bad-soft: #FBE6E6; --str: #A6481A; --num: #2F6DA3;
  --term-bg: #F3F5F9; --term-bar: #E9EDF3; --term-fg: #172031; --term-dim: #66718A; --term-line: #CCD4E1; --term-in: #B88A00;
  --tk-kw: #8A3FB8; --tk-str: #2E7D32; --tk-num: #B4531C; --tk-com: #7A869B; --tk-fn: #2F6DA3; --tk-dec: #9A6B00;
  color-scheme: light;
  width: 210mm; max-width: 100%; min-height: 297mm; padding: 11mm 12mm; background: var(--bg); color: var(--ink);
  box-shadow: 0 10px 30px -12px rgba(0, 0, 0, .35); border-radius: 4px; font-size: 10pt; line-height: 1.5;
  display: flex; flex-direction: column; gap: 4mm; overflow: hidden;
}
.sheet h2, .sheet h3 { font-family: var(--f-display); font-weight: 400; }
.sh-head { display: flex; align-items: center; gap: 4mm; border-bottom: 2px solid var(--ink); padding-bottom: 3mm; }
.sh-head .pixel-badge { min-width: 13mm; height: 13mm; font-size: 16pt; }
.sh-head small { color: var(--muted); font-size: 8.5pt; display: block; }
.sh-head h2 { font-size: 17pt; }
.sh-head .grow { flex: 1; min-width: 0; }
.sh-name { font-size: 9pt; color: var(--muted); display: grid; gap: 2mm; text-align: right; }
.sh-name span { display: inline-block; width: 30mm; border-bottom: 1px solid var(--line); }
.sh-h { font-size: 12pt; display: flex; align-items: center; gap: 2mm; margin: 0; }
.sh-h::before { content: ""; width: 3mm; height: 3mm; background: var(--lv); transform: rotate(45deg); }
.sh-top { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 3mm; }
.sh-card { border: 1px solid var(--line); border-radius: 3mm; padding: 2.5mm 3mm; display: grid; gap: 2mm; align-content: start; min-width: 0; }
.sh-card h3 { font-size: 10.5pt; }
.sh-card.key { background: var(--yellow-soft); border-color: var(--yellow); }
.sheet .v-code { font-size: 8.6pt; padding: 2mm 3mm; border-radius: 2mm; white-space: pre-wrap; }
.sheet .v-screen { font-size: 8.4pt; padding: 1.5mm 2.5mm; border-width: 1.5px; }
.sheet .v-screen::before { top: -8px; font-size: 6.5pt; }
.sheet .v-io { gap: 2mm; }
.sheet .v-io > .v-code, .sheet .v-io > .v-screen { flex-basis: 100%; }
.sheet .v-io .v-arrow { display: none; }
.sheet .vbox { min-width: 14mm; }
.sheet .vbox-body { min-width: 14mm; padding: 1.5mm 2mm; font-size: 9pt; border-width: 2px; }
.sheet .vbox-lid { font-size: 8pt; }
.sheet .vbox-type { font-size: 6.5pt; }
.sheet .v-boxes { gap: 2mm; }
.sheet .tile-v { min-width: 10mm; padding: 1.5mm 1mm; font-size: 8.4pt; }
.sheet .tiles-row { gap: 1mm; }
.sheet .fstep { padding: 1.5mm 2.5mm; font-size: 8.4pt; }
.sheet .v-flow { gap: 1.5mm; }
.sheet .farrow { font-size: 9pt; }
.sheet .op-tile { padding: 1.2mm 2mm; }
.sheet .op-tile .s { font-size: 11pt; }
.sheet .op-tile .nm, .sheet .op-tile .ex { font-size: 7pt; }
.sheet .v-ops { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1.2mm; }
.sheet .cmp { grid-template-columns: 5mm minmax(0, 1fr); gap: 1mm 2mm; }
.sheet .cmp .farrow { display: none; }
.sheet .cmp .res { grid-column: 2; font-size: 8pt; }
.sheet .cmp .mk { width: 5mm; height: 5mm; font-size: 7pt; }
.sheet .cmp .v-code { padding: 1mm 2mm; }
.sheet .an-row { padding: 0 2.5mm; }
.sheet .an-row pre { font-size: 8.2pt; line-height: 1.5; }
.sheet .an-note { font-size: 7.4pt; white-space: normal; }
.sheet .v-anno { padding: 1.5mm 0; }
.sheet .br-q, .sheet .br-r { padding: 1.5mm 2mm; font-size: 8.4pt; }
.sheet .br-lab { font-size: 7pt; }
.sheet .v-branch { gap: 1.5mm 3mm; }
.sheet .kv-k, .sheet .kv-v { font-size: 8.2pt; padding: .8mm 2mm; }
.sheet .m-box { padding: 1.5mm 3mm; font-size: 8.4pt; border-width: 2px; }
.sheet .m-chip { font-size: 8pt; padding: .5mm 2mm; }
.sheet .v-machine { gap: 1.5mm; }
.sheet .ld-q, .sheet .ld-r { font-size: 8pt; padding: 1mm 2mm; }
.sheet .ld-no { font-size: 6.8pt; }
.sheet .loopback { font-size: 7.5pt; }

.sh-paper { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 3mm; }
.pp { border: 1.5px dashed var(--line); border-radius: 3mm; padding: 2.5mm 3mm; display: grid; gap: 2mm; align-content: start; min-width: 0; }
.pp-q { display: flex; gap: 2mm; align-items: baseline; font-size: 9.5pt; }
.pp-q b { flex: none; width: 5mm; height: 5mm; border-radius: 50%; background: var(--ink); color: var(--bg); display: grid; place-items: center; font-size: 7.5pt; }
.pp-q code { font-family: var(--f-code); background: var(--sunk); padding: 0 1.5mm; border-radius: 1mm; font-size: .92em; }
.ans-lines { display: grid; gap: 0; }
.ans-lines i { display: block; height: 7mm; border-bottom: 1px dotted var(--muted); }
.ans-tiles { display: flex; gap: 1.5mm; }
.ans-tiles span { width: 13mm; height: 10mm; border: 1.5px solid var(--line); border-radius: 1.5mm; position: relative; }
.ans-tiles span::after { content: attr(data-i); position: absolute; bottom: -4.2mm; left: 0; right: 0; text-align: center; font-family: var(--f-code); font-size: 7pt; color: var(--blue); }
.sheet .blank { border-bottom-color: var(--ink); min-width: 12mm; }

.sh-bottom { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) 30mm; gap: 3mm; align-items: start; margin-top: auto; }
.sh-todo { list-style: none; margin: 0; padding: 0; display: grid; gap: 1.8mm; }
.sh-todo li { display: grid; grid-template-columns: 5mm minmax(0, 1fr) auto; gap: 2mm; align-items: start; font-size: 9pt; }
.sh-todo .cb { width: 4.5mm; height: 4.5mm; border: 1.5px solid var(--ink); border-radius: 1mm; margin-top: .6mm; }
.sh-todo small { display: block; color: var(--muted); font-size: 7.8pt; line-height: 1.35; }
.sh-todo small code { font-family: var(--f-code); }
.sh-todo .stars svg { width: 3.4mm; height: 3.4mm; }
.sh-errs { display: grid; gap: 1.5mm; }
.sh-err { display: grid; gap: .5mm; font-size: 8pt; }
.sh-err .v-code { padding: 1mm 2mm; font-size: 7.8pt; }
.sh-err code { font-family: var(--f-code); background: var(--sunk); padding: 0 1mm; border-radius: 1mm; }
.stamp { width: 30mm; height: 30mm; border: 2px dashed var(--lv); border-radius: 50%; display: grid; place-items: center; text-align: center; color: var(--lv); font-family: var(--f-display); font-size: 10pt; line-height: 1.3; }

.cover { justify-content: center; align-items: center; text-align: center; gap: 8mm; }
.cover h2 { font-size: 30pt; line-height: 1.2; }
.cover .robot { width: 55mm; }
.cover p { color: var(--muted); font-size: 11pt; margin: 0; }
.cover .name { font-size: 13pt; }
.cover .name span { display: inline-block; width: 60mm; border-bottom: 1.5px solid var(--ink); }
.stamps { display: grid; grid-template-columns: repeat(3, 34mm); gap: 6mm; justify-content: center; }
.stamps div { height: 34mm; border: 2px dashed var(--c); border-radius: 50%; display: grid; place-items: center; color: var(--c); font-family: var(--f-display); font-size: 9.5pt; line-height: 1.3; padding: 3mm; }
.cheat { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 3mm; }
.cheat .sh-card h3 { display: flex; gap: 2mm; align-items: center; }
.cheat .sh-card h3 i { width: 3mm; height: 3mm; background: var(--c); transform: rotate(45deg); display: inline-block; }

/* ── 老師版 ── */
.t-wrap { padding-bottom: 60px; display: grid; gap: 22px; }
.t-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; display: grid; gap: 12px; min-width: 0; }
.t-card h2 { font-size: 1.4rem; }
.t-card h3 { font-size: 1.08rem; }
.t-card ul, .t-card ol { margin: 0; padding-left: 1.3em; display: grid; gap: 6px; }
.t-card li code, .t-card p code { font-family: var(--f-code); background: var(--sunk); padding: 1px 6px; border-radius: 5px; font-size: .9em; }
.t-table { width: 100%; border-collapse: collapse; font-size: .93rem; }
.t-table th, .t-table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.t-table th { font-weight: 700; color: var(--muted); font-size: .82rem; letter-spacing: .04em; }
.t-table td:first-child { white-space: nowrap; }
.t-table .dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--c); margin-right: 6px; }
.scroll-x { overflow-x: auto; }
.t-lesson { border-top: 6px solid var(--lv); }
.t-lesson .head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.t-lesson .head .pixel-badge { min-width: 40px; height: 40px; font-size: 1.1rem; }
.timebar { display: flex; border-radius: 8px; overflow: hidden; font-size: .78rem; }
.timebar div { padding: 6px 8px; background: var(--sunk); border-right: 2px solid var(--surface); min-width: 0; }
.timebar div:nth-child(odd) { background: var(--blue-soft); }
.timebar b { display: block; font-family: var(--f-code); font-size: .8rem; }
.t-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.t-ans { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 12px; }
.t-ans h4 { font-size: .95rem; margin-bottom: 4px; font-family: var(--f-body); font-weight: 700; }
.t-ans .v-code { font-size: .84rem; }
.t-paper { display: grid; gap: 4px; padding-left: 1.3em; margin: 0; }
.t-paper li span { color: var(--good); font-weight: 700; }
.principles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr)); gap: 12px; list-style: none; padding: 0 !important; counter-reset: pr; }
.principles li { background: var(--sunk); border-radius: 10px; padding: 12px 14px; counter-increment: pr; display: grid; gap: 2px; }
.principles li b { font-family: var(--f-display); font-weight: 400; font-size: 1.05rem; }
.principles li span { color: var(--muted); font-size: .92rem; }

@media (max-width: 760px) {
  .sh-top, .sh-paper, .sh-bottom, .cheat { grid-template-columns: 1fr; }
  .sheet { min-height: 0; padding: 18px 16px; }
  .t-cols { grid-template-columns: 1fr; }
  .timebar { flex-wrap: wrap; }
}

@media print {
  @page { size: A4; margin: 0; }
  body { background: #fff; }
  .topbar, .doc-bar, .doc-note, .no-print { display: none !important; }
  .wrap { padding: 0; max-width: none; }
  .sheets { display: block; padding: 0; }
  .sheet { box-shadow: none; border-radius: 0; width: 210mm; height: 297mm; min-height: 0; break-after: page; page-break-after: always; margin: 0; }
  .sheet:last-child { break-after: auto; page-break-after: auto; }
  .sheet[hidden] { display: none !important; }
  .t-card { break-inside: avoid; box-shadow: none; }
  .t-lesson { break-inside: auto; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
.sheet .an-row pre { white-space: pre-wrap; }
.sheet .v-anno { overflow: visible; }
.sheet .tiles-row { flex-wrap: nowrap; gap: .8mm; }
.sheet .tile-v { min-width: 7mm; padding: 1mm 1.5mm; }
.sheet .tile-i { font-size: 6.5pt; }
.sheet .tiles-name { font-size: 7.5pt; }
.sheet .v-tiles + .v-tiles { margin-top: 1.5mm; }
.sheet .v-tiles { gap: .5mm; }
