:root{
  --ink:#15213c;
  --muted:#66708a;
  --bg:#f6f7fb;
  --line:#e5e8f0;
  --brand:#b84044;
  --brand-dark:#9f3438;
  --soft:#fff3f3;
  --card:#ffffff;
  --ok:#0f8a4b;
  --danger:#d64545;
}

*{box-sizing:border-box}

html{scroll-behavior:smooth}

body{
  margin:0;
  background:var(--bg);
  color:var(--ink);
  font:15px "Segoe UI",Arial,Helvetica,sans-serif;
}

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

button,input,select{
  font:inherit;
}

.nav{
  width:min(1180px,calc(100% - 32px));
  min-height:74px;
  margin:auto;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:18px;
}

.logo{
  display:inline-flex;
  align-items:center;
  font-size:20px;
  font-weight:900;
}

.logo b{
  display:grid;
  place-items:center;
  width:35px;
  height:35px;
  margin-right:9px;
  border-radius:10px;
  background:var(--brand);
  color:#fff;
}

.nav span{
  color:var(--muted);
  font-size:13px;
}

.hero,
.head{
  text-align:center;
  padding:58px 20px 28px;
}

.tag{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:7px 11px;
  border-radius:999px;
  background:#f1e9ff;
  color:var(--brand);
  font-size:11px;
  font-weight:900;
  letter-spacing:.2px;
}

.hero h1{
  margin:18px 0 12px;
  font-size:clamp(40px,6vw,66px);
  line-height:1.03;
  letter-spacing:-3px;
}

.hero h1 em{
  color:var(--brand);
  font-style:normal;
}

.hero p,
.head p{
  max-width:660px;
  margin:0 auto;
  color:var(--muted);
  line-height:1.65;
}

.wrap{
  width:min(1180px,calc(100% - 32px));
  margin:30px auto 80px;
}

.label{
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap:20px;
  margin:38px 0 15px;
}

.label h2{
  margin:0;
  font-size:22px;
}

.label p{
  margin:0;
  color:var(--muted);
}

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

.card,
.panel{
  background:var(--card);
  border:1px solid var(--line);
  border-radius:18px;
}

.card{
  min-height:138px;
  padding:20px;
  transition:transform .18s ease,box-shadow .18s ease,border-color .18s ease;
}

.card:hover{
  transform:translateY(-4px);
  border-color:#e2cfd0;
  box-shadow:0 16px 34px rgba(21,33,60,.10);
}

.ico{
  display:grid;
  place-items:center;
  width:42px;
  height:42px;
  border-radius:13px;
  background:#f1efff;
  font-size:21px;
}

.card h3{
  margin:14px 0 6px;
  font-size:16px;
}

.card p{
  margin:0;
  color:var(--muted);
  font-size:13px;
  line-height:1.5;
}

.workspace{
  width:min(900px,calc(100% - 32px));
  margin:0 auto 80px;
}

.head h1{
  margin:14px 0 10px;
  font-size:clamp(30px,5vw,42px);
}

.panel{
  padding:26px;
}

.drop{
  min-height:225px;
  display:grid;
  place-items:center;
  text-align:center;
  padding:25px;
  border:2px dashed #d6bfc0;
  border-radius:16px;
  background:#fffafa;
  cursor:pointer;
  transition:border-color .16s ease,background .16s ease;
}

.drop:hover,
.drop.tph-dragover{
  border-color:var(--brand);
  background:#fff4f4;
}

.drop .big{
  font-size:38px;
}

.drop strong{
  display:block;
  margin:10px 0 4px;
  font-size:18px;
}

.drop p{
  margin:0 0 14px;
  color:var(--muted);
}

.btn{
  border:0;
  border-radius:10px;
  padding:12px 18px;
  background:var(--brand);
  color:#fff;
  font-weight:800;
  cursor:pointer;
  transition:background .16s ease,transform .16s ease,opacity .16s ease;
}

.btn:hover{
  background:var(--brand-dark);
  transform:translateY(-1px);
}

.btn:disabled{
  opacity:.55;
  cursor:not-allowed;
  transform:none;
}

.btn.alt{
  background:#f2e9ea;
  color:var(--brand);
}

.files{
  display:grid;
  gap:8px;
  margin-top:14px;
}

