:root {
  --bg: #eff8f7;
  --surface: #ffffff;
  --mat: #dcefec;
  --deep: #00645d;
  --deep-2: #004b46;
  --teal: #1b9a8f;
  --navy: #163e57;
  --name: #147986;
  --gold: #c8952e;
  --gold-2: #b5841f;
  --gold-ink: #2b1d04;
  --gold-text: #8a6216;
  --ink: #10302e;
  --mute: #47615f;
  --line: #c6dfdb;
  --line-2: #a9cbc6;
  --err: #b3261e;
  --r-s: 10px;
  --r-m: 14px;
  --r-l: 20px;
  --ff-d: "Tajawal", "Vazirmatn", Tahoma, sans-serif;
  --ff-b: "Vazirmatn", "Tajawal", Tahoma, sans-serif;
  --z-sticky: 10;
  --z-toast: 50;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 16px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1rem/1.6 var(--ff-b);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}
h1, h2, p, figure, ol, ul { margin: 0; }
ol, ul { padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; inset-inline-start: 12px; top: -60px; z-index: var(--z-toast); background: var(--gold); color: var(--gold-ink); padding: 8px 14px; border-radius: var(--r-s); font-weight: 700; }
.skip:focus { top: 12px; }
iconify-icon { display: inline-block; width: 1em; height: 1em; flex: none; }

