@font-face {
  font-family: "Noto Sans Bengali";
  src: url("/fonts/NotoSansBengali-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
:root { color-scheme: light; --ink: #202326; --muted: #687078; --line: #e4e6ea; --green: #006a4e; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: transparent;
  color: var(--ink);
  font: 16px/1.5 "Times New Roman", Times, serif;
}
button, input, select, textarea { font: inherit; color: inherit; }
.file-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 168px;
  border: 1px dashed transparent;
  border-radius: 16px;
  padding: 12px;
}
.file-drop.dragover { border-color: #168264; background: #e9f3ef; }
.select-file {
  width: min(340px, 88vw);
  height: 76px;
  border: 0;
  border-radius: 11px;
  background: #006a4e;
  color: #fff;
  font-weight: 700;
  font-size: 1.2rem;
  cursor: pointer;
}
.select-file:hover { background: #00583f; }
.drop-hint { margin: 0; color: #666e76; text-align: center; }
.work { padding-top: 4px; }
.summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e8eaed;
  font-weight: 700;
}
.summary span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(230px, 320px);
  gap: 18px;
  align-items: start;
}
.layout:not(:has(#previewColumn:not([hidden]))) { grid-template-columns: minmax(0, 680px); }
.stage-wrap { min-width: 0; }
.page-bar, .tool-row, .option-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 0 0 10px;
}
.page-bar { justify-content: space-between; }
.page-label { color: var(--muted); }
.stage {
  position: relative;
  width: fit-content;
  max-width: 100%;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 4px 18px #1018200a;
  overflow: hidden;
  touch-action: none;
}
.stage canvas { display: block; width: auto; height: auto; max-width: 100%; max-height: 72vh; }
.overlay { position: absolute; inset: 0; }
.ann { position: absolute; box-sizing: border-box; }
.ann.selected { outline: 2px solid var(--green); outline-offset: 1px; }
.ann-text, .ann-note {
  font-family: "Noto Sans Bengali", "Times New Roman", Times, serif;
  line-height: 1.35;
  white-space: pre-wrap;
  overflow: hidden;
  cursor: text;
}
.ann-text:empty::before { content: attr(data-placeholder); color: #8b939a; }
.ann-note {
  background: #fff4a8;
  border: 1px solid #e2c85a;
  padding: 6px 8px;
  box-shadow: 0 2px 8px #10182014;
}
.ann-highlight { background: rgba(255, 226, 40, .38); }
.ann-ink, .ann-ink svg, .ann-image img { width: 100%; height: 100%; display: block; }
.ann-ink svg { overflow: visible; }
.ann-image img { object-fit: fill; pointer-events: none; }
.resize, .ann-delete { position: absolute; }
.resize {
  right: -6px;
  bottom: -6px;
  width: 12px;
  height: 12px;
  background: var(--green);
  border: 2px solid #fff;
  border-radius: 2px;
  cursor: nwse-resize;
}
.ann-delete {
  top: -12px;
  right: -12px;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: #202326;
  color: #fff;
  cursor: pointer;
  line-height: 22px;
  padding: 0;
}
.ghost {
  position: absolute;
  border: 1px dashed #006a4e;
  background: rgba(255, 226, 40, .25);
  pointer-events: none;
}
form.options { margin: 0; }
.options {
  display: grid;
  gap: 10px;
  padding: 14px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
}
.hint { margin: 0; color: var(--muted); font-size: .92rem; line-height: 1.7; text-align: justify; text-justify: inter-word; overflow-wrap: break-word; hyphens: auto; }
label.field { display: grid; gap: 4px; font-size: .95rem; }
input[type="text"], input[type="password"], input[type="number"], select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #d2d6db;
  border-radius: 8px;
  background: #fff;
}
input[type="color"] { width: 42px; height: 32px; padding: 0; border: 1px solid #d2d6db; background: #fff; }
input[type="range"] { width: 100%; padding: 8px 0; }
.action, .minor {
  border-radius: 9px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 700;
}
.action { border: 0; background: #006a4e; color: #fff; }
.action:hover:not(:disabled) { background: #00583f; }
.action:disabled { background: #8aa99e; cursor: wait; }
.minor { border: 1px solid #b7cdc4; background: #fff; color: var(--green); }
.minor:hover { border-color: var(--green); }
.minor:disabled { opacity: .45; cursor: not-allowed; }
.tool-btn[aria-pressed="true"] { background: #006a4e; color: #fff; border-color: #006a4e; }
.status { min-height: 1.4em; margin: 0; color: var(--muted); }
.download { color: #12634e; font-weight: 700; overflow-wrap: anywhere; }
.sign-pad {
  width: 100%;
  height: 140px;
  border: 1px solid #d2d6db;
  border-radius: 8px;
  background: #fff;
  touch-action: none;
  cursor: crosshair;
}
.organize {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(138px, 1fr));
  gap: 12px;
}
.page-card {
  padding: 8px;
  border: 1px solid #e3e6e9;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 3px 12px #1018200a;
  text-align: center;
}
.page-card.drop-target { border-color: #087653; box-shadow: 0 0 0 2px #08765333; }
.page-card canvas { width: 100%; height: auto; background: #fff; border: 1px solid #eef0f1; }
.page-card .card-actions { display: flex; justify-content: center; gap: 6px; margin-top: 6px; }
.thumb-label { display: block; margin-top: 4px; font-size: .9rem; }
.image-list { display: grid; gap: 8px; }
.image-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid #e4e6e9;
  border-radius: 9px;
  background: #fff;
}
.image-row strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
textarea.ocr-text { min-height: 220px; resize: vertical; font-family: "Noto Sans Bengali", "Times New Roman", Times, serif; }
.choice { display: flex; gap: 14px; align-items: center; }
@media (max-width: 700px) {
  .layout { grid-template-columns: 1fr; }
  .select-file { height: 68px; }
}


/* Editable PDF content selection and visual replacement */
.source-text-hit {
  position:absolute;
  z-index:3;
  border:1px dashed rgba(0,106,78,.65);
  background:rgba(0,106,78,.08);
  border-radius:2px;
  cursor:text;
  padding:0;
  color:transparent;
  outline-offset:2px;
}
.source-text-hit:hover,.source-text-hit:focus-visible{
  border-color:#006a4e;
  background:rgba(0,106,78,.2);
  outline:2px solid #006a4e;
}
.ann-replacement {
  background:#fff;
  outline:1px dashed #006a4e;
  padding:0 2px;
}
.ann-cover { background:#fff; border:1px dashed #9da5a4; }
.secure-choice{align-items:flex-start;gap:8px;font-size:.9rem;}
.secure-choice input{flex:none;margin-top:5px;}
#replaceWarning{font-size:.85rem;}
@media (max-width:700px){
  .source-text-hit{min-height:12px;}
  .tool-row .tool-btn{flex:1 1 auto;}
}


/* PDF editing controls remain usable without sideways scrolling on phones. */
@media(max-width:700px){
  html,body{max-width:100%;overflow-x:clip}
  .work,.layout,.stage-wrap,.options,.organize,.image-list{min-width:0;max-width:100%}
  .layout{grid-template-columns:minmax(0,1fr);gap:12px}
  .summary{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:8px;margin-bottom:9px}
  .summary span{min-width:0;white-space:normal;overflow-wrap:anywhere;text-overflow:clip;line-height:1.3}
  .file-drop{min-height:110px;padding:8px}
  .select-file{max-width:100%;height:62px;font-size:1.05rem}
  .options{padding:11px;gap:8px}
  .hint{line-height:1.5;text-align:left;hyphens:none}
  .page-bar,.tool-row,.option-row{gap:6px;margin-bottom:8px}
  .page-bar .minor,.tool-row .minor,.tool-row .action{min-width:0;white-space:normal;padding:9px 10px;font-size:.9rem}
  .page-label{min-width:0;overflow-wrap:anywhere;text-align:center;font-size:.86rem}
  .tool-row .tool-btn{flex:1 1 31%;min-width:0}
  .organize{grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
  .page-card{min-width:0;padding:6px}
  .page-card .card-actions{flex-wrap:wrap;gap:5px}
  .page-card .card-actions button{font-size:.85rem;padding:7px 9px}
  .image-row{min-width:0;flex-wrap:wrap}
  .image-row strong{min-width:0;max-width:100%;white-space:normal;overflow-wrap:anywhere;text-overflow:clip}
  .sign-pad{width:100%;max-width:100%}
}
