:root {
  --ink: #17181c;
  --muted: #666c78;
  --paper: #fbfaf7;
  --surface: #ffffff;
  --line: #e7e1d8;
  --red: #d73832;
  --teal: #0e7c72;
  --gold: #b97924;
  --blue: #335c9f;
  --shadow: 0 22px 70px rgba(23, 24, 28, .14);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

button, input { font: inherit; }

a { color: inherit; text-decoration: none; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 72px;
  padding: 0 32px;
  background: rgba(251, 250, 247, .88);
  border-bottom: 1px solid rgba(231, 225, 216, .9);
  backdrop-filter: blur(18px);
}

.brand, .nav, .top-actions, .hero-actions, .section-head, .filters {
  display: flex;
  align-items: center;
}

.brand { gap: 10px; font-weight: 800; font-size: 20px; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  color: white;
  background: var(--red);
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(215, 56, 50, .28);
}

.nav { gap: 22px; color: var(--muted); font-size: 14px; font-weight: 600; }
.nav a:hover { color: var(--ink); }
.top-actions { gap: 10px; }

.ghost-button, .dark-button, .primary-button, .secondary-button, .icon-button, .download-link {
  border: 0;
  border-radius: 8px;
  font-weight: 800;
  cursor: pointer;
}

.ghost-button { background: transparent; color: var(--ink); padding: 11px 14px; }
.dark-button { color: white; background: var(--ink); padding: 11px 16px; }
.primary-button, .download-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 20px;
  color: white;
  background: var(--red);
  box-shadow: 0 14px 30px rgba(215, 56, 50, .22);
}

.secondary-button {
  min-height: 48px;
  padding: 0 18px;
  color: var(--ink);
  background: #efe9df;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 520px);
  gap: 42px;
  align-items: center;
  padding: 74px 6vw 32px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--red);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1, h2 { margin: 0; letter-spacing: 0; }
h1 { max-width: 760px; font-size: clamp(42px, 6vw, 78px); line-height: .96; }
h2 { font-size: clamp(28px, 4vw, 44px); line-height: 1.04; }

.hero-text {
  max-width: 650px;
  color: var(--muted);
  font-size: 20px;
  line-height: 1.6;
}

.hero-actions { gap: 12px; flex-wrap: wrap; margin-top: 28px; }