/* ---------- header ---------- */
.top { position: relative; background: var(--deep); color: #fff; }
.top-in {
  max-width: 1320px; margin-inline: auto; padding: 10px 16px 8px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 62px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; min-width: 0; min-height: 44px; }
.mark { width: 38px; height: 38px; flex: none; border-radius: 6px; background: #eff8f7; padding: 3px; }
.brand-txt { display: grid; line-height: 1.25; }
.brand-txt strong { font: 800 1.125rem/1.2 var(--ff-d); }
.brand-txt span { font-size: 0.8125rem; color: #d3ece8; }
.nav { display: none; }
.top-link { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 6px 12px; border-radius: 10px; color: #fff; text-decoration: none; font-weight: 700; font-size: 0.9375rem; white-space: nowrap; background: rgba(255, 255, 255, .12); }
.top-link iconify-icon { font-size: 1.25rem; }
.top-link .tl-s { display: none; }
@media (max-width: 359px) { .top-link .tl-l { display: none; } .top-link .tl-s { display: inline; } .top-link { padding-inline: 10px; } }
.top-link:hover { background: rgba(255, 255, 255, .2); }
html[data-view="verify"] .to-verify, html:not([data-view="verify"]) .to-desk { display: none; }
.nav a[aria-current="page"] { background: rgba(255, 255, 255, .16); color: #fff; }

/* ---------- workbench ---------- */
main { max-width: 1320px; margin-inline: auto; padding: 0 16px; overflow-x: clip; } /* the fanned certificate stack must not widen a phone */
.desk { display: flex; flex-direction: column; gap: 12px; padding-top: 22px; }
.panel { display: contents; }
h1 {
  order: 1; font: 800 clamp(1.55rem, 1rem + 2.6vw, 3rem)/1.2 var(--ff-d);
  color: var(--ink); letter-spacing: 0; text-wrap: balance;
}
h1 .w { display: inline-block; }
.types {
  order: 2; border: 0; margin: 0 -16px; padding: 2px 16px 6px; min-inline-size: 0; display: flex; gap: 8px;
  overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none; scroll-padding-inline: 16px;
}
/* the side that still hides types fades out (app.js sets more-l / more-r from the scroll position) */
.types.more-l { -webkit-mask-image: linear-gradient(to right, transparent 0, #000 64px); mask-image: linear-gradient(to right, transparent 0, #000 64px); }
.types.more-r { -webkit-mask-image: linear-gradient(to left, transparent 0, #000 64px); mask-image: linear-gradient(to left, transparent 0, #000 64px); }
.types.more-l.more-r { -webkit-mask-image: linear-gradient(to right, transparent 0, #000 64px, #000 calc(100% - 64px), transparent 100%); mask-image: linear-gradient(to right, transparent 0, #000 64px, #000 calc(100% - 64px), transparent 100%); }
.types::-webkit-scrollbar { display: none; }
.type { position: relative; display: block; flex: none; scroll-snap-align: start; }
.type input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.type span {
  display: flex; align-items: center; min-height: 46px; height: 100%; white-space: nowrap;
  padding: 6px 12px; border: 1.5px solid var(--line); border-radius: var(--r-m); background: var(--surface);
  transition: background-color .2s, border-color .2s, color .2s, transform .2s;
}
.type b { font: 700 0.875rem/1.3 var(--ff-b); }
.type input:hover + span { border-color: var(--teal); }
.type input:active + span { transform: scale(.98); }
.type input:checked + span { background: var(--deep); border-color: var(--deep); color: #fff; }
.type input:focus-visible + span { outline: 3px solid var(--gold); outline-offset: 2px; }

.stage { order: 3; position: relative; margin: 6px 0 4px; }
.paper {
  position: relative; z-index: 2; aspect-ratio: 2000 / 1414; background: #fff; border-radius: 6px; overflow: hidden;
  box-shadow: 0 1px 2px rgba(0, 60, 56, .12), 0 10px 28px -10px rgba(0, 60, 56, .32), 0 24px 60px -30px rgba(22, 62, 87, .35);
}
.paper .cert { display: block; width: 100%; height: 100%; }
.zoom { position: absolute; z-index: 3; top: 8px; left: 8px; width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: 12px; background: rgba(255, 255, 255, .92); color: var(--deep); font-size: 1.375rem; box-shadow: 0 1px 3px rgba(0, 60, 56, .25); }
@media (max-width: 559px) {
  .stage { margin-inline: -16px; }
  .paper { border-radius: 0; box-shadow: none; cursor: zoom-in; }
  .stack i { border-radius: 0; }
}
.viewer { width: 100%; max-width: 100%; height: 100%; max-height: 100%; margin: 0; padding: 0; border: 0; background: rgba(9, 30, 36, .94); overflow: hidden; }
.viewer[open] { display: block; }
.viewer::backdrop { background: rgba(9, 30, 36, .94); }
.v-sheet { position: absolute; left: 50%; top: 50%; translate: -50% -50%; background: #fff; border-radius: 4px; overflow: hidden; box-shadow: 0 20px 50px -20px rgba(0, 0, 0, .6); }
.v-sheet.turn { rotate: 90deg; }
.v-sheet .cert { display: block; width: 100%; height: 100%; }
.v-close { position: absolute; z-index: 2; top: max(12px, env(safe-area-inset-top)); right: 12px; width: 48px; height: 48px; display: grid; place-items: center; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .14); color: #fff; font-size: 2rem; }
.paper .ghost { position: absolute; inset: 0; }
.stack { position: absolute; inset: 0 0 auto; aspect-ratio: 2000 / 1414; z-index: 1; }
.stack i {
  position: absolute; inset: 0; background: #fff; border-radius: 6px; visibility: hidden;
  box-shadow: 0 6px 18px -8px rgba(0, 60, 56, .35); border: 1px solid #e3efed;
}
.stack i:last-child { background: #f7fbfa; }
.ink {
  position: absolute; z-index: 3; width: 12%; aspect-ratio: 1; left: 44%; top: 73.5%;
  border-radius: 50%; border: 3px solid var(--navy); pointer-events: none;
}
.done {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
  margin-top: 12px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m);
}
.done-txt { font-weight: 700; font-size: 0.9375rem; color: var(--deep); }
.done-txt bdi { letter-spacing: 0; }
.done-act { display: flex; gap: 8px; flex-wrap: wrap; }

.who { order: 4; display: grid; gap: 8px; }
.who-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.seg { display: inline-flex; padding: 3px; gap: 2px; background: #d6ebe8; border-radius: 12px; }
.seg button {
  border: 0; background: transparent; padding: 6px 12px; min-height: 44px; min-width: 44px; border-radius: 9px;
  font-weight: 700; font-size: 0.875rem; color: var(--mute); transition: background-color .2s, color .2s;
}
.seg button[aria-selected="true"], .seg button[aria-checked="true"] { background: #fff; color: var(--deep); box-shadow: 0 1px 3px rgba(0, 60, 56, .18); }
.inp {
  width: 100%; min-height: 50px; padding: 11px 14px; font-size: 1rem; background: #fff;
  border: 1.5px solid var(--line-2); border-radius: var(--r-m); color: var(--ink); transition: border-color .2s, box-shadow .2s;
}
.inp::placeholder { color: #5e7774; }
.inp:focus { outline: none; border-color: var(--deep); box-shadow: 0 0 0 3px rgba(27, 154, 143, .25); }
.inp-name { font: 700 1.1875rem/1.3 var(--ff-d); }
.inp-list { resize: vertical; min-height: 124px; line-height: 1.6; }
select.inp {
  appearance: none; padding-inline-end: 42px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2347615f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat left 14px center / 18px 18px;
}
.hint { font-size: 0.875rem; color: var(--mute); margin-top: 6px; text-wrap: pretty; }
.hint-2 { margin-top: 2px; }
.hint:empty, .done-txt:empty { display: none; }
.nw { white-space: nowrap; }
.viewing {
  order: 4; display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: #fff; border: 1.5px dashed var(--line-2); border-radius: var(--r-m);
}
.viewing > iconify-icon { font-size: 1.625rem; color: var(--deep); }
.viewing p { flex: 1; font-size: 0.9375rem; color: var(--mute); }
.viewing p b { color: var(--ink); font-family: var(--ff-d); white-space: nowrap; }
.err { color: var(--err); font-weight: 700; font-size: 0.875rem; }

.issue {
  order: 5; display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 56px;
  border: 0; border-radius: var(--r-m); background: var(--gold); color: var(--gold-ink);
  font: 800 1.1875rem/1 var(--ff-d);
  transition: background-color .2s;
}
.issue iconify-icon { font-size: 1.5rem; }
.issue:hover { background: #d4a13a; }
.issue:active { transform: scale(.98); }

.fields { order: 6; margin-top: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); }
.fields summary {
  list-style: none; display: flex; align-items: center; gap: 10px; padding: 14px 16px; cursor: pointer;
  font: 700 1.0625rem/1.3 var(--ff-d); color: var(--ink); min-height: 52px;
}
.fields summary::-webkit-details-marker { display: none; }
.fields summary iconify-icon { font-size: 1.375rem; color: var(--deep); }
.fields summary .sum-s { display: none; }
/* below 360px the short label keeps the floating course button off the row's words */
@media (max-width: 359px) { .fields summary .sum-l { display: none; } .fields summary .sum-s { display: inline; } }
.fields summary .chev { margin-inline-start: auto; transition: transform .25s; color: var(--mute); }
.fields[open] summary .chev { transform: rotate(180deg); }
.grid-f { display: grid; gap: 12px; padding: 0 16px 18px; }
.f { display: grid; gap: 6px; }
.f > span { font-size: 0.875rem; font-weight: 700; color: var(--mute); }
.f-hijri { font-size: 0.9375rem; font-weight: 700; color: var(--name); align-self: center; }
.f-sub { font: 800 1rem/1.3 var(--ff-d); color: var(--ink); border-top: 1px solid #e3efed; padding-top: 14px; margin-top: 4px; }
.seg-wide { display: flex; }
.seg-wide button { flex: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 44px; padding: 8px 14px; border-radius: 999px; border: 1.5px solid var(--line-2); background: #fff;
  font-weight: 700; font-size: 0.875rem; color: var(--ink); transition: background-color .2s, border-color .2s, color .2s;
}
.chip:hover { border-color: var(--deep); }
.chip[aria-pressed="true"] { background: var(--deep); border-color: var(--deep); color: #fff; }
.sig-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.sig-row .hint { flex-basis: 100%; margin: 0; }
label.btn { cursor: pointer; }
#sig-prev { height: 44px; max-width: 160px; object-fit: contain; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 2px 6px; }
#sig-file:focus-visible + label, #csv-file:focus-visible + label { outline: 3px solid var(--gold); outline-offset: 2px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 700; color: var(--ink); cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--deep); flex: none; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 8px 16px;
  border-radius: 12px; font-weight: 700; font-size: 0.9375rem; border: 1.5px solid transparent;
  transition: background-color .2s, border-color .2s, transform .15s;
}
.btn iconify-icon { font-size: 1.25rem; }
.btn:active { transform: scale(.97); }
.btn-t { background: var(--deep); color: #fff; }
.btn-t:hover { background: var(--deep-2); }
.btn-o { background: #fff; color: var(--deep); border-color: var(--line-2); }
.btn-o:hover { border-color: var(--deep); background: #f3faf9; }
.btn-s { min-height: 40px; padding: 6px 12px; font-size: 0.875rem; }

/* ---------- batch ---------- */
.sec-head { display: flex; flex-wrap: wrap; align-items: end; gap: 6px 16px; margin-bottom: 16px; }
.sec-head h2 { font: 800 clamp(1.5rem, 1.1rem + 1.4vw, 2.125rem)/1.2 var(--ff-d); color: var(--ink); text-wrap: balance; }
.sec-sub { color: var(--mute); font-size: 0.9375rem; flex: 1 1 auto; }
.batch { margin-top: 48px; scroll-margin-top: 16px; }
.batch .sec-head .btn { margin-inline-start: auto; }
.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.card { background: #fff; border-radius: var(--r-m); padding: 8px; box-shadow: 0 1px 2px rgba(0, 60, 56, .1), 0 12px 26px -16px rgba(0, 60, 56, .45); display: grid; gap: 8px; }
.card-paper { border-radius: 4px; overflow: hidden; border: 1px solid #e3efed; }
.card-paper .cert { display: block; width: 100%; height: auto; }
.card-foot { display: grid; gap: 0; padding-inline: 4px; }
.card-foot b { font: 700 0.9375rem/1.4 var(--ff-d); overflow-wrap: anywhere; }
.card-foot bdi { font-size: 0.8125rem; color: var(--mute); letter-spacing: 0; }
.card-act { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; justify-content: space-between; }
.mini { display: inline-flex; padding: 2px; gap: 2px; background: #d6ebe8; border-radius: 12px; }
.mini button { min-width: 44px; height: 44px; padding: 0 7px; border: 0; border-radius: 10px; background: transparent; font: 700 0.875rem/1 var(--ff-d); color: var(--mute); }
.mini button[aria-pressed="true"] { background: #fff; color: var(--deep); box-shadow: 0 1px 3px rgba(0, 60, 56, .18); }

/* ---------- log and verify ---------- */
.lower { display: grid; gap: 28px; margin-top: 56px; padding-bottom: 40px; }
.log { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); padding: 20px 16px; scroll-margin-top: 16px; }
.log-tools { display: grid; gap: 10px; margin-bottom: 12px; }
.io { display: flex; gap: 8px; flex-wrap: wrap; }
.io .btn { flex: 1 1 auto; }
.search { position: relative; }
.q-clear { position: absolute; top: 50%; inset-inline-end: 3px; translate: 0 -50%; width: 44px; height: 44px; display: grid; place-items: center; border: 0; background: transparent; color: var(--mute); font-size: 1.25rem; border-radius: 10px; }
#q { padding-inline-end: 48px; }
#q::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.search iconify-icon { position: absolute; top: 50%; inset-inline-start: 14px; translate: 0 -50%; font-size: 1.25rem; color: var(--mute); pointer-events: none; }
.search .inp { padding-inline-start: 44px; }
.rows { display: grid; }
.row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "main act" "ser act";
  align-items: center; column-gap: 12px; padding: 12px 2px; border-bottom: 1px solid #e3efed;
}
.row:last-child { border-bottom: 0; }
.r-main { grid-area: main; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; min-width: 0; }
.r-main b { font: 700 1rem/1.4 var(--ff-d); flex-basis: 100%; }
.r-main span { font-size: 0.8125rem; color: var(--mute); }
.r-date { white-space: nowrap; }
.r-main .r-edit { color: var(--gold-text); font-weight: 700; flex-basis: 100%; }
.r-ser { grid-area: ser; font-size: 0.8125rem; font-weight: 700; color: var(--name); letter-spacing: 0; justify-self: start; }
.r-act { grid-area: act; display: flex; gap: 6px; }
.ib { flex: none; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; border: 1.5px solid var(--line-2); background: #fff; color: var(--deep); font-size: 1.25rem; transition: background-color .2s, border-color .2s, transform .15s; }
.ib:hover { border-color: var(--deep); background: #f3faf9; }
.ib:active { transform: scale(.94); }
.ib-t { background: var(--deep); border-color: var(--deep); color: #fff; }
.ib-t:hover { background: var(--deep-2); }
.empty { color: var(--mute); padding: 18px 4px; font-size: 0.9375rem; }
.more { margin-top: 10px; width: 100%; }

.verify { padding: 28px 0 48px; min-height: calc(100svh - 62px - 140px); }
.verify-card {
  max-width: 620px; margin-inline: auto; background: var(--deep); color: #fff; border-radius: var(--r-l); padding: 26px 18px 22px;
  display: grid; gap: 10px; align-content: start;
}
.verify h1 { order: 0; font: 800 1.75rem/1.2 var(--ff-d); color: #fff; outline: none; }
.verify-sub { color: #d3ece8; font-size: 0.9375rem; }
.v-cert { flex-basis: 100%; margin-top: 4px; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.v-cert .cert { display: block; width: 100%; height: auto; }
.verify-f { display: flex; gap: 8px; margin-top: 6px; }
.verify-f .inp { flex: 1; min-width: 0; text-align: right; font-variant-numeric: tabular-nums; border-color: transparent; }
.verify-f .btn { background: var(--gold); color: var(--gold-ink); min-height: 50px; padding-inline: 18px; font-family: var(--ff-d); font-weight: 800; font-size: 1rem; }
.verify-f .btn:hover { background: #d4a13a; }
.verdict:empty { display: none; }
.verdict { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r-m); background: #fff; color: var(--ink); }
.verdict iconify-icon { font-size: 1.75rem; margin-top: 2px; }
.verdict > div:not(.v-cert) { display: grid; gap: 2px; flex: 1; min-width: 0; }
.verdict b { font: 800 1.0625rem/1.3 var(--ff-d); }
.verdict span { font-size: 0.875rem; color: var(--mute); }
.v-ok iconify-icon { color: var(--deep); }
.v-no iconify-icon { color: var(--err); }
.v-no b { color: var(--err); }

.foot { border-top: 1px solid var(--line); padding: 20px 16px 88px;   /* the last line clears the shared floating course button */ text-align: center; color: var(--mute); font-size: 0.875rem; }
.foot p { max-width: 60ch; margin-inline: auto; text-wrap: balance; }

.toast {
  position: fixed; z-index: var(--z-toast); bottom: calc(80px + env(safe-area-inset-bottom, 0px));   /* above the shared floating course button */ left: 50%; translate: -50% 0; max-width: calc(100% - 32px);
  background: var(--navy); color: #fff; padding: 12px 18px; border-radius: var(--r-m); font-weight: 700; font-size: 0.9375rem;
  box-shadow: 0 12px 30px -10px rgba(0, 0, 0, .45);
}
.print-area { display: none; }

/* ---------- sizes ---------- */
@media (min-width: 400px) {
  .type b { font-size: 0.9375rem; }
}
@media (min-width: 560px) {
  .grid-f { grid-template-columns: 1fr 1fr; }
  .f-wide { grid-column: 1 / -1; }
  .cards { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
}
@media (max-width: 479px) {
  .r-main .r-date { flex-basis: 100%; }
}
@media (max-width: 359px) {
  .brand-txt span { display: none; }
  .desk { padding-top: 16px; gap: 10px; }
  h1 { font-size: 1.3rem; }
  .types { gap: 6px; }
  .type span { min-height: 44px; padding: 6px 10px; }
  .type b { font-size: 0.8125rem; }
  .seg button { padding: 6px 8px; font-size: 0.8125rem; }
  .who-head { gap: 6px; }
  .desk { gap: 8px; }
  .stage { margin: 2px 0 0; }
  .who { gap: 6px; }
  .inp { min-height: 46px; padding-block: 9px; }
  .issue { min-height: 50px; }
}

@media (min-width: 900px) {
  .top-in { padding: 12px 28px 10px; min-height: 76px; }
  .mark { width: 44px; height: 44px; }
  .brand-txt strong { font-size: 1.3125rem; }
  h1 { font-size: 1.8rem; }   /* the title stays on one line in the 360-430px panel, never one word alone */
  .nav { display: flex; gap: 4px; position: absolute; left: 50%; translate: -50% 0; }
  .nav a { color: #e6f4f2; text-decoration: none; font-weight: 700; font-size: 0.9375rem; padding: 8px 14px; border-radius: 10px; transition: background-color .2s; }
  .nav a:hover { background: rgba(255, 255, 255, .12); color: #fff; }
  main { padding: 0 28px; }
  .desk {
    display: grid; grid-template-columns: minmax(360px, 430px) minmax(0, 1fr); grid-template-areas: "panel stage" "fields stage";
    gap: 22px 48px; align-items: start; padding-top: 44px;
  }
  .panel { display: flex; flex-direction: column; gap: 18px; grid-area: panel; }
  .types { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0; padding: 0; overflow: visible; -webkit-mask-image: none; mask-image: none; }
  .type span { min-height: 52px; padding: 8px 12px; white-space: normal; }
  .type b { font-size: 0.9375rem; }
  .log-tools { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
  .stage {
    grid-area: stage; position: sticky; top: 24px; margin: 0; padding: 38px 40px 28px; background: var(--mat); border-radius: 26px;
  }
  .stack { inset: 38px 40px auto; aspect-ratio: 2000 / 1414; }
  .fields { grid-area: fields; margin-top: 0; }
  .batch { margin-top: 72px; }
  .cards { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; }
  .lower { margin-top: 72px; padding-bottom: 64px; }
  .top-link { display: none !important; }
  .log { padding: 26px 26px 18px; }
  .row { grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas: "main ser act"; column-gap: 16px; }
  /* the rows end clear of the floating back button in its corner (16px to about 209px from the left), so at rest it never covers a row's view or download button */
  .rows { padding-inline-end: max(0px, calc(228px - max(55px, (100vw - 1264px) / 2 + 27px))); }
  .r-ser { font-size: 0.875rem; justify-self: end; }
  .verify { padding-top: 64px; min-height: calc(100svh - 76px - 140px); }
  .verify-card { padding: 34px 34px 30px; }
  .verify h1 { font-size: 2.125rem; }
  .zoom { display: none; }
  .paper { cursor: default; }
}
@media (min-width: 1200px) {
  .desk { grid-template-columns: 440px minmax(0, 1fr); gap: 24px 64px; }
  h1 { font-size: 2.125rem; }
  .stage { padding: 48px 56px 34px; }
  .stack { inset: 48px 56px auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; scroll-behavior: auto !important; }
}

/* ---------- print: one certificate per A4 landscape page ---------- */
@page { size: A4 landscape; margin: 0; }
@media print {
  html, body { background: #fff !important; }
  body > *:not(.print-area) { display: none !important; }
  .print-area { display: block !important; }
  .pg { width: 297mm; height: 210mm; overflow: hidden; break-after: page; page-break-after: always; }
  .pg:last-child { break-after: auto; page-break-after: auto; }
  .pg .cert { display: block; width: 100%; height: 100%; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* the entrance (app.js intro) reveals these with autoAlpha; hidden before the first paint so they never flash */
html.js-anim #h1, html.js-anim .type, html.js-anim #paper, html.js-anim .who, html.js-anim .issue, html.js-anim #stack i { visibility: hidden; }

/* tablets: the certificate types fit on two rows, so no cut-off scroll strip */
@media (min-width: 560px) and (max-width: 899px) {
  .types { flex-wrap: wrap; overflow: visible; mask-image: none; -webkit-mask-image: none; }
  /* the second row of types costs ~54px, so the preview is a little narrower: the issue button stays on the first
     screen and clear of the floating course button */
  .stage { width: min(100%, 620px); margin-inline: auto; }
}