.file{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:11px 13px;
  border:1px solid var(--line);
  border-radius:10px;
  background:#fff;
  font-size:13px;
}

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

.file button{
  flex:0 0 auto;
  border:0;
  background:none;
  color:var(--danger);
  font-size:20px;
  cursor:pointer;
}

.options{
  display:flex;
  flex-wrap:wrap;
  justify-content:center;
  gap:12px;
  margin-top:18px;
}

.options label{
  display:flex;
  align-items:center;
  gap:8px;
  color:var(--muted);
  font-size:13px;
  font-weight:700;
}

.options input,
.options select{
  width:145px;
  padding:9px 10px;
  border:1px solid var(--line);
  border-radius:9px;
  background:#fff;
  color:var(--ink);
  outline:none;
}

.options input:focus,
.options select:focus{
  border-color:var(--brand);
  box-shadow:0 0 0 3px rgba(184,64,68,.10);
}

.actions{
  display:flex;
  flex-wrap:wrap;
  justify-content:center;
  gap:10px;
  margin-top:18px;
}

.note{
  margin:16px 0 0;
  text-align:center;
  color:var(--muted);
  font-size:12px;
}

.foot{
  padding:24px 16px;
  border-top:1px solid var(--line);
  text-align:center;
  color:var(--muted);
  font-size:12px;
}

@media(max-width:760px){
  .grid{
    grid-template-columns:1fr;
  }

  .nav span{
    display:none;
  }

  .panel{
    padding:16px;
  }

  .hero{
    padding-top:42px;
  }

  .label{
    align-items:flex-start;
    flex-direction:column;
    gap:4px;
  }

  .options{
    align-items:stretch;
    flex-direction:column;
  }

  .options label{
    justify-content:space-between;
    width:100%;
  }

  .options input,
  .options select{
    width:58%;
  }
}

/* =====================================================
   INTERACTIVE CROP PREVIEW
   ===================================================== */

.crop-workspace {
  width: min(1100px, calc(100% - 32px));
  margin: 0 auto 80px;
}

.crop-panel {
  padding: 22px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
}

.crop-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 16px 0;
}

.crop-toolbar label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.crop-toolbar select,
.crop-toolbar input {
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
}