.hero-visual {
  min-height: 430px;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 20% 20%, rgba(215,56,50,.12), transparent 28%),
    linear-gradient(135deg, #f2ede3, #fff);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.desktop-frame {
  width: min(88%, 460px);
  aspect-ratio: 1.16;
  background: #24262c;
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.frame-toolbar { display: flex; gap: 7px; margin-bottom: 18px; }
.frame-toolbar span { width: 10px; height: 10px; border-radius: 50%; background: #e6ded3; }
.doc-stack { position: relative; height: calc(100% - 28px); }
.doc-card { position: absolute; border-radius: 8px; background: white; box-shadow: 0 18px 42px rgba(0,0,0,.22); }
.doc-main { inset: 12px 84px 28px 18px; padding: 28px; }
.doc-side { right: 18px; top: 56px; width: 150px; height: 180px; padding: 22px; background: #f7c56f; }
.doc-chip { right: 42px; bottom: 22px; padding: 14px 18px; font-weight: 800; color: white; background: var(--teal); }
.doc-card b { display: block; margin-bottom: 22px; }
.doc-card span { display: block; height: 12px; margin: 12px 0; border-radius: 20px; background: #e9e4dc; }

.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 24px 56px;
}

.metrics div {
  padding: 24px;
  background: white;
  border: 1px solid var(--line);
}

.metrics strong { display: block; font-size: 30px; }
.metrics span { color: var(--muted); font-weight: 600; }

.tool-shell, .workflow, .trust-band, .premium {
  max-width: 1240px;
  margin: 0 auto 28px;
  padding: 44px 24px;
}

.section-head { justify-content: space-between; gap: 18px; margin-bottom: 24px; }
.search-wrap { width: min(100%, 340px); }
.search-wrap input {
  width: 100%;
  min-height: 48px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.filters { gap: 8px; flex-wrap: wrap; margin-bottom: 22px; }
.filter-button {
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--muted);
  font-weight: 800;
  cursor: pointer;
}
.filter-button.active { color: white; background: var(--ink); border-color: var(--ink); }

.tools-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.tool-card {
  min-height: 190px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  text-align: left;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.tool-card:hover { transform: translateY(-3px); border-color: rgba(215,56,50,.4); box-shadow: var(--shadow); }
.tool-top { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.tool-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  color: white;
  background: var(--red);
  font-weight: 900;
}
.tool-card:nth-child(3n) .tool-icon { background: var(--teal); }
.tool-card:nth-child(4n) .tool-icon { background: var(--gold); }
.tool-card:nth-child(5n) .tool-icon { background: var(--blue); }
.tool-badge { color: var(--muted); font-size: 12px; font-weight: 800; }
.tool-card h3 { margin: 0 0 9px; font-size: 18px; }
.tool-card p { margin: 0; color: var(--muted); line-height: 1.45; }
.engine-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  margin-top: 16px;
  padding: 0 9px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 900;
}
.engine-badge.live { color: #07564f; background: #d9f0ec; }
.engine-badge.backend { color: #6b3c00; background: #f8e3bd; }

.workflow, .trust-band, .premium {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: center;
  border-top: 1px solid var(--line);
}
.workflow p, .trust-band p, .premium p { color: var(--muted); line-height: 1.65; }
.workflow-steps { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.workflow-steps span, .trust-band li {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  font-weight: 800;
}
.trust-band ul { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.premium { margin-bottom: 56px; }

.tool-dialog {
  width: min(720px, calc(100vw - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}
.tool-dialog::backdrop { background: rgba(23,24,28,.46); backdrop-filter: blur(4px); }
.dialog-card { position: relative; padding: 28px; background: var(--surface); }
.close-button {
  position: absolute;
  right: 18px;
  top: 18px;
  width: 36px;
  height: 36px;
  background: #efe9df;
}
.dialog-head { display: flex; gap: 16px; padding-right: 34px; }
.dialog-head p:last-child { color: var(--muted); line-height: 1.5; }
.dropzone {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 150px;
  margin: 22px 0;
  border: 2px dashed #d8cfc3;
  border-radius: 8px;
  background: #fbfaf7;
  cursor: pointer;
}
.dropzone input { position: absolute; opacity: 0; pointer-events: none; }
.dropzone span { font-size: 20px; font-weight: 900; color: var(--red); }
.dropzone small { color: var(--muted); }
.file-list { display: grid; gap: 8px; margin-bottom: 16px; }
.file-row { display: flex; justify-content: space-between; gap: 10px; padding: 10px 12px; background: #f3eee6; border-radius: 8px; font-size: 13px; }
.settings-panel { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 18px; }
.setting { display: grid; gap: 7px; color: var(--muted); font-size: 13px; font-weight: 800; }
.setting input, .setting select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: white;
}
.full { width: 100%; }
.progress { height: 9px; overflow: hidden; border-radius: 20px; background: #f0e8de; margin-top: 16px; }
.progress span { display: block; width: 0; height: 100%; background: var(--teal); transition: width .3s ease; }
.status-text { min-height: 22px; color: var(--muted); font-weight: 700; }
.download-link { width: 100%; }

.editor-dialog {
  width: min(1400px, calc(100vw - 16px));
  height: min(940px, calc(100vh - 16px));
  padding: 0;
  border: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.editor-dialog::backdrop { background: rgba(23,24,28,.5); backdrop-filter: blur(4px); }
.editor-shell { height: 100%; background: #e9e9e9; }
.editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 22px;
  background: white;
  border-bottom: 1px solid #d7d7d7;
}
.editor-head h2 {
  flex: 1;
  text-align: center;
  color: #9aa2a9;
  font-size: clamp(24px, 3vw, 40px);
  line-height: 1.05;
}
.editor-open-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid #1e88e5;
  border-radius: 6px;
  color: #1e88e5;
  background: white;
  font-weight: 800;
  cursor: pointer;
}
.editor-open-button input { position: absolute; opacity: 0; pointer-events: none; }
.editor-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  padding: 20px;
  overflow: auto;
  border-right: 1px solid var(--line);
  background: white;
}
.editor-title { display: flex; gap: 12px; align-items: center; }
.editor-title h2 { font-size: 26px; }
.dropzone.compact { min-height: 112px; margin: 0; }
.editor-controls { display: flex; align-items: center; justify-content: center; gap: 0; flex-wrap: wrap; }
.editor-tool, .editor-upload {
  min-height: 42px;
  display: inline-grid;
  place-items: center;
  padding: 0 16px;
  border: 1px solid #1e88e5;
  border-radius: 0;
  background: white;
  color: #1e88e5;
  font-weight: 800;
  cursor: pointer;
}
.editor-tool:first-child { border-radius: 6px 0 0 6px; }
.editor-tool:last-child { border-radius: 0 6px 6px 0; }
.editor-tool.active { color: #0d5aa7; background: #eaf4ff; }
.editor-upload input { position: absolute; opacity: 0; pointer-events: none; }
.editor-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.editor-fields label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.editor-fields input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: white;
}
.editor-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.element-list { display: grid; gap: 8px; }
.element-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaf7;
  font-size: 12px;
  font-weight: 800;
}
.element-item.active { border-color: var(--red); box-shadow: 0 0 0 2px rgba(215,56,50,.14); }
.editor-stage { min-width: 0; display: grid; grid-template-rows: auto auto auto 1fr auto auto auto; height: 100%; }
.editor-topline {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 18px 18px 12px;
  background: #e9e9e9;
}
.page-controls, .editor-export { display: flex; align-items: center; gap: 0; flex-wrap: wrap; }
.page-controls label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; font-weight: 800; }
.editor-pagebar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 8px 18px 20px;
  background: #e9e9e9;
}
.editor-pagebar #pageLabel {
  min-width: 72px;
  color: #7bb8ef;
  font-size: 36px;
  font-weight: 800;
  text-align: right;
}
.editor-icon-button, .editor-insert-button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid #1e88e5;
  background: #f8fbff;
  color: #1e88e5;
  font-weight: 900;
  cursor: pointer;
}
.editor-icon-button:first-child { border-radius: 6px 0 0 6px; }
.editor-icon-button:last-child { border-radius: 0 6px 6px 0; }
.editor-insert-button { border-radius: 6px; font-size: 18px; }
.editor-zoom {
  min-height: 38px;
  padding: 0 12px;
  border-top: 1px solid #1e88e5;
  border-bottom: 1px solid #1e88e5;
  background: #f8fbff;
}
.editor-canvas-wrap {
  min-height: 0;
  overflow: auto;
  padding: 0 28px 84px;
  display: grid;
  place-items: start center;
  background: #e9e9e9;
}
.pdf-page-host {
  position: relative;
  background: white;
  box-shadow: 0 20px 70px rgba(23,24,28,.18);
}
#pdfCanvas { display: block; }
.overlay-layer { position: absolute; inset: 0; overflow: hidden; cursor: crosshair; }
.edit-element {
  position: absolute;
  min-width: 22px;
  min-height: 18px;
  border: 1px solid transparent;
  user-select: none;
  touch-action: none;
}
.source-text-mask {
  position: absolute;
  pointer-events: none;
}
.edit-element.selected {
  border-color: var(--red);
  outline: 2px solid rgba(215,56,50,.18);
}
.edit-element.text, .edit-element.link, .edit-element.signature, .edit-element.sourceText, .edit-element.comment {
  padding: 4px 6px;
  font-weight: 800;
  white-space: pre-wrap;
}
.edit-element.link { text-decoration: underline; }
.edit-element.signature { font-style: italic; }
.edit-element.sourceText {
  min-width: 0;
  min-height: 0;
  padding: 0;
  border-color: transparent;
  background: transparent;
  font-weight: 500;
  cursor: move;
}
.edit-element.sourceText:hover {
  border-color: rgba(51, 92, 159, .35);
  background: rgba(51, 92, 159, .08);
}
.edit-element.sourceText.selected {
  border-color: transparent;
  background: transparent;
  outline: 1px dashed rgba(215, 56, 50, .55);
  outline-offset: 3px;
}
.edit-element.sourceText.modified {
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  box-shadow: none;
  line-height: 1;
}
.edit-element.comment {
  background: #fff0a8;
  border-color: rgba(185,121,36,.28);
  color: var(--ink);
}
.edit-element.rect, .edit-element.highlight, .edit-element.whiteout, .edit-element.ellipse { border: 2px solid currentColor; }
.edit-element.highlight { background: rgba(255, 221, 67, .42); }
.edit-element.whiteout { border-color: #e5e5e5; }
.edit-element.ellipse { border-radius: 50%; }
.edit-element.line { height: 3px; min-height: 3px; background: currentColor; transform-origin: left center; }
.edit-element.image img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.edit-element.draw svg { width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.resize-handle {
  position: absolute;
  right: -6px;
  bottom: -6px;
  width: 12px;
  height: 12px;
  border: 2px solid white;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 1px 5px rgba(23,24,28,.28);
  cursor: nwse-resize;
}
.selection-toolbar {
  position: absolute;
  z-index: 9;
  display: flex;
  align-items: center;
  min-height: 46px;
  border: 1px solid #1e88e5;
  border-radius: 4px;
  background: white;
  box-shadow: 0 6px 18px rgba(30,136,229,.24);
  overflow: hidden;
}
.selection-toolbar[hidden] { display: none; }
.selection-toolbar button,
.selection-toolbar input {
  min-height: 46px;
  border: 0;
  border-right: 1px solid #1e88e5;
  border-radius: 0;
  background: white;
  color: #1e88e5;
  font-weight: 900;
}
.selection-toolbar button { min-width: 46px; cursor: pointer; }
.selection-toolbar input[type="number"] { width: 64px; padding: 0 8px; }
.selection-toolbar input[type="text"],
.selection-toolbar input:not([type]) { width: 170px; padding: 0 10px; color: var(--ink); font-weight: 700; }
.selection-toolbar input[type="color"] { width: 52px; padding: 8px; }
.selection-toolbar input[type="range"] { width: 86px; padding: 0 8px; }
.apply-bar {
  position: sticky;
  bottom: 0;
  z-index: 10;
  display: flex;
  justify-content: center;
  padding: 12px 18px;
  background: rgba(255,248,236,.88);
  border-top: 1px solid #eadfc8;
  backdrop-filter: blur(12px);
}
.apply-bar .primary-button {
  min-width: 220px;
  background: #18bf8f;
  box-shadow: 0 12px 30px rgba(24,191,143,.25);
  font-size: 20px;
}
.apply-bar .primary-button::after {
  content: "›";
  margin-left: 12px;
  font-size: 30px;
  line-height: 1;
}
.editor-stage .status-text, .editor-stage .download-link { margin: 0 18px 14px; }
.element-list { display: none; }

@media (max-width: 920px) {
  .topbar { padding: 0 18px; }
  .nav, .top-actions { display: none; }
  .hero, .workflow, .trust-band, .premium { grid-template-columns: 1fr; }
  .hero { padding-top: 48px; }
  .tools-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .editor-shell { grid-template-columns: 1fr; }
  .editor-dialog { height: calc(100vh - 16px); }
  .editor-sidebar { max-height: 44vh; border-right: 0; border-bottom: 1px solid var(--line); }
}

@media (max-width: 560px) {
  h1 { font-size: 42px; }
  .hero { padding-inline: 18px; }
  .hero-visual { min-height: 300px; }
  .tools-grid, .metrics, .settings-panel, .workflow-steps { grid-template-columns: 1fr; }
  .section-head { align-items: stretch; flex-direction: column; }
  .dialog-card { padding: 22px; }
}
