/* Montserrat sluzy tu juz tylko do jednego: do rysowania samego dyplomu na
   canvasie podgladu (js/draw-canvas.js). Musi byc dokladnie ten sam kroj, ktory
   jsPDF osadza w gotowym pliku, inaczej podglad klamalby o wyniku. Interfejs
   narzedzia stoi na Figtree i Sorze, tak jak pozostale dziewiec generatorow
   (../../css/fonts.css). Pliki TTF obok, w ../fonts, zostaja nietkniete: jsPDF
   potrzebuje kompletu glifow. */
@font-face {
  font-family: Montserrat;
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
  src: url('../../fonts/Montserrat-latin.woff2') format('woff2');
  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: Montserrat;
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
  src: url('../../fonts/Montserrat-latin-ext.woff2') format('woff2');
  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;
}

:root {
  --navy: #001f5c;
  --navy-deep: #00143d;
  --ink: #14213d;
  --muted: #687386;
  --soft: #8a94a6;
  --green: #40b181;
  --green-dark: #308774;
  --mint: #e4f7ef;
  --canvas: #eef1f7;
  --surface: #ffffff;
  --surface-soft: #f7f9fb;
  --line: #e2e7ed;
  --line-strong: #d4dbe4;
  --danger: #c43c49;
  --shadow-sm: 0 1px 2px rgba(18, 35, 61, .05), 0 6px 20px rgba(18, 35, 61, .04);
  --shadow-paper: 0 2px 4px rgba(8, 28, 58, .08), 0 24px 70px rgba(8, 28, 58, .17);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font: 400 14px/1.5 'Figtree', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* Naglowki na Sorze, jak w pozostalych generatorach. */
h1, h2, h3, .product-title, .btn-download, .step-number, .preview-kicker {
  font-family: 'Sora', 'Figtree', sans-serif;
}

button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
[hidden] { display: none !important; }

.app-header {
  position: relative;
  z-index: 20;
  height: 78px;
  padding: 0 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: var(--navy);
  border-bottom: 0;
  box-shadow: 0 2px 0 rgba(0, 20, 61, .12);
}

.brand-lockup, .header-actions, .product-name, .local-status, .academy-link { display: flex; align-items: center; }
.brand-lockup { gap: 18px; min-width: 0; }
.brand-link { display: block; flex: 0 0 auto; }
.brand-link img { display: block; width: auto; height: 41px; }
.product-name { flex-direction: column; align-items: flex-start; gap: 2px; color: white; white-space: nowrap; }
.product-title { display: flex; align-items: center; gap: 9px; font-size: 18px; font-weight: 700; letter-spacing: -.02em; }
.product-name small { color: rgba(255,255,255,.7); font-size: 10px; font-weight: 400; }
.product-badge {
  padding: 4px 8px;
  border-radius: 999px;
  color: white;
  background: var(--green);
  font-size: 9px;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.header-actions { gap: 10px; }
.local-status { gap: 7px; margin-right: 8px; color: rgba(255,255,255,.67); font-size: 10px; white-space: nowrap; }
.local-status svg { width: 16px; height: 16px; fill: none; stroke: var(--green); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.local-status.is-saving { color: #a9e7d3; }
.academy-link { min-height: 38px; padding: 8px 13px; gap: 5px; color: white; border: 1px solid rgba(255,255,255,.25); border-radius: 10px; text-decoration: none; font-size: 11px; font-weight: 700; }
.academy-link:hover { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.45); }
.academy-link svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s ease; }
.academy-link:hover svg { transform: translateX(2px); }

.app-shell {
  height: calc(100vh - 78px);
  min-height: 620px;
  display: grid;
  grid-template-columns: minmax(400px, 430px) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  overflow: hidden;
}

.editor-panel {
  position: relative;
  z-index: 5;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid #d6ddea;
  box-shadow: none;
}

.editor-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #cbd3dc transparent;
}
.editor-scroll::-webkit-scrollbar { width: 8px; }
.editor-scroll::-webkit-scrollbar-thumb { background: #cbd3dc; border: 2px solid white; border-radius: 99px; }

.editor-intro { padding: 27px 24px 19px; }
.eyebrow {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 10px;
  color: var(--green-dark);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.eyebrow span { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px var(--mint); }
.editor-intro h1 { margin: 0 0 7px; color: var(--navy); font-size: 23px; line-height: 1.2; letter-spacing: -.025em; }
.editor-intro > p:last-child { margin: 0; color: var(--muted); font-size: 11px; }

.stepper {
  margin: 0 24px 8px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}
.stepper a { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 10px; font-weight: 700; text-decoration: none; white-space: nowrap; }
.stepper a span { width: 21px; height: 21px; display: grid; place-items: center; border: 1px solid var(--line-strong); border-radius: 50%; background: white; color: var(--muted); font-size: 9px; }
.stepper a.is-active { color: var(--navy); }
.stepper a.is-active span { border-color: var(--navy); background: var(--navy); color: white; }
.stepper a.is-complete { color: var(--green-dark); }
.stepper a.is-complete span { border-color: var(--green); color: var(--green-dark); background: var(--mint); }
.stepper i { flex: 1; min-width: 12px; height: 1px; margin: 0 9px; background: var(--line-strong); }

.editor-section { padding: 25px 24px 27px; border-bottom: 1px solid var(--line); scroll-margin-top: 20px; }
.section-heading { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 22px; }
.step-number { width: 30px; height: 30px; flex: 0 0 30px; display: grid; place-items: center; border-radius: 9px; color: white; background: var(--navy); font-size: 10px; font-weight: 700; }
.section-heading h2 { margin: 0 0 2px; color: var(--navy); font-size: 16px; line-height: 1.35; }
.section-heading p { margin: 0; color: var(--muted); font-size: 10px; }

fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.control-group + .control-group { margin-top: 22px; }
legend, label { margin: 0 0 8px; color: var(--ink); font-size: 10px; font-weight: 700; }
.legend-row { width: 100%; display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.legend-row > span { color: var(--ink); font-size: 10px; }
.legend-row small { color: var(--soft); font-size: 9px; font-weight: 400; }

.occasion-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.occasion-card {
  position: relative;
  min-height: 48px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: white;
  cursor: pointer;
  text-align: left;
  transition: border-color .15s ease, background .15s ease, transform .15s ease, box-shadow .15s ease;
}
.occasion-card:hover { transform: translateY(-1px); border-color: #aebccc; box-shadow: var(--shadow-sm); }
.occasion-card[aria-pressed="true"] { border-color: var(--green); background: #f1fbf7; box-shadow: 0 0 0 1px var(--green); }
.occasion-icon { width: 29px; height: 29px; flex: 0 0 29px; display: grid; place-items: center; border-radius: 8px; color: var(--navy); background: #eef3f8; font-size: 14px; font-weight: 700; }
.occasion-card[aria-pressed="true"] .occasion-icon { color: var(--green-dark); background: var(--mint); }
.occasion-card strong { display: block; color: var(--ink); font-size: 10px; line-height: 1.25; }
.occasion-card small { display: block; margin-top: 1px; color: var(--soft); font-size: 8px; }
.occasion-check { position: absolute; top: 6px; right: 6px; width: 14px; height: 14px; display: none; place-items: center; border-radius: 50%; color: white; background: var(--green); font-size: 8px; }
.occasion-card[aria-pressed="true"] .occasion-check { display: grid; }

.szablony { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.szablon {
  position: relative;
  padding: 5px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: white;
  cursor: pointer;
  text-align: left;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.szablon:hover { transform: translateY(-2px); border-color: #aebccc; box-shadow: 0 9px 24px rgba(18, 35, 61, .09); }
.szablon[aria-pressed="true"] { border-color: var(--green); box-shadow: 0 0 0 1px var(--green), 0 9px 24px rgba(47, 157, 126, .12); }
.szablon-preview { position: relative; overflow: hidden; border-radius: 7px; background: #eef1f4; }
.szablon canvas { width: 100%; height: auto; display: block; }
.template-check { position: absolute; top: 7px; right: 7px; width: 18px; height: 18px; display: none; place-items: center; border: 2px solid white; border-radius: 50%; color: white; background: var(--green); box-shadow: 0 2px 7px rgba(3, 26, 66, .2); font-size: 9px; }
.szablon[aria-pressed="true"] .template-check { display: grid; }
.template-caption { padding: 8px 5px 5px; display: flex; align-items: center; justify-content: space-between; gap: 5px; }
.template-caption strong { overflow: hidden; color: var(--ink); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.template-caption small { color: var(--soft); font-size: 7px; text-transform: uppercase; white-space: nowrap; }

.fields-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px 10px; }
.field { min-width: 0; }
.field-full { grid-column: 1 / -1; }
.field label { display: flex; align-items: center; justify-content: space-between; }
input[type="text"], input[type="date"], textarea {
  width: 100%;
  display: block;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  outline: none;
  color: var(--ink);
  background: white;
  font-size: 11px;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
input[type="text"], input[type="date"] { height: 40px; padding: 0 12px; }
textarea { min-height: 76px; padding: 10px 12px; line-height: 1.5; resize: vertical; }
input::placeholder, textarea::placeholder { color: #a3abb8; }
input:hover, textarea:hover { border-color: #aeb8c5; }
input:focus, textarea:focus { border-color: var(--green); background: #fcfffe; box-shadow: 0 0 0 3px rgba(47, 157, 126, .12); }

.recipient-group { margin-bottom: 15px; }
.mode-switch { padding: 3px; display: grid; grid-template-columns: 1fr 1fr; gap: 3px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-soft); }
.mode-option { height: 38px; display: flex; align-items: center; justify-content: center; gap: 7px; border: 0; border-radius: 8px; color: var(--muted); background: transparent; cursor: pointer; font-size: 9px; font-weight: 700; }
.mode-option svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.mode-option[aria-pressed="true"] { color: var(--navy); background: white; box-shadow: 0 2px 7px rgba(18, 35, 61, .08); }
.recipient-fields label { display: block; }
.field-hint-row { margin-top: 6px; display: flex; justify-content: space-between; gap: 12px; color: var(--soft); font-size: 8px; }
.field-hint-row #licznik { color: var(--green-dark); font-weight: 700; }

.privacy-note { margin: 24px 24px 0; padding: 13px 14px; display: flex; align-items: flex-start; gap: 10px; border: 1px solid #cfeadf; border-radius: 11px; color: var(--green-dark); background: #f2fbf7; }
.privacy-note svg { width: 18px; height: 18px; flex: 0 0 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.privacy-note strong { display: block; margin-bottom: 2px; font-size: 9px; }
.privacy-note span { display: block; color: #5d7d71; font-size: 8px; }
.editor-links { padding: 17px 24px 27px; display: flex; gap: 16px; }
.editor-links a { color: var(--soft); font-size: 8px; text-decoration: none; }
.editor-links a:hover { color: var(--navy); text-decoration: underline; }

.action-bar { flex: 0 0 auto; padding: 15px 22px 14px; background: rgba(255, 255, 255, .97); border-top: 1px solid var(--line); box-shadow: 0 -10px 26px rgba(18, 35, 61, .05); backdrop-filter: blur(12px); }
.btn-download { width: 100%; height: 46px; display: flex; align-items: center; justify-content: center; gap: 9px; border: 0; border-radius: 10px; color: white; background: var(--green); box-shadow: 0 8px 18px rgba(64,177,129,.22); cursor: pointer; font-size: 12px; font-weight: 700; transition: transform .15s ease, box-shadow .15s ease, background .15s ease; }
.btn-download:hover { transform: translateY(-1px); background: var(--green-dark); box-shadow: 0 11px 22px rgba(48,135,116,.25); }
.btn-download:active { transform: translateY(0); }
.btn-download:disabled { cursor: not-allowed; opacity: .48; transform: none; box-shadow: none; filter: grayscale(.25); }
.btn-download svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.status { min-height: 13px; margin: 5px 0 -5px; color: var(--green-dark); font-size: 8px; font-weight: 700; text-align: center; }
.status.blad { color: var(--danger); }

.preview-workspace {
  min-width: 0;
  min-height: 0;
  padding: 20px 28px 18px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: #eef1f7;
}
.preview-toolbar, .preview-bottom { min-height: 42px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.preview-toolbar > div:first-child { display: flex; align-items: baseline; gap: 9px; min-width: 0; }
.preview-kicker { color: var(--soft); font-size: 9px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; }
.preview-toolbar strong { overflow: hidden; color: var(--navy); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.preview-tools { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 9px; }
.tool-divider { width: 1px; height: 12px; background: var(--line-strong); }
.zoom-pill { padding: 5px 8px; border: 1px solid var(--line-strong); border-radius: 7px; background: rgba(255,255,255,.65); }

.preview-stage { position: relative; min-height: 0; overflow: hidden; }
.canvas-wrap { position: absolute; top: 50%; left: 50%; width: min(calc(100% - 8px), calc((100vh - 210px) * 1.4143)); max-width: 1050px; aspect-ratio: 297 / 210; padding: 8px; border: 1px solid rgba(255, 255, 255, .9); border-radius: 5px; background: white; box-shadow: var(--shadow-paper); transform: translate(-50%, -50%); }
.canvas-wrap::after { content: ''; position: absolute; inset: 7px; pointer-events: none; box-shadow: inset 0 0 0 1px rgba(18, 35, 61, .05); }
.canvas-wrap canvas { width: 100%; height: 100%; display: block; background: white; }

.preview-bottom { padding-top: 4px; }
.preview-tip { display: flex; align-items: center; gap: 7px; color: var(--soft); font-size: 8px; }
.preview-tip svg { width: 15px; height: 15px; fill: none; stroke: var(--green); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
#nawigacja { display: flex; align-items: center; gap: 8px; }
#ktory { min-width: 48px; color: var(--muted); font-size: 9px; text-align: center; }
.preview-nav { width: 28px; height: 28px; display: grid; place-items: center; border: 1px solid var(--line-strong); border-radius: 8px; background: rgba(255, 255, 255, .72); cursor: pointer; }
.preview-nav:hover { border-color: #a9b5c3; background: white; }
.preview-nav svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

@media (max-width: 980px) {
  .app-header { height: 64px; padding: 0 18px; }
  .brand-link img { height: 32px; }
  .product-badge, .local-status { display: none; }
  .app-shell { height: auto; min-height: calc(100vh - 64px); grid-template-columns: minmax(340px, 390px) minmax(0, 1fr); }
  .editor-panel { max-height: calc(100vh - 64px); }
  .preview-workspace { min-height: calc(100vh - 64px); padding: 16px 20px; }
}

@media (max-width: 760px) {
  .app-header { position: sticky; top: 0; }
  .product-name { display: none; }
  .academy-link { font-size: 10px; }
  .app-shell { display: flex; flex-direction: column; overflow: visible; }
  .editor-panel { display: contents; }
  .editor-scroll { overflow: visible; background: white; }
  .szablony { grid-template-columns: repeat(2, 1fr); }
  .editor-intro { padding-top: 26px; }
  .stepper { margin-bottom: 4px; }
  .preview-workspace { order: 2; min-height: auto; padding: 18px 16px 22px; display: block; }
  .preview-stage { padding: 18px 0 20px; overflow: visible; }
  .canvas-wrap { position: relative; top: auto; left: auto; width: 100%; padding: 4px; transform: none; }
  .preview-tools { display: none; }
  .preview-bottom { min-height: 30px; }
  .action-bar { position: sticky; z-index: 15; bottom: 0; order: 3; padding-right: 16px; padding-left: 16px; }
}

@media (max-width: 460px) {
  .app-header { padding: 0 14px; }
  .brand-link img { height: 28px; }
  .academy-link { max-width: 112px; text-align: right; }
  .editor-intro, .editor-section { padding-right: 20px; padding-left: 20px; }
  .editor-intro h1 { font-size: 23px; }
  .stepper { margin-right: 20px; margin-left: 20px; }
  .stepper i { margin: 0 6px; }
  .occasion-grid { grid-template-columns: 1fr; }
  .fields-grid { grid-template-columns: 1fr; }
  .field-full { grid-column: auto; }
  .privacy-note { margin-right: 20px; margin-left: 20px; }
  .editor-links { padding-right: 20px; padding-left: 20px; }
  .preview-tip span { max-width: 220px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .001ms !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; }
}
