@font-face {
  font-family: "Inter Black";
  src: url("./assets/inter-black.woff2") format("woff2");
  font-style: normal;
  font-weight: 900;
  font-display: swap;
}

:root {
  --ink: #152434;
  --muted: #667587;
  --line: #dce3e8;
  --blue: #2f739d;
  --blue-dark: #245f85;
  --blue-soft: #e9f3f8;
  --paper: #fffdf9;
  --surface: #ffffff;
  --background: #eef2f4;
  --success: #19734a;
  --error: #b33a3a;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--background);
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 85% -10%, rgba(47, 115, 157, 0.13), transparent 30rem),
    var(--background);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: min(1480px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 0 42px 42px;
}

.topbar {
  min-height: 96px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  display: block;
  overflow: hidden;
  border-radius: 12px;
  background: white;
  box-shadow: 0 8px 18px rgba(31, 46, 197, 0.18);
}

.brand-logo {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.brand-copy {
  min-width: 0;
}

.brand-copy p,
.brand-copy h1,
.editor-heading h2,
.editor-heading p,
.preview-heading p,
.preview-heading h2,
.preview-note,
.feedback p,
.loading-state p {
  margin: 0;
}

.brand-copy p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

.brand-copy h1 {
  margin-top: 3px;
  font-size: 18px;
  line-height: 1.25;
  letter-spacing: -0.015em;
}

.privacy-badge {
  margin-left: auto;
  padding: 7px 12px;
  border: 1px solid rgba(47, 115, 157, 0.2);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--blue-dark);
  font-size: 12px;
  font-weight: 700;
}

.workspace {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.editor-card,
.preview-card {
  border: 1px solid rgba(183, 196, 205, 0.72);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow:
    0 1px 2px rgba(24, 43, 58, 0.04),
    0 18px 44px rgba(24, 43, 58, 0.07);
}

.editor-card {
  position: sticky;
  top: 18px;
  max-height: calc(100vh - 36px);
  padding: 22px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #c3d0d8 transparent;
}

.control-section {
  min-width: 0;
}

.editor-heading {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 17px;
}

.editor-heading.compact {
  margin-bottom: 17px;
}

.step-number {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--blue-soft);
  color: var(--blue-dark);
  font-size: 13px;
  font-weight: 800;
}

.editor-heading h2 {
  font-size: 16px;
  line-height: 1.3;
}

.editor-heading p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.field-label {
  display: block;
  margin-bottom: 7px;
  color: #354556;
  font-size: 12px;
  font-weight: 700;
}

.name-input {
  width: 100%;
  height: 46px;
  padding: 0 13px;
  border: 1px solid #cfd8de;
  border-radius: 10px;
  outline: none;
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  transition:
    border-color 150ms ease,
    box-shadow 150ms ease;
}

.name-input::placeholder {
  color: #9aa6af;
}

.name-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47, 115, 157, 0.13);
}

.field-help {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 7px;
  color: #7d8993;
  font-size: 10px;
  line-height: 1.3;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.model-library-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  color: #354556;
  font-size: 10px;
  font-weight: 750;
}

.model-library-heading span:last-child {
  color: var(--muted);
  font-weight: 600;
}

.models-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  max-height: 286px;
  margin-bottom: 12px;
  padding: 2px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.models-placeholder {
  grid-column: 1 / -1;
  padding: 17px 12px;
  border: 1px dashed #c8d3da;
  border-radius: 9px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.45;
  text-align: center;
}

.model-card {
  min-width: 0;
  padding: 4px;
  overflow: hidden;
  border: 1px solid #d6dfe4;
  border-radius: 9px;
  background: white;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  transition:
    border-color 150ms ease,
    box-shadow 150ms ease,
    transform 120ms ease;
}

.model-card:hover {
  border-color: #89aabd;
  transform: translateY(-1px);
}

.model-card:focus-visible {
  outline: 3px solid rgba(47, 115, 157, 0.2);
  outline-offset: 2px;
}

.model-card.selected {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(47, 115, 157, 0.15);
}

.model-card.loading {
  pointer-events: none;
  opacity: 0.62;
}

.model-thumbnail {
  position: relative;
  aspect-ratio: 3 / 2;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 6px;
  background: #edf1f3;
}

.model-thumbnail::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid #cbd6dc;
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

.model-card.thumbnail-ready .model-thumbnail::after,
.model-card.thumbnail-error .model-thumbnail::after {
  display: none;
}

.model-card.thumbnail-error .model-thumbnail::before {
  content: "PDF";
  color: #81909a;
  font-size: 9px;
  font-weight: 800;
}

.model-thumbnail canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.model-name {
  display: block;
  padding: 6px 3px 3px;
  overflow: hidden;
  font-size: 9px;
  font-weight: 700;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-button {
  width: 100%;
  min-height: 42px;
  display: grid;
  place-items: center;
  border: 1px dashed #9eb5c4;
  border-radius: 10px;
  background: #f8fbfc;
  color: var(--blue-dark);
  cursor: pointer;
  font-size: 12px;
  font-weight: 750;
  transition:
    border-color 150ms ease,
    background 150ms ease;
}

.file-button:hover {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.file-button:focus-within,
.text-action:focus-within {
  outline: 3px solid rgba(47, 115, 157, 0.2);
  outline-offset: 2px;
}

.selected-file {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 10px;
}

.selected-file span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selected-file button,
.small-button {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: var(--blue-dark);
  cursor: pointer;
  font-size: 10px;
  font-weight: 750;
}

.selected-file button:hover,
.small-button:hover:not(:disabled) {
  text-decoration: underline;
}

.small-button:disabled {
  cursor: default;
  opacity: 0.45;
}

.form-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px 54px;
  gap: 9px;
  margin-top: 17px;
}

.form-field {
  min-width: 0;
}

.select-input,
.number-input {
  width: 100%;
  height: 39px;
  border: 1px solid #cfd8de;
  border-radius: 9px;
  outline: none;
  background: white;
  color: var(--ink);
  font-size: 11px;
}

.select-input {
  padding: 0 28px 0 10px;
}

.number-input {
  padding: 0 7px;
  text-align: center;
}

.select-input:focus,
.number-input:focus,
.color-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47, 115, 157, 0.13);
}

