:root {
  --ink: #1b2430;
  --muted: #5b6676;
  --line: #d9dee6;
  --bg: #eef1f5;
  --panel: #ffffff;
  --brand: #1f3a5f;
  --accent: #1f3a5f;
  --fs: 1;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Nunito", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  color: var(--ink); background: var(--bg);
  display: flex; flex-direction: column;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
[hidden] { display: none !important; }

/* ---------- app chrome ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 8px 20px; background: #fff; border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-logo { width: 54px; height: 54px; object-fit: contain; }
.brand h1 { margin: 0; font-size: 19px; line-height: 1.2; color: var(--brand); }
.brand p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.top-actions { display: flex; align-items: center; gap: 14px; }
.status { font-size: 12.5px; color: var(--muted); max-width: 320px; text-align: right; }

.btn {
  font: inherit; font-size: 13.5px; padding: 8px 14px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
}
.btn:hover:not(:disabled) { background: #f4f6f9; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: #2a4d7e; }
.btn.link { border: 0; background: none; color: #2563eb; padding: 6px 0; text-decoration: underline; }
.btn.small { padding: 4px 9px; font-size: 12.5px; }

.app { flex: 1; display: flex; min-height: 0; }
.panel {
  width: 440px; max-width: 46vw; overflow-y: auto; background: var(--panel);
  border-right: 1px solid var(--line); padding: 6px 18px 40px;
}
.step { padding: 14px 0; border-bottom: 1px solid var(--line); }
.step:last-child { border-bottom: 0; }
.step h2 { margin: 0 0 10px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.num {
  display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  background: var(--brand); color: #fff; font-size: 12px;
}
.note { font-size: 12.5px; color: var(--muted); margin: 6px 0 0; line-height: 1.45; }
.note.err { color: #b42318; }
.field { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 10px; }
.field input:not([type=color]):not([type=checkbox]), .field select, .field textarea, .blk input[type=text], .blk textarea {
  display: block; width: 100%; margin-top: 4px; padding: 7px 9px; font: inherit; font-size: 13.5px; color: var(--ink);
  border: 1px solid var(--line); border-radius: 7px; background: #fff;
}
.field textarea, .blk textarea { resize: vertical; line-height: 1.4; }
.field.check { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 13px; cursor: pointer; }
.field input[type=color] { display: block; margin-top: 4px; width: 56px; height: 32px; padding: 2px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.drop {
  display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center;
  padding: 22px 12px; border: 2px dashed #b8c2d1; border-radius: 12px; cursor: pointer; background: #f8fafc;
  font-size: 13px; color: var(--muted);
}
.drop strong { color: var(--ink); font-size: 14px; }
.drop.over, .drop:hover { border-color: var(--brand); background: #f0f5fb; }
.drop input { display: none; }

.periods { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.periods label {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border: 1px solid var(--line);
  border-radius: 999px; font-size: 13px; color: var(--ink); cursor: pointer; background: #fff;
}
.periods label:has(input:checked) { background: #e7eefb; border-color: #93aee0; }

/* subject editor blocks */
.blk { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; background: #fff; overflow: hidden; }
.blk.off { opacity: .55; }
.blk-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: #f8fafc; }
.blk-head .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.blk-head .title { flex: 1; font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.blk-body { display: none; padding: 10px; border-top: 1px solid var(--line); }
.blk.open .blk-body { display: block; }
.blk label.l { display: block; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin: 2px 0 8px; }
.seg button { font: inherit; font-size: 12.5px; padding: 5px 10px; border: 0; background: #fff; cursor: pointer; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--brand); color: #fff; }
.row { display: flex; align-items: center; gap: 6px; }
.row input[type=text] { margin-top: 0; }
.thumbs { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.th { padding: 0; border: 2px solid transparent; border-radius: 6px; background: #fff; cursor: pointer; overflow: hidden; width: 62px; height: 46px; }
.th img { width: 100%; height: 100%; object-fit: cover; display: block; }
.th.on { border-color: var(--brand); }
.th:hover { border-color: #93aee0; }
.credit { font-size: 11.5px; color: var(--muted); margin-top: 6px; line-height: 1.35; }
.cnt { font-size: 12px; color: var(--muted); min-width: 36px; text-align: center; }

/* preview area */
.preview { flex: 1; overflow: auto; padding: 18px; min-width: 0; }
.empty { height: 100%; display: grid; place-content: center; justify-items: center; gap: 12px; color: var(--muted); text-align: center; }
.empty-logo { width: 120px; opacity: .9; }
.warn { background: #fff4e5; border: 1px solid #f5c27a; color: #7a4a00; border-radius: 8px; padding: 9px 12px; font-size: 13px; margin: 0 auto 12px; max-width: 794px; }
.print-help { font-size: 12.5px; color: var(--muted); text-align: center; margin: 14px auto 0; max-width: 640px; }
.scaler { margin: 0 auto; transform-origin: top left; }
.pages { width: 794px; transform-origin: top left; display: flex; flex-direction: column; gap: 22px; }
.page-label { font-size: 12px; font-weight: 600; color: var(--muted); margin: 0 0 6px; text-transform: uppercase; letter-spacing: .06em; }

/* ---------- the newsletter sheet (A4) ---------- */
.page {
  position: relative; width: 210mm; height: 297mm; padding: 10mm 11mm 17mm; background: var(--pbg, #fff); overflow: hidden;
  display: flex; flex-direction: column; box-shadow: 0 4px 22px rgba(20, 30, 50, .18);
  font-size: calc(9.6pt * var(--fs)); line-height: 1.4; color: #1d2733;
}
.mast { display: flex; align-items: center; gap: 5mm; padding-bottom: 3.5mm; border-bottom: 1.2mm solid var(--accent); margin-bottom: 4mm; }
.mast .logo { width: 26mm; height: 26mm; object-fit: contain; flex: none; display: block; background: #fff; border-radius: 50%; box-shadow: 0 .4mm 1.5mm rgba(0,0,0,.15); }
.mast .titles { flex: 1; min-width: 0; }
.mast .school { font-size: 8.5pt; letter-spacing: .14em; text-transform: uppercase; color: #566070; font-weight: 600; }
.mast h1 { margin: 1mm 0 0; font-size: 22pt; line-height: 1.1; color: var(--accent); letter-spacing: -.01em; font-weight: 800; }
.mast .term { margin-top: 1.2mm; font-size: 11pt; color: #33404f; font-weight: 600; }
.mast .teacher { font-size: 8.5pt; color: #566070; margin-top: .8mm; }
.mast.small { padding-bottom: 2.5mm; margin-bottom: 3.5mm; border-bottom-width: .8mm; }
.mast.small .logo { width: 14mm; height: 14mm; }
.mast.small h1 { font-size: 13pt; margin: 0; }
.mast.small .term { font-size: 9pt; margin-top: .5mm; }

.intro { margin: 0 0 3.5mm; font-size: calc(9.8pt * var(--fs)); color: #2b3745; max-width: 78%; }
.intro p { margin: 0 0 1.2mm; }
.intro .greet { font-weight: 800; color: var(--accent); font-size: calc(10.8pt * var(--fs)); }
.cols { flex: 1; min-height: 0; display: flex; gap: 4.5mm; align-items: stretch; overflow: hidden; }
.after { flex: none; }
.col { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4.5mm; }

.col.two > .card { flex: 1 1 auto; display: flex; flex-direction: column; }
.col.two > .card .card-img { flex: 1 1 0; max-height: 90mm; min-height: calc(22mm * var(--fs) * var(--ih, 1)); height: auto; }
.col.two > .card .card-img > img, .col.two > .card .card-img > svg { position: absolute; inset: 0; }
.card { border: .35mm solid var(--c); border-radius: 3mm; overflow: hidden; background: #fff; break-inside: avoid; box-shadow: 0 .4mm 1.4mm rgba(0,0,0,.1); }
.card-head { background: var(--c); color: #fff; padding: 1.4mm 3mm; }
.card-head h2 { margin: 0; font-size: calc(12pt * var(--fs)); line-height: 1.2; letter-spacing: .01em; font-weight: 800; }
.card-img { height: calc(22mm * var(--fs) * var(--ih, 1)); background: #eef1f5; position: relative; overflow: hidden; }
.card-img img, .card-img svg { width: 100%; height: 100%; object-fit: cover; display: block; }
.sum { margin: 0; padding: 2.6mm 3.4mm 2.4mm; text-align: left; }
.sum p { margin: 0 0 1.8mm; }
.sum p:last-child { margin-bottom: 0; }
.kt { padding: 1.8mm 3mm 0; font-size: calc(7.6pt * var(--fs)); font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--c); }
.card ul { margin: 0; padding: 1mm 3mm 2mm 7mm; }
.card .sum + ul { padding-top: 2mm; }
.card li { margin: 0 0 .9mm; padding-left: .5mm; }
.card li::marker { color: var(--c); }
.tip { margin: 0; padding: 2mm 3mm 2.2mm; font-size: calc(9.2pt * var(--fs)); background: color-mix(in srgb, var(--c) 10%, #fff); border-top: .3mm solid color-mix(in srgb, var(--c) 35%, #fff); }
.tip b { color: var(--c); display: block; margin-bottom: .6mm; }
.tip p { margin: 0; }

.extras { display: flex; gap: 4.5mm; margin-top: 3.5mm; }
.extra { flex: 1; border-radius: 2.6mm; padding: 2.6mm 3.4mm; background: color-mix(in srgb, var(--accent) 8%, #fff); border: .3mm solid color-mix(in srgb, var(--accent) 35%, #fff); }
.extra h3 { margin: 0 0 1mm; font-size: calc(10.5pt * var(--fs)); color: var(--accent); }
.extra ul { margin: 0; padding-left: 4.5mm; }
.extra li { margin-bottom: .6mm; }

.pfoot { position: relative; z-index: 1; margin-top: 2.5mm; display: flex; justify-content: space-between; align-items: flex-end; gap: 6mm; font-size: 7pt; color: #7a8594; line-height: 1.3; }
.pfoot .turn { font-size: 8.5pt; color: var(--accent); font-weight: 600; white-space: nowrap; }
.pfoot .credits { max-width: 100%; }

/* seasonal scenery sits behind everything */
.page > * { position: relative; z-index: 1; }
.page > .deco { position: absolute; z-index: 0; left: 0; width: 100%; display: block; pointer-events: none; }
.page > .deco.top { top: 0; height: auto; }
.page > .deco.bot { bottom: 0; height: 56px; }
.closing { margin-top: 3mm; padding: 2.4mm 3.6mm; background: rgba(255,255,255,.82); border-radius: 2.6mm; border: .3mm solid color-mix(in srgb, var(--accent) 30%, #fff); }
.closing p { margin: 0 0 1mm; }
.closing .sign { margin: 1.4mm 0 0; color: var(--accent); }

/* ---------- print ---------- */
@page { size: A4; margin: 0; }
@media print {
  [hidden] { display: none !important; }
  html, body { height: auto; background: #fff; display: block; }
  .topbar, .panel, .empty, .warn, .print-help, .page-label { display: none !important; }
  .app, .preview { display: block; padding: 0; overflow: visible; }
  .pages-wrap { display: block !important; }
  .scaler { width: auto !important; height: auto !important; transform: none !important; margin: 0 !important; }
  .pages { transform: none !important; width: auto !important; display: block; gap: 0; }
  .page-block { break-after: page; page-break-after: always; }
  .page-block:last-child { break-after: auto; page-break-after: auto; }
  .page { box-shadow: none; }
}
