* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, "Noto Sans Devanagari", sans-serif;
  color: #17211d;
  background: #e9e9e9;
}

.editor-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 52px;
  padding: 0 18px;
  border-bottom: 1px solid #d7dce2;
  background: #fff;
}

.editor-header a {
  color: #0d8a68;
  font-weight: 800;
  text-decoration: none;
}

.editor-header span {
  color: #67736f;
  font-size: 0.9rem;
}

.editor-app {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) 150px;
  gap: 12px;
  padding: 12px;
}

.editor-app.is-locked {
  pointer-events: none;
  opacity: 0.45;
}

.editor-workspace {
  min-width: 0;
}

.top-ad,
.bottom-ad,
.side-ad {
  display: grid;
  place-items: center;
  border: 1px dashed #9fb5ac;
  background: #fff;
  color: #65736e;
  font-weight: 800;
}

.top-ad,
.bottom-ad {
  min-height: 90px;
  margin-bottom: 10px;
}

.bottom-ad {
  margin-top: 10px;
}

.side-ad {
  min-height: calc(100vh - 90px);
}

.upload-strip,
.toolbar,
.page-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px;
  background: #fff;
  border: 1px solid #cfd8df;
}

.toolbar {
  align-items: stretch;
  gap: 10px;
  background: #ededed;
}

.tool-group {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0;
  overflow: hidden;
  border: 1px solid #168cc2;
  border-radius: 3px;
  background: #fff;
}

.upload-strip label span,
.toolbar button,
.page-bar button,
.page-bar a,
.apply-bar button,
.video-box button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border: 1px solid #168cc2;
  border-radius: 3px;
  padding: 0 12px;
  background: #fff;
  color: #25426d;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.toolbar button {
  min-height: 32px;
  border-width: 0 1px 0 0;
  border-radius: 0;
  font-size: 0.84rem;
}

.tool-group button:last-child {
  border-right: 0;
}

.text-options {
  gap: 6px;
  border-color: #cfd8df;
  padding: 4px;
}

.shape-group {
  gap: 6px;
  padding: 4px 8px;
}

.shape-group label {
  color: #25426d;
  font-size: 0.84rem;
  font-weight: 800;
}

.shape-group select {
  min-height: 30px;
  border: 1px solid #cfd8df;
  color: #25426d;
  font-weight: 700;
}

.signature-ready {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 1px solid #0d8a68;
  border-radius: 4px;
  padding: 5px 8px;
  background: #eefaf6;
  color: #0d624d;
  font-weight: 800;
}

.signature-ready[hidden] {
  display: none;
}

.signature-ready img {
  max-width: 120px;
  max-height: 42px;
  object-fit: contain;
}

.upload-strip input,
#imageInput {
  display: none;
}

.toolbar button.active {
  background: #3151a4;
  color: #fff;
}

.toolbar select,
.toolbar input {
  min-height: 34px;
  border: 1px solid #cfd8df;
}

#statusText {
  margin: 0;
  color: #65736e;
}

.canvas-wrap {
  position: relative;
  display: grid;
  justify-items: center;
  min-height: 70vh;
  overflow: auto;
  padding: 26px;
  background: #dedede;
}

.text-mini-toolbar {
  position: absolute;
  z-index: 8;
  display: inline-flex;
  align-items: center;
  gap: 0;
  overflow: hidden;
  border: 1px solid #168cc2;
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
}

.text-mini-toolbar[hidden] {
  display: none;
}

.text-mini-toolbar button,
.text-mini-toolbar select,
.text-mini-toolbar input {
  min-height: 30px;
  border: 0;
  border-right: 1px solid #168cc2;
  background: #fff;
  color: #25426d;
  font-weight: 800;
}

.text-mini-toolbar button.active {
  background: #e9f4ff;
  color: #0b65a3;
}

.text-mini-toolbar input[type="color"] {
  width: 34px;
  padding: 2px;
}

#pdfCanvas {
  background: #fff;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.18);
  touch-action: pan-x pan-y pinch-zoom;
  cursor: crosshair;
}

#pdfCanvas.editing-touch {
  touch-action: none;
}

