@font-face {
  font-family: 'Noto Sans';
  src: url('assets/noto-latin-ext.woff2') format('woff2');
  font-weight: 400 800;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Noto Sans';
  src: url('assets/noto-latin.woff2') format('woff2');
  font-weight: 400 800;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Caveat';
  src: url('assets/caveat-latin-ext.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Caveat';
  src: url('assets/caveat-latin.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: light;
  --blue: #009fe3;
  --action: #006d9b;
  --ink: #162c3d;
  --muted: #4f6473;
  --line: #dbe4ea;
  --surface: #f3f5f7;
  color: var(--ink);
  font-family: 'Noto Sans', system-ui, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--surface); }
img { display: block; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .6; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid #0075a8; outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
.icon { width: 1.25rem; height: 1.25rem; flex: none; }

.locked { color: #fff; background: var(--blue); }
.gate {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 2rem;
  padding: 2rem 1rem;
}
.gate-logo { width: min(78vw, 19rem); height: auto; }
.gate-card {
  width: min(100%, 27rem);
  padding: clamp(1.4rem, 6vw, 2.4rem);
  border: 1px solid #ffffff9c;
  border-radius: 1.4rem;
  background: #005d8b36;
  text-align: center;
}
.gate-lock {
  width: 2.8rem;
  height: 2.8rem;
  display: grid;
  place-items: center;
  margin: 0 auto 1rem;
  border-radius: 50%;
  background: #ffffff26;
}
.gate-lock svg { width: 1.3rem; }
.gate h1 { font-size: clamp(1.55rem, 5vw, 2rem); line-height: 1.18; letter-spacing: -.035em; }
#gate-form { display: grid; gap: .7rem; margin-top: 1.65rem; text-align: left; }
#gate-form label { font-size: .9rem; font-weight: 700; text-shadow: 0 1px 2px #004363; }
#gate-form input { min-width: 0; min-height: 3rem; padding: .65rem .85rem; border: 2px solid transparent; border-radius: .65rem; color: var(--ink); background: #fff; }
#gate-form input[aria-invalid="true"] { border-color: #8a1930; }
#gate-form button { min-height: 3rem; padding: .65rem 1rem; border: 1px solid #003f61; border-radius: .65rem; color: #fff; background: #004d73; font-weight: 700; }
#gate-form button:hover { background: #003d5c; }
#gate-form :focus-visible { outline-color: #fff; outline-offset: 3px; }
#gate-error { padding: .55rem .7rem; border-radius: .45rem; background: #692136; color: #fff; font-size: .875rem; }

#root.editor { display: grid; min-height: 100dvh; grid-template-rows: auto 1fr; }
.app-header {
  min-height: 4.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .75rem clamp(1rem, 3vw, 2.5rem);
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.header-brand { display: flex; align-items: center; gap: .9rem; min-width: 0; }
.brand-mark { display: grid; place-items: center; flex: none; background: #008ac6; border-radius: .55rem; padding: .65rem .7rem; }
.brand-mark img { width: 4.6rem; height: auto; }
.app-header h1 { font-size: clamp(.98rem, 1.85vw, 1.25rem); letter-spacing: -.027em; line-height: 1.2; }
.header-actions { display: flex; gap: .6rem; flex: none; }
.button {
  min-height: 2.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  border: 1px solid #c6d6e0;
  border-radius: .6rem;
  padding: .55rem .9rem;
  color: var(--ink);
  background: #fff;
  font-size: .875rem;
  font-weight: 700;
}
.button:hover { background: #eef6fa; }
.button.primary { border-color: var(--action); color: #fff; background: var(--action); }
.button.primary:hover { background: #005c82; }
.workspace { display: grid; grid-template-columns: minmax(20rem, 26rem) minmax(0, 1fr); min-height: 0; }
.controls {
  padding: 1.5rem clamp(1rem, 2vw, 1.75rem);
  border-right: 1px solid var(--line);
  background: #fff;
}
.controls-intro { margin-bottom: 1.35rem; }
.controls-intro h2, .preview-header h2 { font-size: 1.18rem; letter-spacing: -.025em; }
.controls-intro p { color: var(--muted); margin-top: .3rem; font-size: .875rem; }
.panel { border-top: 1px solid var(--line); padding: 1.1rem 0; min-width: 0; }
.panel h3, .panel summary { display: flex; align-items: center; gap: .65rem; font-size: .975rem; font-weight: 750; }
.panel h3 .icon, .panel summary .icon { width: 1.1rem; height: 1.1rem; color: var(--action); }
.panel summary { cursor: pointer; list-style: none; min-height: 1.5rem; }
.panel summary::-webkit-details-marker { display: none; }
.panel summary::after {
  content: '';
  width: .45rem;
  height: .45rem;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  margin: 0 .35rem .25rem auto;
  rotate: 45deg;
}
.panel[open] summary::after { rotate: 225deg; margin-bottom: -.15rem; }
.fields { display: grid; gap: .85rem; margin-top: .85rem; min-width: 0; }
.field { display: grid; gap: .35rem; min-width: 0; }
.field label, .field legend { font-size: .875rem; font-weight: 650; }
.fieldset { border: 0; padding: 0; margin: 0; min-inline-size: 0; }
.fieldset legend { padding: 0; margin-bottom: .35rem; }
.field input:not([type="checkbox"]), .field select, .field textarea {
  width: 100%;
  min-width: 0;
  min-height: 2.65rem;
  padding: .5rem .65rem;
  background: #fff;
  border: 1px solid #beced8;
  border-radius: .5rem;
  color: var(--ink);
  font-size: .95rem;
}
.field select {
  appearance: none;
  padding-right: 2rem;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%234f6473' stroke-width='1.5' viewBox='0 0 16 16'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E") right .65rem center / 1rem no-repeat;
}
.field input::placeholder, .field textarea::placeholder { color: #617684; }
.field textarea { resize: vertical; line-height: 1.45; }
.field input[type="file"] { font-size: .875rem; }
.field input::file-selector-button { margin-right: .55rem; border: 0; border-radius: .3rem; padding: .3rem .45rem; background: #e9f3f8; color: var(--ink); cursor: pointer; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: .35rem; padding: .25rem; border-radius: .55rem; background: #edf2f5; }
.segmented label {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 2.2rem;
  gap: .45rem;
  padding: .25rem;
  border: 1px solid transparent;
  border-radius: .4rem;
  color: var(--muted);
  cursor: pointer;
}
.segmented input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.segmented label:has(input:checked) { background: #fff; border-color: #cfdee6; color: #00577d; box-shadow: 0 1px 3px #183b5314; }
.segmented label:has(input:focus-visible) { outline: 3px solid var(--action); outline-offset: 2px; }
.segmented .icon { width: 1rem; height: 1rem; }
.toggle { display: flex; align-items: center; gap: .55rem; min-height: 2rem; cursor: pointer; }
.toggle input { width: 1.1rem; height: 1.1rem; margin: 0; accent-color: var(--action); }
.hint { font-size: .82rem; color: var(--muted); line-height: 1.45; }
.feedback { font-size: .875rem; color: #8a2535; }
.inline-action { justify-self: start; min-height: 2.25rem; }
.preview { min-width: 0; padding: 1.5rem clamp(1rem, 3vw, 2.5rem) 1rem; display: flex; flex-direction: column; gap: .85rem; }
.preview-header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .55rem; }
.preview-spec {
  border: 1px solid #d4e0e8;
  border-radius: 2rem;
  padding: .28rem .65rem;
  font-size: .8rem;
  font-weight: 650;
  color: #456072;
  background: #fff;
}
.stage {
  position: relative;
  display: grid;
  place-items: center;
  flex: 1;
  min-height: 13rem;
  padding: 1.25rem;
  border: 1px solid #d8e2e9;
  border-radius: .85rem;
  background-color: #eaf0f4;
  background-image: radial-gradient(circle, #cad8e1 1px, transparent 1.25px);
  background-size: 16px 16px;
  overflow: hidden;
}
.paper-frame { position: relative; overflow: hidden; background: var(--blue); box-shadow: 0 .55rem 1.6rem #173c5b30; }
.paper-frame > .certificate { position: absolute; inset: 0 auto auto 0; transform: scale(var(--zoom, 1)); transform-origin: top left; }
.preview-footer { min-height: 1.3rem; font-size: .84rem; color: var(--muted); display: flex; flex-wrap: wrap; justify-content: space-between; gap: .2rem .7rem; }
.preview-footer output[data-error] { color: #8a2535; }

.certificate {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 2.2em;
  isolation: isolate;
  overflow: hidden;
  padding: 26em 6em 4.7em;
  font-size: var(--unit);
  background: var(--blue);
  color: #fff;
  font-family: 'Noto Sans', sans-serif;
}
.certificate.plain { padding-top: 6em; }
.cert-art { position: absolute; top: 3.7em; width: 16.3em; height: auto; }
.cert-art.left { left: 4.8em; }
.cert-art.right { right: 3.7em; }
.cert-main {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  align-items: safe center;
  justify-items: center;
  min-width: 0;
  min-height: 0;
  padding-bottom: 2em;
  overflow: hidden;
  text-align: center;
}
.cert-story { display: grid; justify-items: center; width: 100%; min-width: 0; overflow-wrap: anywhere; font-size: calc(var(--unit) * var(--fit, 1)); }
.cert-story > * { max-width: 100%; white-space: pre-wrap; }
.cert-kicker { margin-bottom: .6em; font-size: 2.6em; font-weight: 750; letter-spacing: .12em; line-height: 1.25; }
.cert-title { font-size: 6.65em; font-weight: 800; letter-spacing: -.035em; line-height: 1.12; }
.cert-message { display: grid; gap: .83em; margin-top: .95em; width: 100%; max-width: 25em; font-size: 3.47em; font-weight: 400; line-height: 1.25; }
.cert-message p { white-space: pre-wrap; }
.certificate.warm .cert-message p:last-child { font-weight: 750; }
.cert-greeting { margin-top: .18em; font-family: 'Caveat', cursive; font-size: 12.7em; font-weight: 700; line-height: 1.1; letter-spacing: -.025em; }
.certificate.formal .cert-greeting { margin-top: .36em; font-size: 7.1em; }
.cert-signature { margin-top: .55em; font-size: 2.7em; line-height: 1.25; font-weight: 700; }
.cert-amount { margin-top: .7em; padding: .32em .65em; border: .06em solid #fff; border-radius: .27em; font-size: 2.75em; line-height: 1.25; font-weight: 700; }
.cert-foot { display: grid; justify-items: center; gap: 6em; }
.cert-qr {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  gap: 3.4em;
  border-top: .18em solid #fff;
  padding: 3.2em 3.5em 0;
}
.qr-paper { flex: none; width: 17em; height: 17em; display: grid; place-items: center; overflow: hidden; background: #fff; }
.qr-paper img { width: 100%; height: 100%; object-fit: contain; }
.qr-paper img.uploaded { width: 84%; height: 84%; }
.cert-qr-copy { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.cert-qr h3 { margin-bottom: .19em; font-size: 4.55em; letter-spacing: -.024em; line-height: 1.12; font-weight: 800; }
.cert-qr p { font-size: 3.5em; line-height: 1.22; }
.cert-logo { width: 43em; height: 5.4em; display: grid; place-items: center; }
.cert-logo.custom { width: 25.5em; height: 12.9em; }
.cert-logo img { max-width: 100%; max-height: 100%; }
.certificate.landscape { grid-template: minmax(0, 1fr) / minmax(0, 1fr) 42em; gap: 5em; padding: 6em; }
.landscape .cert-main { padding-top: 11.7em; padding-bottom: 2.5em; }
.landscape.plain .cert-main { padding-top: 0; }
.landscape .cert-art.left { width: 11em; top: 2.7em; }
.landscape .cert-art.right { width: 17em; top: 4.5em; right: 18.5em; }
.landscape .cert-foot { align-self: end; }
.landscape .cert-qr { justify-content: start; flex-direction: column; gap: 1.6em; padding: 2.1em 0 0; text-align: center; }
.landscape .qr-paper { width: 16em; height: 16em; }
.landscape .cert-qr h3 { font-size: 3.8em; }
.landscape .cert-qr p { font-size: 3em; }
.landscape .cert-title { font-size: 6.9em; }
.landscape .cert-message { font-size: 3.5em; }
.landscape .cert-greeting { font-size: 11em; }
.landscape.formal .cert-greeting { font-size: 6.5em; }
.landscape .cert-logo { width: 38em; height: 4.8em; }
.landscape .cert-logo.custom { width: 23em; height: 11.5em; }
.export-snapshot { position: absolute; top: 0; left: -20000px; pointer-events: none; }

@media (min-width: 761px) {
  .workspace { height: calc(100dvh - 4.75rem); min-height: 24rem; }
  .controls { overflow-y: auto; }
  .stage { min-height: 0; }
}
@media (max-width: 760px) {
  .workspace { grid-template-columns: 1fr; }
  .controls { border-right: 0; padding-top: 1.2rem; }
  .preview { grid-row: 1; padding-top: 1rem; border-bottom: 1px solid var(--line); }
  .stage { height: clamp(15rem, 56svh, 31rem); flex: none; padding: .85rem; }
  .app-header { flex-wrap: wrap; gap: .6rem; }
  .header-actions { width: 100%; }
  .header-actions > .button { flex: 1; }
}