.color-input {
  width: 100%;
  height: 39px;
  padding: 4px;
  border: 1px solid #cfd8de;
  border-radius: 9px;
  outline: none;
  background: white;
  cursor: pointer;
}

.text-action {
  display: inline-block;
  margin-top: 13px;
  color: var(--blue-dark);
  cursor: pointer;
  font-size: 10px;
  font-weight: 750;
}

.text-action:hover {
  text-decoration: underline;
}

.microcopy {
  margin: 4px 0 0;
  overflow: hidden;
  color: #87939c;
  font-size: 9px;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.divider {
  height: 1px;
  margin: 20px 0;
  background: var(--line);
}

.position-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #f8fafb;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.download-actions {
  display: grid;
  gap: 9px;
}

.button {
  min-height: 44px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 750;
  transition:
    transform 120ms ease,
    background 150ms ease,
    border-color 150ms ease,
    box-shadow 150ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:active:not(:disabled) {
  transform: translateY(0);
}

.button:focus-visible,
.reset-button:focus-visible {
  outline: 3px solid rgba(47, 115, 157, 0.2);
  outline-offset: 2px;
}

.button.primary {
  border: 1px solid var(--blue);
  background: var(--blue);
  color: white;
  box-shadow: 0 7px 16px rgba(47, 115, 157, 0.18);
}

.button.primary:hover:not(:disabled) {
  background: var(--blue-dark);
  border-color: var(--blue-dark);
}

.button.secondary {
  border: 1px solid #c7d4dc;
  background: white;
  color: var(--blue-dark);
}

.button.secondary:hover:not(:disabled) {
  border-color: var(--blue);
  background: #f7fbfd;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.reset-button {
  width: 100%;
  margin-top: 13px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  font-weight: 650;
}

.reset-button:hover:not(:disabled) {
  color: var(--blue-dark);
}

.reset-button:disabled {
  cursor: default;
  opacity: 0.42;
}

.feedback {
  min-height: 40px;
  margin-top: 18px;
  padding-top: 15px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
  line-height: 1.45;
}

.feedback .error-message {
  color: var(--error);
  font-weight: 650;
}

.feedback .success-message {
  color: var(--success);
  font-weight: 650;
}

.preview-card {
  padding: 21px;
}

.preview-heading {
  min-height: 45px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 3px 16px;
}

.eyebrow {
  color: var(--blue);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.preview-heading h2 {
  max-width: 700px;
  margin-top: 3px;
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-dot {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.status-dot::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #b8c1c8;
  box-shadow: 0 0 0 4px rgba(184, 193, 200, 0.16);
}

.status-dot.ready {
  color: var(--success);
}

.status-dot.ready::before {
  background: #24a36a;
  box-shadow: 0 0 0 4px rgba(36, 163, 106, 0.13);
}

.certificate-stage {
  position: relative;
  min-height: 360px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid #d9e0e5;
  border-radius: 13px;
  background:
    linear-gradient(45deg, #e9edef 25%, transparent 25%) 0 0 / 18px 18px,
    linear-gradient(45deg, transparent 75%, #e9edef 75%) 0 0 / 18px 18px,
    linear-gradient(45deg, transparent 75%, #e9edef 75%) 9px -9px / 18px 18px,
    linear-gradient(45deg, #e9edef 25%, #f4f6f7 25%) 9px -9px / 18px 18px;
}

.certificate-canvas {
  display: block;
  width: 100%;
  height: auto;
  opacity: 0;
  touch-action: none;
  user-select: none;
  transition: opacity 220ms ease;
}

.certificate-canvas.movable {
  cursor: crosshair;
}

.certificate-canvas.dragging {
  cursor: grabbing;
}

.certificate-stage.loaded .certificate-canvas {
  opacity: 1;
}

.loading-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}

.loading-state[hidden] {
  display: none;
}

.loading-state span {
  width: 26px;
  height: 26px;
  border: 3px solid #d5dfe5;
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

.preview-note {
  padding: 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.45;
}

.preview-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 3px 1px;
}

.preview-footer > span {
  flex: 0 0 auto;
  color: var(--success);
  font-size: 9px;
  font-weight: 750;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 980px) {
  .app-shell {
    padding: 0 24px 30px;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .editor-card {
    position: static;
    max-height: none;
    overflow: visible;
  }
}

@media (max-width: 660px) {
  .app-shell {
    padding: 0 14px 18px;
  }

  .topbar {
    min-height: 82px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    font-size: 18px;
  }

  .brand-copy p,
  .privacy-badge {
    display: none;
  }

  .brand-copy h1 {
    font-size: 16px;
  }

  .editor-card,
  .preview-card {
    border-radius: 16px;
  }

  .editor-card {
    padding: 20px;
  }

  .certificate-stage {
    min-height: 210px;
  }

  .preview-card {
    padding: 14px;
  }

  .preview-heading {
    padding: 2px 2px 13px;
  }

  .form-row {
    grid-template-columns: minmax(0, 1fr) 70px 52px;
  }

  .preview-footer {
    display: block;
    text-align: center;
  }

  .preview-footer > span {
    display: inline-block;
    margin-top: 7px;
  }

  .status-dot {
    display: none;
  }
}

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