.apply-bar {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 14px;
  background: #fff7df;
  border: 1px solid #ead7a4;
}

#applyBtn,
#insertBottomBtn {
  min-width: 190px;
}

#applyBtn {
  background: #0d8a68;
  color: #fff;
  border-color: #0d8a68;
}

.video-gate {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.64);
}

.video-gate[hidden] {
  display: none;
}

.video-box {
  width: min(560px, 100%);
  border-radius: 8px;
  padding: 24px;
  background: #fff;
  text-align: center;
}

.video-box p {
  color: #0d8a68;
  font-weight: 900;
  text-transform: uppercase;
}

.video-placeholder {
  display: grid;
  place-items: center;
  min-height: 250px;
  margin: 18px 0;
  border: 1px dashed #aebdc6;
  border-radius: 8px;
  background: linear-gradient(135deg, #fff7e1, #eef7ff);
  color: #65736e;
  font-weight: 900;
}

.video-box button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.signature-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.62);
}

.signature-modal[hidden] {
  display: none;
}

.processing-modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.58);
}

.processing-modal[hidden] {
  display: none;
}

.processing-box {
  width: min(420px, 100%);
  border-radius: 8px;
  padding: 22px;
  background: #fff;
  text-align: center;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.22);
}

.loader-bar {
  overflow: hidden;
  height: 9px;
  margin-top: 16px;
  border-radius: 999px;
  background: #e6edf1;
}

.loader-bar span {
  display: block;
  width: 45%;
  height: 100%;
  border-radius: inherit;
  background: #0d8a68;
  animation: loading-slide 1.1s infinite ease-in-out;
}

@keyframes loading-slide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(230%); }
}

.signature-box {
  position: relative;
  width: min(720px, 100%);
  max-height: 90vh;
  overflow: auto;
  border-radius: 8px;
  padding: 22px;
  background: #fff;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
}

.signature-tabs,
.signature-colors,
.signature-samples {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 12px 0;
}

.signature-tabs button,
.signature-colors button,
#saveSignatureBtn,
#clearSignatureDraw {
  min-height: 36px;
  border: 1px solid #cfd8df;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
}

.signature-colors button {
  width: 28px;
  height: 28px;
  border-radius: 999px;
}

.signature-samples button {
  min-width: 180px;
  min-height: 54px;
  border: 1px solid transparent;
  background: #f8fbff;
  font-size: 1.55rem;
  cursor: pointer;
}

#signatureText {
  width: 100%;
  min-height: 42px;
  border: 1px solid #cfd8df;
  padding: 0 12px;
}

#signatureDrawCanvas {
  width: 100%;
  border: 1px solid #d7dce2;
  background: #fff;
  touch-action: none;
}

@media (max-width: 900px) {
  body {
    overflow-x: hidden;
  }

  .editor-app {
    grid-template-columns: 1fr;
  }

  .side-ad {
    display: none;
  }

  .top-ad {
    display: none;
  }

  .bottom-ad {
    min-height: auto;
    margin: 8px 0 0;
    padding: 10px;
    font-size: 0.82rem;
  }

  .editor-header {
    gap: 6px;
    padding: 8px 10px;
    font-size: 0.86rem;
  }

  .upload-strip {
    justify-content: flex-start;
    padding: 8px 10px;
  }

  .upload-strip p {
    flex-basis: 100%;
    text-align: left;
  }

  .toolbar {
    position: sticky;
    top: 0;
    z-index: 20;
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .tool-group {
    flex: 0 0 auto;
    flex-wrap: nowrap;
  }

  .toolbar button,
  .toolbar select {
    min-height: 40px;
    font-size: 0.9rem;
    white-space: nowrap;
  }

  .canvas-wrap {
    min-height: calc(100vh - 190px);
    padding: 8px 4px;
    touch-action: pan-y;
    align-items: start;
  }

  #pdfCanvas {
    width: 100%;
    height: auto;
    max-width: 100%;
    box-shadow: none;
  }

  .text-mini-toolbar {
    position: fixed;
    left: 8px !important;
    right: 8px;
    top: auto !important;
    bottom: 10px;
    overflow-x: auto;
    z-index: 40;
  }
}