.crop-preview-shell {
  min-height: 420px;
  display: grid;
  place-items: center;
  padding: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background:
    linear-gradient(45deg, #f2f3f7 25%, transparent 25%),
    linear-gradient(-45deg, #f2f3f7 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f2f3f7 75%),
    linear-gradient(-45deg, transparent 75%, #f2f3f7 75%);
  background-size: 22px 22px;
  background-position: 0 0, 0 11px, 11px -11px, -11px 0;
}

.crop-preview-shell img {
  display: block;
  max-width: 100%;
  max-height: 620px;
}

.crop-empty {
  max-width: 520px;
  text-align: center;
  color: var(--muted);
}

.crop-empty .big {
  margin-bottom: 8px;
  font-size: 44px;
}

.crop-file-name {
  max-width: 100%;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crop-status {
  min-height: 22px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.crop-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 18px;
}

.crop-actions .btn.secondary {
  background: #eef0f5;
  color: var(--ink);
}

.crop-actions .btn.danger {
  background: #f7e8e8;
  color: var(--danger);
}

.crop-info {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.crop-info div {
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fafbfe;
  text-align: center;
}

.crop-info b {
  display: block;
  margin-bottom: 3px;
  font-size: 12px;
}

.crop-info span {
  color: var(--muted);
  font-size: 12px;
}

.cropper-view-box,
.cropper-face {
  border-radius: 2px;
}

.cropper-line,
.cropper-point {
  background-color: var(--brand) !important;
}

.cropper-view-box {
  outline: 2px solid var(--brand) !important;
  outline-color: var(--brand) !important;
}

@media (max-width: 700px) {
  .crop-panel {
    padding: 14px;
  }

  .crop-preview-shell {
    min-height: 330px;
    padding: 10px;
  }

  .crop-info {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .crop-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .crop-toolbar label {
    justify-content: space-between;
  }

  .crop-toolbar select,
  .crop-toolbar input {
    width: 58%;
  }
}


/* =====================================================
   IMAGE TO PDF — DRAG REORDER
   ===================================================== */

.sortable-grid{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:14px;
  margin-top:18px;
}

.sortable-card{
  position:relative;
  padding:10px;
  border:1px solid var(--line);
  border-radius:14px;
  background:#fff;
  cursor:grab;
  user-select:none;
  transition:transform .16s ease,box-shadow .16s ease,border-color .16s ease,opacity .16s ease;
}

.sortable-card:active{
  cursor:grabbing;
}

.sortable-card.dragging{
  opacity:.55;
  transform:scale(.98);
}

.sortable-card.drag-over{
  border-color:var(--brand);
  box-shadow:0 0 0 3px rgba(184,64,68,.10);
}

.sortable-thumb{
  width:100%;
  aspect-ratio:4/3;
  overflow:hidden;
  border-radius:10px;
  background:#f3f4f8;
}

.sortable-thumb img{
  width:100%;
  height:100%;
  display:block;
  object-fit:cover;
}

.sortable-meta{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  margin-top:9px;
}

.sortable-name{
  min-width:0;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  color:var(--ink);
  font-size:12px;
  font-weight:700;
}

.sortable-index{
  flex:0 0 auto;
  display:grid;
  place-items:center;
  width:26px;
  height:26px;
  border-radius:999px;
  background:var(--soft);
  color:var(--brand);
  font-size:11px;
  font-weight:900;
}

.sortable-remove{
  position:absolute;
  top:8px;
  right:8px;
  width:29px;
  height:29px;
  border:0;
  border-radius:999px;
  background:rgba(255,255,255,.94);
  color:var(--danger);
  font-size:18px;
  font-weight:800;
  cursor:pointer;
  box-shadow:0 4px 12px rgba(0,0,0,.10);
}

.sort-help{
  margin:12px 0 0;
  text-align:center;
  color:var(--muted);
  font-size:12px;
}

@media(max-width:760px){
  .sortable-grid{
    grid-template-columns:repeat(2,minmax(0,1fr));
  }
}

@media(max-width:460px){
  .sortable-grid{
    grid-template-columns:1fr;
  }
}


/* =====================================================
   MERGE PDF — DRAG REORDER
   ===================================================== */

.pdf-sortable-grid{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:14px;
  margin-top:18px;
}

.pdf-sortable-card{
  position:relative;
  padding:14px;
  border:1px solid var(--line);
  border-radius:14px;
  background:#fff;
  cursor:grab;
  user-select:none;
  transition:transform .16s ease,box-shadow .16s ease,border-color .16s ease,opacity .16s ease;
}

.pdf-sortable-card:active{
  cursor:grabbing;
}

.pdf-sortable-card.dragging{
  opacity:.55;
  transform:scale(.98);
}

.pdf-sortable-card.drag-over{
  border-color:var(--brand);
  box-shadow:0 0 0 3px rgba(184,64,68,.10);
}

.pdf-sortable-icon{
  display:grid;
  place-items:center;
  width:100%;
  aspect-ratio:4/3;
  border-radius:10px;
  background:linear-gradient(135deg,#fff4f4,#f4f1ff);
  font-size:54px;
}

.pdf-sortable-meta{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  margin-top:10px;
}

.pdf-sortable-name{
  min-width:0;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  color:var(--ink);
  font-size:12px;
  font-weight:700;
}

.pdf-sortable-index{
  flex:0 0 auto;
  display:grid;
  place-items:center;
  width:27px;
  height:27px;
  border-radius:999px;
  background:var(--soft);
  color:var(--brand);
  font-size:11px;
  font-weight:900;
}

.pdf-sortable-size{
  margin-top:5px;
  color:var(--muted);
  font-size:11px;
}

.pdf-sortable-remove{
  position:absolute;
  top:8px;
  right:8px;
  width:29px;
  height:29px;
  border:0;
  border-radius:999px;
  background:rgba(255,255,255,.95);
  color:var(--danger);
  font-size:18px;
  font-weight:800;
  cursor:pointer;
  box-shadow:0 4px 12px rgba(0,0,0,.10);
}

@media(max-width:760px){
  .pdf-sortable-grid{
    grid-template-columns:repeat(2,minmax(0,1fr));
  }
}

@media(max-width:460px){
  .pdf-sortable-grid{
    grid-template-columns:1fr;
  }
}


/* =====================================================
   DELETE / REORDER PDF OPTIONS
   ===================================================== */

.option-help{
  width:100%;
  max-width:620px;
  margin:14px auto 0;
  padding:12px 14px;
  border:1px solid var(--line);
  border-radius:11px;
  background:#fafbfe;
  color:var(--muted);
  font-size:12px;
  line-height:1.6;
  text-align:left;
}

.option-help code{
  padding:2px 6px;
  border-radius:6px;
  background:#f2e9ea;
  color:var(--brand);
  font-family:Consolas,monospace;
  font-weight:700;
}

.page-count{
  margin-top:12px;
  color:var(--muted);
  font-size:13px;
  text-align:center;
}

.options.single-wide label{
  width:min(620px,100%);
  justify-content:center;
}

.options.single-wide input{
  width:min(430px,70vw);
}


/* =====================================================
   ADVANCED TOOL UI
   ===================================================== */

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

.page-card{
  position:relative;
  padding:10px;
  border:1px solid var(--line);
  border-radius:14px;
  background:#fff;
  cursor:grab;
  user-select:none;
  transition:.16s ease;
}

.page-card.dragging{
  opacity:.5;
  transform:scale(.98);
}

.page-card.drag-over{
  border-color:var(--brand);
  box-shadow:0 0 0 3px rgba(184,64,68,.10);
}

.page-card canvas,
.page-card img{
  width:100%;
  height:auto;
  display:block;
  border-radius:9px;
  background:#f3f4f8;
}

.page-card-meta{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  margin-top:8px;
}

.page-card-meta span{
  font-size:12px;
  font-weight:800;
}

.page-card-actions{
  display:flex;
  gap:6px;
  margin-top:8px;
}

.page-card-actions button{
  flex:1;
  border:0;
  border-radius:8px;
  padding:7px;
  background:#f2e9ea;
  color:var(--brand);
  font-size:12px;
  font-weight:800;
  cursor:pointer;
}

.preview-box{
  display:grid;
  grid-template-columns:1.1fr .9fr;
  gap:18px;
  margin-top:18px;
}

.preview-pane{
  padding:14px;
  border:1px solid var(--line);
  border-radius:14px;
  background:#fff;
}

.preview-pane h3{
  margin:0 0 10px;
  font-size:15px;
}

.preview-pane img,
.preview-pane canvas{
  max-width:100%;
  display:block;
  margin:auto;
  border-radius:10px;
  background:#f3f4f8;
}

.metric-grid{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:10px;
  margin-top:14px;
}

.metric{
  padding:12px;
  border:1px solid var(--line);
  border-radius:10px;
  background:#fafbfe;
  text-align:center;
}

.metric b{
  display:block;
  margin-bottom:4px;
  font-size:12px;
}

.metric span{
  color:var(--muted);
  font-size:12px;
}

.progress-wrap{
  margin-top:16px;
}

.progress-track{
  width:100%;
  height:12px;
  overflow:hidden;
  border-radius:999px;
  background:#eceef3;
}

.progress-bar{
  width:0%;
  height:100%;
  background:linear-gradient(90deg,var(--brand),#e36f73);
  transition:width .18s ease;
}

.progress-text{
  margin-top:6px;
  color:var(--muted);
  font-size:12px;
  text-align:center;
}

.inline-check{
  display:flex;
  align-items:center;
  gap:8px;
  color:var(--muted);
  font-size:13px;
  font-weight:700;
}

.inline-check input{
  width:auto !important;
}

.range-row{
  display:flex;
  flex-wrap:wrap;
  justify-content:center;
  gap:10px;
  margin-top:16px;
}

.range-row label{
  display:flex;
  align-items:center;
  gap:8px;
  color:var(--muted);
  font-size:13px;
  font-weight:700;
}

.range-row input{
  width:120px;
  padding:9px 10px;
  border:1px solid var(--line);
  border-radius:9px;
}

@media(max-width:900px){
  .advanced-grid{grid-template-columns:repeat(3,minmax(0,1fr))}
  .preview-box{grid-template-columns:1fr}
}

@media(max-width:650px){
  .advanced-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
  .metric-grid{grid-template-columns:1fr}
}

@media(max-width:420px){
  .advanced-grid{grid-template-columns:1fr}
}
